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