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