xref: /AOO41X/main/sd/source/ui/view/ViewShellImplementation.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sd.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "ViewShellImplementation.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "sdpage.hxx"
34*cdf0e10cSrcweir #include "drawdoc.hxx"
35*cdf0e10cSrcweir #include "sdresid.hxx"
36*cdf0e10cSrcweir #include "glob.hrc"
37*cdf0e10cSrcweir #include "app.hrc"
38*cdf0e10cSrcweir #include "strings.hrc"
39*cdf0e10cSrcweir #include "strings.hrc"
40*cdf0e10cSrcweir #include "helpids.h"
41*cdf0e10cSrcweir #include "sdattr.hxx"
42*cdf0e10cSrcweir #include "sdabstdlg.hxx"
43*cdf0e10cSrcweir #include "unmodpg.hxx"
44*cdf0e10cSrcweir #include "Window.hxx"
45*cdf0e10cSrcweir #include "optsitem.hxx"
46*cdf0e10cSrcweir #include "DrawDocShell.hxx"
47*cdf0e10cSrcweir #include "DrawController.hxx"
48*cdf0e10cSrcweir #include "FactoryIds.hxx"
49*cdf0e10cSrcweir #include "slideshow.hxx"
50*cdf0e10cSrcweir #include "ViewShellBase.hxx"
51*cdf0e10cSrcweir #include "FrameView.hxx"
52*cdf0e10cSrcweir #include "DrawViewShell.hxx"
53*cdf0e10cSrcweir #include "ViewShellHint.hxx"
54*cdf0e10cSrcweir #include "taskpane/PanelId.hxx"
55*cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx"
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
58*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
59*cdf0e10cSrcweir #include <sfx2/request.hxx>
60*cdf0e10cSrcweir #include <svl/aeitem.hxx>
61*cdf0e10cSrcweir #include <svx/imapdlg.hxx>
62*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
63*cdf0e10cSrcweir #include <basic/sbstar.hxx>
64*cdf0e10cSrcweir #include "undo/undoobjects.hxx"
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
69*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
70*cdf0e10cSrcweir using ::sd::framework::FrameworkHelper;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir namespace sd {
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir ViewShell::Implementation::Implementation (ViewShell& rViewShell)
75*cdf0e10cSrcweir     : mbIsShowingUIControls(false),
76*cdf0e10cSrcweir       mbIsMainViewShell(false),
77*cdf0e10cSrcweir       mbIsInitialized(false),
78*cdf0e10cSrcweir       mbArrangeActive(false),
79*cdf0e10cSrcweir       mpSubShellFactory(),
80*cdf0e10cSrcweir       mpUpdateLockForMouse(),
81*cdf0e10cSrcweir       mrViewShell(rViewShell)
82*cdf0e10cSrcweir {
83*cdf0e10cSrcweir }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir ViewShell::Implementation::~Implementation (void)
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir     if ( ! mpUpdateLockForMouse.expired())
91*cdf0e10cSrcweir     {
92*cdf0e10cSrcweir         ::boost::shared_ptr<ToolBarManagerLock> pLock(mpUpdateLockForMouse);
93*cdf0e10cSrcweir         if (pLock.get() != NULL)
94*cdf0e10cSrcweir         {
95*cdf0e10cSrcweir             // Force the ToolBarManagerLock to be released even when the
96*cdf0e10cSrcweir             // IsUICaptured() returns <TRUE/>.
97*cdf0e10cSrcweir             pLock->Release(true);
98*cdf0e10cSrcweir         }
99*cdf0e10cSrcweir     }
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir void ViewShell::Implementation::ProcessModifyPageSlot (
106*cdf0e10cSrcweir     SfxRequest& rRequest,
107*cdf0e10cSrcweir     SdPage* pCurrentPage,
108*cdf0e10cSrcweir     PageKind ePageKind)
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir     SdDrawDocument* pDocument = mrViewShell.GetDoc();
111*cdf0e10cSrcweir     SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin();
112*cdf0e10cSrcweir     sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
113*cdf0e10cSrcweir     sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
114*cdf0e10cSrcweir     SetOfByte aVisibleLayers;
115*cdf0e10cSrcweir     sal_Bool bHandoutMode = sal_False;
116*cdf0e10cSrcweir     SdPage* pHandoutMPage = NULL;
117*cdf0e10cSrcweir     String aNewName;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     // #95981#
120*cdf0e10cSrcweir     String aOldName;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     AutoLayout aNewAutoLayout;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     sal_Bool bBVisible;
125*cdf0e10cSrcweir     sal_Bool bBObjsVisible;
126*cdf0e10cSrcweir     const SfxItemSet* pArgs = rRequest.GetArgs();
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     if (pCurrentPage != NULL && pCurrentPage->TRG_HasMasterPage())
129*cdf0e10cSrcweir         aVisibleLayers = pCurrentPage->TRG_GetMasterPageVisibleLayers();
130*cdf0e10cSrcweir     else
131*cdf0e10cSrcweir         aVisibleLayers.SetAll();
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     do
134*cdf0e10cSrcweir     {
135*cdf0e10cSrcweir         if (pCurrentPage == NULL)
136*cdf0e10cSrcweir             break;
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         if (!pArgs || pArgs->Count() == 1 || pArgs->Count() == 2 )
139*cdf0e10cSrcweir         {
140*cdf0e10cSrcweir             if (pArgs && pArgs->Count() == 2)
141*cdf0e10cSrcweir             {
142*cdf0e10cSrcweir                 // We have been called with a request that contains two
143*cdf0e10cSrcweir                 // arguments.  One was used as preselected layout in a
144*cdf0e10cSrcweir                 // dialog.  We could select that layout in the
145*cdf0e10cSrcweir                 // layout panel instead.
146*cdf0e10cSrcweir                 /*
147*cdf0e10cSrcweir                     SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False);
148*cdf0e10cSrcweir                     eNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue
149*cdf0e10cSrcweir                     ();
150*cdf0e10cSrcweir                 */
151*cdf0e10cSrcweir             }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir             // Make the layout menu visible in the tool pane.
154*cdf0e10cSrcweir             SfxBoolItem aMakeToolPaneVisible (ID_VAL_ISVISIBLE, sal_True);
155*cdf0e10cSrcweir             SfxUInt32Item aPanelId (ID_VAL_PANEL_INDEX,
156*cdf0e10cSrcweir                 ::sd::toolpanel::PID_LAYOUT);
157*cdf0e10cSrcweir             SfxViewFrame* pFrame = mrViewShell.GetViewFrame();
158*cdf0e10cSrcweir             if (pFrame!=NULL && pFrame->GetDispatcher()!=NULL)
159*cdf0e10cSrcweir             {
160*cdf0e10cSrcweir                 pFrame->GetDispatcher()->Execute (
161*cdf0e10cSrcweir                     SID_SHOW_TOOL_PANEL,
162*cdf0e10cSrcweir                     SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
163*cdf0e10cSrcweir                     &aMakeToolPaneVisible,
164*cdf0e10cSrcweir                     &aPanelId,
165*cdf0e10cSrcweir                     NULL);
166*cdf0e10cSrcweir             }
167*cdf0e10cSrcweir             else
168*cdf0e10cSrcweir             {
169*cdf0e10cSrcweir                 DBG_ASSERT(pFrame!=NULL && pFrame->GetDispatcher()!=NULL,
170*cdf0e10cSrcweir                     "ViewShell::Implementation::ProcessModifyPageSlot(): can not get dispatcher");
171*cdf0e10cSrcweir             }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir             // We have activated a non-modal control in the task pane.
174*cdf0e10cSrcweir             // Because it does not return anything we can not do anything
175*cdf0e10cSrcweir             // more right now and have to exit here.
176*cdf0e10cSrcweir             break;
177*cdf0e10cSrcweir         }
178*cdf0e10cSrcweir         else if (pArgs->Count() == 4)
179*cdf0e10cSrcweir         {
180*cdf0e10cSrcweir             SFX_REQUEST_ARG (rRequest, pNewName, SfxStringItem, ID_VAL_PAGENAME, sal_False);
181*cdf0e10cSrcweir             SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False);
182*cdf0e10cSrcweir             SFX_REQUEST_ARG (rRequest, pBVisible, SfxBoolItem, ID_VAL_ISPAGEBACK, sal_False);
183*cdf0e10cSrcweir             SFX_REQUEST_ARG (rRequest, pBObjsVisible, SfxBoolItem, ID_VAL_ISPAGEOBJ, sal_False);
184*cdf0e10cSrcweir             AutoLayout aLayout ((AutoLayout)pNewAutoLayout->GetValue ());
185*cdf0e10cSrcweir             if (aLayout >= AUTOLAYOUT__START
186*cdf0e10cSrcweir                 && aLayout < AUTOLAYOUT__END)
187*cdf0e10cSrcweir             {
188*cdf0e10cSrcweir                 aNewName		= pNewName->GetValue ();
189*cdf0e10cSrcweir                 aNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue ();
190*cdf0e10cSrcweir                 bBVisible		= pBVisible->GetValue ();
191*cdf0e10cSrcweir                 bBObjsVisible	= pBObjsVisible->GetValue ();
192*cdf0e10cSrcweir             }
193*cdf0e10cSrcweir             else
194*cdf0e10cSrcweir             {
195*cdf0e10cSrcweir                 StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
196*cdf0e10cSrcweir                 rRequest.Ignore ();
197*cdf0e10cSrcweir                 break;
198*cdf0e10cSrcweir             }
199*cdf0e10cSrcweir             if (ePageKind == PK_HANDOUT)
200*cdf0e10cSrcweir             {
201*cdf0e10cSrcweir                 bHandoutMode = sal_True;
202*cdf0e10cSrcweir                 pHandoutMPage = pDocument->GetMasterSdPage(0, PK_HANDOUT);
203*cdf0e10cSrcweir             }
204*cdf0e10cSrcweir         }
205*cdf0e10cSrcweir         else
206*cdf0e10cSrcweir         {
207*cdf0e10cSrcweir             StarBASIC::FatalError (SbERR_WRONG_ARGS);
208*cdf0e10cSrcweir             rRequest.Ignore ();
209*cdf0e10cSrcweir             break;
210*cdf0e10cSrcweir         }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir         SdPage* pUndoPage =
213*cdf0e10cSrcweir             bHandoutMode ? pHandoutMPage : pCurrentPage;
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir         ::svl::IUndoManager* pUndoManager = mrViewShell.GetDocSh()->GetUndoManager();
216*cdf0e10cSrcweir         DBG_ASSERT(pUndoManager, "No UNDO MANAGER ?!?");
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 		if( pUndoManager )
219*cdf0e10cSrcweir 		{
220*cdf0e10cSrcweir 			String aComment( SdResId(STR_UNDO_MODIFY_PAGE) );
221*cdf0e10cSrcweir 			pUndoManager->EnterListAction(aComment, aComment);
222*cdf0e10cSrcweir 			ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
223*cdf0e10cSrcweir 				pDocument, pUndoPage, aNewName, aNewAutoLayout, bBVisible, bBObjsVisible);
224*cdf0e10cSrcweir 			pUndoManager->AddUndoAction(pAction);
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 			// Clear the selection because the selectec object may be removed as
227*cdf0e10cSrcweir 			// a result of the ssignment of the layout.
228*cdf0e10cSrcweir 			mrViewShell.GetDrawView()->UnmarkAll();
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 			if (!bHandoutMode)
231*cdf0e10cSrcweir 			{
232*cdf0e10cSrcweir 				if (pCurrentPage->GetName() != aNewName)
233*cdf0e10cSrcweir 				{
234*cdf0e10cSrcweir 					pCurrentPage->SetName(aNewName);
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 					if (ePageKind == PK_STANDARD)
237*cdf0e10cSrcweir 					{
238*cdf0e10cSrcweir 						sal_uInt16 nPage = (pCurrentPage->GetPageNum()-1) / 2;
239*cdf0e10cSrcweir 						SdPage* pNotesPage = pDocument->GetSdPage(nPage, PK_NOTES);
240*cdf0e10cSrcweir 						if (pNotesPage != NULL)
241*cdf0e10cSrcweir 							pNotesPage->SetName(aNewName);
242*cdf0e10cSrcweir 					}
243*cdf0e10cSrcweir 				}
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 				pCurrentPage->SetAutoLayout(aNewAutoLayout, sal_True);
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 				aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
248*cdf0e10cSrcweir 				aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
249*cdf0e10cSrcweir 				aVisibleLayers.Set(aBckgrnd, bBVisible);
250*cdf0e10cSrcweir 				aVisibleLayers.Set(aBckgrndObj, bBObjsVisible);
251*cdf0e10cSrcweir 				pCurrentPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
252*cdf0e10cSrcweir 			}
253*cdf0e10cSrcweir 			else
254*cdf0e10cSrcweir 			{
255*cdf0e10cSrcweir 				pHandoutMPage->SetAutoLayout(aNewAutoLayout, sal_True);
256*cdf0e10cSrcweir 			}
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir 			mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
259*cdf0e10cSrcweir 				SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 			sal_Bool bSetModified = sal_True;
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir 			if (pArgs && pArgs->Count() == 1)
264*cdf0e10cSrcweir 			{
265*cdf0e10cSrcweir 				bSetModified = (sal_Bool) ((SfxBoolItem&) pArgs->Get(SID_MODIFYPAGE)).GetValue();
266*cdf0e10cSrcweir 			}
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 			pUndoManager->AddUndoAction( new UndoAutoLayoutPosAndSize( *pUndoPage ) );
269*cdf0e10cSrcweir 			pUndoManager->LeaveListAction();
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 			pDocument->SetChanged(bSetModified);
272*cdf0e10cSrcweir         }
273*cdf0e10cSrcweir     }
274*cdf0e10cSrcweir     while (false);
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir     mrViewShell.Cancel();
277*cdf0e10cSrcweir     rRequest.Done ();
278*cdf0e10cSrcweir }
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir void ViewShell::Implementation::AssignLayout ( SfxRequest& rRequest, PageKind ePageKind )
281*cdf0e10cSrcweir {
282*cdf0e10cSrcweir     const SfxUInt32Item* pWhatPage = static_cast< const SfxUInt32Item*  > ( rRequest.GetArg( ID_VAL_WHATPAGE, sal_False, TYPE(SfxUInt32Item) ) );
283*cdf0e10cSrcweir     const SfxUInt32Item* pWhatLayout = static_cast< const SfxUInt32Item*  > ( rRequest.GetArg( ID_VAL_WHATLAYOUT, sal_False, TYPE(SfxUInt32Item) ) );
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir     SdDrawDocument* pDocument = mrViewShell.GetDoc();
286*cdf0e10cSrcweir 	if( !pDocument )
287*cdf0e10cSrcweir 		return;
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir     SdPage* pPage = 0;
290*cdf0e10cSrcweir     if( pWhatPage )
291*cdf0e10cSrcweir     {
292*cdf0e10cSrcweir 		pPage = pDocument->GetSdPage(static_cast<sal_uInt16>(pWhatPage->GetValue()), ePageKind);
293*cdf0e10cSrcweir     }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir     if( pPage == 0 )
296*cdf0e10cSrcweir         pPage = mrViewShell.getCurrentPage();
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir     if( pPage )
299*cdf0e10cSrcweir     {
300*cdf0e10cSrcweir         AutoLayout eLayout = pPage->GetAutoLayout();
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir         if( pWhatLayout )
303*cdf0e10cSrcweir             eLayout = static_cast< AutoLayout >( pWhatLayout->GetValue() );
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir         // Transform the given request into the four argument form that is
306*cdf0e10cSrcweir         // understood by ProcessModifyPageSlot().
307*cdf0e10cSrcweir         SdrLayerAdmin& rLayerAdmin (mrViewShell.GetViewShellBase().GetDocument()->GetLayerAdmin());
308*cdf0e10cSrcweir         sal_uInt8 aBackground (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False));
309*cdf0e10cSrcweir         sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False));
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir         SetOfByte aVisibleLayers;
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 		if( pPage->GetPageKind() == PK_HANDOUT )
314*cdf0e10cSrcweir 			aVisibleLayers.SetAll();
315*cdf0e10cSrcweir 		else
316*cdf0e10cSrcweir 			aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 		SfxRequest aRequest (mrViewShell.GetViewShellBase().GetViewFrame(), SID_MODIFYPAGE);
319*cdf0e10cSrcweir         aRequest.AppendItem(SfxStringItem (ID_VAL_PAGENAME, pPage->GetName()));
320*cdf0e10cSrcweir         aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, eLayout));
321*cdf0e10cSrcweir         aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground)));
322*cdf0e10cSrcweir         aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEOBJ, aVisibleLayers.IsSet(aBackgroundObject)));
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir         // Forward the call with the new arguments.
325*cdf0e10cSrcweir         ProcessModifyPageSlot( aRequest, pPage, pPage->GetPageKind());
326*cdf0e10cSrcweir     }
327*cdf0e10cSrcweir }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir sal_uInt16 ViewShell::Implementation::GetViewId (void)
333*cdf0e10cSrcweir {
334*cdf0e10cSrcweir     switch (mrViewShell.GetShellType())
335*cdf0e10cSrcweir     {
336*cdf0e10cSrcweir         case ViewShell::ST_IMPRESS:
337*cdf0e10cSrcweir         case ViewShell::ST_NOTES:
338*cdf0e10cSrcweir         case ViewShell::ST_HANDOUT:
339*cdf0e10cSrcweir             return IMPRESS_FACTORY_ID;
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir         case ViewShell::ST_DRAW:
342*cdf0e10cSrcweir             return DRAW_FACTORY_ID;
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir         case ViewShell::ST_OUTLINE:
345*cdf0e10cSrcweir             return OUTLINE_FACTORY_ID;
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir         case ViewShell::ST_SLIDE_SORTER:
348*cdf0e10cSrcweir             return SLIDE_SORTER_FACTORY_ID;
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir         case ViewShell::ST_PRESENTATION:
351*cdf0e10cSrcweir             return PRESENTATION_FACTORY_ID;
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir         // Since we have to return a view id for every possible shell type
354*cdf0e10cSrcweir         // and there is not (yet) a proper ViewShellBase sub class for the
355*cdf0e10cSrcweir         // remaining types we chose the Impress factory as a fall back.
356*cdf0e10cSrcweir         case ViewShell::ST_TASK_PANE:
357*cdf0e10cSrcweir         case ViewShell::ST_NONE:
358*cdf0e10cSrcweir         default:
359*cdf0e10cSrcweir             return IMPRESS_FACTORY_ID;
360*cdf0e10cSrcweir     }
361*cdf0e10cSrcweir }
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir SvxIMapDlg* ViewShell::Implementation::GetImageMapDialog (void)
367*cdf0e10cSrcweir {
368*cdf0e10cSrcweir     SvxIMapDlg* pDialog = NULL;
369*cdf0e10cSrcweir     SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow(
370*cdf0e10cSrcweir         SvxIMapDlgChildWindow::GetChildWindowId());
371*cdf0e10cSrcweir     if (pChildWindow != NULL)
372*cdf0e10cSrcweir         pDialog = dynamic_cast<SvxIMapDlg*>(pChildWindow->GetWindow());
373*cdf0e10cSrcweir     return pDialog;
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir //===== ToolBarManagerLock ====================================================
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir class ViewShell::Implementation::ToolBarManagerLock::Deleter { public:
381*cdf0e10cSrcweir     void operator() (ToolBarManagerLock* pObject) { delete pObject; }
382*cdf0e10cSrcweir };
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock>
385*cdf0e10cSrcweir     ViewShell::Implementation::ToolBarManagerLock::Create (
386*cdf0e10cSrcweir         const ::boost::shared_ptr<ToolBarManager>& rpManager)
387*cdf0e10cSrcweir {
388*cdf0e10cSrcweir     ::boost::shared_ptr<ToolBarManagerLock> pLock (
389*cdf0e10cSrcweir         new ViewShell::Implementation::ToolBarManagerLock(rpManager),
390*cdf0e10cSrcweir         ViewShell::Implementation::ToolBarManagerLock::Deleter());
391*cdf0e10cSrcweir     pLock->mpSelf = pLock;
392*cdf0e10cSrcweir     return pLock;
393*cdf0e10cSrcweir }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir ViewShell::Implementation::ToolBarManagerLock::ToolBarManagerLock (
399*cdf0e10cSrcweir     const ::boost::shared_ptr<ToolBarManager>& rpManager)
400*cdf0e10cSrcweir     : mpLock(new ToolBarManager::UpdateLock(rpManager)),
401*cdf0e10cSrcweir       maTimer()
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir     // Start a timer that will unlock the ToolBarManager update lock when
404*cdf0e10cSrcweir     // that is not done explicitly by calling Release().
405*cdf0e10cSrcweir     maTimer.SetTimeoutHdl(LINK(this,ToolBarManagerLock,TimeoutCallback));
406*cdf0e10cSrcweir     maTimer.SetTimeout(100);
407*cdf0e10cSrcweir     maTimer.Start();
408*cdf0e10cSrcweir }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir IMPL_LINK(ViewShell::Implementation::ToolBarManagerLock,TimeoutCallback,Timer*,EMPTYARG)
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir     // If possible then release the lock now.  Otherwise start the timer
416*cdf0e10cSrcweir     // and try again later.
417*cdf0e10cSrcweir     if (Application::IsUICaptured())
418*cdf0e10cSrcweir     {
419*cdf0e10cSrcweir         maTimer.Start();
420*cdf0e10cSrcweir     }
421*cdf0e10cSrcweir     else
422*cdf0e10cSrcweir     {
423*cdf0e10cSrcweir         mpSelf.reset();
424*cdf0e10cSrcweir     }
425*cdf0e10cSrcweir     return 0;
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir void ViewShell::Implementation::ToolBarManagerLock::Release (bool bForce)
432*cdf0e10cSrcweir {
433*cdf0e10cSrcweir     // If possible then release the lock now.  Otherwise try again when the
434*cdf0e10cSrcweir     // timer expires.
435*cdf0e10cSrcweir     if (bForce || ! Application::IsUICaptured())
436*cdf0e10cSrcweir     {
437*cdf0e10cSrcweir         mpSelf.reset();
438*cdf0e10cSrcweir     }
439*cdf0e10cSrcweir }
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir ViewShell::Implementation::ToolBarManagerLock::~ToolBarManagerLock (void)
445*cdf0e10cSrcweir {
446*cdf0e10cSrcweir     mpLock.reset();
447*cdf0e10cSrcweir }
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir } // end of namespace sd
450