xref: /aoo41x/main/sd/source/ui/view/drviewsa.cxx (revision c9c475c9)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "DrawViewShell.hxx"
28 #include <cppuhelper/implbase1.hxx>
29 #include <comphelper/processfactory.hxx>
30 #ifndef _SVX_SIZEITEM
31 #include <editeng/sizeitem.hxx>
32 #endif
33 #include <svx/svdlayer.hxx>
34 #ifndef _SVX_ZOOMITEM
35 #include <svx/zoomitem.hxx>
36 #endif
37 #include <svx/svdpagv.hxx>
38 #include <svl/ptitem.hxx>
39 #include <svl/stritem.hxx>
40 #include <sfx2/request.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <svx/svdopath.hxx>
43 #include <sfx2/docfile.hxx>
44 #include <svx/zoomslideritem.hxx>
45 #include <svl/eitem.hxx>
46 
47 #ifndef _SVX_DIALOGS_HRC
48 #include <svx/dialogs.hrc>
49 #endif
50 #include <svx/extrusionbar.hxx>
51 #include <svx/fontworkbar.hxx>
52 #include <svx/clipfmtitem.hxx>
53 
54 
55 #include <sfx2/viewfrm.hxx>
56 #include <svx/fmshell.hxx>
57 #include <sfx2/dispatch.hxx>
58 #include <svtools/cliplistener.hxx>
59 #include <svx/float3d.hxx>
60 #include <svx/sidebar/SelectionAnalyzer.hxx>
61 #include "helpids.h"
62 
63 #include "view/viewoverlaymanager.hxx"
64 #include "app.hrc"
65 #include "helpids.h"
66 #include "strings.hrc"
67 #include "res_bmp.hrc"
68 #include "sdpage.hxx"
69 #include "FrameView.hxx"
70 #include "drawdoc.hxx"
71 #include "sdresid.hxx"
72 #include "DrawDocShell.hxx"
73 #include "Window.hxx"
74 #include "fupoor.hxx"
75 #include "fusel.hxx"
76 #include "drawview.hxx"
77 #include "SdUnoDrawView.hxx"
78 #include "ViewShellBase.hxx"
79 #include "SdUnoDrawView.hxx"
80 #include "slideshow.hxx"
81 #include "ToolBarManager.hxx"
82 #include "annotationmanager.hxx"
83 
84 #include <boost/bind.hpp>
85 
86 using namespace ::rtl;
87 using namespace ::com::sun::star;
88 using namespace ::com::sun::star::uno;
89 using sfx2::sidebar::EnumContext;
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   mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler(
146           ::boost::bind(&DrawViewShell::GetContextForSelection, this),
147           uno::Reference<frame::XController>(&rViewShellBase.GetDrawController()),
148           sfx2::sidebar::EnumContext::Context_Default))
149 
150 {
151 	if (pFrameViewArgument != NULL)
152 		mpFrameView = pFrameViewArgument;
153 	else
154         mpFrameView = new FrameView(GetDoc());
155     Construct(GetDocSh(), ePageKind);
156 
157     mpSelectionChangeHandler->Connect();
158 
159 	if (mpFrameView->GetViewShEditMode(mePageKind) == EM_PAGE)
160         SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawPage));
161 	else
162         SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_MasterPage));
163 }
164 
165 /*************************************************************************
166 |*
167 |* Destruktor
168 |*
169 \************************************************************************/
170 
171 DrawViewShell::~DrawViewShell()
172 {
173     mpSelectionChangeHandler->Disconnect();
174 
175     mpAnnotationManager.reset();
176     mpViewOverlayManager.reset();
177 
178     OSL_ASSERT (GetViewShell()!=NULL);
179 
180     if( mxScannerListener.is() )
181 		static_cast< ScannerEventListener* >( mxScannerListener.get() )->ParentDestroyed();
182 
183     // #96642# Remove references to items within Svx3DWin
184     // (maybe do a listening sometime in Svx3DWin)
185     sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
186     SfxChildWindow* pWindow = GetViewFrame() ? GetViewFrame()->GetChildWindow(nId) : NULL;
187     if(pWindow)
188     {
189         Svx3DWin* p3DWin = static_cast< Svx3DWin* > (pWindow->GetWindow());
190         if(p3DWin)
191             p3DWin->DocumentReload();
192     }
193 
194     EndListening (*GetDoc());
195     EndListening (*GetDocSh());
196 
197 	if( SlideShow::IsRunning(*this) )
198         StopSlideShow(false);
199 
200 	DisposeFunctions();
201 
202 	SdPage* pPage;
203 	sal_uInt16 aPageCnt = GetDoc()->GetSdPageCount(mePageKind);
204 
205 	for (sal_uInt16 i = 0; i < aPageCnt; i++)
206 	{
207 		pPage = GetDoc()->GetSdPage(i, mePageKind);
208 
209 		if (pPage == mpActualPage)
210 		{
211 			GetDoc()->SetSelected(pPage, sal_True);
212 		}
213 		else
214 		{
215 			GetDoc()->SetSelected(pPage, sal_False);
216 		}
217 	}
218 
219 	if ( mpClipEvtLstnr )
220 	{
221 		mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_False );
222 		mpClipEvtLstnr->ClearCallbackLink();		// #103849# prevent callback if another thread is waiting
223 		mpClipEvtLstnr->release();
224 	}
225 
226 	delete mpDrawView;
227     // Set mpView to NULL so that the destructor of the ViewShell base class
228     // does not access it.
229 	mpView = mpDrawView = NULL;
230 
231 	mpFrameView->Disconnect();
232 	delete [] mpSlotArray;
233 }
234 
235 /*************************************************************************
236 |*
237 |* gemeinsamer Initialisierungsanteil der beiden Konstruktoren
238 |*
239 \************************************************************************/
240 
241 void DrawViewShell::Construct(DrawDocShell* pDocSh, PageKind eInitialPageKind)
242 {
243 	mpActualPage = 0;
244 	mbMousePosFreezed = sal_False;
245 	mbReadOnly = GetDocSh()->IsReadOnly();
246 	mpSlotArray = 0;
247 	mpClipEvtLstnr = 0;
248 	mbPastePossible = sal_False;
249 	mbIsLayerModeActive = false;
250 
251 	mpFrameView->Connect();
252 
253     OSL_ASSERT (GetViewShell()!=NULL);
254 
255 	// Array fuer Slot-/ImageMapping:
256 	// Gerader Eintrag: Haupt-/ToolboxSlot
257 	// Ungerader Eintrag: gemappter Slot
258 	// Achtung: Anpassen von GetIdBySubId() !!!
259 	// Reihenfolge (insbesondere Zoom) darf nicht geaendert werden !!!
260 	mpSlotArray = new sal_uInt16[ SLOTARRAY_COUNT ];
261 	mpSlotArray[ 0 ]  = SID_OBJECT_CHOOSE_MODE;
262 	mpSlotArray[ 1 ]  = SID_OBJECT_ROTATE;
263 	mpSlotArray[ 2 ]  = SID_OBJECT_ALIGN;
264 	mpSlotArray[ 3 ]  = SID_OBJECT_ALIGN_LEFT;
265 	mpSlotArray[ 4 ]  = SID_ZOOM_TOOLBOX;
266 	mpSlotArray[ 5 ]  = SID_ZOOM_TOOLBOX;
267 	mpSlotArray[ 6 ]  = SID_DRAWTBX_TEXT;
268 	mpSlotArray[ 7 ]  = SID_ATTR_CHAR;
269 	mpSlotArray[ 8 ]  = SID_DRAWTBX_RECTANGLES;
270 	mpSlotArray[ 9 ]  = SID_DRAW_RECT;
271 	mpSlotArray[ 10 ] = SID_DRAWTBX_ELLIPSES;
272 	mpSlotArray[ 11 ] = SID_DRAW_ELLIPSE;
273 	mpSlotArray[ 12 ] = SID_DRAWTBX_LINES;
274 	mpSlotArray[ 13 ] = SID_DRAW_FREELINE_NOFILL;
275 	mpSlotArray[ 14 ] = SID_DRAWTBX_3D_OBJECTS;
276 	mpSlotArray[ 15 ] = SID_3D_CUBE;
277 	mpSlotArray[ 16 ] = SID_DRAWTBX_INSERT;
278 	mpSlotArray[ 17 ] = SID_INSERT_DIAGRAM;
279 	mpSlotArray[ 18 ] = SID_POSITION;
280 	mpSlotArray[ 19 ] = SID_FRAME_TO_TOP;
281 	mpSlotArray[ 20 ] = SID_DRAWTBX_CONNECTORS;
282 	mpSlotArray[ 21 ] = SID_TOOL_CONNECTOR;
283 	mpSlotArray[ 22 ] = SID_DRAWTBX_ARROWS;
284 	mpSlotArray[ 23 ] = SID_LINE_ARROW_END;
285 
286 	SetPool( &GetDoc()->GetPool() );
287 
288 	GetDoc()->CreateFirstPages();
289 
290 	mpDrawView = new DrawView(pDocSh, GetActiveWindow(), this);
291 	mpView = mpDrawView;			 // Pointer der Basisklasse ViewShell
292 	mpDrawView->SetSwapAsynchron(sal_True); // Asynchrones Laden von Graphiken
293 
294     // We do not read the page kind from the frame view anymore so we have
295     // to set it in order to resync frame view and this view.
296     mpFrameView->SetPageKind(eInitialPageKind);
297 	mePageKind = eInitialPageKind;
298 	meEditMode = EM_PAGE;
299 	DocumentType eDocType = GetDoc()->GetDocumentType(); // RTTI fasst hier noch nicht
300     switch (mePageKind)
301     {
302         case PK_STANDARD:
303             meShellType = ST_IMPRESS;
304             break;
305 
306         case PK_NOTES:
307             meShellType = ST_NOTES;
308             break;
309 
310         case PK_HANDOUT:
311             meShellType = ST_HANDOUT;
312             break;
313     }
314 
315 	Size aPageSize( GetDoc()->GetSdPage(0, mePageKind)->GetSize() );
316 	Point aPageOrg( aPageSize.Width(), aPageSize.Height() / 2);
317 	Size aSize(aPageSize.Width() * 3, aPageSize.Height() * 2);
318 	InitWindows(aPageOrg, aSize, Point(-1, -1));
319 
320 	Point aVisAreaPos;
321 
322 	if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
323 	{
324 		aVisAreaPos = pDocSh->GetVisArea(ASPECT_CONTENT).TopLeft();
325 	}
326 
327 	mpDrawView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
328 
329 	// Objekte koennen max. so gross wie die ViewSize werden
330 	GetDoc()->SetMaxObjSize(aSize);
331 
332 	// Split-Handler fuer TabControls
333 	maTabControl.SetSplitHdl( LINK( this, DrawViewShell, TabSplitHdl ) );
334 
335 	// Damit der richtige EditMode von der FrameView komplett eingestellt
336 	// werden kann, wird hier ein aktuell anderer gewaehlt (kleiner Trick)
337 	if (mpFrameView->GetViewShEditMode(mePageKind) == EM_PAGE)
338 	{
339 		meEditMode = EM_MASTERPAGE;
340 	}
341 	else
342 	{
343 		meEditMode = EM_PAGE;
344 	}
345 
346 	// Einstellungen der FrameView uebernehmen
347 	ReadFrameViewData(mpFrameView);
348 
349 	if( eDocType == DOCUMENT_TYPE_DRAW )
350 	{
351 		SetHelpId( SD_IF_SDGRAPHICVIEWSHELL );
352 		GetActiveWindow()->SetHelpId( HID_SDGRAPHICVIEWSHELL );
353 		GetActiveWindow()->SetUniqueId( HID_SDGRAPHICVIEWSHELL );
354 	}
355 	else
356 	{
357 		if (mePageKind == PK_NOTES)
358 		{
359 			SetHelpId( SID_NOTESMODE );
360 			GetActiveWindow()->SetHelpId( CMD_SID_NOTESMODE );
361 			GetActiveWindow()->SetUniqueId( CMD_SID_NOTESMODE );
362 
363 			// AutoLayouts muessen erzeugt sein
364 			GetDoc()->StopWorkStartupDelay();
365 		}
366 		else if (mePageKind == PK_HANDOUT)
367 		{
368 			SetHelpId( SID_HANDOUTMODE );
369 			GetActiveWindow()->SetHelpId( CMD_SID_HANDOUTMODE );
370 			GetActiveWindow()->SetUniqueId( CMD_SID_HANDOUTMODE );
371 
372 			// AutoLayouts muessen erzeugt sein
373 			GetDoc()->StopWorkStartupDelay();
374 		}
375 		else
376 		{
377 			SetHelpId( SD_IF_SDDRAWVIEWSHELL );
378 			GetActiveWindow()->SetHelpId( HID_SDDRAWVIEWSHELL );
379 			GetActiveWindow()->SetUniqueId( HID_SDDRAWVIEWSHELL );
380 		}
381 	}
382 
383 	// Selektionsfunktion starten
384 	SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool());
385 	FuPermanent(aReq);
386 	mpDrawView->SetFrameDragSingles(sal_True);
387 
388 	if (pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
389 	{
390 		mbZoomOnPage = sal_False;
391 	}
392 	else
393 	{
394 		mbZoomOnPage = sal_True;
395 	}
396 
397 	mbIsRulerDrag = sal_False;
398 
399 	String aName( RTL_CONSTASCII_USTRINGPARAM("DrawViewShell"));
400 	SetName (aName);
401 
402 	mnLockCount = 0UL;
403 
404 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
405 
406 	if( xMgr.is() )
407 	{
408 		mxScannerManager = ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager >(
409 						   xMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.scanner.ScannerManager" ) ),
410 						   ::com::sun::star::uno::UNO_QUERY );
411 
412 		if( mxScannerManager.is() )
413 		{
414 			mxScannerListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >(
415 								static_cast< ::cppu::OWeakObject* >( new ScannerEventListener( this ) ),
416 								::com::sun::star::uno::UNO_QUERY );
417 		}
418 	}
419 
420     mpAnnotationManager.reset( new AnnotationManager( GetViewShellBase() ) );
421     mpViewOverlayManager.reset( new ViewOverlayManager( GetViewShellBase() ) );
422 }
423 
424 
425 
426 
427 void DrawViewShell::Init (bool bIsMainViewShell)
428 {
429     ViewShell::Init(bIsMainViewShell);
430 
431     StartListening (*GetDocSh());
432 }
433 
434 
435 
436 
437 void DrawViewShell::Shutdown (void)
438 {
439     ViewShell::Shutdown();
440 
441 	if(SlideShow::IsRunning( GetViewShellBase() ) )
442     {
443         // Turn off effects.
444         GetDrawView()->SetAnimationMode(SDR_ANIMATION_DISABLE);
445     }
446 }
447 
448 
449 
450 
451 css::uno::Reference<css::drawing::XDrawSubController> DrawViewShell::CreateSubController (void)
452 {
453     css::uno::Reference<css::drawing::XDrawSubController> xSubController;
454 
455     if (IsMainViewShell())
456     {
457         // Create uno sub controller for the main view shell.
458         xSubController = css::uno::Reference<css::drawing::XDrawSubController>(
459             new SdUnoDrawView (
460                 GetViewShellBase().GetDrawController(),
461                 *this,
462                 *GetView()));
463     }
464 
465     return xSubController;
466 }
467 
468 
469 
470 
471 bool DrawViewShell::RelocateToParentWindow (::Window* pParentWindow)
472 {
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();
477 }
478 
479 
480 
481 
482 /*************************************************************************
483 |*
484 |* pruefe ob linienzuege gezeichnet werden muessen
485 |*
486 \************************************************************************/
487 
488 /*
489 	linienzuege werden ueber makros als folge von
490 		MoveTo (x, y)
491 		LineTo (x, y)	[oder BezierTo (x, y)]
492 		LineTo (x, y)
493 			:
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
500 */
501 
502 void DrawViewShell::CheckLineTo(SfxRequest& rReq)
503 {
504 	(void)rReq;
505 #ifdef DBG_UTIL
506 	if(rReq.IsAPI())
507 	{
508 		if(SID_LINETO == rReq.GetSlot() || SID_BEZIERTO == rReq.GetSlot() || SID_MOVETO == rReq.GetSlot() )
509 		{
510 			DBG_ERROR("DrawViewShell::CheckLineTo: slots SID_LINETO, SID_BEZIERTO, SID_MOVETO no longer supported.");
511 		}
512 	}
513 #endif
514 
515 	rReq.Ignore ();
516 }
517 
518 /*************************************************************************
519 |*
520 |* veraendere die seitemparameter, wenn SID_PAGESIZE oder SID_PAGEMARGIN
521 |*
522 \************************************************************************/
523 
524 void DrawViewShell::SetupPage (Size &rSize,
525 								 long nLeft,
526 								 long nRight,
527 								 long nUpper,
528 								 long nLower,
529 								 sal_Bool bSize,
530 								 sal_Bool bMargin,
531 								 sal_Bool bScaleAll)
532 {
533 	sal_uInt16 nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
534 	sal_uInt16 i;
535 
536 	for (i = 0; i < nPageCnt; i++)
537 	{
538 		/**********************************************************************
539 		* Erst alle MasterPages bearbeiten
540 		**********************************************************************/
541 		SdPage *pPage = GetDoc()->GetMasterSdPage(i, mePageKind);
542 
543 		if( pPage )
544 		{
545 			if( bSize )
546 			{
547 				Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
548 				pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
549 				pPage->SetSize(rSize);
550 
551 			}
552 			if( bMargin )
553 			{
554 				pPage->SetLftBorder(nLeft);
555 				pPage->SetRgtBorder(nRight);
556 				pPage->SetUppBorder(nUpper);
557 				pPage->SetLwrBorder(nLower);
558 			}
559 
560 			if ( mePageKind == PK_STANDARD )
561 			{
562 				GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout();
563 			}
564 
565 			pPage->CreateTitleAndLayout();
566 		}
567 	}
568 
569 	nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
570 
571 	for (i = 0; i < nPageCnt; i++)
572 	{
573 		/**********************************************************************
574 		* Danach alle Pages bearbeiten
575 		**********************************************************************/
576 		SdPage *pPage = GetDoc()->GetSdPage(i, mePageKind);
577 
578 		if( pPage )
579 		{
580 			if( bSize )
581 			{
582 				Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
583 				pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
584 				pPage->SetSize(rSize);
585 			}
586 			if( bMargin )
587 			{
588 				pPage->SetLftBorder(nLeft);
589 				pPage->SetRgtBorder(nRight);
590 				pPage->SetUppBorder(nUpper);
591 				pPage->SetLwrBorder(nLower);
592 			}
593 
594 			if ( mePageKind == PK_STANDARD )
595 			{
596 				SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES);
597 				pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
598 			}
599 
600 			pPage->SetAutoLayout( pPage->GetAutoLayout() );
601 		}
602 	}
603 
604 	if ( mePageKind == PK_STANDARD )
605 	{
606 		SdPage* pHandoutPage = GetDoc()->GetSdPage(0, PK_HANDOUT);
607 		pHandoutPage->CreateTitleAndLayout(sal_True);
608 	}
609 
610 	long nWidth = mpActualPage->GetSize().Width();
611 	long nHeight = mpActualPage->GetSize().Height();
612 
613 	Point aPageOrg(nWidth, nHeight / 2);
614 	Size aSize( nWidth * 3, nHeight * 2);
615 
616 	InitWindows(aPageOrg, aSize, Point(-1, -1), sal_True);
617 
618 	Point aVisAreaPos;
619 
620 	if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
621 	{
622 		aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
623 	}
624 
625 	GetView()->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
626 
627 	UpdateScrollBars();
628 
629 	Point aNewOrigin(mpActualPage->GetLftBorder(), mpActualPage->GetUppBorder());
630 	GetView()->GetSdrPageView()->SetPageOrigin(aNewOrigin);
631 
632 	GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
633 
634 	// auf (neue) Seitengroesse zoomen
635 	GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE,
636 						SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
637 }
638 
639 /*************************************************************************
640 |*
641 |* Statuswerte der Statusbar zurueckgeben
642 |*
643 \************************************************************************/
644 
645 void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
646 {
647 	// Zoom-Item
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 ) )
651 	{
652 		if (GetDocSh()->IsUIActive() || (SlideShow::IsRunning(GetViewShellBase())) )
653 		{
654 			rSet.DisableItem( SID_ATTR_ZOOM );
655 		}
656 		else
657 		{
658 			SvxZoomItem* pZoomItem;
659 			sal_uInt16 nZoom = (sal_uInt16) GetActiveWindow()->GetZoom();
660 
661 			if( mbZoomOnPage )
662 				pZoomItem = new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nZoom );
663 			else
664 				pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom );
665 
666 			// Bereich einschraenken
667 			sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
668 			SdrPageView* pPageView = mpDrawView->GetSdrPageView();
669 
670 			if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
671 				// || ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 0 ) )
672 			{
673 				nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
674 			}
675 
676 			pZoomItem->SetValueSet( nZoomValues );
677 			rSet.Put( *pZoomItem );
678 			delete pZoomItem;
679 		}
680 	}
681 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) )
682 	{
683         rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
684 		if (GetDocSh()->IsUIActive() || (xSlideshow.is() && xSlideshow->isRunning()) || !GetActiveWindow() )
685 		{
686 			rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
687 		}
688 		else
689 		{
690 			sd::Window * pActiveWindow = GetActiveWindow();
691 			SvxZoomSliderItem aZoomItem( (sal_uInt16) pActiveWindow->GetZoom(), (sal_uInt16)pActiveWindow->GetMinZoom(), (sal_uInt16)pActiveWindow->GetMaxZoom() ) ;
692 
693             SdrPageView* pPageView = mpDrawView->GetSdrPageView();
694             if( pPageView )
695             {
696                 Point aPagePos(0, 0);
697 				Size aPageSize = pPageView->GetPage()->GetSize();
698 
699 				aPagePos.X() += aPageSize.Width()  / 2;
700                 aPageSize.Width() = (long) (aPageSize.Width() * 1.03);
701 
702 				aPagePos.Y() += aPageSize.Height() / 2;
703                 aPageSize.Height() = (long) (aPageSize.Height() * 1.03);
704 				aPagePos.Y() -= aPageSize.Height() / 2;
705 
706 				aPagePos.X() -= aPageSize.Width()  / 2;
707 
708                 Rectangle aFullPageZoomRect( aPagePos, aPageSize );
709                 aZoomItem.AddSnappingPoint( pActiveWindow->GetZoomForRect( aFullPageZoomRect ) );
710             }
711 			aZoomItem.AddSnappingPoint(100);
712 			rSet.Put( aZoomItem );
713 		}
714 	}
715 
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;
721 
722 	// Position- und Groesse-Items
723 	if ( mpDrawView->IsAction() )
724 	{
725 		Rectangle aRect;
726 		mpDrawView->TakeActionRect( aRect );
727 
728 		if ( aRect.IsEmpty() )
729 			rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
730 		else
731 		{
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) );
741 		}
742 	}
743 	else
744 	{
745 		if ( mpDrawView->AreObjectsMarked() )
746 		{
747 			Rectangle aRect = mpDrawView->GetAllMarkedRect();
748 			mpDrawView->GetSdrPageView()->LogicToPagePos(aRect);
749 
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));
755 
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) );
760 		}
761 		else
762         {
763             rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
764 			rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
765         }
766 	}
767 
768 	// Display of current page and layer.
769 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_PAGE ) )
770 	{
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 ) );
777 
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())
782 		{
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 			sal_uLong nMarkCount = rMarkList.GetMarkCount();
789 			FASTBOOL bOneLayer = sal_True;
790 
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( sal_uLong j = 0; j < nMarkCount && bOneLayer && j < 10; j++ )
795 			{
796 				pObj = rMarkList.GetMark( j )->GetMarkedSdrObj();
797 				if( pObj )
798 				{
799 					nLayer = pObj->GetLayer();
800 
801 					if( j != 0 && nLayer != nOldLayer )
802 						bOneLayer = sal_False;
803 
804 					nOldLayer = nLayer;
805 				}
806 			}
807 
808             // Append the layer name to the current page number.
809 			if( bOneLayer && nMarkCount )
810 			{
811 				pLayer = rLayerAdmin.GetLayerPerID( nLayer );
812 				if( pLayer )
813                 {
814                     aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ));
815 					aString += pLayer->GetName();
816                     aString += sal_Unicode(')');
817                 }
818 			}
819 		}
820 
821 		rSet.Put (SfxStringItem (SID_STATUS_PAGE, aString));
822 	}
823 	// Layout
824 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_LAYOUT ) )
825 	{
826 		String aString = mpActualPage->GetLayoutName();
827 		aString.Erase( aString.SearchAscii( SD_LT_SEPARATOR ) );
828 		rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aString ) );
829 	}
830 }
831 
832 
833 
834 void DrawViewShell::Notify (SfxBroadcaster&, const SfxHint& rHint)
835 {
836 	const SfxSimpleHint* pSimple = dynamic_cast< const SfxSimpleHint* >(&rHint);
837 	if (pSimple!=NULL && pSimple->GetId()==SFX_HINT_MODECHANGED)
838 	{
839         // Change to selection when turning on read-only mode.
840 		if(GetDocSh()->IsReadOnly() && dynamic_cast< FuSelection* >( GetCurrentFunction().get() ) )
841 		{
842 			SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool());
843 			FuPermanent(aReq);
844 		}
845 
846         // Turn on design mode when document is not read-only.
847 		if (GetDocSh()->IsReadOnly() != mbReadOnly )
848 		{
849 			mbReadOnly = GetDocSh()->IsReadOnly();
850 
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 );
854 		}
855 	}
856 
857 }
858 
859 void DrawViewShell::ExecuteAnnotation (SfxRequest& rRequest)
860 {
861     if( mpAnnotationManager.get() )
862         mpAnnotationManager->ExecuteAnnotation( rRequest );
863 }
864 
865 // --------------------------------------------------------------------
866 
867 void DrawViewShell::GetAnnotationState (SfxItemSet& rItemSet )
868 {
869     if( mpAnnotationManager.get() )
870         mpAnnotationManager->GetAnnotationState( rItemSet );
871 }
872 
873 
874 
875 
876 EnumContext::Context DrawViewShell::GetContextForSelection (void) const
877 {
878     return ::svx::sidebar::SelectionAnalyzer::GetContextForSelection_SD(
879         mpDrawView->GetMarkedObjectList(),
880         meEditMode == EM_MASTERPAGE,
881         mePageKind == PK_HANDOUT,
882         mePageKind == PK_NOTES);
883 }
884 
885 
886 } // end of namespace sd
887