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