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)
170 //Update3DWindow(); // 3D-Controller
171 SfxBoolItem
aItem( SID_3D_STATE
, TRUE
);
172 GetViewFrame()->GetDispatcher()->Execute(
173 SID_3D_STATE
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
, &aItem
, 0L );
175 SdrOle2Obj
* pOleObj
= NULL
;
176 SdrGrafObj
* pGrafObj
= NULL
;
178 if ( mpDrawView
->AreObjectsMarked() )
180 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
182 if (rMarkList
.GetMarkCount() == 1)
184 SdrMark
* pMark
= rMarkList
.GetMark(0);
185 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
187 UINT32 nInv
= pObj
->GetObjInventor();
188 UINT16 nSdrObjKind
= pObj
->GetObjIdentifier();
190 if (nInv
== SdrInventor
&& nSdrObjKind
== OBJ_OLE2
)
192 pOleObj
= (SdrOle2Obj
*) pObj
;
193 UpdateIMapDlg( pObj
);
195 else if (nSdrObjKind
== OBJ_GRAF
)
197 pGrafObj
= (SdrGrafObj
*) pObj
;
198 UpdateIMapDlg( pObj
);
203 ViewShellBase
& rBase
= GetViewShellBase();
208 Client
* pIPClient
= static_cast<Client
*>(rBase
.GetIPClient());
209 if ( pIPClient
&& pIPClient
->IsObjectInPlaceActive() )
211 /**********************************************************************
212 * Ggf. OLE-Objekt beruecksichtigen und deaktivieren
213 **********************************************************************/
215 // this means we recently deselected an inplace active ole object so
216 // we need to deselect it now
219 pIPClient
->DeactivateObject();
220 //HMHmpDrView->ShowMarkHdl();
224 uno::Reference
< embed::XEmbeddedObject
> xObj
= pOleObj
->GetObjRef();
227 rBase
.SetVerbs( xObj
->getSupportedVerbs() );
231 rBase
.SetVerbs( uno::Sequence
< embed::VerbDescriptor
>() );
239 uno::Reference
< embed::XEmbeddedObject
> xObj
= pOleObj
->GetObjRef();
242 rBase
.SetVerbs( xObj
->getSupportedVerbs() );
246 rBase
.SetVerbs( uno::Sequence
< embed::VerbDescriptor
>() );
251 rBase
.SetVerbs( uno::Sequence
< embed::VerbDescriptor
>() );
255 catch( ::com::sun::star::uno::Exception
& e
)
259 (rtl::OString("sd::DrawViewShell::SelectionHasChanged(), "
260 "exception caught: ") +
261 rtl::OUStringToOString(
262 comphelper::anyToString( cppu::getCaughtException() ),
263 RTL_TEXTENCODING_UTF8
)).getStr() );
266 if( HasCurrentFunction() )
268 GetCurrentFunction()->SelectionHasChanged();
272 GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView
);
275 // #96124# Invalidate for every subshell
276 GetViewShellBase().GetViewShellManager()->InvalidateAllSubShells(this);
278 mpDrawView
->UpdateSelectionClipboard( FALSE
);
280 GetViewShellBase().GetDrawController().FireSelectionChangeListener();
284 /*************************************************************************
288 \************************************************************************/
290 void DrawViewShell::SetZoom( long nZoom
)
292 // Make sure that the zoom factor will not be recalculated on
293 // following window resizings.
294 mbZoomOnPage
= FALSE
;
295 ViewShell::SetZoom( nZoom
);
296 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM
);
297 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER
);
300 /*************************************************************************
302 |* Zoomrechteck fuer aktives Fenster einstellen
304 \************************************************************************/
306 void DrawViewShell::SetZoomRect( const Rectangle
& rZoomRect
)
308 ViewShell::SetZoomRect( rZoomRect
);
309 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM
);
310 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER
);
313 /*************************************************************************
315 |* PrepareClose, ggfs. Texteingabe beenden, damit andere Viewshells ein
316 |* aktualisiertes Textobjekt vorfinden
318 \************************************************************************/
320 USHORT
DrawViewShell::PrepareClose( BOOL bUI
, BOOL bForBrowsing
)
322 if ( ViewShell::PrepareClose(bUI
, bForBrowsing
) != TRUE
)
327 if( bRet
&& HasCurrentFunction() )
329 USHORT nID
= GetCurrentFunction()->GetSlotID();
330 if (nID
== SID_TEXTEDIT
|| nID
== SID_ATTR_CHAR
)
332 mpDrawView
->SdrEndTextEdit();
337 maCloseTimer
.SetTimeoutHdl( LINK( this, DrawViewShell
, CloseHdl
) );
338 maCloseTimer
.SetTimeout( 20 );
339 maCloseTimer
.Start();
345 /*************************************************************************
347 |* Status (Enabled/Disabled) von Menue-SfxSlots setzen
349 \************************************************************************/
351 void DrawViewShell::ChangeEditMode(EditMode eEMode
, bool bIsLayerModeActive
)
353 if (meEditMode
!= eEMode
|| mbIsLayerModeActive
!= bIsLayerModeActive
)
355 ViewShellManager::UpdateLock
aLock (GetViewShellBase().GetViewShellManager());
357 USHORT nActualPageNum
= 0;
359 GetViewShellBase().GetDrawController().FireChangeEditMode (eEMode
== EM_MASTERPAGE
);
360 GetViewShellBase().GetDrawController().FireChangeLayerMode (bIsLayerModeActive
);
362 if ( mpDrawView
->IsTextEdit() )
364 mpDrawView
->SdrEndTextEdit();
367 LayerTabBar
* pLayerBar
= GetLayerTabControl();
368 if (pLayerBar
!= NULL
)
369 pLayerBar
->EndEditMode();
370 maTabControl
.EndEditMode();
372 if (mePageKind
== PK_HANDOUT
)
374 // Bei Handzetteln nur MasterPage zulassen
375 eEMode
= EM_MASTERPAGE
;
379 mbIsLayerModeActive
= bIsLayerModeActive
;
381 // Determine whether to show the master view toolbar. The master
382 // page mode has to be active and the shell must not be a handout
384 bool bShowMasterViewToolbar (meEditMode
== EM_MASTERPAGE
385 && GetShellType() != ViewShell::ST_HANDOUT
);
387 // If the master view toolbar is not shown we hide it before
388 // switching the edit mode.
389 if (::sd::ViewShell::mpImpl
->mbIsInitialized
391 && ! bShowMasterViewToolbar
)
393 GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::TBG_MASTER_MODE
);
396 if (meEditMode
== EM_PAGE
)
398 /******************************************************************
400 ******************************************************************/
402 maTabControl
.Clear();
406 USHORT nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
408 for (USHORT i
= 0; i
< nPageCnt
; i
++)
410 pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
411 aPageName
= pPage
->GetName();
412 maTabControl
.InsertPage(i
+ 1, aPageName
);
414 if ( pPage
->IsSelected() && nActualPageNum
== 0 )
420 maTabControl
.SetCurPageId(nActualPageNum
+ 1);
422 SwitchPage(nActualPageNum
);
426 /******************************************************************
428 ******************************************************************/
429 GetViewFrame()->SetChildWindow(
430 AnimationChildWindow::GetChildWindowId(), FALSE
);
434 // Sofern es keine mpActualPage gibt, wird die erste genommen
435 mpActualPage
= GetDoc()->GetSdPage(0, mePageKind
);
438 maTabControl
.Clear();
439 USHORT nActualMasterPageNum
= 0;
440 USHORT nMasterPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
442 for (USHORT i
= 0; i
< nMasterPageCnt
; i
++)
444 SdPage
* pMaster
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
445 String
aLayoutName(pMaster
->GetLayoutName());
446 aLayoutName
.Erase(aLayoutName
.SearchAscii(SD_LT_SEPARATOR
));
448 maTabControl
.InsertPage(i
+ 1, aLayoutName
);
450 if (&(mpActualPage
->TRG_GetMasterPage()) == pMaster
)
452 nActualMasterPageNum
= i
;
456 maTabControl
.SetCurPageId(nActualMasterPageNum
+ 1);
457 SwitchPage(nActualMasterPageNum
);
460 // If the master view toolbar is to be shown we turn it on after the
461 // edit mode has been changed.
462 if (::sd::ViewShell::mpImpl
->mbIsInitialized
464 && bShowMasterViewToolbar
)
466 GetViewShellBase().GetToolBarManager()->SetToolBar(
467 ToolBarManager::TBG_MASTER_MODE
,
468 ToolBarManager::msMasterViewToolBar
);
471 if ( ! mbIsLayerModeActive
)
474 // Set the tab control only for draw pages. For master page
475 // this has been done already above.
476 if (meEditMode
== EM_PAGE
)
477 maTabControl
.SetCurPageId (nActualPageNum
+ 1);
479 /*AF: The LayerDialogChildWindow is not used anymore (I hope).
480 if (GetViewFrame()->KnowsChildWindow(
481 LayerDialogChildWindow::GetChildWindowId()))
483 GetViewFrame()->SetChildWindow(
484 LayerDialogChildWindow::GetChildWindowId(),
485 IsLayerModeActive());
490 Invalidate( SID_PAGEMODE
);
491 Invalidate( SID_LAYERMODE
);
492 Invalidate( SID_MASTERPAGE
);
493 Invalidate( SID_DELETE_MASTER_PAGE
);
494 Invalidate( SID_DELETE_PAGE
);
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 rBindings
.Invalidate(SID_DELETE_MASTER_PAGE
, TRUE
, FALSE
);
1233 rBindings
.Invalidate(SID_DELETE_PAGE
, TRUE
, FALSE
);
1234 UpdatePreview( mpActualPage
);
1236 mpDrawView
->AdjustMarkHdl();
1243 /*************************************************************************
1245 |* Pruefen, ob ein Seitenwechsel erlaubt ist
1247 \************************************************************************/
1249 BOOL
DrawViewShell::IsSwitchPageAllowed() const
1253 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
1254 if (pFormShell
!=NULL
&& !pFormShell
->PrepareClose (FALSE
))
1260 /*************************************************************************
1262 |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert
1263 |* hat (z. B. durch Undo)
1265 \************************************************************************/
1267 void DrawViewShell::ResetActualLayer()
1269 LayerTabBar
* pLayerBar
= GetLayerTabControl();
1270 if (pLayerBar
!= NULL
)
1272 // remember old layer cound and current layer id
1273 // this is needed when one layer is renamed to
1274 // restore current layer
1275 USHORT nOldLayerCnt
= pLayerBar
->GetPageCount();
1276 USHORT nOldLayerId
= pLayerBar
->GetCurPageId();
1278 /*************************************************************
1279 * Update fuer LayerTab
1280 *************************************************************/
1284 String aActiveLayer
= mpDrawView
->GetActiveLayer();
1285 String
aBackgroundLayer( SdResId(STR_LAYER_BCKGRND
) );
1286 String
aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ
) );
1287 String
aLayoutLayer( SdResId(STR_LAYER_LAYOUT
) );
1288 String
aControlsLayer( SdResId(STR_LAYER_CONTROLS
) );
1289 String
aMeasureLinesLayer( SdResId(STR_LAYER_MEASURELINES
) );
1290 USHORT nActiveLayer
= SDRLAYER_NOTFOUND
;
1291 SdrLayerAdmin
& rLayerAdmin
= GetDoc()->GetLayerAdmin();
1292 USHORT nLayerCnt
= rLayerAdmin
.GetLayerCount();
1294 for ( USHORT nLayer
= 0; nLayer
< nLayerCnt
; nLayer
++ )
1296 aName
= rLayerAdmin
.GetLayer(nLayer
)->GetName();
1298 if ( aName
== aActiveLayer
)
1300 nActiveLayer
= nLayer
;
1303 if ( aName
!= aBackgroundLayer
)
1305 if (meEditMode
== EM_MASTERPAGE
)
1307 // Layer der Page nicht auf MasterPage anzeigen
1308 if (aName
!= aLayoutLayer
&&
1309 aName
!= aControlsLayer
&&
1310 aName
!= aMeasureLinesLayer
)
1312 pLayerBar
->InsertPage(nLayer
+1, aName
);
1314 TabBarPageBits nBits
= 0;
1315 SdrPageView
* pPV
= mpDrawView
->GetSdrPageView();
1317 if (pPV
&& !pPV
->IsLayerVisible(aName
))
1319 // Unsichtbare Layer werden anders dargestellt
1320 nBits
= TPB_SPECIAL
;
1323 pLayerBar
->SetPageBits(nLayer
+1, nBits
);
1328 // Layer der MasterPage nicht auf Page anzeigen
1329 if ( aName
!= aBackgroundObjLayer
)
1331 pLayerBar
->InsertPage(nLayer
+1, aName
);
1333 TabBarPageBits nBits
= 0;
1335 if (!mpDrawView
->GetSdrPageView()->IsLayerVisible(aName
))
1337 // Unsichtbare Layer werden anders dargestellt
1338 nBits
= TPB_SPECIAL
;
1341 pLayerBar
->SetPageBits(nLayer
+1, nBits
);
1347 if ( nActiveLayer
== SDRLAYER_NOTFOUND
)
1349 if( nOldLayerCnt
== pLayerBar
->GetPageCount() )
1351 nActiveLayer
= nOldLayerId
- 1;
1355 nActiveLayer
= ( meEditMode
== EM_MASTERPAGE
) ? 2 : 0;
1358 mpDrawView
->SetActiveLayer( pLayerBar
->GetPageText(nActiveLayer
+ 1) );
1361 pLayerBar
->SetCurPageId(nActiveLayer
+ 1);
1362 GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER
);
1363 GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER
);
1367 /*************************************************************************
1369 |* Verzoegertes Close ausfuehren
1371 \************************************************************************/
1373 IMPL_LINK( DrawViewShell
, CloseHdl
, Timer
*, pTimer
)
1376 GetViewFrame()->GetBindings().Execute( SID_CLOSEWIN
);
1380 /*************************************************************************
1384 \************************************************************************/
1386 sal_Int8
DrawViewShell::AcceptDrop (
1387 const AcceptDropEvent
& rEvt
,
1388 DropTargetHelper
& rTargetHelper
,
1389 ::sd::Window
* pTargetWindow
,
1393 if( nPage
!= SDRPAGE_NOTFOUND
)
1394 nPage
= GetDoc()->GetSdPage( nPage
, mePageKind
)->GetPageNum();
1396 if( SlideShow::IsRunning( GetViewShellBase() ) )
1397 return DND_ACTION_NONE
;
1399 return mpDrawView
->AcceptDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
);
1402 /*************************************************************************
1406 \************************************************************************/
1408 sal_Int8
DrawViewShell::ExecuteDrop (
1409 const ExecuteDropEvent
& rEvt
,
1410 DropTargetHelper
& rTargetHelper
,
1411 ::sd::Window
* pTargetWindow
,
1415 if( nPage
!= SDRPAGE_NOTFOUND
)
1416 nPage
= GetDoc()->GetSdPage( nPage
, mePageKind
)->GetPageNum();
1418 if( SlideShow::IsRunning( GetViewShellBase() ) )
1419 return DND_ACTION_NONE
;
1421 Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START
));
1422 sal_Int8
nResult (mpDrawView
->ExecuteDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
));
1423 Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END
));
1428 } // end of namespace sd
1431 #if (_MSC_VER < 1400)
1432 #pragma optimize ( "", on )