xref: /core/sd/source/ui/view/outlnvsh.cxx (revision 412215fb)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <OutlineViewShell.hxx>
21 
22 #include <ViewShellImplementation.hxx>
23 #include <helpids.h>
24 #include <app.hrc>
25 #include <svx/hyperdlg.hxx>
26 #include <svx/zoomslideritem.hxx>
27 #include <svx/svdundo.hxx>
28 
29 #include <sfx2/infobar.hxx>
30 #include <sfx2/objface.hxx>
31 #include <sot/exchange.hxx>
32 #include <svx/ruler.hxx>
33 #include <sfx2/zoomitem.hxx>
34 #include <editeng/editview.hxx>
35 #include <editeng/eeitem.hxx>
36 #include <editeng/flditem.hxx>
37 #include <sfx2/shell.hxx>
38 #include <sfx2/templdlg.hxx>
39 #include <sfx2/viewfac.hxx>
40 #include <sfx2/request.hxx>
41 #include <svx/hlnkitem.hxx>
42 #include <svx/svdotext.hxx>
43 #include <sfx2/dispatch.hxx>
44 #include <vcl/scrbar.hxx>
45 #include <vcl/settings.hxx>
46 
47 #include <sal/log.hxx>
48 #include <svl/whiter.hxx>
49 #include <editeng/editstat.hxx>
50 #include <svl/itempool.hxx>
51 #include <sfx2/tplpitem.hxx>
52 #include <sfx2/sidebar/SidebarChildWindow.hxx>
53 #include <vcl/EnumContext.hxx>
54 #include <svx/svdorect.hxx>
55 #include <sot/formats.hxx>
56 #include <com/sun/star/linguistic2/XThesaurus.hpp>
57 #include <editeng/unolingu.hxx>
58 #include <editeng/outlobj.hxx>
59 #include <svl/cjkoptions.hxx>
60 #include <svtools/cliplistener.hxx>
61 #include <svl/srchitem.hxx>
62 #include <editeng/editobj.hxx>
63 #include <fubullet.hxx>
64 #include <optsitem.hxx>
65 
66 #include <strings.hrc>
67 
68 #include <Outliner.hxx>
69 #include <Window.hxx>
70 #include <TextObjectBar.hxx>
71 #include <drawdoc.hxx>
72 #include <sdresid.hxx>
73 #include <sdpage.hxx>
74 #include <fuoltext.hxx>
75 #include <FrameView.hxx>
76 #include <zoomlist.hxx>
77 #include <stlsheet.hxx>
78 #include <slideshow.hxx>
79 #include <SdUnoOutlineView.hxx>
80 #include <SpellDialogChildWindow.hxx>
81 
82 #include <AccessibleOutlineView.hxx>
83 #include <ViewShellBase.hxx>
84 #include <ViewShellManager.hxx>
85 #include <DrawController.hxx>
86 #include <framework/FrameworkHelper.hxx>
87 
88 #include <memory>
89 
90 using namespace ::com::sun::star;
91 using namespace ::com::sun::star::uno;
92 using namespace ::com::sun::star::lang;
93 using namespace ::com::sun::star::linguistic2;
94 
95 using namespace sd;
96 
97 #define ShellClass_OutlineViewShell
98 #include <sdslots.hxx>
99 
100 namespace sd {
101 
102 #define MIN_ZOOM           10      // minimum zoom factor
103 #define MAX_ZOOM         1000      // maximum zoom factor
104 
105 /**
106  * Declare SFX-Slotmap and standard interface
107  */
108 SFX_IMPL_INTERFACE(OutlineViewShell, SfxShell)
109 
110 void OutlineViewShell::InitInterface_Impl()
111 {
112     GetStaticInterface()->RegisterPopupMenu("outline");
113 
114     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS, SfxVisibilityFlags::Standard | SfxVisibilityFlags::FullScreen | SfxVisibilityFlags::Server,
115                                             ToolbarId::Outline_Toolbox);
116     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Client | SfxVisibilityFlags::Viewer | SfxVisibilityFlags::ReadonlyDoc,
117                                             ToolbarId::Draw_Viewer_Toolbox);
118 
119     GetStaticInterface()->RegisterChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
120     GetStaticInterface()->RegisterChildWindow(SvxHlinkDlgWrapper::GetChildWindowId());
121     GetStaticInterface()->RegisterChildWindow(::sd::SpellDialogChildWindow::GetChildWindowId());
122     GetStaticInterface()->RegisterChildWindow(SID_SEARCH_DLG);
123     GetStaticInterface()->RegisterChildWindow(::sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
124 }
125 
126 
127 /**
128  * common initialization part of both constructors
129  */
130 void OutlineViewShell::Construct()
131 {
132     bool bModified = GetDoc()->IsChanged();
133 
134     meShellType = ST_OUTLINE;
135     Size aSize(29700, 21000);
136     Point aWinPos (0, 0);
137     Point aViewOrigin(0, 0);
138     GetActiveWindow()->SetMinZoomAutoCalc(false);
139     GetActiveWindow()->SetMinZoom( MIN_ZOOM );
140     GetActiveWindow()->SetMaxZoom( MAX_ZOOM );
141     InitWindows(aViewOrigin, aSize, aWinPos);
142     pOlView.reset( new OutlineView(*GetDocSh(), GetActiveWindow(), *this) );
143     mpView = pOlView.get();            // Pointer of base class ViewShell
144 
145     SetPool( &GetDoc()->GetPool() );
146 
147     SetZoom(69);
148 
149     // Apply settings of FrameView
150     ReadFrameViewData(mpFrameView);
151 
152     ::Outliner& rOutl = pOlView->GetOutliner();
153     rOutl.SetUpdateMode(true);
154 
155     if (!bModified)
156     {
157         rOutl.ClearModifyFlag();
158     }
159 
160     pLastPage = GetActualPage();
161 
162     SetName( "OutlineViewShell" );
163 
164     GetActiveWindow()->SetHelpId( HID_SDOUTLINEVIEWSHELL );
165 }
166 
167 Reference<drawing::XDrawSubController> OutlineViewShell::CreateSubController()
168 {
169     Reference<drawing::XDrawSubController> xSubController;
170 
171     if (IsMainViewShell())
172     {
173         // Create uno sub controller for the main view shell.
174         xSubController.set( new SdUnoOutlineView(*this) );
175     }
176 
177     return xSubController;
178 }
179 
180 /**
181  * Default constructor, windows must not center themselves automatically
182  */
183 OutlineViewShell::OutlineViewShell (
184     SfxViewFrame* /*pFrame*/,
185     ViewShellBase& rViewShellBase,
186     vcl::Window* pParentWindow,
187     FrameView* pFrameViewArgument)
188     : ViewShell(pParentWindow, rViewShellBase),
189       pOlView(nullptr),
190       pLastPage( nullptr ),
191       bPastePossible(false),
192       mbInitialized(false)
193 
194 {
195     if (pFrameViewArgument != nullptr)
196         mpFrameView = pFrameViewArgument;
197     else
198         mpFrameView = new FrameView(GetDoc());
199 
200     mpFrameView->Connect();
201 
202     Construct();
203 
204     SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::OutlineText));
205 
206     m_StrOldPageName.clear();
207 
208     doShow();
209 }
210 
211 OutlineViewShell::~OutlineViewShell()
212 {
213     DisposeFunctions();
214 
215     pOlView.reset();
216 
217     mpFrameView->Disconnect();
218 
219     if ( mxClipEvtLstnr.is() )
220     {
221         mxClipEvtLstnr->RemoveListener( GetActiveWindow() );
222         mxClipEvtLstnr->ClearCallbackLink();     // prevent callback if another thread is waiting
223     }
224 }
225 
226 void OutlineViewShell::Shutdown()
227 {
228     ViewShell::Shutdown();
229 
230     PrepareClose();
231 }
232 
233 /**
234  * Paint method: the event gets forwarded from pWindow to the Viewshell
235  * and the current function
236  */
237 void OutlineViewShell::Paint(const ::tools::Rectangle& rRect, ::sd::Window* pWin)
238 {
239     if (pOlView)
240     {
241         pOlView->Paint(rRect, pWin);
242     }
243 }
244 
245 void OutlineViewShell::ArrangeGUIElements ()
246 {
247     // Retrieve the current size (thickness) of the scroll bars.  That is
248     // the width of the vertical and the height of the horizontal scroll
249     // bar.
250     int nScrollBarSize =
251         GetParentWindow()->GetSettings().GetStyleSettings().GetScrollBarSize();
252     maScrBarWH = Size (nScrollBarSize, nScrollBarSize);
253 
254     ViewShell::ArrangeGUIElements ();
255 
256     ::sd::Window* pWindow = mpContentWindow.get();
257     if (pWindow != nullptr)
258     {
259         pWindow->SetMinZoomAutoCalc(false);
260 
261         // change OutputArea of the OutlinerView
262         OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
263 
264         ::tools::Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
265 
266         aWin = pWindow->PixelToLogic(aWin);
267         pOutlinerView->SetOutputArea(aWin);
268 
269         ::tools::Rectangle aVis = pOutlinerView->GetVisArea();
270 
271         ::tools::Rectangle aText = ::tools::Rectangle(Point(0,0),
272             Size(pOlView->GetPaperWidth(),
273                 pOlView->GetOutliner().GetTextHeight()));
274         if (aWin.GetHeight() > aText.Bottom())
275             aText.SetBottom( aWin.GetHeight() );
276 
277         if (!aWin.IsEmpty())            // not when opening
278         {
279             InitWindows(Point(0,0), aText.GetSize(), aVis.TopLeft());
280             UpdateScrollBars();
281         }
282     }
283 }
284 
285 /**
286  * Handle SfxRequest for the Controller
287  */
288 void OutlineViewShell::ExecCtrl(SfxRequest &rReq)
289 {
290     sal_uInt16 nSlot = rReq.GetSlot();
291     switch ( nSlot )
292     {
293         case SID_MAIL_SCROLLBODY_PAGEDOWN:
294         {
295             ExecReq( rReq );
296             break;
297         }
298 
299         case SID_OPT_LOCALE_CHANGED:
300         {
301             pOlView->GetOutliner().UpdateFields();
302             UpdatePreview( GetActualPage() );
303             rReq.Done();
304             break;
305         }
306 
307         default:
308         break;
309     }
310 }
311 
312 /**
313  * Activate(): during the first invocation the fields get updated
314  */
315 void OutlineViewShell::Activate( bool bIsMDIActivate )
316 {
317     if ( ! mbInitialized)
318     {
319         mbInitialized = true;
320         SfxRequest aRequest (SID_EDIT_OUTLINER, SfxCallMode::SLOT, GetDoc()->GetItemPool());
321         FuPermanent (aRequest);
322     }
323 
324     ViewShell::Activate( bIsMDIActivate );
325     SfxShell::BroadcastContextForActivation(true);
326 
327     pOlView->SetLinks();
328     pOlView->ConnectToApplication();
329 
330     if( bIsMDIActivate )
331     {
332         OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
333         ::Outliner* pOutl = pOutlinerView->GetOutliner();
334         pOutl->UpdateFields();
335     }
336 }
337 
338 void OutlineViewShell::Deactivate( bool bIsMDIActivate )
339 {
340     pOlView->DisconnectFromApplication();
341 
342     // Links must be kept also on deactivated viewshell, to allow drag'n'drop
343     // to function properly
344     ViewShell::Deactivate( bIsMDIActivate );
345 }
346 
347 /**
348  * Set status of Controller-SfxSlots
349  */
350 void OutlineViewShell::GetCtrlState(SfxItemSet &rSet)
351 {
352     if (SfxItemState::DEFAULT == rSet.GetItemState(SID_HYPERLINK_GETLINK))
353     {
354         SvxHyperlinkItem aHLinkItem;
355 
356         OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow());
357         if (pOLV)
358         {
359             const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
360             if (pFieldItem)
361             {
362                 ESelection aSel = pOLV->GetSelection();
363                 if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
364                 {
365                     const SvxFieldData* pField = pFieldItem->GetField();
366                     if ( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
367                     {
368                         aHLinkItem.SetName(pUrlField->GetRepresentation());
369                         aHLinkItem.SetURL(pUrlField->GetURL());
370                         aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
371                     }
372                 }
373             }
374         }
375         rSet.Put(aHLinkItem);
376     }
377     rSet.Put( SfxBoolItem( SID_READONLY_MODE, GetDocSh()->IsReadOnly() ) );
378 
379     if ( SfxItemState::DEFAULT == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
380         rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, true ) );
381 
382     if ( SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_HALFWIDTH) ||
383          SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_FULLWIDTH) ||
384          SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_HIRAGANA) ||
385          SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_KATAGANA) )
386     {
387         SvtCJKOptions aCJKOptions;
388         if( !aCJKOptions.IsChangeCaseMapEnabled() )
389         {
390             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, false );
391             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, false );
392             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, false );
393             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, false );
394             rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
395             rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
396             rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
397             rSet.DisableItem( SID_TRANSLITERATE_KATAGANA );
398         }
399         else
400         {
401             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, true );
402             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, true );
403             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, true );
404             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, true );
405         }
406     }
407 }
408 
409 /**
410  * SfxRequests for support functions
411  */
412 void OutlineViewShell::FuSupport(SfxRequest &rReq)
413 {
414     if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs())
415         GetDocSh()->SetStyleFamily(static_cast<SfxStyleFamily>(rReq.GetArgs()->Get( SID_STYLE_FAMILY ).GetValue()));
416 
417     bool bPreviewState = false;
418     sal_uLong nSlot = rReq.GetSlot();
419 
420     std::unique_ptr<OutlineViewModelChangeGuard, o3tl::default_delete<OutlineViewModelChangeGuard>> aGuard;
421     if( pOlView && (
422         (nSlot == SID_TRANSLITERATE_SENTENCE_CASE) ||
423         (nSlot == SID_TRANSLITERATE_TITLE_CASE) ||
424         (nSlot == SID_TRANSLITERATE_TOGGLE_CASE) ||
425         (nSlot == SID_TRANSLITERATE_UPPER) ||
426         (nSlot == SID_TRANSLITERATE_LOWER) ||
427         (nSlot == SID_TRANSLITERATE_HALFWIDTH) ||
428         (nSlot == SID_TRANSLITERATE_FULLWIDTH) ||
429         (nSlot == SID_TRANSLITERATE_HIRAGANA) ||
430         (nSlot == SID_TRANSLITERATE_KATAGANA) ||
431         (nSlot == SID_CUT) ||
432         (nSlot == SID_PASTE) ||
433         (nSlot == SID_PASTE_UNFORMATTED) ||
434         (nSlot == SID_DELETE)))
435     {
436         aGuard.reset( new OutlineViewModelChangeGuard( *pOlView ) );
437     }
438 
439     switch ( nSlot )
440     {
441         case SID_CUT:
442         {
443             if(HasCurrentFunction())
444             {
445                 GetCurrentFunction()->DoCut();
446             }
447             else if (pOlView)
448             {
449                 pOlView->DoCut();
450             }
451             rReq.Done();
452             bPreviewState = true;
453         }
454         break;
455 
456         case SID_COPY:
457         {
458             if(HasCurrentFunction())
459             {
460                 GetCurrentFunction()->DoCopy();
461             }
462             else if (pOlView)
463             {
464                 pOlView->DoCopy();
465             }
466             rReq.Done();
467             bPreviewState = true;
468         }
469         break;
470 
471         case SID_PASTE:
472         {
473             OutlineViewPageChangesGuard aGuard2(pOlView.get());
474 
475             if(HasCurrentFunction())
476             {
477                 GetCurrentFunction()->DoPaste();
478             }
479             else if (pOlView)
480             {
481                 pOlView->DoPaste();
482             }
483             rReq.Done();
484             bPreviewState = true;
485         }
486         break;
487 
488         case SID_PASTE_UNFORMATTED:
489         {
490             OutlineViewPageChangesGuard aGuard2(pOlView.get());
491 
492             if(HasCurrentFunction())
493             {
494                 GetCurrentFunction()->DoPasteUnformatted();
495             }
496             else if(pOlView)
497             {
498                 sal_Int8 nAction = DND_ACTION_COPY;
499                 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
500                 if (aDataHelper.GetTransferable().is())
501                 {
502                     pOlView->InsertData( aDataHelper,
503                                          GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(), GetActiveWindow()->GetOutputSizePixel() ).Center() ),
504                                          nAction, false, SotClipboardFormatId::STRING);
505                 }
506             }
507 
508             rReq.Ignore ();
509         }
510         break;
511         case SID_DELETE:
512         {
513             if( pOlView )
514             {
515                 OutlinerView* pOutlView = pOlView->GetViewByWindow(GetActiveWindow());
516                 if (pOutlView)
517                 {
518                     OutlineViewPageChangesGuard aGuard2(pOlView.get());
519 
520                     vcl::KeyCode aKCode(KEY_DELETE);
521                     KeyEvent aKEvt( 0, aKCode );
522                     pOutlView->PostKeyEvent(aKEvt);
523 
524                     rtl::Reference<FuPoor> xFunc( GetCurrentFunction() );
525                     FuOutlineText* pFuOutlineText = dynamic_cast< FuOutlineText* >( xFunc.get() );
526                     if( pFuOutlineText )
527                         pFuOutlineText->UpdateForKeyPress (aKEvt);
528                 }
529             }
530             rReq.Done();
531             bPreviewState = true;
532         }
533         break;
534 
535         case SID_DRAWINGMODE:
536         case SID_SLIDE_MASTER_MODE:
537         case SID_NOTES_MODE:
538         case SID_NOTES_MASTER_MODE:
539         case SID_HANDOUT_MASTER_MODE:
540         case SID_SLIDE_SORTER_MODE:
541         case SID_OUTLINE_MODE:
542             framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot(
543                 nSlot,
544                 rReq);
545             rReq.Done();
546             break;
547 
548         case SID_RULER:
549             SetRuler( !HasRuler() );
550             Invalidate( SID_RULER );
551             rReq.Done();
552         break;
553 
554         case SID_ZOOM_PREV:
555         {
556             if (mpZoomList->IsPreviousPossible())
557             {
558                 SetZoomRect(mpZoomList->GetPreviousZoomRect());
559             }
560             rReq.Done ();
561         }
562         break;
563 
564         case SID_ZOOM_NEXT:
565         {
566             if (mpZoomList->IsNextPossible())
567             {
568                 SetZoomRect(mpZoomList->GetNextZoomRect());
569             }
570             rReq.Done ();
571         }
572         break;
573 
574         case SID_AUTOSPELL_CHECK:
575         {
576             GetDoc()->SetOnlineSpell(!GetDoc()->GetOnlineSpell());
577             rReq.Done ();
578         }
579         break;
580 
581         case SID_TRANSLITERATE_SENTENCE_CASE:
582         case SID_TRANSLITERATE_TITLE_CASE:
583         case SID_TRANSLITERATE_TOGGLE_CASE:
584         case SID_TRANSLITERATE_UPPER:
585         case SID_TRANSLITERATE_LOWER:
586         case SID_TRANSLITERATE_HALFWIDTH:
587         case SID_TRANSLITERATE_FULLWIDTH:
588         case SID_TRANSLITERATE_HIRAGANA:
589         case SID_TRANSLITERATE_KATAGANA:
590         {
591             OutlinerView* pOLV = pOlView ? pOlView->GetViewByWindow( GetActiveWindow() ) : nullptr;
592             if( pOLV )
593             {
594                 TransliterationFlags nType = TransliterationFlags::NONE;
595 
596                 switch( nSlot )
597                 {
598                     case SID_TRANSLITERATE_SENTENCE_CASE:
599                         nType = TransliterationFlags::SENTENCE_CASE;
600                         break;
601                     case SID_TRANSLITERATE_TITLE_CASE:
602                         nType = TransliterationFlags::TITLE_CASE;
603                         break;
604                     case SID_TRANSLITERATE_TOGGLE_CASE:
605                         nType = TransliterationFlags::TOGGLE_CASE;
606                         break;
607                     case SID_TRANSLITERATE_UPPER:
608                         nType = TransliterationFlags::LOWERCASE_UPPERCASE;
609                         break;
610                     case SID_TRANSLITERATE_LOWER:
611                         nType = TransliterationFlags::UPPERCASE_LOWERCASE;
612                         break;
613                     case SID_TRANSLITERATE_HALFWIDTH:
614                         nType = TransliterationFlags::FULLWIDTH_HALFWIDTH;
615                         break;
616                     case SID_TRANSLITERATE_FULLWIDTH:
617                         nType = TransliterationFlags::HALFWIDTH_FULLWIDTH;
618                         break;
619                     case SID_TRANSLITERATE_HIRAGANA:
620                         nType = TransliterationFlags::KATAKANA_HIRAGANA;
621                         break;
622                     case SID_TRANSLITERATE_KATAGANA:
623                         nType = TransliterationFlags::HIRAGANA_KATAKANA;
624                         break;
625                 }
626 
627                 pOLV->TransliterateText( nType );
628             }
629 
630             rReq.Done();
631             bPreviewState = true;
632         }
633         break;
634 
635         // added Undo/Redo handling
636         case SID_UNDO :
637         {
638             OutlineViewPageChangesGuard aGuard2(pOlView.get());
639             ImpSidUndo(rReq);
640         }
641         break;
642         case SID_REDO :
643         {
644             OutlineViewPageChangesGuard aGuard2(pOlView.get());
645             ImpSidRedo(rReq);
646         }
647         break;
648 
649         default:
650         break;
651     }
652 
653     if( bPreviewState )
654         Invalidate( SID_PREVIEW_STATE );
655 
656     Invalidate(SID_CUT);
657     Invalidate(SID_COPY);
658     Invalidate(SID_PASTE);
659 }
660 
661 /**
662  * SfxRequests for permanent functions
663  */
664 void OutlineViewShell::FuPermanent(SfxRequest &rReq)
665 {
666     if(HasCurrentFunction())
667     {
668         DeactivateCurrentFunction(true);
669     }
670 
671     switch ( rReq.GetSlot() )
672     {
673         case SID_EDIT_OUTLINER:
674         {
675             ::Outliner& rOutl = pOlView->GetOutliner();
676             rOutl.GetUndoManager().Clear();
677             rOutl.UpdateFields();
678 
679             SetCurrentFunction( FuOutlineText::Create(this,GetActiveWindow(),pOlView.get(),GetDoc(),rReq) );
680 
681             rReq.Done();
682         }
683         break;
684 
685       default:
686       break;
687     }
688 
689     if(HasOldFunction())
690     {
691         GetOldFunction()->Deactivate();
692         SetOldFunction(nullptr);
693     }
694 
695     if(HasCurrentFunction())
696     {
697         GetCurrentFunction()->Activate();
698         SetOldFunction(GetCurrentFunction());
699     }
700 }
701 
702 IMPL_LINK( OutlineViewShell, ClipboardChanged, TransferableDataHelper*, pDataHelper, void )
703 {
704     bPastePossible = pDataHelper->GetFormatCount() != 0 &&
705                      ( pDataHelper->HasFormat( SotClipboardFormatId::STRING ) ||
706                        pDataHelper->HasFormat( SotClipboardFormatId::RTF ) ||
707                        pDataHelper->HasFormat( SotClipboardFormatId::RICHTEXT ) ||
708                        pDataHelper->HasFormat( SotClipboardFormatId::HTML ) );
709 
710     SfxBindings& rBindings = GetViewFrame()->GetBindings();
711     rBindings.Invalidate( SID_PASTE );
712     rBindings.Invalidate( SID_PASTE_SPECIAL );
713     rBindings.Invalidate( SID_PASTE_UNFORMATTED );
714     rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
715 }
716 
717 /**
718  * Set Status (Enabled/Disabled) of Menu-SfxSlots
719  */
720 void OutlineViewShell::GetMenuState( SfxItemSet &rSet )
721 {
722     ViewShell::GetMenuState(rSet);
723 
724     rSet.Put(SfxBoolItem(SID_SLIDE_SORTER_MODE, false));
725     rSet.Put(SfxBoolItem(SID_DRAWINGMODE, false));
726     rSet.Put(SfxBoolItem(SID_SLIDE_MASTER_MODE, false));
727     rSet.Put(SfxBoolItem(SID_OUTLINE_MODE, true));
728     rSet.Put(SfxBoolItem(SID_NOTES_MODE, false));
729     rSet.Put(SfxBoolItem(SID_NOTES_MASTER_MODE, false));
730     rSet.Put(SfxBoolItem(SID_HANDOUT_MASTER_MODE, false));
731 
732     if (!mpZoomList->IsNextPossible())
733     {
734        rSet.DisableItem(SID_ZOOM_NEXT);
735     }
736     if (!mpZoomList->IsPreviousPossible())
737     {
738        rSet.DisableItem(SID_ZOOM_PREV);
739     }
740 
741     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_ZOOM_IN ) ||
742         SfxItemState::DEFAULT == rSet.GetItemState( SID_ZOOM_OUT ) )
743     {
744         if( GetActiveWindow()->GetZoom() <= GetActiveWindow()->GetMinZoom() || GetDocSh()->IsUIActive() )
745             rSet.DisableItem( SID_ZOOM_IN );
746         if( GetActiveWindow()->GetZoom() >= GetActiveWindow()->GetMaxZoom() || GetDocSh()->IsUIActive() )
747             rSet.DisableItem( SID_ZOOM_OUT );
748     }
749 
750     ::Outliner& rOutl = pOlView->GetOutliner();
751 
752     // allow 'Select All'?
753     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_SELECTALL ) )
754     {
755         sal_Int32 nParaCount = rOutl.GetParagraphCount();
756         bool bDisable = nParaCount == 0;
757         if (!bDisable && nParaCount == 1)
758         {
759             OUString aTest = rOutl.GetText(rOutl.GetParagraph(0));
760             if (aTest.isEmpty())
761             {
762                 bDisable = true;
763             }
764         }
765         if (bDisable)
766             rSet.DisableItem(SID_SELECTALL);
767     }
768 
769     // set status of Ruler
770     rSet.Put( SfxBoolItem( SID_RULER, HasRuler() ) );
771 
772     // Enable formatting?
773     rSet.Put( SfxBoolItem( SID_OUTLINE_FORMAT, !rOutl.IsFlatMode() ) );
774 
775     if( rOutl.IsFlatMode() )
776         rSet.DisableItem( SID_COLORVIEW );
777     else
778     {
779         // Enable color view?
780         EEControlBits nCntrl = rOutl.GetControlWord();
781         bool bNoColor = false;
782         if (nCntrl & EEControlBits::NOCOLORS)
783             bNoColor = true;
784 
785         rSet.Put( SfxBoolItem( SID_COLORVIEW, bNoColor ) );
786     }
787 
788     // Buttons of toolbar
789     // first the selection dependent ones: COLLAPSE, EXPAND
790     bool bDisableCollapse = true;
791     bool bDisableExpand   = true;
792     bool bUnique          = true;
793     OutlinerView* pOutlinerView = pOlView->GetViewByWindow(GetActiveWindow());
794 
795     std::vector<Paragraph*> aSelList;
796     pOutlinerView->CreateSelectionList(aSelList);
797 
798     if (!aSelList.empty())
799     {
800         std::vector<Paragraph*>::const_iterator iter = aSelList.begin();
801         Paragraph* pPara = *iter;
802 
803         sal_Int16 nDepth;
804         sal_Int16 nTmpDepth = rOutl.GetDepth( rOutl.GetAbsPos( pPara ) );
805         bool bPage = ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE );
806 
807         while (iter != aSelList.begin())
808         {
809             pPara = *iter;
810 
811             nDepth = rOutl.GetDepth( rOutl.GetAbsPos( pPara ) );
812 
813             if( nDepth != nTmpDepth || bPage != ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ))
814                 bUnique = false;
815 
816             if (rOutl.HasChildren(pPara))
817             {
818                 if (!rOutl.IsExpanded(pPara))
819                     bDisableExpand = false;
820                 else
821                     bDisableCollapse = false;
822             }
823 
824             ++iter;
825         }
826     }
827 
828     if (bDisableExpand)
829         rSet.DisableItem(SID_OUTLINE_EXPAND);
830     if (bDisableCollapse)
831         rSet.DisableItem(SID_OUTLINE_COLLAPSE);
832 
833     // does the selection provide a unique presentation layout?
834     // if not, the templates must not be edited
835     SfxItemSet aSet(*rSet.GetPool(), svl::Items<SID_STATUS_LAYOUT, SID_STATUS_LAYOUT>{});
836     GetStatusBarState(aSet);
837     OUString aTest = static_cast<const SfxStringItem&>(aSet.Get(SID_STATUS_LAYOUT)).GetValue();
838     if (aTest.isEmpty())
839     {
840         bUnique = false;
841     }
842 
843     if (!bUnique)
844         rSet.DisableItem( SID_PRESENTATIONOBJECT );
845 
846     // now the selection independent ones: COLLAPSE_ALL, EXPAND_ALL
847     bool bDisableCollapseAll = true;
848     bool bDisableExpandAll   = true;
849 
850     // does the selection contain something collapsible/expandable?
851     if (!bDisableCollapse)
852         bDisableCollapseAll = false;
853     if (!bDisableExpand)
854         bDisableExpandAll = false;
855 
856     // otherwise look through all paragraphs
857     if (bDisableCollapseAll || bDisableExpandAll)
858     {
859         sal_Int32 nParaPos = 0;
860         Paragraph* pPara = rOutl.GetParagraph( nParaPos );
861         while (pPara && (bDisableCollapseAll || bDisableExpandAll))
862         {
863             if (!rOutl.IsExpanded(pPara) && rOutl.HasChildren(pPara))
864                 bDisableExpandAll = false;
865 
866             if (rOutl.IsExpanded(pPara) && rOutl.HasChildren(pPara))
867                 bDisableCollapseAll = false;
868 
869             pPara = rOutl.GetParagraph( ++nParaPos );
870         }
871     }
872 
873     if (bDisableExpandAll)
874         rSet.DisableItem(SID_OUTLINE_EXPAND_ALL);
875     if (bDisableCollapseAll)
876         rSet.DisableItem(SID_OUTLINE_COLLAPSE_ALL);
877 
878     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_PASTE ) )
879     {
880         if ( !mxClipEvtLstnr.is() )
881         {
882             // create listener
883             mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, OutlineViewShell, ClipboardChanged ) );
884             mxClipEvtLstnr->AddListener( GetActiveWindow() );
885 
886             // get initial state
887             TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
888             bPastePossible = ( aDataHelper.GetFormatCount() != 0 &&
889                                 ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) ||
890                                   aDataHelper.HasFormat( SotClipboardFormatId::RTF ) ||
891                                   aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) ||
892                                   aDataHelper.HasFormat( SotClipboardFormatId::HTML ) ) );
893         }
894 
895         if( !bPastePossible )
896         {
897             rSet.DisableItem( SID_PASTE );
898         }
899     }
900 
901     if (!pOlView->GetViewByWindow(GetActiveWindow())->HasSelection())
902     {
903         rSet.DisableItem(SID_CUT);
904         rSet.DisableItem(SID_COPY);
905     }
906 
907     if (pOlView->GetOutliner().IsModified())
908     {
909         GetDoc()->SetChanged();
910     }
911 
912     // the status has to be set here because of overriding
913     if( !GetDocSh()->IsModified() )
914     {
915         rSet.DisableItem( SID_SAVEDOC );
916     }
917 
918     if ( GetDocSh()->IsReadOnly() )
919     {
920         rSet.DisableItem( SID_AUTOSPELL_CHECK );
921     }
922     else
923     {
924         if (GetDoc()->GetOnlineSpell())
925         {
926             rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, true));
927         }
928         else
929         {
930             rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, false));
931         }
932     }
933 
934     // field commands
935     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_MODIFY_FIELD ) )
936     {
937         const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection();
938 
939         if( !( pFldItem && (nullptr != dynamic_cast< const SvxDateField *>( pFldItem->GetField() ) ||
940                             nullptr != dynamic_cast< const SvxAuthorField *>( pFldItem->GetField() ) ||
941                             nullptr != dynamic_cast< const SvxExtFileField *>( pFldItem->GetField() ) ||
942                             nullptr != dynamic_cast< const SvxExtTimeField *>( pFldItem->GetField() ) ) ) )
943         {
944             rSet.DisableItem( SID_MODIFY_FIELD );
945         }
946     }
947 
948     if (SfxItemState::DEFAULT == rSet.GetItemState(SID_EXPAND_PAGE))
949     {
950         bool bDisable = true;
951         sal_uInt16 i = 0;
952         sal_uInt16 nCount = GetDoc()->GetSdPageCount(PageKind::Standard);
953         pOlView->SetSelectedPages();
954 
955         while (i < nCount && bDisable)
956         {
957             SdPage* pPage = GetDoc()->GetSdPage(i, PageKind::Standard);
958 
959             if (pPage->IsSelected())
960             {
961                 SdrObject* pObj = pPage->GetPresObj(PRESOBJ_OUTLINE);
962 
963                 if (pObj!=nullptr )
964                 {
965                     if( !pObj->IsEmptyPresObj() )
966                     {
967                         bDisable = false;
968                     }
969                     else
970                     {
971                         // check if the object is in edit, than its temporarely not empty
972                         SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
973                         if( pTextObj )
974                         {
975                             std::unique_ptr<OutlinerParaObject> pParaObj = pTextObj->GetEditOutlinerParaObject();
976                             if( pParaObj )
977                             {
978                                 bDisable = false;
979                             }
980                         }
981                     }
982                 }
983             }
984 
985             i++;
986         }
987 
988         if (bDisable)
989         {
990             rSet.DisableItem(SID_EXPAND_PAGE);
991         }
992     }
993 
994     if (SfxItemState::DEFAULT == rSet.GetItemState(SID_SUMMARY_PAGE))
995     {
996         bool bDisable = true;
997         sal_uInt16 i = 0;
998         sal_uInt16 nCount = GetDoc()->GetSdPageCount(PageKind::Standard);
999         pOlView->SetSelectedPages();
1000 
1001         while (i < nCount && bDisable)
1002         {
1003             SdPage* pPage = GetDoc()->GetSdPage(i, PageKind::Standard);
1004 
1005             if (pPage->IsSelected())
1006             {
1007                 SdrObject* pObj = pPage->GetPresObj(PRESOBJ_TITLE);
1008 
1009                 if (pObj && !pObj->IsEmptyPresObj())
1010                 {
1011                     bDisable = false;
1012                 }
1013             }
1014 
1015             i++;
1016         }
1017 
1018         if (bDisable)
1019         {
1020             rSet.DisableItem(SID_SUMMARY_PAGE);
1021         }
1022     }
1023 
1024     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_THESAURUS ) )
1025     {
1026         if ( !pOlView->IsTextEdit() )
1027         {
1028             rSet.DisableItem( SID_THESAURUS );
1029         }
1030         else
1031         {
1032             LanguageType            eLang = GetDoc()->GetLanguage( EE_CHAR_LANGUAGE );
1033             Reference< XThesaurus > xThesaurus( LinguMgr::GetThesaurus() );
1034 
1035             if (!xThesaurus.is() || eLang == LANGUAGE_NONE || !xThesaurus->hasLocale( LanguageTag::convertToLocale( eLang)))
1036                 rSet.DisableItem( SID_THESAURUS );
1037         }
1038     }
1039 
1040     // is starting the presentation possible?
1041     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_PRESENTATION ) )
1042     {
1043         bool bDisable = true;
1044         sal_uInt16 nCount = GetDoc()->GetSdPageCount( PageKind::Standard );
1045 
1046         for( sal_uInt16 i = 0; i < nCount && bDisable; i++ )
1047         {
1048             SdPage* pPage = GetDoc()->GetSdPage(i, PageKind::Standard);
1049 
1050             if( !pPage->IsExcluded() )
1051                 bDisable = false;
1052         }
1053         if( bDisable || GetDocSh()->IsPreview())
1054         {
1055             rSet.DisableItem( SID_PRESENTATION );
1056         }
1057     }
1058 
1059     FuBullet::GetSlotState( rSet, this, GetViewFrame() );
1060 
1061 }
1062 
1063 /**
1064  * gets invoked when ScrollBar is used
1065  */
1066 void OutlineViewShell::VirtHScrollHdl(ScrollBar* pHScroll)
1067 {
1068     long   nThumb = pHScroll->GetThumbPos();
1069     long   nRange = pHScroll->GetRange().Len();
1070     double fX     = static_cast<double>(nThumb) / nRange;
1071 
1072     Window*       pWin          = mpContentWindow.get();
1073     OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWin);
1074     long          nViewWidth    = pWin->PixelToLogic(
1075         pWin->GetSizePixel()).Width();
1076     long          nTextWidth    = pOlView->GetPaperWidth();
1077     nViewWidth                  = std::max(nViewWidth, nTextWidth);
1078     long          nCurrentPos   = pOutlinerView->GetVisArea().Left();
1079     long          nTargetPos    = static_cast<long>(fX * nViewWidth);
1080     long          nDelta        = nTargetPos - nCurrentPos;
1081 
1082     pOutlinerView->HideCursor();
1083     pOutlinerView->Scroll(-nDelta, 0);
1084     pOutlinerView->ShowCursor(false);
1085 }
1086 
1087 void OutlineViewShell::VirtVScrollHdl(ScrollBar* pVScroll)
1088 {
1089     long nThumb = pVScroll->GetThumbPos();
1090     long nRange = pVScroll->GetRange().Len();
1091     double fY = static_cast<double>(nThumb) / nRange;
1092 
1093     Window*       pWin          = mpContentWindow.get();
1094     OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWin);
1095     long          nViewHeight   = pWin->PixelToLogic(
1096         pWin->GetSizePixel()).Height();
1097     long          nTextHeight   = pOlView->GetOutliner().GetTextHeight();
1098     nViewHeight                += nTextHeight;
1099     long          nCurrentPos   = pOutlinerView->GetVisArea().Top();
1100     long          nTargetPos    = static_cast<long>(fY * nViewHeight);
1101     long          nDelta        = nTargetPos - nCurrentPos;
1102 
1103     pOutlinerView->HideCursor();
1104     pOutlinerView->Scroll(0, -nDelta);
1105     pOutlinerView->ShowCursor(false);
1106 }
1107 
1108 /**
1109  * PrepareClose, gets called when the Shell shall be destroyed.
1110  * Forwards the invocation to the View
1111  */
1112 bool OutlineViewShell::PrepareClose( bool bUI )
1113 {
1114     if( !ViewShell::PrepareClose(bUI) )
1115         return false;
1116 
1117     if (pOlView)
1118         pOlView->PrepareClose();
1119     return true;
1120 }
1121 
1122 /**
1123  * Zoom with zoom factor. Inform OutlinerView
1124  */
1125 void OutlineViewShell::SetZoom(long nZoom)
1126 {
1127     ViewShell::SetZoom(nZoom);
1128 
1129     ::sd::Window* pWindow = mpContentWindow.get();
1130     if (pWindow)
1131     {
1132         // change OutputArea of OutlinerView
1133         OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
1134         ::tools::Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
1135         aWin = pWindow->PixelToLogic(aWin);
1136         pOutlinerView->SetOutputArea(aWin);
1137     }
1138 
1139     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1140     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1141 }
1142 
1143 /**
1144  * Zoom with zoom rectangle. Inform OutlinerView
1145  */
1146 void OutlineViewShell::SetZoomRect(const ::tools::Rectangle& rZoomRect)
1147 {
1148     ViewShell::SetZoomRect(rZoomRect);
1149 
1150     ::sd::Window* pWindow = mpContentWindow.get();
1151     if (pWindow)
1152     {
1153         // change OutputArea of OutlinerView
1154         OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
1155         ::tools::Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
1156         aWin = pWindow->PixelToLogic(aWin);
1157         pOutlinerView->SetOutputArea(aWin);
1158     }
1159 
1160     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1161     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1162 }
1163 
1164 /**
1165  * Before saving: Update Model of the Drawing Engine, then forward the
1166  * invocation to the ObjectShell.
1167  */
1168 void OutlineViewShell::Execute(SfxRequest& rReq)
1169 {
1170     bool bForwardCall = true;
1171 
1172     switch(rReq.GetSlot())
1173     {
1174         case SID_SAVEDOC:
1175         case SID_SAVEASDOC:
1176             PrepareClose();
1177             break;
1178 
1179         case SID_SEARCH_ITEM:
1180             // Forward this request to the common (old) code of the
1181             // document shell.
1182             GetDocSh()->Execute (rReq);
1183             bForwardCall = false;
1184             break;
1185 
1186         case SID_SPELL_DIALOG:
1187         {
1188             SfxViewFrame* pViewFrame = GetViewFrame();
1189             if (rReq.GetArgs() != nullptr)
1190                 pViewFrame->SetChildWindow (SID_SPELL_DIALOG,
1191                     static_cast<const SfxBoolItem&>(rReq.GetArgs()->
1192                         Get(SID_SPELL_DIALOG)).GetValue());
1193             else
1194                 pViewFrame->ToggleChildWindow(SID_SPELL_DIALOG);
1195 
1196             pViewFrame->GetBindings().Invalidate(SID_SPELL_DIALOG);
1197             rReq.Done ();
1198 
1199             bForwardCall = false;
1200         }
1201         break;
1202 
1203         default:
1204             SAL_WARN("sd", "OutlineViewShell::Execute(): can not handle slot " << rReq.GetSlot());
1205             break;
1206 
1207     }
1208 
1209     if (bForwardCall)
1210         static_cast<DrawDocShell*>(GetViewFrame()->GetObjectShell())->ExecuteSlot( rReq );
1211 }
1212 
1213 /**
1214  * Read FrameViews data and set actual views data
1215  */
1216 void OutlineViewShell::ReadFrameViewData(FrameView* pView)
1217 {
1218     ::Outliner& rOutl = pOlView->GetOutliner();
1219 
1220     rOutl.SetFlatMode( pView->IsNoAttribs() );
1221 
1222     EEControlBits nCntrl = rOutl.GetControlWord();
1223 
1224     if ( pView->IsNoColors() )
1225         rOutl.SetControlWord(nCntrl | EEControlBits::NOCOLORS);
1226     else
1227         rOutl.SetControlWord(nCntrl & ~EEControlBits::NOCOLORS);
1228 
1229     sal_uInt16 nPage = mpFrameView->GetSelectedPage();
1230     pLastPage = GetDoc()->GetSdPage( nPage, PageKind::Standard );
1231     pOlView->SetActualPage(pLastPage);
1232 }
1233 
1234 /**
1235  * Write actual views data to FrameView
1236  */
1237 void OutlineViewShell::WriteFrameViewData()
1238 {
1239     ::Outliner& rOutl = pOlView->GetOutliner();
1240 
1241     EEControlBits nCntrl = rOutl.GetControlWord();
1242     bool bNoColor = false;
1243     if (nCntrl & EEControlBits::NOCOLORS)
1244         bNoColor = true;
1245     mpFrameView->SetNoColors(bNoColor);
1246     mpFrameView->SetNoAttribs( rOutl.IsFlatMode() );
1247     SdPage* pActualPage = pOlView->GetActualPage();
1248     DBG_ASSERT(pActualPage, "No current page");
1249     if( pActualPage )
1250         mpFrameView->SetSelectedPage((pActualPage->GetPageNum() - 1) / 2);
1251 }
1252 
1253 /**
1254  * Handle SfxRequests for the StatusBar
1255  */
1256 void OutlineViewShell::ExecStatusBar(SfxRequest&)
1257 {
1258 }
1259 
1260 void OutlineViewShell::GetStatusBarState(SfxItemSet& rSet)
1261 {
1262     // Zoom-Item
1263     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_ATTR_ZOOM ) )
1264     {
1265         sal_uInt16 nZoom = static_cast<sal_uInt16>(GetActiveWindow()->GetZoom());
1266 
1267         std::unique_ptr<SvxZoomItem> pZoomItem(new SvxZoomItem( SvxZoomType::PERCENT, nZoom ));
1268 
1269         // limit area
1270         SvxZoomEnableFlags nZoomValues = SvxZoomEnableFlags::ALL;
1271         nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
1272         nZoomValues &= ~SvxZoomEnableFlags::WHOLEPAGE;
1273         nZoomValues &= ~SvxZoomEnableFlags::PAGEWIDTH;
1274 
1275         pZoomItem->SetValueSet( nZoomValues );
1276         rSet.Put( *pZoomItem );
1277     }
1278 
1279     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) )
1280     {
1281         if (GetDocSh()->IsUIActive() || !GetActiveWindow() )
1282         {
1283             rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
1284         }
1285         else
1286         {
1287             sd::Window * pActiveWindow = GetActiveWindow();
1288             SvxZoomSliderItem aZoomItem( static_cast<sal_uInt16>(pActiveWindow->GetZoom()), static_cast<sal_uInt16>(pActiveWindow->GetMinZoom()), static_cast<sal_uInt16>(pActiveWindow->GetMaxZoom()) ) ;
1289             aZoomItem.AddSnappingPoint(100);
1290             rSet.Put( aZoomItem );
1291         }
1292     }
1293 
1294     // page view and layout
1295 
1296     sal_uInt16  nPageCount = GetDoc()->GetSdPageCount( PageKind::Standard );
1297     OUString  aPageStr, aLayoutStr;
1298 
1299     ::sd::Window*   pWin        = GetActiveWindow();
1300     OutlinerView*   pActiveView = pOlView->GetViewByWindow( pWin );
1301 
1302     std::vector<Paragraph*> aSelList;
1303     pActiveView->CreateSelectionList(aSelList);
1304 
1305     Paragraph *pFirstPara = nullptr;
1306     Paragraph *pLastPara = nullptr;
1307 
1308     if (!aSelList.empty())
1309     {
1310         pFirstPara = *(aSelList.begin());
1311         pLastPara = *(aSelList.rbegin());
1312     }
1313 
1314     if( !::Outliner::HasParaFlag(pFirstPara,ParaFlag::ISPAGE) )
1315         pFirstPara = pOlView->GetPrevTitle( pFirstPara );
1316 
1317     if( !::Outliner::HasParaFlag(pLastPara, ParaFlag::ISPAGE) )
1318         pLastPara = pOlView->GetPrevTitle( pLastPara );
1319 
1320     // only one page selected?
1321     if( pFirstPara == pLastPara )
1322     {
1323         // how many pages are we before the selected page?
1324         sal_uLong nPos = 0;
1325         while( pFirstPara )
1326         {
1327             pFirstPara = pOlView->GetPrevTitle( pFirstPara );
1328             if( pFirstPara )
1329                 nPos++;
1330         }
1331 
1332         if( nPos >= GetDoc()->GetSdPageCount( PageKind::Standard ) )
1333             nPos = 0;
1334 
1335         SdrPage* pPage = GetDoc()->GetSdPage( static_cast<sal_uInt16>(nPos), PageKind::Standard );
1336 
1337         aPageStr = SdResId(STR_SD_PAGE_COUNT);
1338 
1339         aPageStr = aPageStr.replaceFirst("%1", OUString::number(static_cast<sal_Int32>(nPos + 1)));
1340         aPageStr = aPageStr.replaceFirst("%2", OUString::number(nPageCount));
1341 
1342         aLayoutStr = pPage->GetLayoutName();
1343         sal_Int32 nIndex = aLayoutStr.indexOf(SD_LT_SEPARATOR);
1344         if (nIndex != -1)
1345             aLayoutStr = aLayoutStr.copy(0, nIndex);
1346         //Now, CurrentPage property change is already sent for DrawView and OutlineView, so it is not necessary to send again here
1347         if(m_StrOldPageName!=aPageStr)
1348         {
1349             GetViewShellBase().GetDrawController().fireSwitchCurrentPage(nPos);
1350             m_StrOldPageName = aPageStr;
1351         }
1352     }
1353     rSet.Put( SfxStringItem( SID_STATUS_PAGE, aPageStr ) );
1354     rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aLayoutStr ) );
1355 }
1356 
1357 void OutlineViewShell::Command( const CommandEvent& rCEvt, ::sd::Window* pWin )
1358 {
1359     if ( rCEvt.GetCommand() == CommandEventId::ContextMenu )
1360     {
1361         GetActiveWindow()->ReleaseMouse();
1362 
1363         OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow());
1364         Point aPos(rCEvt.GetMousePosPixel());
1365 
1366         if (pOLV && pOLV->IsWrongSpelledWordAtPos(aPos))
1367         {
1368             // Popup for Online-Spelling now handled by DrawDocShell
1369             Link<SpellCallbackInfo&,void> aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
1370 
1371             pOLV->ExecuteSpellPopup(aPos, &aLink);
1372             pOLV->GetEditView().Invalidate();
1373         }
1374         else
1375         {
1376            GetViewFrame()->GetDispatcher()->ExecutePopup("outline");
1377         }
1378     }
1379     else
1380     {
1381         ViewShell::Command( rCEvt, pWin );
1382 
1383         // if necessary communicate the new context to the Preview
1384         Invalidate( SID_PREVIEW_STATE );
1385 
1386     }
1387 }
1388 
1389 bool OutlineViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin)
1390 {
1391     bool bReturn = false;
1392     OutlineViewPageChangesGuard aGuard(pOlView.get());
1393 
1394     if (pWin == nullptr && HasCurrentFunction())
1395     {
1396         bReturn = GetCurrentFunction()->KeyInput(rKEvt);
1397     }
1398 
1399     // no, forward to base class
1400     else
1401     {
1402         bReturn = ViewShell::KeyInput(rKEvt, pWin);
1403     }
1404 
1405     Invalidate(SID_STYLE_EDIT);
1406     Invalidate(SID_STYLE_NEW);
1407     Invalidate(SID_STYLE_DELETE);
1408     Invalidate(SID_STYLE_HIDE);
1409     Invalidate(SID_STYLE_SHOW);
1410     Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE);
1411     Invalidate(SID_STYLE_NEW_BY_EXAMPLE);
1412     Invalidate(SID_STYLE_WATERCAN);
1413     Invalidate(SID_STYLE_FAMILY5);
1414 
1415     // check and distinguish cursor movements- or input-keys
1416     vcl::KeyCode aKeyGroup( rKEvt.GetKeyCode().GetGroup() );
1417     if( (aKeyGroup != KEYGROUP_CURSOR && aKeyGroup != KEYGROUP_FKEYS) ||
1418         (GetActualPage() != pLastPage) )
1419     {
1420         Invalidate( SID_PREVIEW_STATE );
1421     }
1422 
1423     return bReturn;
1424 }
1425 
1426 /**
1427  * Status of Attribute-Items
1428  */
1429 void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
1430 {
1431     SfxWhichIter  aIter( rSet );
1432     sal_uInt16        nWhich = aIter.FirstWhich();
1433     SfxAllItemSet aAllSet( *rSet.GetPool() );
1434 
1435     while ( nWhich )
1436     {
1437         sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1438             ? GetPool().GetSlotId(nWhich)
1439             : nWhich;
1440 
1441         switch ( nSlotId )
1442         {
1443             case SID_STYLE_FAMILY2:
1444             case SID_STYLE_FAMILY3:
1445             {
1446                 rSet.DisableItem( nWhich );
1447             }
1448             break;
1449 
1450             case SID_STYLE_FAMILY5:
1451             {
1452                 SfxStyleSheet* pStyleSheet = pOlView->GetViewByWindow(GetActiveWindow())->GetStyleSheet();
1453 
1454                 if( pStyleSheet )
1455                 {
1456                     pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet();
1457 
1458                     if (pStyleSheet)
1459                     {
1460                         SfxTemplateItem aItem( nWhich, pStyleSheet->GetName() );
1461                         aAllSet.Put( aItem, aItem.Which()  );
1462                     }
1463                 }
1464 
1465                 if( !pStyleSheet )
1466                 {
1467                     SfxTemplateItem aItem( nWhich, OUString() );
1468                     aAllSet.Put( aItem, aItem.Which() );
1469                     // rSet.DisableItem( nWhich );
1470                 }
1471             }
1472             break;
1473 
1474             case SID_STYLE_EDIT:
1475             {
1476                 std::unique_ptr<SfxPoolItem> pItem;
1477                 GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
1478                 SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
1479                 if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
1480                 {
1481                     SfxItemSet aSet(*rSet.GetPool(), svl::Items<SID_STATUS_LAYOUT, SID_STATUS_LAYOUT>{});
1482                     GetStatusBarState(aSet);
1483                     OUString aRealStyle = static_cast<const SfxStringItem&>(aSet.Get(SID_STATUS_LAYOUT)).GetValue();
1484                     if (aRealStyle.isEmpty())
1485                     {
1486                         // no unique layout name found
1487                         rSet.DisableItem(nWhich);
1488                     }
1489                 }
1490             }
1491             break;
1492 
1493             case SID_STYLE_UPDATE_BY_EXAMPLE:
1494             {
1495                 ::sd::Window*     pActWin = GetActiveWindow();
1496                 OutlinerView* pOV = pOlView->GetViewByWindow(pActWin);
1497                 ESelection aESel(pOV->GetSelection());
1498 
1499                 if (aESel.nStartPara != aESel.nEndPara ||
1500                     aESel.nStartPos  != aESel.nEndPos)
1501                     // spanned selection, i.e. StyleSheet and/or
1502                     // attribution not necessarily unique
1503                     rSet.DisableItem(nWhich);
1504             }
1505             break;
1506 
1507             case SID_STYLE_NEW:
1508             case SID_STYLE_DELETE:
1509             case SID_STYLE_HIDE:
1510             case SID_STYLE_SHOW:
1511             case SID_STYLE_NEW_BY_EXAMPLE:
1512             case SID_STYLE_WATERCAN:
1513             {
1514                 rSet.DisableItem(nWhich);
1515             }
1516             break;
1517         }
1518 
1519         nWhich = aIter.NextWhich();
1520     }
1521 
1522     rSet.Put( aAllSet, false );
1523 }
1524 
1525 void OutlineViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
1526 {
1527     // first the base classes
1528     ViewShell::MouseButtonUp(rMEvt, pWin);
1529 
1530     Invalidate(SID_STYLE_EDIT);
1531     Invalidate(SID_STYLE_NEW);
1532     Invalidate(SID_STYLE_DELETE);
1533     Invalidate(SID_STYLE_HIDE);
1534     Invalidate(SID_STYLE_SHOW);
1535     Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE);
1536     Invalidate(SID_STYLE_NEW_BY_EXAMPLE);
1537     Invalidate(SID_STYLE_WATERCAN);
1538     Invalidate(SID_STYLE_FAMILY5);
1539 
1540     // if necessary communicate the new context to the Preview
1541     if( GetActualPage() != pLastPage )
1542         Invalidate( SID_PREVIEW_STATE );
1543 }
1544 
1545 SdPage* OutlineViewShell::getCurrentPage() const
1546 {
1547     // since there are no master pages in outline view, we can
1548     // for now use the GetActualPage method
1549     return const_cast<OutlineViewShell*>(this)->GetActualPage();
1550 }
1551 
1552 /**
1553  * Returns the first selected page.
1554  * If nothing is selected, the first page is returned.
1555  */
1556 SdPage* OutlineViewShell::GetActualPage()
1557 {
1558     return pOlView->GetActualPage();
1559 }
1560 
1561 void OutlineViewShell::UpdatePreview( SdPage* pPage, bool )
1562 {
1563     const bool bNewPage = pPage != pLastPage;
1564     pLastPage = pPage;
1565     if (bNewPage)
1566     {
1567         OutlineViewPageChangesGuard aGuard(pOlView.get());
1568         SetCurrentPage(pPage);
1569     }
1570 }
1571 
1572 void OutlineViewShell::UpdateTitleObject( SdPage* pPage, Paragraph const * pPara )
1573 {
1574     DBG_ASSERT( pPage, "sd::OutlineViewShell::UpdateTitleObject(), pPage == 0?" );
1575     DBG_ASSERT( pPara, "sd::OutlineViewShell::UpdateTitleObject(), pPara == 0?" );
1576 
1577     if( !pPage || !pPara )
1578         return;
1579 
1580     ::Outliner&         rOutliner = pOlView->GetOutliner();
1581     SdrTextObj*         pTO  = OutlineView::GetTitleTextObject( pPage );
1582 
1583     OUString aTest = rOutliner.GetText(pPara);
1584     bool    bText = !aTest.isEmpty();
1585     bool    bNewObject = false;
1586 
1587     if( bText )
1588     {
1589         // create a title object if we don't have one but have text
1590         if( !pTO )
1591         {
1592             DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1593             pTO = OutlineView::CreateTitleTextObject(pPage);
1594             bNewObject = true;
1595         }
1596 
1597         // if we have a title object and a text, set the text
1598         std::unique_ptr<OutlinerParaObject> pOPO;
1599         if (pTO)
1600             pOPO = rOutliner.CreateParaObject(rOutliner.GetAbsPos(pPara), 1);
1601         if (pOPO)
1602         {
1603             pOPO->SetOutlinerMode( OutlinerMode::TitleObject );
1604             assert(pTO);
1605             pOPO->SetVertical( pTO->IsVerticalWriting() );
1606             if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) )
1607             {
1608                 // do nothing, same text already set
1609             }
1610             else
1611             {
1612                 DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1613                 if( !bNewObject && pOlView->isRecordingUndo() )
1614                     pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1615 
1616                 pTO->SetOutlinerParaObject( std::move(pOPO) );
1617                 pTO->SetEmptyPresObj( false );
1618                 pTO->ActionChanged();
1619             }
1620         }
1621     }
1622     else if( pTO )
1623     {
1624         // no text but object available?
1625         // outline object available, but we have no text
1626         if(pPage->IsPresObj(pTO))
1627         {
1628             // if it is not already empty
1629             if( !pTO->IsEmptyPresObj() )
1630             {
1631                 DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1632 
1633                 // make it empty
1634                 if( pOlView->isRecordingUndo() )
1635                     pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1636                 pPage->RestoreDefaultText( pTO );
1637                 pTO->SetEmptyPresObj(true);
1638                 pTO->ActionChanged();
1639             }
1640         }
1641         else
1642         {
1643             DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1644             // outline object is not part of the layout, delete it
1645             if( pOlView->isRecordingUndo() )
1646                 pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO));
1647             pPage->RemoveObject(pTO->GetOrdNum());
1648         }
1649     }
1650 }
1651 
1652 void OutlineViewShell::UpdateOutlineObject( SdPage* pPage, Paragraph* pPara )
1653 {
1654     DBG_ASSERT( pPage, "sd::OutlineViewShell::UpdateOutlineObject(), pPage == 0?" );
1655     DBG_ASSERT( pPara, "sd::OutlineViewShell::UpdateOutlineObject(), pPara == 0?" );
1656 
1657     if( !pPage || !pPara )
1658         return;
1659 
1660     ::Outliner&         rOutliner = pOlView->GetOutliner();
1661     std::unique_ptr<OutlinerParaObject> pOPO;
1662     SdrTextObj*         pTO  = nullptr;
1663 
1664     bool bNewObject = false;
1665 
1666     OutlinerMode eOutlinerMode = OutlinerMode::TitleObject;
1667     pTO = static_cast<SdrTextObj*>(pPage->GetPresObj( PRESOBJ_TEXT ));
1668     if( !pTO )
1669     {
1670         eOutlinerMode = OutlinerMode::OutlineObject;
1671         pTO = OutlineView::GetOutlineTextObject( pPage );
1672     }
1673 
1674     // how many paragraphs in the outline?
1675     sal_Int32 nTitlePara     = rOutliner.GetAbsPos( pPara );
1676     sal_Int32 nPara          = nTitlePara + 1;
1677     sal_Int32 nParasInLayout = 0;
1678     pPara = rOutliner.GetParagraph( nPara );
1679     while( pPara && !::Outliner::HasParaFlag(pPara, ParaFlag::ISPAGE) )
1680     {
1681         nParasInLayout++;
1682         pPara = rOutliner.GetParagraph( ++nPara );
1683     }
1684     if( nParasInLayout )
1685     {
1686         // create an OutlinerParaObject
1687         pOPO  = rOutliner.CreateParaObject( nTitlePara + 1, nParasInLayout );
1688     }
1689 
1690     if( pOPO )
1691     {
1692         DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1693 
1694         // do we need an outline text object?
1695         if( !pTO )
1696         {
1697             pTO = OutlineView::CreateOutlineTextObject( pPage );
1698             bNewObject = true;
1699         }
1700 
1701         // page object, outline text in Outliner:
1702         // apply text
1703         if( pTO )
1704         {
1705             pOPO->SetVertical( pTO->IsVerticalWriting() );
1706             pOPO->SetOutlinerMode( eOutlinerMode );
1707             if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) )
1708             {
1709                 // do nothing, same text already set
1710             }
1711             else
1712             {
1713                 if( !bNewObject && pOlView->isRecordingUndo() )
1714                     pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1715 
1716                 pTO->SetOutlinerParaObject( std::move(pOPO) );
1717                 pTO->SetEmptyPresObj( false );
1718                 pTO->ActionChanged();
1719             }
1720         }
1721     }
1722     else if( pTO )
1723     {
1724         // page object but no outline text:
1725         // if the object is in the outline of the page -> default text
1726 
1727         // otherwise delete object
1728         if( pPage->IsPresObj(pTO) )
1729         {
1730             if( !pTO->IsEmptyPresObj() )
1731             {
1732                 DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1733 
1734                 // delete old OutlinerParaObject, too
1735                 if( pOlView->isRecordingUndo() )
1736                     pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1737                 pPage->RestoreDefaultText( pTO );
1738                 pTO->SetEmptyPresObj(true);
1739                 pTO->ActionChanged();
1740             }
1741         }
1742         else
1743         {
1744             DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1745             if( pOlView->isRecordingUndo() )
1746                 pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO));
1747             pPage->RemoveObject(pTO->GetOrdNum());
1748         }
1749     }
1750 }
1751 
1752 /**
1753  * Fill Outliner from Stream
1754  */
1755 ErrCode OutlineViewShell::ReadRtf(SvStream& rInput)
1756 {
1757     ErrCode bRet = ERRCODE_NONE;
1758 
1759     ::Outliner& rOutl = pOlView->GetOutliner();
1760 
1761     OutlineViewPageChangesGuard aGuard( pOlView.get() );
1762     OutlineViewModelChangeGuard aGuard2( *pOlView );
1763 
1764     bRet = rOutl.Read( rInput, OUString(), EETextFormat::Rtf, GetDocSh()->GetHeaderAttributes() );
1765 
1766     SdPage* pPage = GetDoc()->GetSdPage( GetDoc()->GetSdPageCount(PageKind::Standard) - 1, PageKind::Standard );
1767     SfxStyleSheet* pTitleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE );
1768     SfxStyleSheet* pOutlSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
1769 
1770     sal_Int32 nParaCount = rOutl.GetParagraphCount();
1771     if ( nParaCount > 0 )
1772     {
1773         for ( sal_Int32 nPara = 0; nPara < nParaCount; nPara++ )
1774         {
1775             pOlView->UpdateParagraph( nPara );
1776 
1777             sal_Int16 nDepth = rOutl.GetDepth( nPara );
1778 
1779             if( (nDepth == 0) || !nPara )
1780             {
1781                 Paragraph* pPara = rOutl.GetParagraph( nPara );
1782                 rOutl.SetDepth(pPara, -1);
1783                 rOutl.SetParaFlag(pPara, ParaFlag::ISPAGE);
1784 
1785                 rOutl.SetStyleSheet( nPara, pTitleSheet );
1786 
1787                 if( nPara ) // first slide already exists
1788                     pOlView->InsertSlideForParagraph( pPara );
1789             }
1790             else
1791             {
1792                 rOutl.SetDepth( rOutl.GetParagraph( nPara ), nDepth - 1 );
1793                 OUString aStyleSheetName = pOutlSheet->GetName();
1794                 if (!aStyleSheetName.isEmpty())
1795                     aStyleSheetName = aStyleSheetName.copy(0, aStyleSheetName.getLength() - 1);
1796                 aStyleSheetName += OUString::number( nDepth );
1797                 SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
1798                 SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pOutlSheet->GetFamily() ) );
1799                 DBG_ASSERT( pStyle, "AutoStyleSheetName - Style not found!" );
1800                 if ( pStyle )
1801                     rOutl.SetStyleSheet( nPara, pStyle );
1802             }
1803         }
1804     }
1805 
1806     rOutl.GetUndoManager().Clear();
1807 
1808     return bRet;
1809 }
1810 
1811 void OutlineViewShell::WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >& rSequence )
1812 {
1813     WriteFrameViewData();
1814 
1815     ViewShell::WriteUserDataSequence( rSequence );
1816 }
1817 
1818 void OutlineViewShell::ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >& rSequence )
1819 {
1820     WriteFrameViewData();
1821 
1822     ViewShell::ReadUserDataSequence( rSequence );
1823 
1824     ReadFrameViewData( mpFrameView );
1825 }
1826 
1827 void OutlineViewShell::VisAreaChanged(const ::tools::Rectangle& rRect)
1828 {
1829     ViewShell::VisAreaChanged( rRect );
1830 
1831     GetViewShellBase().GetDrawController().FireVisAreaChanged(rRect);
1832 }
1833 
1834 /** If there is a valid controller then create a new instance of
1835     <type>AccessibleDrawDocumentView</type>.  Otherwise return an empty
1836     reference.
1837 */
1838 css::uno::Reference<css::accessibility::XAccessible>
1839     OutlineViewShell::CreateAccessibleDocumentView (::sd::Window* pWindow)
1840 {
1841     OSL_ASSERT (GetViewShell()!=nullptr);
1842     if (GetViewShell()->GetController() != nullptr)
1843     {
1844         ::accessibility::AccessibleOutlineView* pDocumentView =
1845             new ::accessibility::AccessibleOutlineView (
1846                 pWindow,
1847                 this,
1848                 GetViewShell()->GetController(),
1849                 pWindow->GetAccessibleParentWindow()->GetAccessible());
1850         pDocumentView->Init();
1851         return css::uno::Reference<css::accessibility::XAccessible>
1852             (static_cast< css::uno::XWeak*>(pDocumentView),
1853                 css::uno::UNO_QUERY);
1854     }
1855 
1856     SAL_WARN("sd", "OutlineViewShell::CreateAccessibleDocumentView: no controller");
1857     return css::uno::Reference< css::accessibility::XAccessible >();
1858 }
1859 
1860 void OutlineViewShell::GetState (SfxItemSet& rSet)
1861 {
1862     // Iterate over all requested items in the set.
1863     SfxWhichIter aIter( rSet );
1864     sal_uInt16 nWhich = aIter.FirstWhich();
1865     while (nWhich)
1866     {
1867         switch (nWhich)
1868         {
1869             case SID_SEARCH_ITEM:
1870             case SID_SEARCH_OPTIONS:
1871                 // Call common (old) implementation in the document shell.
1872                 GetDocSh()->GetState (rSet);
1873                 break;
1874             default:
1875                 SAL_WARN("sd", "OutlineViewShell::GetState(): can not handle which id " << nWhich);
1876                 break;
1877         }
1878         nWhich = aIter.NextWhich();
1879     }
1880 }
1881 
1882 void OutlineViewShell::SetCurrentPage (SdPage* pPage)
1883 {
1884     // Adapt the selection of the model.
1885     for (sal_uInt16 i=0; i<GetDoc()->GetSdPageCount(PageKind::Standard); i++)
1886         GetDoc()->SetSelected(
1887             GetDoc()->GetSdPage(i, PageKind::Standard),
1888             false);
1889     GetDoc()->SetSelected (pPage, true);
1890 
1891     DrawController& rController(GetViewShellBase().GetDrawController());
1892     rController.FireSelectionChangeListener();
1893     rController.FireSwitchCurrentPage (pPage);
1894 
1895     pOlView->SetActualPage(pPage);
1896 }
1897 
1898 } // end of namespace sd
1899 
1900 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1901