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