update dev300-m58
[ooovba.git] / sd / source / ui / view / drviewsa.cxx
blob39cee38ae36b8b693301684bdb3eb2541a0b029e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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>
37 #ifndef _SVX_SIZEITEM
38 #include <svx/sizeitem.hxx>
39 #endif
40 #include <svx/svdlayer.hxx>
41 #ifndef _SVX_ZOOMITEM
42 #include <svx/zoomitem.hxx>
43 #endif
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>
56 #endif
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>
68 #include "app.hrc"
69 #include "helpids.h"
70 #include "strings.hrc"
71 #include "res_bmp.hrc"
72 #include "sdpage.hxx"
73 #include "FrameView.hxx"
74 #include "drawdoc.hxx"
75 #include "sdresid.hxx"
76 #include "DrawDocShell.hxx"
77 #include "Window.hxx"
78 #include "fupoor.hxx"
79 #include "fusel.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"
87 using namespace ::rtl;
88 using namespace ::com::sun::star;
89 using namespace ::com::sun::star::uno;
91 namespace {
92 static const ::rtl::OUString MASTER_VIEW_TOOL_BAR_NAME(
93 ::rtl::OUString::createFromAscii("masterviewtoolbar"));
96 namespace sd {
98 BOOL DrawViewShell::mbPipette = FALSE;
100 // ------------------------
101 // - ScannerEventListener -
102 // ------------------------
104 class ScannerEventListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener >
106 private:
108 DrawViewShell* mpParent;
110 public:
112 ScannerEventListener( DrawViewShell* pParent ) : mpParent( pParent ) {};
113 ~ScannerEventListener();
115 // XEventListener
116 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rEventObject ) throw (::com::sun::star::uno::RuntimeException);
118 void ParentDestroyed() { mpParent = NULL; }
121 // -----------------------------------------------------------------------------
123 ScannerEventListener::~ScannerEventListener()
127 // -----------------------------------------------------------------------------
129 void SAL_CALL ScannerEventListener::disposing( const ::com::sun::star::lang::EventObject& rEventObject ) throw (::com::sun::star::uno::RuntimeException)
131 if( mpParent )
132 mpParent->ScannerEvent( rEventObject );
135 /*************************************************************************
137 |* Standard-Konstruktor
139 \************************************************************************/
141 DrawViewShell::DrawViewShell (
142 SfxViewFrame* pFrame,
143 ViewShellBase& rViewShellBase,
144 ::Window* pParentWindow,
145 PageKind ePageKind,
146 FrameView* pFrameViewArgument)
147 : ViewShell (pFrame, pParentWindow, rViewShellBase),
148 maTabControl(this, pParentWindow),
149 mbIsInSwitchPage(false)
151 if (pFrameViewArgument != NULL)
152 mpFrameView = pFrameViewArgument;
153 else
154 mpFrameView = new FrameView(GetDoc());
155 Construct(GetDocSh(), ePageKind);
158 /*************************************************************************
160 |* Copy-Konstruktor
162 \************************************************************************/
164 DrawViewShell::DrawViewShell (
165 SfxViewFrame* pFrame,
166 ::Window* pParentWindow,
167 const DrawViewShell& rShell)
168 : ViewShell(pFrame, pParentWindow, rShell),
169 maTabControl(this, pParentWindow),
170 mbIsInSwitchPage(false)
172 mpFrameView = new FrameView(GetDoc());
173 Construct (GetDocSh(), PK_STANDARD);
176 /*************************************************************************
178 |* Destruktor
180 \************************************************************************/
182 DrawViewShell::~DrawViewShell()
184 OSL_ASSERT (GetViewShell()!=NULL);
186 if( mxScannerListener.is() )
187 static_cast< ScannerEventListener* >( mxScannerListener.get() )->ParentDestroyed();
189 // #96642# Remove references to items within Svx3DWin
190 // (maybe do a listening sometime in Svx3DWin)
191 USHORT nId = Svx3DChildWindow::GetChildWindowId();
192 SfxChildWindow* pWindow = GetViewFrame() ? GetViewFrame()->GetChildWindow(nId) : NULL;
193 if(pWindow)
195 Svx3DWin* p3DWin = static_cast< Svx3DWin* > (pWindow->GetWindow());
196 if(p3DWin)
197 p3DWin->DocumentReload();
200 EndListening (*GetDoc());
201 EndListening (*GetDocSh());
203 if( SlideShow::IsRunning(*this) )
204 StopSlideShow(false);
206 DisposeFunctions();
208 SdPage* pPage;
209 USHORT aPageCnt = GetDoc()->GetSdPageCount(mePageKind);
211 for (USHORT i = 0; i < aPageCnt; i++)
213 pPage = GetDoc()->GetSdPage(i, mePageKind);
215 if (pPage == mpActualPage)
217 GetDoc()->SetSelected(pPage, TRUE);
219 else
221 GetDoc()->SetSelected(pPage, FALSE);
225 if ( mpClipEvtLstnr )
227 mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), FALSE );
228 mpClipEvtLstnr->ClearCallbackLink(); // #103849# prevent callback if another thread is waiting
229 mpClipEvtLstnr->release();
232 delete mpDrawView;
233 // Set mpView to NULL so that the destructor of the ViewShell base class
234 // does not access it.
235 mpView = mpDrawView = NULL;
237 mpFrameView->Disconnect();
238 delete [] mpSlotArray;
241 /*************************************************************************
243 |* gemeinsamer Initialisierungsanteil der beiden Konstruktoren
245 \************************************************************************/
247 void DrawViewShell::Construct(DrawDocShell* pDocSh, PageKind eInitialPageKind)
249 mpActualPage = 0;
250 mbMousePosFreezed = FALSE;
251 mbReadOnly = GetDocSh()->IsReadOnly();
252 mpSlotArray = 0;
253 mpClipEvtLstnr = 0;
254 mbPastePossible = FALSE;
255 mbIsLayerModeActive = false;
257 mpFrameView->Connect();
259 OSL_ASSERT (GetViewShell()!=NULL);
261 // Array fuer Slot-/ImageMapping:
262 // Gerader Eintrag: Haupt-/ToolboxSlot
263 // Ungerader Eintrag: gemappter Slot
264 // Achtung: Anpassen von GetIdBySubId() !!!
265 // Reihenfolge (insbesondere Zoom) darf nicht geaendert werden !!!
266 mpSlotArray = new USHORT[ SLOTARRAY_COUNT ];
267 mpSlotArray[ 0 ] = SID_OBJECT_CHOOSE_MODE;
268 mpSlotArray[ 1 ] = SID_OBJECT_ROTATE;
269 mpSlotArray[ 2 ] = SID_OBJECT_ALIGN;
270 mpSlotArray[ 3 ] = SID_OBJECT_ALIGN_LEFT;
271 mpSlotArray[ 4 ] = SID_ZOOM_TOOLBOX;
272 mpSlotArray[ 5 ] = SID_ZOOM_TOOLBOX;
273 mpSlotArray[ 6 ] = SID_DRAWTBX_TEXT;
274 mpSlotArray[ 7 ] = SID_ATTR_CHAR;
275 mpSlotArray[ 8 ] = SID_DRAWTBX_RECTANGLES;
276 mpSlotArray[ 9 ] = SID_DRAW_RECT;
277 mpSlotArray[ 10 ] = SID_DRAWTBX_ELLIPSES;
278 mpSlotArray[ 11 ] = SID_DRAW_ELLIPSE;
279 mpSlotArray[ 12 ] = SID_DRAWTBX_LINES;
280 mpSlotArray[ 13 ] = SID_DRAW_FREELINE_NOFILL;
281 mpSlotArray[ 14 ] = SID_DRAWTBX_3D_OBJECTS;
282 mpSlotArray[ 15 ] = SID_3D_CUBE;
283 mpSlotArray[ 16 ] = SID_DRAWTBX_INSERT;
284 mpSlotArray[ 17 ] = SID_INSERT_DIAGRAM;
285 mpSlotArray[ 18 ] = SID_POSITION;
286 mpSlotArray[ 19 ] = SID_FRAME_TO_TOP;
287 mpSlotArray[ 20 ] = SID_DRAWTBX_CONNECTORS;
288 mpSlotArray[ 21 ] = SID_TOOL_CONNECTOR;
289 mpSlotArray[ 22 ] = SID_DRAWTBX_ARROWS;
290 mpSlotArray[ 23 ] = SID_LINE_ARROW_END;
292 SetPool( &GetDoc()->GetPool() );
294 GetDoc()->CreateFirstPages();
296 mpDrawView = new DrawView(pDocSh, GetActiveWindow(), this);
297 mpView = mpDrawView; // Pointer der Basisklasse ViewShell
298 mpDrawView->SetSwapAsynchron(TRUE); // Asynchrones Laden von Graphiken
300 // We do not read the page kind from the frame view anymore so we have
301 // to set it in order to resync frame view and this view.
302 mpFrameView->SetPageKind(eInitialPageKind);
303 mePageKind = eInitialPageKind;
304 meEditMode = EM_PAGE;
305 DocumentType eDocType = GetDoc()->GetDocumentType(); // RTTI fasst hier noch nicht
306 switch (mePageKind)
308 case PK_STANDARD:
309 meShellType = ST_IMPRESS;
310 break;
312 case PK_NOTES:
313 meShellType = ST_NOTES;
314 break;
316 case PK_HANDOUT:
317 meShellType = ST_HANDOUT;
318 break;
321 Size aPageSize( GetDoc()->GetSdPage(0, mePageKind)->GetSize() );
322 Point aPageOrg( aPageSize.Width(), aPageSize.Height() / 2);
323 Size aSize(aPageSize.Width() * 3, aPageSize.Height() * 2);
324 InitWindows(aPageOrg, aSize, Point(-1, -1));
326 Point aVisAreaPos;
328 if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
330 aVisAreaPos = pDocSh->GetVisArea(ASPECT_CONTENT).TopLeft();
333 mpDrawView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
335 // Objekte koennen max. so gross wie die ViewSize werden
336 GetDoc()->SetMaxObjSize(aSize);
338 // Split-Handler fuer TabControls
339 maTabControl.SetSplitHdl( LINK( this, DrawViewShell, TabSplitHdl ) );
341 // Damit der richtige EditMode von der FrameView komplett eingestellt
342 // werden kann, wird hier ein aktuell anderer gewaehlt (kleiner Trick)
343 if (mpFrameView->GetViewShEditMode(mePageKind) == EM_PAGE)
345 meEditMode = EM_MASTERPAGE;
347 else
349 meEditMode = EM_PAGE;
352 // Einstellungen der FrameView uebernehmen
353 ReadFrameViewData(mpFrameView);
355 if( eDocType == DOCUMENT_TYPE_DRAW )
357 SetHelpId( SD_IF_SDGRAPHICVIEWSHELL );
358 GetActiveWindow()->SetHelpId( SD_IF_SDGRAPHICVIEWSHELL );
359 GetActiveWindow()->SetUniqueId( SD_IF_SDGRAPHICVIEWSHELL );
361 else
363 if (mePageKind == PK_NOTES)
365 SetHelpId( SID_NOTESMODE );
366 GetActiveWindow()->SetHelpId( SID_NOTESMODE );
367 GetActiveWindow()->SetUniqueId( SID_NOTESMODE );
369 // AutoLayouts muessen erzeugt sein
370 GetDoc()->StopWorkStartupDelay();
372 else if (mePageKind == PK_HANDOUT)
374 SetHelpId( SID_HANDOUTMODE );
375 GetActiveWindow()->SetHelpId( SID_HANDOUTMODE );
376 GetActiveWindow()->SetUniqueId( SID_HANDOUTMODE );
378 // AutoLayouts muessen erzeugt sein
379 GetDoc()->StopWorkStartupDelay();
381 else
383 SetHelpId( SD_IF_SDDRAWVIEWSHELL );
384 GetActiveWindow()->SetHelpId( SD_IF_SDDRAWVIEWSHELL );
385 GetActiveWindow()->SetUniqueId( SD_IF_SDDRAWVIEWSHELL );
389 // Selektionsfunktion starten
390 SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool());
391 FuPermanent(aReq);
392 mpDrawView->SetFrameDragSingles(TRUE);
394 if (pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
396 mbZoomOnPage = FALSE;
398 else
400 mbZoomOnPage = TRUE;
403 mbIsRulerDrag = FALSE;
405 String aName( RTL_CONSTASCII_USTRINGPARAM("DrawViewShell"));
406 SetName (aName);
408 mnLockCount = 0UL;
410 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
412 if( xMgr.is() )
414 mxScannerManager = ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager >(
415 xMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.scanner.ScannerManager" ) ),
416 ::com::sun::star::uno::UNO_QUERY );
418 if( mxScannerManager.is() )
420 mxScannerListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >(
421 static_cast< ::cppu::OWeakObject* >( new ScannerEventListener( this ) ),
422 ::com::sun::star::uno::UNO_QUERY );
430 void DrawViewShell::Init (bool bIsMainViewShell)
432 ViewShell::Init(bIsMainViewShell);
434 StartListening (*GetDocSh());
440 void DrawViewShell::Shutdown (void)
442 ViewShell::Shutdown();
444 if(SlideShow::IsRunning( GetViewShellBase() ) )
446 // Turn off effects.
447 GetDrawView()->SetAnimationMode(SDR_ANIMATION_DISABLE);
454 css::uno::Reference<css::drawing::XDrawSubController> DrawViewShell::CreateSubController (void)
456 css::uno::Reference<css::drawing::XDrawSubController> xSubController;
458 if (IsMainViewShell())
460 // Create uno sub controller for the main view shell.
461 xSubController = css::uno::Reference<css::drawing::XDrawSubController>(
462 new SdUnoDrawView (
463 GetViewShellBase().GetDrawController(),
464 *this,
465 *GetView()));
468 return xSubController;
474 bool DrawViewShell::RelocateToParentWindow (::Window* pParentWindow)
476 // DrawViewShells can not be relocated to a new parent window at the
477 // moment, so return <FALSE/> except when the given parent window is the
478 // parent window that is already in use.
479 return pParentWindow==GetParentWindow();
485 /*************************************************************************
487 |* pruefe ob linienzuege gezeichnet werden muessen
489 \************************************************************************/
492 linienzuege werden ueber makros als folge von
493 MoveTo (x, y)
494 LineTo (x, y) [oder BezierTo (x, y)]
495 LineTo (x, y)
497 dargestellt. einen endbefehl fuer die linienzuege
498 gibt es nicht, also muessen alle befehle in den
499 requests nach LineTo (BezierTo) abgetestet und die
500 punktparameter gesammelt werden.
501 der erste nicht-LineTo fuehrt dann dazu, dass aus
502 den gesammelten punkten der linienzug erzeugt wird
505 void DrawViewShell::CheckLineTo(SfxRequest& rReq)
507 (void)rReq;
508 #ifdef DBG_UTIL
509 if(rReq.IsAPI())
511 if(SID_LINETO == rReq.GetSlot() || SID_BEZIERTO == rReq.GetSlot() || SID_MOVETO == rReq.GetSlot() )
513 DBG_ERROR("DrawViewShell::CheckLineTo: slots SID_LINETO, SID_BEZIERTO, SID_MOVETO no longer supported.");
516 #endif
518 rReq.Ignore ();
521 /*************************************************************************
523 |* veraendere die seitemparameter, wenn SID_PAGESIZE oder SID_PAGEMARGIN
525 \************************************************************************/
527 void DrawViewShell::SetupPage (Size &rSize,
528 long nLeft,
529 long nRight,
530 long nUpper,
531 long nLower,
532 BOOL bSize,
533 BOOL bMargin,
534 BOOL bScaleAll)
536 USHORT nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
537 USHORT i;
539 for (i = 0; i < nPageCnt; i++)
541 /**********************************************************************
542 * Erst alle MasterPages bearbeiten
543 **********************************************************************/
544 SdPage *pPage = GetDoc()->GetMasterSdPage(i, mePageKind);
546 if( pPage )
548 if( bSize )
550 Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
551 pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
552 pPage->SetSize(rSize);
555 if( bMargin )
557 pPage->SetLftBorder(nLeft);
558 pPage->SetRgtBorder(nRight);
559 pPage->SetUppBorder(nUpper);
560 pPage->SetLwrBorder(nLower);
563 if ( mePageKind == PK_STANDARD )
565 GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout();
568 pPage->CreateTitleAndLayout();
572 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
574 for (i = 0; i < nPageCnt; i++)
576 /**********************************************************************
577 * Danach alle Pages bearbeiten
578 **********************************************************************/
579 SdPage *pPage = GetDoc()->GetSdPage(i, mePageKind);
581 if( pPage )
583 if( bSize )
585 Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
586 pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
587 pPage->SetSize(rSize);
589 if( bMargin )
591 pPage->SetLftBorder(nLeft);
592 pPage->SetRgtBorder(nRight);
593 pPage->SetUppBorder(nUpper);
594 pPage->SetLwrBorder(nLower);
597 if ( mePageKind == PK_STANDARD )
599 SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES);
600 pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
603 pPage->SetAutoLayout( pPage->GetAutoLayout() );
607 if ( mePageKind == PK_STANDARD )
609 SdPage* pHandoutPage = GetDoc()->GetSdPage(0, PK_HANDOUT);
610 pHandoutPage->CreateTitleAndLayout(TRUE);
613 long nWidth = mpActualPage->GetSize().Width();
614 long nHeight = mpActualPage->GetSize().Height();
616 Point aPageOrg(nWidth, nHeight / 2);
617 Size aSize( nWidth * 3, nHeight * 2);
619 InitWindows(aPageOrg, aSize, Point(-1, -1), TRUE);
621 Point aVisAreaPos;
623 if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
625 aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
628 GetView()->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
630 UpdateScrollBars();
632 Point aNewOrigin(mpActualPage->GetLftBorder(), mpActualPage->GetUppBorder());
633 GetView()->GetSdrPageView()->SetPageOrigin(aNewOrigin);
635 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
637 // auf (neue) Seitengroesse zoomen
638 GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE,
639 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
642 /*************************************************************************
644 |* Statuswerte der Statusbar zurueckgeben
646 \************************************************************************/
648 void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
650 // Zoom-Item
651 // Hier sollte der entsprechende Wert (Optimal ?, Seitenbreite oder
652 // Seite) mit Hilfe des ZoomItems weitergegeben werden !!!
653 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOM ) )
655 if (GetDocSh()->IsUIActive() || (SlideShow::IsRunning(GetViewShellBase())) )
657 rSet.DisableItem( SID_ATTR_ZOOM );
659 else
661 SvxZoomItem* pZoomItem;
662 UINT16 nZoom = (UINT16) GetActiveWindow()->GetZoom();
664 if( mbZoomOnPage )
665 pZoomItem = new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nZoom );
666 else
667 pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom );
669 // Bereich einschraenken
670 USHORT nZoomValues = SVX_ZOOM_ENABLE_ALL;
671 SdrPageView* pPageView = mpDrawView->GetSdrPageView();
673 if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
674 // || ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 0 ) )
676 nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
679 pZoomItem->SetValueSet( nZoomValues );
680 rSet.Put( *pZoomItem );
681 delete pZoomItem;
684 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) )
686 rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
687 if (GetDocSh()->IsUIActive() || (xSlideshow.is() && xSlideshow->isRunning()) || !GetActiveWindow() )
689 rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
691 else
693 sd::Window * pActiveWindow = GetActiveWindow();
694 SvxZoomSliderItem aZoomItem( (UINT16) pActiveWindow->GetZoom(), (USHORT)pActiveWindow->GetMinZoom(), (USHORT)pActiveWindow->GetMaxZoom() ) ;
696 SdrPageView* pPageView = mpDrawView->GetSdrPageView();
697 if( pPageView )
699 Point aPagePos(0, 0);
700 Size aPageSize = pPageView->GetPage()->GetSize();
702 aPagePos.X() += aPageSize.Width() / 2;
703 aPageSize.Width() = (long) (aPageSize.Width() * 1.03);
705 aPagePos.Y() += aPageSize.Height() / 2;
706 aPageSize.Height() = (long) (aPageSize.Height() * 1.03);
707 aPagePos.Y() -= aPageSize.Height() / 2;
709 aPagePos.X() -= aPageSize.Width() / 2;
711 Rectangle aFullPageZoomRect( aPagePos, aPageSize );
712 aZoomItem.AddSnappingPoint( pActiveWindow->GetZoomForRect( aFullPageZoomRect ) );
714 aZoomItem.AddSnappingPoint(100);
715 rSet.Put( aZoomItem );
719 Point aPos = GetActiveWindow()->PixelToLogic(maMousePos);
720 mpDrawView->GetSdrPageView()->LogicToPagePos(aPos);
721 Fraction aUIScale(GetDoc()->GetUIScale());
722 aPos.X() = Fraction(aPos.X()) / aUIScale;
723 aPos.Y() = Fraction(aPos.Y()) / aUIScale;
725 // Position- und Groesse-Items
726 if ( mpDrawView->IsAction() )
728 Rectangle aRect;
729 mpDrawView->TakeActionRect( aRect );
731 if ( aRect.IsEmpty() )
732 rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
733 else
735 mpDrawView->GetSdrPageView()->LogicToPagePos(aRect);
736 aPos = aRect.TopLeft();
737 aPos.X() = Fraction(aPos.X()) / aUIScale;
738 aPos.Y() = Fraction(aPos.Y()) / aUIScale;
739 rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos) );
740 Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
741 aSize.Height() = Fraction(aSize.Height()) / aUIScale;
742 aSize.Width() = Fraction(aSize.Width()) / aUIScale;
743 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
746 else
748 if ( mpDrawView->AreObjectsMarked() )
750 Rectangle aRect = mpDrawView->GetAllMarkedRect();
751 mpDrawView->GetSdrPageView()->LogicToPagePos(aRect);
753 // Show the position of the selected shape(s)
754 Point aShapePosition (aRect.TopLeft());
755 aShapePosition.X() = Fraction(aShapePosition.X()) / aUIScale;
756 aShapePosition.Y() = Fraction(aShapePosition.Y()) / aUIScale;
757 rSet.Put (SfxPointItem(SID_ATTR_POSITION, aShapePosition));
759 Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
760 aSize.Height() = Fraction(aSize.Height()) / aUIScale;
761 aSize.Width() = Fraction(aSize.Width()) / aUIScale;
762 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
764 else
766 rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
767 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
771 // Display of current page and layer.
772 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_PAGE ) )
774 // Allways show the slide/page number.
775 String aString (SdResId( STR_SD_PAGE ));
776 aString += sal_Unicode(' ');
777 aString += UniString::CreateFromInt32( maTabControl.GetCurPageId() );
778 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " ));
779 aString += UniString::CreateFromInt32( GetDoc()->GetSdPageCount( mePageKind ) );
781 // If in layer mode additionally show the layer that contains all
782 // selected shapes of the page. If the shapes are distributed on
783 // more than one layer, no layer name is shown.
784 if (IsLayerModeActive())
786 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
787 SdrLayerID nLayer = 0, nOldLayer = 0;
788 SdrLayer* pLayer = NULL;
789 SdrObject* pObj = NULL;
790 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
791 ULONG nMarkCount = rMarkList.GetMarkCount();
792 FASTBOOL bOneLayer = TRUE;
794 // Use the first ten selected shapes as a (hopefully
795 // representative) sample of all shapes of the current page.
796 // Detect whether they belong to the same layer.
797 for( ULONG j = 0; j < nMarkCount && bOneLayer && j < 10; j++ )
799 pObj = rMarkList.GetMark( j )->GetMarkedSdrObj();
800 if( pObj )
802 nLayer = pObj->GetLayer();
804 if( j != 0 && nLayer != nOldLayer )
805 bOneLayer = FALSE;
807 nOldLayer = nLayer;
811 // Append the layer name to the current page number.
812 if( bOneLayer && nMarkCount )
814 pLayer = rLayerAdmin.GetLayerPerID( nLayer );
815 if( pLayer )
817 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ));
818 aString += pLayer->GetName();
819 aString += sal_Unicode(')');
824 rSet.Put (SfxStringItem (SID_STATUS_PAGE, aString));
826 // Layout
827 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_LAYOUT ) )
829 String aString = mpActualPage->GetLayoutName();
830 aString.Erase( aString.SearchAscii( SD_LT_SEPARATOR ) );
831 rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aString ) );
837 void DrawViewShell::Notify (SfxBroadcaster&, const SfxHint& rHint)
839 const SfxSimpleHint* pSimple = dynamic_cast< const SfxSimpleHint* >(&rHint);
840 if (pSimple!=NULL && pSimple->GetId()==SFX_HINT_MODECHANGED)
842 // Change to selection when turning on read-only mode.
843 if(GetDocSh()->IsReadOnly() && dynamic_cast< FuSelection* >( GetCurrentFunction().get() ) )
845 SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool());
846 FuPermanent(aReq);
849 // Turn on design mode when document is not read-only.
850 if (GetDocSh()->IsReadOnly() != mbReadOnly )
852 mbReadOnly = GetDocSh()->IsReadOnly();
854 SfxBoolItem aItem( SID_FM_DESIGN_MODE, !mbReadOnly );
855 GetViewFrame()->GetDispatcher()->Execute( SID_FM_DESIGN_MODE,
856 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
863 } // end of namespace sd