merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / view / ViewShellBase.cxx
blob0624e8f065d0bd401cc9ea9e11c8748605b1df48
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 $
10 * $Revision: 1.45 $
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"
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 "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"
66 #include "Window.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"
91 using namespace sd;
92 #define ViewShellBase
93 #include "sdslots.hxx"
95 using ::sd::framework::FrameworkHelper;
96 using ::rtl::OUString;
98 namespace {
100 class CurrentPageSetter
102 public:
103 CurrentPageSetter (ViewShellBase& rBase);
104 void operator () (bool);
105 private:
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;
117 namespace sd {
119 class ViewShellBase::Implementation
121 public:
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
128 views in one pane.
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.
136 bool mbIsClosing;
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
140 the content window.
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.
166 @param bShow
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().
174 void ResizePixel (
175 const Point& rOrigin,
176 const Size& rSize,
177 bool bOuterResize);
179 /** Show or hide the specified pane. The visibility state is taken
180 fromthe given request.
181 @param rRequest
182 The request determines the new visibility state. The state can
183 either be toggled or be set to a given value.
184 @param rsPaneURL
185 This URL specifies the pane whose visibility state to set.
186 @param rsViewURL
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);
200 private:
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
205 alive.
207 ::boost::shared_ptr<slidesorter::cache::PageCacheManager> mpPageCacheManager;
211 namespace {
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
218 public:
219 FocusForwardingWindow (::Window& rParentWindow, ViewShellBase& rBase);
220 virtual ~FocusForwardingWindow (void);
221 virtual void KeyInput (const KeyEvent& rEvent);
222 virtual void Command (const CommandEvent& rEvent);
224 private:
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());
249 return pBase;
251 void ViewShellBase::RegisterFactory( USHORT nPrio )
253 pFactory = new SfxViewFactory(
254 &CreateInstance,&InitFactory,nPrio,SdResId(STR_DEFAULTVIEW));
255 InitFactory();
257 void ViewShellBase::InitFactory()
259 SFX_VIEW_REGISTRATION(DrawDocShell);
264 SFX_IMPL_INTERFACE(ViewShellBase, SfxViewShell, SdResId(STR_VIEWSHELLBASE))
271 ViewShellBase::ViewShellBase (
272 SfxViewFrame* _pFrame,
273 SfxViewShell*)
274 : SfxViewShell (_pFrame,
275 SFX_VIEW_MAXIMIZE_FIRST
276 | SFX_VIEW_OPTIMIZE_EACH
277 | SFX_VIEW_DISABLE_ACCELS
278 | SFX_VIEW_OBJECTSIZE_EMBEDDED
279 | SFX_VIEW_CAN_PRINT
280 | SFX_VIEW_HAS_PRINTOPTIONS),
281 maMutex(),
282 mpImpl(),
283 mpDocShell (NULL),
284 mpDocument (NULL)
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();
324 if (pShell!=NULL
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());
338 SetWindow(NULL);
344 void ViewShellBase::LateInit (const ::rtl::OUString& rsDefaultView)
346 StartListening(*GetViewFrame(),TRUE);
347 StartListening(*GetDocShell(),TRUE);
348 mpImpl->LateInit();
349 InitializeFramework();
351 mpImpl->mpEventMultiplexer.reset(new tools::EventMultiplexer (*this));
353 mpImpl->mpFormShellManager.reset(new FormShellManager(*this));
355 mpImpl->mpToolBarManager = ToolBarManager::Create(
356 *this,
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
384 // has been created.
385 sd::framework::ConfigurationController* pConfigurationController
386 = dynamic_cast<sd::framework::ConfigurationController*>(xConfigurationController.get());
387 if (pConfigurationController != NULL)
389 while (
390 ! pConfigurationController->getResource(xCenterViewId).is()
391 && pConfigurationController->hasPendingRequests())
393 pConfigurationController->ProcessEvent();
398 catch (RuntimeException&)
401 // AutoLayouts have to be ready.
402 GetDocument()->StopWorkStartupDelay();
404 UpdateBorder();
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);
454 return pBase;
460 void ViewShellBase::GetMenuState (SfxItemSet& )
467 DrawDocShell* ViewShellBase::GetDocShell (void) const
469 return mpDocShell;
474 SdDrawDocument* ViewShellBase::GetDocument (void) const
476 return mpDocument;
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() )
493 if( GetViewFrame() )
495 GetViewFrame()->GetDispatcher()->Execute(
496 SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON );
499 else
501 // mpPaneManager->InitPanes();
503 break;
505 default:
506 break;
514 void ViewShellBase::InitializeFramework (void)
521 void ViewShellBase::InnerResizePixel (const Point& rOrigin, const Size &rSize)
523 Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
524 if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
526 SvBorder aBorder( GetBorderPixel() );
527 Size aSize( rSize );
528 aSize.Width() -= (aBorder.Left() + aBorder.Right());
529 aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
530 Size aObjSizePixel = mpImpl->mpViewWindow->LogicToPixel( aObjSize, MAP_100TH_MM );
531 SfxViewShell::SetZoomFactor(
532 Fraction( aSize.Width(), std::max( aObjSizePixel.Width(), (long int)1 ) ),
533 Fraction( aSize.Height(), std::max( aObjSizePixel.Height(), (long int)1) ) );
536 mpImpl->ResizePixel(rOrigin, rSize, false);
542 void ViewShellBase::OuterResizePixel (const Point& rOrigin, const Size &rSize)
544 mpImpl->ResizePixel (rOrigin, rSize, true);
550 void ViewShellBase::Rearrange (void)
552 OSL_ASSERT(GetViewFrame()!=NULL);
554 // There is a bug in the communication between embedded objects and the
555 // framework::LayoutManager that leads to missing resize updates. The
556 // following workaround enforces such an update by cycling the border to
557 // zero and back to the current value.
558 if (GetWindow() != NULL)
560 SetBorderPixel(SvBorder());
561 UpdateBorder(true);
563 else
565 OSL_TRACE("Rearrange: window missing");
568 GetViewFrame()->Resize(TRUE);
574 ErrCode ViewShellBase::DoVerb (long nVerb)
576 ErrCode aResult = ERRCODE_NONE;
578 ::sd::ViewShell* pShell = GetMainViewShell().get();
579 if (pShell != NULL)
580 aResult = pShell->DoVerb (nVerb);
582 return aResult;
588 SfxPrinter* ViewShellBase::GetPrinter (BOOL bCreate)
590 OSL_ASSERT(mpImpl.get()!=NULL);
591 OSL_ASSERT(mpImpl->mpPrintManager.get()!=NULL);
593 return mpImpl->mpPrintManager->GetPrinter(bCreate);
599 USHORT ViewShellBase::SetPrinter (
600 SfxPrinter* pNewPrinter,
601 USHORT nDiffFlags,
602 bool bIsAPI)
604 OSL_ASSERT(mpImpl.get()!=NULL);
605 OSL_ASSERT(mpImpl->mpPrintManager.get()!=NULL);
607 return mpImpl->mpPrintManager->SetPrinter (pNewPrinter, nDiffFlags, bIsAPI);
613 PrintDialog* ViewShellBase::CreatePrintDialog (::Window *pParent)
615 OSL_ASSERT(mpImpl.get()!=NULL);
616 OSL_ASSERT(mpImpl->mpPrintManager.get()!=NULL);
618 return mpImpl->mpPrintManager->CreatePrintDialog (pParent);
624 SfxTabPage* ViewShellBase::CreatePrintOptionsPage(
625 ::Window *pParent,
626 const SfxItemSet &rOptions)
628 OSL_ASSERT(mpImpl.get()!=NULL);
629 OSL_ASSERT(mpImpl->mpPrintManager.get()!=NULL);
631 return mpImpl->mpPrintManager->CreatePrintOptionsPage (pParent, rOptions);
637 USHORT ViewShellBase::Print(SfxProgress& rProgress, BOOL bIsAPI, PrintDialog* pDlg)
639 OSL_ASSERT(mpImpl.get()!=NULL);
640 OSL_ASSERT(mpImpl->mpPrintManager.get()!=NULL);
642 return mpImpl->mpPrintManager->Print (rProgress, bIsAPI, pDlg);
648 ErrCode ViewShellBase::DoPrint (
649 SfxPrinter* pPrinter,
650 PrintDialog* pPrintDialog,
651 BOOL bSilent, BOOL bIsAPI )
653 OSL_ASSERT(mpImpl.get()!=NULL);
654 OSL_ASSERT(mpImpl->mpPrintManager.get()!=NULL);
656 return mpImpl->mpPrintManager->DoPrint (pPrinter, pPrintDialog, bSilent, bIsAPI );
662 USHORT ViewShellBase::SetPrinterOptDlg (
663 SfxPrinter* pNewPrinter,
664 USHORT nDiffFlags,
665 BOOL bShowDialog)
667 OSL_ASSERT(mpImpl.get()!=NULL);
668 OSL_ASSERT(mpImpl->mpPrintManager.get()!=NULL);
670 return mpImpl->mpPrintManager->SetPrinterOptDlg (
671 pNewPrinter,
672 nDiffFlags,
673 bShowDialog);
679 void ViewShellBase::PreparePrint (PrintDialog* pPrintDialog)
681 OSL_ASSERT(mpImpl.get()!=NULL);
682 OSL_ASSERT(mpImpl->mpPrintManager.get()!=NULL);
684 SfxViewShell::PreparePrint (pPrintDialog);
685 return mpImpl->mpPrintManager->PreparePrint (pPrintDialog);
691 void ViewShellBase::UIActivating( SfxInPlaceClient* pClient )
693 mpImpl->ShowViewTabBar(false);
695 ViewShell* pViewShell = GetMainViewShell().get();
696 if ( pViewShell )
697 pViewShell->UIActivating( pClient );
699 SfxViewShell::UIActivating( pClient );
705 void ViewShellBase::UIDeactivated( SfxInPlaceClient* pClient )
707 SfxViewShell::UIDeactivated( pClient );
709 mpImpl->ShowViewTabBar(true);
711 ViewShell* pViewShell = GetMainViewShell().get();
712 if ( pViewShell )
713 pViewShell->UIDeactivated( pClient );
719 SvBorder ViewShellBase::GetBorder (bool )
721 int nTop = 0;
722 if (mpImpl->mpViewTabBar.is() && mpImpl->mpViewTabBar->GetTabControl()->IsVisible())
723 nTop = mpImpl->mpViewTabBar->GetHeight();
724 return SvBorder(0,nTop,0,0);
730 void ViewShellBase::Execute (SfxRequest& rRequest)
732 USHORT nSlotId = rRequest.GetSlot();
734 switch (nSlotId)
736 case SID_SWITCH_SHELL:
738 Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
739 if (xControllerManager.is())
741 Reference<XConfigurationController> xConfigurationController (
742 xControllerManager->getConfigurationController());
743 if (xConfigurationController.is())
744 xConfigurationController->update();
747 break;
749 case SID_LEFT_PANE_DRAW:
750 mpImpl->SetPaneVisibility(
751 rRequest,
752 framework::FrameworkHelper::msLeftDrawPaneURL,
753 framework::FrameworkHelper::msSlideSorterURL);
754 break;
756 case SID_LEFT_PANE_IMPRESS:
757 mpImpl->SetPaneVisibility(
758 rRequest,
759 framework::FrameworkHelper::msLeftImpressPaneURL,
760 framework::FrameworkHelper::msSlideSorterURL);
761 break;
763 case SID_RIGHT_PANE:
764 mpImpl->SetPaneVisibility(
765 rRequest,
766 framework::FrameworkHelper::msRightPaneURL,
767 framework::FrameworkHelper::msTaskPaneURL);
768 break;
770 case SID_NORMAL_MULTI_PANE_GUI:
771 case SID_SLIDE_SORTER_MULTI_PANE_GUI:
772 case SID_DRAWINGMODE:
773 case SID_DIAMODE:
774 case SID_OUTLINEMODE:
775 case SID_NOTESMODE:
776 case SID_HANDOUTMODE:
777 framework::FrameworkHelper::Instance(*this)->HandleModeChangeSlot(nSlotId, rRequest);
778 break;
780 case SID_WIN_FULLSCREEN:
781 // The full screen mode is not supported. Ignore the request.
782 break;
784 case SID_TASK_PANE:
785 mpImpl->ProcessTaskPaneSlot(rRequest);
786 break;
788 case SID_RESTORE_EDITING_VIEW:
789 mpImpl->ProcessRestoreEditingViewSlot();
790 break;
792 default:
793 // Ignore any other slot.
794 rRequest.Ignore ();
795 break;
802 void ViewShellBase::GetState (SfxItemSet& rSet)
804 // The full screen mode is not supported. Disable the the slot so that
805 // it appears grayed out when somebody uses configures the menu to show
806 // an menu item for it.
807 // if (rSet.GetItemState(SID_WIN_FULLSCREEN) == SFX_ITEM_AVAILABLE)
808 // rSet.DisableItem(SID_WIN_FULLSCREEN);
810 mpImpl->GetSlotState(rSet);
812 FuBullet::GetSlotState( rSet, 0, GetViewFrame() );
818 void ViewShellBase::WriteUserDataSequence (
819 ::com::sun::star::uno::Sequence <
820 ::com::sun::star::beans::PropertyValue >& rSequence,
821 sal_Bool bBrowse)
823 // Forward call to main sub shell.
824 ViewShell* pShell = GetMainViewShell().get();
825 if (pShell != NULL)
826 pShell->WriteUserDataSequence (rSequence, bBrowse);
832 void ViewShellBase::ReadUserDataSequence (
833 const ::com::sun::star::uno::Sequence <
834 ::com::sun::star::beans::PropertyValue >& rSequence,
835 sal_Bool bBrowse)
837 // Forward call to main sub shell.
838 ViewShell* pShell = GetMainViewShell().get();
839 if (pShell != NULL)
841 pShell->ReadUserDataSequence (rSequence, bBrowse);
843 // For certain shell types ReadUserDataSequence may have changed the
844 // type to another one. Make sure that the center pane shows the
845 // right view shell.
846 switch (pShell->GetShellType())
848 case ViewShell::ST_IMPRESS:
849 case ViewShell::ST_NOTES:
850 case ViewShell::ST_HANDOUT:
852 ::rtl::OUString sViewURL;
853 switch (PTR_CAST(DrawViewShell, pShell)->GetPageKind())
855 default:
856 case PK_STANDARD:
857 sViewURL = framework::FrameworkHelper::msImpressViewURL;
858 break;
859 case PK_NOTES:
860 sViewURL = framework::FrameworkHelper::msNotesViewURL;
861 break;
862 case PK_HANDOUT:
863 sViewURL = framework::FrameworkHelper::msHandoutViewURL;
864 break;
866 if (sViewURL.getLength() > 0)
867 framework::FrameworkHelper::Instance(*this)->RequestView(
868 sViewURL,
869 framework::FrameworkHelper::msCenterPaneURL);
871 break;
873 default:
874 break;
882 void ViewShellBase::Activate (BOOL bIsMDIActivate)
884 SfxViewShell::Activate(bIsMDIActivate);
886 Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
887 if (xControllerManager.is())
889 Reference<XConfigurationController> xConfigurationController (
890 xControllerManager->getConfigurationController());
891 if (xConfigurationController.is())
892 xConfigurationController->update();
894 GetToolBarManager()->RequestUpdate();
900 void ViewShellBase::Deactivate (BOOL bIsMDIActivate)
902 SfxViewShell::Deactivate(bIsMDIActivate);
908 void ViewShellBase::SetZoomFactor (
909 const Fraction &rZoomX,
910 const Fraction &rZoomY)
912 SfxViewShell::SetZoomFactor (rZoomX, rZoomY);
913 // Forward call to main sub shell.
914 ViewShell* pShell = GetMainViewShell().get();
915 if (pShell != NULL)
916 pShell->SetZoomFactor (rZoomX, rZoomY);
922 USHORT ViewShellBase::PrepareClose (BOOL bUI, BOOL bForBrowsing)
924 USHORT nResult = SfxViewShell::PrepareClose (bUI, bForBrowsing);
926 if (nResult == TRUE)
928 mpImpl->mbIsClosing = true;
930 // Forward call to main sub shell.
931 ViewShell* pShell = GetMainViewShell().get();
932 if (pShell != NULL)
933 nResult = pShell->PrepareClose (bUI, bForBrowsing);
936 return nResult;
942 void ViewShellBase::WriteUserData (String& rString, BOOL bBrowse)
944 SfxViewShell::WriteUserData (rString, bBrowse);
946 // Forward call to main sub shell.
947 ViewShell* pShell = GetMainViewShell().get();
948 if (pShell != NULL)
949 pShell->WriteUserData (rString);
955 void ViewShellBase::ReadUserData (const String& rString, BOOL bBrowse)
957 SfxViewShell::ReadUserData (rString, bBrowse);
959 // Forward call to main sub shell.
960 ViewShell* pShell = GetMainViewShell().get();
961 if (pShell != NULL)
962 pShell->ReadUserData (rString);
968 SdrView* ViewShellBase::GetDrawView (void) const
970 // Forward call to main sub shell.
971 ViewShell* pShell = GetMainViewShell().get();
972 if (pShell != NULL)
973 return pShell->GetDrawView ();
974 else
975 return SfxViewShell::GetDrawView();
981 void ViewShellBase::AdjustPosSizePixel (const Point &rOfs, const Size &rSize)
983 SfxViewShell::AdjustPosSizePixel (rOfs, rSize);
989 void ViewShellBase::SetBusyState (bool bBusy)
991 if (GetDocShell() != NULL)
992 GetDocShell()->SetWaitCursor (bBusy);
998 void ViewShellBase::UpdateBorder ( bool bForce /* = false */ )
1000 // The following calls to SetBorderPixel() and InvalidateBorder() are
1001 // made only for the main view shell. This not only avoids unnecessary
1002 // calls for the views in side panes but prevents calling an already
1003 // dying SfxViewShell base class.
1004 // For issue #140703# we have to check the existence of the window,
1005 // too. The SfxTopViewFrame accesses the window without checking it.
1006 ViewShell* pMainViewShell = GetMainViewShell().get();
1007 if (pMainViewShell != NULL && GetWindow()!=NULL)
1009 SvBorder aCurrentBorder (GetBorderPixel());
1010 bool bOuterResize ( ! GetDocShell()->IsInPlaceActive());
1011 SvBorder aBorder (GetBorder(bOuterResize));
1012 aBorder += pMainViewShell->GetBorder(bOuterResize);
1014 if (bForce || (aBorder != aCurrentBorder))
1016 SetBorderPixel (aBorder);
1017 InvalidateBorder();
1025 void ViewShellBase::ShowUIControls (bool bVisible)
1027 if (mpImpl->mpViewTabBar.is())
1028 mpImpl->mpViewTabBar->GetTabControl()->Show(bVisible);
1030 ViewShell* pMainViewShell = GetMainViewShell().get();
1031 if (pMainViewShell != NULL)
1032 pMainViewShell->ShowUIControls (bVisible);
1034 UpdateBorder();
1035 if (bVisible)
1036 Rearrange();
1042 OUString ViewShellBase::GetInitialViewShellType (void)
1044 OUString sRequestedView (FrameworkHelper::msImpressViewURL);
1048 Reference<document::XViewDataSupplier> xViewDataSupplier (
1049 GetDocShell()->GetModel(), UNO_QUERY);
1050 if ( ! xViewDataSupplier.is())
1051 break;
1053 Reference<container::XIndexAccess> xViewData (xViewDataSupplier->getViewData());
1054 if ( ! xViewData.is())
1055 break;
1056 if (xViewData->getCount() == 0)
1057 break;
1059 sal_Int32 nView = 0;
1060 ::com::sun::star::uno::Any aAny = xViewData->getByIndex(nView);
1061 Sequence<beans::PropertyValue> aProperties;
1062 if ( ! (aAny >>= aProperties))
1063 break;
1065 // Search the properties for the one that tells us what page kind to
1066 // use.
1067 for (sal_Int32 n=0; n<aProperties.getLength(); n++)
1069 const beans::PropertyValue& rProperty (aProperties[n]);
1070 if (rProperty.Name.compareToAscii(sUNO_View_PageKind) == COMPARE_EQUAL)
1072 sal_Int16 nPageKind = 0;
1073 rProperty.Value >>= nPageKind;
1074 switch ((PageKind)nPageKind)
1076 case PK_STANDARD:
1077 sRequestedView = FrameworkHelper::msImpressViewURL;
1078 break;
1080 case PK_HANDOUT:
1081 sRequestedView = FrameworkHelper::msHandoutViewURL;
1082 break;
1084 case PK_NOTES:
1085 sRequestedView = FrameworkHelper::msNotesViewURL;
1086 break;
1088 default:
1089 // The page kind is invalid. This is propably an
1090 // error by the caller. We use the standard type to
1091 // keep things going.
1092 DBG_ASSERT(sal_False, "ViewShellBase::GetInitialViewShellType: invalid page kind");
1093 sRequestedView = FrameworkHelper::msImpressViewURL;
1094 break;
1096 break;
1100 while (false);
1102 return sRequestedView;
1108 /** this method starts the presentation by
1109 executing the slot SID_PRESENTATION asynchronous */
1110 void ViewShellBase::StartPresentation()
1112 if( GetViewFrame() && GetViewFrame()->GetDispatcher() )
1113 GetViewFrame()->GetDispatcher()->Execute(SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
1120 ::boost::shared_ptr<tools::EventMultiplexer> ViewShellBase::GetEventMultiplexer (void)
1122 OSL_ASSERT(mpImpl.get()!=NULL);
1123 OSL_ASSERT(mpImpl->mpEventMultiplexer.get()!=NULL);
1125 return mpImpl->mpEventMultiplexer;
1131 const Rectangle& ViewShellBase::getClientRectangle (void) const
1133 return mpImpl->maClientArea;
1139 ::boost::shared_ptr<UpdateLockManager> ViewShellBase::GetUpdateLockManager (void) const
1141 OSL_ASSERT(mpImpl.get()!=NULL);
1142 OSL_ASSERT(mpImpl->mpUpdateLockManager.get()!=NULL);
1144 return mpImpl->mpUpdateLockManager;
1150 ::boost::shared_ptr<ToolBarManager> ViewShellBase::GetToolBarManager (void) const
1152 OSL_ASSERT(mpImpl.get()!=NULL);
1153 OSL_ASSERT(mpImpl->mpToolBarManager.get()!=NULL);
1155 return mpImpl->mpToolBarManager;
1161 ::boost::shared_ptr<FormShellManager> ViewShellBase::GetFormShellManager (void) const
1163 OSL_ASSERT(mpImpl.get()!=NULL);
1164 OSL_ASSERT(mpImpl->mpFormShellManager.get()!=NULL);
1166 return mpImpl->mpFormShellManager;
1172 DrawController& ViewShellBase::GetDrawController (void) const
1174 OSL_ASSERT(mpImpl.get()!=NULL);
1176 return *mpImpl->mpController;
1182 void ViewShellBase::SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabBar)
1184 OSL_ASSERT(mpImpl.get()!=NULL);
1186 mpImpl->mpViewTabBar = rViewTabBar;
1192 ::Window* ViewShellBase::GetViewWindow (void)
1194 OSL_ASSERT(mpImpl.get()!=NULL);
1196 return mpImpl->mpViewWindow.get();
1202 CustomHandleManager& ViewShellBase::getCustomHandleManager() const
1204 OSL_ASSERT(mpImpl.get()!=NULL);
1206 if( !mpImpl->mpCustomHandleManager.get() )
1207 mpImpl->mpCustomHandleManager.reset( new ::sd::CustomHandleManager(*const_cast< ViewShellBase* >(this)) );
1209 return *mpImpl->mpCustomHandleManager.get();
1214 //===== ViewShellBase::Implementation =========================================
1216 ViewShellBase::Implementation::Implementation (ViewShellBase& rBase)
1217 : mpController(),
1218 mpViewTabBar(),
1219 maClientArea(),
1220 mbIsClosing(false),
1221 mpViewWindow(),
1222 mpToolBarManager(),
1223 mpViewShellManager(),
1224 mpEventMultiplexer(),
1225 mpUpdateLockManager(),
1226 mpPrintManager(),
1227 mpFormShellManager(),
1228 mrBase(rBase),
1229 mpPageCacheManager(slidesorter::cache::PageCacheManager::Instance())
1236 ViewShellBase::Implementation::~Implementation (void)
1238 mpController = NULL;
1239 mpViewTabBar = NULL;
1240 mpViewWindow.reset();
1241 mpToolBarManager.reset();
1247 void ViewShellBase::Implementation::LateInit (void)
1249 mpController = new DrawController(mrBase);
1255 void ViewShellBase::Implementation::ProcessRestoreEditingViewSlot (void)
1257 ViewShell* pViewShell = mrBase.GetMainViewShell().get();
1258 if (pViewShell != NULL)
1260 FrameView* pFrameView = pViewShell->GetFrameView();
1261 if (pFrameView != NULL)
1263 // Set view shell, edit mode, and page kind.
1264 pFrameView->SetViewShEditMode(
1265 pFrameView->GetViewShEditModeOnLoad(),
1266 pFrameView->GetPageKindOnLoad());
1267 pFrameView->SetPageKind(
1268 pFrameView->GetPageKindOnLoad());
1269 ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(mrBase));
1270 pHelper->RequestView(
1271 pHelper->GetViewURL(pFrameView->GetViewShellTypeOnLoad()),
1272 FrameworkHelper::msCenterPaneURL);
1273 pHelper->RunOnConfigurationEvent(
1274 ::rtl::OUString::createFromAscii("ConfigurationUpdateEnd"),
1275 CurrentPageSetter(mrBase));
1283 void ViewShellBase::Implementation::ShowViewTabBar (bool bShow)
1285 if (mpViewTabBar.is()
1286 && (mpViewTabBar->GetTabControl()->IsVisible()==TRUE) != bShow)
1288 mpViewTabBar->GetTabControl()->Show(bShow ? TRUE : FALSE);
1289 mrBase.Rearrange();
1296 void ViewShellBase::Implementation::ResizePixel (
1297 const Point& rOrigin,
1298 const Size &rSize,
1299 bool bOuterResize)
1301 if (mbIsClosing)
1302 return;
1304 // Forward the call to both the base class and the main stacked sub
1305 // shell only when main sub shell exists.
1306 ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
1308 // Set the ViewTabBar temporarily to full size so that, when asked
1309 // later, it can return its true height.
1310 mrBase.SetWindow (mpViewWindow.get());
1311 if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
1312 mpViewTabBar->GetTabControl()->SetPosSizePixel (rOrigin, rSize);
1314 // Calculate and set the border before the controls are placed.
1315 SvBorder aBorder;
1316 if (pMainViewShell != NULL)
1317 aBorder = pMainViewShell->GetBorder(bOuterResize);
1318 aBorder += mrBase.GetBorder(bOuterResize);
1319 if (mrBase.GetBorderPixel() != aBorder)
1320 mrBase.SetBorderPixel(aBorder);
1322 // Place the ViewTabBar at the top. It is part of the border.
1323 SvBorder aBaseBorder;
1324 if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
1326 aBaseBorder.Top() = mpViewTabBar->GetHeight();
1327 mpViewTabBar->GetTabControl()->SetPosSizePixel(
1328 rOrigin, Size(rSize.Width(),aBaseBorder.Top()));
1331 // The view window gets the remaining space.
1332 Point aViewWindowPosition (
1333 rOrigin.X()+aBaseBorder.Left(),
1334 rOrigin.Y()+aBaseBorder.Top());
1335 Size aViewWindowSize (
1336 rSize.Width() - aBaseBorder.Left() - aBaseBorder.Right(),
1337 rSize.Height() - aBaseBorder.Top() - aBaseBorder.Bottom());
1338 mpViewWindow->SetPosSizePixel(aViewWindowPosition, aViewWindowSize);
1340 maClientArea = Rectangle(Point(0,0), aViewWindowSize);
1346 void ViewShellBase::Implementation::SetPaneVisibility (
1347 const SfxRequest& rRequest,
1348 const ::rtl::OUString& rsPaneURL,
1349 const ::rtl::OUString& rsViewURL)
1353 Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
1355 const Reference< XComponentContext > xContext(
1356 ::comphelper::getProcessComponentContext() );
1357 Reference<XResourceId> xPaneId (ResourceId::create(
1358 xContext, rsPaneURL));
1359 Reference<XResourceId> xViewId (ResourceId::createWithAnchorURL(
1360 xContext, rsViewURL, rsPaneURL));
1362 // Determine the new visibility state.
1363 const SfxItemSet* pArguments = rRequest.GetArgs();
1364 BOOL bShowChildWindow;
1365 USHORT nSlotId = rRequest.GetSlot();
1366 if (pArguments != NULL)
1367 bShowChildWindow = static_cast<const SfxBoolItem&>(
1368 pArguments->Get(nSlotId)).GetValue();
1369 else
1371 Reference<XConfigurationController> xConfigurationController (
1372 xControllerManager->getConfigurationController());
1373 if ( ! xConfigurationController.is())
1374 throw RuntimeException();
1375 Reference<XConfiguration> xConfiguration (
1376 xConfigurationController->getRequestedConfiguration());
1377 if ( ! xConfiguration.is())
1378 throw RuntimeException();
1380 bShowChildWindow = ! xConfiguration->hasResource(xPaneId);
1383 // Set the desired visibility state at the current configuration
1384 // and update it accordingly.
1385 Reference<XConfigurationController> xConfigurationController (
1386 xControllerManager->getConfigurationController());
1387 if ( ! xConfigurationController.is())
1388 throw RuntimeException();
1389 if (bShowChildWindow)
1391 xConfigurationController->requestResourceActivation(
1392 xPaneId,
1393 ResourceActivationMode_ADD);
1394 xConfigurationController->requestResourceActivation(
1395 xViewId,
1396 ResourceActivationMode_REPLACE);
1398 else
1399 xConfigurationController->requestResourceDeactivation(
1400 xPaneId);
1402 catch (RuntimeException&)
1404 DBG_ASSERT(false, "ViewShellBase::Implementation::SetPaneVisibility(): caught exception");
1412 void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet)
1416 // Get some frequently used values.
1417 Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
1418 Reference<XConfigurationController> xConfigurationController (
1419 xControllerManager->getConfigurationController());
1420 if ( ! xConfigurationController.is())
1421 throw RuntimeException();
1422 Reference<XConfiguration> xConfiguration (
1423 xConfigurationController->getRequestedConfiguration());
1424 if ( ! xConfiguration.is())
1425 throw RuntimeException();
1427 const Reference< XComponentContext > xContext(
1428 ::comphelper::getProcessComponentContext() );
1429 SfxWhichIter aSetIterator (rSet);
1430 sal_uInt16 nItemId (aSetIterator.FirstWhich());
1431 while (nItemId > 0)
1433 bool bState (false);
1434 Reference<XResourceId> xResourceId;
1437 switch (nItemId)
1439 case SID_LEFT_PANE_IMPRESS:
1440 xResourceId = ResourceId::create(
1441 xContext, FrameworkHelper::msLeftImpressPaneURL);
1442 break;
1444 case SID_LEFT_PANE_DRAW:
1445 xResourceId = ResourceId::create(
1446 xContext, FrameworkHelper::msLeftDrawPaneURL);
1447 break;
1449 case SID_RIGHT_PANE:
1450 xResourceId = ResourceId::create(
1451 xContext, FrameworkHelper::msRightPaneURL);
1452 break;
1454 case SID_NORMAL_MULTI_PANE_GUI:
1455 xResourceId = ResourceId::createWithAnchorURL(
1456 xContext,
1457 FrameworkHelper::msImpressViewURL,
1458 FrameworkHelper::msCenterPaneURL);
1459 break;
1461 case SID_SLIDE_SORTER_MULTI_PANE_GUI:
1462 case SID_DIAMODE:
1463 xResourceId = ResourceId::createWithAnchorURL(
1464 xContext,
1465 FrameworkHelper::msSlideSorterURL,
1466 FrameworkHelper::msCenterPaneURL);
1467 break;
1469 case SID_OUTLINEMODE:
1470 xResourceId = ResourceId::createWithAnchorURL(
1471 xContext,
1472 FrameworkHelper::msOutlineViewURL,
1473 FrameworkHelper::msCenterPaneURL);
1474 break;
1476 case SID_HANDOUTMODE:
1477 // There is only the master page mode for the handout
1478 // view so ignore the master page flag.
1479 xResourceId = ResourceId::createWithAnchorURL(
1480 xContext,
1481 FrameworkHelper::msHandoutViewURL,
1482 FrameworkHelper::msCenterPaneURL);
1483 break;
1485 case SID_NOTESMODE:
1486 xResourceId = ResourceId::createWithAnchorURL(
1487 xContext,
1488 FrameworkHelper::msNotesViewURL,
1489 FrameworkHelper::msCenterPaneURL);
1490 break;
1492 default:
1493 // Ignore all other items. They are not meant to be
1494 // handled by us.
1495 break;
1498 catch (DeploymentException)
1502 // Determine the state for the resource.
1503 bState = xConfiguration->hasResource(xResourceId);
1505 // Take the master page mode into account.
1506 switch (nItemId)
1508 case SID_NORMAL_MULTI_PANE_GUI:
1509 case SID_NOTESMODE:
1511 // Determine the master page mode.
1512 ViewShell* pCenterViewShell = FrameworkHelper::Instance(mrBase)->GetViewShell(
1513 FrameworkHelper::msCenterPaneURL).get();
1514 bool bMasterPageMode (false);
1515 if (pCenterViewShell!=NULL && pCenterViewShell->ISA(DrawViewShell))
1516 if (PTR_CAST(DrawViewShell,pCenterViewShell)->GetEditMode()
1517 == EM_MASTERPAGE)
1519 bMasterPageMode = true;
1522 bState &= !bMasterPageMode;
1523 break;
1526 case SID_HANDOUTMODE:
1527 // There is only the master page mode for the handout
1528 // view so ignore the master page flag.
1529 break;
1532 // And finally set the state.
1533 rSet.Put(SfxBoolItem(nItemId, bState));
1535 nItemId = aSetIterator.NextWhich();
1538 catch (RuntimeException&)
1540 DBG_ASSERT(false, "ViewShellBase::Implementation::GetSlotState(): caught exception");
1548 void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest& rRequest)
1550 // Set the visibility state of the toolpanel and one of its top
1551 // level panels.
1552 BOOL bShowToolPanel = TRUE;
1553 toolpanel::TaskPaneViewShell::PanelId nPanelId (
1554 toolpanel::TaskPaneViewShell::PID_UNKNOWN);
1555 bool bPanelIdGiven = false;
1557 // Extract the given arguments.
1558 const SfxItemSet* pArgs = rRequest.GetArgs();
1559 if (pArgs)
1561 if ((pArgs->Count() == 1) || (pArgs->Count() == 2))
1563 SFX_REQUEST_ARG (rRequest, pIsPanelVisible,
1564 SfxBoolItem, ID_VAL_ISVISIBLE, FALSE);
1565 if (pIsPanelVisible != NULL)
1566 bShowToolPanel = pIsPanelVisible->GetValue();
1568 if (pArgs->Count() == 2)
1570 SFX_REQUEST_ARG (rRequest, pPanelId, SfxUInt32Item,
1571 ID_VAL_PANEL_INDEX, FALSE);
1572 if (pPanelId != NULL)
1574 nPanelId = static_cast<
1575 toolpanel::TaskPaneViewShell::PanelId>(
1576 pPanelId->GetValue());
1577 bPanelIdGiven = true;
1582 // Ignore the request for some combinations of panels and view
1583 // shell types.
1584 if (bPanelIdGiven
1585 && ! (nPanelId==toolpanel::TaskPaneViewShell::PID_LAYOUT
1586 && mrBase.GetMainViewShell()!=NULL
1587 && mrBase.GetMainViewShell()->GetShellType()==ViewShell::ST_OUTLINE))
1589 framework::FrameworkHelper::Instance(mrBase)->RequestTaskPanel(
1590 framework::FrameworkHelper::msLayoutTaskPanelURL);
1595 } // end of namespace sd
1600 //===== CurrentPageSetter ===========================================
1602 namespace {
1604 CurrentPageSetter::CurrentPageSetter (ViewShellBase& rBase)
1605 : mrBase(rBase)
1613 void CurrentPageSetter::operator() (bool)
1615 FrameView* pFrameView = NULL;
1617 if (mrBase.GetMainViewShell() != NULL)
1619 pFrameView = mrBase.GetMainViewShell()->GetFrameView();
1622 if (pFrameView!=NULL)
1626 // Get the current page either from the DrawPagesSupplier or the
1627 // MasterPagesSupplier.
1628 Any aPage;
1629 if (pFrameView->GetViewShEditModeOnLoad() == EM_PAGE)
1631 Reference<drawing::XDrawPagesSupplier> xPagesSupplier (
1632 mrBase.GetController()->getModel(), UNO_QUERY_THROW);
1633 Reference<container::XIndexAccess> xPages (
1634 xPagesSupplier->getDrawPages(), UNO_QUERY_THROW);
1635 aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
1637 else
1639 Reference<drawing::XMasterPagesSupplier> xPagesSupplier (
1640 mrBase.GetController()->getModel(), UNO_QUERY_THROW);
1641 Reference<container::XIndexAccess> xPages (
1642 xPagesSupplier->getMasterPages(), UNO_QUERY_THROW);
1643 aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
1645 // Switch to the page last edited by setting the CurrentPage
1646 // property.
1647 Reference<beans::XPropertySet> xSet (mrBase.GetController(), UNO_QUERY_THROW);
1648 xSet->setPropertyValue (String::CreateFromAscii("CurrentPage"), aPage);
1650 catch (RuntimeException aException)
1652 // We have not been able to set the current page at the main view.
1653 // This is sad but still leaves us in a valid state. Therefore,
1654 // this exception is silently ignored.
1656 catch (beans::UnknownPropertyException aException)
1658 DBG_ASSERT(false,"CurrentPage property unknown");
1663 } // end of anonymouse namespace
1668 //===== FocusForwardingWindow =================================================
1670 namespace sd { namespace {
1672 FocusForwardingWindow::FocusForwardingWindow (
1673 ::Window& rParentWindow,
1674 ViewShellBase& rBase)
1675 : ::Window(&rParentWindow, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
1676 mrBase(rBase)
1678 OSL_TRACE("created FocusForwardingWindow at %x", this);
1684 FocusForwardingWindow::~FocusForwardingWindow (void)
1686 OSL_TRACE("destroyed FocusForwardingWindow at %x", this);
1692 void FocusForwardingWindow::KeyInput (const KeyEvent& rKEvt)
1694 ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
1695 if (pViewShell.get() != NULL)
1697 ::Window* pWindow = pViewShell->GetActiveWindow();
1698 if (pWindow != NULL)
1700 // Forward the focus so that the window is called directly the
1701 // next time.
1702 pWindow->GrabFocus();
1703 // Forward the key press as well.
1704 pWindow->KeyInput(rKEvt);
1712 void FocusForwardingWindow::Command (const CommandEvent& rEvent)
1714 ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
1715 if (pViewShell.get() != NULL)
1717 ::Window* pWindow = pViewShell->GetActiveWindow();
1718 if (pWindow != NULL)
1720 pWindow->Command(rEvent);
1726 } // end of anonymouse namespace
1728 // ====================================================================
1730 CustomHandleManager::CustomHandleManager( ViewShellBase& rViewShellBase )
1731 : mrViewShellBase( rViewShellBase )
1735 CustomHandleManager::~CustomHandleManager()
1737 DBG_ASSERT( maSupplier.empty(), "sd::CustomHandleManager::~CustomHandleManager(), still suppliers attached!" );
1740 void CustomHandleManager::registerSupplier( ICustomhandleSupplier* pSupplier )
1742 maSupplier.insert( pSupplier );
1745 void CustomHandleManager::unRegisterSupplier( ICustomhandleSupplier* pSupplier )
1747 maSupplier.erase( pSupplier );
1750 void CustomHandleManager::addCustomHandler( SdrView& rSourceView, ViewShell::ShellType eShellType, SdrHdlList& rHandlerList )
1752 for( std::set< ICustomhandleSupplier* >::iterator aIter( maSupplier.begin() ); aIter != maSupplier.end(); aIter++ )
1754 (*aIter)->addCustomHandler( rSourceView, eShellType, rHandlerList );
1758 } // end of namespace sd