xref: /trunk/main/sd/source/ui/view/drviews1.cxx (revision a893be29343ee97512d484e6e8fefa91df2b44cb)
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 
405         if(pLayerBar)
406         {
407             // #87182# only switch activation mode of LayerTabBar when there is one,
408             // else it will not get initialized with the current set of Layers as needed
409             mbIsLayerModeActive = bIsLayerModeActive;
410         }
411 
412         // Determine whether to show the master view toolbar.  The master
413         // page mode has to be active and the shell must not be a handout
414         // view.
415         bool bShowMasterViewToolbar (meEditMode == EM_MASTERPAGE
416              && GetShellType() != ViewShell::ST_HANDOUT);
417 
418         // If the master view toolbar is not shown we hide it before
419         // switching the edit mode.
420         if (::sd::ViewShell::mpImpl->mbIsInitialized
421             && IsMainViewShell()
422             && ! bShowMasterViewToolbar)
423         {
424             GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::TBG_MASTER_MODE);
425         }
426 
427         if (meEditMode == EM_PAGE)
428         {
429             /******************************************************************
430             * PAGEMODE
431             ******************************************************************/
432 
433             maTabControl.Clear();
434 
435             SdPage* pPage;
436             String aPageName;
437             sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
438 
439             for (sal_uInt16 i = 0; i < nPageCnt; i++)
440             {
441                 pPage = GetDoc()->GetSdPage(i, mePageKind);
442                 aPageName = pPage->GetName();
443                 maTabControl.InsertPage(i + 1, aPageName);
444 
445                 if ( pPage->IsSelected() && nActualPageNum == 0 )
446                 {
447                     nActualPageNum = i;
448                 }
449             }
450 
451             maTabControl.SetCurPageId(nActualPageNum + 1);
452 
453             SwitchPage(nActualPageNum);
454         }
455         else
456         {
457             /******************************************************************
458             * MASTERPAGE
459             ******************************************************************/
460             GetViewFrame()->SetChildWindow(
461                 AnimationChildWindow::GetChildWindowId(), sal_False );
462 
463             if (!mpActualPage)
464             {
465                 // Sofern es keine mpActualPage gibt, wird die erste genommen
466                 mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
467             }
468 
469             maTabControl.Clear();
470             sal_uInt16 nActualMasterPageNum = 0;
471             sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
472 
473             for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
474             {
475                 SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
476                 String aLayoutName(pMaster->GetLayoutName());
477                 aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
478 
479                 maTabControl.InsertPage(i + 1, aLayoutName);
480 
481                 if (&(mpActualPage->TRG_GetMasterPage()) == pMaster)
482                 {
483                     nActualMasterPageNum = i;
484                 }
485             }
486 
487             maTabControl.SetCurPageId(nActualMasterPageNum + 1);
488             SwitchPage(nActualMasterPageNum);
489         }
490 
491         // If the master view toolbar is to be shown we turn it on after the
492         // edit mode has been changed.
493         if (::sd::ViewShell::mpImpl->mbIsInitialized
494             && IsMainViewShell()
495             && bShowMasterViewToolbar)
496         {
497             GetViewShellBase().GetToolBarManager()->SetToolBar(
498                 ToolBarManager::TBG_MASTER_MODE,
499                 ToolBarManager::msMasterViewToolBar);
500         }
501 
502         if ( ! mbIsLayerModeActive)
503         {
504             maTabControl.Show();
505             // Set the tab control only for draw pages.  For master page
506             // this has been done already above.
507             if (meEditMode == EM_PAGE)
508                 maTabControl.SetCurPageId (nActualPageNum + 1);
509         }
510         /*AF: The LayerDialogChildWindow is not used anymore (I hope).
511         if (GetViewFrame()->KnowsChildWindow(
512             LayerDialogChildWindow::GetChildWindowId()))
513         {
514             GetViewFrame()->SetChildWindow(
515                 LayerDialogChildWindow::GetChildWindowId(),
516                 IsLayerModeActive());
517         }
518         */
519         ResetActualLayer();
520 
521         Invalidate( SID_PAGEMODE );
522         Invalidate( SID_LAYERMODE );
523         Invalidate( SID_MASTERPAGE );
524         Invalidate( SID_DELETE_MASTER_PAGE );
525         Invalidate( SID_DELETE_PAGE );
526         Invalidate( SID_SLIDE_MASTERPAGE );
527         Invalidate( SID_TITLE_MASTERPAGE );
528         Invalidate( SID_NOTES_MASTERPAGE );
529         Invalidate( SID_HANDOUT_MASTERPAGE );
530 
531         SetContextName(GetSidebarContextName());
532     }
533 }
534 
535 
536 
537 
538 bool DrawViewShell::IsLayerModeActive (void) const
539 {
540     return mbIsLayerModeActive;
541 }
542 
543 
544 
545 
546 /*************************************************************************
547 |*
548 |* Groesse des TabControls und der ModeButtons zurueckgeben
549 |*
550 \************************************************************************/
551 
552 long DrawViewShell::GetHCtrlWidth()
553 {
554     //  return maTabControl.GetSizePixel().Width();
555     return 0;
556 }
557 
558 
559 /*************************************************************************
560 |*
561 |* Horizontales Lineal erzeugen
562 |*
563 \************************************************************************/
564 
565 SvxRuler* DrawViewShell::CreateHRuler (::sd::Window* pWin, sal_Bool bIsFirst)
566 {
567     Ruler* pRuler;
568     WinBits  aWBits;
569     sal_uInt16   nFlags = SVXRULER_SUPPORT_OBJECT;
570 
571     if ( bIsFirst )
572     {
573         aWBits  = WB_HSCROLL | WB_3DLOOK | WB_BORDER | WB_EXTRAFIELD;
574         nFlags |= ( SVXRULER_SUPPORT_SET_NULLOFFSET |
575                     SVXRULER_SUPPORT_TABS |
576                     SVXRULER_SUPPORT_PARAGRAPH_MARGINS ); // Neu
577     }
578     else
579         aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER;
580 
581     pRuler = new Ruler (*this, GetParentWindow(), pWin, nFlags,
582         GetViewFrame()->GetBindings(), aWBits);
583     pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit());
584 
585     // Metric ...
586     sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit();
587 
588     if( nMetric == 0xffff )
589         nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit();
590 
591     pRuler->SetUnit( FieldUnit( nMetric ) );
592 
593     // ... und auch DefTab am Lineal einstellen
594     pRuler->SetDefTabDist( GetDoc()->GetDefaultTabulator() ); // Neu
595 
596     Fraction aUIScale(pWin->GetMapMode().GetScaleX());
597     aUIScale *= GetDoc()->GetUIScale();
598     pRuler->SetZoom(aUIScale);
599 
600     return pRuler;
601 }
602 
603 /*************************************************************************
604 |*
605 |* Vertikales Lineal erzeugen
606 |*
607 \************************************************************************/
608 
609 SvxRuler* DrawViewShell::CreateVRuler(::sd::Window* pWin)
610 {
611     Ruler* pRuler;
612     WinBits  aWBits = WB_VSCROLL | WB_3DLOOK | WB_BORDER;
613     sal_uInt16   nFlags = SVXRULER_SUPPORT_OBJECT;
614 
615     pRuler = new Ruler(*this, GetParentWindow(), pWin, nFlags,
616         GetViewFrame()->GetBindings(), aWBits);
617     pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit());
618 
619     // #96629# Metric same as HRuler, use document setting
620     sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit();
621 
622     if( nMetric == 0xffff )
623         nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit();
624 
625     pRuler->SetUnit( FieldUnit( nMetric ) );
626 
627     Fraction aUIScale(pWin->GetMapMode().GetScaleY());
628     aUIScale *= GetDoc()->GetUIScale();
629     pRuler->SetZoom(aUIScale);
630 
631     return pRuler;
632 }
633 
634 /*************************************************************************
635 |*
636 |* Horizontales Lineal aktualisieren
637 |*
638 \************************************************************************/
639 
640 void DrawViewShell::UpdateHRuler()
641 {
642     Invalidate( SID_ATTR_LONG_LRSPACE );
643     Invalidate( SID_RULER_PAGE_POS );
644     Invalidate( SID_RULER_OBJECT );
645     Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT );
646 
647     if (mpHorizontalRuler.get() != NULL)
648         mpHorizontalRuler->ForceUpdate();
649 }
650 
651 /*************************************************************************
652 |*
653 |* Vertikales Lineal aktualisieren
654 |*
655 \************************************************************************/
656 
657 void DrawViewShell::UpdateVRuler()
658 {
659     Invalidate( SID_ATTR_LONG_LRSPACE );
660     Invalidate( SID_RULER_PAGE_POS );
661     Invalidate( SID_RULER_OBJECT );
662 
663     if (mpVerticalRuler.get() != NULL)
664         mpVerticalRuler->ForceUpdate();
665 }
666 
667 /*************************************************************************
668 |*
669 |* Metrik setzen
670 |*
671 \************************************************************************/
672 
673 void DrawViewShell::SetUIUnit(FieldUnit eUnit)
674 {
675     ViewShell::SetUIUnit(eUnit);
676 }
677 
678 /*************************************************************************
679 |*
680 |* TabControl nach Splitteraenderung aktualisieren
681 |*
682 \************************************************************************/
683 
684 IMPL_LINK( DrawViewShell, TabSplitHdl, TabBar *, pTab )
685 {
686     const long int nMax = maViewSize.Width() - maScrBarWH.Width()
687         - maTabControl.GetPosPixel().X() ;
688 
689     Size aTabSize = maTabControl.GetSizePixel();
690     aTabSize.Width() = Min(pTab->GetSplitSize(), (long)(nMax-1));
691 
692     maTabControl.SetSizePixel(aTabSize);
693 
694     if(GetLayerTabControl()) // #87182#
695     {
696         GetLayerTabControl()->SetSizePixel(aTabSize);
697     }
698 
699     Point aPos = maTabControl.GetPosPixel();
700     aPos.X() += aTabSize.Width();
701 
702     Size aScrSize(nMax - aTabSize.Width(), maScrBarWH.Height());
703     mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
704 
705     return 0;
706 }
707 
708 /// inherited from sd::ViewShell
709 SdPage* DrawViewShell::getCurrentPage() const
710 {
711     const sal_Int32 nPageCount = (meEditMode == EM_PAGE)?
712                                     GetDoc()->GetSdPageCount(mePageKind):
713                                     GetDoc()->GetMasterSdPageCount(mePageKind);
714 
715     sal_Int32 nCurrentPage = maTabControl.GetCurPageId() - 1;
716     DBG_ASSERT( (nPageCount>0) && (nCurrentPage<nPageCount), "sd::DrawViewShell::getCurrentPage(), illegal page index!" );
717     if( (nPageCount < 0) || (nCurrentPage>=nPageCount) )
718         nCurrentPage = 0; // play safe here
719 
720     if (meEditMode == EM_PAGE)
721     {
722         return GetDoc()->GetSdPage((sal_uInt16)nCurrentPage, mePageKind);
723     }
724     else // EM_MASTERPAGE
725     {
726         return GetDoc()->GetMasterSdPage((sal_uInt16)nCurrentPage, mePageKind);
727     }
728 }
729 
730 /*************************************************************************
731 |*
732 |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert
733 |* hat (z. B. durch Undo)
734 |*
735 \************************************************************************/
736 
737 void DrawViewShell::ResetActualPage()
738 {
739     sal_uInt16 nCurrentPage = maTabControl.GetCurPageId() - 1;
740     sal_uInt16 nPageCount   = (meEditMode == EM_PAGE)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind);
741     if (nPageCount > 0)
742         nCurrentPage = Min((sal_uInt16)(nPageCount - 1), nCurrentPage);
743     else
744         nCurrentPage = 0;
745 
746     if (meEditMode == EM_PAGE)
747     {
748 
749         // Update fuer TabControl
750         maTabControl.Clear();
751 
752         SdPage* pPage = NULL;
753         String aPageName;
754 
755         for (sal_uInt16 i = 0; i < nPageCount; i++)
756         {
757             pPage = GetDoc()->GetSdPage(i, mePageKind);
758             aPageName = pPage->GetName();
759             maTabControl.InsertPage(i + 1, aPageName);
760 
761             // Selektionskennungen der Seiten korrigieren
762             GetDoc()->SetSelected(pPage, i == nCurrentPage);
763         }
764 
765         maTabControl.SetCurPageId(nCurrentPage + 1);
766     }
767     else // EM_MASTERPAGE
768     {
769         SdPage* pActualPage = GetDoc()->GetMasterSdPage(nCurrentPage, mePageKind);
770         maTabControl.Clear();
771         sal_uInt16 nActualMasterPageNum = 0;
772 
773         sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
774         for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
775         {
776             SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
777             String aLayoutName(pMaster->GetLayoutName());
778             aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
779             maTabControl.InsertPage(i + 1, aLayoutName);
780 
781             if (pActualPage == pMaster)
782                 nActualMasterPageNum = i;
783         }
784 
785         maTabControl.SetCurPageId(nActualMasterPageNum + 1);
786         SwitchPage(nActualMasterPageNum);
787     }
788 
789     GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
790                 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
791 }
792 
793 /*************************************************************************
794 |*
795 |* Verb auf OLE-Objekt anwenden
796 |*
797 \************************************************************************/
798 
799 
800 ErrCode DrawViewShell::DoVerb(long nVerb)
801 {
802     if ( mpDrawView->AreObjectsMarked() )
803     {
804         const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
805 
806         if (rMarkList.GetMarkCount() == 1)
807         {
808             SdrMark* pMark = rMarkList.GetMark(0);
809             SdrObject* pObj = pMark->GetMarkedSdrObj();
810 
811             sal_uInt32 nInv = pObj->GetObjInventor();
812             sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
813 
814             if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
815             {
816                 ActivateObject( (SdrOle2Obj*) pObj, nVerb);
817             }
818 #ifdef STARIMAGE_AVAILABLE
819             else if (nInv = SdrInventor && nSdrObjKind == OBJ_GRAF &&
820                      ((SdrGrafObj*) pObj)->GetGraphicType() == GRAPHIC_BITMAP &&
821                      SFX_APP()->HasFeature(SFX_FEATURE_SIMAGE))
822             {
823                 SdrGrafObj* pSdrGrafObj = (SdrGrafObj*) pObj;
824                 short nOK = RET_YES;
825 
826                 if ( pSdrGrafObj->GetFileName().Len() )
827                 {
828                     // Graphik ist gelinkt, soll der Link aufgehoben werden?
829                     QueryBox aBox(pWindow, WB_YES_NO | WB_DEF_YES,
830                                   String( SdResId(STR_REMOVE_LINK) ) );
831                     nOK = aBox.Execute();
832 
833                     if (nOK == RET_YES)
834                     {
835                         // Link aufheben (File- und Filtername zuruecksetzen)
836                         pSdrGrafObj->SetGraphicLink(String(), String());
837                     }
838                 }
839 
840                 if (nOK == RET_YES)
841                 {
842                     /**************************************************************
843                     * OLE-Objekt erzeugen, StarImage starten
844                     * Grafik-Objekt loeschen (durch OLE-Objekt ersetzt)
845                     **************************************************************/
846                     //HMHmpDrView->HideMarkHdl();
847 
848                     SvStorageRef aStor = new SvStorage(String());
849                     SvInPlaceObjectRef aNewIPObj = &((SvFactory*)SvInPlaceObject::ClassFactory())
850                     ->CreateAndInit(SimModuleDummy::GetID(SOFFICE_FILEFORMAT_CURRENT), aStor);
851                     if ( aNewIPObj.Is() )
852                     {
853                         SdrGrafObj* pTempSdrGrafObj = (SdrGrafObj*) pSdrGrafObj->Clone ();
854 
855                         SvEmbeddedInfoObject * pInfo;
856                         pInfo = GetViewFrame()->GetObjectShell()->
857                                        InsertObject( aNewIPObj, String() );
858 
859                         String aName;
860                         if (pInfo)
861                         {
862                             aName = pInfo->GetObjName();
863                         }
864 
865                         Rectangle aRect = pObj->GetLogicRect();
866                         SdrOle2Obj* pSdrOle2Obj = new SdrOle2Obj( aNewIPObj,
867                                                                   aName, aRect );
868 
869                         SdrPageView* pPV = mpDrawView->GetSdrPageView();
870 
871                         pPV->GetObjList()->InsertObject( pSdrOle2Obj );
872                         mpDrawView->ReplaceObjectAtView( pObj, *pPV, pTempSdrGrafObj );
873 
874                         pSdrOle2Obj->SetLogicRect(aRect);
875                         aNewIPObj->SetVisAreaSize(aRect.GetSize());
876 
877                         SimDLL::Update(aNewIPObj, pTempSdrGrafObj->GetGraphic(), pWindow);
878                         ActivateObject(pSdrOle2Obj, SVVERB_SHOW);
879 
880                         Client* pClient = (Client*) GetIPClient();
881 
882                         if (pClient)
883                             pClient->SetSdrGrafObj( pTempSdrGrafObj );
884                     }
885                 }
886             }
887 #endif
888         }
889     }
890 
891     return 0;
892 }
893 
894 
895 /*************************************************************************
896 |*
897 |* OLE-Object aktivieren
898 |*
899 \************************************************************************/
900 
901 sal_Bool DrawViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb)
902 {
903     sal_Bool bActivated = sal_False;
904 
905     if ( !GetDocSh()->IsUIActive() )
906     {
907         ToolBarManager::UpdateLock aLock (GetViewShellBase().GetToolBarManager());
908 
909         bActivated = ViewShell::ActivateObject(pObj, nVerb);
910 
911         OSL_ASSERT(GetViewShell()!=NULL);
912         Client* pClient = static_cast<Client*>(GetViewShell()->GetIPClient());
913         if (pClient)
914             pClient->SetSdrGrafObj(NULL);
915     }
916 
917     return(bActivated);
918 }
919 
920 /*************************************************************************
921 |*
922 |* Auf gewuenschte Seite schalten
923 |* Der Parameter nSelectedPage bezieht sich auf den aktuellen EditMode
924 |*
925 \************************************************************************/
926 
927 void LclResetFlag (bool& rbFlag) {rbFlag = false;}
928 
929 sal_Bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
930 {
931     /** Under some circumstances there are nested calls to SwitchPage() and
932         may crash the application (activation of form controls when the
933         shell of the edit view is not on top of the shell stack, see issue
934         83888 for details.)  Therefore the nested calls are ignored (they
935         would jump to the wrong page anyway.)
936     */
937     if (mbIsInSwitchPage)
938         return sal_False;
939     mbIsInSwitchPage = true;
940     comphelper::ScopeGuard aGuard (::boost::bind(LclResetFlag, ::boost::ref(mbIsInSwitchPage)));
941 
942     if (GetActiveWindow()->IsInPaint())
943     {
944         // Switching the current page while a Paint is being executed is
945         // dangerous.  So, post it for later execution and return.
946         maAsynchronousSwitchPageCall.Post(::boost::bind(
947             ::std::mem_fun(&DrawViewShell::SwitchPage),
948             this,
949             nSelectedPage));
950         return sal_False;
951     }
952 
953     sal_Bool bOK = sal_False;
954 
955     // With the current implementation of FuSlideShow there is a problem
956     // when it dsplays the show in a window: When the show is stopped it
957     // returns at one point in time SDRPAGE_NOTFOUND as current page index.
958     // Because FuSlideShow is currently being rewritten this bug is fixed
959     // here.
960     // This is not as bad a hack as it may look because making SwitchPage()
961     // more robust with respect to invalid page numbers is a good thing
962     // anyway.
963     if (nSelectedPage == SDRPAGE_NOTFOUND)
964     {
965         nSelectedPage = 0;
966     }
967     else
968     {
969         // Make sure that the given page index points to an existing page.  Move
970         // the index into the valid range if necessary.
971         sal_uInt16 nPageCount = (meEditMode == EM_PAGE)
972             ? GetDoc()->GetSdPageCount(mePageKind)
973             : GetDoc()->GetMasterSdPageCount(mePageKind);
974         if (nSelectedPage >= nPageCount)
975             nSelectedPage = nPageCount-1;
976     }
977 
978     if (IsSwitchPageAllowed())
979     {
980         ModifyGuard aGuard2( GetDoc() );
981 
982         bOK = sal_True;
983 
984         if (mpActualPage)
985         {
986             SdPage* pNewPage = NULL;
987 
988             if (meEditMode == EM_MASTERPAGE)
989             {
990                 if( GetDoc()->GetMasterSdPageCount(mePageKind) > nSelectedPage )
991                     pNewPage = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
992 
993                 if( pNewPage )
994                 {
995                     SdrPageView* pPV = mpDrawView->GetSdrPageView();
996 
997                     String sPageText (pNewPage->GetLayoutName());
998                     sPageText.Erase(sPageText.SearchAscii(SD_LT_SEPARATOR));
999                     if (pPV
1000                         && pNewPage == dynamic_cast< SdPage* >( pPV->GetPage() )
1001                         && sPageText == maTabControl.GetPageText(nSelectedPage+1))
1002                     {
1003                         // this slide is already visible
1004                         return sal_True;
1005                     }
1006                 }
1007             }
1008             else
1009             {
1010                 OSL_ASSERT(mpFrameView!=NULL);
1011                 mpFrameView->SetSelectedPage(nSelectedPage);
1012 
1013                 if (GetDoc()->GetSdPageCount(mePageKind) > nSelectedPage)
1014                     pNewPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
1015 
1016                 if (mpActualPage == pNewPage)
1017                 {
1018                     SdrPageView* pPV = mpDrawView->GetSdrPageView();
1019 
1020                     SdPage* pCurrentPage = dynamic_cast< SdPage* >( pPV->GetPage());
1021                     if (pPV
1022                         && pNewPage == pCurrentPage
1023                         && pNewPage->GetName() == maTabControl.GetPageText(nSelectedPage+1))
1024                     {
1025                         // this slide is already visible
1026                         return sal_True;
1027                     }
1028                 }
1029             }
1030         }
1031 
1032         if( mpDrawView )
1033             mpDrawView->SdrEndTextEdit();
1034 
1035         mpActualPage = NULL;
1036 
1037         if (meEditMode == EM_PAGE)
1038         {
1039             mpActualPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
1040         }
1041         else
1042         {
1043             SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
1044 
1045             // Passt die selektierte Seite zur MasterPage?
1046             sal_uInt16 nPageCount = GetDoc()->GetSdPageCount(mePageKind);
1047             for (sal_uInt16 i = 0; i < nPageCount; i++)
1048             {
1049                 SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
1050                 if(pPage && pPage->IsSelected() && pMaster == &(pPage->TRG_GetMasterPage()))
1051                 {
1052                     mpActualPage = pPage;
1053                     break;
1054                 }
1055             }
1056 
1057             if (!mpActualPage)
1058             {
1059                 // Die erste Seite nehmen, welche zur MasterPage passt
1060                 for (sal_uInt16 i = 0; i < nPageCount; i++)
1061                 {
1062                     SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
1063                     if(pPage && pMaster == &(pPage->TRG_GetMasterPage()))
1064                     {
1065                         mpActualPage = pPage;
1066                         break;
1067                     }
1068                 }
1069             }
1070         }
1071 
1072         for (sal_uInt16 i = 0; i < GetDoc()->GetSdPageCount(mePageKind); i++)
1073         {
1074             // Alle Seiten deselektieren
1075             GetDoc()->SetSelected( GetDoc()->GetSdPage(i, mePageKind), sal_False);
1076         }
1077 
1078         if (!mpActualPage)
1079         {
1080             // Sofern es keine mpActualPage gibt, wird die erste genommen
1081             mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
1082         }
1083 
1084         // diese Seite auch selektieren (mpActualPage zeigt immer auf Zeichenseite,
1085         // nie auf eine Masterpage)
1086         GetDoc()->SetSelected(mpActualPage, sal_True);
1087 
1088         rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
1089         if( !xSlideshow.is() || !xSlideshow->isRunning() || ( xSlideshow->getAnimationMode() != ANIMATIONMODE_SHOW ) )
1090         {
1091             // VisArea zuziehen, um ggf. Objekte zu deaktivieren
1092             // !!! only if we are not in presentation mode (#96279) !!!
1093             OSL_ASSERT (GetViewShell()!=NULL);
1094             GetViewShell()->DisconnectAllClients();
1095             VisAreaChanged(Rectangle(Point(), Size(1, 1)));
1096         }
1097 
1098         if (meEditMode == EM_PAGE)
1099         {
1100             /**********************************************************************
1101             * PAGEMODE
1102             **********************************************************************/
1103             GetDoc()->SetSelected(mpActualPage, sal_True);
1104 
1105             SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1106 
1107             if (pPageView)
1108             {
1109                 mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
1110                 mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
1111                 mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
1112 
1113                 if (mePageKind == PK_NOTES)
1114                 {
1115                     mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
1116                 }
1117                 else if (mePageKind == PK_HANDOUT)
1118                 {
1119                     mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
1120                 }
1121                 else
1122                 {
1123                     mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
1124                 }
1125             }
1126 
1127             mpDrawView->HideSdrPage();
1128             mpDrawView->ShowSdrPage(mpActualPage);
1129             GetViewShellBase().GetDrawController().FireSwitchCurrentPage(mpActualPage);
1130 
1131             SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
1132 
1133             if (pNewPageView)
1134             {
1135                 pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
1136                 pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
1137                 pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
1138 
1139                 if (mePageKind == PK_NOTES)
1140                 {
1141                     pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
1142                 }
1143                 else if (mePageKind == PK_HANDOUT)
1144                 {
1145                     pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
1146                 }
1147                 else
1148                 {
1149                     pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
1150                 }
1151             }
1152 
1153             maTabControl.SetCurPageId(nSelectedPage+1);
1154             String aPageName = mpActualPage->GetName();
1155 
1156             if (maTabControl.GetPageText(nSelectedPage+1) != aPageName)
1157             {
1158                 maTabControl.SetPageText(nSelectedPage+1, aPageName);
1159             }
1160         }
1161         else
1162         {
1163             /**********************************************************************
1164             * MASTERPAGE
1165             **********************************************************************/
1166             SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1167 
1168             if (pPageView)
1169             {
1170                 mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
1171                 mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
1172                 mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
1173 
1174                 if (mePageKind == PK_NOTES)
1175                 {
1176                     mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
1177                 }
1178                 else if (mePageKind == PK_HANDOUT)
1179                 {
1180                     mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
1181                 }
1182                 else
1183                 {
1184                     mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
1185                 }
1186             }
1187 
1188             mpDrawView->HideSdrPage();
1189 
1190             SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
1191 
1192             if( !pMaster )              // Falls es diese Page nicht geben sollte
1193                 pMaster = GetDoc()->GetMasterSdPage(0, mePageKind);
1194 
1195             sal_uInt16 nNum = pMaster->GetPageNum();
1196             mpDrawView->ShowSdrPage(mpDrawView->GetModel()->GetMasterPage(nNum));
1197 
1198             GetViewShellBase().GetDrawController().FireSwitchCurrentPage(pMaster);
1199 
1200             SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
1201 
1202             if (pNewPageView)
1203             {
1204                 pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
1205                 pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
1206                 pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
1207 
1208                 if (mePageKind == PK_NOTES)
1209                 {
1210                     pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
1211                 }
1212                 else if (mePageKind == PK_HANDOUT)
1213                 {
1214                     pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
1215                 }
1216                 else
1217                 {
1218                     pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
1219                 }
1220             }
1221 
1222             String aLayoutName(pMaster->GetLayoutName());
1223             aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
1224 
1225             maTabControl.SetCurPageId(nSelectedPage+1);
1226 
1227             if (maTabControl.GetPageText(nSelectedPage+1) != aLayoutName)
1228             {
1229                 maTabControl.SetPageText(nSelectedPage+1, aLayoutName);
1230             }
1231 
1232             if( mePageKind == PK_HANDOUT )
1233             {
1234                 // set pages for all available handout presentation objects
1235                 sd::ShapeList& rShapeList = pMaster->GetPresentationShapeList();
1236                 SdrObject* pObj = 0;
1237 
1238                 while( (pObj = rShapeList.getNextShape(pObj)) != 0 )
1239                 {
1240                     if( pMaster->GetPresObjKind(pObj) == PRESOBJ_HANDOUT )
1241                     {
1242                         // #i105146# We want no content to be displayed for PK_HANDOUT,
1243                         // so just never set a page as content
1244                         static_cast<SdrPageObj*>(pObj)->SetReferencedPage(0);
1245                     }
1246                 }
1247             }
1248         }
1249 
1250         Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
1251         Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
1252         VisAreaChanged(aVisAreaWin);
1253         mpDrawView->VisAreaChanged(GetActiveWindow());
1254 
1255         // Damit der Navigator (und das Effekte-Window) das mitbekommt (/-men)
1256         SfxBindings& rBindings = GetViewFrame()->GetBindings();
1257         rBindings.Invalidate(SID_NAVIGATOR_PAGENAME, sal_True, sal_False);
1258         rBindings.Invalidate(SID_STATUS_PAGE, sal_True, sal_False);
1259         rBindings.Invalidate(SID_DELETE_MASTER_PAGE, sal_True, sal_False);
1260         rBindings.Invalidate(SID_DELETE_PAGE, sal_True, sal_False);
1261         rBindings.Invalidate(SID_ASSIGN_LAYOUT,sal_True,sal_False);
1262         rBindings.Invalidate(SID_INSERTPAGE,sal_True,sal_False);
1263         UpdatePreview( mpActualPage );
1264 
1265         mpDrawView->AdjustMarkHdl();
1266     }
1267 
1268     return (bOK);
1269 }
1270 
1271 
1272 /*************************************************************************
1273 |*
1274 |* Pruefen, ob ein Seitenwechsel erlaubt ist
1275 |*
1276 \************************************************************************/
1277 
1278 sal_Bool DrawViewShell::IsSwitchPageAllowed() const
1279 {
1280     bool bOK = true;
1281 
1282     FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
1283     if (pFormShell!=NULL && !pFormShell->PrepareClose (sal_False))
1284         bOK = false;
1285 
1286     return bOK;
1287 }
1288 
1289 /*************************************************************************
1290 |*
1291 |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert
1292 |* hat (z. B. durch Undo)
1293 |*
1294 \************************************************************************/
1295 
1296 void DrawViewShell::ResetActualLayer()
1297 {
1298     LayerTabBar* pLayerBar = GetLayerTabControl();
1299     if (pLayerBar != NULL)
1300     {
1301         // remember old layer cound and current layer id
1302         // this is needed when one layer is renamed to
1303         // restore current layer
1304         sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount();
1305         sal_uInt16 nOldLayerId = pLayerBar->GetCurPageId();
1306 
1307         /*************************************************************
1308             * Update fuer LayerTab
1309             *************************************************************/
1310         pLayerBar->Clear();
1311 
1312         String aName;
1313         String aActiveLayer = mpDrawView->GetActiveLayer();
1314         String aBackgroundLayer( SdResId(STR_LAYER_BCKGRND) );
1315         String aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ) );
1316         String aLayoutLayer( SdResId(STR_LAYER_LAYOUT) );
1317         String aControlsLayer( SdResId(STR_LAYER_CONTROLS) );
1318         String aMeasureLinesLayer( SdResId(STR_LAYER_MEASURELINES) );
1319         sal_uInt16 nActiveLayer = SDRLAYER_NOTFOUND;
1320         SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
1321         sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
1322 
1323         for ( sal_uInt16 nLayer = 0; nLayer < nLayerCnt; nLayer++ )
1324         {
1325             aName = rLayerAdmin.GetLayer(nLayer)->GetName();
1326 
1327             if ( aName == aActiveLayer )
1328             {
1329                 nActiveLayer = nLayer;
1330             }
1331 
1332             if ( aName != aBackgroundLayer )
1333             {
1334                 if (meEditMode == EM_MASTERPAGE)
1335                 {
1336                     // Layer der Page nicht auf MasterPage anzeigen
1337                     if (aName != aLayoutLayer   &&
1338                         aName != aControlsLayer &&
1339                         aName != aMeasureLinesLayer)
1340                     {
1341                         pLayerBar->InsertPage(nLayer+1, aName);
1342 
1343                         TabBarPageBits nBits = 0;
1344                         SdrPageView* pPV = mpDrawView->GetSdrPageView();
1345 
1346                         if (pPV && !pPV->IsLayerVisible(aName))
1347                         {
1348                             // Unsichtbare Layer werden anders dargestellt
1349                             nBits = TPB_SPECIAL;
1350                         }
1351 
1352                         pLayerBar->SetPageBits(nLayer+1, nBits);
1353                     }
1354                 }
1355                 else
1356                 {
1357                     // Layer der MasterPage nicht auf Page anzeigen
1358                     if ( aName != aBackgroundObjLayer )
1359                     {
1360                         pLayerBar->InsertPage(nLayer+1, aName);
1361 
1362                         TabBarPageBits nBits = 0;
1363 
1364                         if (!mpDrawView->GetSdrPageView()->IsLayerVisible(aName))
1365                         {
1366                             // Unsichtbare Layer werden anders dargestellt
1367                             nBits = TPB_SPECIAL;
1368                         }
1369 
1370                         pLayerBar->SetPageBits(nLayer+1, nBits);
1371                     }
1372                 }
1373             }
1374         }
1375 
1376         if ( nActiveLayer == SDRLAYER_NOTFOUND )
1377         {
1378             if( nOldLayerCnt == pLayerBar->GetPageCount() )
1379             {
1380                 nActiveLayer = nOldLayerId - 1;
1381             }
1382             else
1383             {
1384                 nActiveLayer = ( meEditMode == EM_MASTERPAGE ) ? 2 : 0;
1385             }
1386 
1387             mpDrawView->SetActiveLayer( pLayerBar->GetPageText(nActiveLayer + 1) );
1388         }
1389 
1390         pLayerBar->SetCurPageId(nActiveLayer + 1);
1391         GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER );
1392         GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER );
1393     }
1394 }
1395 
1396 /*************************************************************************
1397 |*
1398 |* Verzoegertes Close ausfuehren
1399 |*
1400 \************************************************************************/
1401 
1402 IMPL_LINK( DrawViewShell, CloseHdl, Timer*, pTimer )
1403 {
1404     pTimer->Stop();
1405     GetViewFrame()->GetBindings().Execute( SID_CLOSEWIN );
1406     return 0L;
1407 }
1408 
1409 /*************************************************************************
1410 |*
1411 |* AcceptDrop
1412 |*
1413 \************************************************************************/
1414 
1415 sal_Int8 DrawViewShell::AcceptDrop (
1416     const AcceptDropEvent& rEvt,
1417     DropTargetHelper& rTargetHelper,
1418     ::sd::Window* pTargetWindow,
1419     sal_uInt16 nPage,
1420     sal_uInt16 nLayer )
1421 {
1422     if( nPage != SDRPAGE_NOTFOUND )
1423         nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
1424 
1425     if( SlideShow::IsRunning( GetViewShellBase() ) )
1426         return DND_ACTION_NONE;
1427 
1428     return mpDrawView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer );
1429 }
1430 
1431 /*************************************************************************
1432 |*
1433 |* ExecuteDrop
1434 |*
1435 \************************************************************************/
1436 
1437 sal_Int8 DrawViewShell::ExecuteDrop (
1438     const ExecuteDropEvent& rEvt,
1439     DropTargetHelper& rTargetHelper,
1440     ::sd::Window* pTargetWindow,
1441     sal_uInt16 nPage,
1442     sal_uInt16 nLayer)
1443 {
1444     if( nPage != SDRPAGE_NOTFOUND )
1445         nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
1446 
1447     if( SlideShow::IsRunning( GetViewShellBase() ) )
1448         return DND_ACTION_NONE;
1449 
1450     Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START));
1451     sal_Int8 nResult (mpDrawView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ));
1452     Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END));
1453 
1454     return nResult;
1455 }
1456 
1457 } // end of namespace sd
1458 
1459 #ifdef _MSC_VER
1460 #if (_MSC_VER < 1400)
1461 #pragma optimize ( "", on )
1462 #endif
1463 #endif
1464 
1465