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