xref: /trunk/main/sd/source/ui/view/drviewsa.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #include "DrawViewShell.hxx"
32 #include <cppuhelper/implbase1.hxx>
33 #include <comphelper/processfactory.hxx>
34 #ifndef _SVX_SIZEITEM
35 #include <editeng/sizeitem.hxx>
36 #endif
37 #include <svx/svdlayer.hxx>
38 #ifndef _SVX_ZOOMITEM
39 #include <svx/zoomitem.hxx>
40 #endif
41 #include <svx/svdpagv.hxx>
42 #include <svl/ptitem.hxx>
43 #include <svl/stritem.hxx>
44 #include <sfx2/request.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <svx/svdopath.hxx>
47 #include <sfx2/docfile.hxx>
48 #include <svx/zoomslideritem.hxx>
49 #include <svl/eitem.hxx>
50 
51 #ifndef _SVX_DIALOGS_HRC
52 #include <svx/dialogs.hrc>
53 #endif
54 #include <svx/extrusionbar.hxx>
55 #include <svx/fontworkbar.hxx>
56 #include <svx/clipfmtitem.hxx>
57 
58 
59 #include <sfx2/viewfrm.hxx>
60 #include <svx/fmshell.hxx>
61 #include <sfx2/dispatch.hxx>
62 #include <svtools/cliplistener.hxx>
63 #include <svx/float3d.hxx>
64 #include "helpids.h"
65 
66 #include "view/viewoverlaymanager.hxx"
67 #include "app.hrc"
68 #include "helpids.h"
69 #include "strings.hrc"
70 #include "res_bmp.hrc"
71 #include "sdpage.hxx"
72 #include "FrameView.hxx"
73 #include "drawdoc.hxx"
74 #include "sdresid.hxx"
75 #include "DrawDocShell.hxx"
76 #include "Window.hxx"
77 #include "fupoor.hxx"
78 #include "fusel.hxx"
79 #include "drawview.hxx"
80 #include "SdUnoDrawView.hxx"
81 #include "ViewShellBase.hxx"
82 #include "SdUnoDrawView.hxx"
83 #include "slideshow.hxx"
84 #include "ToolBarManager.hxx"
85 #include "annotationmanager.hxx"
86 
87 using namespace ::rtl;
88 using namespace ::com::sun::star;
89 using namespace ::com::sun::star::uno;
90 
91 namespace {
92 static const ::rtl::OUString MASTER_VIEW_TOOL_BAR_NAME(
93     ::rtl::OUString::createFromAscii("masterviewtoolbar"));
94 }
95 
96 namespace sd {
97 
98 sal_Bool DrawViewShell::mbPipette = sal_False;
99 
100 // ------------------------
101 // - ScannerEventListener -
102 // ------------------------
103 
104 class ScannerEventListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener >
105 {
106 private:
107 
108     DrawViewShell*      mpParent;
109 
110 public:
111 
112                             ScannerEventListener( DrawViewShell* pParent ) : mpParent( pParent )  {};
113                             ~ScannerEventListener();
114 
115     // XEventListener
116     virtual void SAL_CALL   disposing( const ::com::sun::star::lang::EventObject& rEventObject ) throw (::com::sun::star::uno::RuntimeException);
117 
118     void                    ParentDestroyed() { mpParent = NULL; }
119 };
120 
121 // -----------------------------------------------------------------------------
122 
123 ScannerEventListener::~ScannerEventListener()
124 {
125 }
126 
127 // -----------------------------------------------------------------------------
128 
129 void SAL_CALL ScannerEventListener::disposing( const ::com::sun::star::lang::EventObject& rEventObject ) throw (::com::sun::star::uno::RuntimeException)
130 {
131     if( mpParent )
132         mpParent->ScannerEvent( rEventObject );
133 }
134 
135 /*************************************************************************
136 |*
137 |* Standard-Konstruktor
138 |*
139 \************************************************************************/
140 
141 DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBase, ::Window* pParentWindow, PageKind ePageKind, FrameView* pFrameViewArgument )
142 : ViewShell (pFrame, pParentWindow, rViewShellBase)
143 , maTabControl(this, pParentWindow)
144 , mbIsInSwitchPage(false)
145 {
146     if (pFrameViewArgument != NULL)
147         mpFrameView = pFrameViewArgument;
148     else
149         mpFrameView = new FrameView(GetDoc());
150     Construct(GetDocSh(), ePageKind);
151 }
152 
153 /*************************************************************************
154 |*
155 |* Destruktor
156 |*
157 \************************************************************************/
158 
159 DrawViewShell::~DrawViewShell()
160 {
161     mpAnnotationManager.reset();
162     mpViewOverlayManager.reset();
163 
164     OSL_ASSERT (GetViewShell()!=NULL);
165 
166     if( mxScannerListener.is() )
167         static_cast< ScannerEventListener* >( mxScannerListener.get() )->ParentDestroyed();
168 
169     // #96642# Remove references to items within Svx3DWin
170     // (maybe do a listening sometime in Svx3DWin)
171     sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
172     SfxChildWindow* pWindow = GetViewFrame() ? GetViewFrame()->GetChildWindow(nId) : NULL;
173     if(pWindow)
174     {
175         Svx3DWin* p3DWin = static_cast< Svx3DWin* > (pWindow->GetWindow());
176         if(p3DWin)
177             p3DWin->DocumentReload();
178     }
179 
180     EndListening (*GetDoc());
181     EndListening (*GetDocSh());
182 
183     if( SlideShow::IsRunning(*this) )
184         StopSlideShow(false);
185 
186     DisposeFunctions();
187 
188     SdPage* pPage;
189     sal_uInt16 aPageCnt = GetDoc()->GetSdPageCount(mePageKind);
190 
191     for (sal_uInt16 i = 0; i < aPageCnt; i++)
192     {
193         pPage = GetDoc()->GetSdPage(i, mePageKind);
194 
195         if (pPage == mpActualPage)
196         {
197             GetDoc()->SetSelected(pPage, sal_True);
198         }
199         else
200         {
201             GetDoc()->SetSelected(pPage, sal_False);
202         }
203     }
204 
205     if ( mpClipEvtLstnr )
206     {
207         mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_False );
208         mpClipEvtLstnr->ClearCallbackLink();        // #103849# prevent callback if another thread is waiting
209         mpClipEvtLstnr->release();
210     }
211 
212     delete mpDrawView;
213     // Set mpView to NULL so that the destructor of the ViewShell base class
214     // does not access it.
215     mpView = mpDrawView = NULL;
216 
217     mpFrameView->Disconnect();
218     delete [] mpSlotArray;
219 }
220 
221 /*************************************************************************
222 |*
223 |* gemeinsamer Initialisierungsanteil der beiden Konstruktoren
224 |*
225 \************************************************************************/
226 
227 void DrawViewShell::Construct(DrawDocShell* pDocSh, PageKind eInitialPageKind)
228 {
229     mpActualPage = 0;
230     mbMousePosFreezed = sal_False;
231     mbReadOnly = GetDocSh()->IsReadOnly();
232     mpSlotArray = 0;
233     mpClipEvtLstnr = 0;
234     mbPastePossible = sal_False;
235     mbIsLayerModeActive = false;
236 
237     mpFrameView->Connect();
238 
239     OSL_ASSERT (GetViewShell()!=NULL);
240 
241     // Array fuer Slot-/ImageMapping:
242     // Gerader Eintrag: Haupt-/ToolboxSlot
243     // Ungerader Eintrag: gemappter Slot
244     // Achtung: Anpassen von GetIdBySubId() !!!
245     // Reihenfolge (insbesondere Zoom) darf nicht geaendert werden !!!
246     mpSlotArray = new sal_uInt16[ SLOTARRAY_COUNT ];
247     mpSlotArray[ 0 ]  = SID_OBJECT_CHOOSE_MODE;
248     mpSlotArray[ 1 ]  = SID_OBJECT_ROTATE;
249     mpSlotArray[ 2 ]  = SID_OBJECT_ALIGN;
250     mpSlotArray[ 3 ]  = SID_OBJECT_ALIGN_LEFT;
251     mpSlotArray[ 4 ]  = SID_ZOOM_TOOLBOX;
252     mpSlotArray[ 5 ]  = SID_ZOOM_TOOLBOX;
253     mpSlotArray[ 6 ]  = SID_DRAWTBX_TEXT;
254     mpSlotArray[ 7 ]  = SID_ATTR_CHAR;
255     mpSlotArray[ 8 ]  = SID_DRAWTBX_RECTANGLES;
256     mpSlotArray[ 9 ]  = SID_DRAW_RECT;
257     mpSlotArray[ 10 ] = SID_DRAWTBX_ELLIPSES;
258     mpSlotArray[ 11 ] = SID_DRAW_ELLIPSE;
259     mpSlotArray[ 12 ] = SID_DRAWTBX_LINES;
260     mpSlotArray[ 13 ] = SID_DRAW_FREELINE_NOFILL;
261     mpSlotArray[ 14 ] = SID_DRAWTBX_3D_OBJECTS;
262     mpSlotArray[ 15 ] = SID_3D_CUBE;
263     mpSlotArray[ 16 ] = SID_DRAWTBX_INSERT;
264     mpSlotArray[ 17 ] = SID_INSERT_DIAGRAM;
265     mpSlotArray[ 18 ] = SID_POSITION;
266     mpSlotArray[ 19 ] = SID_FRAME_TO_TOP;
267     mpSlotArray[ 20 ] = SID_DRAWTBX_CONNECTORS;
268     mpSlotArray[ 21 ] = SID_TOOL_CONNECTOR;
269     mpSlotArray[ 22 ] = SID_DRAWTBX_ARROWS;
270     mpSlotArray[ 23 ] = SID_LINE_ARROW_END;
271 
272     SetPool( &GetDoc()->GetPool() );
273 
274     GetDoc()->CreateFirstPages();
275 
276     mpDrawView = new DrawView(pDocSh, GetActiveWindow(), this);
277     mpView = mpDrawView;             // Pointer der Basisklasse ViewShell
278     mpDrawView->SetSwapAsynchron(sal_True); // Asynchrones Laden von Graphiken
279 
280     // We do not read the page kind from the frame view anymore so we have
281     // to set it in order to resync frame view and this view.
282     mpFrameView->SetPageKind(eInitialPageKind);
283     mePageKind = eInitialPageKind;
284     meEditMode = EM_PAGE;
285     DocumentType eDocType = GetDoc()->GetDocumentType(); // RTTI fasst hier noch nicht
286     switch (mePageKind)
287     {
288         case PK_STANDARD:
289             meShellType = ST_IMPRESS;
290             break;
291 
292         case PK_NOTES:
293             meShellType = ST_NOTES;
294             break;
295 
296         case PK_HANDOUT:
297             meShellType = ST_HANDOUT;
298             break;
299     }
300 
301     Size aPageSize( GetDoc()->GetSdPage(0, mePageKind)->GetSize() );
302     Point aPageOrg( aPageSize.Width(), aPageSize.Height() / 2);
303     Size aSize(aPageSize.Width() * 3, aPageSize.Height() * 2);
304     InitWindows(aPageOrg, aSize, Point(-1, -1));
305 
306     Point aVisAreaPos;
307 
308     if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
309     {
310         aVisAreaPos = pDocSh->GetVisArea(ASPECT_CONTENT).TopLeft();
311     }
312 
313     mpDrawView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
314 
315     // Objekte koennen max. so gross wie die ViewSize werden
316     GetDoc()->SetMaxObjSize(aSize);
317 
318     // Split-Handler fuer TabControls
319     maTabControl.SetSplitHdl( LINK( this, DrawViewShell, TabSplitHdl ) );
320 
321     // Damit der richtige EditMode von der FrameView komplett eingestellt
322     // werden kann, wird hier ein aktuell anderer gewaehlt (kleiner Trick)
323     if (mpFrameView->GetViewShEditMode(mePageKind) == EM_PAGE)
324     {
325         meEditMode = EM_MASTERPAGE;
326     }
327     else
328     {
329         meEditMode = EM_PAGE;
330     }
331 
332     // Einstellungen der FrameView uebernehmen
333     ReadFrameViewData(mpFrameView);
334 
335     if( eDocType == DOCUMENT_TYPE_DRAW )
336     {
337         SetHelpId( SD_IF_SDGRAPHICVIEWSHELL );
338         GetActiveWindow()->SetHelpId( HID_SDGRAPHICVIEWSHELL );
339         GetActiveWindow()->SetUniqueId( HID_SDGRAPHICVIEWSHELL );
340     }
341     else
342     {
343         if (mePageKind == PK_NOTES)
344         {
345             SetHelpId( SID_NOTESMODE );
346             GetActiveWindow()->SetHelpId( CMD_SID_NOTESMODE );
347             GetActiveWindow()->SetUniqueId( CMD_SID_NOTESMODE );
348 
349             // AutoLayouts muessen erzeugt sein
350             GetDoc()->StopWorkStartupDelay();
351         }
352         else if (mePageKind == PK_HANDOUT)
353         {
354             SetHelpId( SID_HANDOUTMODE );
355             GetActiveWindow()->SetHelpId( CMD_SID_HANDOUTMODE );
356             GetActiveWindow()->SetUniqueId( CMD_SID_HANDOUTMODE );
357 
358             // AutoLayouts muessen erzeugt sein
359             GetDoc()->StopWorkStartupDelay();
360         }
361         else
362         {
363             SetHelpId( SD_IF_SDDRAWVIEWSHELL );
364             GetActiveWindow()->SetHelpId( HID_SDDRAWVIEWSHELL );
365             GetActiveWindow()->SetUniqueId( HID_SDDRAWVIEWSHELL );
366         }
367     }
368 
369     // Selektionsfunktion starten
370     SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool());
371     FuPermanent(aReq);
372     mpDrawView->SetFrameDragSingles(sal_True);
373 
374     if (pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
375     {
376         mbZoomOnPage = sal_False;
377     }
378     else
379     {
380         mbZoomOnPage = sal_True;
381     }
382 
383     mbIsRulerDrag = sal_False;
384 
385     String aName( RTL_CONSTASCII_USTRINGPARAM("DrawViewShell"));
386     SetName (aName);
387 
388     mnLockCount = 0UL;
389 
390     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
391 
392     if( xMgr.is() )
393     {
394         mxScannerManager = ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager >(
395                            xMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.scanner.ScannerManager" ) ),
396                            ::com::sun::star::uno::UNO_QUERY );
397 
398         if( mxScannerManager.is() )
399         {
400             mxScannerListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >(
401                                 static_cast< ::cppu::OWeakObject* >( new ScannerEventListener( this ) ),
402                                 ::com::sun::star::uno::UNO_QUERY );
403         }
404     }
405 
406     mpAnnotationManager.reset( new AnnotationManager( GetViewShellBase() ) );
407     mpViewOverlayManager.reset( new ViewOverlayManager( GetViewShellBase() ) );
408 }
409 
410 
411 
412 
413 void DrawViewShell::Init (bool bIsMainViewShell)
414 {
415     ViewShell::Init(bIsMainViewShell);
416 
417     StartListening (*GetDocSh());
418 }
419 
420 
421 
422 
423 void DrawViewShell::Shutdown (void)
424 {
425     ViewShell::Shutdown();
426 
427     if(SlideShow::IsRunning( GetViewShellBase() ) )
428     {
429         // Turn off effects.
430         GetDrawView()->SetAnimationMode(SDR_ANIMATION_DISABLE);
431     }
432 }
433 
434 
435 
436 
437 css::uno::Reference<css::drawing::XDrawSubController> DrawViewShell::CreateSubController (void)
438 {
439     css::uno::Reference<css::drawing::XDrawSubController> xSubController;
440 
441     if (IsMainViewShell())
442     {
443         // Create uno sub controller for the main view shell.
444         xSubController = css::uno::Reference<css::drawing::XDrawSubController>(
445             new SdUnoDrawView (
446                 GetViewShellBase().GetDrawController(),
447                 *this,
448                 *GetView()));
449     }
450 
451     return xSubController;
452 }
453 
454 
455 
456 
457 bool DrawViewShell::RelocateToParentWindow (::Window* pParentWindow)
458 {
459     // DrawViewShells can not be relocated to a new parent window at the
460     // moment, so return <FALSE/> except when the given parent window is the
461     // parent window that is already in use.
462     return pParentWindow==GetParentWindow();
463 }
464 
465 
466 
467 
468 /*************************************************************************
469 |*
470 |* pruefe ob linienzuege gezeichnet werden muessen
471 |*
472 \************************************************************************/
473 
474 /*
475     linienzuege werden ueber makros als folge von
476         MoveTo (x, y)
477         LineTo (x, y)   [oder BezierTo (x, y)]
478         LineTo (x, y)
479             :
480     dargestellt. einen endbefehl fuer die linienzuege
481     gibt es nicht, also muessen alle befehle in den
482     requests nach LineTo (BezierTo) abgetestet und die
483     punktparameter gesammelt werden.
484     der erste nicht-LineTo fuehrt dann dazu, dass aus
485     den gesammelten punkten der linienzug erzeugt wird
486 */
487 
488 void DrawViewShell::CheckLineTo(SfxRequest& rReq)
489 {
490     (void)rReq;
491 #ifdef DBG_UTIL
492     if(rReq.IsAPI())
493     {
494         if(SID_LINETO == rReq.GetSlot() || SID_BEZIERTO == rReq.GetSlot() || SID_MOVETO == rReq.GetSlot() )
495         {
496             DBG_ERROR("DrawViewShell::CheckLineTo: slots SID_LINETO, SID_BEZIERTO, SID_MOVETO no longer supported.");
497         }
498     }
499 #endif
500 
501     rReq.Ignore ();
502 }
503 
504 /*************************************************************************
505 |*
506 |* veraendere die seitemparameter, wenn SID_PAGESIZE oder SID_PAGEMARGIN
507 |*
508 \************************************************************************/
509 
510 void DrawViewShell::SetupPage (Size &rSize,
511                                  long nLeft,
512                                  long nRight,
513                                  long nUpper,
514                                  long nLower,
515                                  sal_Bool bSize,
516                                  sal_Bool bMargin,
517                                  sal_Bool bScaleAll)
518 {
519     sal_uInt16 nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
520     sal_uInt16 i;
521 
522     for (i = 0; i < nPageCnt; i++)
523     {
524         /**********************************************************************
525         * Erst alle MasterPages bearbeiten
526         **********************************************************************/
527         SdPage *pPage = GetDoc()->GetMasterSdPage(i, mePageKind);
528 
529         if( pPage )
530         {
531             if( bSize )
532             {
533                 Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
534                 pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
535                 pPage->SetSize(rSize);
536 
537             }
538             if( bMargin )
539             {
540                 pPage->SetLftBorder(nLeft);
541                 pPage->SetRgtBorder(nRight);
542                 pPage->SetUppBorder(nUpper);
543                 pPage->SetLwrBorder(nLower);
544             }
545 
546             if ( mePageKind == PK_STANDARD )
547             {
548                 GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout();
549             }
550 
551             pPage->CreateTitleAndLayout();
552         }
553     }
554 
555     nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
556 
557     for (i = 0; i < nPageCnt; i++)
558     {
559         /**********************************************************************
560         * Danach alle Pages bearbeiten
561         **********************************************************************/
562         SdPage *pPage = GetDoc()->GetSdPage(i, mePageKind);
563 
564         if( pPage )
565         {
566             if( bSize )
567             {
568                 Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
569                 pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
570                 pPage->SetSize(rSize);
571             }
572             if( bMargin )
573             {
574                 pPage->SetLftBorder(nLeft);
575                 pPage->SetRgtBorder(nRight);
576                 pPage->SetUppBorder(nUpper);
577                 pPage->SetLwrBorder(nLower);
578             }
579 
580             if ( mePageKind == PK_STANDARD )
581             {
582                 SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES);
583                 pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
584             }
585 
586             pPage->SetAutoLayout( pPage->GetAutoLayout() );
587         }
588     }
589 
590     if ( mePageKind == PK_STANDARD )
591     {
592         SdPage* pHandoutPage = GetDoc()->GetSdPage(0, PK_HANDOUT);
593         pHandoutPage->CreateTitleAndLayout(sal_True);
594     }
595 
596     long nWidth = mpActualPage->GetSize().Width();
597     long nHeight = mpActualPage->GetSize().Height();
598 
599     Point aPageOrg(nWidth, nHeight / 2);
600     Size aSize( nWidth * 3, nHeight * 2);
601 
602     InitWindows(aPageOrg, aSize, Point(-1, -1), sal_True);
603 
604     Point aVisAreaPos;
605 
606     if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
607     {
608         aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
609     }
610 
611     GetView()->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
612 
613     UpdateScrollBars();
614 
615     Point aNewOrigin(mpActualPage->GetLftBorder(), mpActualPage->GetUppBorder());
616     GetView()->GetSdrPageView()->SetPageOrigin(aNewOrigin);
617 
618     GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
619 
620     // auf (neue) Seitengroesse zoomen
621     GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE,
622                         SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
623 }
624 
625 /*************************************************************************
626 |*
627 |* Statuswerte der Statusbar zurueckgeben
628 |*
629 \************************************************************************/
630 
631 void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
632 {
633     // Zoom-Item
634     // Hier sollte der entsprechende Wert (Optimal ?, Seitenbreite oder
635     // Seite) mit Hilfe des ZoomItems weitergegeben werden !!!
636     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOM ) )
637     {
638         if (GetDocSh()->IsUIActive() || (SlideShow::IsRunning(GetViewShellBase())) )
639         {
640             rSet.DisableItem( SID_ATTR_ZOOM );
641         }
642         else
643         {
644             SvxZoomItem* pZoomItem;
645             sal_uInt16 nZoom = (sal_uInt16) GetActiveWindow()->GetZoom();
646 
647             if( mbZoomOnPage )
648                 pZoomItem = new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nZoom );
649             else
650                 pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom );
651 
652             // Bereich einschraenken
653             sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
654             SdrPageView* pPageView = mpDrawView->GetSdrPageView();
655 
656             if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
657                 // || ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 0 ) )
658             {
659                 nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
660             }
661 
662             pZoomItem->SetValueSet( nZoomValues );
663             rSet.Put( *pZoomItem );
664             delete pZoomItem;
665         }
666     }
667     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) )
668     {
669         rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
670         if (GetDocSh()->IsUIActive() || (xSlideshow.is() && xSlideshow->isRunning()) || !GetActiveWindow() )
671         {
672             rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
673         }
674         else
675         {
676             sd::Window * pActiveWindow = GetActiveWindow();
677             SvxZoomSliderItem aZoomItem( (sal_uInt16) pActiveWindow->GetZoom(), (sal_uInt16)pActiveWindow->GetMinZoom(), (sal_uInt16)pActiveWindow->GetMaxZoom() ) ;
678 
679             SdrPageView* pPageView = mpDrawView->GetSdrPageView();
680             if( pPageView )
681             {
682                 Point aPagePos(0, 0);
683                 Size aPageSize = pPageView->GetPage()->GetSize();
684 
685                 aPagePos.X() += aPageSize.Width()  / 2;
686                 aPageSize.Width() = (long) (aPageSize.Width() * 1.03);
687 
688                 aPagePos.Y() += aPageSize.Height() / 2;
689                 aPageSize.Height() = (long) (aPageSize.Height() * 1.03);
690                 aPagePos.Y() -= aPageSize.Height() / 2;
691 
692                 aPagePos.X() -= aPageSize.Width()  / 2;
693 
694                 Rectangle aFullPageZoomRect( aPagePos, aPageSize );
695                 aZoomItem.AddSnappingPoint( pActiveWindow->GetZoomForRect( aFullPageZoomRect ) );
696             }
697             aZoomItem.AddSnappingPoint(100);
698             rSet.Put( aZoomItem );
699         }
700     }
701 
702     Point aPos = GetActiveWindow()->PixelToLogic(maMousePos);
703     mpDrawView->GetSdrPageView()->LogicToPagePos(aPos);
704     Fraction aUIScale(GetDoc()->GetUIScale());
705     aPos.X() = Fraction(aPos.X()) / aUIScale;
706     aPos.Y() = Fraction(aPos.Y()) / aUIScale;
707 
708     // Position- und Groesse-Items
709     if ( mpDrawView->IsAction() )
710     {
711         Rectangle aRect;
712         mpDrawView->TakeActionRect( aRect );
713 
714         if ( aRect.IsEmpty() )
715             rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
716         else
717         {
718             mpDrawView->GetSdrPageView()->LogicToPagePos(aRect);
719             aPos = aRect.TopLeft();
720             aPos.X() = Fraction(aPos.X()) / aUIScale;
721             aPos.Y() = Fraction(aPos.Y()) / aUIScale;
722             rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos) );
723             Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
724             aSize.Height() = Fraction(aSize.Height()) / aUIScale;
725             aSize.Width()  = Fraction(aSize.Width())  / aUIScale;
726             rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
727         }
728     }
729     else
730     {
731         if ( mpDrawView->AreObjectsMarked() )
732         {
733             Rectangle aRect = mpDrawView->GetAllMarkedRect();
734             mpDrawView->GetSdrPageView()->LogicToPagePos(aRect);
735 
736             // Show the position of the selected shape(s)
737             Point aShapePosition (aRect.TopLeft());
738             aShapePosition.X() = Fraction(aShapePosition.X()) / aUIScale;
739             aShapePosition.Y() = Fraction(aShapePosition.Y()) / aUIScale;
740             rSet.Put (SfxPointItem(SID_ATTR_POSITION, aShapePosition));
741 
742             Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
743             aSize.Height() = Fraction(aSize.Height()) / aUIScale;
744             aSize.Width()  = Fraction(aSize.Width())  / aUIScale;
745             rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
746         }
747         else
748         {
749             rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
750             rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
751         }
752     }
753 
754     // Display of current page and layer.
755     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_PAGE ) )
756     {
757         // Allways show the slide/page number.
758         String aString (SdResId( STR_SD_PAGE ));
759         aString += sal_Unicode(' ');
760         aString += UniString::CreateFromInt32( maTabControl.GetCurPageId() );
761         aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " ));
762         aString += UniString::CreateFromInt32( GetDoc()->GetSdPageCount( mePageKind ) );
763 
764         // If in layer mode additionally show the layer that contains all
765         // selected shapes of the page.  If the shapes are distributed on
766         // more than one layer, no layer name is shown.
767         if (IsLayerModeActive())
768         {
769             SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
770             SdrLayerID nLayer = 0, nOldLayer = 0;
771             SdrLayer*  pLayer = NULL;
772             SdrObject* pObj = NULL;
773             const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
774             sal_uLong nMarkCount = rMarkList.GetMarkCount();
775             FASTBOOL bOneLayer = sal_True;
776 
777             // Use the first ten selected shapes as a (hopefully
778             // representative) sample of all shapes of the current page.
779             // Detect whether they belong to the same layer.
780             for( sal_uLong j = 0; j < nMarkCount && bOneLayer && j < 10; j++ )
781             {
782                 pObj = rMarkList.GetMark( j )->GetMarkedSdrObj();
783                 if( pObj )
784                 {
785                     nLayer = pObj->GetLayer();
786 
787                     if( j != 0 && nLayer != nOldLayer )
788                         bOneLayer = sal_False;
789 
790                     nOldLayer = nLayer;
791                 }
792             }
793 
794             // Append the layer name to the current page number.
795             if( bOneLayer && nMarkCount )
796             {
797                 pLayer = rLayerAdmin.GetLayerPerID( nLayer );
798                 if( pLayer )
799                 {
800                     aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ));
801                     aString += pLayer->GetName();
802                     aString += sal_Unicode(')');
803                 }
804             }
805         }
806 
807         rSet.Put (SfxStringItem (SID_STATUS_PAGE, aString));
808     }
809     // Layout
810     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_LAYOUT ) )
811     {
812         String aString = mpActualPage->GetLayoutName();
813         aString.Erase( aString.SearchAscii( SD_LT_SEPARATOR ) );
814         rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aString ) );
815     }
816 }
817 
818 
819 
820 void DrawViewShell::Notify (SfxBroadcaster&, const SfxHint& rHint)
821 {
822     const SfxSimpleHint* pSimple = dynamic_cast< const SfxSimpleHint* >(&rHint);
823     if (pSimple!=NULL && pSimple->GetId()==SFX_HINT_MODECHANGED)
824     {
825         // Change to selection when turning on read-only mode.
826         if(GetDocSh()->IsReadOnly() && dynamic_cast< FuSelection* >( GetCurrentFunction().get() ) )
827         {
828             SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool());
829             FuPermanent(aReq);
830         }
831 
832         // Turn on design mode when document is not read-only.
833         if (GetDocSh()->IsReadOnly() != mbReadOnly )
834         {
835             mbReadOnly = GetDocSh()->IsReadOnly();
836 
837             SfxBoolItem aItem( SID_FM_DESIGN_MODE, !mbReadOnly );
838             GetViewFrame()->GetDispatcher()->Execute( SID_FM_DESIGN_MODE,
839                 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
840         }
841     }
842 
843 }
844 
845 void DrawViewShell::ExecuteAnnotation (SfxRequest& rRequest)
846 {
847     if( mpAnnotationManager.get() )
848         mpAnnotationManager->ExecuteAnnotation( rRequest );
849 }
850 
851 // --------------------------------------------------------------------
852 
853 void DrawViewShell::GetAnnotationState (SfxItemSet& rItemSet )
854 {
855     if( mpAnnotationManager.get() )
856         mpAnnotationManager->GetAnnotationState( rItemSet );
857 }
858 
859 
860 } // end of namespace sd
861