xref: /AOO41X/main/sd/source/ui/unoidl/SdUnoDrawView.cxx (revision 0deba7fbda3d9908785c25a443701a293b6f4e71)
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 "SdUnoDrawView.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "DrawController.hxx"
30cdf0e10cSrcweir #include "DrawDocShell.hxx"
31cdf0e10cSrcweir #include "DrawViewShell.hxx"
32cdf0e10cSrcweir #include "drawdoc.hxx"
33cdf0e10cSrcweir #include "unolayer.hxx"
34cdf0e10cSrcweir #include "unomodel.hxx"
35cdf0e10cSrcweir #include "unopage.hxx"
36cdf0e10cSrcweir #include "Window.hxx"
37cdf0e10cSrcweir #include "pres.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <cppuhelper/proptypehlp.hxx>
40cdf0e10cSrcweir #include <comphelper/serviceinfohelper.hxx>
41cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
42cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
43cdf0e10cSrcweir #include <svx/svdpagv.hxx>
44cdf0e10cSrcweir #include <svx/unoshape.hxx>
45cdf0e10cSrcweir #include <svx/unoshcol.hxx>
46cdf0e10cSrcweir #include <svx/zoomitem.hxx>
47cdf0e10cSrcweir #include <com/sun/star/drawing/DrawViewMode.hpp>
48cdf0e10cSrcweir #include <com/sun/star/drawing/XLayerManager.hpp>
49cdf0e10cSrcweir #include <com/sun/star/view/DocumentZoomType.hpp>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include <vector>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir using rtl::OUString;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir using namespace ::com::sun::star;
56cdf0e10cSrcweir using namespace ::com::sun::star::uno;
57cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 
60cdf0e10cSrcweir namespace sd {
61cdf0e10cSrcweir 
62cdf0e10cSrcweir SdUnoDrawView::SdUnoDrawView(
63cdf0e10cSrcweir     DrawController& rController,
64cdf0e10cSrcweir     DrawViewShell& rViewShell,
65cdf0e10cSrcweir     View& rView) throw()
66cdf0e10cSrcweir     :	DrawSubControllerInterfaceBase(m_aMutex),
67cdf0e10cSrcweir         mrController(rController),
68cdf0e10cSrcweir         mrDrawViewShell(rViewShell),
69cdf0e10cSrcweir         mrView(rView)
70cdf0e10cSrcweir {
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 
76cdf0e10cSrcweir SdUnoDrawView::~SdUnoDrawView() throw()
77cdf0e10cSrcweir {
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 
83cdf0e10cSrcweir sal_Bool SdUnoDrawView::getMasterPageMode(void) const throw()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     return (mrDrawViewShell.GetEditMode() == EM_MASTERPAGE);
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
91cdf0e10cSrcweir void SdUnoDrawView::setMasterPageMode (sal_Bool bMasterPageMode) throw()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	if ((mrDrawViewShell.GetEditMode() == EM_MASTERPAGE) != bMasterPageMode)
94cdf0e10cSrcweir     {
95cdf0e10cSrcweir         mrDrawViewShell.ChangeEditMode (
96cdf0e10cSrcweir             bMasterPageMode ? EM_MASTERPAGE : EM_PAGE,
97cdf0e10cSrcweir             mrDrawViewShell.IsLayerModeActive());
98cdf0e10cSrcweir     }
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir sal_Bool SdUnoDrawView::getLayerMode(void) const throw()
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     return mrDrawViewShell.IsLayerModeActive();
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir void SdUnoDrawView::setLayerMode (sal_Bool bLayerMode) throw()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir 	if (mrDrawViewShell.IsLayerModeActive() != (bLayerMode==sal_True))
115cdf0e10cSrcweir     {
116cdf0e10cSrcweir         mrDrawViewShell.ChangeEditMode (
117cdf0e10cSrcweir             mrDrawViewShell.GetEditMode(),
118cdf0e10cSrcweir             bLayerMode);
119cdf0e10cSrcweir     }
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 
125cdf0e10cSrcweir Reference<drawing::XLayer> SdUnoDrawView::getActiveLayer (void) throw ()
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     Reference<drawing::XLayer> xCurrentLayer;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     do
130cdf0e10cSrcweir     {
131cdf0e10cSrcweir         // Retrieve the layer manager from the model.
132cdf0e10cSrcweir         SdXImpressDocument* pModel = GetModel();
133cdf0e10cSrcweir         if (pModel == NULL)
134cdf0e10cSrcweir             break;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         SdDrawDocument* pSdModel = pModel->GetDoc();
137cdf0e10cSrcweir         if (pSdModel == NULL)
138cdf0e10cSrcweir             break;
139cdf0e10cSrcweir 
140cdf0e10cSrcweir         // From the model get the current SdrLayer object via the layer admin.
141cdf0e10cSrcweir         SdrLayerAdmin& rLayerAdmin = pSdModel->GetLayerAdmin ();
142cdf0e10cSrcweir         SdrLayer* pLayer = rLayerAdmin.GetLayer (mrView.GetActiveLayer(), sal_True);
143cdf0e10cSrcweir         if (pLayer == NULL)
144cdf0e10cSrcweir             break;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir         // Get the corresponding XLayer object from the implementation
147cdf0e10cSrcweir         // object of the layer manager.
148cdf0e10cSrcweir         Reference<drawing::XLayerManager> xManager (pModel->getLayerManager(), uno::UNO_QUERY);
149cdf0e10cSrcweir         SdLayerManager* pManager = SdLayerManager::getImplementation (xManager);
150cdf0e10cSrcweir         if (pManager != NULL)
151cdf0e10cSrcweir             xCurrentLayer = pManager->GetLayer (pLayer);
152cdf0e10cSrcweir     }
153cdf0e10cSrcweir     while (false);
154*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
155*0deba7fbSSteve Yin 	mrController.mpCurrentLayer = &(xCurrentLayer) ;
156*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     return xCurrentLayer;
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 
164cdf0e10cSrcweir void SdUnoDrawView::setActiveLayer (const Reference<drawing::XLayer>& rxLayer) throw ()
165cdf0e10cSrcweir {
166cdf0e10cSrcweir     do
167cdf0e10cSrcweir     {
168cdf0e10cSrcweir         // Get the SdrLayer object corresponding to the given reference.
169cdf0e10cSrcweir         if ( ! rxLayer.is())
170cdf0e10cSrcweir             break;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir         SdLayer* pLayer = SdLayer::getImplementation (rxLayer);
173cdf0e10cSrcweir         if (pLayer == NULL)
174cdf0e10cSrcweir             break;
175cdf0e10cSrcweir 
176cdf0e10cSrcweir         SdrLayer* pSdrLayer = pLayer->GetSdrLayer();
177cdf0e10cSrcweir         if (pSdrLayer == NULL)
178cdf0e10cSrcweir             break;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir         // Set the new active layer and make the change visible.
181cdf0e10cSrcweir         mrView.SetActiveLayer (pSdrLayer->GetName());
182cdf0e10cSrcweir         mrDrawViewShell.ResetActualLayer ();
183cdf0e10cSrcweir     }
184cdf0e10cSrcweir     while (false);
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 
190cdf0e10cSrcweir // XSelectionSupplier
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 
193cdf0e10cSrcweir sal_Bool SAL_CALL SdUnoDrawView::select( const Any& aSelection )
194cdf0e10cSrcweir 	throw(lang::IllegalArgumentException, RuntimeException)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     bool bOk = true;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     ::std::vector<SdrObject*> aObjects;
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     SdrPage* pSdrPage = NULL;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     Reference< drawing::XShape > xShape;
203cdf0e10cSrcweir     aSelection >>= xShape;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     if(xShape.is())
206cdf0e10cSrcweir     {
207cdf0e10cSrcweir         SvxShape* pShape = SvxShape::getImplementation( xShape );
208cdf0e10cSrcweir         if( pShape && (pShape->GetSdrObject() != NULL) )
209cdf0e10cSrcweir         {
210cdf0e10cSrcweir             SdrObject* pObj = pShape->GetSdrObject();
211cdf0e10cSrcweir             pSdrPage = pObj->GetPage();
212cdf0e10cSrcweir             aObjects.push_back( pObj );
213cdf0e10cSrcweir         }
214cdf0e10cSrcweir         else
215cdf0e10cSrcweir         {
216cdf0e10cSrcweir             bOk = false;
217cdf0e10cSrcweir         }
218cdf0e10cSrcweir     }
219cdf0e10cSrcweir     else
220cdf0e10cSrcweir     {
221cdf0e10cSrcweir         Reference< drawing::XShapes > xShapes;
222cdf0e10cSrcweir         aSelection >>= xShapes;
223cdf0e10cSrcweir         if( xShapes.is() )
224cdf0e10cSrcweir         {
225cdf0e10cSrcweir             const sal_uInt32 nCount = xShapes->getCount();
226cdf0e10cSrcweir             for( sal_uInt32 i = 0; i < nCount; i++ )
227cdf0e10cSrcweir             {
228cdf0e10cSrcweir                 xShapes->getByIndex(i) >>= xShape;
229cdf0e10cSrcweir                 if( xShape.is() )
230cdf0e10cSrcweir                 {
231cdf0e10cSrcweir                     SvxShape* pShape = SvxShape::getImplementation(xShape);
232cdf0e10cSrcweir                     if( (pShape == NULL) || (pShape->GetSdrObject() == NULL) )
233cdf0e10cSrcweir                     {
234cdf0e10cSrcweir                         bOk = false;
235cdf0e10cSrcweir                         break;
236cdf0e10cSrcweir                     }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir                     SdrObject* pObj = pShape->GetSdrObject();
239cdf0e10cSrcweir 
240cdf0e10cSrcweir                     if( pSdrPage == NULL )
241cdf0e10cSrcweir                     {
242cdf0e10cSrcweir                         pSdrPage = pObj->GetPage();
243cdf0e10cSrcweir                     }
244cdf0e10cSrcweir                     else if( pSdrPage != pObj->GetPage() )
245cdf0e10cSrcweir                     {
246cdf0e10cSrcweir                         bOk = false;
247cdf0e10cSrcweir                         break;
248cdf0e10cSrcweir                     }
249cdf0e10cSrcweir 
250cdf0e10cSrcweir                     aObjects.push_back( pObj );
251cdf0e10cSrcweir                 }
252cdf0e10cSrcweir             }
253cdf0e10cSrcweir         }
254cdf0e10cSrcweir     }
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     if( bOk )
257cdf0e10cSrcweir     {
258cdf0e10cSrcweir         if( pSdrPage )
259cdf0e10cSrcweir         {
260cdf0e10cSrcweir             setMasterPageMode( pSdrPage->IsMasterPage() );
261cdf0e10cSrcweir             mrDrawViewShell.SwitchPage( (pSdrPage->GetPageNum() - 1) >> 1 );
262cdf0e10cSrcweir             mrDrawViewShell.WriteFrameViewData();
263cdf0e10cSrcweir         }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir         SdrPageView *pPV = mrView.GetSdrPageView();
266cdf0e10cSrcweir 
267cdf0e10cSrcweir         if(pPV)
268cdf0e10cSrcweir         {
269cdf0e10cSrcweir             // first deselect all
270cdf0e10cSrcweir             mrView.UnmarkAllObj( pPV );
271cdf0e10cSrcweir 
272cdf0e10cSrcweir             ::std::vector<SdrObject*>::iterator aIter( aObjects.begin() );
273cdf0e10cSrcweir             const ::std::vector<SdrObject*>::iterator aEnd( aObjects.end() );
274cdf0e10cSrcweir             while( aIter != aEnd )
275cdf0e10cSrcweir             {
276cdf0e10cSrcweir                 SdrObject* pObj = (*aIter++);
277cdf0e10cSrcweir                 mrView.MarkObj( pObj, pPV );
278cdf0e10cSrcweir             }
279cdf0e10cSrcweir         }
280cdf0e10cSrcweir         else
281cdf0e10cSrcweir         {
282cdf0e10cSrcweir             bOk = false;
283cdf0e10cSrcweir         }
284cdf0e10cSrcweir     }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	return bOk;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir //----------------------------------------------------------------------
290cdf0e10cSrcweir 
291cdf0e10cSrcweir Any SAL_CALL SdUnoDrawView::getSelection()
292cdf0e10cSrcweir 	throw(RuntimeException)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir 	Any aAny;
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     if( mrView.IsTextEdit() )
297cdf0e10cSrcweir         mrView.getTextSelection( aAny );
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 
300cdf0e10cSrcweir     if( !aAny.hasValue() )
301cdf0e10cSrcweir     {
302cdf0e10cSrcweir         const SdrMarkList& rMarkList = mrView.GetMarkedObjectList();
303cdf0e10cSrcweir         sal_uInt32 nCount = rMarkList.GetMarkCount();
304cdf0e10cSrcweir         if( nCount )
305cdf0e10cSrcweir         {
306cdf0e10cSrcweir             Reference< drawing::XShapes > xShapes( SvxShapeCollection_NewInstance(), UNO_QUERY );
307cdf0e10cSrcweir             for( sal_uInt32 nNum = 0; nNum < nCount; nNum++)
308cdf0e10cSrcweir             {
309cdf0e10cSrcweir                 SdrMark *pMark = rMarkList.GetMark(nNum);
310cdf0e10cSrcweir                 if(pMark==NULL)
311cdf0e10cSrcweir                     continue;
312cdf0e10cSrcweir 
313cdf0e10cSrcweir                 SdrObject *pObj = pMark->GetMarkedSdrObj();
314cdf0e10cSrcweir                 if(pObj==NULL || pObj->GetPage() == NULL)
315cdf0e10cSrcweir                     continue;
316cdf0e10cSrcweir 
317cdf0e10cSrcweir                 Reference< drawing::XDrawPage > xPage( pObj->GetPage()->getUnoPage(), UNO_QUERY);
318cdf0e10cSrcweir 
319cdf0e10cSrcweir                 if(!xPage.is())
320cdf0e10cSrcweir                     continue;
321cdf0e10cSrcweir 
322cdf0e10cSrcweir                 SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xPage );
323cdf0e10cSrcweir 
324cdf0e10cSrcweir                 if(pDrawPage==NULL)
325cdf0e10cSrcweir                     continue;
326cdf0e10cSrcweir 
327cdf0e10cSrcweir                 Reference< drawing::XShape > xShape( pObj->getUnoShape(), UNO_QUERY );
328cdf0e10cSrcweir 
329cdf0e10cSrcweir                 if(xShape.is())
330cdf0e10cSrcweir                     xShapes->add(xShape);
331cdf0e10cSrcweir             }
332cdf0e10cSrcweir             aAny <<= xShapes;
333cdf0e10cSrcweir         }
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 	return aAny;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 
342cdf0e10cSrcweir void SAL_CALL SdUnoDrawView::addSelectionChangeListener (
343cdf0e10cSrcweir     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
344cdf0e10cSrcweir     throw(css::uno::RuntimeException)
345cdf0e10cSrcweir {
346cdf0e10cSrcweir     (void)rxListener;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 
352cdf0e10cSrcweir void SAL_CALL SdUnoDrawView::removeSelectionChangeListener (
353cdf0e10cSrcweir     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
354cdf0e10cSrcweir     throw(css::uno::RuntimeException)
355cdf0e10cSrcweir {
356cdf0e10cSrcweir     (void)rxListener;
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 
362cdf0e10cSrcweir void SdUnoDrawView::setFastPropertyValue (
363cdf0e10cSrcweir 	sal_Int32 nHandle,
364cdf0e10cSrcweir         const Any& rValue)
365cdf0e10cSrcweir     throw(css::beans::UnknownPropertyException,
366cdf0e10cSrcweir         css::beans::PropertyVetoException,
367cdf0e10cSrcweir         css::lang::IllegalArgumentException,
368cdf0e10cSrcweir         css::lang::WrappedTargetException,
369cdf0e10cSrcweir         css::uno::RuntimeException)
370cdf0e10cSrcweir {
371cdf0e10cSrcweir 	switch( nHandle )
372cdf0e10cSrcweir 	{
373cdf0e10cSrcweir 		case DrawController::PROPERTY_CURRENTPAGE:
374cdf0e10cSrcweir 			{
375cdf0e10cSrcweir 				Reference< drawing::XDrawPage > xPage;
376cdf0e10cSrcweir 				rValue >>= xPage;
377cdf0e10cSrcweir 				setCurrentPage( xPage );
378cdf0e10cSrcweir 			}
379cdf0e10cSrcweir 			break;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 		case DrawController::PROPERTY_MASTERPAGEMODE:
382cdf0e10cSrcweir 			{
383cdf0e10cSrcweir 				sal_Bool bValue = sal_False;
384cdf0e10cSrcweir 				rValue >>= bValue;
385cdf0e10cSrcweir 				setMasterPageMode( bValue );
386cdf0e10cSrcweir 			}
387cdf0e10cSrcweir 			break;
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 		case DrawController::PROPERTY_LAYERMODE:
390cdf0e10cSrcweir 			{
391cdf0e10cSrcweir 				sal_Bool bValue = sal_False;
392cdf0e10cSrcweir 				rValue >>= bValue;
393cdf0e10cSrcweir 				setLayerMode( bValue );
394cdf0e10cSrcweir 			}
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 		case DrawController::PROPERTY_ACTIVE_LAYER:
397cdf0e10cSrcweir 			{
398cdf0e10cSrcweir 				Reference<drawing::XLayer> xLayer;
399cdf0e10cSrcweir 				rValue >>= xLayer;
400cdf0e10cSrcweir 				setActiveLayer (xLayer);
401cdf0e10cSrcweir 			}
402cdf0e10cSrcweir 			break;
403cdf0e10cSrcweir 		case DrawController::PROPERTY_ZOOMVALUE:
404cdf0e10cSrcweir 			{
405cdf0e10cSrcweir 				sal_Int16 nZoom = 0;
406cdf0e10cSrcweir 				rValue >>= nZoom;
407cdf0e10cSrcweir 				SetZoom( nZoom );
408cdf0e10cSrcweir 			}
409cdf0e10cSrcweir 			break;
410cdf0e10cSrcweir 		case DrawController::PROPERTY_ZOOMTYPE:
411cdf0e10cSrcweir 			{
412cdf0e10cSrcweir 				sal_Int16 nType = 0;
413cdf0e10cSrcweir 				rValue >>= nType;
414cdf0e10cSrcweir 				SetZoomType( nType );
415cdf0e10cSrcweir 			}
416cdf0e10cSrcweir 			break;
417cdf0e10cSrcweir 		case DrawController::PROPERTY_VIEWOFFSET:
418cdf0e10cSrcweir 			{
419cdf0e10cSrcweir 				awt::Point aOffset;
420cdf0e10cSrcweir 				rValue >>= aOffset;
421cdf0e10cSrcweir 				SetViewOffset( aOffset );
422cdf0e10cSrcweir 			}
423cdf0e10cSrcweir 			break;
424cdf0e10cSrcweir         default:
425cdf0e10cSrcweir             throw beans::UnknownPropertyException();
426cdf0e10cSrcweir 	}
427cdf0e10cSrcweir }
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 
432cdf0e10cSrcweir Any SAL_CALL SdUnoDrawView::getFastPropertyValue (
433cdf0e10cSrcweir     sal_Int32 nHandle)
434cdf0e10cSrcweir     throw(css::beans::UnknownPropertyException,
435cdf0e10cSrcweir         css::lang::WrappedTargetException,
436cdf0e10cSrcweir         css::uno::RuntimeException)
437cdf0e10cSrcweir {
438cdf0e10cSrcweir     Any aValue;
439cdf0e10cSrcweir 	switch( nHandle )
440cdf0e10cSrcweir 	{
441cdf0e10cSrcweir 		case DrawController::PROPERTY_CURRENTPAGE:
442cdf0e10cSrcweir 			aValue <<= (const_cast<SdUnoDrawView*>(this))->getCurrentPage();
443cdf0e10cSrcweir 			break;
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 		case DrawController::PROPERTY_MASTERPAGEMODE:
446cdf0e10cSrcweir 			aValue <<= getMasterPageMode();
447cdf0e10cSrcweir 			break;
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 		case DrawController::PROPERTY_LAYERMODE:
450cdf0e10cSrcweir 			aValue <<= getLayerMode();
451cdf0e10cSrcweir 			break;
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 		case DrawController::PROPERTY_ACTIVE_LAYER:
454cdf0e10cSrcweir 			aValue <<= (const_cast<SdUnoDrawView*>(this))->getActiveLayer();
455cdf0e10cSrcweir 			break;
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 		case DrawController::PROPERTY_ZOOMVALUE:
458cdf0e10cSrcweir 			aValue <<= GetZoom();
459cdf0e10cSrcweir 			break;
460cdf0e10cSrcweir 		case DrawController::PROPERTY_ZOOMTYPE:
461cdf0e10cSrcweir 			aValue <<= (sal_Int16)com::sun::star::view::DocumentZoomType::BY_VALUE;
462cdf0e10cSrcweir 			break;
463cdf0e10cSrcweir 		case DrawController::PROPERTY_VIEWOFFSET:
464cdf0e10cSrcweir 			aValue <<= GetViewOffset();
465cdf0e10cSrcweir 			break;
466cdf0e10cSrcweir 
467cdf0e10cSrcweir 		case DrawController::PROPERTY_DRAWVIEWMODE:
468cdf0e10cSrcweir 			aValue = getDrawViewMode();
469cdf0e10cSrcweir 			break;
470cdf0e10cSrcweir 
471cdf0e10cSrcweir         default:
472cdf0e10cSrcweir             throw beans::UnknownPropertyException();
473cdf0e10cSrcweir 	}
474cdf0e10cSrcweir 
475cdf0e10cSrcweir     return aValue;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 
481cdf0e10cSrcweir // XDrawView
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 
484cdf0e10cSrcweir void SAL_CALL SdUnoDrawView::setCurrentPage (
485cdf0e10cSrcweir     const Reference< drawing::XDrawPage >& xPage )
486cdf0e10cSrcweir 	throw(RuntimeException)
487cdf0e10cSrcweir {
488cdf0e10cSrcweir     SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xPage );
489cdf0e10cSrcweir     SdrPage *pSdrPage = pDrawPage ? pDrawPage->GetSdrPage() : NULL;
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     if(pSdrPage)
492cdf0e10cSrcweir     {
493cdf0e10cSrcweir         // End editing of text.  Otherwise the edited text object would
494cdf0e10cSrcweir         // still be visible on the new page.
495cdf0e10cSrcweir         mrDrawViewShell.GetView()->SdrEndTextEdit();
496cdf0e10cSrcweir 
497cdf0e10cSrcweir         setMasterPageMode( pSdrPage->IsMasterPage() );
498cdf0e10cSrcweir         mrDrawViewShell.SwitchPage( (pSdrPage->GetPageNum() - 1) >> 1 );
499cdf0e10cSrcweir         mrDrawViewShell.WriteFrameViewData();
500cdf0e10cSrcweir     }
501cdf0e10cSrcweir }
502cdf0e10cSrcweir 
503cdf0e10cSrcweir //----------------------------------------------------------------------
504cdf0e10cSrcweir 
505cdf0e10cSrcweir Reference< drawing::XDrawPage > SAL_CALL SdUnoDrawView::getCurrentPage()
506cdf0e10cSrcweir 	throw(RuntimeException)
507cdf0e10cSrcweir {
508cdf0e10cSrcweir 	Reference< drawing::XDrawPage >  xPage;
509cdf0e10cSrcweir 
510cdf0e10cSrcweir     SdrPageView *pPV = mrView.GetSdrPageView();
511cdf0e10cSrcweir     SdrPage* pPage = pPV ? pPV->GetPage() : NULL;
512cdf0e10cSrcweir 
513cdf0e10cSrcweir     if(pPage)
514cdf0e10cSrcweir         xPage = Reference< drawing::XDrawPage >::query( pPage->getUnoPage() );
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 	return xPage;
517cdf0e10cSrcweir }
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 
520cdf0e10cSrcweir sal_Int16 SdUnoDrawView::GetZoom(void) const
521cdf0e10cSrcweir {
522cdf0e10cSrcweir 	if (mrDrawViewShell.GetActiveWindow() )
523cdf0e10cSrcweir 	{
524cdf0e10cSrcweir 		return (sal_Int16)mrDrawViewShell.GetActiveWindow()->GetZoom();
525cdf0e10cSrcweir 	}
526cdf0e10cSrcweir 	else
527cdf0e10cSrcweir 	{
528cdf0e10cSrcweir 		return 0;
529cdf0e10cSrcweir 	}
530cdf0e10cSrcweir }
531cdf0e10cSrcweir 
532cdf0e10cSrcweir void SdUnoDrawView::SetZoom( sal_Int16 nZoom )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir 	SvxZoomItem aZoomItem( SVX_ZOOM_PERCENT, nZoom );
535cdf0e10cSrcweir 
536cdf0e10cSrcweir     SfxViewFrame* pViewFrame = mrDrawViewShell.GetViewFrame();
537cdf0e10cSrcweir     if( pViewFrame )
538cdf0e10cSrcweir     {
539cdf0e10cSrcweir         SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
540cdf0e10cSrcweir         if( pDispatcher )
541cdf0e10cSrcweir         {
542cdf0e10cSrcweir             pDispatcher->Execute(SID_ATTR_ZOOM,SFX_CALLMODE_SYNCHRON,&aZoomItem, 0L);
543cdf0e10cSrcweir         }
544cdf0e10cSrcweir     }
545cdf0e10cSrcweir }
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 
548cdf0e10cSrcweir void SdUnoDrawView::SetViewOffset(const awt::Point& rWinPos )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir     Point aWinPos( rWinPos.X, rWinPos.Y );
551cdf0e10cSrcweir     aWinPos += mrDrawViewShell.GetViewOrigin();
552cdf0e10cSrcweir     mrDrawViewShell.SetWinViewPos( aWinPos, true );
553cdf0e10cSrcweir }
554cdf0e10cSrcweir 
555cdf0e10cSrcweir awt::Point SdUnoDrawView::GetViewOffset() const
556cdf0e10cSrcweir {
557cdf0e10cSrcweir 	Point aRet;
558cdf0e10cSrcweir 
559cdf0e10cSrcweir     aRet = mrDrawViewShell.GetWinViewPos();
560cdf0e10cSrcweir     aRet -= mrDrawViewShell.GetViewOrigin();
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 	return awt::Point( aRet.X(), aRet.Y() );
563cdf0e10cSrcweir }
564cdf0e10cSrcweir 
565cdf0e10cSrcweir void SdUnoDrawView::SetZoomType ( sal_Int16 nType )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir     SfxViewFrame* pViewFrame = mrDrawViewShell.GetViewFrame();
568cdf0e10cSrcweir     if( pViewFrame )
569cdf0e10cSrcweir     {
570cdf0e10cSrcweir         SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
571cdf0e10cSrcweir         if( pDispatcher )
572cdf0e10cSrcweir         {
573cdf0e10cSrcweir             SvxZoomType eZoomType;
574cdf0e10cSrcweir             switch( nType )
575cdf0e10cSrcweir             {
576cdf0e10cSrcweir                 case com::sun::star::view::DocumentZoomType::OPTIMAL:
577cdf0e10cSrcweir                     eZoomType = SVX_ZOOM_OPTIMAL;
578cdf0e10cSrcweir                     break;
579cdf0e10cSrcweir 
580cdf0e10cSrcweir                 case com::sun::star::view::DocumentZoomType::PAGE_WIDTH:
581cdf0e10cSrcweir                 case com::sun::star::view::DocumentZoomType::PAGE_WIDTH_EXACT:
582cdf0e10cSrcweir                     eZoomType = SVX_ZOOM_PAGEWIDTH;
583cdf0e10cSrcweir                     break;
584cdf0e10cSrcweir 
585cdf0e10cSrcweir                 case com::sun::star::view::DocumentZoomType::ENTIRE_PAGE:
586cdf0e10cSrcweir                     eZoomType = SVX_ZOOM_WHOLEPAGE;
587cdf0e10cSrcweir                     break;
588cdf0e10cSrcweir 
589cdf0e10cSrcweir                 default:
590cdf0e10cSrcweir                     return;
591cdf0e10cSrcweir             }
592cdf0e10cSrcweir             SvxZoomItem aZoomItem( eZoomType );
593cdf0e10cSrcweir             pDispatcher->Execute(SID_ATTR_ZOOM,SFX_CALLMODE_SYNCHRON,&aZoomItem, 0L);
594cdf0e10cSrcweir         }
595cdf0e10cSrcweir     }
596cdf0e10cSrcweir }
597cdf0e10cSrcweir 
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 
601cdf0e10cSrcweir SdXImpressDocument* SdUnoDrawView::GetModel (void) const throw()
602cdf0e10cSrcweir {
603cdf0e10cSrcweir 	if (mrView.GetDocSh()!=NULL)
604cdf0e10cSrcweir 	{
605cdf0e10cSrcweir 		Reference<frame::XModel> xModel (mrView.GetDocSh()->GetModel());
606cdf0e10cSrcweir 		return SdXImpressDocument::getImplementation(xModel);
607cdf0e10cSrcweir 	}
608cdf0e10cSrcweir 	else
609cdf0e10cSrcweir 		return NULL;
610cdf0e10cSrcweir }
611cdf0e10cSrcweir 
612cdf0e10cSrcweir Any SdUnoDrawView::getDrawViewMode() const
613cdf0e10cSrcweir {
614cdf0e10cSrcweir 	Any aRet;
615cdf0e10cSrcweir 	switch( mrDrawViewShell.GetPageKind() )
616cdf0e10cSrcweir 	{
617cdf0e10cSrcweir 	case PK_NOTES:	aRet <<= DrawViewMode_NOTES; break;
618cdf0e10cSrcweir 	case PK_HANDOUT: aRet <<= DrawViewMode_HANDOUT; break;
619cdf0e10cSrcweir 	case PK_STANDARD: aRet <<= DrawViewMode_DRAW; break;
620cdf0e10cSrcweir 	}
621cdf0e10cSrcweir 	return aRet;
622cdf0e10cSrcweir }
623cdf0e10cSrcweir 
624cdf0e10cSrcweir // XServiceInfo
625cdf0e10cSrcweir OUString SAL_CALL SdUnoDrawView::getImplementationName(  ) throw (RuntimeException)
626cdf0e10cSrcweir {
627cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sd.SdUnoDrawView") );
628cdf0e10cSrcweir }
629cdf0e10cSrcweir 
630cdf0e10cSrcweir sal_Bool SAL_CALL SdUnoDrawView::supportsService( const OUString& ServiceName ) throw (RuntimeException)
631cdf0e10cSrcweir {
632cdf0e10cSrcweir 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
633cdf0e10cSrcweir }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir Sequence< OUString > SAL_CALL SdUnoDrawView::getSupportedServiceNames(  ) throw (RuntimeException)
636cdf0e10cSrcweir {
637cdf0e10cSrcweir 	OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView") );
638cdf0e10cSrcweir 	uno::Sequence< OUString > aSeq( &aSN, 1 );
639cdf0e10cSrcweir 	return aSeq;
640cdf0e10cSrcweir }
641cdf0e10cSrcweir 
642cdf0e10cSrcweir } // end of namespace sd
643cdf0e10cSrcweir 
644