1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drviews1.cxx,v $
10 * $Revision: 1.79.34.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "DrawViewShell.hxx"
35 #include "ViewShellImplementation.hxx"
37 #include "DrawController.hxx"
38 #include <com/sun/star/embed/EmbedStates.hpp>
40 #include "comphelper/anytostring.hxx"
41 #include "comphelper/scopeguard.hxx"
42 #include "cppuhelper/exc_hlp.hxx"
43 #include "rtl/ref.hxx"
46 #include <svx/svxids.hrc>
48 #include <svx/svdpagv.hxx>
49 #include <sfx2/viewfrm.hxx>
50 #include <sfx2/bindings.hxx>
51 #include <svx/svdoole2.hxx>
52 #include <sfx2/dispatch.hxx>
53 #include <vcl/scrbar.hxx>
54 #include <svx/svdograf.hxx>
55 #include <svx/svdopage.hxx>
56 #include <vcl/msgbox.hxx>
57 #include <sot/storage.hxx>
58 #include <svx/fmshell.hxx>
59 #include <svx/globl3d.hxx>
60 #include <svx/fmglob.hxx>
61 #include <svx/outliner.hxx>
66 #ifdef STARIMAGE_AVAILABLE
68 #include <sim2/simdll.hxx>
72 #include <svx/dialogs.hrc>
76 #include "res_bmp.hrc"
77 #include "strings.hrc"
82 #include "sdresid.hxx"
85 #include "FrameView.hxx"
86 #include "stlpool.hxx"
88 #ifndef SD_DRAWVIEW_HXX
89 #include "drawview.hxx"
91 #include "drawdoc.hxx"
92 #include "DrawDocShell.hxx"
95 #include "slideshow.hxx"
96 #include "optsitem.hxx"
97 #include "fusearch.hxx"
98 #include "fuspell.hxx"
99 #include "Outliner.hxx"
100 #include "AnimationChildWindow.hxx"
101 #include "SdUnoDrawView.hxx"
102 #include "ToolBarManager.hxx"
103 #include "FormShellManager.hxx"
104 #include "ViewShellBase.hxx"
105 #include "LayerDialogChildWindow.hxx"
106 #include "LayerTabBar.hxx"
107 #include "ViewShellManager.hxx"
108 #include "ViewShellHint.hxx"
110 #include <sfx2/request.hxx>
111 #include <boost/bind.hpp>
114 #if (_MSC_VER < 1400)
115 #pragma optimize ( "", off )
119 using namespace com::sun::star
;
123 void DrawViewShell::Activate(BOOL bIsMDIActivate
)
125 ViewShell::Activate(bIsMDIActivate
);
128 void DrawViewShell::UIActivating( SfxInPlaceClient
* pCli
)
130 ViewShell::UIActivating(pCli
);
132 // #94252# Disable own controls
133 maTabControl
.Disable();
134 if (GetLayerTabControl() != NULL
)
135 GetLayerTabControl()->Disable();
138 void DrawViewShell::UIDeactivated( SfxInPlaceClient
* pCli
)
140 // #94252# Enable own controls
141 maTabControl
.Enable();
142 if (GetLayerTabControl() != NULL
)
143 GetLayerTabControl()->Enable();
145 ViewShell::UIDeactivated(pCli
);
149 /*************************************************************************
153 \************************************************************************/
155 void DrawViewShell::Deactivate(BOOL bIsMDIActivate
)
157 ViewShell::Deactivate(bIsMDIActivate
);
160 /*************************************************************************
162 |* Wird gerufen, wenn sich der Selektionszustand der View aendert
164 \************************************************************************/
166 void DrawViewShell::SelectionHasChanged (void)
168 // Um die Performance zu steigern wird jetzt die komplette
169 // Shell invalidiert statt alle Slots einzeln
172 //Update3DWindow(); // 3D-Controller
173 SfxBoolItem
aItem( SID_3D_STATE
, TRUE
);
174 GetViewFrame()->GetDispatcher()->Execute(
175 SID_3D_STATE
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
, &aItem
, 0L );
177 SdrOle2Obj
* pOleObj
= NULL
;
178 SdrGrafObj
* pGrafObj
= NULL
;
180 if ( mpDrawView
->AreObjectsMarked() )
182 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
184 if (rMarkList
.GetMarkCount() == 1)
186 SdrMark
* pMark
= rMarkList
.GetMark(0);
187 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
189 UINT32 nInv
= pObj
->GetObjInventor();
190 UINT16 nSdrObjKind
= pObj
->GetObjIdentifier();
192 if (nInv
== SdrInventor
&& nSdrObjKind
== OBJ_OLE2
)
194 pOleObj
= (SdrOle2Obj
*) pObj
;
195 UpdateIMapDlg( pObj
);
197 else if (nSdrObjKind
== OBJ_GRAF
)
199 pGrafObj
= (SdrGrafObj
*) pObj
;
200 UpdateIMapDlg( pObj
);
205 ViewShellBase
& rBase
= GetViewShellBase();
210 Client
* pIPClient
= static_cast<Client
*>(rBase
.GetIPClient());
211 if ( pIPClient
&& pIPClient
->IsObjectInPlaceActive() )
213 /**********************************************************************
214 * Ggf. OLE-Objekt beruecksichtigen und deaktivieren
215 **********************************************************************/
217 // this means we recently deselected an inplace active ole object so
218 // we need to deselect it now
221 pIPClient
->DeactivateObject();
222 //HMHmpDrView->ShowMarkHdl();
226 uno::Reference
< embed::XEmbeddedObject
> xObj
= pOleObj
->GetObjRef();
229 rBase
.SetVerbs( xObj
->getSupportedVerbs() );
233 rBase
.SetVerbs( uno::Sequence
< embed::VerbDescriptor
>() );
241 uno::Reference
< embed::XEmbeddedObject
> xObj
= pOleObj
->GetObjRef();
244 rBase
.SetVerbs( xObj
->getSupportedVerbs() );
248 rBase
.SetVerbs( uno::Sequence
< embed::VerbDescriptor
>() );
253 rBase
.SetVerbs( uno::Sequence
< embed::VerbDescriptor
>() );
257 catch( ::com::sun::star::uno::Exception
& e
)
261 (rtl::OString("sd::DrawViewShell::SelectionHasChanged(), "
262 "exception caught: ") +
263 rtl::OUStringToOString(
264 comphelper::anyToString( cppu::getCaughtException() ),
265 RTL_TEXTENCODING_UTF8
)).getStr() );
268 if( HasCurrentFunction() )
270 GetCurrentFunction()->SelectionHasChanged();
274 GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView
);
277 // #96124# Invalidate for every subshell
278 GetViewShellBase().GetViewShellManager()->InvalidateAllSubShells(this);
280 mpDrawView
->UpdateSelectionClipboard( FALSE
);
282 GetViewShellBase().GetDrawController().FireSelectionChangeListener();
286 /*************************************************************************
290 \************************************************************************/
292 void DrawViewShell::SetZoom( long nZoom
)
294 // Make sure that the zoom factor will not be recalculated on
295 // following window resizings.
296 mbZoomOnPage
= FALSE
;
297 ViewShell::SetZoom( nZoom
);
298 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM
);
299 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER
);
302 /*************************************************************************
304 |* Zoomrechteck fuer aktives Fenster einstellen
306 \************************************************************************/
308 void DrawViewShell::SetZoomRect( const Rectangle
& rZoomRect
)
310 ViewShell::SetZoomRect( rZoomRect
);
311 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM
);
312 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER
);
315 /*************************************************************************
317 |* PrepareClose, ggfs. Texteingabe beenden, damit andere Viewshells ein
318 |* aktualisiertes Textobjekt vorfinden
320 \************************************************************************/
322 USHORT
DrawViewShell::PrepareClose( BOOL bUI
, BOOL bForBrowsing
)
324 if ( ViewShell::PrepareClose(bUI
, bForBrowsing
) != TRUE
)
329 if( bRet
&& HasCurrentFunction() )
331 USHORT nID
= GetCurrentFunction()->GetSlotID();
332 if (nID
== SID_TEXTEDIT
|| nID
== SID_ATTR_CHAR
)
334 mpDrawView
->SdrEndTextEdit();
339 maCloseTimer
.SetTimeoutHdl( LINK( this, DrawViewShell
, CloseHdl
) );
340 maCloseTimer
.SetTimeout( 20 );
341 maCloseTimer
.Start();
347 /*************************************************************************
349 |* Status (Enabled/Disabled) von Menue-SfxSlots setzen
351 \************************************************************************/
353 void DrawViewShell::ChangeEditMode(EditMode eEMode
, bool bIsLayerModeActive
)
355 if (meEditMode
!= eEMode
|| mbIsLayerModeActive
!= bIsLayerModeActive
)
357 ViewShellManager::UpdateLock
aLock (GetViewShellBase().GetViewShellManager());
359 USHORT nActualPageNum
= 0;
361 GetViewShellBase().GetDrawController().FireChangeEditMode (eEMode
== EM_MASTERPAGE
);
362 GetViewShellBase().GetDrawController().FireChangeLayerMode (bIsLayerModeActive
);
364 if ( mpDrawView
->IsTextEdit() )
366 mpDrawView
->SdrEndTextEdit();
369 LayerTabBar
* pLayerBar
= GetLayerTabControl();
370 if (pLayerBar
!= NULL
)
371 pLayerBar
->EndEditMode();
372 maTabControl
.EndEditMode();
374 if (mePageKind
== PK_HANDOUT
)
376 // Bei Handzetteln nur MasterPage zulassen
377 eEMode
= EM_MASTERPAGE
;
381 mbIsLayerModeActive
= bIsLayerModeActive
;
383 // Determine whether to show the master view toolbar. The master
384 // page mode has to be active and the shell must not be a handout
386 bool bShowMasterViewToolbar (meEditMode
== EM_MASTERPAGE
387 && GetShellType() != ViewShell::ST_HANDOUT
);
389 // If the master view toolbar is not shown we hide it before
390 // switching the edit mode.
391 if (::sd::ViewShell::mpImpl
->mbIsInitialized
393 && ! bShowMasterViewToolbar
)
395 GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::TBG_MASTER_MODE
);
398 if (meEditMode
== EM_PAGE
)
400 /******************************************************************
402 ******************************************************************/
404 maTabControl
.Clear();
408 USHORT nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
410 for (USHORT i
= 0; i
< nPageCnt
; i
++)
412 pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
413 aPageName
= pPage
->GetName();
414 maTabControl
.InsertPage(i
+ 1, aPageName
);
416 if ( pPage
->IsSelected() && nActualPageNum
== 0 )
422 maTabControl
.SetCurPageId(nActualPageNum
+ 1);
424 SwitchPage(nActualPageNum
);
428 /******************************************************************
430 ******************************************************************/
431 GetViewFrame()->SetChildWindow(
432 AnimationChildWindow::GetChildWindowId(), FALSE
);
436 // Sofern es keine mpActualPage gibt, wird die erste genommen
437 mpActualPage
= GetDoc()->GetSdPage(0, mePageKind
);
440 maTabControl
.Clear();
441 USHORT nActualMasterPageNum
= 0;
442 USHORT nMasterPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
444 for (USHORT i
= 0; i
< nMasterPageCnt
; i
++)
446 SdPage
* pMaster
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
447 String
aLayoutName(pMaster
->GetLayoutName());
448 aLayoutName
.Erase(aLayoutName
.SearchAscii(SD_LT_SEPARATOR
));
450 maTabControl
.InsertPage(i
+ 1, aLayoutName
);
452 if (&(mpActualPage
->TRG_GetMasterPage()) == pMaster
)
454 nActualMasterPageNum
= i
;
458 maTabControl
.SetCurPageId(nActualMasterPageNum
+ 1);
459 SwitchPage(nActualMasterPageNum
);
462 // If the master view toolbar is to be shown we turn it on after the
463 // edit mode has been changed.
464 if (::sd::ViewShell::mpImpl
->mbIsInitialized
466 && bShowMasterViewToolbar
)
468 GetViewShellBase().GetToolBarManager()->SetToolBar(
469 ToolBarManager::TBG_MASTER_MODE
,
470 ToolBarManager::msMasterViewToolBar
);
473 if ( ! mbIsLayerModeActive
)
476 // Set the tab control only for draw pages. For master page
477 // this has been done already above.
478 if (meEditMode
== EM_PAGE
)
479 maTabControl
.SetCurPageId (nActualPageNum
+ 1);
481 /*AF: The LayerDialogChildWindow is not used anymore (I hope).
482 if (GetViewFrame()->KnowsChildWindow(
483 LayerDialogChildWindow::GetChildWindowId()))
485 GetViewFrame()->SetChildWindow(
486 LayerDialogChildWindow::GetChildWindowId(),
487 IsLayerModeActive());
492 Invalidate( SID_PAGEMODE
);
493 Invalidate( SID_LAYERMODE
);
494 Invalidate( SID_MASTERPAGE
);
495 Invalidate( SID_SLIDE_MASTERPAGE
);
496 Invalidate( SID_TITLE_MASTERPAGE
);
497 Invalidate( SID_NOTES_MASTERPAGE
);
498 Invalidate( SID_HANDOUT_MASTERPAGE
);
505 bool DrawViewShell::IsLayerModeActive (void) const
507 return mbIsLayerModeActive
;
513 /*************************************************************************
515 |* Groesse des TabControls und der ModeButtons zurueckgeben
517 \************************************************************************/
519 long DrawViewShell::GetHCtrlWidth()
521 // return maTabControl.GetSizePixel().Width();
526 /*************************************************************************
528 |* Horizontales Lineal erzeugen
530 \************************************************************************/
532 SvxRuler
* DrawViewShell::CreateHRuler (::sd::Window
* pWin
, BOOL bIsFirst
)
536 USHORT nFlags
= SVXRULER_SUPPORT_OBJECT
;
540 aWBits
= WB_HSCROLL
| WB_3DLOOK
| WB_BORDER
| WB_EXTRAFIELD
;
541 nFlags
|= ( SVXRULER_SUPPORT_SET_NULLOFFSET
|
542 SVXRULER_SUPPORT_TABS
|
543 SVXRULER_SUPPORT_PARAGRAPH_MARGINS
); // Neu
546 aWBits
= WB_HSCROLL
| WB_3DLOOK
| WB_BORDER
;
548 pRuler
= new Ruler (*this, GetParentWindow(), pWin
, nFlags
,
549 GetViewFrame()->GetBindings(), aWBits
);
550 pRuler
->SetSourceUnit(pWin
->GetMapMode().GetMapUnit());
553 UINT16 nMetric
= (UINT16
)GetDoc()->GetUIUnit();
555 if( nMetric
== 0xffff )
556 nMetric
= (UINT16
)GetModuleFieldUnit();
558 pRuler
->SetUnit( FieldUnit( nMetric
) );
560 // ... und auch DefTab am Lineal einstellen
561 pRuler
->SetDefTabDist( GetDoc()->GetDefaultTabulator() ); // Neu
563 Fraction
aUIScale(pWin
->GetMapMode().GetScaleX());
564 aUIScale
*= GetDoc()->GetUIScale();
565 pRuler
->SetZoom(aUIScale
);
570 /*************************************************************************
572 |* Vertikales Lineal erzeugen
574 \************************************************************************/
576 SvxRuler
* DrawViewShell::CreateVRuler(::sd::Window
* pWin
)
579 WinBits aWBits
= WB_VSCROLL
| WB_3DLOOK
| WB_BORDER
;
580 USHORT nFlags
= SVXRULER_SUPPORT_OBJECT
;
582 pRuler
= new Ruler(*this, GetParentWindow(), pWin
, nFlags
,
583 GetViewFrame()->GetBindings(), aWBits
);
584 pRuler
->SetSourceUnit(pWin
->GetMapMode().GetMapUnit());
586 // #96629# Metric same as HRuler, use document setting
587 UINT16 nMetric
= (UINT16
)GetDoc()->GetUIUnit();
589 if( nMetric
== 0xffff )
590 nMetric
= (UINT16
)GetModuleFieldUnit();
592 pRuler
->SetUnit( FieldUnit( nMetric
) );
594 Fraction
aUIScale(pWin
->GetMapMode().GetScaleY());
595 aUIScale
*= GetDoc()->GetUIScale();
596 pRuler
->SetZoom(aUIScale
);
601 /*************************************************************************
603 |* Horizontales Lineal aktualisieren
605 \************************************************************************/
607 void DrawViewShell::UpdateHRuler()
609 Invalidate( SID_ATTR_LONG_LRSPACE
);
610 Invalidate( SID_RULER_PAGE_POS
);
611 Invalidate( SID_RULER_OBJECT
);
612 Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT
);
614 if (mpHorizontalRuler
.get() != NULL
)
615 mpHorizontalRuler
->ForceUpdate();
618 /*************************************************************************
620 |* Vertikales Lineal aktualisieren
622 \************************************************************************/
624 void DrawViewShell::UpdateVRuler()
626 Invalidate( SID_ATTR_LONG_LRSPACE
);
627 Invalidate( SID_RULER_PAGE_POS
);
628 Invalidate( SID_RULER_OBJECT
);
630 if (mpVerticalRuler
.get() != NULL
)
631 mpVerticalRuler
->ForceUpdate();
634 /*************************************************************************
638 \************************************************************************/
640 void DrawViewShell::SetUIUnit(FieldUnit eUnit
)
642 ViewShell::SetUIUnit(eUnit
);
645 /*************************************************************************
647 |* TabControl nach Splitteraenderung aktualisieren
649 \************************************************************************/
651 IMPL_LINK( DrawViewShell
, TabSplitHdl
, TabBar
*, pTab
)
653 const long int nMax
= maViewSize
.Width() - maScrBarWH
.Width()
654 - maTabControl
.GetPosPixel().X() ;
656 Size aTabSize
= maTabControl
.GetSizePixel();
657 aTabSize
.Width() = Min(pTab
->GetSplitSize(), (long)(nMax
-1));
659 maTabControl
.SetSizePixel(aTabSize
);
660 GetLayerTabControl()->SetSizePixel(aTabSize
);
662 Point aPos
= maTabControl
.GetPosPixel();
663 aPos
.X() += aTabSize
.Width();
665 Size
aScrSize(nMax
- aTabSize
.Width(), maScrBarWH
.Height());
666 mpHorizontalScrollBar
->SetPosSizePixel(aPos
, aScrSize
);
671 /// inherited from sd::ViewShell
672 SdPage
* DrawViewShell::getCurrentPage() const
674 const sal_Int32 nPageCount
= (meEditMode
== EM_PAGE
)?
675 GetDoc()->GetSdPageCount(mePageKind
):
676 GetDoc()->GetMasterSdPageCount(mePageKind
);
678 sal_Int32 nCurrentPage
= maTabControl
.GetCurPageId() - 1;
679 DBG_ASSERT( (nPageCount
>0) && (nCurrentPage
<nPageCount
), "sd::DrawViewShell::getCurrentPage(), illegal page index!" );
680 if( (nPageCount
< 0) || (nCurrentPage
>=nPageCount
) )
681 nCurrentPage
= 0; // play safe here
683 if (meEditMode
== EM_PAGE
)
685 return GetDoc()->GetSdPage((USHORT
)nCurrentPage
, mePageKind
);
687 else // EM_MASTERPAGE
689 return GetDoc()->GetMasterSdPage((USHORT
)nCurrentPage
, mePageKind
);
693 /*************************************************************************
695 |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert
696 |* hat (z. B. durch Undo)
698 \************************************************************************/
700 void DrawViewShell::ResetActualPage()
702 USHORT nCurrentPage
= maTabControl
.GetCurPageId() - 1;
703 USHORT nPageCount
= (meEditMode
== EM_PAGE
)?GetDoc()->GetSdPageCount(mePageKind
):GetDoc()->GetMasterSdPageCount(mePageKind
);
705 nCurrentPage
= Min((USHORT
)(nPageCount
- 1), nCurrentPage
);
709 if (meEditMode
== EM_PAGE
)
712 // Update fuer TabControl
713 maTabControl
.Clear();
715 SdPage
* pPage
= NULL
;
718 for (USHORT i
= 0; i
< nPageCount
; i
++)
720 pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
721 aPageName
= pPage
->GetName();
722 maTabControl
.InsertPage(i
+ 1, aPageName
);
724 // Selektionskennungen der Seiten korrigieren
725 GetDoc()->SetSelected(pPage
, i
== nCurrentPage
);
728 maTabControl
.SetCurPageId(nCurrentPage
+ 1);
730 else // EM_MASTERPAGE
732 SdPage
* pActualPage
= GetDoc()->GetMasterSdPage(nCurrentPage
, mePageKind
);
733 maTabControl
.Clear();
734 USHORT nActualMasterPageNum
= 0;
736 USHORT nMasterPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
737 for (USHORT i
= 0; i
< nMasterPageCnt
; i
++)
739 SdPage
* pMaster
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
740 String
aLayoutName(pMaster
->GetLayoutName());
741 aLayoutName
.Erase(aLayoutName
.SearchAscii(SD_LT_SEPARATOR
));
742 maTabControl
.InsertPage(i
+ 1, aLayoutName
);
744 if (pActualPage
== pMaster
)
745 nActualMasterPageNum
= i
;
748 maTabControl
.SetCurPageId(nActualMasterPageNum
+ 1);
749 SwitchPage(nActualMasterPageNum
);
752 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE
,
753 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
756 /*************************************************************************
758 |* Verb auf OLE-Objekt anwenden
760 \************************************************************************/
763 ErrCode
DrawViewShell::DoVerb(long nVerb
)
765 if ( mpDrawView
->AreObjectsMarked() )
767 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
769 if (rMarkList
.GetMarkCount() == 1)
771 SdrMark
* pMark
= rMarkList
.GetMark(0);
772 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
774 UINT32 nInv
= pObj
->GetObjInventor();
775 UINT16 nSdrObjKind
= pObj
->GetObjIdentifier();
777 if (nInv
== SdrInventor
&& nSdrObjKind
== OBJ_OLE2
)
779 ActivateObject( (SdrOle2Obj
*) pObj
, nVerb
);
781 #ifdef STARIMAGE_AVAILABLE
782 else if (nInv
= SdrInventor
&& nSdrObjKind
== OBJ_GRAF
&&
783 ((SdrGrafObj
*) pObj
)->GetGraphicType() == GRAPHIC_BITMAP
&&
784 SFX_APP()->HasFeature(SFX_FEATURE_SIMAGE
))
786 SdrGrafObj
* pSdrGrafObj
= (SdrGrafObj
*) pObj
;
789 if ( pSdrGrafObj
->GetFileName().Len() )
791 // Graphik ist gelinkt, soll der Link aufgehoben werden?
792 QueryBox
aBox(pWindow
, WB_YES_NO
| WB_DEF_YES
,
793 String( SdResId(STR_REMOVE_LINK
) ) );
794 nOK
= aBox
.Execute();
798 // Link aufheben (File- und Filtername zuruecksetzen)
799 pSdrGrafObj
->SetGraphicLink(String(), String());
805 /**************************************************************
806 * OLE-Objekt erzeugen, StarImage starten
807 * Grafik-Objekt loeschen (durch OLE-Objekt ersetzt)
808 **************************************************************/
809 //HMHmpDrView->HideMarkHdl();
811 SvStorageRef aStor
= new SvStorage(String());
812 SvInPlaceObjectRef aNewIPObj
= &((SvFactory
*)SvInPlaceObject::ClassFactory())
813 ->CreateAndInit(SimModuleDummy::GetID(SOFFICE_FILEFORMAT_CURRENT
), aStor
);
814 if ( aNewIPObj
.Is() )
816 SdrGrafObj
* pTempSdrGrafObj
= (SdrGrafObj
*) pSdrGrafObj
->Clone ();
818 SvEmbeddedInfoObject
* pInfo
;
819 pInfo
= GetViewFrame()->GetObjectShell()->
820 InsertObject( aNewIPObj
, String() );
825 aName
= pInfo
->GetObjName();
828 Rectangle aRect
= pObj
->GetLogicRect();
829 SdrOle2Obj
* pSdrOle2Obj
= new SdrOle2Obj( aNewIPObj
,
832 SdrPageView
* pPV
= mpDrawView
->GetSdrPageView();
834 pPV
->GetObjList()->InsertObject( pSdrOle2Obj
);
835 mpDrawView
->ReplaceObjectAtView( pObj
, *pPV
, pTempSdrGrafObj
);
837 pSdrOle2Obj
->SetLogicRect(aRect
);
838 aNewIPObj
->SetVisAreaSize(aRect
.GetSize());
840 SimDLL::Update(aNewIPObj
, pTempSdrGrafObj
->GetGraphic(), pWindow
);
841 ActivateObject(pSdrOle2Obj
, SVVERB_SHOW
);
843 Client
* pClient
= (Client
*) GetIPClient();
846 pClient
->SetSdrGrafObj( pTempSdrGrafObj
);
858 /*************************************************************************
860 |* OLE-Object aktivieren
862 \************************************************************************/
864 BOOL
DrawViewShell::ActivateObject(SdrOle2Obj
* pObj
, long nVerb
)
866 BOOL bActivated
= FALSE
;
868 if ( !GetDocSh()->IsUIActive() )
870 ToolBarManager::UpdateLock
aLock (GetViewShellBase().GetToolBarManager());
872 bActivated
= ViewShell::ActivateObject(pObj
, nVerb
);
874 OSL_ASSERT(GetViewShell()!=NULL
);
875 Client
* pClient
= static_cast<Client
*>(GetViewShell()->GetIPClient());
877 pClient
->SetSdrGrafObj(NULL
);
883 /*************************************************************************
885 |* Auf gewuenschte Seite schalten
886 |* Der Parameter nSelectedPage bezieht sich auf den aktuellen EditMode
888 \************************************************************************/
890 void LclResetFlag (bool& rbFlag
) {rbFlag
= false;}
892 BOOL
DrawViewShell::SwitchPage(USHORT nSelectedPage
)
894 /** Under some circumstances there are nested calls to SwitchPage() and
895 may crash the application (activation of form controls when the
896 shell of the edit view is not on top of the shell stack, see issue
897 83888 for details.) Therefore the nested calls are ignored (they
898 would jump to the wrong page anyway.)
900 if (mbIsInSwitchPage
)
902 mbIsInSwitchPage
= true;
903 comphelper::ScopeGuard
aGuard (::boost::bind(LclResetFlag
, ::boost::ref(mbIsInSwitchPage
)));
905 if (GetActiveWindow()->IsInPaint())
907 // Switching the current page while a Paint is being executed is
908 // dangerous. So, post it for later execution and return.
909 maAsynchronousSwitchPageCall
.Post(::boost::bind(
910 ::std::mem_fun(&DrawViewShell::SwitchPage
),
918 // With the current implementation of FuSlideShow there is a problem
919 // when it dsplays the show in a window: When the show is stopped it
920 // returns at one point in time SDRPAGE_NOTFOUND as current page index.
921 // Because FuSlideShow is currently being rewritten this bug is fixed
923 // This is not as bad a hack as it may look because making SwitchPage()
924 // more robust with respect to invalid page numbers is a good thing
926 if (nSelectedPage
== SDRPAGE_NOTFOUND
)
932 // Make sure that the given page index points to an existing page. Move
933 // the index into the valid range if necessary.
934 USHORT nPageCount
= (meEditMode
== EM_PAGE
)
935 ? GetDoc()->GetSdPageCount(mePageKind
)
936 : GetDoc()->GetMasterSdPageCount(mePageKind
);
937 if (nSelectedPage
>= nPageCount
)
938 nSelectedPage
= nPageCount
-1;
941 if (IsSwitchPageAllowed())
943 ModifyGuard
aGuard2( GetDoc() );
949 SdPage
* pNewPage
= NULL
;
951 if (meEditMode
== EM_MASTERPAGE
)
953 if( GetDoc()->GetMasterSdPageCount(mePageKind
) > nSelectedPage
)
954 pNewPage
= GetDoc()->GetMasterSdPage(nSelectedPage
, mePageKind
);
958 SdrPageView
* pPV
= mpDrawView
->GetSdrPageView();
960 String
sPageText (pNewPage
->GetLayoutName());
961 sPageText
.Erase(sPageText
.SearchAscii(SD_LT_SEPARATOR
));
963 && pNewPage
== dynamic_cast< SdPage
* >( pPV
->GetPage() )
964 && sPageText
== maTabControl
.GetPageText(nSelectedPage
+1))
966 // this slide is already visible
973 OSL_ASSERT(mpFrameView
!=NULL
);
974 mpFrameView
->SetSelectedPage(nSelectedPage
);
976 if (GetDoc()->GetSdPageCount(mePageKind
) > nSelectedPage
)
977 pNewPage
= GetDoc()->GetSdPage(nSelectedPage
, mePageKind
);
979 if (mpActualPage
== pNewPage
)
981 SdrPageView
* pPV
= mpDrawView
->GetSdrPageView();
983 SdPage
* pCurrentPage
= dynamic_cast< SdPage
* >( pPV
->GetPage());
985 && pNewPage
== pCurrentPage
986 && pNewPage
->GetName() == maTabControl
.GetPageText(nSelectedPage
+1))
988 // this slide is already visible
996 mpDrawView
->SdrEndTextEdit();
1000 if (meEditMode
== EM_PAGE
)
1002 mpActualPage
= GetDoc()->GetSdPage(nSelectedPage
, mePageKind
);
1006 SdPage
* pMaster
= GetDoc()->GetMasterSdPage(nSelectedPage
, mePageKind
);
1008 // Passt die selektierte Seite zur MasterPage?
1009 USHORT nPageCount
= GetDoc()->GetSdPageCount(mePageKind
);
1010 for (USHORT i
= 0; i
< nPageCount
; i
++)
1012 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
1013 if(pPage
&& pPage
->IsSelected() && pMaster
== &(pPage
->TRG_GetMasterPage()))
1015 mpActualPage
= pPage
;
1022 // Die erste Seite nehmen, welche zur MasterPage passt
1023 for (USHORT i
= 0; i
< nPageCount
; i
++)
1025 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
1026 if(pPage
&& pMaster
== &(pPage
->TRG_GetMasterPage()))
1028 mpActualPage
= pPage
;
1035 for (USHORT i
= 0; i
< GetDoc()->GetSdPageCount(mePageKind
); i
++)
1037 // Alle Seiten deselektieren
1038 GetDoc()->SetSelected( GetDoc()->GetSdPage(i
, mePageKind
), FALSE
);
1043 // Sofern es keine mpActualPage gibt, wird die erste genommen
1044 mpActualPage
= GetDoc()->GetSdPage(0, mePageKind
);
1047 // diese Seite auch selektieren (mpActualPage zeigt immer auf Zeichenseite,
1048 // nie auf eine Masterpage)
1049 GetDoc()->SetSelected(mpActualPage
, TRUE
);
1051 rtl::Reference
< sd::SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
1052 if( !xSlideshow
.is() || !xSlideshow
->isRunning() || ( xSlideshow
->getAnimationMode() != ANIMATIONMODE_SHOW
) )
1054 // VisArea zuziehen, um ggf. Objekte zu deaktivieren
1055 // !!! only if we are not in presentation mode (#96279) !!!
1056 OSL_ASSERT (GetViewShell()!=NULL
);
1057 GetViewShell()->DisconnectAllClients();
1058 VisAreaChanged(Rectangle(Point(), Size(1, 1)));
1061 if (meEditMode
== EM_PAGE
)
1063 /**********************************************************************
1065 **********************************************************************/
1066 GetDoc()->SetSelected(mpActualPage
, TRUE
);
1068 SdrPageView
* pPageView
= mpDrawView
->GetSdrPageView();
1072 mpFrameView
->SetVisibleLayers( pPageView
->GetVisibleLayers() );
1073 mpFrameView
->SetPrintableLayers( pPageView
->GetPrintableLayers() );
1074 mpFrameView
->SetLockedLayers( pPageView
->GetLockedLayers() );
1076 if (mePageKind
== PK_NOTES
)
1078 mpFrameView
->SetNotesHelpLines( pPageView
->GetHelpLines() );
1080 else if (mePageKind
== PK_HANDOUT
)
1082 mpFrameView
->SetHandoutHelpLines( pPageView
->GetHelpLines() );
1086 mpFrameView
->SetStandardHelpLines( pPageView
->GetHelpLines() );
1090 mpDrawView
->HideSdrPage();
1091 mpDrawView
->ShowSdrPage(mpActualPage
);
1092 GetViewShellBase().GetDrawController().FireSwitchCurrentPage(mpActualPage
);
1094 SdrPageView
* pNewPageView
= mpDrawView
->GetSdrPageView();
1098 pNewPageView
->SetVisibleLayers( mpFrameView
->GetVisibleLayers() );
1099 pNewPageView
->SetPrintableLayers( mpFrameView
->GetPrintableLayers() );
1100 pNewPageView
->SetLockedLayers( mpFrameView
->GetLockedLayers() );
1102 if (mePageKind
== PK_NOTES
)
1104 pNewPageView
->SetHelpLines( mpFrameView
->GetNotesHelpLines() );
1106 else if (mePageKind
== PK_HANDOUT
)
1108 pNewPageView
->SetHelpLines( mpFrameView
->GetHandoutHelpLines() );
1112 pNewPageView
->SetHelpLines( mpFrameView
->GetStandardHelpLines() );
1116 maTabControl
.SetCurPageId(nSelectedPage
+1);
1117 String aPageName
= mpActualPage
->GetName();
1119 if (maTabControl
.GetPageText(nSelectedPage
+1) != aPageName
)
1121 maTabControl
.SetPageText(nSelectedPage
+1, aPageName
);
1126 /**********************************************************************
1128 **********************************************************************/
1129 SdrPageView
* pPageView
= mpDrawView
->GetSdrPageView();
1133 mpFrameView
->SetVisibleLayers( pPageView
->GetVisibleLayers() );
1134 mpFrameView
->SetPrintableLayers( pPageView
->GetPrintableLayers() );
1135 mpFrameView
->SetLockedLayers( pPageView
->GetLockedLayers() );
1137 if (mePageKind
== PK_NOTES
)
1139 mpFrameView
->SetNotesHelpLines( pPageView
->GetHelpLines() );
1141 else if (mePageKind
== PK_HANDOUT
)
1143 mpFrameView
->SetHandoutHelpLines( pPageView
->GetHelpLines() );
1147 mpFrameView
->SetStandardHelpLines( pPageView
->GetHelpLines() );
1151 mpDrawView
->HideSdrPage();
1153 SdPage
* pMaster
= GetDoc()->GetMasterSdPage(nSelectedPage
, mePageKind
);
1155 if( !pMaster
) // Falls es diese Page nicht geben sollte
1156 pMaster
= GetDoc()->GetMasterSdPage(0, mePageKind
);
1158 USHORT nNum
= pMaster
->GetPageNum();
1159 mpDrawView
->ShowSdrPage(mpDrawView
->GetModel()->GetMasterPage(nNum
));
1161 GetViewShellBase().GetDrawController().FireSwitchCurrentPage(pMaster
);
1163 SdrPageView
* pNewPageView
= mpDrawView
->GetSdrPageView();
1167 pNewPageView
->SetVisibleLayers( mpFrameView
->GetVisibleLayers() );
1168 pNewPageView
->SetPrintableLayers( mpFrameView
->GetPrintableLayers() );
1169 pNewPageView
->SetLockedLayers( mpFrameView
->GetLockedLayers() );
1171 if (mePageKind
== PK_NOTES
)
1173 pNewPageView
->SetHelpLines( mpFrameView
->GetNotesHelpLines() );
1175 else if (mePageKind
== PK_HANDOUT
)
1177 pNewPageView
->SetHelpLines( mpFrameView
->GetHandoutHelpLines() );
1181 pNewPageView
->SetHelpLines( mpFrameView
->GetStandardHelpLines() );
1185 String
aLayoutName(pMaster
->GetLayoutName());
1186 aLayoutName
.Erase(aLayoutName
.SearchAscii(SD_LT_SEPARATOR
));
1188 maTabControl
.SetCurPageId(nSelectedPage
+1);
1190 if (maTabControl
.GetPageText(nSelectedPage
+1) != aLayoutName
)
1192 maTabControl
.SetPageText(nSelectedPage
+1, aLayoutName
);
1195 if( mePageKind
== PK_HANDOUT
)
1197 // set pages for all available handout presentation objects
1198 sd::ShapeList
& rShapeList
= pMaster
->GetPresentationShapeList();
1200 sal_uInt16 nPgNum
= 0;
1201 SdrObject
* pObj
= 0;
1202 while( (pObj
= rShapeList
.getNextShape(pObj
)) != 0 )
1204 if( pMaster
->GetPresObjKind(pObj
) == PRESOBJ_HANDOUT
)
1206 const sal_uInt16
nDestinationPageNum(2 * nPgNum
+ 1);
1208 if(nDestinationPageNum
< GetDoc()->GetPageCount())
1210 static_cast<SdrPageObj
*>(pObj
)->SetReferencedPage(GetDoc()->GetPage(nDestinationPageNum
));
1214 static_cast<SdrPageObj
*>(pObj
)->SetReferencedPage(0L);
1223 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
1224 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
1225 VisAreaChanged(aVisAreaWin
);
1226 mpDrawView
->VisAreaChanged(GetActiveWindow());
1228 // Damit der Navigator (und das Effekte-Window) das mitbekommt (/-men)
1229 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
1230 rBindings
.Invalidate(SID_NAVIGATOR_PAGENAME
, TRUE
, FALSE
);
1231 rBindings
.Invalidate(SID_STATUS_PAGE
, TRUE
, FALSE
);
1232 UpdatePreview( mpActualPage
);
1239 /*************************************************************************
1241 |* Pruefen, ob ein Seitenwechsel erlaubt ist
1243 \************************************************************************/
1245 BOOL
DrawViewShell::IsSwitchPageAllowed() const
1249 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
1250 if (pFormShell
!=NULL
&& !pFormShell
->PrepareClose (FALSE
))
1256 /*************************************************************************
1258 |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert
1259 |* hat (z. B. durch Undo)
1261 \************************************************************************/
1263 void DrawViewShell::ResetActualLayer()
1265 LayerTabBar
* pLayerBar
= GetLayerTabControl();
1266 if (pLayerBar
!= NULL
)
1268 // remember old layer cound and current layer id
1269 // this is needed when one layer is renamed to
1270 // restore current layer
1271 USHORT nOldLayerCnt
= pLayerBar
->GetPageCount();
1272 USHORT nOldLayerId
= pLayerBar
->GetCurPageId();
1274 /*************************************************************
1275 * Update fuer LayerTab
1276 *************************************************************/
1280 String aActiveLayer
= mpDrawView
->GetActiveLayer();
1281 String
aBackgroundLayer( SdResId(STR_LAYER_BCKGRND
) );
1282 String
aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ
) );
1283 String
aLayoutLayer( SdResId(STR_LAYER_LAYOUT
) );
1284 String
aControlsLayer( SdResId(STR_LAYER_CONTROLS
) );
1285 String
aMeasureLinesLayer( SdResId(STR_LAYER_MEASURELINES
) );
1286 USHORT nActiveLayer
= SDRLAYER_NOTFOUND
;
1287 SdrLayerAdmin
& rLayerAdmin
= GetDoc()->GetLayerAdmin();
1288 USHORT nLayerCnt
= rLayerAdmin
.GetLayerCount();
1290 for ( USHORT nLayer
= 0; nLayer
< nLayerCnt
; nLayer
++ )
1292 aName
= rLayerAdmin
.GetLayer(nLayer
)->GetName();
1294 if ( aName
== aActiveLayer
)
1296 nActiveLayer
= nLayer
;
1299 if ( aName
!= aBackgroundLayer
)
1301 if (meEditMode
== EM_MASTERPAGE
)
1303 // Layer der Page nicht auf MasterPage anzeigen
1304 if (aName
!= aLayoutLayer
&&
1305 aName
!= aControlsLayer
&&
1306 aName
!= aMeasureLinesLayer
)
1308 pLayerBar
->InsertPage(nLayer
+1, aName
);
1310 TabBarPageBits nBits
= 0;
1311 SdrPageView
* pPV
= mpDrawView
->GetSdrPageView();
1313 if (pPV
&& !pPV
->IsLayerVisible(aName
))
1315 // Unsichtbare Layer werden anders dargestellt
1316 nBits
= TPB_SPECIAL
;
1319 pLayerBar
->SetPageBits(nLayer
+1, nBits
);
1324 // Layer der MasterPage nicht auf Page anzeigen
1325 if ( aName
!= aBackgroundObjLayer
)
1327 pLayerBar
->InsertPage(nLayer
+1, aName
);
1329 TabBarPageBits nBits
= 0;
1331 if (!mpDrawView
->GetSdrPageView()->IsLayerVisible(aName
))
1333 // Unsichtbare Layer werden anders dargestellt
1334 nBits
= TPB_SPECIAL
;
1337 pLayerBar
->SetPageBits(nLayer
+1, nBits
);
1343 if ( nActiveLayer
== SDRLAYER_NOTFOUND
)
1345 if( nOldLayerCnt
== pLayerBar
->GetPageCount() )
1347 nActiveLayer
= nOldLayerId
- 1;
1351 nActiveLayer
= ( meEditMode
== EM_MASTERPAGE
) ? 2 : 0;
1354 mpDrawView
->SetActiveLayer( pLayerBar
->GetPageText(nActiveLayer
+ 1) );
1357 pLayerBar
->SetCurPageId(nActiveLayer
+ 1);
1358 GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER
);
1362 /*************************************************************************
1364 |* Verzoegertes Close ausfuehren
1366 \************************************************************************/
1368 IMPL_LINK( DrawViewShell
, CloseHdl
, Timer
*, pTimer
)
1371 GetViewFrame()->GetBindings().Execute( SID_CLOSEWIN
);
1375 /*************************************************************************
1379 \************************************************************************/
1381 sal_Int8
DrawViewShell::AcceptDrop (
1382 const AcceptDropEvent
& rEvt
,
1383 DropTargetHelper
& rTargetHelper
,
1384 ::sd::Window
* pTargetWindow
,
1388 if( nPage
!= SDRPAGE_NOTFOUND
)
1389 nPage
= GetDoc()->GetSdPage( nPage
, mePageKind
)->GetPageNum();
1391 if( SlideShow::IsRunning( GetViewShellBase() ) )
1392 return DND_ACTION_NONE
;
1394 return mpDrawView
->AcceptDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
);
1397 /*************************************************************************
1401 \************************************************************************/
1403 sal_Int8
DrawViewShell::ExecuteDrop (
1404 const ExecuteDropEvent
& rEvt
,
1405 DropTargetHelper
& rTargetHelper
,
1406 ::sd::Window
* pTargetWindow
,
1410 if( nPage
!= SDRPAGE_NOTFOUND
)
1411 nPage
= GetDoc()->GetSdPage( nPage
, mePageKind
)->GetPageNum();
1413 if( SlideShow::IsRunning( GetViewShellBase() ) )
1414 return DND_ACTION_NONE
;
1416 Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START
));
1417 sal_Int8
nResult (mpDrawView
->ExecuteDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
));
1418 Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END
));
1423 } // end of namespace sd
1426 #if (_MSC_VER < 1400)
1427 #pragma optimize ( "", on )