1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ViewShellBase.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "ViewShellBase.hxx"
36 #include "EventMultiplexer.hxx"
37 #include "cache/SlsPageCacheManager.hxx"
38 #include "sdresid.hxx"
40 #include "strings.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 "PrintManager.hxx"
51 #include "UpdateLockManager.hxx"
52 #include "FrameView.hxx"
53 #include "ViewTabBar.hxx"
54 #include <sfx2/event.hxx>
55 #include "drawdoc.hxx"
56 #include <sfx2/dispatch.hxx>
57 #include <sfx2/request.hxx>
58 #include "DrawViewShell.hxx"
59 #include "GraphicViewShell.hxx"
60 #include "OutlineViewShell.hxx"
61 #include "SlideSorterViewShell.hxx"
62 #include "PresentationViewShell.hxx"
63 #include "TaskPaneViewShell.hxx"
64 #include "FormShellManager.hxx"
65 #include "ToolBarManager.hxx"
67 #include "framework/ConfigurationController.hxx"
69 #include <com/sun/star/frame/XFrame.hpp>
70 #include <com/sun/star/awt/XWindow.hpp>
71 #include <com/sun/star/frame/XController.hpp>
72 #include <com/sun/star/frame/XModel.hpp>
73 #include <com/sun/star/document/XViewDataSupplier.hpp>
74 #include <com/sun/star/container/XIndexAccess.hpp>
75 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
76 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
77 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
78 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
79 #include <com/sun/star/drawing/framework/ResourceId.hpp>
80 #include "framework/FrameworkHelper.hxx"
82 #include <rtl/ref.hxx>
83 #include <sfx2/msg.hxx>
84 #include <sfx2/objface.hxx>
85 #include <sfx2/viewfrm.hxx>
86 #include <svtools/whiter.hxx>
87 #include <comphelper/processfactory.hxx>
89 #include "fubullet.hxx"
93 #include "sdslots.hxx"
95 using ::sd::framework::FrameworkHelper
;
96 using ::rtl::OUString
;
100 class CurrentPageSetter
103 CurrentPageSetter (ViewShellBase
& rBase
);
104 void operator () (bool);
106 ViewShellBase
& mrBase
;
109 } // end of anonymous namespace
112 using namespace ::com::sun::star
;
113 using namespace ::com::sun::star::uno
;
114 using namespace ::com::sun::star::drawing::framework
;
115 using ::sd::framework::FrameworkHelper
;
119 class ViewShellBase::Implementation
122 /** Main controller of the view shell. During the switching from one
123 stacked shell to another this pointer may be NULL.
125 ::rtl::Reference
<DrawController
> mpController
;
127 /** The view tab bar is the control for switching between different
130 ::rtl::Reference
<ViewTabBar
> mpViewTabBar
;
132 // contains the complete area of the current view relative to the frame window
133 Rectangle maClientArea
;
135 // This is set to true when PrepareClose() is called.
138 /** The view window is the parent of all UI elements that belong to the
139 view or ViewShell. This comprises the rulers, the scroll bars, and
141 It does not include the ViewTabBar.
143 ::boost::scoped_ptr
< ::Window
> mpViewWindow
;
145 ::boost::shared_ptr
<ToolBarManager
> mpToolBarManager
;
147 ::boost::shared_ptr
<ViewShellManager
> mpViewShellManager
;
149 ::boost::shared_ptr
<tools::EventMultiplexer
> mpEventMultiplexer
;
151 ::boost::shared_ptr
<UpdateLockManager
> mpUpdateLockManager
;
153 /// The print manager is responsible for printing documents.
154 ::boost::shared_ptr
<PrintManager
> mpPrintManager
;
156 ::boost::shared_ptr
<FormShellManager
> mpFormShellManager
;
158 ::boost::shared_ptr
<CustomHandleManager
> mpCustomHandleManager
;
160 Implementation (ViewShellBase
& rBase
);
161 ~Implementation (void);
163 void LateInit (void);
165 /** Show or hide the ViewTabBar.
167 When <TRUE/> then the ViewTabBar is shown, otherwise it is hidden.
169 void ShowViewTabBar (bool bShow
);
171 /** Common code of ViewShellBase::OuterResizePixel() and
172 ViewShellBase::InnerResizePixel().
175 const Point
& rOrigin
,
179 /** Show or hide the specified pane. The visibility state is taken
180 fromthe given request.
182 The request determines the new visibility state. The state can
183 either be toggled or be set to a given value.
185 This URL specifies the pane whose visibility state to set.
187 When the pane becomes visible then this view URL specifies which
188 type of view to show in it.
190 void SetPaneVisibility (
191 const SfxRequest
& rRequest
,
192 const ::rtl::OUString
& rsPaneURL
,
193 const ::rtl::OUString
& rsViewURL
);
195 void GetSlotState (SfxItemSet
& rSet
);
197 void ProcessRestoreEditingViewSlot (void);
198 void ProcessTaskPaneSlot (SfxRequest
& rRequest
);
201 ViewShellBase
& mrBase
;
203 /** Hold a reference to the page cache manager of the slide sorter in
204 order to ensure that it stays alive while the ViewShellBase is
207 ::boost::shared_ptr
<slidesorter::cache::PageCacheManager
> mpPageCacheManager
;
212 /** The only task of this window is to forward key presses to the content
213 window of the main view shell. With the key press it forwards the focus
214 so that it is not called very often.
216 class FocusForwardingWindow
: public ::Window
219 FocusForwardingWindow (::Window
& rParentWindow
, ViewShellBase
& rBase
);
220 virtual ~FocusForwardingWindow (void);
221 virtual void KeyInput (const KeyEvent
& rEvent
);
222 virtual void Command (const CommandEvent
& rEvent
);
225 ViewShellBase
& mrBase
;
227 } // end of anonymous namespace
230 //===== ViewShellBase =========================================================
232 TYPEINIT1(ViewShellBase
, SfxViewShell
);
234 // We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
235 // new ViewShellBase object has been constructed.
238 SFX_IMPL_VIEWFACTORY(ViewShellBase, SdResId(STR_DEFAULTVIEW))
240 SFX_VIEW_REGISTRATION(DrawDocShell);
243 SfxViewFactory
* ViewShellBase::pFactory
;
244 SfxViewShell
* __EXPORT
ViewShellBase::CreateInstance (
245 SfxViewFrame
*pFrame
, SfxViewShell
*pOldView
)
247 ViewShellBase
* pBase
= new ViewShellBase(pFrame
, pOldView
);
248 pBase
->LateInit(OUString());
251 void ViewShellBase::RegisterFactory( USHORT nPrio
)
253 pFactory
= new SfxViewFactory(
254 &CreateInstance
,&InitFactory
,nPrio
,SdResId(STR_DEFAULTVIEW
));
257 void ViewShellBase::InitFactory()
259 SFX_VIEW_REGISTRATION(DrawDocShell
);
264 SFX_IMPL_INTERFACE(ViewShellBase
, SfxViewShell
, SdResId(STR_VIEWSHELLBASE
))
271 ViewShellBase::ViewShellBase (
272 SfxViewFrame
* _pFrame
,
274 : SfxViewShell (_pFrame
,
275 SFX_VIEW_MAXIMIZE_FIRST
276 | SFX_VIEW_OPTIMIZE_EACH
277 | SFX_VIEW_DISABLE_ACCELS
278 | SFX_VIEW_OBJECTSIZE_EMBEDDED
280 | SFX_VIEW_HAS_PRINTOPTIONS
),
286 mpImpl
.reset(new Implementation(*this));
287 mpImpl
->mpViewWindow
.reset(new FocusForwardingWindow(_pFrame
->GetWindow(),*this));
288 mpImpl
->mpViewWindow
->SetBackground(Wallpaper());
289 mpImpl
->mpUpdateLockManager
.reset(new UpdateLockManager(*this));
290 mpImpl
->mpPrintManager
.reset(new PrintManager(*this));
292 _pFrame
->GetWindow().SetBackground(Wallpaper());
294 // Set up the members in the correct order.
295 if (GetViewFrame()->GetObjectShell()->ISA(DrawDocShell
))
296 mpDocShell
= static_cast<DrawDocShell
*>(
297 GetViewFrame()->GetObjectShell());
298 if (mpDocShell
!= NULL
)
299 mpDocument
= mpDocShell
->GetDoc();
300 mpImpl
->mpViewShellManager
.reset(new ViewShellManager(*this));
302 SetWindow(mpImpl
->mpViewWindow
.get());
304 // Hide the window to avoid complaints from Sfx...SwitchViewShell...
305 _pFrame
->GetWindow().Hide();
311 /** In this destructor the order in which some of the members are destroyed
312 (and/or being prepared to being destroyed) is important. Change it only
313 when you know what you are doing.
315 ViewShellBase::~ViewShellBase (void)
317 // Tell the controller that the ViewShellBase is not available anymore.
318 if (mpImpl
->mpController
.get() != NULL
)
319 mpImpl
->mpController
->ReleaseViewShellBase();
321 // We have to hide the main window to prevent SFX complaining after a
322 // reload about it being already visible.
323 ViewShell
* pShell
= GetMainViewShell().get();
325 && pShell
->GetActiveWindow()!=NULL
326 && pShell
->GetActiveWindow()->GetParent()!=NULL
)
328 pShell
->GetActiveWindow()->GetParent()->Hide();
331 mpImpl
->mpUpdateLockManager
->Disable();
332 mpImpl
->mpToolBarManager
->Shutdown();
333 mpImpl
->mpViewShellManager
->Shutdown();
335 EndListening(*GetViewFrame());
336 EndListening(*GetDocShell());
344 void ViewShellBase::LateInit (const ::rtl::OUString
& rsDefaultView
)
346 StartListening(*GetViewFrame(),TRUE
);
347 StartListening(*GetDocShell(),TRUE
);
349 InitializeFramework();
351 mpImpl
->mpEventMultiplexer
.reset(new tools::EventMultiplexer (*this));
353 mpImpl
->mpFormShellManager
.reset(new FormShellManager(*this));
355 mpImpl
->mpToolBarManager
= ToolBarManager::Create(
357 mpImpl
->mpEventMultiplexer
,
358 mpImpl
->mpViewShellManager
);
362 Reference
<XControllerManager
> xControllerManager (GetDrawController(), UNO_QUERY_THROW
);
363 Reference
<XConfigurationController
> xConfigurationController (
364 xControllerManager
->getConfigurationController());
365 if (xConfigurationController
.is())
367 OUString
sView (rsDefaultView
);
368 if (sView
.getLength() == 0)
369 sView
= GetInitialViewShellType();
371 ::boost::shared_ptr
<FrameworkHelper
> pHelper (FrameworkHelper::Instance(*this));
373 // Create the resource ids for the center pane and view.
374 const Reference
<drawing::framework::XResourceId
> xCenterPaneId (
375 pHelper
->CreateResourceId(FrameworkHelper::msCenterPaneURL
));
376 const Reference
<drawing::framework::XResourceId
> xCenterViewId (
377 pHelper
->CreateResourceId(sView
, xCenterPaneId
));
379 // Request center pane and view.
380 xConfigurationController
->requestResourceActivation(xCenterPaneId
, ResourceActivationMode_ADD
);
381 xConfigurationController
->requestResourceActivation(xCenterViewId
, ResourceActivationMode_REPLACE
);
383 // Process configuration events synchronously until the center view
385 sd::framework::ConfigurationController
* pConfigurationController
386 = dynamic_cast<sd::framework::ConfigurationController
*>(xConfigurationController
.get());
387 if (pConfigurationController
!= NULL
)
390 ! pConfigurationController
->getResource(xCenterViewId
).is()
391 && pConfigurationController
->hasPendingRequests())
393 pConfigurationController
->ProcessEvent();
398 catch (RuntimeException
&)
401 // AutoLayouts have to be ready.
402 GetDocument()->StopWorkStartupDelay();
406 // Remember the type of the current main view shell in the frame view.
407 ViewShell
* pViewShell
= GetMainViewShell().get();
408 if (pViewShell
!= NULL
)
410 FrameView
* pFrameView
= pViewShell
->GetFrameView();
411 if (pFrameView
!= NULL
)
412 pFrameView
->SetViewShellTypeOnLoad(pViewShell
->GetShellType());
419 ::boost::shared_ptr
<ViewShellManager
> ViewShellBase::GetViewShellManager (void) const
421 return mpImpl
->mpViewShellManager
;
427 ::boost::shared_ptr
<ViewShell
> ViewShellBase::GetMainViewShell (void) const
429 ::boost::shared_ptr
<ViewShell
> pMainViewShell (
430 framework::FrameworkHelper::Instance(*const_cast<ViewShellBase
*>(this))
431 ->GetViewShell(framework::FrameworkHelper::msCenterPaneURL
));
432 if (pMainViewShell
.get() == NULL
)
433 pMainViewShell
= framework::FrameworkHelper::Instance(*const_cast<ViewShellBase
*>(this))
434 ->GetViewShell(framework::FrameworkHelper::msFullScreenPaneURL
);
435 return pMainViewShell
;
441 ViewShellBase
* ViewShellBase::GetViewShellBase (SfxViewFrame
* pViewFrame
)
443 ViewShellBase
* pBase
= NULL
;
445 if (pViewFrame
!= NULL
)
447 // Get the view shell for the frame and cast it to
448 // sd::ViewShellBase.
449 SfxViewShell
* pSfxViewShell
= pViewFrame
->GetViewShell();
450 if (pSfxViewShell
!=NULL
&& pSfxViewShell
->ISA(::sd::ViewShellBase
))
451 pBase
= static_cast<ViewShellBase
*>(pSfxViewShell
);
460 void ViewShellBase::GetMenuState (SfxItemSet
& )
467 DrawDocShell
* ViewShellBase::GetDocShell (void) const
474 SdDrawDocument
* ViewShellBase::GetDocument (void) const
482 void ViewShellBase::Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
484 SfxViewShell::Notify(rBC
, rHint
);
486 if (rHint
.IsA(TYPE(SfxEventHint
)))
488 switch (static_cast<const SfxEventHint
&>(rHint
).GetEventId())
490 case SFX_EVENT_OPENDOC
:
491 if( GetDocument() && GetDocument()->IsStartWithPresentation() )
495 GetViewFrame()->GetDispatcher()->Execute(
496 SID_PRESENTATION
, SFX_CALLMODE_ASYNCHRON
);
501 // mpPaneManager->InitPanes();
505 case SFX_EVENT_CREATEDOC
:
506 // mpPaneManager->InitPanes();
509 case SFX_EVENT_ACTIVATEDOC
:
512 case SFX_EVENT_STARTAPP
:
513 case SFX_EVENT_CLOSEAPP
:
514 case SFX_EVENT_CLOSEDOC
:
515 case SFX_EVENT_SAVEDOC
:
516 case SFX_EVENT_SAVEASDOC
:
517 case SFX_EVENT_DEACTIVATEDOC
:
518 case SFX_EVENT_PRINTDOC
:
519 case SFX_EVENT_ONERROR
:
520 case SFX_EVENT_LOADFINISHED
:
521 case SFX_EVENT_SAVEFINISHED
:
522 case SFX_EVENT_MODIFYCHANGED
:
523 case SFX_EVENT_PREPARECLOSEDOC
:
524 case SFX_EVENT_NEWMESSAGE
:
525 case SFX_EVENT_TOGGLEFULLSCREENMODE
:
526 case SFX_EVENT_SAVEDOCDONE
:
527 case SFX_EVENT_SAVEASDOCDONE
:
528 case SFX_EVENT_MOUSEOVER_OBJECT
:
529 case SFX_EVENT_MOUSECLICK_OBJECT
:
530 case SFX_EVENT_MOUSEOUT_OBJECT
:
539 void ViewShellBase::InitializeFramework (void)
546 void ViewShellBase::InnerResizePixel (const Point
& rOrigin
, const Size
&rSize
)
548 Size aObjSize
= GetObjectShell()->GetVisArea().GetSize();
549 if ( aObjSize
.Width() > 0 && aObjSize
.Height() > 0 )
551 SvBorder
aBorder( GetBorderPixel() );
553 aSize
.Width() -= (aBorder
.Left() + aBorder
.Right());
554 aSize
.Height() -= (aBorder
.Top() + aBorder
.Bottom());
555 Size aObjSizePixel
= mpImpl
->mpViewWindow
->LogicToPixel( aObjSize
, MAP_100TH_MM
);
556 SfxViewShell::SetZoomFactor(
557 Fraction( aSize
.Width(), std::max( aObjSizePixel
.Width(), (long int)1 ) ),
558 Fraction( aSize
.Height(), std::max( aObjSizePixel
.Height(), (long int)1) ) );
561 mpImpl
->ResizePixel(rOrigin
, rSize
, false);
567 void ViewShellBase::OuterResizePixel (const Point
& rOrigin
, const Size
&rSize
)
569 mpImpl
->ResizePixel (rOrigin
, rSize
, true);
575 void ViewShellBase::Rearrange (void)
577 OSL_ASSERT(GetViewFrame()!=NULL
);
579 // There is a bug in the communication between embedded objects and the
580 // framework::LayoutManager that leads to missing resize updates. The
581 // following workaround enforces such an update by cycling the border to
582 // zero and back to the current value.
583 if (GetWindow() != NULL
)
585 SetBorderPixel(SvBorder());
590 OSL_TRACE("Rearrange: window missing");
593 GetViewFrame()->Resize(TRUE
);
599 ErrCode
ViewShellBase::DoVerb (long nVerb
)
601 ErrCode aResult
= ERRCODE_NONE
;
603 ::sd::ViewShell
* pShell
= GetMainViewShell().get();
605 aResult
= pShell
->DoVerb (nVerb
);
613 SfxPrinter
* ViewShellBase::GetPrinter (BOOL bCreate
)
615 OSL_ASSERT(mpImpl
.get()!=NULL
);
616 OSL_ASSERT(mpImpl
->mpPrintManager
.get()!=NULL
);
618 return mpImpl
->mpPrintManager
->GetPrinter(bCreate
);
624 USHORT
ViewShellBase::SetPrinter (
625 SfxPrinter
* pNewPrinter
,
629 OSL_ASSERT(mpImpl
.get()!=NULL
);
630 OSL_ASSERT(mpImpl
->mpPrintManager
.get()!=NULL
);
632 return mpImpl
->mpPrintManager
->SetPrinter (pNewPrinter
, nDiffFlags
, bIsAPI
);
638 PrintDialog
* ViewShellBase::CreatePrintDialog (::Window
*pParent
)
640 OSL_ASSERT(mpImpl
.get()!=NULL
);
641 OSL_ASSERT(mpImpl
->mpPrintManager
.get()!=NULL
);
643 return mpImpl
->mpPrintManager
->CreatePrintDialog (pParent
);
649 SfxTabPage
* ViewShellBase::CreatePrintOptionsPage(
651 const SfxItemSet
&rOptions
)
653 OSL_ASSERT(mpImpl
.get()!=NULL
);
654 OSL_ASSERT(mpImpl
->mpPrintManager
.get()!=NULL
);
656 return mpImpl
->mpPrintManager
->CreatePrintOptionsPage (pParent
, rOptions
);
662 USHORT
ViewShellBase::Print(SfxProgress
& rProgress
, BOOL bIsAPI
, PrintDialog
* pDlg
)
664 OSL_ASSERT(mpImpl
.get()!=NULL
);
665 OSL_ASSERT(mpImpl
->mpPrintManager
.get()!=NULL
);
667 return mpImpl
->mpPrintManager
->Print (rProgress
, bIsAPI
, pDlg
);
673 ErrCode
ViewShellBase::DoPrint (
674 SfxPrinter
* pPrinter
,
675 PrintDialog
* pPrintDialog
,
676 BOOL bSilent
, BOOL bIsAPI
)
678 OSL_ASSERT(mpImpl
.get()!=NULL
);
679 OSL_ASSERT(mpImpl
->mpPrintManager
.get()!=NULL
);
681 return mpImpl
->mpPrintManager
->DoPrint (pPrinter
, pPrintDialog
, bSilent
, bIsAPI
);
687 USHORT
ViewShellBase::SetPrinterOptDlg (
688 SfxPrinter
* pNewPrinter
,
692 OSL_ASSERT(mpImpl
.get()!=NULL
);
693 OSL_ASSERT(mpImpl
->mpPrintManager
.get()!=NULL
);
695 return mpImpl
->mpPrintManager
->SetPrinterOptDlg (
704 void ViewShellBase::PreparePrint (PrintDialog
* pPrintDialog
)
706 OSL_ASSERT(mpImpl
.get()!=NULL
);
707 OSL_ASSERT(mpImpl
->mpPrintManager
.get()!=NULL
);
709 SfxViewShell::PreparePrint (pPrintDialog
);
710 return mpImpl
->mpPrintManager
->PreparePrint (pPrintDialog
);
716 void ViewShellBase::UIActivating( SfxInPlaceClient
* pClient
)
718 mpImpl
->ShowViewTabBar(false);
720 ViewShell
* pViewShell
= GetMainViewShell().get();
722 pViewShell
->UIActivating( pClient
);
724 SfxViewShell::UIActivating( pClient
);
730 void ViewShellBase::UIDeactivated( SfxInPlaceClient
* pClient
)
732 SfxViewShell::UIDeactivated( pClient
);
734 mpImpl
->ShowViewTabBar(true);
736 ViewShell
* pViewShell
= GetMainViewShell().get();
738 pViewShell
->UIDeactivated( pClient
);
744 SvBorder
ViewShellBase::GetBorder (bool )
747 if (mpImpl
->mpViewTabBar
.is() && mpImpl
->mpViewTabBar
->GetTabControl()->IsVisible())
748 nTop
= mpImpl
->mpViewTabBar
->GetHeight();
749 return SvBorder(0,nTop
,0,0);
755 void ViewShellBase::Execute (SfxRequest
& rRequest
)
757 USHORT nSlotId
= rRequest
.GetSlot();
761 case SID_SWITCH_SHELL
:
763 Reference
<XControllerManager
> xControllerManager (GetController(), UNO_QUERY
);
764 if (xControllerManager
.is())
766 Reference
<XConfigurationController
> xConfigurationController (
767 xControllerManager
->getConfigurationController());
768 if (xConfigurationController
.is())
769 xConfigurationController
->update();
774 case SID_LEFT_PANE_DRAW
:
775 mpImpl
->SetPaneVisibility(
777 framework::FrameworkHelper::msLeftDrawPaneURL
,
778 framework::FrameworkHelper::msSlideSorterURL
);
781 case SID_LEFT_PANE_IMPRESS
:
782 mpImpl
->SetPaneVisibility(
784 framework::FrameworkHelper::msLeftImpressPaneURL
,
785 framework::FrameworkHelper::msSlideSorterURL
);
789 mpImpl
->SetPaneVisibility(
791 framework::FrameworkHelper::msRightPaneURL
,
792 framework::FrameworkHelper::msTaskPaneURL
);
795 case SID_NORMAL_MULTI_PANE_GUI
:
796 case SID_SLIDE_SORTER_MULTI_PANE_GUI
:
797 case SID_DRAWINGMODE
:
799 case SID_OUTLINEMODE
:
801 case SID_HANDOUTMODE
:
802 framework::FrameworkHelper::Instance(*this)->HandleModeChangeSlot(nSlotId
, rRequest
);
805 case SID_WIN_FULLSCREEN
:
806 // The full screen mode is not supported. Ignore the request.
810 mpImpl
->ProcessTaskPaneSlot(rRequest
);
813 case SID_RESTORE_EDITING_VIEW
:
814 mpImpl
->ProcessRestoreEditingViewSlot();
818 // Ignore any other slot.
827 void ViewShellBase::GetState (SfxItemSet
& rSet
)
829 // The full screen mode is not supported. Disable the the slot so that
830 // it appears grayed out when somebody uses configures the menu to show
831 // an menu item for it.
832 // if (rSet.GetItemState(SID_WIN_FULLSCREEN) == SFX_ITEM_AVAILABLE)
833 // rSet.DisableItem(SID_WIN_FULLSCREEN);
835 mpImpl
->GetSlotState(rSet
);
837 FuBullet::GetSlotState( rSet
, 0, GetViewFrame() );
843 void ViewShellBase::WriteUserDataSequence (
844 ::com::sun::star::uno::Sequence
<
845 ::com::sun::star::beans::PropertyValue
>& rSequence
,
848 // Forward call to main sub shell.
849 ViewShell
* pShell
= GetMainViewShell().get();
851 pShell
->WriteUserDataSequence (rSequence
, bBrowse
);
857 void ViewShellBase::ReadUserDataSequence (
858 const ::com::sun::star::uno::Sequence
<
859 ::com::sun::star::beans::PropertyValue
>& rSequence
,
862 // Forward call to main sub shell.
863 ViewShell
* pShell
= GetMainViewShell().get();
866 pShell
->ReadUserDataSequence (rSequence
, bBrowse
);
868 // For certain shell types ReadUserDataSequence may have changed the
869 // type to another one. Make sure that the center pane shows the
871 switch (pShell
->GetShellType())
873 case ViewShell::ST_IMPRESS
:
874 case ViewShell::ST_NOTES
:
875 case ViewShell::ST_HANDOUT
:
877 ::rtl::OUString sViewURL
;
878 switch (PTR_CAST(DrawViewShell
, pShell
)->GetPageKind())
882 sViewURL
= framework::FrameworkHelper::msImpressViewURL
;
885 sViewURL
= framework::FrameworkHelper::msNotesViewURL
;
888 sViewURL
= framework::FrameworkHelper::msHandoutViewURL
;
891 if (sViewURL
.getLength() > 0)
892 framework::FrameworkHelper::Instance(*this)->RequestView(
894 framework::FrameworkHelper::msCenterPaneURL
);
907 void ViewShellBase::Activate (BOOL bIsMDIActivate
)
909 SfxViewShell::Activate(bIsMDIActivate
);
911 Reference
<XControllerManager
> xControllerManager (GetController(), UNO_QUERY
);
912 if (xControllerManager
.is())
914 Reference
<XConfigurationController
> xConfigurationController (
915 xControllerManager
->getConfigurationController());
916 if (xConfigurationController
.is())
917 xConfigurationController
->update();
919 GetToolBarManager()->RequestUpdate();
925 void ViewShellBase::Deactivate (BOOL bIsMDIActivate
)
927 SfxViewShell::Deactivate(bIsMDIActivate
);
933 void ViewShellBase::SetZoomFactor (
934 const Fraction
&rZoomX
,
935 const Fraction
&rZoomY
)
937 SfxViewShell::SetZoomFactor (rZoomX
, rZoomY
);
938 // Forward call to main sub shell.
939 ViewShell
* pShell
= GetMainViewShell().get();
941 pShell
->SetZoomFactor (rZoomX
, rZoomY
);
947 USHORT
ViewShellBase::PrepareClose (BOOL bUI
, BOOL bForBrowsing
)
949 USHORT nResult
= SfxViewShell::PrepareClose (bUI
, bForBrowsing
);
953 mpImpl
->mbIsClosing
= true;
955 // Forward call to main sub shell.
956 ViewShell
* pShell
= GetMainViewShell().get();
958 nResult
= pShell
->PrepareClose (bUI
, bForBrowsing
);
967 void ViewShellBase::WriteUserData (String
& rString
, BOOL bBrowse
)
969 SfxViewShell::WriteUserData (rString
, bBrowse
);
971 // Forward call to main sub shell.
972 ViewShell
* pShell
= GetMainViewShell().get();
974 pShell
->WriteUserData (rString
);
980 void ViewShellBase::ReadUserData (const String
& rString
, BOOL bBrowse
)
982 SfxViewShell::ReadUserData (rString
, bBrowse
);
984 // Forward call to main sub shell.
985 ViewShell
* pShell
= GetMainViewShell().get();
987 pShell
->ReadUserData (rString
);
993 SdrView
* ViewShellBase::GetDrawView (void) const
995 // Forward call to main sub shell.
996 ViewShell
* pShell
= GetMainViewShell().get();
998 return pShell
->GetDrawView ();
1000 return SfxViewShell::GetDrawView();
1006 void ViewShellBase::AdjustPosSizePixel (const Point
&rOfs
, const Size
&rSize
)
1008 SfxViewShell::AdjustPosSizePixel (rOfs
, rSize
);
1014 void ViewShellBase::SetBusyState (bool bBusy
)
1016 if (GetDocShell() != NULL
)
1017 GetDocShell()->SetWaitCursor (bBusy
);
1023 void ViewShellBase::UpdateBorder ( bool bForce
/* = false */ )
1025 // The following calls to SetBorderPixel() and InvalidateBorder() are
1026 // made only for the main view shell. This not only avoids unnecessary
1027 // calls for the views in side panes but prevents calling an already
1028 // dying SfxViewShell base class.
1029 // For issue #140703# we have to check the existence of the window,
1030 // too. The SfxTopViewFrame accesses the window without checking it.
1031 ViewShell
* pMainViewShell
= GetMainViewShell().get();
1032 if (pMainViewShell
!= NULL
&& GetWindow()!=NULL
)
1034 SvBorder
aCurrentBorder (GetBorderPixel());
1035 bool bOuterResize ( ! GetDocShell()->IsInPlaceActive());
1036 SvBorder
aBorder (GetBorder(bOuterResize
));
1037 aBorder
+= pMainViewShell
->GetBorder(bOuterResize
);
1039 if (bForce
|| (aBorder
!= aCurrentBorder
))
1041 SetBorderPixel (aBorder
);
1050 void ViewShellBase::ShowUIControls (bool bVisible
)
1052 if (mpImpl
->mpViewTabBar
.is())
1053 mpImpl
->mpViewTabBar
->GetTabControl()->Show(bVisible
);
1055 ViewShell
* pMainViewShell
= GetMainViewShell().get();
1056 if (pMainViewShell
!= NULL
)
1057 pMainViewShell
->ShowUIControls (bVisible
);
1067 OUString
ViewShellBase::GetInitialViewShellType (void)
1069 OUString
sRequestedView (FrameworkHelper::msImpressViewURL
);
1073 Reference
<document::XViewDataSupplier
> xViewDataSupplier (
1074 GetDocShell()->GetModel(), UNO_QUERY
);
1075 if ( ! xViewDataSupplier
.is())
1078 Reference
<container::XIndexAccess
> xViewData (xViewDataSupplier
->getViewData());
1079 if ( ! xViewData
.is())
1081 if (xViewData
->getCount() == 0)
1084 sal_Int32 nView
= 0;
1085 ::com::sun::star::uno::Any aAny
= xViewData
->getByIndex(nView
);
1086 Sequence
<beans::PropertyValue
> aProperties
;
1087 if ( ! (aAny
>>= aProperties
))
1090 // Search the properties for the one that tells us what page kind to
1092 for (sal_Int32 n
=0; n
<aProperties
.getLength(); n
++)
1094 const beans::PropertyValue
& rProperty (aProperties
[n
]);
1095 if (rProperty
.Name
.compareToAscii(sUNO_View_PageKind
) == COMPARE_EQUAL
)
1097 sal_Int16 nPageKind
= 0;
1098 rProperty
.Value
>>= nPageKind
;
1099 switch ((PageKind
)nPageKind
)
1102 sRequestedView
= FrameworkHelper::msImpressViewURL
;
1106 sRequestedView
= FrameworkHelper::msHandoutViewURL
;
1110 sRequestedView
= FrameworkHelper::msNotesViewURL
;
1114 // The page kind is invalid. This is propably an
1115 // error by the caller. We use the standard type to
1116 // keep things going.
1117 DBG_ASSERT(sal_False
, "ViewShellBase::GetInitialViewShellType: invalid page kind");
1118 sRequestedView
= FrameworkHelper::msImpressViewURL
;
1127 return sRequestedView
;
1133 /** this method starts the presentation by
1134 executing the slot SID_PRESENTATION asynchronous */
1135 void ViewShellBase::StartPresentation()
1137 if( GetViewFrame() && GetViewFrame()->GetDispatcher() )
1138 GetViewFrame()->GetDispatcher()->Execute(SID_PRESENTATION
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
1145 ::boost::shared_ptr
<tools::EventMultiplexer
> ViewShellBase::GetEventMultiplexer (void)
1147 OSL_ASSERT(mpImpl
.get()!=NULL
);
1148 OSL_ASSERT(mpImpl
->mpEventMultiplexer
.get()!=NULL
);
1150 return mpImpl
->mpEventMultiplexer
;
1156 const Rectangle
& ViewShellBase::getClientRectangle (void) const
1158 return mpImpl
->maClientArea
;
1164 ::boost::shared_ptr
<UpdateLockManager
> ViewShellBase::GetUpdateLockManager (void) const
1166 OSL_ASSERT(mpImpl
.get()!=NULL
);
1167 OSL_ASSERT(mpImpl
->mpUpdateLockManager
.get()!=NULL
);
1169 return mpImpl
->mpUpdateLockManager
;
1175 ::boost::shared_ptr
<ToolBarManager
> ViewShellBase::GetToolBarManager (void) const
1177 OSL_ASSERT(mpImpl
.get()!=NULL
);
1178 OSL_ASSERT(mpImpl
->mpToolBarManager
.get()!=NULL
);
1180 return mpImpl
->mpToolBarManager
;
1186 ::boost::shared_ptr
<FormShellManager
> ViewShellBase::GetFormShellManager (void) const
1188 OSL_ASSERT(mpImpl
.get()!=NULL
);
1189 OSL_ASSERT(mpImpl
->mpFormShellManager
.get()!=NULL
);
1191 return mpImpl
->mpFormShellManager
;
1197 DrawController
& ViewShellBase::GetDrawController (void) const
1199 OSL_ASSERT(mpImpl
.get()!=NULL
);
1201 return *mpImpl
->mpController
;
1207 void ViewShellBase::SetViewTabBar (const ::rtl::Reference
<ViewTabBar
>& rViewTabBar
)
1209 OSL_ASSERT(mpImpl
.get()!=NULL
);
1211 mpImpl
->mpViewTabBar
= rViewTabBar
;
1217 ::Window
* ViewShellBase::GetViewWindow (void)
1219 OSL_ASSERT(mpImpl
.get()!=NULL
);
1221 return mpImpl
->mpViewWindow
.get();
1227 CustomHandleManager
& ViewShellBase::getCustomHandleManager() const
1229 OSL_ASSERT(mpImpl
.get()!=NULL
);
1231 if( !mpImpl
->mpCustomHandleManager
.get() )
1232 mpImpl
->mpCustomHandleManager
.reset( new ::sd::CustomHandleManager(*const_cast< ViewShellBase
* >(this)) );
1234 return *mpImpl
->mpCustomHandleManager
.get();
1239 //===== ViewShellBase::Implementation =========================================
1241 ViewShellBase::Implementation::Implementation (ViewShellBase
& rBase
)
1248 mpViewShellManager(),
1249 mpEventMultiplexer(),
1250 mpUpdateLockManager(),
1252 mpFormShellManager(),
1254 mpPageCacheManager(slidesorter::cache::PageCacheManager::Instance())
1261 ViewShellBase::Implementation::~Implementation (void)
1263 mpController
= NULL
;
1264 mpViewTabBar
= NULL
;
1265 mpViewWindow
.reset();
1266 mpToolBarManager
.reset();
1272 void ViewShellBase::Implementation::LateInit (void)
1274 mpController
= new DrawController(mrBase
);
1280 void ViewShellBase::Implementation::ProcessRestoreEditingViewSlot (void)
1282 ViewShell
* pViewShell
= mrBase
.GetMainViewShell().get();
1283 if (pViewShell
!= NULL
)
1285 FrameView
* pFrameView
= pViewShell
->GetFrameView();
1286 if (pFrameView
!= NULL
)
1288 // Set view shell, edit mode, and page kind.
1289 pFrameView
->SetViewShEditMode(
1290 pFrameView
->GetViewShEditModeOnLoad(),
1291 pFrameView
->GetPageKindOnLoad());
1292 pFrameView
->SetPageKind(
1293 pFrameView
->GetPageKindOnLoad());
1294 ::boost::shared_ptr
<FrameworkHelper
> pHelper (FrameworkHelper::Instance(mrBase
));
1295 pHelper
->RequestView(
1296 pHelper
->GetViewURL(pFrameView
->GetViewShellTypeOnLoad()),
1297 FrameworkHelper::msCenterPaneURL
);
1298 pHelper
->RunOnConfigurationEvent(
1299 ::rtl::OUString::createFromAscii("ConfigurationUpdateEnd"),
1300 CurrentPageSetter(mrBase
));
1308 void ViewShellBase::Implementation::ShowViewTabBar (bool bShow
)
1310 if (mpViewTabBar
.is()
1311 && (mpViewTabBar
->GetTabControl()->IsVisible()==TRUE
) != bShow
)
1313 mpViewTabBar
->GetTabControl()->Show(bShow
? TRUE
: FALSE
);
1321 void ViewShellBase::Implementation::ResizePixel (
1322 const Point
& rOrigin
,
1329 // Forward the call to both the base class and the main stacked sub
1330 // shell only when main sub shell exists.
1331 ViewShell
* pMainViewShell
= mrBase
.GetMainViewShell().get();
1333 // Set the ViewTabBar temporarily to full size so that, when asked
1334 // later, it can return its true height.
1335 mrBase
.SetWindow (mpViewWindow
.get());
1336 if (mpViewTabBar
.is() && mpViewTabBar
->GetTabControl()->IsVisible())
1337 mpViewTabBar
->GetTabControl()->SetPosSizePixel (rOrigin
, rSize
);
1339 // Calculate and set the border before the controls are placed.
1341 if (pMainViewShell
!= NULL
)
1342 aBorder
= pMainViewShell
->GetBorder(bOuterResize
);
1343 aBorder
+= mrBase
.GetBorder(bOuterResize
);
1344 if (mrBase
.GetBorderPixel() != aBorder
)
1345 mrBase
.SetBorderPixel(aBorder
);
1347 // Place the ViewTabBar at the top. It is part of the border.
1348 SvBorder aBaseBorder
;
1349 if (mpViewTabBar
.is() && mpViewTabBar
->GetTabControl()->IsVisible())
1351 aBaseBorder
.Top() = mpViewTabBar
->GetHeight();
1352 mpViewTabBar
->GetTabControl()->SetPosSizePixel(
1353 rOrigin
, Size(rSize
.Width(),aBaseBorder
.Top()));
1356 // The view window gets the remaining space.
1357 Point
aViewWindowPosition (
1358 rOrigin
.X()+aBaseBorder
.Left(),
1359 rOrigin
.Y()+aBaseBorder
.Top());
1360 Size
aViewWindowSize (
1361 rSize
.Width() - aBaseBorder
.Left() - aBaseBorder
.Right(),
1362 rSize
.Height() - aBaseBorder
.Top() - aBaseBorder
.Bottom());
1363 mpViewWindow
->SetPosSizePixel(aViewWindowPosition
, aViewWindowSize
);
1365 maClientArea
= Rectangle(Point(0,0), aViewWindowSize
);
1371 void ViewShellBase::Implementation::SetPaneVisibility (
1372 const SfxRequest
& rRequest
,
1373 const ::rtl::OUString
& rsPaneURL
,
1374 const ::rtl::OUString
& rsViewURL
)
1378 Reference
<XControllerManager
> xControllerManager (mrBase
.GetController(), UNO_QUERY_THROW
);
1380 Reference
<XResourceId
> xPaneId (ResourceId::create(
1381 comphelper_getProcessComponentContext(), rsPaneURL
));
1382 Reference
<XResourceId
> xViewId (ResourceId::createWithAnchorURL(
1383 comphelper_getProcessComponentContext(), rsViewURL
, rsPaneURL
));
1385 // Determine the new visibility state.
1386 const SfxItemSet
* pArguments
= rRequest
.GetArgs();
1387 BOOL bShowChildWindow
;
1388 USHORT nSlotId
= rRequest
.GetSlot();
1389 if (pArguments
!= NULL
)
1390 bShowChildWindow
= static_cast<const SfxBoolItem
&>(
1391 pArguments
->Get(nSlotId
)).GetValue();
1394 Reference
<XConfigurationController
> xConfigurationController (
1395 xControllerManager
->getConfigurationController());
1396 if ( ! xConfigurationController
.is())
1397 throw RuntimeException();
1398 Reference
<XConfiguration
> xConfiguration (
1399 xConfigurationController
->getRequestedConfiguration());
1400 if ( ! xConfiguration
.is())
1401 throw RuntimeException();
1403 bShowChildWindow
= ! xConfiguration
->hasResource(xPaneId
);
1406 // Set the desired visibility state at the current configuration
1407 // and update it accordingly.
1408 Reference
<XConfigurationController
> xConfigurationController (
1409 xControllerManager
->getConfigurationController());
1410 if ( ! xConfigurationController
.is())
1411 throw RuntimeException();
1412 if (bShowChildWindow
)
1414 xConfigurationController
->requestResourceActivation(
1416 ResourceActivationMode_ADD
);
1417 xConfigurationController
->requestResourceActivation(
1419 ResourceActivationMode_REPLACE
);
1422 xConfigurationController
->requestResourceDeactivation(
1425 catch (RuntimeException
&)
1427 DBG_ASSERT(false, "ViewShellBase::Implementation::SetPaneVisibility(): caught exception");
1435 void ViewShellBase::Implementation::GetSlotState (SfxItemSet
& rSet
)
1439 // Get some frequently used values.
1440 Reference
<XControllerManager
> xControllerManager (mrBase
.GetController(), UNO_QUERY_THROW
);
1441 Reference
<XConfigurationController
> xConfigurationController (
1442 xControllerManager
->getConfigurationController());
1443 if ( ! xConfigurationController
.is())
1444 throw RuntimeException();
1445 Reference
<XConfiguration
> xConfiguration (
1446 xConfigurationController
->getRequestedConfiguration());
1447 if ( ! xConfiguration
.is())
1448 throw RuntimeException();
1450 SfxWhichIter
aSetIterator (rSet
);
1451 sal_uInt16
nItemId (aSetIterator
.FirstWhich());
1454 bool bState (false);
1455 Reference
<XResourceId
> xResourceId
;
1460 case SID_LEFT_PANE_IMPRESS
:
1461 xResourceId
= ResourceId::create(
1462 comphelper_getProcessComponentContext(),
1463 FrameworkHelper::msLeftImpressPaneURL
);
1466 case SID_LEFT_PANE_DRAW
:
1467 xResourceId
= ResourceId::create(
1468 comphelper_getProcessComponentContext(),
1469 FrameworkHelper::msLeftDrawPaneURL
);
1472 case SID_RIGHT_PANE
:
1473 xResourceId
= ResourceId::create(
1474 comphelper_getProcessComponentContext(),
1475 FrameworkHelper::msRightPaneURL
);
1478 case SID_NORMAL_MULTI_PANE_GUI
:
1479 xResourceId
= ResourceId::createWithAnchorURL(
1480 comphelper_getProcessComponentContext(),
1481 FrameworkHelper::msImpressViewURL
,
1482 FrameworkHelper::msCenterPaneURL
);
1485 case SID_SLIDE_SORTER_MULTI_PANE_GUI
:
1487 xResourceId
= ResourceId::createWithAnchorURL(
1488 comphelper_getProcessComponentContext(),
1489 FrameworkHelper::msSlideSorterURL
,
1490 FrameworkHelper::msCenterPaneURL
);
1493 case SID_OUTLINEMODE
:
1494 xResourceId
= ResourceId::createWithAnchorURL(
1495 comphelper_getProcessComponentContext(),
1496 FrameworkHelper::msOutlineViewURL
,
1497 FrameworkHelper::msCenterPaneURL
);
1500 case SID_HANDOUTMODE
:
1501 // There is only the master page mode for the handout
1502 // view so ignore the master page flag.
1503 xResourceId
= ResourceId::createWithAnchorURL(
1504 comphelper_getProcessComponentContext(),
1505 FrameworkHelper::msHandoutViewURL
,
1506 FrameworkHelper::msCenterPaneURL
);
1510 xResourceId
= ResourceId::createWithAnchorURL(
1511 comphelper_getProcessComponentContext(),
1512 FrameworkHelper::msNotesViewURL
,
1513 FrameworkHelper::msCenterPaneURL
);
1517 // Ignore all other items. They are not meant to be
1522 catch (DeploymentException
)
1526 // Determine the state for the resource.
1527 bState
= xConfiguration
->hasResource(xResourceId
);
1529 // Take the master page mode into account.
1532 case SID_NORMAL_MULTI_PANE_GUI
:
1535 // Determine the master page mode.
1536 ViewShell
* pCenterViewShell
= FrameworkHelper::Instance(mrBase
)->GetViewShell(
1537 FrameworkHelper::msCenterPaneURL
).get();
1538 bool bMasterPageMode (false);
1539 if (pCenterViewShell
!=NULL
&& pCenterViewShell
->ISA(DrawViewShell
))
1540 if (PTR_CAST(DrawViewShell
,pCenterViewShell
)->GetEditMode()
1543 bMasterPageMode
= true;
1546 bState
&= !bMasterPageMode
;
1550 case SID_HANDOUTMODE
:
1551 // There is only the master page mode for the handout
1552 // view so ignore the master page flag.
1556 // And finally set the state.
1557 rSet
.Put(SfxBoolItem(nItemId
, bState
));
1559 nItemId
= aSetIterator
.NextWhich();
1562 catch (RuntimeException
&)
1564 DBG_ASSERT(false, "ViewShellBase::Implementation::GetSlotState(): caught exception");
1572 void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest
& rRequest
)
1574 // Set the visibility state of the toolpanel and one of its top
1576 BOOL bShowToolPanel
= TRUE
;
1577 toolpanel::TaskPaneViewShell::PanelId
nPanelId (
1578 toolpanel::TaskPaneViewShell::PID_UNKNOWN
);
1579 bool bPanelIdGiven
= false;
1581 // Extract the given arguments.
1582 const SfxItemSet
* pArgs
= rRequest
.GetArgs();
1585 if ((pArgs
->Count() == 1) || (pArgs
->Count() == 2))
1587 SFX_REQUEST_ARG (rRequest
, pIsPanelVisible
,
1588 SfxBoolItem
, ID_VAL_ISVISIBLE
, FALSE
);
1589 if (pIsPanelVisible
!= NULL
)
1590 bShowToolPanel
= pIsPanelVisible
->GetValue();
1592 if (pArgs
->Count() == 2)
1594 SFX_REQUEST_ARG (rRequest
, pPanelId
, SfxUInt32Item
,
1595 ID_VAL_PANEL_INDEX
, FALSE
);
1596 if (pPanelId
!= NULL
)
1598 nPanelId
= static_cast<
1599 toolpanel::TaskPaneViewShell::PanelId
>(
1600 pPanelId
->GetValue());
1601 bPanelIdGiven
= true;
1606 // Ignore the request for some combinations of panels and view
1609 && ! (nPanelId
==toolpanel::TaskPaneViewShell::PID_LAYOUT
1610 && mrBase
.GetMainViewShell()!=NULL
1611 && mrBase
.GetMainViewShell()->GetShellType()==ViewShell::ST_OUTLINE
))
1613 framework::FrameworkHelper::Instance(mrBase
)->RequestTaskPanel(
1614 framework::FrameworkHelper::msLayoutTaskPanelURL
);
1619 } // end of namespace sd
1624 //===== CurrentPageSetter ===========================================
1628 CurrentPageSetter::CurrentPageSetter (ViewShellBase
& rBase
)
1637 void CurrentPageSetter::operator() (bool)
1639 FrameView
* pFrameView
= NULL
;
1641 if (mrBase
.GetMainViewShell() != NULL
)
1643 pFrameView
= mrBase
.GetMainViewShell()->GetFrameView();
1646 if (pFrameView
!=NULL
)
1650 // Get the current page either from the DrawPagesSupplier or the
1651 // MasterPagesSupplier.
1653 if (pFrameView
->GetViewShEditModeOnLoad() == EM_PAGE
)
1655 Reference
<drawing::XDrawPagesSupplier
> xPagesSupplier (
1656 mrBase
.GetController()->getModel(), UNO_QUERY_THROW
);
1657 Reference
<container::XIndexAccess
> xPages (
1658 xPagesSupplier
->getDrawPages(), UNO_QUERY_THROW
);
1659 aPage
= xPages
->getByIndex(pFrameView
->GetSelectedPageOnLoad());
1663 Reference
<drawing::XMasterPagesSupplier
> xPagesSupplier (
1664 mrBase
.GetController()->getModel(), UNO_QUERY_THROW
);
1665 Reference
<container::XIndexAccess
> xPages (
1666 xPagesSupplier
->getMasterPages(), UNO_QUERY_THROW
);
1667 aPage
= xPages
->getByIndex(pFrameView
->GetSelectedPageOnLoad());
1669 // Switch to the page last edited by setting the CurrentPage
1671 Reference
<beans::XPropertySet
> xSet (mrBase
.GetController(), UNO_QUERY_THROW
);
1672 xSet
->setPropertyValue (String::CreateFromAscii("CurrentPage"), aPage
);
1674 catch (RuntimeException aException
)
1676 // We have not been able to set the current page at the main view.
1677 // This is sad but still leaves us in a valid state. Therefore,
1678 // this exception is silently ignored.
1680 catch (beans::UnknownPropertyException aException
)
1682 DBG_ASSERT(false,"CurrentPage property unknown");
1687 } // end of anonymouse namespace
1692 //===== FocusForwardingWindow =================================================
1694 namespace sd
{ namespace {
1696 FocusForwardingWindow::FocusForwardingWindow (
1697 ::Window
& rParentWindow
,
1698 ViewShellBase
& rBase
)
1699 : ::Window(&rParentWindow
, WinBits(WB_CLIPCHILDREN
| WB_DIALOGCONTROL
)),
1702 OSL_TRACE("created FocusForwardingWindow at %x", this);
1708 FocusForwardingWindow::~FocusForwardingWindow (void)
1710 OSL_TRACE("destroyed FocusForwardingWindow at %x", this);
1716 void FocusForwardingWindow::KeyInput (const KeyEvent
& rKEvt
)
1718 ::boost::shared_ptr
<ViewShell
> pViewShell
= mrBase
.GetMainViewShell();
1719 if (pViewShell
.get() != NULL
)
1721 ::Window
* pWindow
= pViewShell
->GetActiveWindow();
1722 if (pWindow
!= NULL
)
1724 // Forward the focus so that the window is called directly the
1726 pWindow
->GrabFocus();
1727 // Forward the key press as well.
1728 pWindow
->KeyInput(rKEvt
);
1736 void FocusForwardingWindow::Command (const CommandEvent
& rEvent
)
1738 ::boost::shared_ptr
<ViewShell
> pViewShell
= mrBase
.GetMainViewShell();
1739 if (pViewShell
.get() != NULL
)
1741 ::Window
* pWindow
= pViewShell
->GetActiveWindow();
1742 if (pWindow
!= NULL
)
1744 pWindow
->Command(rEvent
);
1750 } // end of anonymouse namespace
1752 // ====================================================================
1754 CustomHandleManager::CustomHandleManager( ViewShellBase
& rViewShellBase
)
1755 : mrViewShellBase( rViewShellBase
)
1759 CustomHandleManager::~CustomHandleManager()
1761 DBG_ASSERT( maSupplier
.empty(), "sd::CustomHandleManager::~CustomHandleManager(), still suppliers attached!" );
1764 void CustomHandleManager::registerSupplier( ICustomhandleSupplier
* pSupplier
)
1766 maSupplier
.insert( pSupplier
);
1769 void CustomHandleManager::unRegisterSupplier( ICustomhandleSupplier
* pSupplier
)
1771 maSupplier
.erase( pSupplier
);
1774 void CustomHandleManager::addCustomHandler( SdrView
& rSourceView
, ViewShell::ShellType eShellType
, SdrHdlList
& rHandlerList
)
1776 for( std::set
< ICustomhandleSupplier
* >::iterator
aIter( maSupplier
.begin() ); aIter
!= maSupplier
.end(); aIter
++ )
1778 (*aIter
)->addCustomHandler( rSourceView
, eShellType
, rHandlerList
);
1782 } // end of namespace sd