xref: /aoo41x/main/sd/source/ui/view/ViewShellBase.cxx (revision b9e67834)
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 
858     ContextChangeEventMultiplexer::NotifyContextChange(
859         GetController(),
860         ::sfx2::sidebar::EnumContext::Context_Default);
861 
862     Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
863     if (xControllerManager.is())
864     {
865         Reference<XConfigurationController> xConfigurationController (
866             xControllerManager->getConfigurationController());
867         if (xConfigurationController.is())
868             xConfigurationController->update();
869     }
870     GetToolBarManager()->RequestUpdate();
871 }
872 
873 
874 
875 
876 void ViewShellBase::Deactivate (sal_Bool bIsMDIActivate)
877 {
878     SfxViewShell::Deactivate(bIsMDIActivate);
879 }
880 
881 
882 
883 
884 void ViewShellBase::SetZoomFactor (
885     const Fraction &rZoomX,
886     const Fraction &rZoomY)
887 {
888     SfxViewShell::SetZoomFactor (rZoomX, rZoomY);
889     // Forward call to main sub shell.
890     ViewShell* pShell = GetMainViewShell().get();
891     if (pShell != NULL)
892         pShell->SetZoomFactor (rZoomX, rZoomY);
893 }
894 
895 
896 
897 
898 sal_uInt16 ViewShellBase::PrepareClose (sal_Bool bUI, sal_Bool bForBrowsing)
899 {
900 	sal_uInt16 nResult = SfxViewShell::PrepareClose (bUI, bForBrowsing);
901 
902 	if (nResult == sal_True)
903     {
904         mpImpl->mbIsClosing = true;
905 
906         // Forward call to main sub shell.
907         ViewShell* pShell = GetMainViewShell().get();
908         if (pShell != NULL)
909             nResult = pShell->PrepareClose (bUI, bForBrowsing);
910     }
911 
912     return nResult;
913 }
914 
915 
916 
917 
918 void ViewShellBase::WriteUserData (String& rString, sal_Bool bBrowse)
919 {
920 	SfxViewShell::WriteUserData (rString, bBrowse);
921 
922     // Forward call to main sub shell.
923     ViewShell* pShell = GetMainViewShell().get();
924     if (pShell != NULL)
925         pShell->WriteUserData (rString);
926 }
927 
928 
929 
930 
931 void ViewShellBase::ReadUserData (const String& rString, sal_Bool bBrowse)
932 {
933 	SfxViewShell::ReadUserData (rString, bBrowse);
934 
935     // Forward call to main sub shell.
936     ViewShell* pShell = GetMainViewShell().get();
937     if (pShell != NULL)
938         pShell->ReadUserData (rString);
939 }
940 
941 
942 
943 
944 SdrView* ViewShellBase::GetDrawView (void) const
945 {
946     // Forward call to main sub shell.
947     ViewShell* pShell = GetMainViewShell().get();
948     if (pShell != NULL)
949         return pShell->GetDrawView ();
950     else
951         return SfxViewShell::GetDrawView();
952 }
953 
954 
955 
956 
957 void ViewShellBase::AdjustPosSizePixel (const Point &rOfs, const Size &rSize)
958 {
959 	SfxViewShell::AdjustPosSizePixel (rOfs, rSize);
960 }
961 
962 
963 
964 
965 void ViewShellBase::SetBusyState (bool bBusy)
966 {
967     if (GetDocShell() != NULL)
968         GetDocShell()->SetWaitCursor (bBusy);
969 }
970 
971 
972 
973 
974 void ViewShellBase::UpdateBorder ( bool bForce /* = false */ )
975 {
976     // The following calls to SetBorderPixel() and InvalidateBorder() are
977     // made only for the main view shell.  This not only avoids unnecessary
978     // calls for the views in side panes but prevents calling an already
979     // dying SfxViewShell base class.
980     // For issue #140703# we have to check the existence of the window,
981     // too.  The SfxViewFrame accesses the window without checking it.
982     ViewShell* pMainViewShell = GetMainViewShell().get();
983     if (pMainViewShell != NULL && GetWindow()!=NULL)
984     {
985         SvBorder aCurrentBorder (GetBorderPixel());
986         bool bOuterResize ( ! GetDocShell()->IsInPlaceActive());
987         SvBorder aBorder (GetBorder(bOuterResize));
988         aBorder += pMainViewShell->GetBorder(bOuterResize);
989 
990         if (bForce || (aBorder != aCurrentBorder))
991         {
992             SetBorderPixel (aBorder);
993             InvalidateBorder();
994         }
995     }
996 }
997 
998 
999 
1000 
1001 void ViewShellBase::ShowUIControls (bool bVisible)
1002 {
1003     if (mpImpl->mpViewTabBar.is())
1004         mpImpl->mpViewTabBar->GetTabControl()->Show(bVisible);
1005 
1006     ViewShell* pMainViewShell = GetMainViewShell().get();
1007     if (pMainViewShell != NULL)
1008         pMainViewShell->ShowUIControls (bVisible);
1009 
1010     UpdateBorder();
1011     if (bVisible)
1012         Rearrange();
1013 }
1014 
1015 
1016 
1017 
1018 OUString ViewShellBase::GetInitialViewShellType (void)
1019 {
1020     OUString sRequestedView (FrameworkHelper::msImpressViewURL);
1021 
1022     do
1023     {
1024         Reference<document::XViewDataSupplier> xViewDataSupplier (
1025             GetDocShell()->GetModel(), UNO_QUERY);
1026         if ( ! xViewDataSupplier.is())
1027             break;
1028 
1029         Reference<container::XIndexAccess> xViewData (xViewDataSupplier->getViewData());
1030         if ( ! xViewData.is())
1031             break;
1032         if (xViewData->getCount() == 0)
1033             break;
1034 
1035         sal_Int32 nView = 0;
1036 		::com::sun::star::uno::Any aAny = xViewData->getByIndex(nView);
1037     	Sequence<beans::PropertyValue> aProperties;
1038 		if ( ! (aAny >>= aProperties))
1039             break;
1040 
1041         // Search the properties for the one that tells us what page kind to
1042         // use.
1043         for (sal_Int32 n=0; n<aProperties.getLength(); n++)
1044         {
1045             const beans::PropertyValue& rProperty (aProperties[n]);
1046             if (rProperty.Name.compareToAscii(sUNO_View_PageKind) == COMPARE_EQUAL)
1047             {
1048 				sal_Int16 nPageKind = 0;
1049                 rProperty.Value >>= nPageKind;
1050                 switch ((PageKind)nPageKind)
1051                 {
1052                     case PK_STANDARD:
1053                         sRequestedView = FrameworkHelper::msImpressViewURL;
1054                         break;
1055 
1056                     case PK_HANDOUT:
1057                         sRequestedView = FrameworkHelper::msHandoutViewURL;
1058                         break;
1059 
1060                     case PK_NOTES:
1061                         sRequestedView = FrameworkHelper::msNotesViewURL;
1062                         break;
1063 
1064                     default:
1065                         // The page kind is invalid.  This is propably an
1066                         // error by the caller.  We use the standard type to
1067                         // keep things going.
1068                         DBG_ASSERT(sal_False, "ViewShellBase::GetInitialViewShellType: invalid page kind");
1069                         sRequestedView = FrameworkHelper::msImpressViewURL;
1070                         break;
1071                 }
1072                 break;
1073             }
1074 		}
1075     }
1076     while (false);
1077 
1078     return sRequestedView;
1079 }
1080 
1081 
1082 
1083 
1084 /** this method starts the presentation by
1085 	executing the slot SID_PRESENTATION asynchronous */
1086 void ViewShellBase::StartPresentation()
1087 {
1088 	if( GetViewFrame() && GetViewFrame()->GetDispatcher() )
1089 		GetViewFrame()->GetDispatcher()->Execute(SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
1090 }
1091 
1092 
1093 
1094 
1095 
1096 ::boost::shared_ptr<tools::EventMultiplexer> ViewShellBase::GetEventMultiplexer (void)
1097 {
1098     OSL_ASSERT(mpImpl.get()!=NULL);
1099     OSL_ASSERT(mpImpl->mpEventMultiplexer.get()!=NULL);
1100 
1101     return mpImpl->mpEventMultiplexer;
1102 }
1103 
1104 
1105 
1106 
1107 const Rectangle& ViewShellBase::getClientRectangle (void) const
1108 {
1109 	return mpImpl->maClientArea;
1110 }
1111 
1112 
1113 
1114 
1115 ::boost::shared_ptr<UpdateLockManager> ViewShellBase::GetUpdateLockManager (void) const
1116 {
1117     OSL_ASSERT(mpImpl.get()!=NULL);
1118     OSL_ASSERT(mpImpl->mpUpdateLockManager.get()!=NULL);
1119 
1120     return mpImpl->mpUpdateLockManager;
1121 }
1122 
1123 
1124 
1125 
1126 ::boost::shared_ptr<ToolBarManager> ViewShellBase::GetToolBarManager (void) const
1127 {
1128     OSL_ASSERT(mpImpl.get()!=NULL);
1129     OSL_ASSERT(mpImpl->mpToolBarManager.get()!=NULL);
1130 
1131     return mpImpl->mpToolBarManager;
1132 }
1133 
1134 
1135 
1136 
1137 ::boost::shared_ptr<FormShellManager> ViewShellBase::GetFormShellManager (void) const
1138 {
1139     OSL_ASSERT(mpImpl.get()!=NULL);
1140     OSL_ASSERT(mpImpl->mpFormShellManager.get()!=NULL);
1141 
1142     return mpImpl->mpFormShellManager;
1143 }
1144 
1145 
1146 
1147 
1148 DrawController& ViewShellBase::GetDrawController (void) const
1149 {
1150     OSL_ASSERT(mpImpl.get()!=NULL);
1151 
1152     return *mpImpl->mpController;
1153 }
1154 
1155 
1156 
1157 
1158 void ViewShellBase::SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabBar)
1159 {
1160     OSL_ASSERT(mpImpl.get()!=NULL);
1161 
1162     mpImpl->mpViewTabBar = rViewTabBar;
1163 }
1164 
1165 
1166 
1167 
1168 ::Window* ViewShellBase::GetViewWindow (void)
1169 {
1170     OSL_ASSERT(mpImpl.get()!=NULL);
1171 
1172     return mpImpl->mpViewWindow.get();
1173 }
1174 
1175 
1176 ::rtl::OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const ::rtl::OUString& aCmdURL )
1177 {
1178     ::rtl::OUString aLabel;
1179 
1180     if ( aCmdURL.getLength() > 0 ) try
1181     {
1182 		Reference< XMultiServiceFactory > xServiceManager( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
1183 
1184 		Reference< XModuleManager > xModuleManager( xServiceManager->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager") ) ), UNO_QUERY_THROW );
1185 		Reference< XInterface > xIfac( xFrame, UNO_QUERY_THROW );
1186 
1187 		::rtl::OUString aModuleIdentifier( xModuleManager->identify( xIfac ) );
1188 
1189         if( aModuleIdentifier.getLength() > 0 )
1190         {
1191 			Reference< XNameAccess > xNameAccess( xServiceManager->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.UICommandDescription" ) ) ), UNO_QUERY );
1192             if( xNameAccess.is() )
1193             {
1194 				Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels( xNameAccess->getByName( aModuleIdentifier ), UNO_QUERY_THROW );
1195                 Sequence< PropertyValue > aPropSeq;
1196                 if( m_xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq )
1197                 {
1198                     for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
1199                     {
1200                         if( aPropSeq[i].Name.equalsAscii( "Name" ))
1201                         {
1202                             aPropSeq[i].Value >>= aLabel;
1203                             break;
1204                         }
1205                     }
1206                 }
1207             }
1208         }
1209     }
1210     catch ( Exception& )
1211     {
1212     }
1213 
1214 	return aLabel;
1215 }
1216 
1217 ::rtl::OUString ViewShellBase::RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ) const
1218 {
1219 	Reference< XFrame > xFrame( GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(), UNO_QUERY );
1220 	return ImplRetrieveLabelFromCommand( xFrame, aCmdURL );
1221 }
1222 
1223 
1224 
1225 //===== ViewShellBase::Implementation =========================================
1226 
1227 ViewShellBase::Implementation::Implementation (ViewShellBase& rBase)
1228     : mpController(),
1229       mpViewTabBar(),
1230       maClientArea(),
1231       mbIsClosing(false),
1232       mpViewWindow(),
1233       mpToolBarManager(),
1234       mpViewShellManager(),
1235       mpEventMultiplexer(),
1236       mpUpdateLockManager(),
1237       mpFormShellManager(),
1238       mrBase(rBase),
1239       mpPageCacheManager(slidesorter::cache::PageCacheManager::Instance())
1240 {
1241 }
1242 
1243 
1244 
1245 
1246 ViewShellBase::Implementation::~Implementation (void)
1247 {
1248     mpController = NULL;
1249     mpViewTabBar = NULL;
1250     mpViewWindow.reset();
1251     mpToolBarManager.reset();
1252 }
1253 
1254 
1255 
1256 
1257 void ViewShellBase::Implementation::LateInit (void)
1258 {
1259     mpController = new DrawController(mrBase);
1260 }
1261 
1262 
1263 
1264 
1265 void ViewShellBase::Implementation::ProcessRestoreEditingViewSlot (void)
1266 {
1267     ViewShell* pViewShell = mrBase.GetMainViewShell().get();
1268     if (pViewShell != NULL)
1269     {
1270         FrameView* pFrameView = pViewShell->GetFrameView();
1271         if (pFrameView != NULL)
1272         {
1273             // Set view shell, edit mode, and page kind.
1274             pFrameView->SetViewShEditMode(
1275                 pFrameView->GetViewShEditModeOnLoad(),
1276                 pFrameView->GetPageKindOnLoad());
1277             pFrameView->SetPageKind(
1278                 pFrameView->GetPageKindOnLoad());
1279             ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(mrBase));
1280             pHelper->RequestView(
1281                 pHelper->GetViewURL(pFrameView->GetViewShellTypeOnLoad()),
1282                 FrameworkHelper::msCenterPaneURL);
1283             pHelper->RunOnConfigurationEvent(
1284                 ::rtl::OUString::createFromAscii("ConfigurationUpdateEnd"),
1285                 CurrentPageSetter(mrBase));
1286         }
1287     }
1288 }
1289 
1290 
1291 
1292 
1293 void ViewShellBase::Implementation::ShowViewTabBar (bool bShow)
1294 {
1295     if (mpViewTabBar.is()
1296         && (mpViewTabBar->GetTabControl()->IsVisible()==sal_True) != bShow)
1297     {
1298         mpViewTabBar->GetTabControl()->Show(bShow ? sal_True : sal_False);
1299         mrBase.Rearrange();
1300     }
1301 }
1302 
1303 
1304 
1305 
1306 void ViewShellBase::Implementation::ResizePixel (
1307     const Point& rOrigin,
1308     const Size &rSize,
1309     bool bOuterResize)
1310 {
1311     if (mbIsClosing)
1312         return;
1313 
1314 	// Forward the call to both the base class and the main stacked sub
1315     // shell only when main sub shell exists.
1316     ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
1317 
1318     // Set the ViewTabBar temporarily to full size so that, when asked
1319     // later, it can return its true height.
1320     mrBase.SetWindow (mpViewWindow.get());
1321     if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
1322         mpViewTabBar->GetTabControl()->SetPosSizePixel (rOrigin, rSize);
1323 
1324     // Calculate and set the border before the controls are placed.
1325     SvBorder aBorder;
1326     if (pMainViewShell != NULL)
1327         aBorder = pMainViewShell->GetBorder(bOuterResize);
1328     aBorder += mrBase.GetBorder(bOuterResize);
1329     if (mrBase.GetBorderPixel() != aBorder)
1330         mrBase.SetBorderPixel(aBorder);
1331 
1332     // Place the ViewTabBar at the top.  It is part of the border.
1333     SvBorder aBaseBorder;
1334     if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
1335     {
1336         aBaseBorder.Top() = mpViewTabBar->GetHeight();
1337         mpViewTabBar->GetTabControl()->SetPosSizePixel(
1338             rOrigin, Size(rSize.Width(),aBaseBorder.Top()));
1339     }
1340 
1341     // The view window gets the remaining space.
1342     Point aViewWindowPosition (
1343         rOrigin.X()+aBaseBorder.Left(),
1344         rOrigin.Y()+aBaseBorder.Top());
1345     Size aViewWindowSize (
1346         rSize.Width() - aBaseBorder.Left() - aBaseBorder.Right(),
1347         rSize.Height() - aBaseBorder.Top() - aBaseBorder.Bottom());
1348     mpViewWindow->SetPosSizePixel(aViewWindowPosition, aViewWindowSize);
1349 
1350     maClientArea = Rectangle(Point(0,0), aViewWindowSize);
1351 }
1352 
1353 
1354 
1355 
1356 void ViewShellBase::Implementation::SetPaneVisibility (
1357     const SfxRequest& rRequest,
1358     const ::rtl::OUString& rsPaneURL,
1359     const ::rtl::OUString& rsViewURL)
1360 {
1361     try
1362     {
1363         Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
1364 
1365         const Reference< XComponentContext > xContext(
1366             ::comphelper::getProcessComponentContext() );
1367         Reference<XResourceId> xPaneId (ResourceId::create(
1368             xContext, rsPaneURL));
1369         Reference<XResourceId> xViewId (ResourceId::createWithAnchorURL(
1370             xContext, rsViewURL, rsPaneURL));
1371 
1372         // Determine the new visibility state.
1373         const SfxItemSet* pArguments = rRequest.GetArgs();
1374         sal_Bool bShowChildWindow;
1375         sal_uInt16 nSlotId = rRequest.GetSlot();
1376         if (pArguments != NULL)
1377             bShowChildWindow = static_cast<const SfxBoolItem&>(
1378                 pArguments->Get(nSlotId)).GetValue();
1379         else
1380         {
1381             Reference<XConfigurationController> xConfigurationController (
1382                 xControllerManager->getConfigurationController());
1383             if ( ! xConfigurationController.is())
1384                 throw RuntimeException();
1385             Reference<XConfiguration> xConfiguration (
1386                 xConfigurationController->getRequestedConfiguration());
1387             if ( ! xConfiguration.is())
1388                 throw RuntimeException();
1389 
1390             bShowChildWindow = ! xConfiguration->hasResource(xPaneId);
1391         }
1392 
1393         // Set the desired visibility state at the current configuration
1394         // and update it accordingly.
1395         Reference<XConfigurationController> xConfigurationController (
1396             xControllerManager->getConfigurationController());
1397         if ( ! xConfigurationController.is())
1398             throw RuntimeException();
1399         if (bShowChildWindow)
1400         {
1401             xConfigurationController->requestResourceActivation(
1402                 xPaneId,
1403                 ResourceActivationMode_ADD);
1404             xConfigurationController->requestResourceActivation(
1405                 xViewId,
1406                 ResourceActivationMode_REPLACE);
1407         }
1408         else
1409             xConfigurationController->requestResourceDeactivation(
1410                 xPaneId);
1411     }
1412     catch (const Exception &)
1413     {
1414         DBG_UNHANDLED_EXCEPTION();
1415     }
1416 }
1417 
1418 
1419 
1420 
1421 
1422 void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet)
1423 {
1424     try
1425     {
1426         // Get some frequently used values.
1427         Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
1428         Reference<XConfigurationController> xConfigurationController (
1429             xControllerManager->getConfigurationController());
1430         if ( ! xConfigurationController.is())
1431             throw RuntimeException();
1432         Reference<XConfiguration> xConfiguration (
1433             xConfigurationController->getRequestedConfiguration());
1434         if ( ! xConfiguration.is())
1435             throw RuntimeException();
1436 
1437         const Reference< XComponentContext > xContext(
1438             ::comphelper::getProcessComponentContext() );
1439         SfxWhichIter aSetIterator (rSet);
1440         sal_uInt16 nItemId (aSetIterator.FirstWhich());
1441         while (nItemId > 0)
1442         {
1443             bool bState (false);
1444             Reference<XResourceId> xResourceId;
1445             try
1446             {
1447                 switch (nItemId)
1448                 {
1449                     case SID_LEFT_PANE_IMPRESS:
1450                         xResourceId = ResourceId::create(
1451                             xContext, FrameworkHelper::msLeftImpressPaneURL);
1452                         break;
1453 
1454                     case SID_LEFT_PANE_DRAW:
1455                         xResourceId = ResourceId::create(
1456                             xContext, FrameworkHelper::msLeftDrawPaneURL);
1457                         break;
1458 
1459                     case SID_TASKPANE:
1460                         xResourceId = ResourceId::create(
1461                             xContext, FrameworkHelper::msRightPaneURL);
1462                         break;
1463 
1464                     case SID_NORMAL_MULTI_PANE_GUI:
1465                         xResourceId = ResourceId::createWithAnchorURL(
1466                             xContext,
1467                             FrameworkHelper::msImpressViewURL,
1468                             FrameworkHelper::msCenterPaneURL);
1469                         break;
1470 
1471                     case SID_SLIDE_SORTER_MULTI_PANE_GUI:
1472                     case SID_DIAMODE:
1473                         xResourceId = ResourceId::createWithAnchorURL(
1474                             xContext,
1475                             FrameworkHelper::msSlideSorterURL,
1476                             FrameworkHelper::msCenterPaneURL);
1477                         break;
1478 
1479                     case SID_OUTLINEMODE:
1480                         xResourceId = ResourceId::createWithAnchorURL(
1481                             xContext,
1482                             FrameworkHelper::msOutlineViewURL,
1483                             FrameworkHelper::msCenterPaneURL);
1484                         break;
1485 
1486                     case SID_HANDOUTMODE:
1487                         // There is only the master page mode for the handout
1488                         // view so ignore the master page flag.
1489                         xResourceId = ResourceId::createWithAnchorURL(
1490                             xContext,
1491                             FrameworkHelper::msHandoutViewURL,
1492                             FrameworkHelper::msCenterPaneURL);
1493                         break;
1494 
1495                     case SID_NOTESMODE:
1496                         xResourceId = ResourceId::createWithAnchorURL(
1497                             xContext,
1498                             FrameworkHelper::msNotesViewURL,
1499                             FrameworkHelper::msCenterPaneURL);
1500                         break;
1501 
1502                     default:
1503                         // Ignore all other items.  They are not meant to be
1504                         // handled by us.
1505                         break;
1506                 }
1507             }
1508             catch (DeploymentException)
1509             {
1510             }
1511 
1512             // Determine the state for the resource.
1513             bState = xConfiguration->hasResource(xResourceId);
1514 
1515             // Take the master page mode into account.
1516             switch (nItemId)
1517             {
1518                 case SID_NORMAL_MULTI_PANE_GUI:
1519                 case SID_NOTESMODE:
1520                 {
1521                     // Determine the master page mode.
1522                     ViewShell* pCenterViewShell = FrameworkHelper::Instance(mrBase)->GetViewShell(
1523                         FrameworkHelper::msCenterPaneURL).get();
1524                     bool bMasterPageMode (false);
1525                     if (pCenterViewShell!=NULL && pCenterViewShell->ISA(DrawViewShell))
1526                         if (PTR_CAST(DrawViewShell,pCenterViewShell)->GetEditMode()
1527                             == EM_MASTERPAGE)
1528                         {
1529                             bMasterPageMode = true;
1530                         }
1531 
1532                     bState &= !bMasterPageMode;
1533                     break;
1534                 }
1535 
1536                 case SID_HANDOUTMODE:
1537                     // There is only the master page mode for the handout
1538                     // view so ignore the master page flag.
1539                     break;
1540             }
1541 
1542             // And finally set the state.
1543             rSet.Put(SfxBoolItem(nItemId, bState));
1544 
1545             nItemId = aSetIterator.NextWhich();
1546         }
1547     }
1548     catch (RuntimeException&)
1549     {
1550         DBG_UNHANDLED_EXCEPTION();
1551     }
1552 
1553 }
1554 
1555 
1556 
1557 
1558 void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest& rRequest)
1559 {
1560     // Set the visibility state of the toolpanel and one of its top
1561     // level panels.
1562     sal_Bool bShowToolPanel = sal_True;
1563     toolpanel::PanelId nPanelId (
1564         toolpanel::PID_UNKNOWN);
1565     bool bPanelIdGiven = false;
1566 
1567     // Extract the given arguments.
1568 	const SfxItemSet* pArgs = rRequest.GetArgs();
1569     if (pArgs)
1570     {
1571         if ((pArgs->Count() == 1) || (pArgs->Count() == 2))
1572         {
1573             SFX_REQUEST_ARG (rRequest, pIsPanelVisible,
1574                 SfxBoolItem, ID_VAL_ISVISIBLE, sal_False);
1575             if (pIsPanelVisible != NULL)
1576                 bShowToolPanel = pIsPanelVisible->GetValue();
1577         }
1578         if (pArgs->Count() == 2)
1579         {
1580             SFX_REQUEST_ARG (rRequest, pPanelId, SfxUInt32Item,
1581                 ID_VAL_PANEL_INDEX, sal_False);
1582             if (pPanelId != NULL)
1583             {
1584                 nPanelId = static_cast<
1585                     toolpanel::PanelId>(
1586                         pPanelId->GetValue());
1587                 bPanelIdGiven = true;
1588             }
1589         }
1590     }
1591 
1592     // Ignore the request for some combinations of panels and view
1593     // shell types.
1594     if (bPanelIdGiven
1595         && ! (nPanelId==toolpanel::PID_LAYOUT
1596             && mrBase.GetMainViewShell()!=NULL
1597             && mrBase.GetMainViewShell()->GetShellType()==ViewShell::ST_OUTLINE))
1598     {
1599         framework::FrameworkHelper::Instance(mrBase)->RequestTaskPanel(
1600             framework::FrameworkHelper::msLayoutTaskPanelURL);
1601     }
1602 }
1603 
1604 
1605 } // end of namespace sd
1606 
1607 
1608 
1609 
1610 //===== CurrentPageSetter ===========================================
1611 
1612 namespace {
1613 
1614 CurrentPageSetter::CurrentPageSetter (ViewShellBase& rBase)
1615     : mrBase(rBase)
1616 {
1617 }
1618 
1619 
1620 
1621 
1622 
1623 void CurrentPageSetter::operator() (bool)
1624 {
1625     FrameView* pFrameView = NULL;
1626 
1627     if (mrBase.GetMainViewShell() != NULL)
1628     {
1629         pFrameView = mrBase.GetMainViewShell()->GetFrameView();
1630     }
1631 
1632     if (pFrameView!=NULL)
1633     {
1634         try
1635         {
1636             // Get the current page either from the DrawPagesSupplier or the
1637             // MasterPagesSupplier.
1638             Any aPage;
1639             if (pFrameView->GetViewShEditModeOnLoad() == EM_PAGE)
1640             {
1641                 Reference<drawing::XDrawPagesSupplier> xPagesSupplier (
1642                     mrBase.GetController()->getModel(), UNO_QUERY_THROW);
1643                 Reference<container::XIndexAccess> xPages (
1644                     xPagesSupplier->getDrawPages(), UNO_QUERY_THROW);
1645                 aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
1646             }
1647             else
1648             {
1649                 Reference<drawing::XMasterPagesSupplier> xPagesSupplier (
1650                     mrBase.GetController()->getModel(), UNO_QUERY_THROW);
1651                 Reference<container::XIndexAccess> xPages (
1652                     xPagesSupplier->getMasterPages(), UNO_QUERY_THROW);
1653                 aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
1654             }
1655             // Switch to the page last edited by setting the CurrentPage
1656             // property.
1657             Reference<beans::XPropertySet> xSet (mrBase.GetController(), UNO_QUERY_THROW);
1658             xSet->setPropertyValue (String::CreateFromAscii("CurrentPage"), aPage);
1659         }
1660         catch (RuntimeException aException)
1661         {
1662             // We have not been able to set the current page at the main view.
1663             // This is sad but still leaves us in a valid state.  Therefore,
1664             // this exception is silently ignored.
1665         }
1666         catch (beans::UnknownPropertyException aException)
1667         {
1668             DBG_ASSERT(false,"CurrentPage property unknown");
1669         }
1670     }
1671 }
1672 
1673 } // end of anonymouse namespace
1674 
1675 
1676 
1677 
1678 //===== FocusForwardingWindow =================================================
1679 
1680 namespace sd { namespace {
1681 
1682 FocusForwardingWindow::FocusForwardingWindow (
1683     ::Window& rParentWindow,
1684     ViewShellBase& rBase)
1685     : ::Window(&rParentWindow, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
1686         mrBase(rBase)
1687 {
1688     OSL_TRACE("created FocusForwardingWindow at %x", this);
1689 }
1690 
1691 
1692 
1693 
1694 FocusForwardingWindow::~FocusForwardingWindow (void)
1695 {
1696     OSL_TRACE("destroyed FocusForwardingWindow at %x", this);
1697 }
1698 
1699 
1700 
1701 
1702 void FocusForwardingWindow::KeyInput (const KeyEvent& rKEvt)
1703 {
1704     ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
1705     if (pViewShell.get() != NULL)
1706     {
1707         ::Window* pWindow = pViewShell->GetActiveWindow();
1708         if (pWindow != NULL)
1709         {
1710             // Forward the focus so that the window is called directly the
1711             // next time.
1712             pWindow->GrabFocus();
1713             // Forward the key press as well.
1714             pWindow->KeyInput(rKEvt);
1715         }
1716     }
1717 }
1718 
1719 
1720 
1721 
1722 void FocusForwardingWindow::Command (const CommandEvent& rEvent)
1723 {
1724     ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
1725     if (pViewShell.get() != NULL)
1726     {
1727         ::Window* pWindow = pViewShell->GetActiveWindow();
1728         if (pWindow != NULL)
1729         {
1730             pWindow->Command(rEvent);
1731         }
1732     }
1733 }
1734 
1735 
1736 } // end of anonymouse namespace
1737 
1738 } // end of namespace sd
1739