fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / view / ViewShellBase.cxx
blob91091c49bb1e575444e5b00dba5e6b6535b88bd1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <comphelper/processfactory.hxx>
22 #include <com/sun/star/frame/UnknownModuleException.hpp>
23 #include <com/sun/star/frame/ModuleManager.hpp>
24 #include <com/sun/star/container/XNameAccess.hpp>
25 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include <com/sun/star/frame/UICommandDescription.hpp>
28 #include "ViewShellBase.hxx"
29 #include <algorithm>
30 #include "EventMultiplexer.hxx"
31 #include "cache/SlsPageCacheManager.hxx"
32 #include "sdresid.hxx"
33 #include "app.hrc"
34 #include "strings.hrc"
35 #include "glob.hrc"
36 #include "unokywds.hxx"
37 #include <svx/svxids.hrc>
38 #include "DrawDocShell.hxx"
39 #include <sfx2/app.hxx>
40 #include "PaneChildWindows.hxx"
41 #include "ViewShellManager.hxx"
42 #include "DrawController.hxx"
43 #include "FrameView.hxx"
44 #include "ViewTabBar.hxx"
45 #include <sfx2/event.hxx>
46 #include "drawdoc.hxx"
47 #include <sfx2/dispatch.hxx>
48 #include <sfx2/request.hxx>
49 #include <sfx2/printer.hxx>
50 #include "DrawViewShell.hxx"
51 #include "GraphicViewShell.hxx"
52 #include "OutlineViewShell.hxx"
53 #include "SlideSorterViewShell.hxx"
54 #include "PresentationViewShell.hxx"
55 #include "FormShellManager.hxx"
56 #include "ToolBarManager.hxx"
57 #include "taskpane/PanelId.hxx"
58 #include "SidebarPanelId.hxx"
59 #include "Window.hxx"
60 #include "framework/ConfigurationController.hxx"
61 #include "DocumentRenderer.hxx"
63 #include <com/sun/star/frame/XFrame.hpp>
64 #include <com/sun/star/awt/XWindow.hpp>
65 #include <com/sun/star/frame/XController.hpp>
66 #include <com/sun/star/frame/XModel.hpp>
67 #include <com/sun/star/document/XViewDataSupplier.hpp>
68 #include <com/sun/star/container/XIndexAccess.hpp>
69 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
70 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
71 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
72 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
73 #include <com/sun/star/drawing/framework/ResourceId.hpp>
74 #include "framework/FrameworkHelper.hxx"
76 #include <rtl/ref.hxx>
77 #include <sfx2/msg.hxx>
78 #include <sfx2/objface.hxx>
79 #include <sfx2/viewfrm.hxx>
80 #include <svl/whiter.hxx>
81 #include <vcl/msgbox.hxx>
82 #include <tools/diagnose_ex.h>
84 #include "fubullet.hxx"
86 using namespace sd;
87 #define ViewShellBase
88 #include "sdslots.hxx"
90 using ::sd::framework::FrameworkHelper;
91 using namespace com::sun::star::uno;
92 using namespace com::sun::star::frame;
93 using namespace com::sun::star::container;
94 using namespace com::sun::star::lang;
95 using namespace com::sun::star::beans;
97 namespace {
99 class CurrentPageSetter
101 public:
102 CurrentPageSetter (ViewShellBase& rBase);
103 void operator () (bool);
104 private:
105 ViewShellBase& mrBase;
108 } // end of anonymous namespace
111 using namespace ::com::sun::star;
112 using namespace ::com::sun::star::uno;
113 using namespace ::com::sun::star::drawing::framework;
114 using ::sd::framework::FrameworkHelper;
116 namespace sd {
118 class ViewShellBase::Implementation
120 public:
121 /** Main controller of the view shell. During the switching from one
122 stacked shell to another this pointer may be NULL.
124 ::rtl::Reference<DrawController> mpController;
126 /** The view tab bar is the control for switching between different
127 views in one pane.
129 ::rtl::Reference<ViewTabBar> mpViewTabBar;
131 // contains the complete area of the current view relative to the frame window
132 Rectangle maClientArea;
134 // This is set to true when PrepareClose() is called.
135 bool mbIsClosing;
137 /** The view window is the parent of all UI elements that belong to the
138 view or ViewShell. This comprises the rulers, the scroll bars, and
139 the content window.
140 It does not include the ViewTabBar.
142 ::boost::scoped_ptr< ::Window> mpViewWindow;
143 ::boost::shared_ptr<ToolBarManager> mpToolBarManager;
144 ::boost::shared_ptr<ViewShellManager> mpViewShellManager;
145 ::boost::shared_ptr<tools::EventMultiplexer> mpEventMultiplexer;
146 ::boost::shared_ptr<FormShellManager> mpFormShellManager;
148 Implementation (ViewShellBase& rBase);
149 ~Implementation (void);
151 void LateInit (void);
153 /** Show or hide the ViewTabBar.
154 @param bShow
155 When <TRUE/> then the ViewTabBar is shown, otherwise it is hidden.
157 void ShowViewTabBar (bool bShow);
159 /** Common code of ViewShellBase::OuterResizePixel() and
160 ViewShellBase::InnerResizePixel().
162 void ResizePixel (
163 const Point& rOrigin,
164 const Size& rSize,
165 bool bOuterResize);
167 /** Show or hide the specified pane. The visibility state is taken
168 fromthe given request.
169 @param rRequest
170 The request determines the new visibility state. The state can
171 either be toggled or be set to a given value.
172 @param rsPaneURL
173 This URL specifies the pane whose visibility state to set.
174 @param rsViewURL
175 When the pane becomes visible then this view URL specifies which
176 type of view to show in it.
178 void SetPaneVisibility (
179 const SfxRequest& rRequest,
180 const OUString& rsPaneURL,
181 const OUString& rsViewURL);
183 void GetSlotState (SfxItemSet& rSet);
185 void ProcessRestoreEditingViewSlot (void);
186 void ProcessTaskPaneSlot (SfxRequest& rRequest);
188 private:
189 ViewShellBase& mrBase;
191 /** Hold a reference to the page cache manager of the slide sorter in
192 order to ensure that it stays alive while the ViewShellBase is
193 alive.
195 ::boost::shared_ptr<slidesorter::cache::PageCacheManager> mpPageCacheManager;
199 namespace {
200 /** The only task of this window is to forward key presses to the content
201 window of the main view shell. With the key press it forwards the focus
202 so that it is not called very often.
204 class FocusForwardingWindow : public ::Window
206 public:
207 FocusForwardingWindow (::Window& rParentWindow, ViewShellBase& rBase);
208 virtual ~FocusForwardingWindow (void);
209 virtual void KeyInput (const KeyEvent& rEvent);
210 virtual void Command (const CommandEvent& rEvent);
212 private:
213 ViewShellBase& mrBase;
215 } // end of anonymous namespace
218 //===== ViewShellBase =========================================================
220 TYPEINIT1(ViewShellBase, SfxViewShell);
222 // We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
223 // new ViewShellBase object has been constructed.
225 SfxViewFactory* ViewShellBase::pFactory;
226 SfxViewShell* ViewShellBase::CreateInstance (
227 SfxViewFrame *pFrame, SfxViewShell *pOldView)
229 ViewShellBase* pBase = new ViewShellBase(pFrame, pOldView);
230 pBase->LateInit("");
231 return pBase;
234 SFX_IMPL_INTERFACE(ViewShellBase, SfxViewShell, SdResId(0))
238 ViewShellBase::ViewShellBase (
239 SfxViewFrame* _pFrame,
240 SfxViewShell*)
241 : SfxViewShell (_pFrame,
242 SFX_VIEW_CAN_PRINT
243 | SFX_VIEW_HAS_PRINTOPTIONS),
244 maMutex(),
245 mpImpl(),
246 mpDocShell (NULL),
247 mpDocument (NULL)
249 mpImpl.reset(new Implementation(*this));
250 mpImpl->mpViewWindow.reset(new FocusForwardingWindow(_pFrame->GetWindow(),*this));
251 mpImpl->mpViewWindow->SetBackground(Wallpaper());
253 _pFrame->GetWindow().SetBackground(Application::GetSettings().GetStyleSettings().GetLightColor());
255 // Set up the members in the correct order.
256 if (GetViewFrame()->GetObjectShell()->ISA(DrawDocShell))
257 mpDocShell = static_cast<DrawDocShell*>(
258 GetViewFrame()->GetObjectShell());
259 if (mpDocShell != NULL)
260 mpDocument = mpDocShell->GetDoc();
261 mpImpl->mpViewShellManager.reset(new ViewShellManager(*this));
263 SetWindow(mpImpl->mpViewWindow.get());
265 // Hide the window to avoid complaints from Sfx...SwitchViewShell...
266 _pFrame->GetWindow().Hide();
272 /** In this destructor the order in which some of the members are destroyed
273 (and/or being prepared to being destroyed) is important. Change it only
274 when you know what you are doing.
276 ViewShellBase::~ViewShellBase (void)
278 // Tell the controller that the ViewShellBase is not available anymore.
279 if (mpImpl->mpController.get() != NULL)
280 mpImpl->mpController->ReleaseViewShellBase();
282 // We have to hide the main window to prevent SFX complaining after a
283 // reload about it being already visible.
284 ViewShell* pShell = GetMainViewShell().get();
285 if (pShell!=NULL
286 && pShell->GetActiveWindow()!=NULL
287 && pShell->GetActiveWindow()->GetParent()!=NULL)
289 pShell->GetActiveWindow()->GetParent()->Hide();
292 mpImpl->mpToolBarManager->Shutdown();
293 mpImpl->mpViewShellManager->Shutdown();
295 EndListening(*GetViewFrame());
296 EndListening(*GetDocShell());
298 SetWindow(NULL);
304 void ViewShellBase::LateInit (const OUString& rsDefaultView)
306 StartListening(*GetViewFrame(),sal_True);
307 StartListening(*GetDocShell(),sal_True);
308 mpImpl->LateInit();
309 InitializeFramework();
311 mpImpl->mpEventMultiplexer.reset(new tools::EventMultiplexer (*this));
313 mpImpl->mpFormShellManager.reset(new FormShellManager(*this));
315 mpImpl->mpToolBarManager = ToolBarManager::Create(
316 *this,
317 mpImpl->mpEventMultiplexer,
318 mpImpl->mpViewShellManager);
322 Reference<XControllerManager> xControllerManager (GetDrawController(), UNO_QUERY_THROW);
323 Reference<XConfigurationController> xConfigurationController (
324 xControllerManager->getConfigurationController());
325 if (xConfigurationController.is())
327 OUString sView (rsDefaultView);
328 if (sView.isEmpty())
329 sView = GetInitialViewShellType();
331 ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(*this));
333 // Create the resource ids for the center pane and view.
334 const Reference<drawing::framework::XResourceId> xCenterPaneId (
335 pHelper->CreateResourceId(FrameworkHelper::msCenterPaneURL));
336 const Reference<drawing::framework::XResourceId> xCenterViewId (
337 pHelper->CreateResourceId(sView, xCenterPaneId));
339 // Request center pane and view.
340 xConfigurationController->requestResourceActivation(xCenterPaneId, ResourceActivationMode_ADD);
341 xConfigurationController->requestResourceActivation(xCenterViewId, ResourceActivationMode_REPLACE);
343 // Process configuration events synchronously until the center view
344 // has been created.
345 sd::framework::ConfigurationController* pConfigurationController
346 = dynamic_cast<sd::framework::ConfigurationController*>(xConfigurationController.get());
347 if (pConfigurationController != NULL)
349 while (
350 ! pConfigurationController->getResource(xCenterViewId).is()
351 && pConfigurationController->hasPendingRequests())
353 pConfigurationController->ProcessEvent();
358 catch (const RuntimeException&)
362 // AutoLayouts have to be ready.
363 GetDocument()->StopWorkStartupDelay();
365 UpdateBorder();
367 // Remember the type of the current main view shell in the frame view.
368 ViewShell* pViewShell = GetMainViewShell().get();
369 if (pViewShell != NULL)
371 FrameView* pFrameView = pViewShell->GetFrameView();
372 if (pFrameView != NULL)
373 pFrameView->SetViewShellTypeOnLoad(pViewShell->GetShellType());
380 ::boost::shared_ptr<ViewShellManager> ViewShellBase::GetViewShellManager (void) const
382 return mpImpl->mpViewShellManager;
388 ::boost::shared_ptr<ViewShell> ViewShellBase::GetMainViewShell (void) const
390 ::boost::shared_ptr<ViewShell> pMainViewShell (
391 framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))
392 ->GetViewShell(framework::FrameworkHelper::msCenterPaneURL));
393 if (pMainViewShell.get() == NULL)
394 pMainViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))
395 ->GetViewShell(framework::FrameworkHelper::msFullScreenPaneURL);
396 return pMainViewShell;
402 ViewShellBase* ViewShellBase::GetViewShellBase (SfxViewFrame* pViewFrame)
404 ViewShellBase* pBase = NULL;
406 if (pViewFrame != NULL)
408 // Get the view shell for the frame and cast it to
409 // sd::ViewShellBase.
410 SfxViewShell* pSfxViewShell = pViewFrame->GetViewShell();
411 if (pSfxViewShell!=NULL && pSfxViewShell->ISA(::sd::ViewShellBase))
412 pBase = static_cast<ViewShellBase*>(pSfxViewShell);
415 return pBase;
421 DrawDocShell* ViewShellBase::GetDocShell (void) const
423 return mpDocShell;
428 SdDrawDocument* ViewShellBase::GetDocument (void) const
430 return mpDocument;
436 void ViewShellBase::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
438 SfxViewShell::Notify(rBC, rHint);
440 if (rHint.IsA(TYPE(SfxEventHint)))
442 switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
444 case SFX_EVENT_OPENDOC:
445 if( GetDocument() && GetDocument()->IsStartWithPresentation() )
447 if( GetViewFrame() )
449 GetViewFrame()->GetDispatcher()->Execute(
450 SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON );
453 break;
455 default:
456 break;
464 void ViewShellBase::InitializeFramework (void)
469 String ViewShellBase::GetSelectionText(sal_Bool bCompleteWords)
471 ::boost::shared_ptr<ViewShell> const pMainShell(GetMainViewShell());
472 DrawViewShell *const pDrawViewShell(
473 dynamic_cast<DrawViewShell*>(pMainShell.get()));
474 return (pDrawViewShell)
475 ? pDrawViewShell->GetSelectionText(bCompleteWords)
476 : SfxViewShell::GetSelectionText(bCompleteWords);
479 sal_Bool ViewShellBase::HasSelection(sal_Bool bText) const
481 ::boost::shared_ptr<ViewShell> const pMainShell(GetMainViewShell());
482 DrawViewShell *const pDrawViewShell(
483 dynamic_cast<DrawViewShell*>(pMainShell.get()));
484 return (pDrawViewShell)
485 ? pDrawViewShell->HasSelection(bText)
486 : SfxViewShell::HasSelection(bText);
489 void ViewShellBase::InnerResizePixel (const Point& rOrigin, const Size &rSize)
491 Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
492 if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
494 SvBorder aBorder( GetBorderPixel() );
495 Size aSize( rSize );
496 aSize.Width() -= (aBorder.Left() + aBorder.Right());
497 aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
498 Size aObjSizePixel = mpImpl->mpViewWindow->LogicToPixel( aObjSize, MAP_100TH_MM );
499 SfxViewShell::SetZoomFactor(
500 Fraction( aSize.Width(), std::max( aObjSizePixel.Width(), (long int)1 ) ),
501 Fraction( aSize.Height(), std::max( aObjSizePixel.Height(), (long int)1) ) );
504 mpImpl->ResizePixel(rOrigin, rSize, false);
510 void ViewShellBase::OuterResizePixel (const Point& rOrigin, const Size &rSize)
512 mpImpl->ResizePixel (rOrigin, rSize, true);
518 void ViewShellBase::Rearrange (void)
520 OSL_ASSERT(GetViewFrame()!=NULL);
522 // There is a bug in the communication between embedded objects and the
523 // framework::LayoutManager that leads to missing resize updates. The
524 // following workaround enforces such an update by cycling the border to
525 // zero and back to the current value.
526 if (GetWindow() != NULL)
528 SetBorderPixel(SvBorder());
529 UpdateBorder(true);
531 else
533 OSL_TRACE("Rearrange: window missing");
536 GetViewFrame()->Resize(sal_True);
542 ErrCode ViewShellBase::DoVerb (long nVerb)
544 ErrCode aResult = ERRCODE_NONE;
546 ::sd::ViewShell* pShell = GetMainViewShell().get();
547 if (pShell != NULL)
548 aResult = pShell->DoVerb (nVerb);
550 return aResult;
556 Reference<view::XRenderable> ViewShellBase::GetRenderable (void)
558 // Create a new DocumentRenderer on every call. It observes the life
559 // time of this ViewShellBase object.
560 return Reference<view::XRenderable>(new DocumentRenderer(*this));
566 SfxPrinter* ViewShellBase::GetPrinter (sal_Bool bCreate)
568 OSL_ASSERT(mpImpl.get()!=NULL);
570 return GetDocShell()->GetPrinter (bCreate);
576 sal_uInt16 ViewShellBase::SetPrinter (
577 SfxPrinter* pNewPrinter,
578 sal_uInt16 nDiffFlags,
579 bool bIsAPI)
581 OSL_ASSERT(mpImpl.get()!=NULL);
583 GetDocShell()->SetPrinter(pNewPrinter);
585 if ( (nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ||
586 nDiffFlags & SFX_PRINTER_CHG_SIZE) && pNewPrinter )
588 MapMode aMap = pNewPrinter->GetMapMode();
589 aMap.SetMapUnit(MAP_100TH_MM);
590 MapMode aOldMap = pNewPrinter->GetMapMode();
591 pNewPrinter->SetMapMode(aMap);
592 Size aNewSize = pNewPrinter->GetOutputSize();
594 sal_Bool bScaleAll = sal_False;
595 if ( bIsAPI )
597 WarningBox aWarnBox (
598 GetWindow(),
599 (WinBits)(WB_YES_NO | WB_DEF_YES),
600 String(SdResId(STR_SCALE_OBJS_TO_PAGE)));
601 bScaleAll = (aWarnBox.Execute() == RET_YES);
604 ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
605 ::boost::dynamic_pointer_cast<DrawViewShell>(GetMainViewShell()));
606 if (pDrawViewShell)
608 SdPage* pPage = GetDocument()->GetSdPage(
609 0, PK_STANDARD );
610 pDrawViewShell->SetPageSizeAndBorder (
611 pDrawViewShell->GetPageKind(),
612 aNewSize,
613 -1,-1,-1,-1,
614 bScaleAll,
615 pNewPrinter->GetOrientation(),
616 pPage->GetPaperBin(),
617 pPage->IsBackgroundFullSize());
620 pNewPrinter->SetMapMode(aOldMap);
623 return 0;
629 void ViewShellBase::UIActivating( SfxInPlaceClient* pClient )
631 mpImpl->ShowViewTabBar(false);
633 ViewShell* pViewShell = GetMainViewShell().get();
634 if ( pViewShell )
635 pViewShell->UIActivating( pClient );
637 SfxViewShell::UIActivating( pClient );
643 void ViewShellBase::UIDeactivated( SfxInPlaceClient* pClient )
645 SfxViewShell::UIDeactivated( pClient );
647 mpImpl->ShowViewTabBar(true);
649 ViewShell* pViewShell = GetMainViewShell().get();
650 if ( pViewShell )
651 pViewShell->UIDeactivated( pClient );
657 SvBorder ViewShellBase::GetBorder (bool )
659 int nTop = 0;
660 if (mpImpl->mpViewTabBar.is() && mpImpl->mpViewTabBar->GetTabControl()->IsVisible())
661 nTop = mpImpl->mpViewTabBar->GetHeight();
662 return SvBorder(0,nTop,0,0);
668 void ViewShellBase::Execute (SfxRequest& rRequest)
670 sal_uInt16 nSlotId = rRequest.GetSlot();
672 switch (nSlotId)
674 case SID_SWITCH_SHELL:
676 Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
677 if (xControllerManager.is())
679 Reference<XConfigurationController> xConfigurationController (
680 xControllerManager->getConfigurationController());
681 if (xConfigurationController.is())
682 xConfigurationController->update();
685 break;
687 case SID_LEFT_PANE_DRAW:
688 mpImpl->SetPaneVisibility(
689 rRequest,
690 framework::FrameworkHelper::msLeftDrawPaneURL,
691 framework::FrameworkHelper::msSlideSorterURL);
692 break;
694 case SID_LEFT_PANE_IMPRESS:
695 mpImpl->SetPaneVisibility(
696 rRequest,
697 framework::FrameworkHelper::msLeftImpressPaneURL,
698 framework::FrameworkHelper::msSlideSorterURL);
699 break;
701 case SID_TASKPANE:
702 mpImpl->SetPaneVisibility(
703 rRequest,
704 framework::FrameworkHelper::msRightPaneURL,
705 framework::FrameworkHelper::msTaskPaneURL);
706 break;
708 case SID_NORMAL_MULTI_PANE_GUI:
709 case SID_SLIDE_SORTER_MULTI_PANE_GUI:
710 case SID_DRAWINGMODE:
711 case SID_DIAMODE:
712 case SID_OUTLINEMODE:
713 case SID_NOTESMODE:
714 case SID_HANDOUTMODE:
715 framework::FrameworkHelper::Instance(*this)->HandleModeChangeSlot(nSlotId, rRequest);
716 break;
718 case SID_WIN_FULLSCREEN:
719 // The full screen mode is not supported. Ignore the request.
720 break;
722 case SID_SHOW_TOOL_PANEL:
723 mpImpl->ProcessTaskPaneSlot(rRequest);
724 break;
726 case SID_RESTORE_EDITING_VIEW:
727 mpImpl->ProcessRestoreEditingViewSlot();
728 break;
730 default:
731 // Ignore any other slot.
732 rRequest.Ignore ();
733 break;
740 void ViewShellBase::GetState (SfxItemSet& rSet)
742 mpImpl->GetSlotState(rSet);
744 FuBullet::GetSlotState( rSet, 0, GetViewFrame() );
750 void ViewShellBase::WriteUserDataSequence (
751 ::com::sun::star::uno::Sequence <
752 ::com::sun::star::beans::PropertyValue >& rSequence,
753 sal_Bool bBrowse)
755 // Forward call to main sub shell.
756 ViewShell* pShell = GetMainViewShell().get();
757 if (pShell != NULL)
758 pShell->WriteUserDataSequence (rSequence, bBrowse);
764 void ViewShellBase::ReadUserDataSequence (
765 const ::com::sun::star::uno::Sequence <
766 ::com::sun::star::beans::PropertyValue >& rSequence,
767 sal_Bool bBrowse)
769 // Forward call to main sub shell.
770 ViewShell* pShell = GetMainViewShell().get();
771 if (pShell != NULL)
773 pShell->ReadUserDataSequence (rSequence, bBrowse);
775 // For certain shell types ReadUserDataSequence may have changed the
776 // type to another one. Make sure that the center pane shows the
777 // right view shell.
778 switch (pShell->GetShellType())
780 case ViewShell::ST_IMPRESS:
781 case ViewShell::ST_NOTES:
782 case ViewShell::ST_HANDOUT:
784 OUString sViewURL;
785 switch (PTR_CAST(DrawViewShell, pShell)->GetPageKind())
787 default:
788 case PK_STANDARD:
789 sViewURL = framework::FrameworkHelper::msImpressViewURL;
790 break;
791 case PK_NOTES:
792 sViewURL = framework::FrameworkHelper::msNotesViewURL;
793 break;
794 case PK_HANDOUT:
795 sViewURL = framework::FrameworkHelper::msHandoutViewURL;
796 break;
798 if (!sViewURL.isEmpty())
799 framework::FrameworkHelper::Instance(*this)->RequestView(
800 sViewURL,
801 framework::FrameworkHelper::msCenterPaneURL);
803 break;
805 default:
806 break;
814 void ViewShellBase::Activate (sal_Bool bIsMDIActivate)
816 SfxViewShell::Activate(bIsMDIActivate);
818 Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
819 if (xControllerManager.is())
821 Reference<XConfigurationController> xConfigurationController (
822 xControllerManager->getConfigurationController());
823 if (xConfigurationController.is())
824 xConfigurationController->update();
826 GetToolBarManager()->RequestUpdate();
832 void ViewShellBase::Deactivate (sal_Bool bIsMDIActivate)
834 SfxViewShell::Deactivate(bIsMDIActivate);
840 void ViewShellBase::SetZoomFactor (
841 const Fraction &rZoomX,
842 const Fraction &rZoomY)
844 SfxViewShell::SetZoomFactor (rZoomX, rZoomY);
845 // Forward call to main sub shell.
846 ViewShell* pShell = GetMainViewShell().get();
847 if (pShell != NULL)
848 pShell->SetZoomFactor (rZoomX, rZoomY);
854 sal_uInt16 ViewShellBase::PrepareClose (sal_Bool bUI, sal_Bool bForBrowsing)
856 sal_uInt16 nResult = SfxViewShell::PrepareClose (bUI, bForBrowsing);
858 if (nResult == sal_True)
860 mpImpl->mbIsClosing = true;
862 // Forward call to main sub shell.
863 ViewShell* pShell = GetMainViewShell().get();
864 if (pShell != NULL)
865 nResult = pShell->PrepareClose (bUI, bForBrowsing);
868 return nResult;
874 void ViewShellBase::WriteUserData (String& rString, sal_Bool bBrowse)
876 SfxViewShell::WriteUserData (rString, bBrowse);
878 // Forward call to main sub shell.
879 ViewShell* pShell = GetMainViewShell().get();
880 if (pShell != NULL)
881 pShell->WriteUserData (rString);
887 void ViewShellBase::ReadUserData (const String& rString, sal_Bool bBrowse)
889 SfxViewShell::ReadUserData (rString, bBrowse);
891 // Forward call to main sub shell.
892 ViewShell* pShell = GetMainViewShell().get();
893 if (pShell != NULL)
894 pShell->ReadUserData (rString);
900 SdrView* ViewShellBase::GetDrawView (void) const
902 // Forward call to main sub shell.
903 ViewShell* pShell = GetMainViewShell().get();
904 if (pShell != NULL)
905 return pShell->GetDrawView ();
906 else
907 return SfxViewShell::GetDrawView();
913 void ViewShellBase::AdjustPosSizePixel (const Point &rOfs, const Size &rSize)
915 SfxViewShell::AdjustPosSizePixel (rOfs, rSize);
921 void ViewShellBase::SetBusyState (bool bBusy)
923 if (GetDocShell() != NULL)
924 GetDocShell()->SetWaitCursor (bBusy);
930 void ViewShellBase::UpdateBorder ( bool bForce /* = false */ )
932 // The following calls to SetBorderPixel() and InvalidateBorder() are
933 // made only for the main view shell. This not only avoids unnecessary
934 // calls for the views in side panes but prevents calling an already
935 // dying SfxViewShell base class.
936 // We have to check the existence of the window, too.
937 // The SfxViewFrame accesses the window without checking it.
938 ViewShell* pMainViewShell = GetMainViewShell().get();
939 if (pMainViewShell != NULL && GetWindow()!=NULL)
941 SvBorder aCurrentBorder (GetBorderPixel());
942 bool bOuterResize ( ! GetDocShell()->IsInPlaceActive());
943 SvBorder aBorder (GetBorder(bOuterResize));
944 aBorder += pMainViewShell->GetBorder(bOuterResize);
946 if (bForce || (aBorder != aCurrentBorder))
948 SetBorderPixel (aBorder);
949 InvalidateBorder();
957 void ViewShellBase::ShowUIControls (bool bVisible)
959 if (mpImpl->mpViewTabBar.is())
960 mpImpl->mpViewTabBar->GetTabControl()->Show(bVisible);
962 ViewShell* pMainViewShell = GetMainViewShell().get();
963 if (pMainViewShell != NULL)
964 pMainViewShell->ShowUIControls (bVisible);
966 UpdateBorder();
967 if (bVisible)
968 Rearrange();
974 OUString ViewShellBase::GetInitialViewShellType (void)
976 OUString sRequestedView (FrameworkHelper::msImpressViewURL);
980 Reference<document::XViewDataSupplier> xViewDataSupplier (
981 GetDocShell()->GetModel(), UNO_QUERY);
982 if ( ! xViewDataSupplier.is())
983 break;
985 Reference<container::XIndexAccess> xViewData (xViewDataSupplier->getViewData());
986 if ( ! xViewData.is())
987 break;
988 if (xViewData->getCount() == 0)
989 break;
991 sal_Int32 nView = 0;
992 ::com::sun::star::uno::Any aAny = xViewData->getByIndex(nView);
993 Sequence<beans::PropertyValue> aProperties;
994 if ( ! (aAny >>= aProperties))
995 break;
997 // Search the properties for the one that tells us what page kind to
998 // use.
999 for (sal_Int32 n=0; n<aProperties.getLength(); n++)
1001 const beans::PropertyValue& rProperty (aProperties[n]);
1002 if (rProperty.Name.compareToAscii(sUNO_View_PageKind) == COMPARE_EQUAL)
1004 sal_Int16 nPageKind = 0;
1005 rProperty.Value >>= nPageKind;
1006 switch ((PageKind)nPageKind)
1008 case PK_STANDARD:
1009 sRequestedView = FrameworkHelper::msImpressViewURL;
1010 break;
1012 case PK_HANDOUT:
1013 sRequestedView = FrameworkHelper::msHandoutViewURL;
1014 break;
1016 case PK_NOTES:
1017 sRequestedView = FrameworkHelper::msNotesViewURL;
1018 break;
1020 default:
1021 // The page kind is invalid. This is propably an
1022 // error by the caller. We use the standard type to
1023 // keep things going.
1024 DBG_ASSERT(sal_False, "ViewShellBase::GetInitialViewShellType: invalid page kind");
1025 sRequestedView = FrameworkHelper::msImpressViewURL;
1026 break;
1028 break;
1032 while (false);
1034 return sRequestedView;
1040 /** this method starts the presentation by
1041 executing the slot SID_PRESENTATION asynchronous */
1042 void ViewShellBase::StartPresentation()
1044 if( GetViewFrame() && GetViewFrame()->GetDispatcher() )
1045 GetViewFrame()->GetDispatcher()->Execute(SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
1052 ::boost::shared_ptr<tools::EventMultiplexer> ViewShellBase::GetEventMultiplexer (void)
1054 OSL_ASSERT(mpImpl.get()!=NULL);
1055 OSL_ASSERT(mpImpl->mpEventMultiplexer.get()!=NULL);
1057 return mpImpl->mpEventMultiplexer;
1063 const Rectangle& ViewShellBase::getClientRectangle (void) const
1065 return mpImpl->maClientArea;
1069 ::boost::shared_ptr<ToolBarManager> ViewShellBase::GetToolBarManager (void) const
1071 OSL_ASSERT(mpImpl.get()!=NULL);
1072 OSL_ASSERT(mpImpl->mpToolBarManager.get()!=NULL);
1074 return mpImpl->mpToolBarManager;
1080 ::boost::shared_ptr<FormShellManager> ViewShellBase::GetFormShellManager (void) const
1082 OSL_ASSERT(mpImpl.get()!=NULL);
1083 OSL_ASSERT(mpImpl->mpFormShellManager.get()!=NULL);
1085 return mpImpl->mpFormShellManager;
1091 DrawController& ViewShellBase::GetDrawController (void) const
1093 OSL_ASSERT(mpImpl.get()!=NULL);
1095 return *mpImpl->mpController;
1101 void ViewShellBase::SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabBar)
1103 OSL_ASSERT(mpImpl.get()!=NULL);
1105 mpImpl->mpViewTabBar = rViewTabBar;
1111 ::Window* ViewShellBase::GetViewWindow (void)
1113 OSL_ASSERT(mpImpl.get()!=NULL);
1115 return mpImpl->mpViewWindow.get();
1119 OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const OUString& aCmdURL )
1121 OUString aLabel;
1123 if ( !aCmdURL.isEmpty() ) try
1125 Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext(), UNO_QUERY_THROW );
1127 Reference< XModuleManager2 > xModuleManager( ModuleManager::create(xContext) );
1128 Reference< XInterface > xIfac( xFrame, UNO_QUERY_THROW );
1130 OUString aModuleIdentifier( xModuleManager->identify( xIfac ) );
1132 if( !aModuleIdentifier.isEmpty() )
1134 Reference< XNameAccess > const xNameAccess(
1135 frame::UICommandDescription::create(xContext) );
1136 Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels( xNameAccess->getByName( aModuleIdentifier ), UNO_QUERY_THROW );
1137 Sequence< PropertyValue > aPropSeq;
1138 if( m_xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq )
1140 for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
1142 if ( aPropSeq[i].Name == "Name" )
1144 aPropSeq[i].Value >>= aLabel;
1145 break;
1151 catch (const Exception&)
1155 return aLabel;
1158 OUString ViewShellBase::RetrieveLabelFromCommand( const OUString& aCmdURL ) const
1160 Reference< XFrame > xFrame( GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(), UNO_QUERY );
1161 return ImplRetrieveLabelFromCommand( xFrame, aCmdURL );
1166 //===== ViewShellBase::Implementation =========================================
1168 ViewShellBase::Implementation::Implementation (ViewShellBase& rBase)
1169 : mpController(),
1170 mpViewTabBar(),
1171 maClientArea(),
1172 mbIsClosing(false),
1173 mpViewWindow(),
1174 mpToolBarManager(),
1175 mpViewShellManager(),
1176 mpEventMultiplexer(),
1177 mpFormShellManager(),
1178 mrBase(rBase),
1179 mpPageCacheManager(slidesorter::cache::PageCacheManager::Instance())
1186 ViewShellBase::Implementation::~Implementation (void)
1188 mpController = NULL;
1189 mpViewTabBar = NULL;
1190 mpViewWindow.reset();
1191 mpToolBarManager.reset();
1197 void ViewShellBase::Implementation::LateInit (void)
1199 mpController = new DrawController(mrBase);
1205 void ViewShellBase::Implementation::ProcessRestoreEditingViewSlot (void)
1207 ViewShell* pViewShell = mrBase.GetMainViewShell().get();
1208 if (pViewShell != NULL)
1210 FrameView* pFrameView = pViewShell->GetFrameView();
1211 if (pFrameView != NULL)
1213 // Set view shell, edit mode, and page kind.
1214 pFrameView->SetViewShEditMode(
1215 pFrameView->GetViewShEditModeOnLoad(),
1216 pFrameView->GetPageKindOnLoad());
1217 pFrameView->SetPageKind(
1218 pFrameView->GetPageKindOnLoad());
1219 ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(mrBase));
1220 pHelper->RequestView(
1221 pHelper->GetViewURL(pFrameView->GetViewShellTypeOnLoad()),
1222 FrameworkHelper::msCenterPaneURL);
1223 pHelper->RunOnConfigurationEvent("ConfigurationUpdateEnd", CurrentPageSetter(mrBase));
1231 void ViewShellBase::Implementation::ShowViewTabBar (bool bShow)
1233 if (mpViewTabBar.is()
1234 && (mpViewTabBar->GetTabControl()->IsVisible()==sal_True) != bShow)
1236 mpViewTabBar->GetTabControl()->Show(bShow ? sal_True : sal_False);
1237 mrBase.Rearrange();
1244 void ViewShellBase::Implementation::ResizePixel (
1245 const Point& rOrigin,
1246 const Size &rSize,
1247 bool bOuterResize)
1249 if (mbIsClosing)
1250 return;
1252 // Forward the call to both the base class and the main stacked sub
1253 // shell only when main sub shell exists.
1254 ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
1256 // Set the ViewTabBar temporarily to full size so that, when asked
1257 // later, it can return its true height.
1258 mrBase.SetWindow (mpViewWindow.get());
1259 if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
1260 mpViewTabBar->GetTabControl()->SetPosSizePixel (rOrigin, rSize);
1262 // Calculate and set the border before the controls are placed.
1263 SvBorder aBorder;
1264 if (pMainViewShell != NULL)
1265 aBorder = pMainViewShell->GetBorder(bOuterResize);
1266 aBorder += mrBase.GetBorder(bOuterResize);
1267 if (mrBase.GetBorderPixel() != aBorder)
1268 mrBase.SetBorderPixel(aBorder);
1270 // Place the ViewTabBar at the top. It is part of the border.
1271 SvBorder aBaseBorder;
1272 if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
1274 aBaseBorder.Top() = mpViewTabBar->GetHeight();
1275 mpViewTabBar->GetTabControl()->SetPosSizePixel(
1276 rOrigin, Size(rSize.Width(),aBaseBorder.Top()));
1279 // The view window gets the remaining space.
1280 Point aViewWindowPosition (
1281 rOrigin.X()+aBaseBorder.Left(),
1282 rOrigin.Y()+aBaseBorder.Top());
1284 Size aViewWindowSize (
1285 rSize.Width() - aBaseBorder.Left() - aBaseBorder.Right(),
1286 rSize.Height() - aBaseBorder.Top() - aBaseBorder.Bottom());
1287 mpViewWindow->SetPosSizePixel(aViewWindowPosition, aViewWindowSize);
1289 maClientArea = Rectangle(Point(0,0), aViewWindowSize);
1295 void ViewShellBase::Implementation::SetPaneVisibility (
1296 const SfxRequest& rRequest,
1297 const OUString& rsPaneURL,
1298 const OUString& rsViewURL)
1302 Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
1304 const Reference< XComponentContext > xContext(
1305 ::comphelper::getProcessComponentContext() );
1306 Reference<XResourceId> xPaneId (ResourceId::create(
1307 xContext, rsPaneURL));
1308 Reference<XResourceId> xViewId (ResourceId::createWithAnchorURL(
1309 xContext, rsViewURL, rsPaneURL));
1311 // Determine the new visibility state.
1312 const SfxItemSet* pArguments = rRequest.GetArgs();
1313 sal_Bool bShowChildWindow;
1314 sal_uInt16 nSlotId = rRequest.GetSlot();
1315 if (pArguments != NULL)
1316 bShowChildWindow = static_cast<const SfxBoolItem&>(
1317 pArguments->Get(nSlotId)).GetValue();
1318 else
1320 Reference<XConfigurationController> xConfigurationController (
1321 xControllerManager->getConfigurationController());
1322 if ( ! xConfigurationController.is())
1323 throw RuntimeException();
1324 Reference<XConfiguration> xConfiguration (
1325 xConfigurationController->getRequestedConfiguration());
1326 if ( ! xConfiguration.is())
1327 throw RuntimeException();
1329 bShowChildWindow = ! xConfiguration->hasResource(xPaneId);
1332 // Set the desired visibility state at the current configuration
1333 // and update it accordingly.
1334 Reference<XConfigurationController> xConfigurationController (
1335 xControllerManager->getConfigurationController());
1336 if ( ! xConfigurationController.is())
1337 throw RuntimeException();
1338 if (bShowChildWindow)
1340 xConfigurationController->requestResourceActivation(
1341 xPaneId,
1342 ResourceActivationMode_ADD);
1343 xConfigurationController->requestResourceActivation(
1344 xViewId,
1345 ResourceActivationMode_REPLACE);
1347 else
1348 xConfigurationController->requestResourceDeactivation(
1349 xPaneId);
1351 catch (const Exception&)
1353 DBG_UNHANDLED_EXCEPTION();
1361 void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet)
1365 // Get some frequently used values.
1366 Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
1367 Reference<XConfigurationController> xConfigurationController (
1368 xControllerManager->getConfigurationController());
1369 if ( ! xConfigurationController.is())
1370 throw RuntimeException();
1371 Reference<XConfiguration> xConfiguration (
1372 xConfigurationController->getRequestedConfiguration());
1373 if ( ! xConfiguration.is())
1374 throw RuntimeException();
1376 const Reference< XComponentContext > xContext(
1377 ::comphelper::getProcessComponentContext() );
1378 SfxWhichIter aSetIterator (rSet);
1379 sal_uInt16 nItemId (aSetIterator.FirstWhich());
1380 while (nItemId > 0)
1382 bool bState (false);
1383 Reference<XResourceId> xResourceId;
1386 switch (nItemId)
1388 case SID_LEFT_PANE_IMPRESS:
1389 xResourceId = ResourceId::create(
1390 xContext, FrameworkHelper::msLeftImpressPaneURL);
1391 break;
1393 case SID_LEFT_PANE_DRAW:
1394 xResourceId = ResourceId::create(
1395 xContext, FrameworkHelper::msLeftDrawPaneURL);
1396 break;
1398 case SID_TASKPANE:
1399 xResourceId = ResourceId::create(
1400 xContext, FrameworkHelper::msRightPaneURL);
1401 break;
1403 case SID_NORMAL_MULTI_PANE_GUI:
1404 xResourceId = ResourceId::createWithAnchorURL(
1405 xContext,
1406 FrameworkHelper::msImpressViewURL,
1407 FrameworkHelper::msCenterPaneURL);
1408 break;
1410 case SID_SLIDE_SORTER_MULTI_PANE_GUI:
1411 case SID_DIAMODE:
1412 xResourceId = ResourceId::createWithAnchorURL(
1413 xContext,
1414 FrameworkHelper::msSlideSorterURL,
1415 FrameworkHelper::msCenterPaneURL);
1416 break;
1418 case SID_OUTLINEMODE:
1419 xResourceId = ResourceId::createWithAnchorURL(
1420 xContext,
1421 FrameworkHelper::msOutlineViewURL,
1422 FrameworkHelper::msCenterPaneURL);
1423 break;
1425 case SID_HANDOUTMODE:
1426 // There is only the master page mode for the handout
1427 // view so ignore the master page flag.
1428 xResourceId = ResourceId::createWithAnchorURL(
1429 xContext,
1430 FrameworkHelper::msHandoutViewURL,
1431 FrameworkHelper::msCenterPaneURL);
1432 break;
1434 case SID_NOTESMODE:
1435 xResourceId = ResourceId::createWithAnchorURL(
1436 xContext,
1437 FrameworkHelper::msNotesViewURL,
1438 FrameworkHelper::msCenterPaneURL);
1439 break;
1441 default:
1442 // Ignore all other items. They are not meant to be
1443 // handled by us.
1444 break;
1447 catch (const DeploymentException&)
1451 // Determine the state for the resource.
1452 bState = xConfiguration->hasResource(xResourceId);
1454 // Take the master page mode into account.
1455 switch (nItemId)
1457 case SID_NORMAL_MULTI_PANE_GUI:
1458 case SID_NOTESMODE:
1460 // Determine the master page mode.
1461 ViewShell* pCenterViewShell = FrameworkHelper::Instance(mrBase)->GetViewShell(
1462 FrameworkHelper::msCenterPaneURL).get();
1463 bool bMasterPageMode (false);
1464 if (pCenterViewShell!=NULL && pCenterViewShell->ISA(DrawViewShell))
1465 if (PTR_CAST(DrawViewShell,pCenterViewShell)->GetEditMode()
1466 == EM_MASTERPAGE)
1468 bMasterPageMode = true;
1471 bState &= !bMasterPageMode;
1472 break;
1475 case SID_HANDOUTMODE:
1476 // There is only the master page mode for the handout
1477 // view so ignore the master page flag.
1478 break;
1481 // And finally set the state.
1482 rSet.Put(SfxBoolItem(nItemId, bState));
1484 nItemId = aSetIterator.NextWhich();
1487 catch (const RuntimeException&)
1489 DBG_UNHANDLED_EXCEPTION();
1497 void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest& rRequest)
1499 // Set the visibility state of the toolpanel and one of its top
1500 // level panels.
1501 sidebar::PanelId nPanelId (sidebar::PID_UNKNOWN);
1502 bool bPanelIdGiven = false;
1504 // Extract the given arguments.
1505 const SfxItemSet* pArgs = rRequest.GetArgs();
1506 if (pArgs)
1508 if (pArgs->Count() == 2)
1510 SFX_REQUEST_ARG (rRequest, pPanelId, SfxUInt32Item,
1511 ID_VAL_PANEL_INDEX, sal_False);
1512 if (pPanelId != NULL)
1514 nPanelId = static_cast<sidebar::PanelId>(pPanelId->GetValue());
1515 bPanelIdGiven = true;
1520 // Ignore the request for some combinations of panels and view
1521 // shell types.
1522 if (bPanelIdGiven
1523 && ! (nPanelId==sidebar::PID_LAYOUT
1524 && mrBase.GetMainViewShell()!=NULL
1525 && mrBase.GetMainViewShell()->GetShellType()==ViewShell::ST_OUTLINE))
1527 framework::FrameworkHelper::Instance(mrBase)->RequestSidebarPanel(
1528 framework::FrameworkHelper::msLayoutTaskPanelURL);
1533 } // end of namespace sd
1538 //===== CurrentPageSetter ===========================================
1540 namespace {
1542 CurrentPageSetter::CurrentPageSetter (ViewShellBase& rBase)
1543 : mrBase(rBase)
1551 void CurrentPageSetter::operator() (bool)
1553 FrameView* pFrameView = NULL;
1555 if (mrBase.GetMainViewShell() != NULL)
1557 pFrameView = mrBase.GetMainViewShell()->GetFrameView();
1560 if (pFrameView!=NULL)
1564 // Get the current page either from the DrawPagesSupplier or the
1565 // MasterPagesSupplier.
1566 Any aPage;
1567 if (pFrameView->GetViewShEditModeOnLoad() == EM_PAGE)
1569 Reference<drawing::XDrawPagesSupplier> xPagesSupplier (
1570 mrBase.GetController()->getModel(), UNO_QUERY_THROW);
1571 Reference<container::XIndexAccess> xPages (
1572 xPagesSupplier->getDrawPages(), UNO_QUERY_THROW);
1573 aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
1575 else
1577 Reference<drawing::XMasterPagesSupplier> xPagesSupplier (
1578 mrBase.GetController()->getModel(), UNO_QUERY_THROW);
1579 Reference<container::XIndexAccess> xPages (
1580 xPagesSupplier->getMasterPages(), UNO_QUERY_THROW);
1581 aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
1583 // Switch to the page last edited by setting the CurrentPage
1584 // property.
1585 Reference<beans::XPropertySet> xSet (mrBase.GetController(), UNO_QUERY_THROW);
1586 xSet->setPropertyValue (OUString("CurrentPage"), aPage);
1588 catch (const RuntimeException&)
1590 // We have not been able to set the current page at the main view.
1591 // This is sad but still leaves us in a valid state. Therefore,
1592 // this exception is silently ignored.
1594 catch (const beans::UnknownPropertyException&)
1596 DBG_ASSERT(false,"CurrentPage property unknown");
1601 } // end of anonymouse namespace
1606 //===== FocusForwardingWindow =================================================
1608 namespace sd { namespace {
1610 FocusForwardingWindow::FocusForwardingWindow (
1611 ::Window& rParentWindow,
1612 ViewShellBase& rBase)
1613 : ::Window(&rParentWindow, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
1614 mrBase(rBase)
1616 OSL_TRACE("created FocusForwardingWindow at %x", this);
1622 FocusForwardingWindow::~FocusForwardingWindow (void)
1624 OSL_TRACE("destroyed FocusForwardingWindow at %x", this);
1630 void FocusForwardingWindow::KeyInput (const KeyEvent& rKEvt)
1632 ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
1633 if (pViewShell.get() != NULL)
1635 ::Window* pWindow = pViewShell->GetActiveWindow();
1636 if (pWindow != NULL)
1638 // Forward the focus so that the window is called directly the
1639 // next time.
1640 pWindow->GrabFocus();
1641 // Forward the key press as well.
1642 pWindow->KeyInput(rKEvt);
1650 void FocusForwardingWindow::Command (const CommandEvent& rEvent)
1652 ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
1653 if (pViewShell.get() != NULL)
1655 ::Window* pWindow = pViewShell->GetActiveWindow();
1656 if (pWindow != NULL)
1658 pWindow->Command(rEvent);
1664 } // end of anonymouse namespace
1666 } // end of namespace sd
1668 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */