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