xref: /aoo41x/main/sd/source/ui/view/drviews1.cxx (revision 0a7c867c)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
105b190011SAndrew Rist  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
125b190011SAndrew Rist  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
195b190011SAndrew Rist  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "DrawViewShell.hxx"
28cdf0e10cSrcweir #include "ViewShellImplementation.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "DrawController.hxx"
31cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "comphelper/anytostring.hxx"
34cdf0e10cSrcweir #include "comphelper/scopeguard.hxx"
35cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx"
36cdf0e10cSrcweir #include "rtl/ref.hxx"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #ifndef _SVXIDS_HRC
39cdf0e10cSrcweir #include <svx/svxids.hrc>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #include <svx/svdpagv.hxx>
42cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
43cdf0e10cSrcweir #include <sfx2/bindings.hxx>
44cdf0e10cSrcweir #include <svx/svdoole2.hxx>
45cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
46cdf0e10cSrcweir #include <vcl/scrbar.hxx>
47cdf0e10cSrcweir #include <svx/svdograf.hxx>
48cdf0e10cSrcweir #include <svx/svdopage.hxx>
49cdf0e10cSrcweir #include <vcl/msgbox.hxx>
50cdf0e10cSrcweir #include <sot/storage.hxx>
51cdf0e10cSrcweir #include <svx/fmshell.hxx>
52cdf0e10cSrcweir #include <svx/globl3d.hxx>
53cdf0e10cSrcweir #include <svx/fmglob.hxx>
54cdf0e10cSrcweir #include <editeng/outliner.hxx>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 
57cdf0e10cSrcweir #include "misc.hxx"
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #ifdef STARIMAGE_AVAILABLE
60cdf0e10cSrcweir #ifndef _SIMDLL_HXX
61cdf0e10cSrcweir #include <sim2/simdll.hxx>
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #endif
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #include <svx/dialogs.hrc>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #include "view/viewoverlaymanager.hxx"
68cdf0e10cSrcweir 
69cdf0e10cSrcweir #include "glob.hrc"
70cdf0e10cSrcweir #include "app.hrc"
71cdf0e10cSrcweir #include "res_bmp.hrc"
72cdf0e10cSrcweir #include "strings.hrc"
73cdf0e10cSrcweir #include "helpids.h"
74cdf0e10cSrcweir 
75cdf0e10cSrcweir #include "app.hxx"
76cdf0e10cSrcweir #include "fupoor.hxx"
77cdf0e10cSrcweir #include "sdresid.hxx"
78cdf0e10cSrcweir #include "fusel.hxx"
79cdf0e10cSrcweir #include "sdpage.hxx"
80cdf0e10cSrcweir #include "FrameView.hxx"
81cdf0e10cSrcweir #include "stlpool.hxx"
82cdf0e10cSrcweir #include "Window.hxx"
83cdf0e10cSrcweir #ifndef SD_DRAWVIEW_HXX
84cdf0e10cSrcweir #include "drawview.hxx"
85cdf0e10cSrcweir #endif
86cdf0e10cSrcweir #include "drawdoc.hxx"
87cdf0e10cSrcweir #include "DrawDocShell.hxx"
88cdf0e10cSrcweir #include "Ruler.hxx"
89cdf0e10cSrcweir #include "Client.hxx"
90cdf0e10cSrcweir #include "slideshow.hxx"
91cdf0e10cSrcweir #include "optsitem.hxx"
92cdf0e10cSrcweir #include "fusearch.hxx"
93cdf0e10cSrcweir #include "Outliner.hxx"
94cdf0e10cSrcweir #include "AnimationChildWindow.hxx"
95cdf0e10cSrcweir #include "SdUnoDrawView.hxx"
96cdf0e10cSrcweir #include "ToolBarManager.hxx"
97cdf0e10cSrcweir #include "FormShellManager.hxx"
98cdf0e10cSrcweir #include "ViewShellBase.hxx"
99cdf0e10cSrcweir #include "LayerDialogChildWindow.hxx"
100cdf0e10cSrcweir #include "LayerTabBar.hxx"
101cdf0e10cSrcweir #include "ViewShellManager.hxx"
102cdf0e10cSrcweir #include "ViewShellHint.hxx"
103cdf0e10cSrcweir 
104cdf0e10cSrcweir #include <sfx2/request.hxx>
105cdf0e10cSrcweir #include <boost/bind.hpp>
106cdf0e10cSrcweir 
107cdf0e10cSrcweir #ifdef _MSC_VER
108cdf0e10cSrcweir #if (_MSC_VER < 1400)
109cdf0e10cSrcweir #pragma optimize ( "", off )
110cdf0e10cSrcweir #endif
111cdf0e10cSrcweir #endif
112cdf0e10cSrcweir 
113cdf0e10cSrcweir using namespace com::sun::star;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir namespace sd {
116cdf0e10cSrcweir 
117cdf0e10cSrcweir void DrawViewShell::Activate(sal_Bool bIsMDIActivate)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir     ViewShell::Activate(bIsMDIActivate);
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir void DrawViewShell::UIActivating( SfxInPlaceClient* pCli )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir     ViewShell::UIActivating(pCli);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     // #94252# Disable own controls
127cdf0e10cSrcweir     maTabControl.Disable();
128cdf0e10cSrcweir     if (GetLayerTabControl() != NULL)
129cdf0e10cSrcweir         GetLayerTabControl()->Disable();
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir void DrawViewShell::UIDeactivated( SfxInPlaceClient* pCli )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir     // #94252# Enable own controls
135cdf0e10cSrcweir     maTabControl.Enable();
136cdf0e10cSrcweir     if (GetLayerTabControl() != NULL)
137cdf0e10cSrcweir         GetLayerTabControl()->Enable();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     ViewShell::UIDeactivated(pCli);
140cdf0e10cSrcweir }
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 
143cdf0e10cSrcweir /*************************************************************************
144cdf0e10cSrcweir |*
145cdf0e10cSrcweir |* Deactivate()
146cdf0e10cSrcweir |*
147cdf0e10cSrcweir \************************************************************************/
148cdf0e10cSrcweir 
149cdf0e10cSrcweir void DrawViewShell::Deactivate(sal_Bool bIsMDIActivate)
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     ViewShell::Deactivate(bIsMDIActivate);
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir namespace
155cdf0e10cSrcweir {
156cdf0e10cSrcweir     class LockUI
157cdf0e10cSrcweir     {
158cdf0e10cSrcweir     private:
159cdf0e10cSrcweir         void Lock(bool bLock);
160cdf0e10cSrcweir         SfxViewFrame *mpFrame;
161cdf0e10cSrcweir     public:
162cdf0e10cSrcweir         LockUI(SfxViewFrame *pFrame) : mpFrame(pFrame) { Lock(true); }
163cdf0e10cSrcweir         ~LockUI() { Lock(false); }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     };
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     void LockUI::Lock(bool bLock)
168cdf0e10cSrcweir     {
169cdf0e10cSrcweir         if (!mpFrame)
170cdf0e10cSrcweir             return;
171cdf0e10cSrcweir         mpFrame->Enable( !bLock );
172cdf0e10cSrcweir     }
173cdf0e10cSrcweir }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir /*************************************************************************
176cdf0e10cSrcweir |*
177cdf0e10cSrcweir |* Wird gerufen, wenn sich der Selektionszustand der View aendert
178cdf0e10cSrcweir |*
179cdf0e10cSrcweir \************************************************************************/
180cdf0e10cSrcweir void DrawViewShell::SelectionHasChanged (void)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir 	Invalidate();
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	//Update3DWindow(); // 3D-Controller
185cdf0e10cSrcweir 	SfxBoolItem aItem( SID_3D_STATE, sal_True );
186cdf0e10cSrcweir 	GetViewFrame()->GetDispatcher()->Execute(
187cdf0e10cSrcweir 		SID_3D_STATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 	SdrOle2Obj* pOleObj = NULL;
190cdf0e10cSrcweir 	SdrGrafObj* pGrafObj = NULL;
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 	if ( mpDrawView->AreObjectsMarked() )
193cdf0e10cSrcweir 	{
194cdf0e10cSrcweir 		const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 		if (rMarkList.GetMarkCount() == 1)
197cdf0e10cSrcweir 		{
198cdf0e10cSrcweir 			SdrMark* pMark = rMarkList.GetMark(0);
199cdf0e10cSrcweir 			SdrObject* pObj = pMark->GetMarkedSdrObj();
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 			sal_uInt32 nInv = pObj->GetObjInventor();
202cdf0e10cSrcweir 			sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 			if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
205cdf0e10cSrcweir 			{
206cdf0e10cSrcweir 				pOleObj = (SdrOle2Obj*) pObj;
207cdf0e10cSrcweir 				UpdateIMapDlg( pObj );
208cdf0e10cSrcweir 			}
209cdf0e10cSrcweir 			else if (nSdrObjKind == OBJ_GRAF)
210cdf0e10cSrcweir 			{
211cdf0e10cSrcweir 				pGrafObj = (SdrGrafObj*) pObj;
212cdf0e10cSrcweir 				UpdateIMapDlg( pObj );
213cdf0e10cSrcweir 			}
214cdf0e10cSrcweir 		}
215cdf0e10cSrcweir 	}
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     ViewShellBase& rBase = GetViewShellBase();
218cdf0e10cSrcweir 	rBase.SetVerbs( uno::Sequence< embed::VerbDescriptor >() );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	try
221cdf0e10cSrcweir 	{
222cdf0e10cSrcweir 		Client* pIPClient = static_cast<Client*>(rBase.GetIPClient());
223cdf0e10cSrcweir 		if ( pIPClient && pIPClient->IsObjectInPlaceActive() )
224cdf0e10cSrcweir 		{
225cdf0e10cSrcweir 			/**********************************************************************
226cdf0e10cSrcweir 			* Ggf. OLE-Objekt beruecksichtigen und deaktivieren
227cdf0e10cSrcweir 			**********************************************************************/
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 			// this means we recently deselected an inplace active ole object so
230cdf0e10cSrcweir 			// we need to deselect it now
231cdf0e10cSrcweir 			if (!pOleObj)
232cdf0e10cSrcweir 			{
233cdf0e10cSrcweir                 //#i47279# disable frame until after object has completed unload
234cdf0e10cSrcweir                 LockUI aUILock(GetViewFrame());
235cdf0e10cSrcweir                 pIPClient->DeactivateObject();
236cdf0e10cSrcweir 				//HMHmpDrView->ShowMarkHdl();
237cdf0e10cSrcweir 			}
238cdf0e10cSrcweir 			else
239cdf0e10cSrcweir 			{
240cdf0e10cSrcweir 				uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
241cdf0e10cSrcweir 				if ( xObj.is() )
242cdf0e10cSrcweir 				{
243cdf0e10cSrcweir 					rBase.SetVerbs( xObj->getSupportedVerbs() );
244cdf0e10cSrcweir 				}
245cdf0e10cSrcweir 				else
246cdf0e10cSrcweir 				{
247cdf0e10cSrcweir 					rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
248cdf0e10cSrcweir 				}
249cdf0e10cSrcweir 			}
250cdf0e10cSrcweir 		}
251cdf0e10cSrcweir 		else
252cdf0e10cSrcweir 		{
253cdf0e10cSrcweir 			if ( pOleObj )
254cdf0e10cSrcweir 			{
255cdf0e10cSrcweir 				uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
256cdf0e10cSrcweir 				if ( xObj.is() )
257cdf0e10cSrcweir 				{
258cdf0e10cSrcweir 					rBase.SetVerbs( xObj->getSupportedVerbs() );
259cdf0e10cSrcweir 				}
260cdf0e10cSrcweir 				else
261cdf0e10cSrcweir 				{
262cdf0e10cSrcweir 					rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
263cdf0e10cSrcweir 				}
264cdf0e10cSrcweir 			}
265cdf0e10cSrcweir 			else
266cdf0e10cSrcweir 			{
267cdf0e10cSrcweir 				rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
268cdf0e10cSrcweir 			}
269cdf0e10cSrcweir 		}
270cdf0e10cSrcweir 	}
271cdf0e10cSrcweir 	catch( ::com::sun::star::uno::Exception& e )
272cdf0e10cSrcweir 	{
273cdf0e10cSrcweir 		(void)e;
274cdf0e10cSrcweir 		DBG_ERROR(
275cdf0e10cSrcweir 			(rtl::OString("sd::DrawViewShell::SelectionHasChanged(), "
276cdf0e10cSrcweir 					"exception caught: ") +
277cdf0e10cSrcweir 			rtl::OUStringToOString(
278cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
279cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
280cdf0e10cSrcweir 	}
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 	if( HasCurrentFunction() )
283cdf0e10cSrcweir 	{
284cdf0e10cSrcweir 		GetCurrentFunction()->SelectionHasChanged();
285cdf0e10cSrcweir 	}
286cdf0e10cSrcweir 	else
287cdf0e10cSrcweir 	{
288cdf0e10cSrcweir         GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView);
289cdf0e10cSrcweir 	}
290cdf0e10cSrcweir 
291cdf0e10cSrcweir     // #96124# Invalidate for every subshell
292cdf0e10cSrcweir     GetViewShellBase().GetViewShellManager()->InvalidateAllSubShells(this);
293cdf0e10cSrcweir 
294cdf0e10cSrcweir     mpDrawView->UpdateSelectionClipboard( sal_False );
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     GetViewShellBase().GetDrawController().FireSelectionChangeListener();
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 
300cdf0e10cSrcweir /*************************************************************************
301cdf0e10cSrcweir |*
302cdf0e10cSrcweir |* Zoomfaktor setzen
303cdf0e10cSrcweir |*
304cdf0e10cSrcweir \************************************************************************/
305cdf0e10cSrcweir 
306cdf0e10cSrcweir void DrawViewShell::SetZoom( long nZoom )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir     // Make sure that the zoom factor will not be recalculated on
309cdf0e10cSrcweir     // following window resizings.
310cdf0e10cSrcweir     mbZoomOnPage = sal_False;
311cdf0e10cSrcweir 	ViewShell::SetZoom( nZoom );
312cdf0e10cSrcweir 	GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
313cdf0e10cSrcweir 	GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
314cdf0e10cSrcweir 	mpViewOverlayManager->onZoomChanged();
315cdf0e10cSrcweir }
316cdf0e10cSrcweir 
317cdf0e10cSrcweir /*************************************************************************
318cdf0e10cSrcweir |*
319cdf0e10cSrcweir |* Zoomrechteck fuer aktives Fenster einstellen
320cdf0e10cSrcweir |*
321cdf0e10cSrcweir \************************************************************************/
322cdf0e10cSrcweir 
323cdf0e10cSrcweir void DrawViewShell::SetZoomRect( const Rectangle& rZoomRect )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir 	ViewShell::SetZoomRect( rZoomRect );
326cdf0e10cSrcweir 	GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
327cdf0e10cSrcweir 	GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
328cdf0e10cSrcweir 	mpViewOverlayManager->onZoomChanged();
329cdf0e10cSrcweir }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir /*************************************************************************
332cdf0e10cSrcweir |*
333cdf0e10cSrcweir |* PrepareClose, ggfs. Texteingabe beenden, damit andere Viewshells ein
334cdf0e10cSrcweir |* aktualisiertes Textobjekt vorfinden
335cdf0e10cSrcweir |*
336cdf0e10cSrcweir \************************************************************************/
337cdf0e10cSrcweir 
338cdf0e10cSrcweir sal_uInt16 DrawViewShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir 	if ( ViewShell::PrepareClose(bUI, bForBrowsing) != sal_True )
341cdf0e10cSrcweir 		return sal_False;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	sal_Bool			bRet = sal_True;
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	if( bRet && HasCurrentFunction() )
346cdf0e10cSrcweir 	{
347cdf0e10cSrcweir 		sal_uInt16 nID = GetCurrentFunction()->GetSlotID();
348cdf0e10cSrcweir 		if (nID == SID_TEXTEDIT || nID == SID_ATTR_CHAR)
349cdf0e10cSrcweir 		{
350cdf0e10cSrcweir 			mpDrawView->SdrEndTextEdit();
351cdf0e10cSrcweir 		}
352cdf0e10cSrcweir 	}
353cdf0e10cSrcweir 	else if( !bRet )
354cdf0e10cSrcweir 	{
355cdf0e10cSrcweir 		maCloseTimer.SetTimeoutHdl( LINK( this, DrawViewShell, CloseHdl ) );
356cdf0e10cSrcweir 		maCloseTimer.SetTimeout( 20 );
357cdf0e10cSrcweir 		maCloseTimer.Start();
358cdf0e10cSrcweir 	}
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 	return bRet;
361cdf0e10cSrcweir }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir /*************************************************************************
364cdf0e10cSrcweir |*
365cdf0e10cSrcweir |* Status (Enabled/Disabled) von Menue-SfxSlots setzen
366cdf0e10cSrcweir |*
367cdf0e10cSrcweir \************************************************************************/
368cdf0e10cSrcweir 
369cdf0e10cSrcweir void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive)
370cdf0e10cSrcweir {
371cdf0e10cSrcweir 	if (meEditMode != eEMode || mbIsLayerModeActive != bIsLayerModeActive)
372cdf0e10cSrcweir 	{
373cdf0e10cSrcweir         ViewShellManager::UpdateLock aLock (GetViewShellBase().GetViewShellManager());
374cdf0e10cSrcweir 
375cdf0e10cSrcweir         sal_uInt16 nActualPageNum = 0;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir         GetViewShellBase().GetDrawController().FireChangeEditMode (eEMode == EM_MASTERPAGE);
378cdf0e10cSrcweir         GetViewShellBase().GetDrawController().FireChangeLayerMode (bIsLayerModeActive);
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 		if ( mpDrawView->IsTextEdit() )
381cdf0e10cSrcweir 		{
382cdf0e10cSrcweir 			mpDrawView->SdrEndTextEdit();
383cdf0e10cSrcweir 		}
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 		LayerTabBar* pLayerBar = GetLayerTabControl();
386cdf0e10cSrcweir         if (pLayerBar != NULL)
387cdf0e10cSrcweir             pLayerBar->EndEditMode();
388cdf0e10cSrcweir 		maTabControl.EndEditMode();
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 		if (mePageKind == PK_HANDOUT)
391cdf0e10cSrcweir 		{
392cdf0e10cSrcweir 			// Bei Handzetteln nur MasterPage zulassen
393cdf0e10cSrcweir 			eEMode = EM_MASTERPAGE;
394cdf0e10cSrcweir 		}
395cdf0e10cSrcweir 
39665be1ea2SAndre Fischer         GetViewShellBase().GetDrawController().BroadcastContextChange();
39765be1ea2SAndre Fischer 
398cdf0e10cSrcweir 		meEditMode = eEMode;
399cdf0e10cSrcweir 		mbIsLayerModeActive = bIsLayerModeActive;
400cdf0e10cSrcweir 
401cdf0e10cSrcweir         // Determine whether to show the master view toolbar.  The master
402cdf0e10cSrcweir         // page mode has to be active and the shell must not be a handout
403cdf0e10cSrcweir         // view.
404cdf0e10cSrcweir         bool bShowMasterViewToolbar (meEditMode == EM_MASTERPAGE
405cdf0e10cSrcweir              && GetShellType() != ViewShell::ST_HANDOUT);
406cdf0e10cSrcweir 
407cdf0e10cSrcweir         // If the master view toolbar is not shown we hide it before
408cdf0e10cSrcweir         // switching the edit mode.
409cdf0e10cSrcweir         if (::sd::ViewShell::mpImpl->mbIsInitialized
410cdf0e10cSrcweir             && IsMainViewShell()
411cdf0e10cSrcweir             && ! bShowMasterViewToolbar)
412cdf0e10cSrcweir         {
413cdf0e10cSrcweir             GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::TBG_MASTER_MODE);
414cdf0e10cSrcweir         }
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 		if (meEditMode == EM_PAGE)
417cdf0e10cSrcweir 		{
418cdf0e10cSrcweir 			/******************************************************************
419cdf0e10cSrcweir 			* PAGEMODE
420cdf0e10cSrcweir 			******************************************************************/
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 			maTabControl.Clear();
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 			SdPage* pPage;
425cdf0e10cSrcweir 			String aPageName;
426cdf0e10cSrcweir 			sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 			for (sal_uInt16 i = 0; i < nPageCnt; i++)
429cdf0e10cSrcweir 			{
430cdf0e10cSrcweir 				pPage = GetDoc()->GetSdPage(i, mePageKind);
431cdf0e10cSrcweir 				aPageName = pPage->GetName();
432cdf0e10cSrcweir 				maTabControl.InsertPage(i + 1, aPageName);
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 				if ( pPage->IsSelected() && nActualPageNum == 0 )
435cdf0e10cSrcweir 				{
436cdf0e10cSrcweir 					nActualPageNum = i;
437cdf0e10cSrcweir 				}
438cdf0e10cSrcweir 			}
439cdf0e10cSrcweir 
440cdf0e10cSrcweir             maTabControl.SetCurPageId(nActualPageNum + 1);
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 			SwitchPage(nActualPageNum);
443cdf0e10cSrcweir 		}
444cdf0e10cSrcweir 		else
445cdf0e10cSrcweir 		{
446cdf0e10cSrcweir 			/******************************************************************
447cdf0e10cSrcweir 			* MASTERPAGE
448cdf0e10cSrcweir 			******************************************************************/
449cdf0e10cSrcweir 			GetViewFrame()->SetChildWindow(
450cdf0e10cSrcweir                 AnimationChildWindow::GetChildWindowId(), sal_False );
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 			if (!mpActualPage)
453cdf0e10cSrcweir 			{
454cdf0e10cSrcweir 				// Sofern es keine mpActualPage gibt, wird die erste genommen
455cdf0e10cSrcweir 				mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
456cdf0e10cSrcweir 			}
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 			maTabControl.Clear();
459cdf0e10cSrcweir 			sal_uInt16 nActualMasterPageNum = 0;
460cdf0e10cSrcweir 			sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 			for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
463cdf0e10cSrcweir 			{
464cdf0e10cSrcweir 				SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
465cdf0e10cSrcweir 				String aLayoutName(pMaster->GetLayoutName());
466cdf0e10cSrcweir 				aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 				maTabControl.InsertPage(i + 1, aLayoutName);
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 				if (&(mpActualPage->TRG_GetMasterPage()) == pMaster)
471cdf0e10cSrcweir 				{
472cdf0e10cSrcweir 					nActualMasterPageNum = i;
473cdf0e10cSrcweir 				}
474cdf0e10cSrcweir 			}
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 			maTabControl.SetCurPageId(nActualMasterPageNum + 1);
477cdf0e10cSrcweir 			SwitchPage(nActualMasterPageNum);
478cdf0e10cSrcweir 		}
479cdf0e10cSrcweir 
480cdf0e10cSrcweir         // If the master view toolbar is to be shown we turn it on after the
481cdf0e10cSrcweir         // edit mode has been changed.
482cdf0e10cSrcweir         if (::sd::ViewShell::mpImpl->mbIsInitialized
483cdf0e10cSrcweir             && IsMainViewShell()
484cdf0e10cSrcweir             && bShowMasterViewToolbar)
485cdf0e10cSrcweir         {
486cdf0e10cSrcweir             GetViewShellBase().GetToolBarManager()->SetToolBar(
487cdf0e10cSrcweir                 ToolBarManager::TBG_MASTER_MODE,
488cdf0e10cSrcweir                 ToolBarManager::msMasterViewToolBar);
489cdf0e10cSrcweir         }
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 		if ( ! mbIsLayerModeActive)
492cdf0e10cSrcweir 		{
493cdf0e10cSrcweir             maTabControl.Show();
494cdf0e10cSrcweir             // Set the tab control only for draw pages.  For master page
495cdf0e10cSrcweir             // this has been done already above.
496cdf0e10cSrcweir             if (meEditMode == EM_PAGE)
497cdf0e10cSrcweir                 maTabControl.SetCurPageId (nActualPageNum + 1);
498cdf0e10cSrcweir 		}
499cdf0e10cSrcweir         /*AF: The LayerDialogChildWindow is not used anymore (I hope).
500cdf0e10cSrcweir         if (GetViewFrame()->KnowsChildWindow(
501cdf0e10cSrcweir             LayerDialogChildWindow::GetChildWindowId()))
502cdf0e10cSrcweir         {
503cdf0e10cSrcweir             GetViewFrame()->SetChildWindow(
504cdf0e10cSrcweir                 LayerDialogChildWindow::GetChildWindowId(),
505cdf0e10cSrcweir                 IsLayerModeActive());
506cdf0e10cSrcweir         }
507cdf0e10cSrcweir         */
508cdf0e10cSrcweir 		ResetActualLayer();
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 		Invalidate( SID_PAGEMODE );
511cdf0e10cSrcweir 		Invalidate( SID_LAYERMODE );
512cdf0e10cSrcweir 		Invalidate( SID_MASTERPAGE );
513cdf0e10cSrcweir         Invalidate( SID_DELETE_MASTER_PAGE );
514cdf0e10cSrcweir         Invalidate( SID_DELETE_PAGE );
515cdf0e10cSrcweir 		Invalidate( SID_SLIDE_MASTERPAGE );
516cdf0e10cSrcweir 		Invalidate( SID_TITLE_MASTERPAGE );
517cdf0e10cSrcweir 		Invalidate( SID_NOTES_MASTERPAGE );
518cdf0e10cSrcweir 		Invalidate( SID_HANDOUT_MASTERPAGE );
519*0a7c867cSAndre Fischer 
520*0a7c867cSAndre Fischer         if (meEditMode == EM_PAGE)
521*0a7c867cSAndre Fischer             SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawPage));
522*0a7c867cSAndre Fischer         else
523*0a7c867cSAndre Fischer             SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_MasterPage));
524cdf0e10cSrcweir 	}
525cdf0e10cSrcweir }
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 
530cdf0e10cSrcweir bool DrawViewShell::IsLayerModeActive (void) const
531cdf0e10cSrcweir {
532cdf0e10cSrcweir     return mbIsLayerModeActive;
533cdf0e10cSrcweir }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 
538cdf0e10cSrcweir /*************************************************************************
539cdf0e10cSrcweir |*
540cdf0e10cSrcweir |* Groesse des TabControls und der ModeButtons zurueckgeben
541cdf0e10cSrcweir |*
542cdf0e10cSrcweir \************************************************************************/
543cdf0e10cSrcweir 
544cdf0e10cSrcweir long DrawViewShell::GetHCtrlWidth()
545cdf0e10cSrcweir {
546cdf0e10cSrcweir     //	return maTabControl.GetSizePixel().Width();
547cdf0e10cSrcweir     return 0;
548cdf0e10cSrcweir }
549cdf0e10cSrcweir 
550cdf0e10cSrcweir 
551cdf0e10cSrcweir /*************************************************************************
552cdf0e10cSrcweir |*
553cdf0e10cSrcweir |* Horizontales Lineal erzeugen
554cdf0e10cSrcweir |*
555cdf0e10cSrcweir \************************************************************************/
556cdf0e10cSrcweir 
557cdf0e10cSrcweir SvxRuler* DrawViewShell::CreateHRuler (::sd::Window* pWin, sal_Bool bIsFirst)
558cdf0e10cSrcweir {
559cdf0e10cSrcweir 	Ruler* pRuler;
560cdf0e10cSrcweir 	WinBits  aWBits;
561cdf0e10cSrcweir 	sal_uInt16	 nFlags = SVXRULER_SUPPORT_OBJECT;
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 	if ( bIsFirst )
564cdf0e10cSrcweir 	{
565cdf0e10cSrcweir 		aWBits	= WB_HSCROLL | WB_3DLOOK | WB_BORDER | WB_EXTRAFIELD;
566cdf0e10cSrcweir 		nFlags |= ( SVXRULER_SUPPORT_SET_NULLOFFSET |
567cdf0e10cSrcweir 					SVXRULER_SUPPORT_TABS |
568cdf0e10cSrcweir 					SVXRULER_SUPPORT_PARAGRAPH_MARGINS ); // Neu
569cdf0e10cSrcweir 	}
570cdf0e10cSrcweir 	else
571cdf0e10cSrcweir 		aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER;
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 	pRuler = new Ruler (*this, GetParentWindow(), pWin, nFlags,
574cdf0e10cSrcweir         GetViewFrame()->GetBindings(), aWBits);
575cdf0e10cSrcweir 	pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit());
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 	// Metric ...
578cdf0e10cSrcweir 	sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit();
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 	if( nMetric == 0xffff )
581cdf0e10cSrcweir 		nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit();
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 	pRuler->SetUnit( FieldUnit( nMetric ) );
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 	// ... und auch DefTab am Lineal einstellen
586cdf0e10cSrcweir 	pRuler->SetDefTabDist( GetDoc()->GetDefaultTabulator() ); // Neu
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 	Fraction aUIScale(pWin->GetMapMode().GetScaleX());
589cdf0e10cSrcweir 	aUIScale *= GetDoc()->GetUIScale();
590cdf0e10cSrcweir 	pRuler->SetZoom(aUIScale);
591cdf0e10cSrcweir 
592cdf0e10cSrcweir 	return pRuler;
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir /*************************************************************************
596cdf0e10cSrcweir |*
597cdf0e10cSrcweir |* Vertikales Lineal erzeugen
598cdf0e10cSrcweir |*
599cdf0e10cSrcweir \************************************************************************/
600cdf0e10cSrcweir 
601cdf0e10cSrcweir SvxRuler* DrawViewShell::CreateVRuler(::sd::Window* pWin)
602cdf0e10cSrcweir {
603cdf0e10cSrcweir 	Ruler* pRuler;
604cdf0e10cSrcweir 	WinBits  aWBits = WB_VSCROLL | WB_3DLOOK | WB_BORDER;
605cdf0e10cSrcweir 	sal_uInt16	 nFlags = SVXRULER_SUPPORT_OBJECT;
606cdf0e10cSrcweir 
607cdf0e10cSrcweir 	pRuler = new Ruler(*this, GetParentWindow(), pWin, nFlags,
608cdf0e10cSrcweir         GetViewFrame()->GetBindings(), aWBits);
609cdf0e10cSrcweir 	pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit());
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 	// #96629# Metric same as HRuler, use document setting
612cdf0e10cSrcweir 	sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit();
613cdf0e10cSrcweir 
614cdf0e10cSrcweir 	if( nMetric == 0xffff )
615cdf0e10cSrcweir 		nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit();
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 	pRuler->SetUnit( FieldUnit( nMetric ) );
618cdf0e10cSrcweir 
619cdf0e10cSrcweir 	Fraction aUIScale(pWin->GetMapMode().GetScaleY());
620cdf0e10cSrcweir 	aUIScale *= GetDoc()->GetUIScale();
621cdf0e10cSrcweir 	pRuler->SetZoom(aUIScale);
622cdf0e10cSrcweir 
623cdf0e10cSrcweir 	return pRuler;
624cdf0e10cSrcweir }
625cdf0e10cSrcweir 
626cdf0e10cSrcweir /*************************************************************************
627cdf0e10cSrcweir |*
628cdf0e10cSrcweir |* Horizontales Lineal aktualisieren
629cdf0e10cSrcweir |*
630cdf0e10cSrcweir \************************************************************************/
631cdf0e10cSrcweir 
632cdf0e10cSrcweir void DrawViewShell::UpdateHRuler()
633cdf0e10cSrcweir {
634cdf0e10cSrcweir 	Invalidate( SID_ATTR_LONG_LRSPACE );
635cdf0e10cSrcweir 	Invalidate( SID_RULER_PAGE_POS );
636cdf0e10cSrcweir 	Invalidate( SID_RULER_OBJECT );
637cdf0e10cSrcweir 	Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT );
638cdf0e10cSrcweir 
639cdf0e10cSrcweir     if (mpHorizontalRuler.get() != NULL)
640cdf0e10cSrcweir         mpHorizontalRuler->ForceUpdate();
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
643cdf0e10cSrcweir /*************************************************************************
644cdf0e10cSrcweir |*
645cdf0e10cSrcweir |* Vertikales Lineal aktualisieren
646cdf0e10cSrcweir |*
647cdf0e10cSrcweir \************************************************************************/
648cdf0e10cSrcweir 
649cdf0e10cSrcweir void DrawViewShell::UpdateVRuler()
650cdf0e10cSrcweir {
651cdf0e10cSrcweir 	Invalidate( SID_ATTR_LONG_LRSPACE );
652cdf0e10cSrcweir 	Invalidate( SID_RULER_PAGE_POS );
653cdf0e10cSrcweir 	Invalidate( SID_RULER_OBJECT );
654cdf0e10cSrcweir 
655cdf0e10cSrcweir     if (mpVerticalRuler.get() != NULL)
656cdf0e10cSrcweir         mpVerticalRuler->ForceUpdate();
657cdf0e10cSrcweir }
658cdf0e10cSrcweir 
659cdf0e10cSrcweir /*************************************************************************
660cdf0e10cSrcweir |*
661cdf0e10cSrcweir |* Metrik setzen
662cdf0e10cSrcweir |*
663cdf0e10cSrcweir \************************************************************************/
664cdf0e10cSrcweir 
665cdf0e10cSrcweir void DrawViewShell::SetUIUnit(FieldUnit eUnit)
666cdf0e10cSrcweir {
667cdf0e10cSrcweir 	ViewShell::SetUIUnit(eUnit);
668cdf0e10cSrcweir }
669cdf0e10cSrcweir 
670cdf0e10cSrcweir /*************************************************************************
671cdf0e10cSrcweir |*
672cdf0e10cSrcweir |* TabControl nach Splitteraenderung aktualisieren
673cdf0e10cSrcweir |*
674cdf0e10cSrcweir \************************************************************************/
675cdf0e10cSrcweir 
676cdf0e10cSrcweir IMPL_LINK( DrawViewShell, TabSplitHdl, TabBar *, pTab )
677cdf0e10cSrcweir {
678cdf0e10cSrcweir     const long int nMax = maViewSize.Width() - maScrBarWH.Width()
679cdf0e10cSrcweir         - maTabControl.GetPosPixel().X() ;
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 	Size aTabSize = maTabControl.GetSizePixel();
682cdf0e10cSrcweir 	aTabSize.Width() = Min(pTab->GetSplitSize(), (long)(nMax-1));
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 	maTabControl.SetSizePixel(aTabSize);
685cdf0e10cSrcweir 	GetLayerTabControl()->SetSizePixel(aTabSize);
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 	Point aPos = maTabControl.GetPosPixel();
688cdf0e10cSrcweir 	aPos.X() += aTabSize.Width();
689cdf0e10cSrcweir 
690cdf0e10cSrcweir 	Size aScrSize(nMax - aTabSize.Width(), maScrBarWH.Height());
691cdf0e10cSrcweir 	mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 	return 0;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir 
696cdf0e10cSrcweir /// inherited from sd::ViewShell
697cdf0e10cSrcweir SdPage* DrawViewShell::getCurrentPage() const
698cdf0e10cSrcweir {
699cdf0e10cSrcweir 	const sal_Int32 nPageCount = (meEditMode == EM_PAGE)?
700cdf0e10cSrcweir 									GetDoc()->GetSdPageCount(mePageKind):
701cdf0e10cSrcweir 									GetDoc()->GetMasterSdPageCount(mePageKind);
702cdf0e10cSrcweir 
703cdf0e10cSrcweir 	sal_Int32 nCurrentPage = maTabControl.GetCurPageId() - 1;
704cdf0e10cSrcweir 	DBG_ASSERT( (nPageCount>0) && (nCurrentPage<nPageCount), "sd::DrawViewShell::getCurrentPage(), illegal page index!" );
705cdf0e10cSrcweir 	if( (nPageCount < 0) || (nCurrentPage>=nPageCount) )
706cdf0e10cSrcweir 		nCurrentPage = 0; // play safe here
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 	if (meEditMode == EM_PAGE)
709cdf0e10cSrcweir 	{
710cdf0e10cSrcweir 		return GetDoc()->GetSdPage((sal_uInt16)nCurrentPage, mePageKind);
711cdf0e10cSrcweir 	}
712cdf0e10cSrcweir 	else // EM_MASTERPAGE
713cdf0e10cSrcweir 	{
714cdf0e10cSrcweir 		return GetDoc()->GetMasterSdPage((sal_uInt16)nCurrentPage, mePageKind);
715cdf0e10cSrcweir 	}
716cdf0e10cSrcweir }
717cdf0e10cSrcweir 
718cdf0e10cSrcweir /*************************************************************************
719cdf0e10cSrcweir |*
720cdf0e10cSrcweir |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert
721cdf0e10cSrcweir |* hat (z. B. durch Undo)
722cdf0e10cSrcweir |*
723cdf0e10cSrcweir \************************************************************************/
724cdf0e10cSrcweir 
725cdf0e10cSrcweir void DrawViewShell::ResetActualPage()
726cdf0e10cSrcweir {
727cdf0e10cSrcweir 	sal_uInt16 nCurrentPage = maTabControl.GetCurPageId() - 1;
728cdf0e10cSrcweir 	sal_uInt16 nPageCount	= (meEditMode == EM_PAGE)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind);
729cdf0e10cSrcweir 	if (nPageCount > 0)
730cdf0e10cSrcweir 		nCurrentPage = Min((sal_uInt16)(nPageCount - 1), nCurrentPage);
731cdf0e10cSrcweir 	else
732cdf0e10cSrcweir 		nCurrentPage = 0;
733cdf0e10cSrcweir 
734cdf0e10cSrcweir 	if (meEditMode == EM_PAGE)
735cdf0e10cSrcweir 	{
736cdf0e10cSrcweir 
737cdf0e10cSrcweir 		// Update fuer TabControl
738cdf0e10cSrcweir 		maTabControl.Clear();
739cdf0e10cSrcweir 
740cdf0e10cSrcweir 		SdPage* pPage = NULL;
741cdf0e10cSrcweir 		String aPageName;
742cdf0e10cSrcweir 
743cdf0e10cSrcweir 		for (sal_uInt16 i = 0; i < nPageCount; i++)
744cdf0e10cSrcweir 		{
745cdf0e10cSrcweir 			pPage = GetDoc()->GetSdPage(i, mePageKind);
746cdf0e10cSrcweir 			aPageName = pPage->GetName();
747cdf0e10cSrcweir 			maTabControl.InsertPage(i + 1, aPageName);
748cdf0e10cSrcweir 
749cdf0e10cSrcweir 			// Selektionskennungen der Seiten korrigieren
750cdf0e10cSrcweir 			GetDoc()->SetSelected(pPage, i == nCurrentPage);
751cdf0e10cSrcweir 		}
752cdf0e10cSrcweir 
753cdf0e10cSrcweir 		maTabControl.SetCurPageId(nCurrentPage + 1);
754cdf0e10cSrcweir 	}
755cdf0e10cSrcweir 	else // EM_MASTERPAGE
756cdf0e10cSrcweir 	{
757cdf0e10cSrcweir 		SdPage* pActualPage = GetDoc()->GetMasterSdPage(nCurrentPage, mePageKind);
758cdf0e10cSrcweir 		maTabControl.Clear();
759cdf0e10cSrcweir 		sal_uInt16 nActualMasterPageNum = 0;
760cdf0e10cSrcweir 
761cdf0e10cSrcweir 		sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
762cdf0e10cSrcweir 		for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
763cdf0e10cSrcweir 		{
764cdf0e10cSrcweir 			SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
765cdf0e10cSrcweir 			String aLayoutName(pMaster->GetLayoutName());
766cdf0e10cSrcweir 			aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
767cdf0e10cSrcweir 			maTabControl.InsertPage(i + 1, aLayoutName);
768cdf0e10cSrcweir 
769cdf0e10cSrcweir 			if (pActualPage == pMaster)
770cdf0e10cSrcweir 				nActualMasterPageNum = i;
771cdf0e10cSrcweir 		}
772cdf0e10cSrcweir 
773cdf0e10cSrcweir 		maTabControl.SetCurPageId(nActualMasterPageNum + 1);
774cdf0e10cSrcweir 		SwitchPage(nActualMasterPageNum);
775cdf0e10cSrcweir 	}
776cdf0e10cSrcweir 
777cdf0e10cSrcweir 	GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
778cdf0e10cSrcweir 				SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
779cdf0e10cSrcweir }
780cdf0e10cSrcweir 
781cdf0e10cSrcweir /*************************************************************************
782cdf0e10cSrcweir |*
783cdf0e10cSrcweir |* Verb auf OLE-Objekt anwenden
784cdf0e10cSrcweir |*
785cdf0e10cSrcweir \************************************************************************/
786cdf0e10cSrcweir 
787cdf0e10cSrcweir 
788cdf0e10cSrcweir ErrCode DrawViewShell::DoVerb(long nVerb)
789cdf0e10cSrcweir {
790cdf0e10cSrcweir 	if ( mpDrawView->AreObjectsMarked() )
791cdf0e10cSrcweir 	{
792cdf0e10cSrcweir 		const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
793cdf0e10cSrcweir 
794cdf0e10cSrcweir 		if (rMarkList.GetMarkCount() == 1)
795cdf0e10cSrcweir 		{
796cdf0e10cSrcweir 			SdrMark* pMark = rMarkList.GetMark(0);
797cdf0e10cSrcweir 			SdrObject* pObj = pMark->GetMarkedSdrObj();
798cdf0e10cSrcweir 
799cdf0e10cSrcweir 			sal_uInt32 nInv = pObj->GetObjInventor();
800cdf0e10cSrcweir 			sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 			if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
803cdf0e10cSrcweir 			{
804cdf0e10cSrcweir 				ActivateObject( (SdrOle2Obj*) pObj, nVerb);
805cdf0e10cSrcweir 			}
806cdf0e10cSrcweir #ifdef STARIMAGE_AVAILABLE
807cdf0e10cSrcweir 			else if (nInv = SdrInventor && nSdrObjKind == OBJ_GRAF &&
808cdf0e10cSrcweir 					 ((SdrGrafObj*) pObj)->GetGraphicType() == GRAPHIC_BITMAP &&
809cdf0e10cSrcweir 					 SFX_APP()->HasFeature(SFX_FEATURE_SIMAGE))
810cdf0e10cSrcweir 			{
811cdf0e10cSrcweir 				SdrGrafObj* pSdrGrafObj = (SdrGrafObj*) pObj;
812cdf0e10cSrcweir 				short nOK = RET_YES;
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 				if ( pSdrGrafObj->GetFileName().Len() )
815cdf0e10cSrcweir 				{
816cdf0e10cSrcweir 					// Graphik ist gelinkt, soll der Link aufgehoben werden?
817cdf0e10cSrcweir 					QueryBox aBox(pWindow, WB_YES_NO | WB_DEF_YES,
818cdf0e10cSrcweir 								  String( SdResId(STR_REMOVE_LINK) ) );
819cdf0e10cSrcweir 					nOK = aBox.Execute();
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 					if (nOK == RET_YES)
822cdf0e10cSrcweir 					{
823cdf0e10cSrcweir 						// Link aufheben (File- und Filtername zuruecksetzen)
824cdf0e10cSrcweir 						pSdrGrafObj->SetGraphicLink(String(), String());
825cdf0e10cSrcweir 					}
826cdf0e10cSrcweir 				}
827cdf0e10cSrcweir 
828cdf0e10cSrcweir 				if (nOK == RET_YES)
829cdf0e10cSrcweir 				{
830cdf0e10cSrcweir 					/**************************************************************
831cdf0e10cSrcweir 					* OLE-Objekt erzeugen, StarImage starten
832cdf0e10cSrcweir 					* Grafik-Objekt loeschen (durch OLE-Objekt ersetzt)
833cdf0e10cSrcweir 					**************************************************************/
834cdf0e10cSrcweir 					//HMHmpDrView->HideMarkHdl();
835cdf0e10cSrcweir 
836cdf0e10cSrcweir 					SvStorageRef aStor = new SvStorage(String());
837cdf0e10cSrcweir 					SvInPlaceObjectRef aNewIPObj = &((SvFactory*)SvInPlaceObject::ClassFactory())
838cdf0e10cSrcweir 					->CreateAndInit(SimModuleDummy::GetID(SOFFICE_FILEFORMAT_CURRENT), aStor);
839cdf0e10cSrcweir 					if ( aNewIPObj.Is() )
840cdf0e10cSrcweir 					{
841cdf0e10cSrcweir 						SdrGrafObj* pTempSdrGrafObj = (SdrGrafObj*) pSdrGrafObj->Clone ();
842cdf0e10cSrcweir 
843cdf0e10cSrcweir 						SvEmbeddedInfoObject * pInfo;
844cdf0e10cSrcweir 						pInfo = GetViewFrame()->GetObjectShell()->
845cdf0e10cSrcweir 									   InsertObject( aNewIPObj, String() );
846cdf0e10cSrcweir 
847cdf0e10cSrcweir 						String aName;
848cdf0e10cSrcweir 						if (pInfo)
849cdf0e10cSrcweir 						{
850cdf0e10cSrcweir 							aName = pInfo->GetObjName();
851cdf0e10cSrcweir 						}
852cdf0e10cSrcweir 
853cdf0e10cSrcweir 						Rectangle aRect = pObj->GetLogicRect();
854cdf0e10cSrcweir 						SdrOle2Obj* pSdrOle2Obj = new SdrOle2Obj( aNewIPObj,
855cdf0e10cSrcweir 																  aName, aRect );
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 						SdrPageView* pPV = mpDrawView->GetSdrPageView();
858cdf0e10cSrcweir 
859cdf0e10cSrcweir 						pPV->GetObjList()->InsertObject( pSdrOle2Obj );
860cdf0e10cSrcweir 						mpDrawView->ReplaceObjectAtView( pObj, *pPV, pTempSdrGrafObj );
861cdf0e10cSrcweir 
862cdf0e10cSrcweir 						pSdrOle2Obj->SetLogicRect(aRect);
863cdf0e10cSrcweir 						aNewIPObj->SetVisAreaSize(aRect.GetSize());
864cdf0e10cSrcweir 
865cdf0e10cSrcweir 						SimDLL::Update(aNewIPObj, pTempSdrGrafObj->GetGraphic(), pWindow);
866cdf0e10cSrcweir 						ActivateObject(pSdrOle2Obj, SVVERB_SHOW);
867cdf0e10cSrcweir 
868cdf0e10cSrcweir 						Client* pClient = (Client*) GetIPClient();
869cdf0e10cSrcweir 
870cdf0e10cSrcweir 						if (pClient)
871cdf0e10cSrcweir 							pClient->SetSdrGrafObj( pTempSdrGrafObj );
872cdf0e10cSrcweir 					}
873cdf0e10cSrcweir 				}
874cdf0e10cSrcweir 			}
875cdf0e10cSrcweir #endif
876cdf0e10cSrcweir 		}
877cdf0e10cSrcweir 	}
878cdf0e10cSrcweir 
879cdf0e10cSrcweir 	return 0;
880cdf0e10cSrcweir }
881cdf0e10cSrcweir 
882cdf0e10cSrcweir 
883cdf0e10cSrcweir /*************************************************************************
884cdf0e10cSrcweir |*
885cdf0e10cSrcweir |* OLE-Object aktivieren
886cdf0e10cSrcweir |*
887cdf0e10cSrcweir \************************************************************************/
888cdf0e10cSrcweir 
889cdf0e10cSrcweir sal_Bool DrawViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb)
890cdf0e10cSrcweir {
891cdf0e10cSrcweir 	sal_Bool bActivated = sal_False;
892cdf0e10cSrcweir 
893cdf0e10cSrcweir 	if ( !GetDocSh()->IsUIActive() )
894cdf0e10cSrcweir 	{
895cdf0e10cSrcweir         ToolBarManager::UpdateLock aLock (GetViewShellBase().GetToolBarManager());
896cdf0e10cSrcweir 
897cdf0e10cSrcweir 		bActivated = ViewShell::ActivateObject(pObj, nVerb);
898cdf0e10cSrcweir 
899cdf0e10cSrcweir         OSL_ASSERT(GetViewShell()!=NULL);
900cdf0e10cSrcweir         Client* pClient = static_cast<Client*>(GetViewShell()->GetIPClient());
901cdf0e10cSrcweir 		if (pClient)
902cdf0e10cSrcweir 			pClient->SetSdrGrafObj(NULL);
903cdf0e10cSrcweir 	}
904cdf0e10cSrcweir 
905cdf0e10cSrcweir 	return(bActivated);
906cdf0e10cSrcweir }
907cdf0e10cSrcweir 
908cdf0e10cSrcweir /*************************************************************************
909cdf0e10cSrcweir |*
910cdf0e10cSrcweir |* Auf gewuenschte Seite schalten
911cdf0e10cSrcweir |* Der Parameter nSelectedPage bezieht sich auf den aktuellen EditMode
912cdf0e10cSrcweir |*
913cdf0e10cSrcweir \************************************************************************/
914cdf0e10cSrcweir 
915cdf0e10cSrcweir void LclResetFlag (bool& rbFlag) {rbFlag = false;}
916cdf0e10cSrcweir 
917cdf0e10cSrcweir sal_Bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
918cdf0e10cSrcweir {
919cdf0e10cSrcweir     /** Under some circumstances there are nested calls to SwitchPage() and
920cdf0e10cSrcweir         may crash the application (activation of form controls when the
921cdf0e10cSrcweir         shell of the edit view is not on top of the shell stack, see issue
922cdf0e10cSrcweir         83888 for details.)  Therefore the nested calls are ignored (they
923cdf0e10cSrcweir         would jump to the wrong page anyway.)
924cdf0e10cSrcweir     */
925cdf0e10cSrcweir     if (mbIsInSwitchPage)
926cdf0e10cSrcweir         return sal_False;
927cdf0e10cSrcweir     mbIsInSwitchPage = true;
928cdf0e10cSrcweir     comphelper::ScopeGuard aGuard (::boost::bind(LclResetFlag, ::boost::ref(mbIsInSwitchPage)));
929cdf0e10cSrcweir 
930cdf0e10cSrcweir     if (GetActiveWindow()->IsInPaint())
931cdf0e10cSrcweir     {
932cdf0e10cSrcweir         // Switching the current page while a Paint is being executed is
933cdf0e10cSrcweir         // dangerous.  So, post it for later execution and return.
934cdf0e10cSrcweir         maAsynchronousSwitchPageCall.Post(::boost::bind(
935cdf0e10cSrcweir             ::std::mem_fun(&DrawViewShell::SwitchPage),
936cdf0e10cSrcweir             this,
937cdf0e10cSrcweir             nSelectedPage));
938cdf0e10cSrcweir         return sal_False;
939cdf0e10cSrcweir     }
940cdf0e10cSrcweir 
941cdf0e10cSrcweir 	sal_Bool bOK = sal_False;
942cdf0e10cSrcweir 
943cdf0e10cSrcweir     // With the current implementation of FuSlideShow there is a problem
944cdf0e10cSrcweir     // when it dsplays the show in a window: When the show is stopped it
945cdf0e10cSrcweir     // returns at one point in time SDRPAGE_NOTFOUND as current page index.
946cdf0e10cSrcweir     // Because FuSlideShow is currently being rewritten this bug is fixed
947cdf0e10cSrcweir     // here.
948cdf0e10cSrcweir     // This is not as bad a hack as it may look because making SwitchPage()
949cdf0e10cSrcweir     // more robust with respect to invalid page numbers is a good thing
950cdf0e10cSrcweir     // anyway.
951cdf0e10cSrcweir     if (nSelectedPage == SDRPAGE_NOTFOUND)
952cdf0e10cSrcweir 	{
953cdf0e10cSrcweir         nSelectedPage = 0;
954cdf0e10cSrcweir 	}
955cdf0e10cSrcweir 	else
956cdf0e10cSrcweir 	{
957cdf0e10cSrcweir 	    // Make sure that the given page index points to an existing page.  Move
958cdf0e10cSrcweir 		// the index into the valid range if necessary.
959cdf0e10cSrcweir 		sal_uInt16 nPageCount = (meEditMode == EM_PAGE)
960cdf0e10cSrcweir 			? GetDoc()->GetSdPageCount(mePageKind)
961cdf0e10cSrcweir 			: GetDoc()->GetMasterSdPageCount(mePageKind);
962cdf0e10cSrcweir 		if (nSelectedPage >= nPageCount)
963cdf0e10cSrcweir 			nSelectedPage = nPageCount-1;
964cdf0e10cSrcweir 	}
965cdf0e10cSrcweir 
966cdf0e10cSrcweir 	if (IsSwitchPageAllowed())
967cdf0e10cSrcweir 	{
968cdf0e10cSrcweir 		ModifyGuard aGuard2( GetDoc() );
969cdf0e10cSrcweir 
970cdf0e10cSrcweir 		bOK = sal_True;
971cdf0e10cSrcweir 
972cdf0e10cSrcweir 		if (mpActualPage)
973cdf0e10cSrcweir 		{
974cdf0e10cSrcweir             SdPage* pNewPage = NULL;
975cdf0e10cSrcweir 
976cdf0e10cSrcweir 			if (meEditMode == EM_MASTERPAGE)
977cdf0e10cSrcweir 			{
978cdf0e10cSrcweir 				if( GetDoc()->GetMasterSdPageCount(mePageKind) > nSelectedPage )
979cdf0e10cSrcweir 					pNewPage = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
980cdf0e10cSrcweir 
981cdf0e10cSrcweir 				if( pNewPage )
982cdf0e10cSrcweir 				{
983cdf0e10cSrcweir 					SdrPageView* pPV = mpDrawView->GetSdrPageView();
984cdf0e10cSrcweir 
985cdf0e10cSrcweir                     String sPageText (pNewPage->GetLayoutName());
986cdf0e10cSrcweir                     sPageText.Erase(sPageText.SearchAscii(SD_LT_SEPARATOR));
987cdf0e10cSrcweir 					if (pPV
988cdf0e10cSrcweir                         && pNewPage == dynamic_cast< SdPage* >( pPV->GetPage() )
989cdf0e10cSrcweir                         && sPageText == maTabControl.GetPageText(nSelectedPage+1))
990cdf0e10cSrcweir 					{
991cdf0e10cSrcweir 						// this slide is already visible
992cdf0e10cSrcweir 						return sal_True;
993cdf0e10cSrcweir 					}
994cdf0e10cSrcweir 				}
995cdf0e10cSrcweir 			}
996cdf0e10cSrcweir 			else
997cdf0e10cSrcweir 			{
998cdf0e10cSrcweir                 OSL_ASSERT(mpFrameView!=NULL);
999cdf0e10cSrcweir                 mpFrameView->SetSelectedPage(nSelectedPage);
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir 				if (GetDoc()->GetSdPageCount(mePageKind) > nSelectedPage)
1002cdf0e10cSrcweir 					pNewPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 				if (mpActualPage == pNewPage)
1005cdf0e10cSrcweir 				{
1006cdf0e10cSrcweir 					SdrPageView* pPV = mpDrawView->GetSdrPageView();
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir                     SdPage* pCurrentPage = dynamic_cast< SdPage* >( pPV->GetPage());
1009cdf0e10cSrcweir                     if (pPV
1010cdf0e10cSrcweir                         && pNewPage == pCurrentPage
1011cdf0e10cSrcweir                         && pNewPage->GetName() == maTabControl.GetPageText(nSelectedPage+1))
1012cdf0e10cSrcweir 					{
1013cdf0e10cSrcweir 						// this slide is already visible
1014cdf0e10cSrcweir 						return sal_True;
1015cdf0e10cSrcweir 					}
1016cdf0e10cSrcweir 				}
1017cdf0e10cSrcweir 			}
1018cdf0e10cSrcweir 		}
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 		if( mpDrawView )
1021cdf0e10cSrcweir 			mpDrawView->SdrEndTextEdit();
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir 		mpActualPage = NULL;
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir 		if (meEditMode == EM_PAGE)
1026cdf0e10cSrcweir 		{
1027cdf0e10cSrcweir 			mpActualPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
1028cdf0e10cSrcweir 		}
1029cdf0e10cSrcweir 		else
1030cdf0e10cSrcweir 		{
1031cdf0e10cSrcweir 			SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir 			// Passt die selektierte Seite zur MasterPage?
1034cdf0e10cSrcweir 			sal_uInt16 nPageCount = GetDoc()->GetSdPageCount(mePageKind);
1035cdf0e10cSrcweir 			for (sal_uInt16 i = 0; i < nPageCount; i++)
1036cdf0e10cSrcweir 			{
1037cdf0e10cSrcweir 				SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
1038cdf0e10cSrcweir 				if(pPage && pPage->IsSelected() && pMaster == &(pPage->TRG_GetMasterPage()))
1039cdf0e10cSrcweir 				{
1040cdf0e10cSrcweir 					mpActualPage = pPage;
1041cdf0e10cSrcweir 					break;
1042cdf0e10cSrcweir 				}
1043cdf0e10cSrcweir 			}
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir 			if (!mpActualPage)
1046cdf0e10cSrcweir 			{
1047cdf0e10cSrcweir 				// Die erste Seite nehmen, welche zur MasterPage passt
1048cdf0e10cSrcweir 				for (sal_uInt16 i = 0; i < nPageCount; i++)
1049cdf0e10cSrcweir 				{
1050cdf0e10cSrcweir 					SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
1051cdf0e10cSrcweir 					if(pPage && pMaster == &(pPage->TRG_GetMasterPage()))
1052cdf0e10cSrcweir 					{
1053cdf0e10cSrcweir 						mpActualPage = pPage;
1054cdf0e10cSrcweir 						break;
1055cdf0e10cSrcweir 					}
1056cdf0e10cSrcweir 				}
1057cdf0e10cSrcweir 			}
1058cdf0e10cSrcweir 		}
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 		for (sal_uInt16 i = 0; i < GetDoc()->GetSdPageCount(mePageKind); i++)
1061cdf0e10cSrcweir 		{
1062cdf0e10cSrcweir 			// Alle Seiten deselektieren
1063cdf0e10cSrcweir 			GetDoc()->SetSelected( GetDoc()->GetSdPage(i, mePageKind), sal_False);
1064cdf0e10cSrcweir 		}
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir 		if (!mpActualPage)
1067cdf0e10cSrcweir 		{
1068cdf0e10cSrcweir 			// Sofern es keine mpActualPage gibt, wird die erste genommen
1069cdf0e10cSrcweir 			mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
1070cdf0e10cSrcweir 		}
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir 		// diese Seite auch selektieren (mpActualPage zeigt immer auf Zeichenseite,
1073cdf0e10cSrcweir 		// nie auf eine Masterpage)
1074cdf0e10cSrcweir 		GetDoc()->SetSelected(mpActualPage, sal_True);
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir 		rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
1077cdf0e10cSrcweir         if( !xSlideshow.is() || !xSlideshow->isRunning() || ( xSlideshow->getAnimationMode() != ANIMATIONMODE_SHOW ) )
1078cdf0e10cSrcweir         {
1079cdf0e10cSrcweir     		// VisArea zuziehen, um ggf. Objekte zu deaktivieren
1080cdf0e10cSrcweir             // !!! only if we are not in presentation mode (#96279) !!!
1081cdf0e10cSrcweir             OSL_ASSERT (GetViewShell()!=NULL);
1082cdf0e10cSrcweir             GetViewShell()->DisconnectAllClients();
1083cdf0e10cSrcweir     		VisAreaChanged(Rectangle(Point(), Size(1, 1)));
1084cdf0e10cSrcweir         }
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir 		if (meEditMode == EM_PAGE)
1087cdf0e10cSrcweir 		{
1088cdf0e10cSrcweir 			/**********************************************************************
1089cdf0e10cSrcweir 			* PAGEMODE
1090cdf0e10cSrcweir 			**********************************************************************/
1091cdf0e10cSrcweir 			GetDoc()->SetSelected(mpActualPage, sal_True);
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir 			SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir 			if (pPageView)
1096cdf0e10cSrcweir 			{
1097cdf0e10cSrcweir 				mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
1098cdf0e10cSrcweir 				mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
1099cdf0e10cSrcweir 				mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir 				if (mePageKind == PK_NOTES)
1102cdf0e10cSrcweir 				{
1103cdf0e10cSrcweir 					mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
1104cdf0e10cSrcweir 				}
1105cdf0e10cSrcweir 				else if (mePageKind == PK_HANDOUT)
1106cdf0e10cSrcweir 				{
1107cdf0e10cSrcweir 					mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
1108cdf0e10cSrcweir 				}
1109cdf0e10cSrcweir 				else
1110cdf0e10cSrcweir 				{
1111cdf0e10cSrcweir 					mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
1112cdf0e10cSrcweir 				}
1113cdf0e10cSrcweir 			}
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir 			mpDrawView->HideSdrPage();
1116cdf0e10cSrcweir 			mpDrawView->ShowSdrPage(mpActualPage);
1117cdf0e10cSrcweir             GetViewShellBase().GetDrawController().FireSwitchCurrentPage(mpActualPage);
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir 			SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir 			if (pNewPageView)
1122cdf0e10cSrcweir 			{
1123cdf0e10cSrcweir 				pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
1124cdf0e10cSrcweir 				pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
1125cdf0e10cSrcweir 				pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir 				if (mePageKind == PK_NOTES)
1128cdf0e10cSrcweir 				{
1129cdf0e10cSrcweir 					pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
1130cdf0e10cSrcweir 				}
1131cdf0e10cSrcweir 				else if (mePageKind == PK_HANDOUT)
1132cdf0e10cSrcweir 				{
1133cdf0e10cSrcweir 					pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
1134cdf0e10cSrcweir 				}
1135cdf0e10cSrcweir 				else
1136cdf0e10cSrcweir 				{
1137cdf0e10cSrcweir 					pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
1138cdf0e10cSrcweir 				}
1139cdf0e10cSrcweir 			}
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir 			maTabControl.SetCurPageId(nSelectedPage+1);
1142cdf0e10cSrcweir 			String aPageName = mpActualPage->GetName();
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir 			if (maTabControl.GetPageText(nSelectedPage+1) != aPageName)
1145cdf0e10cSrcweir 			{
1146cdf0e10cSrcweir 				maTabControl.SetPageText(nSelectedPage+1, aPageName);
1147cdf0e10cSrcweir 			}
1148cdf0e10cSrcweir 		}
1149cdf0e10cSrcweir 		else
1150cdf0e10cSrcweir 		{
1151cdf0e10cSrcweir 			/**********************************************************************
1152cdf0e10cSrcweir 			* MASTERPAGE
1153cdf0e10cSrcweir 			**********************************************************************/
1154cdf0e10cSrcweir 			SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir 			if (pPageView)
1157cdf0e10cSrcweir 			{
1158cdf0e10cSrcweir 				mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
1159cdf0e10cSrcweir 				mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
1160cdf0e10cSrcweir 				mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir 				if (mePageKind == PK_NOTES)
1163cdf0e10cSrcweir 				{
1164cdf0e10cSrcweir 					mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
1165cdf0e10cSrcweir 				}
1166cdf0e10cSrcweir 				else if (mePageKind == PK_HANDOUT)
1167cdf0e10cSrcweir 				{
1168cdf0e10cSrcweir 					mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
1169cdf0e10cSrcweir 				}
1170cdf0e10cSrcweir 				else
1171cdf0e10cSrcweir 				{
1172cdf0e10cSrcweir 					mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
1173cdf0e10cSrcweir 				}
1174cdf0e10cSrcweir 			}
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir 			mpDrawView->HideSdrPage();
1177cdf0e10cSrcweir 
1178cdf0e10cSrcweir 			SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir 			if( !pMaster )              // Falls es diese Page nicht geben sollte
1181cdf0e10cSrcweir 				pMaster = GetDoc()->GetMasterSdPage(0, mePageKind);
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir 			sal_uInt16 nNum = pMaster->GetPageNum();
1184cdf0e10cSrcweir 			mpDrawView->ShowSdrPage(mpDrawView->GetModel()->GetMasterPage(nNum));
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir             GetViewShellBase().GetDrawController().FireSwitchCurrentPage(pMaster);
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir 			SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir 			if (pNewPageView)
1191cdf0e10cSrcweir 			{
1192cdf0e10cSrcweir 				pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
1193cdf0e10cSrcweir 				pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
1194cdf0e10cSrcweir 				pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir 				if (mePageKind == PK_NOTES)
1197cdf0e10cSrcweir 				{
1198cdf0e10cSrcweir 					pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
1199cdf0e10cSrcweir 				}
1200cdf0e10cSrcweir 				else if (mePageKind == PK_HANDOUT)
1201cdf0e10cSrcweir 				{
1202cdf0e10cSrcweir 					pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
1203cdf0e10cSrcweir 				}
1204cdf0e10cSrcweir 				else
1205cdf0e10cSrcweir 				{
1206cdf0e10cSrcweir 					pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
1207cdf0e10cSrcweir 				}
1208cdf0e10cSrcweir 			}
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir 			String aLayoutName(pMaster->GetLayoutName());
1211cdf0e10cSrcweir 			aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir 			maTabControl.SetCurPageId(nSelectedPage+1);
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir 			if (maTabControl.GetPageText(nSelectedPage+1) != aLayoutName)
1216cdf0e10cSrcweir 			{
1217cdf0e10cSrcweir 				maTabControl.SetPageText(nSelectedPage+1, aLayoutName);
1218cdf0e10cSrcweir 			}
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir 			if( mePageKind == PK_HANDOUT )
1221cdf0e10cSrcweir 			{
1222cdf0e10cSrcweir 				// set pages for all available handout presentation objects
1223cdf0e10cSrcweir 				sd::ShapeList& rShapeList = pMaster->GetPresentationShapeList();
1224cdf0e10cSrcweir 				SdrObject* pObj = 0;
1225cdf0e10cSrcweir 
1226cdf0e10cSrcweir                 while( (pObj = rShapeList.getNextShape(pObj)) != 0 )
1227cdf0e10cSrcweir 				{
1228cdf0e10cSrcweir 					if( pMaster->GetPresObjKind(pObj) == PRESOBJ_HANDOUT )
1229cdf0e10cSrcweir 					{
1230cdf0e10cSrcweir                         // #i105146# We want no content to be displayed for PK_HANDOUT,
1231cdf0e10cSrcweir                         // so just never set a page as content
1232cdf0e10cSrcweir 						static_cast<SdrPageObj*>(pObj)->SetReferencedPage(0);
1233cdf0e10cSrcweir 					}
1234cdf0e10cSrcweir 				}
1235cdf0e10cSrcweir 			}
1236cdf0e10cSrcweir 		}
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir 		Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
1239cdf0e10cSrcweir 		Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
1240cdf0e10cSrcweir 		VisAreaChanged(aVisAreaWin);
1241cdf0e10cSrcweir 		mpDrawView->VisAreaChanged(GetActiveWindow());
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir 		// Damit der Navigator (und das Effekte-Window) das mitbekommt (/-men)
1244cdf0e10cSrcweir 		SfxBindings& rBindings = GetViewFrame()->GetBindings();
1245cdf0e10cSrcweir 		rBindings.Invalidate(SID_NAVIGATOR_PAGENAME, sal_True, sal_False);
1246cdf0e10cSrcweir 		rBindings.Invalidate(SID_STATUS_PAGE, sal_True, sal_False);
1247cdf0e10cSrcweir 		rBindings.Invalidate(SID_DELETE_MASTER_PAGE, sal_True, sal_False);
1248cdf0e10cSrcweir 		rBindings.Invalidate(SID_DELETE_PAGE, sal_True, sal_False);
1249cdf0e10cSrcweir 		rBindings.Invalidate(SID_ASSIGN_LAYOUT,sal_True,sal_False);
1250cdf0e10cSrcweir 		rBindings.Invalidate(SID_INSERTPAGE,sal_True,sal_False);
1251cdf0e10cSrcweir 		UpdatePreview( mpActualPage );
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir 		mpDrawView->AdjustMarkHdl();
1254cdf0e10cSrcweir 	}
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir 	return (bOK);
1257cdf0e10cSrcweir }
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir /*************************************************************************
1261cdf0e10cSrcweir |*
1262cdf0e10cSrcweir |* Pruefen, ob ein Seitenwechsel erlaubt ist
1263cdf0e10cSrcweir |*
1264cdf0e10cSrcweir \************************************************************************/
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir sal_Bool DrawViewShell::IsSwitchPageAllowed() const
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir 	bool bOK = true;
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir     FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
1271cdf0e10cSrcweir     if (pFormShell!=NULL && !pFormShell->PrepareClose (sal_False))
1272cdf0e10cSrcweir         bOK = false;
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir 	return bOK;
1275cdf0e10cSrcweir }
1276cdf0e10cSrcweir 
1277cdf0e10cSrcweir /*************************************************************************
1278cdf0e10cSrcweir |*
1279cdf0e10cSrcweir |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert
1280cdf0e10cSrcweir |* hat (z. B. durch Undo)
1281cdf0e10cSrcweir |*
1282cdf0e10cSrcweir \************************************************************************/
1283cdf0e10cSrcweir 
1284cdf0e10cSrcweir void DrawViewShell::ResetActualLayer()
1285cdf0e10cSrcweir {
1286cdf0e10cSrcweir     LayerTabBar* pLayerBar = GetLayerTabControl();
1287cdf0e10cSrcweir     if (pLayerBar != NULL)
1288cdf0e10cSrcweir     {
1289cdf0e10cSrcweir         // remember old layer cound and current layer id
1290cdf0e10cSrcweir         // this is needed when one layer is renamed to
1291cdf0e10cSrcweir         // restore current layer
1292cdf0e10cSrcweir         sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount();
1293cdf0e10cSrcweir         sal_uInt16 nOldLayerId = pLayerBar->GetCurPageId();
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir         /*************************************************************
1296cdf0e10cSrcweir             * Update fuer LayerTab
1297cdf0e10cSrcweir             *************************************************************/
1298cdf0e10cSrcweir         pLayerBar->Clear();
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir         String aName;
1301cdf0e10cSrcweir         String aActiveLayer = mpDrawView->GetActiveLayer();
1302cdf0e10cSrcweir         String aBackgroundLayer( SdResId(STR_LAYER_BCKGRND) );
1303cdf0e10cSrcweir         String aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ) );
1304cdf0e10cSrcweir         String aLayoutLayer( SdResId(STR_LAYER_LAYOUT) );
1305cdf0e10cSrcweir         String aControlsLayer( SdResId(STR_LAYER_CONTROLS) );
1306cdf0e10cSrcweir         String aMeasureLinesLayer( SdResId(STR_LAYER_MEASURELINES) );
1307cdf0e10cSrcweir         sal_uInt16 nActiveLayer = SDRLAYER_NOTFOUND;
1308cdf0e10cSrcweir         SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
1309cdf0e10cSrcweir         sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir         for ( sal_uInt16 nLayer = 0; nLayer < nLayerCnt; nLayer++ )
1312cdf0e10cSrcweir         {
1313cdf0e10cSrcweir             aName = rLayerAdmin.GetLayer(nLayer)->GetName();
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir             if ( aName == aActiveLayer )
1316cdf0e10cSrcweir             {
1317cdf0e10cSrcweir                 nActiveLayer = nLayer;
1318cdf0e10cSrcweir             }
1319cdf0e10cSrcweir 
1320cdf0e10cSrcweir             if ( aName != aBackgroundLayer )
1321cdf0e10cSrcweir             {
1322cdf0e10cSrcweir                 if (meEditMode == EM_MASTERPAGE)
1323cdf0e10cSrcweir                 {
1324cdf0e10cSrcweir                     // Layer der Page nicht auf MasterPage anzeigen
1325cdf0e10cSrcweir                     if (aName != aLayoutLayer   &&
1326cdf0e10cSrcweir                         aName != aControlsLayer &&
1327cdf0e10cSrcweir                         aName != aMeasureLinesLayer)
1328cdf0e10cSrcweir                     {
1329cdf0e10cSrcweir                         pLayerBar->InsertPage(nLayer+1, aName);
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir                         TabBarPageBits nBits = 0;
1332cdf0e10cSrcweir                         SdrPageView* pPV = mpDrawView->GetSdrPageView();
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir                         if (pPV && !pPV->IsLayerVisible(aName))
1335cdf0e10cSrcweir                         {
1336cdf0e10cSrcweir                             // Unsichtbare Layer werden anders dargestellt
1337cdf0e10cSrcweir                             nBits = TPB_SPECIAL;
1338cdf0e10cSrcweir                         }
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir                         pLayerBar->SetPageBits(nLayer+1, nBits);
1341cdf0e10cSrcweir                     }
1342cdf0e10cSrcweir                 }
1343cdf0e10cSrcweir                 else
1344cdf0e10cSrcweir                 {
1345cdf0e10cSrcweir                     // Layer der MasterPage nicht auf Page anzeigen
1346cdf0e10cSrcweir                     if ( aName != aBackgroundObjLayer )
1347cdf0e10cSrcweir                     {
1348cdf0e10cSrcweir                         pLayerBar->InsertPage(nLayer+1, aName);
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir                         TabBarPageBits nBits = 0;
1351cdf0e10cSrcweir 
1352cdf0e10cSrcweir                         if (!mpDrawView->GetSdrPageView()->IsLayerVisible(aName))
1353cdf0e10cSrcweir                         {
1354cdf0e10cSrcweir                             // Unsichtbare Layer werden anders dargestellt
1355cdf0e10cSrcweir                             nBits = TPB_SPECIAL;
1356cdf0e10cSrcweir                         }
1357cdf0e10cSrcweir 
1358cdf0e10cSrcweir                         pLayerBar->SetPageBits(nLayer+1, nBits);
1359cdf0e10cSrcweir                     }
1360cdf0e10cSrcweir                 }
1361cdf0e10cSrcweir             }
1362cdf0e10cSrcweir         }
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir         if ( nActiveLayer == SDRLAYER_NOTFOUND )
1365cdf0e10cSrcweir         {
1366cdf0e10cSrcweir             if( nOldLayerCnt == pLayerBar->GetPageCount() )
1367cdf0e10cSrcweir             {
1368cdf0e10cSrcweir                 nActiveLayer = nOldLayerId - 1;
1369cdf0e10cSrcweir             }
1370cdf0e10cSrcweir             else
1371cdf0e10cSrcweir             {
1372cdf0e10cSrcweir                 nActiveLayer = ( meEditMode == EM_MASTERPAGE ) ? 2 : 0;
1373cdf0e10cSrcweir             }
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir             mpDrawView->SetActiveLayer( pLayerBar->GetPageText(nActiveLayer + 1) );
1376cdf0e10cSrcweir         }
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir         pLayerBar->SetCurPageId(nActiveLayer + 1);
1379cdf0e10cSrcweir         GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER );
1380cdf0e10cSrcweir         GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER );
1381cdf0e10cSrcweir     }
1382cdf0e10cSrcweir }
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir /*************************************************************************
1385cdf0e10cSrcweir |*
1386cdf0e10cSrcweir |* Verzoegertes Close ausfuehren
1387cdf0e10cSrcweir |*
1388cdf0e10cSrcweir \************************************************************************/
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir IMPL_LINK( DrawViewShell, CloseHdl, Timer*, pTimer )
1391cdf0e10cSrcweir {
1392cdf0e10cSrcweir 	pTimer->Stop();
1393cdf0e10cSrcweir 	GetViewFrame()->GetBindings().Execute( SID_CLOSEWIN );
1394cdf0e10cSrcweir 	return 0L;
1395cdf0e10cSrcweir }
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir /*************************************************************************
1398cdf0e10cSrcweir |*
1399cdf0e10cSrcweir |* AcceptDrop
1400cdf0e10cSrcweir |*
1401cdf0e10cSrcweir \************************************************************************/
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir sal_Int8 DrawViewShell::AcceptDrop (
1404cdf0e10cSrcweir     const AcceptDropEvent& rEvt,
1405cdf0e10cSrcweir     DropTargetHelper& rTargetHelper,
1406cdf0e10cSrcweir     ::sd::Window* pTargetWindow,
1407cdf0e10cSrcweir     sal_uInt16 nPage,
1408cdf0e10cSrcweir     sal_uInt16 nLayer )
1409cdf0e10cSrcweir {
1410cdf0e10cSrcweir 	if( nPage != SDRPAGE_NOTFOUND )
1411cdf0e10cSrcweir 		nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir 	if( SlideShow::IsRunning( GetViewShellBase() ) )
1414cdf0e10cSrcweir 		return DND_ACTION_NONE;
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir 	return mpDrawView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer );
1417cdf0e10cSrcweir }
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir /*************************************************************************
1420cdf0e10cSrcweir |*
1421cdf0e10cSrcweir |* ExecuteDrop
1422cdf0e10cSrcweir |*
1423cdf0e10cSrcweir \************************************************************************/
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir sal_Int8 DrawViewShell::ExecuteDrop (
1426cdf0e10cSrcweir     const ExecuteDropEvent& rEvt,
1427cdf0e10cSrcweir     DropTargetHelper& rTargetHelper,
1428cdf0e10cSrcweir     ::sd::Window* pTargetWindow,
1429cdf0e10cSrcweir     sal_uInt16 nPage,
1430cdf0e10cSrcweir     sal_uInt16 nLayer)
1431cdf0e10cSrcweir {
1432cdf0e10cSrcweir 	if( nPage != SDRPAGE_NOTFOUND )
1433cdf0e10cSrcweir 		nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir 	if( SlideShow::IsRunning( GetViewShellBase() ) )
1436cdf0e10cSrcweir 		return DND_ACTION_NONE;
1437cdf0e10cSrcweir 
1438cdf0e10cSrcweir     Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START));
1439cdf0e10cSrcweir     sal_Int8 nResult (mpDrawView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ));
1440cdf0e10cSrcweir     Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END));
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir     return nResult;
1443cdf0e10cSrcweir }
1444cdf0e10cSrcweir 
1445cdf0e10cSrcweir } // end of namespace sd
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir #ifdef _MSC_VER
1448cdf0e10cSrcweir #if (_MSC_VER < 1400)
1449cdf0e10cSrcweir #pragma optimize ( "", on )
1450cdf0e10cSrcweir #endif
1451cdf0e10cSrcweir #endif
1452cdf0e10cSrcweir 
1453