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