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