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