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