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