1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
31 #include <comphelper/processfactory.hxx>
33 #include <com/sun/star/frame/UnknownModuleException.hpp>
34 #include <com/sun/star/frame/XModuleManager.hpp>
35 #include <com/sun/star/container/XNameAccess.hpp>
36 #include <com/sun/star/beans/PropertyValue.hpp>
38 #include "ViewShellBase.hxx"
40 #include "EventMultiplexer.hxx"
41 #include "cache/SlsPageCacheManager.hxx"
42 #include "sdresid.hxx"
44 #include "strings.hrc"
46 #include "unokywds.hxx"
47 #include <svx/svxids.hrc>
48 #include "DrawDocShell.hxx"
49 #include <sfx2/app.hxx>
50 #include "PaneChildWindows.hxx"
51 #include "NotesChildWindow.hxx"
52 #include "ViewShellManager.hxx"
53 #include "DrawController.hxx"
54 #include "UpdateLockManager.hxx"
55 #include "FrameView.hxx"
56 #include "ViewTabBar.hxx"
57 #include <sfx2/event.hxx>
58 #include "drawdoc.hxx"
59 #include <sfx2/dispatch.hxx>
60 #include <sfx2/request.hxx>
61 #include <sfx2/printer.hxx>
62 #include "DrawViewShell.hxx"
63 #include "GraphicViewShell.hxx"
64 #include "OutlineViewShell.hxx"
65 #include "SlideSorterViewShell.hxx"
66 #include "PresentationViewShell.hxx"
67 #include "FormShellManager.hxx"
68 #include "ToolBarManager.hxx"
69 #include "taskpane/PanelId.hxx"
71 #include "framework/ConfigurationController.hxx"
72 #include "DocumentRenderer.hxx"
74 #include <com/sun/star/frame/XFrame.hpp>
75 #include <com/sun/star/awt/XWindow.hpp>
76 #include <com/sun/star/frame/XController.hpp>
77 #include <com/sun/star/frame/XModel.hpp>
78 #include <com/sun/star/document/XViewDataSupplier.hpp>
79 #include <com/sun/star/container/XIndexAccess.hpp>
80 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
81 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
82 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
83 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
84 #include <com/sun/star/drawing/framework/ResourceId.hpp>
85 #include "framework/FrameworkHelper.hxx"
87 #include <rtl/ref.hxx>
88 #include <sfx2/msg.hxx>
89 #include <sfx2/objface.hxx>
90 #include <sfx2/viewfrm.hxx>
91 #include <svl/whiter.hxx>
92 #include <comphelper/processfactory.hxx>
93 #include <vcl/msgbox.hxx>
94 #include <tools/diagnose_ex.h>
96 #include "fubullet.hxx"
100 #include "sdslots.hxx"
102 using ::sd::framework::FrameworkHelper
;
103 using ::rtl::OUString
;
104 using namespace com::sun::star::uno
;
105 using namespace com::sun::star::frame
;
106 using namespace com::sun::star::container
;
107 using namespace com::sun::star::lang
;
108 using namespace com::sun::star::beans
;
112 class CurrentPageSetter
115 CurrentPageSetter (ViewShellBase
& rBase
);
116 void operator () (bool);
118 ViewShellBase
& mrBase
;
121 } // end of anonymous namespace
124 using namespace ::com::sun::star
;
125 using namespace ::com::sun::star::uno
;
126 using namespace ::com::sun::star::drawing::framework
;
127 using ::sd::framework::FrameworkHelper
;
131 class ViewShellBase::Implementation
134 /** Main controller of the view shell. During the switching from one
135 stacked shell to another this pointer may be NULL.
137 ::rtl::Reference
<DrawController
> mpController
;
139 /** The view tab bar is the control for switching between different
142 ::rtl::Reference
<ViewTabBar
> mpViewTabBar
;
144 // contains the complete area of the current view relative to the frame window
145 Rectangle maClientArea
;
147 // This is set to true when PrepareClose() is called.
150 /** The view window is the parent of all UI elements that belong to the
151 view or ViewShell. This comprises the rulers, the scroll bars, and
153 It does not include the ViewTabBar.
155 ::boost::scoped_ptr
< ::Window
> mpViewWindow
;
157 ::boost::shared_ptr
<ToolBarManager
> mpToolBarManager
;
159 ::boost::shared_ptr
<ViewShellManager
> mpViewShellManager
;
161 ::boost::shared_ptr
<tools::EventMultiplexer
> mpEventMultiplexer
;
163 ::boost::shared_ptr
<UpdateLockManager
> mpUpdateLockManager
;
165 ::boost::shared_ptr
<FormShellManager
> mpFormShellManager
;
167 Implementation (ViewShellBase
& rBase
);
168 ~Implementation (void);
170 void LateInit (void);
172 /** Show or hide the ViewTabBar.
174 When <TRUE/> then the ViewTabBar is shown, otherwise it is hidden.
176 void ShowViewTabBar (bool bShow
);
178 /** Common code of ViewShellBase::OuterResizePixel() and
179 ViewShellBase::InnerResizePixel().
182 const Point
& rOrigin
,
186 /** Show or hide the specified pane. The visibility state is taken
187 fromthe given request.
189 The request determines the new visibility state. The state can
190 either be toggled or be set to a given value.
192 This URL specifies the pane whose visibility state to set.
194 When the pane becomes visible then this view URL specifies which
195 type of view to show in it.
197 void SetPaneVisibility (
198 const SfxRequest
& rRequest
,
199 const ::rtl::OUString
& rsPaneURL
,
200 const ::rtl::OUString
& rsViewURL
);
202 void GetSlotState (SfxItemSet
& rSet
);
204 void ProcessRestoreEditingViewSlot (void);
205 void ProcessTaskPaneSlot (SfxRequest
& rRequest
);
208 ViewShellBase
& mrBase
;
210 /** Hold a reference to the page cache manager of the slide sorter in
211 order to ensure that it stays alive while the ViewShellBase is
214 ::boost::shared_ptr
<slidesorter::cache::PageCacheManager
> mpPageCacheManager
;
219 /** The only task of this window is to forward key presses to the content
220 window of the main view shell. With the key press it forwards the focus
221 so that it is not called very often.
223 class FocusForwardingWindow
: public ::Window
226 FocusForwardingWindow (::Window
& rParentWindow
, ViewShellBase
& rBase
);
227 virtual ~FocusForwardingWindow (void);
228 virtual void KeyInput (const KeyEvent
& rEvent
);
229 virtual void Command (const CommandEvent
& rEvent
);
232 ViewShellBase
& mrBase
;
234 } // end of anonymous namespace
237 //===== ViewShellBase =========================================================
239 TYPEINIT1(ViewShellBase
, SfxViewShell
);
241 // We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
242 // new ViewShellBase object has been constructed.
244 SfxViewFactory
* ViewShellBase::pFactory
;
245 SfxViewShell
* __EXPORT
ViewShellBase::CreateInstance (
246 SfxViewFrame
*pFrame
, SfxViewShell
*pOldView
)
248 ViewShellBase
* pBase
= new ViewShellBase(pFrame
, pOldView
);
249 pBase
->LateInit(OUString());
252 void ViewShellBase::RegisterFactory( sal_uInt16 nPrio
)
254 pFactory
= new SfxViewFactory(
255 &CreateInstance
,&InitFactory
,nPrio
,"Default");
258 void ViewShellBase::InitFactory()
260 SFX_VIEW_REGISTRATION(DrawDocShell
);
265 SFX_IMPL_INTERFACE(ViewShellBase
, SfxViewShell
, SdResId(STR_VIEWSHELLBASE
))
272 ViewShellBase::ViewShellBase (
273 SfxViewFrame
* _pFrame
,
275 : SfxViewShell (_pFrame
,
277 | SFX_VIEW_HAS_PRINTOPTIONS
),
283 mpImpl
.reset(new Implementation(*this));
284 mpImpl
->mpViewWindow
.reset(new FocusForwardingWindow(_pFrame
->GetWindow(),*this));
285 mpImpl
->mpViewWindow
->SetBackground(Wallpaper());
286 mpImpl
->mpUpdateLockManager
.reset(new UpdateLockManager(*this));
288 _pFrame
->GetWindow().SetBackground(Wallpaper());
290 // Set up the members in the correct order.
291 if (GetViewFrame()->GetObjectShell()->ISA(DrawDocShell
))
292 mpDocShell
= static_cast<DrawDocShell
*>(
293 GetViewFrame()->GetObjectShell());
294 if (mpDocShell
!= NULL
)
295 mpDocument
= mpDocShell
->GetDoc();
296 mpImpl
->mpViewShellManager
.reset(new ViewShellManager(*this));
298 SetWindow(mpImpl
->mpViewWindow
.get());
300 // Hide the window to avoid complaints from Sfx...SwitchViewShell...
301 _pFrame
->GetWindow().Hide();
307 /** In this destructor the order in which some of the members are destroyed
308 (and/or being prepared to being destroyed) is important. Change it only
309 when you know what you are doing.
311 ViewShellBase::~ViewShellBase (void)
313 // Tell the controller that the ViewShellBase is not available anymore.
314 if (mpImpl
->mpController
.get() != NULL
)
315 mpImpl
->mpController
->ReleaseViewShellBase();
317 // We have to hide the main window to prevent SFX complaining after a
318 // reload about it being already visible.
319 ViewShell
* pShell
= GetMainViewShell().get();
321 && pShell
->GetActiveWindow()!=NULL
322 && pShell
->GetActiveWindow()->GetParent()!=NULL
)
324 pShell
->GetActiveWindow()->GetParent()->Hide();
327 mpImpl
->mpUpdateLockManager
->Disable();
328 mpImpl
->mpToolBarManager
->Shutdown();
329 mpImpl
->mpViewShellManager
->Shutdown();
331 EndListening(*GetViewFrame());
332 EndListening(*GetDocShell());
340 void ViewShellBase::LateInit (const ::rtl::OUString
& rsDefaultView
)
342 StartListening(*GetViewFrame(),sal_True
);
343 StartListening(*GetDocShell(),sal_True
);
345 InitializeFramework();
347 mpImpl
->mpEventMultiplexer
.reset(new tools::EventMultiplexer (*this));
349 mpImpl
->mpFormShellManager
.reset(new FormShellManager(*this));
351 mpImpl
->mpToolBarManager
= ToolBarManager::Create(
353 mpImpl
->mpEventMultiplexer
,
354 mpImpl
->mpViewShellManager
);
358 Reference
<XControllerManager
> xControllerManager (GetDrawController(), UNO_QUERY_THROW
);
359 Reference
<XConfigurationController
> xConfigurationController (
360 xControllerManager
->getConfigurationController());
361 if (xConfigurationController
.is())
363 OUString
sView (rsDefaultView
);
364 if (sView
.getLength() == 0)
365 sView
= GetInitialViewShellType();
367 ::boost::shared_ptr
<FrameworkHelper
> pHelper (FrameworkHelper::Instance(*this));
369 // Create the resource ids for the center pane and view.
370 const Reference
<drawing::framework::XResourceId
> xCenterPaneId (
371 pHelper
->CreateResourceId(FrameworkHelper::msCenterPaneURL
));
372 const Reference
<drawing::framework::XResourceId
> xCenterViewId (
373 pHelper
->CreateResourceId(sView
, xCenterPaneId
));
375 // Request center pane and view.
376 xConfigurationController
->requestResourceActivation(xCenterPaneId
, ResourceActivationMode_ADD
);
377 xConfigurationController
->requestResourceActivation(xCenterViewId
, ResourceActivationMode_REPLACE
);
379 // Process configuration events synchronously until the center view
381 sd::framework::ConfigurationController
* pConfigurationController
382 = dynamic_cast<sd::framework::ConfigurationController
*>(xConfigurationController
.get());
383 if (pConfigurationController
!= NULL
)
386 ! pConfigurationController
->getResource(xCenterViewId
).is()
387 && pConfigurationController
->hasPendingRequests())
389 pConfigurationController
->ProcessEvent();
394 catch (RuntimeException
&)
397 // AutoLayouts have to be ready.
398 GetDocument()->StopWorkStartupDelay();
402 // Remember the type of the current main view shell in the frame view.
403 ViewShell
* pViewShell
= GetMainViewShell().get();
404 if (pViewShell
!= NULL
)
406 FrameView
* pFrameView
= pViewShell
->GetFrameView();
407 if (pFrameView
!= NULL
)
408 pFrameView
->SetViewShellTypeOnLoad(pViewShell
->GetShellType());
415 ::boost::shared_ptr
<ViewShellManager
> ViewShellBase::GetViewShellManager (void) const
417 return mpImpl
->mpViewShellManager
;
423 ::boost::shared_ptr
<ViewShell
> ViewShellBase::GetMainViewShell (void) const
425 ::boost::shared_ptr
<ViewShell
> pMainViewShell (
426 framework::FrameworkHelper::Instance(*const_cast<ViewShellBase
*>(this))
427 ->GetViewShell(framework::FrameworkHelper::msCenterPaneURL
));
428 if (pMainViewShell
.get() == NULL
)
429 pMainViewShell
= framework::FrameworkHelper::Instance(*const_cast<ViewShellBase
*>(this))
430 ->GetViewShell(framework::FrameworkHelper::msFullScreenPaneURL
);
431 return pMainViewShell
;
437 ViewShellBase
* ViewShellBase::GetViewShellBase (SfxViewFrame
* pViewFrame
)
439 ViewShellBase
* pBase
= NULL
;
441 if (pViewFrame
!= NULL
)
443 // Get the view shell for the frame and cast it to
444 // sd::ViewShellBase.
445 SfxViewShell
* pSfxViewShell
= pViewFrame
->GetViewShell();
446 if (pSfxViewShell
!=NULL
&& pSfxViewShell
->ISA(::sd::ViewShellBase
))
447 pBase
= static_cast<ViewShellBase
*>(pSfxViewShell
);
456 DrawDocShell
* ViewShellBase::GetDocShell (void) const
463 SdDrawDocument
* ViewShellBase::GetDocument (void) const
471 void ViewShellBase::Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
473 SfxViewShell::Notify(rBC
, rHint
);
475 if (rHint
.IsA(TYPE(SfxEventHint
)))
477 switch (static_cast<const SfxEventHint
&>(rHint
).GetEventId())
479 case SFX_EVENT_OPENDOC
:
480 if( GetDocument() && GetDocument()->IsStartWithPresentation() )
484 GetDocument()->SetStartWithPresentation( false );
485 GetViewFrame()->GetDispatcher()->Execute(
486 SID_PRESENTATION
, SFX_CALLMODE_ASYNCHRON
);
491 // mpPaneManager->InitPanes();
504 void ViewShellBase::InitializeFramework (void)
511 void ViewShellBase::InnerResizePixel (const Point
& rOrigin
, const Size
&rSize
)
513 Size aObjSize
= GetObjectShell()->GetVisArea().GetSize();
514 if ( aObjSize
.Width() > 0 && aObjSize
.Height() > 0 )
516 SvBorder
aBorder( GetBorderPixel() );
518 aSize
.Width() -= (aBorder
.Left() + aBorder
.Right());
519 aSize
.Height() -= (aBorder
.Top() + aBorder
.Bottom());
520 Size aObjSizePixel
= mpImpl
->mpViewWindow
->LogicToPixel( aObjSize
, MAP_100TH_MM
);
521 SfxViewShell::SetZoomFactor(
522 Fraction( aSize
.Width(), std::max( aObjSizePixel
.Width(), (long int)1 ) ),
523 Fraction( aSize
.Height(), std::max( aObjSizePixel
.Height(), (long int)1) ) );
526 mpImpl
->ResizePixel(rOrigin
, rSize
, false);
532 void ViewShellBase::OuterResizePixel (const Point
& rOrigin
, const Size
&rSize
)
534 mpImpl
->ResizePixel (rOrigin
, rSize
, true);
540 void ViewShellBase::Rearrange (void)
542 OSL_ASSERT(GetViewFrame()!=NULL
);
544 // There is a bug in the communication between embedded objects and the
545 // framework::LayoutManager that leads to missing resize updates. The
546 // following workaround enforces such an update by cycling the border to
547 // zero and back to the current value.
548 if (GetWindow() != NULL
)
550 SetBorderPixel(SvBorder());
555 OSL_TRACE("Rearrange: window missing");
558 GetViewFrame()->Resize(sal_True
);
564 ErrCode
ViewShellBase::DoVerb (long nVerb
)
566 ErrCode aResult
= ERRCODE_NONE
;
568 ::sd::ViewShell
* pShell
= GetMainViewShell().get();
570 aResult
= pShell
->DoVerb (nVerb
);
578 Reference
<view::XRenderable
> ViewShellBase::GetRenderable (void)
580 // Create a new DocumentRenderer on every call. It observes the life
581 // time of this ViewShellBase object.
582 return Reference
<view::XRenderable
>(new DocumentRenderer(*this));
588 SfxPrinter
* ViewShellBase::GetPrinter (sal_Bool bCreate
)
590 OSL_ASSERT(mpImpl
.get()!=NULL
);
592 return GetDocShell()->GetPrinter (bCreate
);
598 sal_uInt16
ViewShellBase::SetPrinter (
599 SfxPrinter
* pNewPrinter
,
600 sal_uInt16 nDiffFlags
,
603 OSL_ASSERT(mpImpl
.get()!=NULL
);
605 GetDocShell()->SetPrinter(pNewPrinter
);
607 if ( (nDiffFlags
& SFX_PRINTER_CHG_ORIENTATION
||
608 nDiffFlags
& SFX_PRINTER_CHG_SIZE
) && pNewPrinter
)
610 MapMode aMap
= pNewPrinter
->GetMapMode();
611 aMap
.SetMapUnit(MAP_100TH_MM
);
612 MapMode aOldMap
= pNewPrinter
->GetMapMode();
613 pNewPrinter
->SetMapMode(aMap
);
614 Size aNewSize
= pNewPrinter
->GetOutputSize();
616 sal_Bool bScaleAll
= sal_False
;
619 WarningBox
aWarnBox (
621 (WinBits
)(WB_YES_NO
| WB_DEF_YES
),
622 String(SdResId(STR_SCALE_OBJS_TO_PAGE
)));
623 bScaleAll
= (aWarnBox
.Execute() == RET_YES
);
626 ::boost::shared_ptr
<DrawViewShell
> pDrawViewShell (
627 ::boost::dynamic_pointer_cast
<DrawViewShell
>(GetMainViewShell()));
630 SdPage
* pPage
= GetDocument()->GetSdPage(
632 pDrawViewShell
->SetPageSizeAndBorder (
633 pDrawViewShell
->GetPageKind(),
637 pNewPrinter
->GetOrientation(),
638 pPage
->GetPaperBin(),
639 pPage
->IsBackgroundFullSize());
642 pNewPrinter
->SetMapMode(aOldMap
);
651 SfxTabPage
* ViewShellBase::CreatePrintOptionsPage(
653 const SfxItemSet
&rOptions
)
658 // return mpImpl->mpPrintManager->CreatePrintOptionsPage (pParent, rOptions);
664 void ViewShellBase::UIActivating( SfxInPlaceClient
* pClient
)
666 mpImpl
->ShowViewTabBar(false);
668 ViewShell
* pViewShell
= GetMainViewShell().get();
670 pViewShell
->UIActivating( pClient
);
672 SfxViewShell::UIActivating( pClient
);
678 void ViewShellBase::UIDeactivated( SfxInPlaceClient
* pClient
)
680 SfxViewShell::UIDeactivated( pClient
);
682 mpImpl
->ShowViewTabBar(true);
684 ViewShell
* pViewShell
= GetMainViewShell().get();
686 pViewShell
->UIDeactivated( pClient
);
692 SvBorder
ViewShellBase::GetBorder (bool )
695 if (mpImpl
->mpViewTabBar
.is() && mpImpl
->mpViewTabBar
->GetTabControl()->IsVisible())
696 nTop
= mpImpl
->mpViewTabBar
->GetHeight();
697 return SvBorder(0,nTop
,0,0);
703 void ViewShellBase::Execute (SfxRequest
& rRequest
)
705 sal_uInt16 nSlotId
= rRequest
.GetSlot();
709 case SID_SWITCH_SHELL
:
711 Reference
<XControllerManager
> xControllerManager (GetController(), UNO_QUERY
);
712 if (xControllerManager
.is())
714 Reference
<XConfigurationController
> xConfigurationController (
715 xControllerManager
->getConfigurationController());
716 if (xConfigurationController
.is())
717 xConfigurationController
->update();
722 case SID_LEFT_PANE_DRAW
:
723 mpImpl
->SetPaneVisibility(
725 framework::FrameworkHelper::msLeftDrawPaneURL
,
726 framework::FrameworkHelper::msSlideSorterURL
);
729 case SID_LEFT_PANE_IMPRESS
:
730 mpImpl
->SetPaneVisibility(
732 framework::FrameworkHelper::msLeftImpressPaneURL
,
733 framework::FrameworkHelper::msSlideSorterURL
);
737 mpImpl
->SetPaneVisibility(
739 framework::FrameworkHelper::msRightPaneURL
,
740 framework::FrameworkHelper::msTaskPaneURL
);
743 case SID_NORMAL_MULTI_PANE_GUI
:
744 case SID_SLIDE_SORTER_MULTI_PANE_GUI
:
745 case SID_DRAWINGMODE
:
747 case SID_OUTLINEMODE
:
749 case SID_HANDOUTMODE
:
750 framework::FrameworkHelper::Instance(*this)->HandleModeChangeSlot(nSlotId
, rRequest
);
753 case SID_WIN_FULLSCREEN
:
754 // The full screen mode is not supported. Ignore the request.
757 case SID_SHOW_TOOL_PANEL
:
758 mpImpl
->ProcessTaskPaneSlot(rRequest
);
761 case SID_RESTORE_EDITING_VIEW
:
762 mpImpl
->ProcessRestoreEditingViewSlot();
766 // Ignore any other slot.
775 void ViewShellBase::GetState (SfxItemSet
& rSet
)
777 // The full screen mode is not supported. Disable the the slot so that
778 // it appears grayed out when somebody uses configures the menu to show
779 // an menu item for it.
780 // if (rSet.GetItemState(SID_WIN_FULLSCREEN) == SFX_ITEM_AVAILABLE)
781 // rSet.DisableItem(SID_WIN_FULLSCREEN);
783 mpImpl
->GetSlotState(rSet
);
785 FuBullet::GetSlotState( rSet
, 0, GetViewFrame() );
791 void ViewShellBase::WriteUserDataSequence (
792 ::com::sun::star::uno::Sequence
<
793 ::com::sun::star::beans::PropertyValue
>& rSequence
,
796 // Forward call to main sub shell.
797 ViewShell
* pShell
= GetMainViewShell().get();
799 pShell
->WriteUserDataSequence (rSequence
, bBrowse
);
805 void ViewShellBase::ReadUserDataSequence (
806 const ::com::sun::star::uno::Sequence
<
807 ::com::sun::star::beans::PropertyValue
>& rSequence
,
810 // Forward call to main sub shell.
811 ViewShell
* pShell
= GetMainViewShell().get();
814 pShell
->ReadUserDataSequence (rSequence
, bBrowse
);
816 // For certain shell types ReadUserDataSequence may have changed the
817 // type to another one. Make sure that the center pane shows the
819 switch (pShell
->GetShellType())
821 case ViewShell::ST_IMPRESS
:
822 case ViewShell::ST_NOTES
:
823 case ViewShell::ST_HANDOUT
:
825 ::rtl::OUString sViewURL
;
826 switch (PTR_CAST(DrawViewShell
, pShell
)->GetPageKind())
830 sViewURL
= framework::FrameworkHelper::msImpressViewURL
;
833 sViewURL
= framework::FrameworkHelper::msNotesViewURL
;
836 sViewURL
= framework::FrameworkHelper::msHandoutViewURL
;
839 if (sViewURL
.getLength() > 0)
840 framework::FrameworkHelper::Instance(*this)->RequestView(
842 framework::FrameworkHelper::msCenterPaneURL
);
855 void ViewShellBase::Activate (sal_Bool bIsMDIActivate
)
857 SfxViewShell::Activate(bIsMDIActivate
);
859 Reference
<XControllerManager
> xControllerManager (GetController(), UNO_QUERY
);
860 if (xControllerManager
.is())
862 Reference
<XConfigurationController
> xConfigurationController (
863 xControllerManager
->getConfigurationController());
864 if (xConfigurationController
.is())
865 xConfigurationController
->update();
867 GetToolBarManager()->RequestUpdate();
873 void ViewShellBase::Deactivate (sal_Bool bIsMDIActivate
)
875 SfxViewShell::Deactivate(bIsMDIActivate
);
881 void ViewShellBase::SetZoomFactor (
882 const Fraction
&rZoomX
,
883 const Fraction
&rZoomY
)
885 SfxViewShell::SetZoomFactor (rZoomX
, rZoomY
);
886 // Forward call to main sub shell.
887 ViewShell
* pShell
= GetMainViewShell().get();
889 pShell
->SetZoomFactor (rZoomX
, rZoomY
);
895 sal_uInt16
ViewShellBase::PrepareClose (sal_Bool bUI
, sal_Bool bForBrowsing
)
897 sal_uInt16 nResult
= SfxViewShell::PrepareClose (bUI
, bForBrowsing
);
899 if (nResult
== sal_True
)
901 mpImpl
->mbIsClosing
= true;
903 // Forward call to main sub shell.
904 ViewShell
* pShell
= GetMainViewShell().get();
906 nResult
= pShell
->PrepareClose (bUI
, bForBrowsing
);
915 void ViewShellBase::WriteUserData (String
& rString
, sal_Bool bBrowse
)
917 SfxViewShell::WriteUserData (rString
, bBrowse
);
919 // Forward call to main sub shell.
920 ViewShell
* pShell
= GetMainViewShell().get();
922 pShell
->WriteUserData (rString
);
928 void ViewShellBase::ReadUserData (const String
& rString
, sal_Bool bBrowse
)
930 SfxViewShell::ReadUserData (rString
, bBrowse
);
932 // Forward call to main sub shell.
933 ViewShell
* pShell
= GetMainViewShell().get();
935 pShell
->ReadUserData (rString
);
941 SdrView
* ViewShellBase::GetDrawView (void) const
943 // Forward call to main sub shell.
944 ViewShell
* pShell
= GetMainViewShell().get();
946 return pShell
->GetDrawView ();
948 return SfxViewShell::GetDrawView();
954 void ViewShellBase::AdjustPosSizePixel (const Point
&rOfs
, const Size
&rSize
)
956 SfxViewShell::AdjustPosSizePixel (rOfs
, rSize
);
962 void ViewShellBase::SetBusyState (bool bBusy
)
964 if (GetDocShell() != NULL
)
965 GetDocShell()->SetWaitCursor (bBusy
);
971 void ViewShellBase::UpdateBorder ( bool bForce
/* = false */ )
973 // The following calls to SetBorderPixel() and InvalidateBorder() are
974 // made only for the main view shell. This not only avoids unnecessary
975 // calls for the views in side panes but prevents calling an already
976 // dying SfxViewShell base class.
977 // For issue #140703# we have to check the existence of the window,
978 // too. The SfxViewFrame accesses the window without checking it.
979 ViewShell
* pMainViewShell
= GetMainViewShell().get();
980 if (pMainViewShell
!= NULL
&& GetWindow()!=NULL
)
982 SvBorder
aCurrentBorder (GetBorderPixel());
983 bool bOuterResize ( ! GetDocShell()->IsInPlaceActive());
984 SvBorder
aBorder (GetBorder(bOuterResize
));
985 aBorder
+= pMainViewShell
->GetBorder(bOuterResize
);
987 if (bForce
|| (aBorder
!= aCurrentBorder
))
989 SetBorderPixel (aBorder
);
998 void ViewShellBase::ShowUIControls (bool bVisible
)
1000 if (mpImpl
->mpViewTabBar
.is())
1001 mpImpl
->mpViewTabBar
->GetTabControl()->Show(bVisible
);
1003 ViewShell
* pMainViewShell
= GetMainViewShell().get();
1004 if (pMainViewShell
!= NULL
)
1005 pMainViewShell
->ShowUIControls (bVisible
);
1015 OUString
ViewShellBase::GetInitialViewShellType (void)
1017 OUString
sRequestedView (FrameworkHelper::msImpressViewURL
);
1021 Reference
<document::XViewDataSupplier
> xViewDataSupplier (
1022 GetDocShell()->GetModel(), UNO_QUERY
);
1023 if ( ! xViewDataSupplier
.is())
1026 Reference
<container::XIndexAccess
> xViewData (xViewDataSupplier
->getViewData());
1027 if ( ! xViewData
.is())
1029 if (xViewData
->getCount() == 0)
1032 sal_Int32 nView
= 0;
1033 ::com::sun::star::uno::Any aAny
= xViewData
->getByIndex(nView
);
1034 Sequence
<beans::PropertyValue
> aProperties
;
1035 if ( ! (aAny
>>= aProperties
))
1038 // Search the properties for the one that tells us what page kind to
1040 for (sal_Int32 n
=0; n
<aProperties
.getLength(); n
++)
1042 const beans::PropertyValue
& rProperty (aProperties
[n
]);
1043 if (rProperty
.Name
.compareToAscii(sUNO_View_PageKind
) == COMPARE_EQUAL
)
1045 sal_Int16 nPageKind
= 0;
1046 rProperty
.Value
>>= nPageKind
;
1047 switch ((PageKind
)nPageKind
)
1050 sRequestedView
= FrameworkHelper::msImpressViewURL
;
1054 sRequestedView
= FrameworkHelper::msHandoutViewURL
;
1058 sRequestedView
= FrameworkHelper::msNotesViewURL
;
1062 // The page kind is invalid. This is propably an
1063 // error by the caller. We use the standard type to
1064 // keep things going.
1065 DBG_ASSERT(sal_False
, "ViewShellBase::GetInitialViewShellType: invalid page kind");
1066 sRequestedView
= FrameworkHelper::msImpressViewURL
;
1075 return sRequestedView
;
1081 /** this method starts the presentation by
1082 executing the slot SID_PRESENTATION asynchronous */
1083 void ViewShellBase::StartPresentation()
1085 if( GetViewFrame() && GetViewFrame()->GetDispatcher() )
1086 GetViewFrame()->GetDispatcher()->Execute(SID_PRESENTATION
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
1093 ::boost::shared_ptr
<tools::EventMultiplexer
> ViewShellBase::GetEventMultiplexer (void)
1095 OSL_ASSERT(mpImpl
.get()!=NULL
);
1096 OSL_ASSERT(mpImpl
->mpEventMultiplexer
.get()!=NULL
);
1098 return mpImpl
->mpEventMultiplexer
;
1104 const Rectangle
& ViewShellBase::getClientRectangle (void) const
1106 return mpImpl
->maClientArea
;
1112 ::boost::shared_ptr
<UpdateLockManager
> ViewShellBase::GetUpdateLockManager (void) const
1114 OSL_ASSERT(mpImpl
.get()!=NULL
);
1115 OSL_ASSERT(mpImpl
->mpUpdateLockManager
.get()!=NULL
);
1117 return mpImpl
->mpUpdateLockManager
;
1123 ::boost::shared_ptr
<ToolBarManager
> ViewShellBase::GetToolBarManager (void) const
1125 OSL_ASSERT(mpImpl
.get()!=NULL
);
1126 OSL_ASSERT(mpImpl
->mpToolBarManager
.get()!=NULL
);
1128 return mpImpl
->mpToolBarManager
;
1134 ::boost::shared_ptr
<FormShellManager
> ViewShellBase::GetFormShellManager (void) const
1136 OSL_ASSERT(mpImpl
.get()!=NULL
);
1137 OSL_ASSERT(mpImpl
->mpFormShellManager
.get()!=NULL
);
1139 return mpImpl
->mpFormShellManager
;
1145 DrawController
& ViewShellBase::GetDrawController (void) const
1147 OSL_ASSERT(mpImpl
.get()!=NULL
);
1149 return *mpImpl
->mpController
;
1155 void ViewShellBase::SetViewTabBar (const ::rtl::Reference
<ViewTabBar
>& rViewTabBar
)
1157 OSL_ASSERT(mpImpl
.get()!=NULL
);
1159 mpImpl
->mpViewTabBar
= rViewTabBar
;
1165 ::Window
* ViewShellBase::GetViewWindow (void)
1167 OSL_ASSERT(mpImpl
.get()!=NULL
);
1169 return mpImpl
->mpViewWindow
.get();
1173 ::rtl::OUString
ImplRetrieveLabelFromCommand( const Reference
< XFrame
>& xFrame
, const ::rtl::OUString
& aCmdURL
)
1175 ::rtl::OUString aLabel
;
1177 if ( aCmdURL
.getLength() > 0 ) try
1179 Reference
< XMultiServiceFactory
> xServiceManager( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW
);
1181 Reference
< XModuleManager
> xModuleManager( xServiceManager
->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager") ) ), UNO_QUERY_THROW
);
1182 Reference
< XInterface
> xIfac( xFrame
, UNO_QUERY_THROW
);
1184 ::rtl::OUString
aModuleIdentifier( xModuleManager
->identify( xIfac
) );
1186 if( aModuleIdentifier
.getLength() > 0 )
1188 Reference
< XNameAccess
> xNameAccess( xServiceManager
->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.UICommandDescription" ) ) ), UNO_QUERY
);
1189 if( xNameAccess
.is() )
1191 Reference
< ::com::sun::star::container::XNameAccess
> m_xUICommandLabels( xNameAccess
->getByName( aModuleIdentifier
), UNO_QUERY_THROW
);
1192 Sequence
< PropertyValue
> aPropSeq
;
1193 if( m_xUICommandLabels
->getByName( aCmdURL
) >>= aPropSeq
)
1195 for( sal_Int32 i
= 0; i
< aPropSeq
.getLength(); i
++ )
1197 if( aPropSeq
[i
].Name
.equalsAscii( "Name" ))
1199 aPropSeq
[i
].Value
>>= aLabel
;
1207 catch ( Exception
& )
1214 ::rtl::OUString
ViewShellBase::RetrieveLabelFromCommand( const ::rtl::OUString
& aCmdURL
) const
1216 Reference
< XFrame
> xFrame( GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(), UNO_QUERY
);
1217 return ImplRetrieveLabelFromCommand( xFrame
, aCmdURL
);
1222 //===== ViewShellBase::Implementation =========================================
1224 ViewShellBase::Implementation::Implementation (ViewShellBase
& rBase
)
1231 mpViewShellManager(),
1232 mpEventMultiplexer(),
1233 mpUpdateLockManager(),
1234 mpFormShellManager(),
1236 mpPageCacheManager(slidesorter::cache::PageCacheManager::Instance())
1243 ViewShellBase::Implementation::~Implementation (void)
1245 mpController
= NULL
;
1246 mpViewTabBar
= NULL
;
1247 mpViewWindow
.reset();
1248 mpToolBarManager
.reset();
1254 void ViewShellBase::Implementation::LateInit (void)
1256 mpController
= new DrawController(mrBase
);
1262 void ViewShellBase::Implementation::ProcessRestoreEditingViewSlot (void)
1264 ViewShell
* pViewShell
= mrBase
.GetMainViewShell().get();
1265 if (pViewShell
!= NULL
)
1267 FrameView
* pFrameView
= pViewShell
->GetFrameView();
1268 if (pFrameView
!= NULL
)
1270 // Set view shell, edit mode, and page kind.
1271 pFrameView
->SetViewShEditMode(
1272 pFrameView
->GetViewShEditModeOnLoad(),
1273 pFrameView
->GetPageKindOnLoad());
1274 pFrameView
->SetPageKind(
1275 pFrameView
->GetPageKindOnLoad());
1276 ::boost::shared_ptr
<FrameworkHelper
> pHelper (FrameworkHelper::Instance(mrBase
));
1277 pHelper
->RequestView(
1278 pHelper
->GetViewURL(pFrameView
->GetViewShellTypeOnLoad()),
1279 FrameworkHelper::msCenterPaneURL
);
1280 pHelper
->RunOnConfigurationEvent(
1281 ::rtl::OUString::createFromAscii("ConfigurationUpdateEnd"),
1282 CurrentPageSetter(mrBase
));
1290 void ViewShellBase::Implementation::ShowViewTabBar (bool bShow
)
1292 if (mpViewTabBar
.is()
1293 && (mpViewTabBar
->GetTabControl()->IsVisible()==sal_True
) != bShow
)
1295 mpViewTabBar
->GetTabControl()->Show(bShow
? sal_True
: sal_False
);
1303 void ViewShellBase::Implementation::ResizePixel (
1304 const Point
& rOrigin
,
1311 // Forward the call to both the base class and the main stacked sub
1312 // shell only when main sub shell exists.
1313 ViewShell
* pMainViewShell
= mrBase
.GetMainViewShell().get();
1315 // Set the ViewTabBar temporarily to full size so that, when asked
1316 // later, it can return its true height.
1317 mrBase
.SetWindow (mpViewWindow
.get());
1318 if (mpViewTabBar
.is() && mpViewTabBar
->GetTabControl()->IsVisible())
1319 mpViewTabBar
->GetTabControl()->SetPosSizePixel (rOrigin
, rSize
);
1321 // Calculate and set the border before the controls are placed.
1323 if (pMainViewShell
!= NULL
)
1324 aBorder
= pMainViewShell
->GetBorder(bOuterResize
);
1325 aBorder
+= mrBase
.GetBorder(bOuterResize
);
1326 if (mrBase
.GetBorderPixel() != aBorder
)
1327 mrBase
.SetBorderPixel(aBorder
);
1329 // Place the ViewTabBar at the top. It is part of the border.
1330 SvBorder aBaseBorder
;
1331 if (mpViewTabBar
.is() && mpViewTabBar
->GetTabControl()->IsVisible())
1333 aBaseBorder
.Top() = mpViewTabBar
->GetHeight();
1334 mpViewTabBar
->GetTabControl()->SetPosSizePixel(
1335 rOrigin
, Size(rSize
.Width(),aBaseBorder
.Top()));
1338 // The view window gets the remaining space.
1339 Point
aViewWindowPosition (
1340 rOrigin
.X()+aBaseBorder
.Left(),
1341 rOrigin
.Y()+aBaseBorder
.Top());
1342 Size
aViewWindowSize (
1343 rSize
.Width() - aBaseBorder
.Left() - aBaseBorder
.Right(),
1344 rSize
.Height() - aBaseBorder
.Top() - aBaseBorder
.Bottom());
1345 mpViewWindow
->SetPosSizePixel(aViewWindowPosition
, aViewWindowSize
);
1347 maClientArea
= Rectangle(Point(0,0), aViewWindowSize
);
1353 void ViewShellBase::Implementation::SetPaneVisibility (
1354 const SfxRequest
& rRequest
,
1355 const ::rtl::OUString
& rsPaneURL
,
1356 const ::rtl::OUString
& rsViewURL
)
1360 Reference
<XControllerManager
> xControllerManager (mrBase
.GetController(), UNO_QUERY_THROW
);
1362 const Reference
< XComponentContext
> xContext(
1363 ::comphelper::getProcessComponentContext() );
1364 Reference
<XResourceId
> xPaneId (ResourceId::create(
1365 xContext
, rsPaneURL
));
1366 Reference
<XResourceId
> xViewId (ResourceId::createWithAnchorURL(
1367 xContext
, rsViewURL
, rsPaneURL
));
1369 // Determine the new visibility state.
1370 const SfxItemSet
* pArguments
= rRequest
.GetArgs();
1371 sal_Bool bShowChildWindow
;
1372 sal_uInt16 nSlotId
= rRequest
.GetSlot();
1373 if (pArguments
!= NULL
)
1374 bShowChildWindow
= static_cast<const SfxBoolItem
&>(
1375 pArguments
->Get(nSlotId
)).GetValue();
1378 Reference
<XConfigurationController
> xConfigurationController (
1379 xControllerManager
->getConfigurationController());
1380 if ( ! xConfigurationController
.is())
1381 throw RuntimeException();
1382 Reference
<XConfiguration
> xConfiguration (
1383 xConfigurationController
->getRequestedConfiguration());
1384 if ( ! xConfiguration
.is())
1385 throw RuntimeException();
1387 bShowChildWindow
= ! xConfiguration
->hasResource(xPaneId
);
1390 // Set the desired visibility state at the current configuration
1391 // and update it accordingly.
1392 Reference
<XConfigurationController
> xConfigurationController (
1393 xControllerManager
->getConfigurationController());
1394 if ( ! xConfigurationController
.is())
1395 throw RuntimeException();
1396 if (bShowChildWindow
)
1398 xConfigurationController
->requestResourceActivation(
1400 ResourceActivationMode_ADD
);
1401 xConfigurationController
->requestResourceActivation(
1403 ResourceActivationMode_REPLACE
);
1406 xConfigurationController
->requestResourceDeactivation(
1409 catch (const Exception
&)
1411 DBG_UNHANDLED_EXCEPTION();
1419 void ViewShellBase::Implementation::GetSlotState (SfxItemSet
& rSet
)
1423 // Get some frequently used values.
1424 Reference
<XControllerManager
> xControllerManager (mrBase
.GetController(), UNO_QUERY_THROW
);
1425 Reference
<XConfigurationController
> xConfigurationController (
1426 xControllerManager
->getConfigurationController());
1427 if ( ! xConfigurationController
.is())
1428 throw RuntimeException();
1429 Reference
<XConfiguration
> xConfiguration (
1430 xConfigurationController
->getRequestedConfiguration());
1431 if ( ! xConfiguration
.is())
1432 throw RuntimeException();
1434 const Reference
< XComponentContext
> xContext(
1435 ::comphelper::getProcessComponentContext() );
1436 SfxWhichIter
aSetIterator (rSet
);
1437 sal_uInt16
nItemId (aSetIterator
.FirstWhich());
1440 bool bState (false);
1441 Reference
<XResourceId
> xResourceId
;
1446 case SID_LEFT_PANE_IMPRESS
:
1447 xResourceId
= ResourceId::create(
1448 xContext
, FrameworkHelper::msLeftImpressPaneURL
);
1451 case SID_LEFT_PANE_DRAW
:
1452 xResourceId
= ResourceId::create(
1453 xContext
, FrameworkHelper::msLeftDrawPaneURL
);
1457 xResourceId
= ResourceId::create(
1458 xContext
, FrameworkHelper::msRightPaneURL
);
1461 case SID_NORMAL_MULTI_PANE_GUI
:
1462 xResourceId
= ResourceId::createWithAnchorURL(
1464 FrameworkHelper::msImpressViewURL
,
1465 FrameworkHelper::msCenterPaneURL
);
1468 case SID_SLIDE_SORTER_MULTI_PANE_GUI
:
1470 xResourceId
= ResourceId::createWithAnchorURL(
1472 FrameworkHelper::msSlideSorterURL
,
1473 FrameworkHelper::msCenterPaneURL
);
1476 case SID_OUTLINEMODE
:
1477 xResourceId
= ResourceId::createWithAnchorURL(
1479 FrameworkHelper::msOutlineViewURL
,
1480 FrameworkHelper::msCenterPaneURL
);
1483 case SID_HANDOUTMODE
:
1484 // There is only the master page mode for the handout
1485 // view so ignore the master page flag.
1486 xResourceId
= ResourceId::createWithAnchorURL(
1488 FrameworkHelper::msHandoutViewURL
,
1489 FrameworkHelper::msCenterPaneURL
);
1493 xResourceId
= ResourceId::createWithAnchorURL(
1495 FrameworkHelper::msNotesViewURL
,
1496 FrameworkHelper::msCenterPaneURL
);
1500 // Ignore all other items. They are not meant to be
1505 catch (DeploymentException
)
1509 // Determine the state for the resource.
1510 bState
= xConfiguration
->hasResource(xResourceId
);
1512 // Take the master page mode into account.
1515 case SID_NORMAL_MULTI_PANE_GUI
:
1518 // Determine the master page mode.
1519 ViewShell
* pCenterViewShell
= FrameworkHelper::Instance(mrBase
)->GetViewShell(
1520 FrameworkHelper::msCenterPaneURL
).get();
1521 bool bMasterPageMode (false);
1522 if (pCenterViewShell
!=NULL
&& pCenterViewShell
->ISA(DrawViewShell
))
1523 if (PTR_CAST(DrawViewShell
,pCenterViewShell
)->GetEditMode()
1526 bMasterPageMode
= true;
1529 bState
&= !bMasterPageMode
;
1533 case SID_HANDOUTMODE
:
1534 // There is only the master page mode for the handout
1535 // view so ignore the master page flag.
1539 // And finally set the state.
1540 rSet
.Put(SfxBoolItem(nItemId
, bState
));
1542 nItemId
= aSetIterator
.NextWhich();
1545 catch (RuntimeException
&)
1547 DBG_UNHANDLED_EXCEPTION();
1555 void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest
& rRequest
)
1557 // Set the visibility state of the toolpanel and one of its top
1559 sal_Bool bShowToolPanel
= sal_True
;
1560 toolpanel::PanelId
nPanelId (
1561 toolpanel::PID_UNKNOWN
);
1562 bool bPanelIdGiven
= false;
1564 // Extract the given arguments.
1565 const SfxItemSet
* pArgs
= rRequest
.GetArgs();
1568 if ((pArgs
->Count() == 1) || (pArgs
->Count() == 2))
1570 SFX_REQUEST_ARG (rRequest
, pIsPanelVisible
,
1571 SfxBoolItem
, ID_VAL_ISVISIBLE
, sal_False
);
1572 if (pIsPanelVisible
!= NULL
)
1573 bShowToolPanel
= pIsPanelVisible
->GetValue();
1575 if (pArgs
->Count() == 2)
1577 SFX_REQUEST_ARG (rRequest
, pPanelId
, SfxUInt32Item
,
1578 ID_VAL_PANEL_INDEX
, sal_False
);
1579 if (pPanelId
!= NULL
)
1581 nPanelId
= static_cast<
1582 toolpanel::PanelId
>(
1583 pPanelId
->GetValue());
1584 bPanelIdGiven
= true;
1589 // Ignore the request for some combinations of panels and view
1592 && ! (nPanelId
==toolpanel::PID_LAYOUT
1593 && mrBase
.GetMainViewShell()!=NULL
1594 && mrBase
.GetMainViewShell()->GetShellType()==ViewShell::ST_OUTLINE
))
1596 framework::FrameworkHelper::Instance(mrBase
)->RequestTaskPanel(
1597 framework::FrameworkHelper::msLayoutTaskPanelURL
);
1602 } // end of namespace sd
1607 //===== CurrentPageSetter ===========================================
1611 CurrentPageSetter::CurrentPageSetter (ViewShellBase
& rBase
)
1620 void CurrentPageSetter::operator() (bool)
1622 FrameView
* pFrameView
= NULL
;
1624 if (mrBase
.GetMainViewShell() != NULL
)
1626 pFrameView
= mrBase
.GetMainViewShell()->GetFrameView();
1629 if (pFrameView
!=NULL
)
1633 // Get the current page either from the DrawPagesSupplier or the
1634 // MasterPagesSupplier.
1636 if (pFrameView
->GetViewShEditModeOnLoad() == EM_PAGE
)
1638 Reference
<drawing::XDrawPagesSupplier
> xPagesSupplier (
1639 mrBase
.GetController()->getModel(), UNO_QUERY_THROW
);
1640 Reference
<container::XIndexAccess
> xPages (
1641 xPagesSupplier
->getDrawPages(), UNO_QUERY_THROW
);
1642 aPage
= xPages
->getByIndex(pFrameView
->GetSelectedPageOnLoad());
1646 Reference
<drawing::XMasterPagesSupplier
> xPagesSupplier (
1647 mrBase
.GetController()->getModel(), UNO_QUERY_THROW
);
1648 Reference
<container::XIndexAccess
> xPages (
1649 xPagesSupplier
->getMasterPages(), UNO_QUERY_THROW
);
1650 aPage
= xPages
->getByIndex(pFrameView
->GetSelectedPageOnLoad());
1652 // Switch to the page last edited by setting the CurrentPage
1654 Reference
<beans::XPropertySet
> xSet (mrBase
.GetController(), UNO_QUERY_THROW
);
1655 xSet
->setPropertyValue (String::CreateFromAscii("CurrentPage"), aPage
);
1657 catch (RuntimeException aException
)
1659 // We have not been able to set the current page at the main view.
1660 // This is sad but still leaves us in a valid state. Therefore,
1661 // this exception is silently ignored.
1663 catch (beans::UnknownPropertyException aException
)
1665 DBG_ASSERT(false,"CurrentPage property unknown");
1670 } // end of anonymouse namespace
1675 //===== FocusForwardingWindow =================================================
1677 namespace sd
{ namespace {
1679 FocusForwardingWindow::FocusForwardingWindow (
1680 ::Window
& rParentWindow
,
1681 ViewShellBase
& rBase
)
1682 : ::Window(&rParentWindow
, WinBits(WB_CLIPCHILDREN
| WB_DIALOGCONTROL
)),
1685 OSL_TRACE("created FocusForwardingWindow at %x", this);
1691 FocusForwardingWindow::~FocusForwardingWindow (void)
1693 OSL_TRACE("destroyed FocusForwardingWindow at %x", this);
1699 void FocusForwardingWindow::KeyInput (const KeyEvent
& rKEvt
)
1701 ::boost::shared_ptr
<ViewShell
> pViewShell
= mrBase
.GetMainViewShell();
1702 if (pViewShell
.get() != NULL
)
1704 ::Window
* pWindow
= pViewShell
->GetActiveWindow();
1705 if (pWindow
!= NULL
)
1707 // Forward the focus so that the window is called directly the
1709 pWindow
->GrabFocus();
1710 // Forward the key press as well.
1711 pWindow
->KeyInput(rKEvt
);
1719 void FocusForwardingWindow::Command (const CommandEvent
& rEvent
)
1721 ::boost::shared_ptr
<ViewShell
> pViewShell
= mrBase
.GetMainViewShell();
1722 if (pViewShell
.get() != NULL
)
1724 ::Window
* pWindow
= pViewShell
->GetActiveWindow();
1725 if (pWindow
!= NULL
)
1727 pWindow
->Command(rEvent
);
1733 } // end of anonymouse namespace
1735 } // end of namespace sd