xref: /aoo42x/main/sd/source/ui/view/ViewShellBase.cxx (revision 95a18594)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include <comphelper/processfactory.hxx>
28 
29 #include <com/sun/star/frame/UnknownModuleException.hpp>
30 #include <com/sun/star/frame/XModuleManager.hpp>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 
34 #include "ViewShellBase.hxx"
35 #include <algorithm>
36 #include "EventMultiplexer.hxx"
37 #include "cache/SlsPageCacheManager.hxx"
38 #include "sdresid.hxx"
39 #include "app.hrc"
40 #include "strings.hrc"
41 #include "glob.hrc"
42 #include "unokywds.hxx"
43 #include <svx/svxids.hrc>
44 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
45 #include "DrawDocShell.hxx"
46 #include <sfx2/app.hxx>
47 #include "PaneChildWindows.hxx"
48 #include "NotesChildWindow.hxx"
49 #include "ViewShellManager.hxx"
50 #include "DrawController.hxx"
51 #include "UpdateLockManager.hxx"
52 #include "FrameView.hxx"
53 #include "ViewTabBar.hxx"
54 #include <sfx2/event.hxx>
55 #include "drawdoc.hxx"
56 #include <sfx2/dispatch.hxx>
57 #include <sfx2/request.hxx>
58 #include <sfx2/printer.hxx>
59 #include "DrawViewShell.hxx"
60 #include "GraphicViewShell.hxx"
61 #include "OutlineViewShell.hxx"
62 #include "SlideSorterViewShell.hxx"
63 #include "PresentationViewShell.hxx"
64 #include "FormShellManager.hxx"
65 #include "ToolBarManager.hxx"
66 #include "taskpane/PanelId.hxx"
67 #include "Window.hxx"
68 #include "framework/ConfigurationController.hxx"
69 #include "DocumentRenderer.hxx"
70 
71 #include <com/sun/star/frame/XFrame.hpp>
72 #include <com/sun/star/awt/XWindow.hpp>
73 #include <com/sun/star/frame/XController.hpp>
74 #include <com/sun/star/frame/XModel.hpp>
75 #include <com/sun/star/document/XViewDataSupplier.hpp>
76 #include <com/sun/star/container/XIndexAccess.hpp>
77 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
78 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
79 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
80 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
81 #include <com/sun/star/drawing/framework/ResourceId.hpp>
82 #include "framework/FrameworkHelper.hxx"
83 
84 #include <rtl/ref.hxx>
85 #include <sfx2/msg.hxx>
86 #include <sfx2/objface.hxx>
87 #include <sfx2/viewfrm.hxx>
88 #include <sfx2/sidebar/EnumContext.hxx>
89 #include <svl/whiter.hxx>
90 #include <comphelper/processfactory.hxx>
91 #include <vcl/msgbox.hxx>
92 #include <tools/diagnose_ex.h>
93 
94 #include "fubullet.hxx"
95 
96 using namespace sd;
97 #define ViewShellBase
98 #include "sdslots.hxx"
99 
100 using ::sd::framework::FrameworkHelper;
101 using ::rtl::OUString;
102 using namespace com::sun::star::uno;
103 using namespace com::sun::star::frame;
104 using namespace com::sun::star::container;
105 using namespace com::sun::star::lang;
106 using namespace com::sun::star::beans;
107 
108 namespace {
109 
110 class CurrentPageSetter
111 {
112 public:
113     CurrentPageSetter (ViewShellBase& rBase);
114     void operator () (bool);
115 private:
116     ViewShellBase& mrBase;
117 };
118 
119 } // end of anonymous namespace
120 
121 
122 using namespace ::com::sun::star;
123 using namespace ::com::sun::star::uno;
124 using namespace ::com::sun::star::drawing::framework;
125 using ::sd::framework::FrameworkHelper;
126 
127 namespace sd {
128 
129 class ViewShellBase::Implementation
130 {
131 public:
132     /** Main controller of the view shell.  During the switching from one
133         stacked shell to another this pointer may be NULL.
134     */
135     ::rtl::Reference<DrawController> mpController;
136 
137     /** The view tab bar is the control for switching between different
138         views in one pane.
139     */
140     ::rtl::Reference<ViewTabBar> mpViewTabBar;
141 
142 	// contains the complete area of the current view relative to the frame window
143 	Rectangle maClientArea;
144 
145     // This is set to true when PrepareClose() is called.
146     bool mbIsClosing;
147 
148     /** The view window is the parent of all UI elements that belong to the
149         view or ViewShell.  This comprises the rulers, the scroll bars, and
150         the content window.
151         It does not include the ViewTabBar.
152     */
153     ::boost::scoped_ptr< ::Window> mpViewWindow;
154 
155     ::boost::shared_ptr<ToolBarManager> mpToolBarManager;
156 
157     ::boost::shared_ptr<ViewShellManager> mpViewShellManager;
158 
159     ::boost::shared_ptr<tools::EventMultiplexer> mpEventMultiplexer;
160 
161     ::boost::shared_ptr<UpdateLockManager> mpUpdateLockManager;
162 
163     ::boost::shared_ptr<FormShellManager> mpFormShellManager;
164 
165     Implementation (ViewShellBase& rBase);
166     ~Implementation (void);
167 
168     void LateInit (void);
169 
170     /** Show or hide the ViewTabBar.
171         @param bShow
172             When <TRUE/> then the ViewTabBar is shown, otherwise it is hidden.
173     */
174     void ShowViewTabBar (bool bShow);
175 
176     /** Common code of ViewShellBase::OuterResizePixel() and
177         ViewShellBase::InnerResizePixel().
178     */
179     void ResizePixel (
180         const Point& rOrigin,
181         const Size& rSize,
182         bool bOuterResize);
183 
184     /** Show or hide the specified pane.  The visibility state is taken
185         fromthe given request.
186         @param rRequest
187             The request determines the new visibility state.  The state can
188             either be toggled or be set to a given value.
189         @param rsPaneURL
190             This URL specifies the pane whose visibility state to set.
191         @param rsViewURL
192             When the pane becomes visible then this view URL specifies which
193             type of view to show in it.
194     */
195     void SetPaneVisibility (
196         const SfxRequest& rRequest,
197         const ::rtl::OUString& rsPaneURL,
198         const ::rtl::OUString& rsViewURL);
199 
200     void GetSlotState (SfxItemSet& rSet);
201 
202     void ProcessRestoreEditingViewSlot (void);
203     void ProcessTaskPaneSlot (SfxRequest& rRequest);
204 
205 private:
206     ViewShellBase& mrBase;
207 
208     /** Hold a reference to the page cache manager of the slide sorter in
209         order to ensure that it stays alive while the ViewShellBase is
210         alive.
211     */
212     ::boost::shared_ptr<slidesorter::cache::PageCacheManager> mpPageCacheManager;
213 };
214 
215 
216 namespace {
217 /** The only task of this window is to forward key presses to the content
218     window of the main view shell.  With the key press it forwards the focus
219     so that it is not called very often.
220 */
221 class FocusForwardingWindow : public ::Window
222 {
223 public:
224     FocusForwardingWindow (::Window& rParentWindow, ViewShellBase& rBase);
225     virtual ~FocusForwardingWindow (void);
226     virtual void KeyInput (const KeyEvent& rEvent);
227     virtual void Command (const CommandEvent& rEvent);
228 
229 private:
230     ViewShellBase& mrBase;
231 };
232 } // end of anonymous namespace
233 
234 
235 //===== ViewShellBase =========================================================
236 
237 TYPEINIT1(ViewShellBase, SfxViewShell);
238 
239 // We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
240 // new ViewShellBase object has been constructed.
241 
242 SfxViewFactory* ViewShellBase::pFactory;
243 SfxViewShell* __EXPORT ViewShellBase::CreateInstance (
244     SfxViewFrame *pFrame, SfxViewShell *pOldView)
245 {
246     ViewShellBase* pBase = new ViewShellBase(pFrame, pOldView);
247     pBase->LateInit(OUString());
248     return pBase;
249 }
250 void ViewShellBase::RegisterFactory( sal_uInt16 nPrio )
251 {
252     pFactory = new SfxViewFactory(
253         &CreateInstance,&InitFactory,nPrio,"Default");
254     InitFactory();
255 }
256 void ViewShellBase::InitFactory()
257 {
258 	SFX_VIEW_REGISTRATION(DrawDocShell);
259 }
260 
261 
262 
263 SFX_IMPL_INTERFACE(ViewShellBase, SfxViewShell, SdResId(STR_VIEWSHELLBASE))
264 {
265 }
266 
267 
268 
269 
270 ViewShellBase::ViewShellBase (
271     SfxViewFrame* _pFrame,
272     SfxViewShell*)
273     : SfxViewShell (_pFrame,
274           SFX_VIEW_CAN_PRINT
275         | SFX_VIEW_HAS_PRINTOPTIONS),
276       maMutex(),
277       mpImpl(),
278       mpDocShell (NULL),
279       mpDocument (NULL)
280 {
281     mpImpl.reset(new Implementation(*this));
282     mpImpl->mpViewWindow.reset(new FocusForwardingWindow(_pFrame->GetWindow(),*this));
283     mpImpl->mpViewWindow->SetBackground(Wallpaper());
284     mpImpl->mpUpdateLockManager.reset(new UpdateLockManager(*this));
285 
286     _pFrame->GetWindow().SetBackground(Wallpaper());
287 
288     // Set up the members in the correct order.
289     if (GetViewFrame()->GetObjectShell()->ISA(DrawDocShell))
290         mpDocShell = static_cast<DrawDocShell*>(
291             GetViewFrame()->GetObjectShell());
292     if (mpDocShell != NULL)
293         mpDocument = mpDocShell->GetDoc();
294     mpImpl->mpViewShellManager.reset(new ViewShellManager(*this));
295 
296     SetWindow(mpImpl->mpViewWindow.get());
297 
298     // Hide the window to avoid complaints from Sfx...SwitchViewShell...
299     _pFrame->GetWindow().Hide();
300 }
301 
302 
303 
304 
305 /** In this destructor the order in which some of the members are destroyed
306     (and/or being prepared to being destroyed) is important.  Change it only
307     when you know what you are doing.
308 */
309 ViewShellBase::~ViewShellBase (void)
310 {
311     // Tell the controller that the ViewShellBase is not available anymore.
312     if (mpImpl->mpController.get() != NULL)
313         mpImpl->mpController->ReleaseViewShellBase();
314 
315     // We have to hide the main window to prevent SFX complaining after a
316     // reload about it being already visible.
317     ViewShell* pShell = GetMainViewShell().get();
318     if (pShell!=NULL
319         && pShell->GetActiveWindow()!=NULL
320         && pShell->GetActiveWindow()->GetParent()!=NULL)
321     {
322         pShell->GetActiveWindow()->GetParent()->Hide();
323     }
324 
325     mpImpl->mpUpdateLockManager->Disable();
326     mpImpl->mpToolBarManager->Shutdown();
327     mpImpl->mpViewShellManager->Shutdown();
328 
329     EndListening(*GetViewFrame());
330     EndListening(*GetDocShell());
331 
332     SetWindow(NULL);
333 }
334 
335 
336 
337 
338 void ViewShellBase::LateInit (const ::rtl::OUString& rsDefaultView)
339 {
340     StartListening(*GetViewFrame(),sal_True);
341     StartListening(*GetDocShell(),sal_True);
342     mpImpl->LateInit();
343     InitializeFramework();
344 
345     mpImpl->mpEventMultiplexer.reset(new tools::EventMultiplexer (*this));
346 
347     mpImpl->mpFormShellManager.reset(new FormShellManager(*this));
348 
349     mpImpl->mpToolBarManager = ToolBarManager::Create(
350         *this,
351         mpImpl->mpEventMultiplexer,
352         mpImpl->mpViewShellManager);
353 
354     try
355     {
356         Reference<XControllerManager> xControllerManager (GetDrawController(), UNO_QUERY_THROW);
357         Reference<XConfigurationController> xConfigurationController (
358             xControllerManager->getConfigurationController());
359         if (xConfigurationController.is())
360         {
361             OUString sView (rsDefaultView);
362             if (sView.getLength() == 0)
363                 sView = GetInitialViewShellType();
364 
365             ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(*this));
366 
367             // Create the resource ids for the center pane and view.
368             const Reference<drawing::framework::XResourceId> xCenterPaneId (
369                 pHelper->CreateResourceId(FrameworkHelper::msCenterPaneURL));
370             const Reference<drawing::framework::XResourceId> xCenterViewId (
371                 pHelper->CreateResourceId(sView, xCenterPaneId));
372 
373             // Request center pane and view.
374             xConfigurationController->requestResourceActivation(xCenterPaneId, ResourceActivationMode_ADD);
375             xConfigurationController->requestResourceActivation(xCenterViewId, ResourceActivationMode_REPLACE);
376 
377             // Process configuration events synchronously until the center view
378             // has been created.
379             sd::framework::ConfigurationController* pConfigurationController
380                 = dynamic_cast<sd::framework::ConfigurationController*>(xConfigurationController.get());
381             if (pConfigurationController != NULL)
382             {
383                 while (
384                     ! pConfigurationController->getResource(xCenterViewId).is()
385                         && pConfigurationController->hasPendingRequests())
386                 {
387                     pConfigurationController->ProcessEvent();
388                 }
389             }
390         }
391     }
392     catch (RuntimeException&)
393     {}
394 
395     // AutoLayouts have to be ready.
396     GetDocument()->StopWorkStartupDelay();
397 
398     UpdateBorder();
399 
400     // Remember the type of the current main view shell in the frame view.
401     ViewShell* pViewShell = GetMainViewShell().get();
402     if (pViewShell != NULL)
403     {
404         FrameView* pFrameView = pViewShell->GetFrameView();
405         if (pFrameView != NULL)
406             pFrameView->SetViewShellTypeOnLoad(pViewShell->GetShellType());
407     }
408 }
409 
410 
411 
412 
413 ::boost::shared_ptr<ViewShellManager> ViewShellBase::GetViewShellManager (void) const
414 {
415     return mpImpl->mpViewShellManager;
416 }
417 
418 
419 
420 
421 ::boost::shared_ptr<ViewShell> ViewShellBase::GetMainViewShell (void) const
422 {
423     ::boost::shared_ptr<ViewShell> pMainViewShell (
424         framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))
425             ->GetViewShell(framework::FrameworkHelper::msCenterPaneURL));
426     if (pMainViewShell.get() == NULL)
427         pMainViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))
428             ->GetViewShell(framework::FrameworkHelper::msFullScreenPaneURL);
429     return pMainViewShell;
430 }
431 
432 
433 
434 
435 ViewShellBase* ViewShellBase::GetViewShellBase (SfxViewFrame* pViewFrame)
436 {
437     ViewShellBase* pBase = NULL;
438 
439     if (pViewFrame != NULL)
440     {
441         // Get the view shell for the frame and cast it to
442         // sd::ViewShellBase.
443         SfxViewShell* pSfxViewShell = pViewFrame->GetViewShell();
444         if (pSfxViewShell!=NULL && pSfxViewShell->ISA(::sd::ViewShellBase))
445             pBase = static_cast<ViewShellBase*>(pSfxViewShell);
446     }
447 
448     return pBase;
449 }
450 
451 
452 
453 
454 DrawDocShell* ViewShellBase::GetDocShell (void) const
455 {
456     return mpDocShell;
457 }
458 
459 
460 
461 SdDrawDocument* ViewShellBase::GetDocument (void) const
462 {
463     return mpDocument;
464 }
465 
466 
467 
468 
469 void ViewShellBase::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
470 {
471     SfxViewShell::Notify(rBC, rHint);
472 
473 	if (rHint.IsA(TYPE(SfxEventHint)))
474 	{
475         switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
476 		{
477             case SFX_EVENT_OPENDOC:
478                 if( GetDocument() && GetDocument()->IsStartWithPresentation() )
479                 {
480                     if( GetViewFrame() )
481                     {
482                         GetDocument()->SetStartWithPresentation( false );
483                         GetViewFrame()->GetDispatcher()->Execute(
484                             SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON );
485                     }
486                 }
487                 else
488                 {
489                     //                    mpPaneManager->InitPanes();
490                 }
491                 break;
492 
493             default:
494                 break;
495         }
496 	}
497 }
498 
499 
500 
501 
502 void ViewShellBase::InitializeFramework (void)
503 {
504 }
505 
506 
507 
508 
509 void ViewShellBase::InnerResizePixel (const Point& rOrigin, const Size &rSize)
510 {
511     Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
512     if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
513     {
514         SvBorder aBorder( GetBorderPixel() );
515         Size aSize( rSize );
516         aSize.Width() -= (aBorder.Left() + aBorder.Right());
517         aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
518         Size aObjSizePixel = mpImpl->mpViewWindow->LogicToPixel( aObjSize, MAP_100TH_MM );
519 		SfxViewShell::SetZoomFactor(
520             Fraction( aSize.Width(), std::max( aObjSizePixel.Width(), (long int)1 ) ),
521 			Fraction( aSize.Height(), std::max( aObjSizePixel.Height(), (long int)1) ) );
522     }
523 
524     mpImpl->ResizePixel(rOrigin, rSize, false);
525 }
526 
527 
528 
529 
530 void ViewShellBase::OuterResizePixel (const Point& rOrigin, const Size &rSize)
531 {
532     mpImpl->ResizePixel (rOrigin, rSize, true);
533 }
534 
535 
536 
537 
538 void ViewShellBase::Rearrange (void)
539 {
540     OSL_ASSERT(GetViewFrame()!=NULL);
541 
542     // There is a bug in the communication between embedded objects and the
543     // framework::LayoutManager that leads to missing resize updates.  The
544     // following workaround enforces such an update by cycling the border to
545     // zero and back to the current value.
546     if (GetWindow() != NULL)
547     {
548         SetBorderPixel(SvBorder());
549         UpdateBorder(true);
550     }
551     else
552     {
553         OSL_TRACE("Rearrange: window missing");
554     }
555 
556     GetViewFrame()->Resize(sal_True);
557 }
558 
559 
560 
561 
562 ErrCode ViewShellBase::DoVerb (long nVerb)
563 {
564     ErrCode aResult = ERRCODE_NONE;
565 
566     ::sd::ViewShell* pShell = GetMainViewShell().get();
567     if (pShell != NULL)
568         aResult = pShell->DoVerb (nVerb);
569 
570     return aResult;
571 }
572 
573 
574 
575 
576 Reference<view::XRenderable> ViewShellBase::GetRenderable (void)
577 {
578     // Create a new DocumentRenderer on every call.  It observes the life
579     // time of this ViewShellBase object.
580     return Reference<view::XRenderable>(new DocumentRenderer(*this));
581 }
582 
583 
584 
585 
586 SfxPrinter* ViewShellBase::GetPrinter (sal_Bool bCreate)
587 {
588     OSL_ASSERT(mpImpl.get()!=NULL);
589 
590 	return GetDocShell()->GetPrinter (bCreate);
591 }
592 
593 
594 
595 
596 sal_uInt16 ViewShellBase::SetPrinter (
597     SfxPrinter* pNewPrinter,
598     sal_uInt16 nDiffFlags,
599     bool bIsAPI)
600 {
601     OSL_ASSERT(mpImpl.get()!=NULL);
602 
603 	GetDocShell()->SetPrinter(pNewPrinter);
604 
605 	if ( (nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ||
606 		  nDiffFlags & SFX_PRINTER_CHG_SIZE) && pNewPrinter  )
607 	{
608 		MapMode aMap = pNewPrinter->GetMapMode();
609 		aMap.SetMapUnit(MAP_100TH_MM);
610 		MapMode aOldMap = pNewPrinter->GetMapMode();
611 		pNewPrinter->SetMapMode(aMap);
612 		Size aNewSize = pNewPrinter->GetOutputSize();
613 
614 		sal_Bool bScaleAll = sal_False;
615 		if ( bIsAPI )
616 		{
617 			WarningBox aWarnBox (
618                 GetWindow(),
619                 (WinBits)(WB_YES_NO | WB_DEF_YES),
620                 String(SdResId(STR_SCALE_OBJS_TO_PAGE)));
621 			bScaleAll = (aWarnBox.Execute() == RET_YES);
622 		}
623 
624         ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
625             ::boost::dynamic_pointer_cast<DrawViewShell>(GetMainViewShell()));
626 		if (pDrawViewShell)
627 		{
628 			SdPage* pPage = GetDocument()->GetSdPage(
629                 0, PK_STANDARD );
630 			pDrawViewShell->SetPageSizeAndBorder (
631                 pDrawViewShell->GetPageKind(),
632                 aNewSize,
633                 -1,-1,-1,-1,
634                 bScaleAll,
635                 pNewPrinter->GetOrientation(),
636                 pPage->GetPaperBin(),
637                 pPage->IsBackgroundFullSize());
638 		}
639 
640 		pNewPrinter->SetMapMode(aOldMap);
641     }
642 
643     return 0;
644 }
645 
646 
647 
648 
649 SfxTabPage*  ViewShellBase::CreatePrintOptionsPage(
650     ::Window *pParent,
651     const SfxItemSet &rOptions)
652 {
653     (void)pParent;
654     (void)rOptions;
655     return NULL;
656     //    return mpImpl->mpPrintManager->CreatePrintOptionsPage (pParent, rOptions);
657 }
658 
659 
660 
661 
662 void ViewShellBase::UIActivating( SfxInPlaceClient* pClient )
663 {
664     mpImpl->ShowViewTabBar(false);
665 
666 	ViewShell* pViewShell = GetMainViewShell().get();
667 	if ( pViewShell )
668     	pViewShell->UIActivating( pClient );
669 
670     SfxViewShell::UIActivating( pClient );
671 }
672 
673 
674 
675 
676 void ViewShellBase::UIDeactivated( SfxInPlaceClient* pClient )
677 {
678     SfxViewShell::UIDeactivated( pClient );
679 
680     mpImpl->ShowViewTabBar(true);
681 
682 	ViewShell* pViewShell = GetMainViewShell().get();
683 	if ( pViewShell )
684     	pViewShell->UIDeactivated( pClient );
685 }
686 
687 
688 
689 
690 SvBorder ViewShellBase::GetBorder (bool )
691 {
692     int nTop = 0;
693     if (mpImpl->mpViewTabBar.is() && mpImpl->mpViewTabBar->GetTabControl()->IsVisible())
694         nTop = mpImpl->mpViewTabBar->GetHeight();
695     return SvBorder(0,nTop,0,0);
696 }
697 
698 
699 
700 
701 void ViewShellBase::Execute (SfxRequest& rRequest)
702 {
703 	sal_uInt16 nSlotId = rRequest.GetSlot();
704 
705 	switch (nSlotId)
706     {
707         case SID_SWITCH_SHELL:
708         {
709             Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
710             if (xControllerManager.is())
711             {
712                 Reference<XConfigurationController> xConfigurationController (
713                     xControllerManager->getConfigurationController());
714                 if (xConfigurationController.is())
715                     xConfigurationController->update();
716             }
717         }
718         break;
719 
720         case SID_LEFT_PANE_DRAW:
721             mpImpl->SetPaneVisibility(
722                 rRequest,
723                 framework::FrameworkHelper::msLeftDrawPaneURL,
724                 framework::FrameworkHelper::msSlideSorterURL);
725             break;
726 
727         case SID_LEFT_PANE_IMPRESS:
728             mpImpl->SetPaneVisibility(
729                 rRequest,
730                 framework::FrameworkHelper::msLeftImpressPaneURL,
731                 framework::FrameworkHelper::msSlideSorterURL);
732             break;
733 
734         case SID_TASKPANE:
735             mpImpl->SetPaneVisibility(
736                 rRequest,
737                 framework::FrameworkHelper::msRightPaneURL,
738                 framework::FrameworkHelper::msTaskPaneURL);
739             break;
740 
741         case SID_NORMAL_MULTI_PANE_GUI:
742         case SID_SLIDE_SORTER_MULTI_PANE_GUI:
743         case SID_DRAWINGMODE:
744         case SID_DIAMODE:
745         case SID_OUTLINEMODE:
746         case SID_NOTESMODE:
747         case SID_HANDOUTMODE:
748             framework::FrameworkHelper::Instance(*this)->HandleModeChangeSlot(nSlotId, rRequest);
749             break;
750 
751         case SID_WIN_FULLSCREEN:
752             // The full screen mode is not supported.  Ignore the request.
753             break;
754 
755         case SID_SHOW_TOOL_PANEL:
756             mpImpl->ProcessTaskPaneSlot(rRequest);
757             break;
758 
759         case SID_RESTORE_EDITING_VIEW:
760             mpImpl->ProcessRestoreEditingViewSlot();
761             break;
762 
763         default:
764             // Ignore any other slot.
765 			rRequest.Ignore ();
766             break;
767     }
768 }
769 
770 
771 
772 
773 void ViewShellBase::GetState (SfxItemSet& rSet)
774 {
775     // The full screen mode is not supported.  Disable the the slot so that
776     // it appears grayed out when somebody uses configures the menu to show
777     // an menu item for it.
778     //    if (rSet.GetItemState(SID_WIN_FULLSCREEN) == SFX_ITEM_AVAILABLE)
779     //        rSet.DisableItem(SID_WIN_FULLSCREEN);
780 
781     mpImpl->GetSlotState(rSet);
782 
783 	FuBullet::GetSlotState( rSet, 0, GetViewFrame() );
784 }
785 
786 
787 
788 
789 void ViewShellBase::WriteUserDataSequence (
790     ::com::sun::star::uno::Sequence <
791     ::com::sun::star::beans::PropertyValue >& rSequence,
792     sal_Bool bBrowse)
793 {
794     // Forward call to main sub shell.
795     ViewShell* pShell = GetMainViewShell().get();
796     if (pShell != NULL)
797         pShell->WriteUserDataSequence (rSequence, bBrowse);
798 }
799 
800 
801 
802 
803 void ViewShellBase::ReadUserDataSequence (
804     const ::com::sun::star::uno::Sequence <
805     ::com::sun::star::beans::PropertyValue >& rSequence,
806     sal_Bool bBrowse)
807 {
808     // Forward call to main sub shell.
809     ViewShell* pShell = GetMainViewShell().get();
810     if (pShell != NULL)
811     {
812         pShell->ReadUserDataSequence (rSequence, bBrowse);
813 
814         // For certain shell types ReadUserDataSequence may have changed the
815         // type to another one.  Make sure that the center pane shows the
816         // right view shell.
817         switch (pShell->GetShellType())
818         {
819             case ViewShell::ST_IMPRESS:
820             case ViewShell::ST_NOTES:
821             case ViewShell::ST_HANDOUT:
822             {
823                 ::rtl::OUString sViewURL;
824                 switch (PTR_CAST(DrawViewShell, pShell)->GetPageKind())
825                 {
826                     default:
827                     case PK_STANDARD:
828                         sViewURL = framework::FrameworkHelper::msImpressViewURL;
829                         break;
830                     case PK_NOTES:
831                         sViewURL = framework::FrameworkHelper::msNotesViewURL;
832                         break;
833                     case PK_HANDOUT:
834                         sViewURL = framework::FrameworkHelper::msHandoutViewURL;
835                         break;
836                 }
837                 if (sViewURL.getLength() > 0)
838                     framework::FrameworkHelper::Instance(*this)->RequestView(
839                         sViewURL,
840                         framework::FrameworkHelper::msCenterPaneURL);
841             }
842             break;
843 
844             default:
845                 break;
846         }
847     }
848 }
849 
850 
851 
852 
853 void ViewShellBase::Activate (sal_Bool bIsMDIActivate)
854 {
855     SfxViewShell::Activate(bIsMDIActivate);
856 
857     Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
858     if (xControllerManager.is())
859     {
860         Reference<XConfigurationController> xConfigurationController (
861             xControllerManager->getConfigurationController());
862         if (xConfigurationController.is())
863             xConfigurationController->update();
864     }
865     GetToolBarManager()->RequestUpdate();
866 
867     ContextChangeEventMultiplexer::NotifyContextChange(
868         GetController(),
869         ::sfx2::sidebar::EnumContext::Context_Default);
870 }
871 
872 
873 
874 
875 void ViewShellBase::Deactivate (sal_Bool bIsMDIActivate)
876 {
877     SfxViewShell::Deactivate(bIsMDIActivate);
878 }
879 
880 
881 
882 
883 void ViewShellBase::SetZoomFactor (
884     const Fraction &rZoomX,
885     const Fraction &rZoomY)
886 {
887     SfxViewShell::SetZoomFactor (rZoomX, rZoomY);
888     // Forward call to main sub shell.
889     ViewShell* pShell = GetMainViewShell().get();
890     if (pShell != NULL)
891         pShell->SetZoomFactor (rZoomX, rZoomY);
892 }
893 
894 
895 
896 
897 sal_uInt16 ViewShellBase::PrepareClose (sal_Bool bUI, sal_Bool bForBrowsing)
898 {
899 	sal_uInt16 nResult = SfxViewShell::PrepareClose (bUI, bForBrowsing);
900 
901 	if (nResult == sal_True)
902     {
903         mpImpl->mbIsClosing = true;
904 
905         // Forward call to main sub shell.
906         ViewShell* pShell = GetMainViewShell().get();
907         if (pShell != NULL)
908             nResult = pShell->PrepareClose (bUI, bForBrowsing);
909     }
910 
911     return nResult;
912 }
913 
914 
915 
916 
917 void ViewShellBase::WriteUserData (String& rString, sal_Bool bBrowse)
918 {
919 	SfxViewShell::WriteUserData (rString, bBrowse);
920 
921     // Forward call to main sub shell.
922     ViewShell* pShell = GetMainViewShell().get();
923     if (pShell != NULL)
924         pShell->WriteUserData (rString);
925 }
926 
927 
928 
929 
930 void ViewShellBase::ReadUserData (const String& rString, sal_Bool bBrowse)
931 {
932 	SfxViewShell::ReadUserData (rString, bBrowse);
933 
934     // Forward call to main sub shell.
935     ViewShell* pShell = GetMainViewShell().get();
936     if (pShell != NULL)
937         pShell->ReadUserData (rString);
938 }
939 
940 
941 
942 
943 SdrView* ViewShellBase::GetDrawView (void) const
944 {
945     // Forward call to main sub shell.
946     ViewShell* pShell = GetMainViewShell().get();
947     if (pShell != NULL)
948         return pShell->GetDrawView ();
949     else
950         return SfxViewShell::GetDrawView();
951 }
952 
953 
954 
955 
956 void ViewShellBase::AdjustPosSizePixel (const Point &rOfs, const Size &rSize)
957 {
958 	SfxViewShell::AdjustPosSizePixel (rOfs, rSize);
959 }
960 
961 
962 
963 
964 void ViewShellBase::SetBusyState (bool bBusy)
965 {
966     if (GetDocShell() != NULL)
967         GetDocShell()->SetWaitCursor (bBusy);
968 }
969 
970 
971 
972 
973 void ViewShellBase::UpdateBorder ( bool bForce /* = false */ )
974 {
975     // The following calls to SetBorderPixel() and InvalidateBorder() are
976     // made only for the main view shell.  This not only avoids unnecessary
977     // calls for the views in side panes but prevents calling an already
978     // dying SfxViewShell base class.
979     // For issue #140703# we have to check the existence of the window,
980     // too.  The SfxViewFrame accesses the window without checking it.
981     ViewShell* pMainViewShell = GetMainViewShell().get();
982     if (pMainViewShell != NULL && GetWindow()!=NULL)
983     {
984         SvBorder aCurrentBorder (GetBorderPixel());
985         bool bOuterResize ( ! GetDocShell()->IsInPlaceActive());
986         SvBorder aBorder (GetBorder(bOuterResize));
987         aBorder += pMainViewShell->GetBorder(bOuterResize);
988 
989         if (bForce || (aBorder != aCurrentBorder))
990         {
991             SetBorderPixel (aBorder);
992             InvalidateBorder();
993         }
994     }
995 }
996 
997 
998 
999 
1000 void ViewShellBase::ShowUIControls (bool bVisible)
1001 {
1002     if (mpImpl->mpViewTabBar.is())
1003         mpImpl->mpViewTabBar->GetTabControl()->Show(bVisible);
1004 
1005     ViewShell* pMainViewShell = GetMainViewShell().get();
1006     if (pMainViewShell != NULL)
1007         pMainViewShell->ShowUIControls (bVisible);
1008 
1009     UpdateBorder();
1010     if (bVisible)
1011         Rearrange();
1012 }
1013 
1014 
1015 
1016 
1017 OUString ViewShellBase::GetInitialViewShellType (void)
1018 {
1019     OUString sRequestedView (FrameworkHelper::msImpressViewURL);
1020 
1021     do
1022     {
1023         Reference<document::XViewDataSupplier> xViewDataSupplier (
1024             GetDocShell()->GetModel(), UNO_QUERY);
1025         if ( ! xViewDataSupplier.is())
1026             break;
1027 
1028         Reference<container::XIndexAccess> xViewData (xViewDataSupplier->getViewData());
1029         if ( ! xViewData.is())
1030             break;
1031         if (xViewData->getCount() == 0)
1032             break;
1033 
1034         sal_Int32 nView = 0;
1035 		::com::sun::star::uno::Any aAny = xViewData->getByIndex(nView);
1036     	Sequence<beans::PropertyValue> aProperties;
1037 		if ( ! (aAny >>= aProperties))
1038             break;
1039 
1040         // Search the properties for the one that tells us what page kind to
1041         // use.
1042         for (sal_Int32 n=0; n<aProperties.getLength(); n++)
1043         {
1044             const beans::PropertyValue& rProperty (aProperties[n]);
1045             if (rProperty.Name.compareToAscii(sUNO_View_PageKind) == COMPARE_EQUAL)
1046             {
1047 				sal_Int16 nPageKind = 0;
1048                 rProperty.Value >>= nPageKind;
1049                 switch ((PageKind)nPageKind)
1050                 {
1051                     case PK_STANDARD:
1052                         sRequestedView = FrameworkHelper::msImpressViewURL;
1053                         break;
1054 
1055                     case PK_HANDOUT:
1056                         sRequestedView = FrameworkHelper::msHandoutViewURL;
1057                         break;
1058 
1059                     case PK_NOTES:
1060                         sRequestedView = FrameworkHelper::msNotesViewURL;
1061                         break;
1062 
1063                     default:
1064                         // The page kind is invalid.  This is propably an
1065                         // error by the caller.  We use the standard type to
1066                         // keep things going.
1067                         DBG_ASSERT(sal_False, "ViewShellBase::GetInitialViewShellType: invalid page kind");
1068                         sRequestedView = FrameworkHelper::msImpressViewURL;
1069                         break;
1070                 }
1071                 break;
1072             }
1073 		}
1074     }
1075     while (false);
1076 
1077     return sRequestedView;
1078 }
1079 
1080 
1081 
1082 
1083 /** this method starts the presentation by
1084 	executing the slot SID_PRESENTATION asynchronous */
1085 void ViewShellBase::StartPresentation()
1086 {
1087 	if( GetViewFrame() && GetViewFrame()->GetDispatcher() )
1088 		GetViewFrame()->GetDispatcher()->Execute(SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
1089 }
1090 
1091 
1092 
1093 
1094 
1095 ::boost::shared_ptr<tools::EventMultiplexer> ViewShellBase::GetEventMultiplexer (void)
1096 {
1097     OSL_ASSERT(mpImpl.get()!=NULL);
1098     OSL_ASSERT(mpImpl->mpEventMultiplexer.get()!=NULL);
1099 
1100     return mpImpl->mpEventMultiplexer;
1101 }
1102 
1103 
1104 
1105 
1106 const Rectangle& ViewShellBase::getClientRectangle (void) const
1107 {
1108 	return mpImpl->maClientArea;
1109 }
1110 
1111 
1112 
1113 
1114 ::boost::shared_ptr<UpdateLockManager> ViewShellBase::GetUpdateLockManager (void) const
1115 {
1116     OSL_ASSERT(mpImpl.get()!=NULL);
1117     OSL_ASSERT(mpImpl->mpUpdateLockManager.get()!=NULL);
1118 
1119     return mpImpl->mpUpdateLockManager;
1120 }
1121 
1122 
1123 
1124 
1125 ::boost::shared_ptr<ToolBarManager> ViewShellBase::GetToolBarManager (void) const
1126 {
1127     OSL_ASSERT(mpImpl.get()!=NULL);
1128     OSL_ASSERT(mpImpl->mpToolBarManager.get()!=NULL);
1129 
1130     return mpImpl->mpToolBarManager;
1131 }
1132 
1133 
1134 
1135 
1136 ::boost::shared_ptr<FormShellManager> ViewShellBase::GetFormShellManager (void) const
1137 {
1138     OSL_ASSERT(mpImpl.get()!=NULL);
1139     OSL_ASSERT(mpImpl->mpFormShellManager.get()!=NULL);
1140 
1141     return mpImpl->mpFormShellManager;
1142 }
1143 
1144 
1145 
1146 
1147 DrawController& ViewShellBase::GetDrawController (void) const
1148 {
1149     OSL_ASSERT(mpImpl.get()!=NULL);
1150 
1151     return *mpImpl->mpController;
1152 }
1153 
1154 
1155 
1156 
1157 void ViewShellBase::SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabBar)
1158 {
1159     OSL_ASSERT(mpImpl.get()!=NULL);
1160 
1161     mpImpl->mpViewTabBar = rViewTabBar;
1162 }
1163 
1164 
1165 
1166 
1167 ::Window* ViewShellBase::GetViewWindow (void)
1168 {
1169     OSL_ASSERT(mpImpl.get()!=NULL);
1170 
1171     return mpImpl->mpViewWindow.get();
1172 }
1173 
1174 
1175 ::rtl::OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const ::rtl::OUString& aCmdURL )
1176 {
1177     ::rtl::OUString aLabel;
1178 
1179     if ( aCmdURL.getLength() > 0 ) try
1180     {
1181 		Reference< XMultiServiceFactory > xServiceManager( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
1182 
1183 		Reference< XModuleManager > xModuleManager( xServiceManager->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager") ) ), UNO_QUERY_THROW );
1184 		Reference< XInterface > xIfac( xFrame, UNO_QUERY_THROW );
1185 
1186 		::rtl::OUString aModuleIdentifier( xModuleManager->identify( xIfac ) );
1187 
1188         if( aModuleIdentifier.getLength() > 0 )
1189         {
1190 			Reference< XNameAccess > xNameAccess( xServiceManager->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.UICommandDescription" ) ) ), UNO_QUERY );
1191             if( xNameAccess.is() )
1192             {
1193 				Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels( xNameAccess->getByName( aModuleIdentifier ), UNO_QUERY_THROW );
1194                 Sequence< PropertyValue > aPropSeq;
1195                 if( m_xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq )
1196                 {
1197                     for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
1198                     {
1199                         if( aPropSeq[i].Name.equalsAscii( "Name" ))
1200                         {
1201                             aPropSeq[i].Value >>= aLabel;
1202                             break;
1203                         }
1204                     }
1205                 }
1206             }
1207         }
1208     }
1209     catch ( Exception& )
1210     {
1211     }
1212 
1213 	return aLabel;
1214 }
1215 
1216 ::rtl::OUString ViewShellBase::RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ) const
1217 {
1218 	Reference< XFrame > xFrame( GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(), UNO_QUERY );
1219 	return ImplRetrieveLabelFromCommand( xFrame, aCmdURL );
1220 }
1221 
1222 
1223 
1224 //===== ViewShellBase::Implementation =========================================
1225 
1226 ViewShellBase::Implementation::Implementation (ViewShellBase& rBase)
1227     : mpController(),
1228       mpViewTabBar(),
1229       maClientArea(),
1230       mbIsClosing(false),
1231       mpViewWindow(),
1232       mpToolBarManager(),
1233       mpViewShellManager(),
1234       mpEventMultiplexer(),
1235       mpUpdateLockManager(),
1236       mpFormShellManager(),
1237       mrBase(rBase),
1238       mpPageCacheManager(slidesorter::cache::PageCacheManager::Instance())
1239 {
1240 }
1241 
1242 
1243 
1244 
1245 ViewShellBase::Implementation::~Implementation (void)
1246 {
1247     mpController = NULL;
1248     mpViewTabBar = NULL;
1249     mpViewWindow.reset();
1250     mpToolBarManager.reset();
1251 }
1252 
1253 
1254 
1255 
1256 void ViewShellBase::Implementation::LateInit (void)
1257 {
1258     mpController = new DrawController(mrBase);
1259 }
1260 
1261 
1262 
1263 
1264 void ViewShellBase::Implementation::ProcessRestoreEditingViewSlot (void)
1265 {
1266     ViewShell* pViewShell = mrBase.GetMainViewShell().get();
1267     if (pViewShell != NULL)
1268     {
1269         FrameView* pFrameView = pViewShell->GetFrameView();
1270         if (pFrameView != NULL)
1271         {
1272             // Set view shell, edit mode, and page kind.
1273             pFrameView->SetViewShEditMode(
1274                 pFrameView->GetViewShEditModeOnLoad(),
1275                 pFrameView->GetPageKindOnLoad());
1276             pFrameView->SetPageKind(
1277                 pFrameView->GetPageKindOnLoad());
1278             ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(mrBase));
1279             pHelper->RequestView(
1280                 pHelper->GetViewURL(pFrameView->GetViewShellTypeOnLoad()),
1281                 FrameworkHelper::msCenterPaneURL);
1282             pHelper->RunOnConfigurationEvent(
1283                 ::rtl::OUString::createFromAscii("ConfigurationUpdateEnd"),
1284                 CurrentPageSetter(mrBase));
1285         }
1286     }
1287 }
1288 
1289 
1290 
1291 
1292 void ViewShellBase::Implementation::ShowViewTabBar (bool bShow)
1293 {
1294     if (mpViewTabBar.is()
1295         && (mpViewTabBar->GetTabControl()->IsVisible()==sal_True) != bShow)
1296     {
1297         mpViewTabBar->GetTabControl()->Show(bShow ? sal_True : sal_False);
1298         mrBase.Rearrange();
1299     }
1300 }
1301 
1302 
1303 
1304 
1305 void ViewShellBase::Implementation::ResizePixel (
1306     const Point& rOrigin,
1307     const Size &rSize,
1308     bool bOuterResize)
1309 {
1310     if (mbIsClosing)
1311         return;
1312 
1313 	// Forward the call to both the base class and the main stacked sub
1314     // shell only when main sub shell exists.
1315     ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
1316 
1317     // Set the ViewTabBar temporarily to full size so that, when asked
1318     // later, it can return its true height.
1319     mrBase.SetWindow (mpViewWindow.get());
1320     if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
1321         mpViewTabBar->GetTabControl()->SetPosSizePixel (rOrigin, rSize);
1322 
1323     // Calculate and set the border before the controls are placed.
1324     SvBorder aBorder;
1325     if (pMainViewShell != NULL)
1326         aBorder = pMainViewShell->GetBorder(bOuterResize);
1327     aBorder += mrBase.GetBorder(bOuterResize);
1328     if (mrBase.GetBorderPixel() != aBorder)
1329         mrBase.SetBorderPixel(aBorder);
1330 
1331     // Place the ViewTabBar at the top.  It is part of the border.
1332     SvBorder aBaseBorder;
1333     if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
1334     {
1335         aBaseBorder.Top() = mpViewTabBar->GetHeight();
1336         mpViewTabBar->GetTabControl()->SetPosSizePixel(
1337             rOrigin, Size(rSize.Width(),aBaseBorder.Top()));
1338     }
1339 
1340     // The view window gets the remaining space.
1341     Point aViewWindowPosition (
1342         rOrigin.X()+aBaseBorder.Left(),
1343         rOrigin.Y()+aBaseBorder.Top());
1344     Size aViewWindowSize (
1345         rSize.Width() - aBaseBorder.Left() - aBaseBorder.Right(),
1346         rSize.Height() - aBaseBorder.Top() - aBaseBorder.Bottom());
1347     mpViewWindow->SetPosSizePixel(aViewWindowPosition, aViewWindowSize);
1348 
1349     maClientArea = Rectangle(Point(0,0), aViewWindowSize);
1350 }
1351 
1352 
1353 
1354 
1355 void ViewShellBase::Implementation::SetPaneVisibility (
1356     const SfxRequest& rRequest,
1357     const ::rtl::OUString& rsPaneURL,
1358     const ::rtl::OUString& rsViewURL)
1359 {
1360     try
1361     {
1362         Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
1363 
1364         const Reference< XComponentContext > xContext(
1365             ::comphelper::getProcessComponentContext() );
1366         Reference<XResourceId> xPaneId (ResourceId::create(
1367             xContext, rsPaneURL));
1368         Reference<XResourceId> xViewId (ResourceId::createWithAnchorURL(
1369             xContext, rsViewURL, rsPaneURL));
1370 
1371         // Determine the new visibility state.
1372         const SfxItemSet* pArguments = rRequest.GetArgs();
1373         sal_Bool bShowChildWindow;
1374         sal_uInt16 nSlotId = rRequest.GetSlot();
1375         if (pArguments != NULL)
1376             bShowChildWindow = static_cast<const SfxBoolItem&>(
1377                 pArguments->Get(nSlotId)).GetValue();
1378         else
1379         {
1380             Reference<XConfigurationController> xConfigurationController (
1381                 xControllerManager->getConfigurationController());
1382             if ( ! xConfigurationController.is())
1383                 throw RuntimeException();
1384             Reference<XConfiguration> xConfiguration (
1385                 xConfigurationController->getRequestedConfiguration());
1386             if ( ! xConfiguration.is())
1387                 throw RuntimeException();
1388 
1389             bShowChildWindow = ! xConfiguration->hasResource(xPaneId);
1390         }
1391 
1392         // Set the desired visibility state at the current configuration
1393         // and update it accordingly.
1394         Reference<XConfigurationController> xConfigurationController (
1395             xControllerManager->getConfigurationController());
1396         if ( ! xConfigurationController.is())
1397             throw RuntimeException();
1398         if (bShowChildWindow)
1399         {
1400             xConfigurationController->requestResourceActivation(
1401                 xPaneId,
1402                 ResourceActivationMode_ADD);
1403             xConfigurationController->requestResourceActivation(
1404                 xViewId,
1405                 ResourceActivationMode_REPLACE);
1406         }
1407         else
1408             xConfigurationController->requestResourceDeactivation(
1409                 xPaneId);
1410     }
1411     catch (const Exception &)
1412     {
1413         DBG_UNHANDLED_EXCEPTION();
1414     }
1415 }
1416 
1417 
1418 
1419 
1420 
1421 void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet)
1422 {
1423     try
1424     {
1425         // Get some frequently used values.
1426         Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
1427         Reference<XConfigurationController> xConfigurationController (
1428             xControllerManager->getConfigurationController());
1429         if ( ! xConfigurationController.is())
1430             throw RuntimeException();
1431         Reference<XConfiguration> xConfiguration (
1432             xConfigurationController->getRequestedConfiguration());
1433         if ( ! xConfiguration.is())
1434             throw RuntimeException();
1435 
1436         const Reference< XComponentContext > xContext(
1437             ::comphelper::getProcessComponentContext() );
1438         SfxWhichIter aSetIterator (rSet);
1439         sal_uInt16 nItemId (aSetIterator.FirstWhich());
1440         while (nItemId > 0)
1441         {
1442             bool bState (false);
1443             Reference<XResourceId> xResourceId;
1444             try
1445             {
1446                 switch (nItemId)
1447                 {
1448                     case SID_LEFT_PANE_IMPRESS:
1449                         xResourceId = ResourceId::create(
1450                             xContext, FrameworkHelper::msLeftImpressPaneURL);
1451                         break;
1452 
1453                     case SID_LEFT_PANE_DRAW:
1454                         xResourceId = ResourceId::create(
1455                             xContext, FrameworkHelper::msLeftDrawPaneURL);
1456                         break;
1457 
1458                     case SID_TASKPANE:
1459                         xResourceId = ResourceId::create(
1460                             xContext, FrameworkHelper::msRightPaneURL);
1461                         break;
1462 
1463                     case SID_NORMAL_MULTI_PANE_GUI:
1464                         xResourceId = ResourceId::createWithAnchorURL(
1465                             xContext,
1466                             FrameworkHelper::msImpressViewURL,
1467                             FrameworkHelper::msCenterPaneURL);
1468                         break;
1469 
1470                     case SID_SLIDE_SORTER_MULTI_PANE_GUI:
1471                     case SID_DIAMODE:
1472                         xResourceId = ResourceId::createWithAnchorURL(
1473                             xContext,
1474                             FrameworkHelper::msSlideSorterURL,
1475                             FrameworkHelper::msCenterPaneURL);
1476                         break;
1477 
1478                     case SID_OUTLINEMODE:
1479                         xResourceId = ResourceId::createWithAnchorURL(
1480                             xContext,
1481                             FrameworkHelper::msOutlineViewURL,
1482                             FrameworkHelper::msCenterPaneURL);
1483                         break;
1484 
1485                     case SID_HANDOUTMODE:
1486                         // There is only the master page mode for the handout
1487                         // view so ignore the master page flag.
1488                         xResourceId = ResourceId::createWithAnchorURL(
1489                             xContext,
1490                             FrameworkHelper::msHandoutViewURL,
1491                             FrameworkHelper::msCenterPaneURL);
1492                         break;
1493 
1494                     case SID_NOTESMODE:
1495                         xResourceId = ResourceId::createWithAnchorURL(
1496                             xContext,
1497                             FrameworkHelper::msNotesViewURL,
1498                             FrameworkHelper::msCenterPaneURL);
1499                         break;
1500 
1501                     default:
1502                         // Ignore all other items.  They are not meant to be
1503                         // handled by us.
1504                         break;
1505                 }
1506             }
1507             catch (DeploymentException)
1508             {
1509             }
1510 
1511             // Determine the state for the resource.
1512             bState = xConfiguration->hasResource(xResourceId);
1513 
1514             // Take the master page mode into account.
1515             switch (nItemId)
1516             {
1517                 case SID_NORMAL_MULTI_PANE_GUI:
1518                 case SID_NOTESMODE:
1519                 {
1520                     // Determine the master page mode.
1521                     ViewShell* pCenterViewShell = FrameworkHelper::Instance(mrBase)->GetViewShell(
1522                         FrameworkHelper::msCenterPaneURL).get();
1523                     bool bMasterPageMode (false);
1524                     if (pCenterViewShell!=NULL && pCenterViewShell->ISA(DrawViewShell))
1525                         if (PTR_CAST(DrawViewShell,pCenterViewShell)->GetEditMode()
1526                             == EM_MASTERPAGE)
1527                         {
1528                             bMasterPageMode = true;
1529                         }
1530 
1531                     bState &= !bMasterPageMode;
1532                     break;
1533                 }
1534 
1535                 case SID_HANDOUTMODE:
1536                     // There is only the master page mode for the handout
1537                     // view so ignore the master page flag.
1538                     break;
1539             }
1540 
1541             // And finally set the state.
1542             rSet.Put(SfxBoolItem(nItemId, bState));
1543 
1544             nItemId = aSetIterator.NextWhich();
1545         }
1546     }
1547     catch (RuntimeException&)
1548     {
1549         DBG_UNHANDLED_EXCEPTION();
1550     }
1551 
1552 }
1553 
1554 
1555 
1556 
1557 void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest& rRequest)
1558 {
1559     // Set the visibility state of the toolpanel and one of its top
1560     // level panels.
1561     sal_Bool bShowToolPanel = sal_True;
1562     toolpanel::PanelId nPanelId (
1563         toolpanel::PID_UNKNOWN);
1564     bool bPanelIdGiven = false;
1565 
1566     // Extract the given arguments.
1567 	const SfxItemSet* pArgs = rRequest.GetArgs();
1568     if (pArgs)
1569     {
1570         if ((pArgs->Count() == 1) || (pArgs->Count() == 2))
1571         {
1572             SFX_REQUEST_ARG (rRequest, pIsPanelVisible,
1573                 SfxBoolItem, ID_VAL_ISVISIBLE, sal_False);
1574             if (pIsPanelVisible != NULL)
1575                 bShowToolPanel = pIsPanelVisible->GetValue();
1576         }
1577         if (pArgs->Count() == 2)
1578         {
1579             SFX_REQUEST_ARG (rRequest, pPanelId, SfxUInt32Item,
1580                 ID_VAL_PANEL_INDEX, sal_False);
1581             if (pPanelId != NULL)
1582             {
1583                 nPanelId = static_cast<
1584                     toolpanel::PanelId>(
1585                         pPanelId->GetValue());
1586                 bPanelIdGiven = true;
1587             }
1588         }
1589     }
1590 
1591     // Ignore the request for some combinations of panels and view
1592     // shell types.
1593     if (bPanelIdGiven
1594         && ! (nPanelId==toolpanel::PID_LAYOUT
1595             && mrBase.GetMainViewShell()!=NULL
1596             && mrBase.GetMainViewShell()->GetShellType()==ViewShell::ST_OUTLINE))
1597     {
1598         framework::FrameworkHelper::Instance(mrBase)->RequestTaskPanel(
1599             framework::FrameworkHelper::msLayoutTaskPanelURL);
1600     }
1601 }
1602 
1603 
1604 } // end of namespace sd
1605 
1606 
1607 
1608 
1609 //===== CurrentPageSetter ===========================================
1610 
1611 namespace {
1612 
1613 CurrentPageSetter::CurrentPageSetter (ViewShellBase& rBase)
1614     : mrBase(rBase)
1615 {
1616 }
1617 
1618 
1619 
1620 
1621 
1622 void CurrentPageSetter::operator() (bool)
1623 {
1624     FrameView* pFrameView = NULL;
1625 
1626     if (mrBase.GetMainViewShell() != NULL)
1627     {
1628         pFrameView = mrBase.GetMainViewShell()->GetFrameView();
1629     }
1630 
1631     if (pFrameView!=NULL)
1632     {
1633         try
1634         {
1635             // Get the current page either from the DrawPagesSupplier or the
1636             // MasterPagesSupplier.
1637             Any aPage;
1638             if (pFrameView->GetViewShEditModeOnLoad() == EM_PAGE)
1639             {
1640                 Reference<drawing::XDrawPagesSupplier> xPagesSupplier (
1641                     mrBase.GetController()->getModel(), UNO_QUERY_THROW);
1642                 Reference<container::XIndexAccess> xPages (
1643                     xPagesSupplier->getDrawPages(), UNO_QUERY_THROW);
1644                 aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
1645             }
1646             else
1647             {
1648                 Reference<drawing::XMasterPagesSupplier> xPagesSupplier (
1649                     mrBase.GetController()->getModel(), UNO_QUERY_THROW);
1650                 Reference<container::XIndexAccess> xPages (
1651                     xPagesSupplier->getMasterPages(), UNO_QUERY_THROW);
1652                 aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
1653             }
1654             // Switch to the page last edited by setting the CurrentPage
1655             // property.
1656             Reference<beans::XPropertySet> xSet (mrBase.GetController(), UNO_QUERY_THROW);
1657             xSet->setPropertyValue (String::CreateFromAscii("CurrentPage"), aPage);
1658         }
1659         catch (RuntimeException aException)
1660         {
1661             // We have not been able to set the current page at the main view.
1662             // This is sad but still leaves us in a valid state.  Therefore,
1663             // this exception is silently ignored.
1664         }
1665         catch (beans::UnknownPropertyException aException)
1666         {
1667             DBG_ASSERT(false,"CurrentPage property unknown");
1668         }
1669     }
1670 }
1671 
1672 } // end of anonymouse namespace
1673 
1674 
1675 
1676 
1677 //===== FocusForwardingWindow =================================================
1678 
1679 namespace sd { namespace {
1680 
1681 FocusForwardingWindow::FocusForwardingWindow (
1682     ::Window& rParentWindow,
1683     ViewShellBase& rBase)
1684     : ::Window(&rParentWindow, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
1685         mrBase(rBase)
1686 {
1687     OSL_TRACE("created FocusForwardingWindow at %x", this);
1688 }
1689 
1690 
1691 
1692 
1693 FocusForwardingWindow::~FocusForwardingWindow (void)
1694 {
1695     OSL_TRACE("destroyed FocusForwardingWindow at %x", this);
1696 }
1697 
1698 
1699 
1700 
1701 void FocusForwardingWindow::KeyInput (const KeyEvent& rKEvt)
1702 {
1703     ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
1704     if (pViewShell.get() != NULL)
1705     {
1706         ::Window* pWindow = pViewShell->GetActiveWindow();
1707         if (pWindow != NULL)
1708         {
1709             // Forward the focus so that the window is called directly the
1710             // next time.
1711             pWindow->GrabFocus();
1712             // Forward the key press as well.
1713             pWindow->KeyInput(rKEvt);
1714         }
1715     }
1716 }
1717 
1718 
1719 
1720 
1721 void FocusForwardingWindow::Command (const CommandEvent& rEvent)
1722 {
1723     ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
1724     if (pViewShell.get() != NULL)
1725     {
1726         ::Window* pWindow = pViewShell->GetActiveWindow();
1727         if (pWindow != NULL)
1728         {
1729             pWindow->Command(rEvent);
1730         }
1731     }
1732 }
1733 
1734 
1735 } // end of anonymouse namespace
1736 
1737 } // end of namespace sd
1738