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: drviewsa.cxx,v $
10 * $Revision: 1.49.70.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 <cppuhelper/implbase1.hxx>
36 #include <comphelper/processfactory.hxx>
38 #include <svx/sizeitem.hxx>
40 #include <svx/svdlayer.hxx>
42 #include <svx/zoomitem.hxx>
44 #include <svx/svdpagv.hxx>
45 #include <svtools/ptitem.hxx>
46 #include <svtools/stritem.hxx>
47 #include <sfx2/request.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <svx/svdopath.hxx>
50 #include <sfx2/docfile.hxx>
51 #include <svx/zoomslideritem.hxx>
52 #include <svtools/eitem.hxx>
54 #ifndef _SVX_DIALOGS_HRC
55 #include <svx/dialogs.hrc>
57 #include <svx/extrusionbar.hxx>
58 #include <svx/fontworkbar.hxx>
59 #include <svx/clipfmtitem.hxx>
62 #include <sfx2/viewfrm.hxx>
63 #include <svx/fmshell.hxx>
64 #include <sfx2/dispatch.hxx>
65 #include <svtools/cliplistener.hxx>
66 #include <svx/float3d.hxx>
70 #include "strings.hrc"
71 #include "res_bmp.hrc"
73 #include "FrameView.hxx"
74 #include "drawdoc.hxx"
75 #include "sdresid.hxx"
76 #include "DrawDocShell.hxx"
80 #include "drawview.hxx"
81 #include "SdUnoDrawView.hxx"
82 #include "ViewShellBase.hxx"
83 #include "SdUnoDrawView.hxx"
84 #include "slideshow.hxx"
85 #include "ToolBarManager.hxx"
86 #include "annotationmanager.hxx"
88 using namespace ::rtl
;
89 using namespace ::com::sun::star
;
90 using namespace ::com::sun::star::uno
;
93 static const ::rtl::OUString
MASTER_VIEW_TOOL_BAR_NAME(
94 ::rtl::OUString::createFromAscii("masterviewtoolbar"));
99 BOOL
DrawViewShell::mbPipette
= FALSE
;
101 // ------------------------
102 // - ScannerEventListener -
103 // ------------------------
105 class ScannerEventListener
: public ::cppu::WeakImplHelper1
< ::com::sun::star::lang::XEventListener
>
109 DrawViewShell
* mpParent
;
113 ScannerEventListener( DrawViewShell
* pParent
) : mpParent( pParent
) {};
114 ~ScannerEventListener();
117 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& rEventObject
) throw (::com::sun::star::uno::RuntimeException
);
119 void ParentDestroyed() { mpParent
= NULL
; }
122 // -----------------------------------------------------------------------------
124 ScannerEventListener::~ScannerEventListener()
128 // -----------------------------------------------------------------------------
130 void SAL_CALL
ScannerEventListener::disposing( const ::com::sun::star::lang::EventObject
& rEventObject
) throw (::com::sun::star::uno::RuntimeException
)
133 mpParent
->ScannerEvent( rEventObject
);
136 /*************************************************************************
138 |* Standard-Konstruktor
140 \************************************************************************/
142 DrawViewShell::DrawViewShell( SfxViewFrame
* pFrame
, ViewShellBase
& rViewShellBase
, ::Window
* pParentWindow
, PageKind ePageKind
, FrameView
* pFrameViewArgument
)
143 : ViewShell (pFrame
, pParentWindow
, rViewShellBase
)
144 , maTabControl(this, pParentWindow
)
145 , mbIsInSwitchPage(false)
147 if (pFrameViewArgument
!= NULL
)
148 mpFrameView
= pFrameViewArgument
;
150 mpFrameView
= new FrameView(GetDoc());
151 Construct(GetDocSh(), ePageKind
);
154 /*************************************************************************
158 \************************************************************************/
160 DrawViewShell::DrawViewShell( SfxViewFrame
* pFrame
, ::Window
* pParentWindow
, const DrawViewShell
& rShell
)
161 : ViewShell(pFrame
, pParentWindow
, rShell
)
162 , maTabControl(this, pParentWindow
)
163 , mbIsInSwitchPage(false)
165 mpFrameView
= new FrameView(GetDoc());
166 Construct (GetDocSh(), PK_STANDARD
);
169 /*************************************************************************
173 \************************************************************************/
175 DrawViewShell::~DrawViewShell()
177 mpAnnotationManager
.release();
179 OSL_ASSERT (GetViewShell()!=NULL
);
181 if( mxScannerListener
.is() )
182 static_cast< ScannerEventListener
* >( mxScannerListener
.get() )->ParentDestroyed();
184 // #96642# Remove references to items within Svx3DWin
185 // (maybe do a listening sometime in Svx3DWin)
186 USHORT nId
= Svx3DChildWindow::GetChildWindowId();
187 SfxChildWindow
* pWindow
= GetViewFrame() ? GetViewFrame()->GetChildWindow(nId
) : NULL
;
190 Svx3DWin
* p3DWin
= static_cast< Svx3DWin
* > (pWindow
->GetWindow());
192 p3DWin
->DocumentReload();
195 EndListening (*GetDoc());
196 EndListening (*GetDocSh());
198 if( SlideShow::IsRunning(*this) )
199 StopSlideShow(false);
204 USHORT aPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
206 for (USHORT i
= 0; i
< aPageCnt
; i
++)
208 pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
210 if (pPage
== mpActualPage
)
212 GetDoc()->SetSelected(pPage
, TRUE
);
216 GetDoc()->SetSelected(pPage
, FALSE
);
220 if ( mpClipEvtLstnr
)
222 mpClipEvtLstnr
->AddRemoveListener( GetActiveWindow(), FALSE
);
223 mpClipEvtLstnr
->ClearCallbackLink(); // #103849# prevent callback if another thread is waiting
224 mpClipEvtLstnr
->release();
228 // Set mpView to NULL so that the destructor of the ViewShell base class
229 // does not access it.
230 mpView
= mpDrawView
= NULL
;
232 mpFrameView
->Disconnect();
233 delete [] mpSlotArray
;
236 /*************************************************************************
238 |* gemeinsamer Initialisierungsanteil der beiden Konstruktoren
240 \************************************************************************/
242 void DrawViewShell::Construct(DrawDocShell
* pDocSh
, PageKind eInitialPageKind
)
245 mbMousePosFreezed
= FALSE
;
246 mbReadOnly
= GetDocSh()->IsReadOnly();
249 mbPastePossible
= FALSE
;
250 mbIsLayerModeActive
= false;
252 mpFrameView
->Connect();
254 OSL_ASSERT (GetViewShell()!=NULL
);
256 // Array fuer Slot-/ImageMapping:
257 // Gerader Eintrag: Haupt-/ToolboxSlot
258 // Ungerader Eintrag: gemappter Slot
259 // Achtung: Anpassen von GetIdBySubId() !!!
260 // Reihenfolge (insbesondere Zoom) darf nicht geaendert werden !!!
261 mpSlotArray
= new USHORT
[ SLOTARRAY_COUNT
];
262 mpSlotArray
[ 0 ] = SID_OBJECT_CHOOSE_MODE
;
263 mpSlotArray
[ 1 ] = SID_OBJECT_ROTATE
;
264 mpSlotArray
[ 2 ] = SID_OBJECT_ALIGN
;
265 mpSlotArray
[ 3 ] = SID_OBJECT_ALIGN_LEFT
;
266 mpSlotArray
[ 4 ] = SID_ZOOM_TOOLBOX
;
267 mpSlotArray
[ 5 ] = SID_ZOOM_TOOLBOX
;
268 mpSlotArray
[ 6 ] = SID_DRAWTBX_TEXT
;
269 mpSlotArray
[ 7 ] = SID_ATTR_CHAR
;
270 mpSlotArray
[ 8 ] = SID_DRAWTBX_RECTANGLES
;
271 mpSlotArray
[ 9 ] = SID_DRAW_RECT
;
272 mpSlotArray
[ 10 ] = SID_DRAWTBX_ELLIPSES
;
273 mpSlotArray
[ 11 ] = SID_DRAW_ELLIPSE
;
274 mpSlotArray
[ 12 ] = SID_DRAWTBX_LINES
;
275 mpSlotArray
[ 13 ] = SID_DRAW_FREELINE_NOFILL
;
276 mpSlotArray
[ 14 ] = SID_DRAWTBX_3D_OBJECTS
;
277 mpSlotArray
[ 15 ] = SID_3D_CUBE
;
278 mpSlotArray
[ 16 ] = SID_DRAWTBX_INSERT
;
279 mpSlotArray
[ 17 ] = SID_INSERT_DIAGRAM
;
280 mpSlotArray
[ 18 ] = SID_POSITION
;
281 mpSlotArray
[ 19 ] = SID_FRAME_TO_TOP
;
282 mpSlotArray
[ 20 ] = SID_DRAWTBX_CONNECTORS
;
283 mpSlotArray
[ 21 ] = SID_TOOL_CONNECTOR
;
284 mpSlotArray
[ 22 ] = SID_DRAWTBX_ARROWS
;
285 mpSlotArray
[ 23 ] = SID_LINE_ARROW_END
;
287 SetPool( &GetDoc()->GetPool() );
289 GetDoc()->CreateFirstPages();
291 mpDrawView
= new DrawView(pDocSh
, GetActiveWindow(), this);
292 mpView
= mpDrawView
; // Pointer der Basisklasse ViewShell
293 mpDrawView
->SetSwapAsynchron(TRUE
); // Asynchrones Laden von Graphiken
295 // We do not read the page kind from the frame view anymore so we have
296 // to set it in order to resync frame view and this view.
297 mpFrameView
->SetPageKind(eInitialPageKind
);
298 mePageKind
= eInitialPageKind
;
299 meEditMode
= EM_PAGE
;
300 DocumentType eDocType
= GetDoc()->GetDocumentType(); // RTTI fasst hier noch nicht
304 meShellType
= ST_IMPRESS
;
308 meShellType
= ST_NOTES
;
312 meShellType
= ST_HANDOUT
;
316 Size
aPageSize( GetDoc()->GetSdPage(0, mePageKind
)->GetSize() );
317 Point
aPageOrg( aPageSize
.Width(), aPageSize
.Height() / 2);
318 Size
aSize(aPageSize
.Width() * 3, aPageSize
.Height() * 2);
319 InitWindows(aPageOrg
, aSize
, Point(-1, -1));
323 if ( pDocSh
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
325 aVisAreaPos
= pDocSh
->GetVisArea(ASPECT_CONTENT
).TopLeft();
328 mpDrawView
->SetWorkArea(Rectangle(Point() - aVisAreaPos
- aPageOrg
, aSize
));
330 // Objekte koennen max. so gross wie die ViewSize werden
331 GetDoc()->SetMaxObjSize(aSize
);
333 // Split-Handler fuer TabControls
334 maTabControl
.SetSplitHdl( LINK( this, DrawViewShell
, TabSplitHdl
) );
336 // Damit der richtige EditMode von der FrameView komplett eingestellt
337 // werden kann, wird hier ein aktuell anderer gewaehlt (kleiner Trick)
338 if (mpFrameView
->GetViewShEditMode(mePageKind
) == EM_PAGE
)
340 meEditMode
= EM_MASTERPAGE
;
344 meEditMode
= EM_PAGE
;
347 // Einstellungen der FrameView uebernehmen
348 ReadFrameViewData(mpFrameView
);
350 if( eDocType
== DOCUMENT_TYPE_DRAW
)
352 SetHelpId( SD_IF_SDGRAPHICVIEWSHELL
);
353 GetActiveWindow()->SetHelpId( SD_IF_SDGRAPHICVIEWSHELL
);
354 GetActiveWindow()->SetUniqueId( SD_IF_SDGRAPHICVIEWSHELL
);
358 if (mePageKind
== PK_NOTES
)
360 SetHelpId( SID_NOTESMODE
);
361 GetActiveWindow()->SetHelpId( SID_NOTESMODE
);
362 GetActiveWindow()->SetUniqueId( SID_NOTESMODE
);
364 // AutoLayouts muessen erzeugt sein
365 GetDoc()->StopWorkStartupDelay();
367 else if (mePageKind
== PK_HANDOUT
)
369 SetHelpId( SID_HANDOUTMODE
);
370 GetActiveWindow()->SetHelpId( SID_HANDOUTMODE
);
371 GetActiveWindow()->SetUniqueId( SID_HANDOUTMODE
);
373 // AutoLayouts muessen erzeugt sein
374 GetDoc()->StopWorkStartupDelay();
378 SetHelpId( SD_IF_SDDRAWVIEWSHELL
);
379 GetActiveWindow()->SetHelpId( SD_IF_SDDRAWVIEWSHELL
);
380 GetActiveWindow()->SetUniqueId( SD_IF_SDDRAWVIEWSHELL
);
384 // Selektionsfunktion starten
385 SfxRequest
aReq(SID_OBJECT_SELECT
, 0, GetDoc()->GetItemPool());
387 mpDrawView
->SetFrameDragSingles(TRUE
);
389 if (pDocSh
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
391 mbZoomOnPage
= FALSE
;
398 mbIsRulerDrag
= FALSE
;
400 String
aName( RTL_CONSTASCII_USTRINGPARAM("DrawViewShell"));
405 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xMgr( ::comphelper::getProcessServiceFactory() );
409 mxScannerManager
= ::com::sun::star::uno::Reference
< ::com::sun::star::scanner::XScannerManager
>(
410 xMgr
->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.scanner.ScannerManager" ) ),
411 ::com::sun::star::uno::UNO_QUERY
);
413 if( mxScannerManager
.is() )
415 mxScannerListener
= ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>(
416 static_cast< ::cppu::OWeakObject
* >( new ScannerEventListener( this ) ),
417 ::com::sun::star::uno::UNO_QUERY
);
421 mpAnnotationManager
.reset( new AnnotationManager( GetViewShellBase() ) );
427 void DrawViewShell::Init (bool bIsMainViewShell
)
429 ViewShell::Init(bIsMainViewShell
);
431 StartListening (*GetDocSh());
437 void DrawViewShell::Shutdown (void)
439 ViewShell::Shutdown();
441 if(SlideShow::IsRunning( GetViewShellBase() ) )
444 GetDrawView()->SetAnimationMode(SDR_ANIMATION_DISABLE
);
451 css::uno::Reference
<css::drawing::XDrawSubController
> DrawViewShell::CreateSubController (void)
453 css::uno::Reference
<css::drawing::XDrawSubController
> xSubController
;
455 if (IsMainViewShell())
457 // Create uno sub controller for the main view shell.
458 xSubController
= css::uno::Reference
<css::drawing::XDrawSubController
>(
460 GetViewShellBase().GetDrawController(),
465 return xSubController
;
471 bool DrawViewShell::RelocateToParentWindow (::Window
* pParentWindow
)
473 // DrawViewShells can not be relocated to a new parent window at the
474 // moment, so return <FALSE/> except when the given parent window is the
475 // parent window that is already in use.
476 return pParentWindow
==GetParentWindow();
482 /*************************************************************************
484 |* pruefe ob linienzuege gezeichnet werden muessen
486 \************************************************************************/
489 linienzuege werden ueber makros als folge von
491 LineTo (x, y) [oder BezierTo (x, y)]
494 dargestellt. einen endbefehl fuer die linienzuege
495 gibt es nicht, also muessen alle befehle in den
496 requests nach LineTo (BezierTo) abgetestet und die
497 punktparameter gesammelt werden.
498 der erste nicht-LineTo fuehrt dann dazu, dass aus
499 den gesammelten punkten der linienzug erzeugt wird
502 void DrawViewShell::CheckLineTo(SfxRequest
& rReq
)
508 if(SID_LINETO
== rReq
.GetSlot() || SID_BEZIERTO
== rReq
.GetSlot() || SID_MOVETO
== rReq
.GetSlot() )
510 DBG_ERROR("DrawViewShell::CheckLineTo: slots SID_LINETO, SID_BEZIERTO, SID_MOVETO no longer supported.");
518 /*************************************************************************
520 |* veraendere die seitemparameter, wenn SID_PAGESIZE oder SID_PAGEMARGIN
522 \************************************************************************/
524 void DrawViewShell::SetupPage (Size
&rSize
,
533 USHORT nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
536 for (i
= 0; i
< nPageCnt
; i
++)
538 /**********************************************************************
539 * Erst alle MasterPages bearbeiten
540 **********************************************************************/
541 SdPage
*pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
547 Rectangle
aBorderRect(nLeft
, nUpper
, nRight
, nLower
);
548 pPage
->ScaleObjects(rSize
, aBorderRect
, bScaleAll
);
549 pPage
->SetSize(rSize
);
554 pPage
->SetLftBorder(nLeft
);
555 pPage
->SetRgtBorder(nRight
);
556 pPage
->SetUppBorder(nUpper
);
557 pPage
->SetLwrBorder(nLower
);
560 if ( mePageKind
== PK_STANDARD
)
562 GetDoc()->GetMasterSdPage(i
, PK_NOTES
)->CreateTitleAndLayout();
565 pPage
->CreateTitleAndLayout();
569 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
571 for (i
= 0; i
< nPageCnt
; i
++)
573 /**********************************************************************
574 * Danach alle Pages bearbeiten
575 **********************************************************************/
576 SdPage
*pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
582 Rectangle
aBorderRect(nLeft
, nUpper
, nRight
, nLower
);
583 pPage
->ScaleObjects(rSize
, aBorderRect
, bScaleAll
);
584 pPage
->SetSize(rSize
);
588 pPage
->SetLftBorder(nLeft
);
589 pPage
->SetRgtBorder(nRight
);
590 pPage
->SetUppBorder(nUpper
);
591 pPage
->SetLwrBorder(nLower
);
594 if ( mePageKind
== PK_STANDARD
)
596 SdPage
* pNotesPage
= GetDoc()->GetSdPage(i
, PK_NOTES
);
597 pNotesPage
->SetAutoLayout( pNotesPage
->GetAutoLayout() );
600 pPage
->SetAutoLayout( pPage
->GetAutoLayout() );
604 if ( mePageKind
== PK_STANDARD
)
606 SdPage
* pHandoutPage
= GetDoc()->GetSdPage(0, PK_HANDOUT
);
607 pHandoutPage
->CreateTitleAndLayout(TRUE
);
610 long nWidth
= mpActualPage
->GetSize().Width();
611 long nHeight
= mpActualPage
->GetSize().Height();
613 Point
aPageOrg(nWidth
, nHeight
/ 2);
614 Size
aSize( nWidth
* 3, nHeight
* 2);
616 InitWindows(aPageOrg
, aSize
, Point(-1, -1), TRUE
);
620 if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
622 aVisAreaPos
= GetDocSh()->GetVisArea(ASPECT_CONTENT
).TopLeft();
625 GetView()->SetWorkArea(Rectangle(Point() - aVisAreaPos
- aPageOrg
, aSize
));
629 Point
aNewOrigin(mpActualPage
->GetLftBorder(), mpActualPage
->GetUppBorder());
630 GetView()->GetSdrPageView()->SetPageOrigin(aNewOrigin
);
632 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET
);
634 // auf (neue) Seitengroesse zoomen
635 GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE
,
636 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
639 /*************************************************************************
641 |* Statuswerte der Statusbar zurueckgeben
643 \************************************************************************/
645 void DrawViewShell::GetStatusBarState(SfxItemSet
& rSet
)
648 // Hier sollte der entsprechende Wert (Optimal ?, Seitenbreite oder
649 // Seite) mit Hilfe des ZoomItems weitergegeben werden !!!
650 if( SFX_ITEM_AVAILABLE
== rSet
.GetItemState( SID_ATTR_ZOOM
) )
652 if (GetDocSh()->IsUIActive() || (SlideShow::IsRunning(GetViewShellBase())) )
654 rSet
.DisableItem( SID_ATTR_ZOOM
);
658 SvxZoomItem
* pZoomItem
;
659 UINT16 nZoom
= (UINT16
) GetActiveWindow()->GetZoom();
662 pZoomItem
= new SvxZoomItem( SVX_ZOOM_WHOLEPAGE
, nZoom
);
664 pZoomItem
= new SvxZoomItem( SVX_ZOOM_PERCENT
, nZoom
);
666 // Bereich einschraenken
667 USHORT nZoomValues
= SVX_ZOOM_ENABLE_ALL
;
668 SdrPageView
* pPageView
= mpDrawView
->GetSdrPageView();
670 if( ( pPageView
&& pPageView
->GetObjList()->GetObjCount() == 0 ) )
671 // || ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 0 ) )
673 nZoomValues
&= ~SVX_ZOOM_ENABLE_OPTIMAL
;
676 pZoomItem
->SetValueSet( nZoomValues
);
677 rSet
.Put( *pZoomItem
);
681 if( SFX_ITEM_AVAILABLE
== rSet
.GetItemState( SID_ATTR_ZOOMSLIDER
) )
683 rtl::Reference
< sd::SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
684 if (GetDocSh()->IsUIActive() || (xSlideshow
.is() && xSlideshow
->isRunning()) || !GetActiveWindow() )
686 rSet
.DisableItem( SID_ATTR_ZOOMSLIDER
);
690 sd::Window
* pActiveWindow
= GetActiveWindow();
691 SvxZoomSliderItem
aZoomItem( (UINT16
) pActiveWindow
->GetZoom(), (USHORT
)pActiveWindow
->GetMinZoom(), (USHORT
)pActiveWindow
->GetMaxZoom() ) ;
693 SdrPageView
* pPageView
= mpDrawView
->GetSdrPageView();
696 Point
aPagePos(0, 0);
697 Size aPageSize
= pPageView
->GetPage()->GetSize();
699 aPagePos
.X() += aPageSize
.Width() / 2;
700 aPageSize
.Width() = (long) (aPageSize
.Width() * 1.03);
702 aPagePos
.Y() += aPageSize
.Height() / 2;
703 aPageSize
.Height() = (long) (aPageSize
.Height() * 1.03);
704 aPagePos
.Y() -= aPageSize
.Height() / 2;
706 aPagePos
.X() -= aPageSize
.Width() / 2;
708 Rectangle
aFullPageZoomRect( aPagePos
, aPageSize
);
709 aZoomItem
.AddSnappingPoint( pActiveWindow
->GetZoomForRect( aFullPageZoomRect
) );
711 aZoomItem
.AddSnappingPoint(100);
712 rSet
.Put( aZoomItem
);
716 Point aPos
= GetActiveWindow()->PixelToLogic(maMousePos
);
717 mpDrawView
->GetSdrPageView()->LogicToPagePos(aPos
);
718 Fraction
aUIScale(GetDoc()->GetUIScale());
719 aPos
.X() = Fraction(aPos
.X()) / aUIScale
;
720 aPos
.Y() = Fraction(aPos
.Y()) / aUIScale
;
722 // Position- und Groesse-Items
723 if ( mpDrawView
->IsAction() )
726 mpDrawView
->TakeActionRect( aRect
);
728 if ( aRect
.IsEmpty() )
729 rSet
.Put( SfxPointItem(SID_ATTR_POSITION
, aPos
) );
732 mpDrawView
->GetSdrPageView()->LogicToPagePos(aRect
);
733 aPos
= aRect
.TopLeft();
734 aPos
.X() = Fraction(aPos
.X()) / aUIScale
;
735 aPos
.Y() = Fraction(aPos
.Y()) / aUIScale
;
736 rSet
.Put( SfxPointItem( SID_ATTR_POSITION
, aPos
) );
737 Size
aSize( aRect
.Right() - aRect
.Left(), aRect
.Bottom() - aRect
.Top() );
738 aSize
.Height() = Fraction(aSize
.Height()) / aUIScale
;
739 aSize
.Width() = Fraction(aSize
.Width()) / aUIScale
;
740 rSet
.Put( SvxSizeItem( SID_ATTR_SIZE
, aSize
) );
745 if ( mpDrawView
->AreObjectsMarked() )
747 Rectangle aRect
= mpDrawView
->GetAllMarkedRect();
748 mpDrawView
->GetSdrPageView()->LogicToPagePos(aRect
);
750 // Show the position of the selected shape(s)
751 Point
aShapePosition (aRect
.TopLeft());
752 aShapePosition
.X() = Fraction(aShapePosition
.X()) / aUIScale
;
753 aShapePosition
.Y() = Fraction(aShapePosition
.Y()) / aUIScale
;
754 rSet
.Put (SfxPointItem(SID_ATTR_POSITION
, aShapePosition
));
756 Size
aSize( aRect
.Right() - aRect
.Left(), aRect
.Bottom() - aRect
.Top() );
757 aSize
.Height() = Fraction(aSize
.Height()) / aUIScale
;
758 aSize
.Width() = Fraction(aSize
.Width()) / aUIScale
;
759 rSet
.Put( SvxSizeItem( SID_ATTR_SIZE
, aSize
) );
763 rSet
.Put( SfxPointItem(SID_ATTR_POSITION
, aPos
) );
764 rSet
.Put( SvxSizeItem( SID_ATTR_SIZE
, Size( 0, 0 ) ) );
768 // Display of current page and layer.
769 if( SFX_ITEM_AVAILABLE
== rSet
.GetItemState( SID_STATUS_PAGE
) )
771 // Allways show the slide/page number.
772 String
aString (SdResId( STR_SD_PAGE
));
773 aString
+= sal_Unicode(' ');
774 aString
+= UniString::CreateFromInt32( maTabControl
.GetCurPageId() );
775 aString
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " ));
776 aString
+= UniString::CreateFromInt32( GetDoc()->GetSdPageCount( mePageKind
) );
778 // If in layer mode additionally show the layer that contains all
779 // selected shapes of the page. If the shapes are distributed on
780 // more than one layer, no layer name is shown.
781 if (IsLayerModeActive())
783 SdrLayerAdmin
& rLayerAdmin
= GetDoc()->GetLayerAdmin();
784 SdrLayerID nLayer
= 0, nOldLayer
= 0;
785 SdrLayer
* pLayer
= NULL
;
786 SdrObject
* pObj
= NULL
;
787 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
788 ULONG nMarkCount
= rMarkList
.GetMarkCount();
789 FASTBOOL bOneLayer
= TRUE
;
791 // Use the first ten selected shapes as a (hopefully
792 // representative) sample of all shapes of the current page.
793 // Detect whether they belong to the same layer.
794 for( ULONG j
= 0; j
< nMarkCount
&& bOneLayer
&& j
< 10; j
++ )
796 pObj
= rMarkList
.GetMark( j
)->GetMarkedSdrObj();
799 nLayer
= pObj
->GetLayer();
801 if( j
!= 0 && nLayer
!= nOldLayer
)
808 // Append the layer name to the current page number.
809 if( bOneLayer
&& nMarkCount
)
811 pLayer
= rLayerAdmin
.GetLayerPerID( nLayer
);
814 aString
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ));
815 aString
+= pLayer
->GetName();
816 aString
+= sal_Unicode(')');
821 rSet
.Put (SfxStringItem (SID_STATUS_PAGE
, aString
));
824 if( SFX_ITEM_AVAILABLE
== rSet
.GetItemState( SID_STATUS_LAYOUT
) )
826 String aString
= mpActualPage
->GetLayoutName();
827 aString
.Erase( aString
.SearchAscii( SD_LT_SEPARATOR
) );
828 rSet
.Put( SfxStringItem( SID_STATUS_LAYOUT
, aString
) );
834 void DrawViewShell::Notify (SfxBroadcaster
&, const SfxHint
& rHint
)
836 const SfxSimpleHint
* pSimple
= dynamic_cast< const SfxSimpleHint
* >(&rHint
);
837 if (pSimple
!=NULL
&& pSimple
->GetId()==SFX_HINT_MODECHANGED
)
839 // Change to selection when turning on read-only mode.
840 if(GetDocSh()->IsReadOnly() && dynamic_cast< FuSelection
* >( GetCurrentFunction().get() ) )
842 SfxRequest
aReq(SID_OBJECT_SELECT
, 0, GetDoc()->GetItemPool());
846 // Turn on design mode when document is not read-only.
847 if (GetDocSh()->IsReadOnly() != mbReadOnly
)
849 mbReadOnly
= GetDocSh()->IsReadOnly();
851 SfxBoolItem
aItem( SID_FM_DESIGN_MODE
, !mbReadOnly
);
852 GetViewFrame()->GetDispatcher()->Execute( SID_FM_DESIGN_MODE
,
853 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
, &aItem
, 0L );
859 void DrawViewShell::ExecuteAnnotation (SfxRequest
& rRequest
)
861 if( mpAnnotationManager
.get() )
862 mpAnnotationManager
->ExecuteAnnotation( rRequest
);
865 // --------------------------------------------------------------------
867 void DrawViewShell::GetAnnotationState (SfxItemSet
& rItemSet
)
869 if( mpAnnotationManager
.get() )
870 mpAnnotationManager
->GetAnnotationState( rItemSet
);
874 } // end of namespace sd