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