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 "DrawController.hxx" 32*cdf0e10cSrcweir #include "DrawDocShell.hxx" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include "DrawSubController.hxx" 35*cdf0e10cSrcweir #include "sdpage.hxx" 36*cdf0e10cSrcweir #include "ViewShellBase.hxx" 37*cdf0e10cSrcweir #include "ViewShellManager.hxx" 38*cdf0e10cSrcweir #include "FormShellManager.hxx" 39*cdf0e10cSrcweir #include "Window.hxx" 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <comphelper/anytostring.hxx> 42*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 43*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 44*cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 45*cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx> 46*cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ConfigurationController.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ModuleController.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir #include "slideshow.hxx" 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #include <svx/fmshell.hxx> 56*cdf0e10cSrcweir #include <vos/mutex.hxx> 57*cdf0e10cSrcweir #include <vcl/svapp.hxx> 58*cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir using namespace ::std; 61*cdf0e10cSrcweir using ::rtl::OUString; 62*cdf0e10cSrcweir using namespace ::cppu; 63*cdf0e10cSrcweir using namespace ::vos; 64*cdf0e10cSrcweir using namespace ::com::sun::star; 65*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 66*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework; 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir namespace { 69*cdf0e10cSrcweir static const ::com::sun::star::uno::Type saComponentTypeIdentifier ( 70*cdf0e10cSrcweir ::getCppuType( (Reference<lang::XEventListener > *)0 )); 71*cdf0e10cSrcweir static const ::com::sun::star::uno::Type saSelectionTypeIdentifier ( 72*cdf0e10cSrcweir ::getCppuType( (Reference<view::XSelectionChangeListener > *)0 )); 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir } // end of anonymous namespace 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir namespace sd { 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir DrawController::DrawController (ViewShellBase& rBase) throw() 79*cdf0e10cSrcweir : DrawControllerInterfaceBase(&rBase), 80*cdf0e10cSrcweir BroadcastHelperOwner(SfxBaseController::m_aMutex), 81*cdf0e10cSrcweir OPropertySetHelper( static_cast<OBroadcastHelperVar< 82*cdf0e10cSrcweir OMultiTypeInterfaceContainerHelper, 83*cdf0e10cSrcweir OMultiTypeInterfaceContainerHelper::keyType>& >( 84*cdf0e10cSrcweir BroadcastHelperOwner::maBroadcastHelper)), 85*cdf0e10cSrcweir mpBase(&rBase), 86*cdf0e10cSrcweir maLastVisArea(), 87*cdf0e10cSrcweir mpCurrentPage(NULL), 88*cdf0e10cSrcweir mbMasterPageMode(false), 89*cdf0e10cSrcweir mbLayerMode(false), 90*cdf0e10cSrcweir mbDisposing(false), 91*cdf0e10cSrcweir mpPropertyArrayHelper(NULL), 92*cdf0e10cSrcweir mxSubController(), 93*cdf0e10cSrcweir mxConfigurationController(), 94*cdf0e10cSrcweir mxModuleController() 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir ProvideFrameworkControllers(); 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir DrawController::~DrawController (void) throw() 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir void DrawController::SetSubController ( 110*cdf0e10cSrcweir const Reference<drawing::XDrawSubController>& rxSubController) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir // Update the internal state. 113*cdf0e10cSrcweir mxSubController = rxSubController; 114*cdf0e10cSrcweir mpPropertyArrayHelper.reset(); 115*cdf0e10cSrcweir maLastVisArea = Rectangle(); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir // Inform listeners about the changed state. 118*cdf0e10cSrcweir FireSelectionChangeListener(); 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir // XInterface 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( 127*cdf0e10cSrcweir DrawController, 128*cdf0e10cSrcweir DrawControllerInterfaceBase, 129*cdf0e10cSrcweir OPropertySetHelper); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir // XTypeProvider 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir Sequence<Type> SAL_CALL DrawController::getTypes (void) 135*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir ThrowIfDisposed(); 138*cdf0e10cSrcweir // OPropertySetHelper does not provide getTypes, so we have to 139*cdf0e10cSrcweir // implement this method manually and list its three interfaces. 140*cdf0e10cSrcweir OTypeCollection aTypeCollection ( 141*cdf0e10cSrcweir ::getCppuType (( const Reference<beans::XMultiPropertySet>*)NULL), 142*cdf0e10cSrcweir ::getCppuType (( const Reference<beans::XFastPropertySet>*)NULL), 143*cdf0e10cSrcweir ::getCppuType (( const Reference<beans::XPropertySet>*)NULL)); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir return ::comphelper::concatSequences( 146*cdf0e10cSrcweir SfxBaseController::getTypes(), 147*cdf0e10cSrcweir aTypeCollection.getTypes(), 148*cdf0e10cSrcweir DrawControllerInterfaceBase::getTypes()); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir IMPLEMENT_GET_IMPLEMENTATION_ID(DrawController); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir // XComponent 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir void SAL_CALL DrawController::dispose (void) 159*cdf0e10cSrcweir throw( RuntimeException ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir if( !mbDisposing ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir if( !mbDisposing ) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir mbDisposing = true; 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell(); 170*cdf0e10cSrcweir if ( pViewShell ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir pViewShell->DeactivateCurrentFunction(); 173*cdf0e10cSrcweir DrawDocShell* pDocShell = pViewShell->GetDocSh(); 174*cdf0e10cSrcweir if ( pDocShell != NULL ) 175*cdf0e10cSrcweir pDocShell->SetDocShellFunction(0); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir pViewShell.reset(); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir // When the controller has not been detached from its view 180*cdf0e10cSrcweir // shell, i.e. mpViewShell is not NULL, then tell PaneManager 181*cdf0e10cSrcweir // and ViewShellManager to clear the shell stack. 182*cdf0e10cSrcweir if (mxSubController.is() && mpBase!=NULL) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir mpBase->DisconnectAllClients(); 185*cdf0e10cSrcweir mpBase->GetViewShellManager()->Shutdown(); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir OPropertySetHelper::disposing(); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir DisposeFrameworkControllers(); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir SfxBaseController::dispose(); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir void SAL_CALL DrawController::addEventListener( 201*cdf0e10cSrcweir const Reference<lang::XEventListener >& xListener) 202*cdf0e10cSrcweir throw (RuntimeException) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir ThrowIfDisposed(); 205*cdf0e10cSrcweir SfxBaseController::addEventListener( xListener ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir void SAL_CALL DrawController::removeEventListener ( 212*cdf0e10cSrcweir const Reference<lang::XEventListener >& aListener) 213*cdf0e10cSrcweir throw (RuntimeException) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir if(!rBHelper.bDisposed && !rBHelper.bInDispose && !mbDisposing) 216*cdf0e10cSrcweir SfxBaseController::removeEventListener( aListener ); 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // XController 220*cdf0e10cSrcweir ::sal_Bool SAL_CALL DrawController::suspend( ::sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir if( Suspend ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir ViewShellBase* pViewShellBase = GetViewShellBase(); 225*cdf0e10cSrcweir if( pViewShellBase ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir // do not allow suspend if a slideshow needs this controller! 228*cdf0e10cSrcweir rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pViewShellBase ) ); 229*cdf0e10cSrcweir if( xSlideShow.is() && xSlideShow->dependsOn(pViewShellBase) ) 230*cdf0e10cSrcweir return sal_False; 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir return SfxBaseController::suspend( Suspend ); 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir // XServiceInfo 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir OUString SAL_CALL DrawController::getImplementationName( ) throw(RuntimeException) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir // Do not throw an excepetion at the moment. This leads to a crash 243*cdf0e10cSrcweir // under Solaris on relead. See issue i70929 for details. 244*cdf0e10cSrcweir // ThrowIfDisposed(); 245*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( "DrawController" ) ); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir static OUString ssServiceName (OUString::createFromAscii( 251*cdf0e10cSrcweir "com.sun.star.drawing.DrawingDocumentDrawView")); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir sal_Bool SAL_CALL DrawController::supportsService ( 254*cdf0e10cSrcweir const OUString& rsServiceName) 255*cdf0e10cSrcweir throw(RuntimeException) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir // Do not throw an excepetion at the moment. This leads to a crash 258*cdf0e10cSrcweir // under Solaris on relead. See issue i70929 for details. 259*cdf0e10cSrcweir // ThrowIfDisposed(); 260*cdf0e10cSrcweir return rsServiceName.equals(ssServiceName); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames (void) 267*cdf0e10cSrcweir throw(RuntimeException) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir ThrowIfDisposed(); 270*cdf0e10cSrcweir Sequence<OUString> aSupportedServices (1); 271*cdf0e10cSrcweir OUString* pServices = aSupportedServices.getArray(); 272*cdf0e10cSrcweir pServices[0] = ssServiceName; 273*cdf0e10cSrcweir return aSupportedServices; 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir //------ XSelectionSupplier -------------------------------------------- 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir sal_Bool SAL_CALL DrawController::select (const Any& aSelection) 282*cdf0e10cSrcweir throw(lang::IllegalArgumentException, RuntimeException) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir ThrowIfDisposed(); 285*cdf0e10cSrcweir ::vos::OGuard aGuard (Application::GetSolarMutex()); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir if (mxSubController.is()) 288*cdf0e10cSrcweir return mxSubController->select(aSelection); 289*cdf0e10cSrcweir else 290*cdf0e10cSrcweir return false; 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir Any SAL_CALL DrawController::getSelection() 297*cdf0e10cSrcweir throw(RuntimeException) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir ThrowIfDisposed(); 300*cdf0e10cSrcweir ::vos::OGuard aGuard (Application::GetSolarMutex()); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir if (mxSubController.is()) 303*cdf0e10cSrcweir return mxSubController->getSelection(); 304*cdf0e10cSrcweir else 305*cdf0e10cSrcweir return Any(); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir void SAL_CALL DrawController::addSelectionChangeListener( 312*cdf0e10cSrcweir const Reference< view::XSelectionChangeListener >& xListener) 313*cdf0e10cSrcweir throw(RuntimeException) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir if( mbDisposing ) 316*cdf0e10cSrcweir throw lang::DisposedException(); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir BroadcastHelperOwner::maBroadcastHelper.addListener (saSelectionTypeIdentifier, xListener); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir void SAL_CALL DrawController::removeSelectionChangeListener( 325*cdf0e10cSrcweir const Reference< view::XSelectionChangeListener >& xListener ) 326*cdf0e10cSrcweir throw(RuntimeException) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir if (rBHelper.bDisposed) 329*cdf0e10cSrcweir throw lang::DisposedException(); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir BroadcastHelperOwner::maBroadcastHelper.removeListener (saSelectionTypeIdentifier, xListener); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir //===== lang::XEventListener ================================================ 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir void SAL_CALL 341*cdf0e10cSrcweir DrawController::disposing (const lang::EventObject& ) 342*cdf0e10cSrcweir throw (uno::RuntimeException) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir //===== view::XSelectionChangeListener ====================================== 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir void SAL_CALL 352*cdf0e10cSrcweir DrawController::selectionChanged (const lang::EventObject& rEvent) 353*cdf0e10cSrcweir throw (uno::RuntimeException) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir ThrowIfDisposed(); 356*cdf0e10cSrcweir // Have to forward the event to our selection change listeners. 357*cdf0e10cSrcweir OInterfaceContainerHelper* pListeners = BroadcastHelperOwner::maBroadcastHelper.getContainer( 358*cdf0e10cSrcweir ::getCppuType((Reference<view::XSelectionChangeListener>*)0)); 359*cdf0e10cSrcweir if (pListeners) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir // Re-send the event to all of our listeners. 362*cdf0e10cSrcweir OInterfaceIteratorHelper aIterator (*pListeners); 363*cdf0e10cSrcweir while (aIterator.hasMoreElements()) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir try 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir view::XSelectionChangeListener* pListener = 368*cdf0e10cSrcweir static_cast<view::XSelectionChangeListener*>( 369*cdf0e10cSrcweir aIterator.next()); 370*cdf0e10cSrcweir if (pListener != NULL) 371*cdf0e10cSrcweir pListener->selectionChanged (rEvent); 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir catch (RuntimeException aException) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir // XDrawView 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir void SAL_CALL DrawController::setCurrentPage( const Reference< drawing::XDrawPage >& xPage ) 386*cdf0e10cSrcweir throw(RuntimeException) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir ThrowIfDisposed(); 389*cdf0e10cSrcweir ::vos::OGuard aGuard (Application::GetSolarMutex()); 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir if (mxSubController.is()) 392*cdf0e10cSrcweir mxSubController->setCurrentPage(xPage); 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir Reference< drawing::XDrawPage > SAL_CALL DrawController::getCurrentPage (void) 399*cdf0e10cSrcweir throw(RuntimeException) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir ThrowIfDisposed(); 402*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 403*cdf0e10cSrcweir Reference<drawing::XDrawPage> xPage; 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir // Get current page from sub controller. 406*cdf0e10cSrcweir if (mxSubController.is()) 407*cdf0e10cSrcweir xPage = mxSubController->getCurrentPage(); 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir // When there is not yet a sub controller (during initialization) then fall back 410*cdf0e10cSrcweir // to the current page in mpCurrentPage. 411*cdf0e10cSrcweir if ( ! xPage.is() && mpCurrentPage.is()) 412*cdf0e10cSrcweir xPage = Reference<drawing::XDrawPage>(mpCurrentPage->getUnoPage(), UNO_QUERY); 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir return xPage; 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir void DrawController::FireVisAreaChanged (const Rectangle& rVisArea) throw() 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir if( maLastVisArea != rVisArea ) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir Any aNewValue; 425*cdf0e10cSrcweir aNewValue <<= awt::Rectangle( 426*cdf0e10cSrcweir rVisArea.Left(), 427*cdf0e10cSrcweir rVisArea.Top(), 428*cdf0e10cSrcweir rVisArea.GetWidth(), 429*cdf0e10cSrcweir rVisArea.GetHeight() ); 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir Any aOldValue; 432*cdf0e10cSrcweir aOldValue <<= awt::Rectangle( 433*cdf0e10cSrcweir maLastVisArea.Left(), 434*cdf0e10cSrcweir maLastVisArea.Top(), 435*cdf0e10cSrcweir maLastVisArea.GetWidth(), 436*cdf0e10cSrcweir maLastVisArea.GetHeight() ); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir FirePropertyChange (PROPERTY_WORKAREA, aNewValue, aOldValue); 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir maLastVisArea = rVisArea; 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir void DrawController::FireSelectionChangeListener() throw() 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir OInterfaceContainerHelper * pLC = BroadcastHelperOwner::maBroadcastHelper.getContainer( 450*cdf0e10cSrcweir saSelectionTypeIdentifier); 451*cdf0e10cSrcweir if( pLC ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir Reference< XInterface > xSource( (XWeak*)this ); 454*cdf0e10cSrcweir const lang::EventObject aEvent( xSource ); 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir // Ueber alle Listener iterieren und Events senden 457*cdf0e10cSrcweir OInterfaceIteratorHelper aIt( *pLC); 458*cdf0e10cSrcweir while( aIt.hasMoreElements() ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir try 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir view::XSelectionChangeListener * pL = 463*cdf0e10cSrcweir static_cast<view::XSelectionChangeListener*>(aIt.next()); 464*cdf0e10cSrcweir if (pL != NULL) 465*cdf0e10cSrcweir pL->selectionChanged( aEvent ); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir catch (RuntimeException aException) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir void DrawController::FireChangeEditMode (bool bMasterPageMode) throw() 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir if (bMasterPageMode != mbMasterPageMode ) 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir FirePropertyChange( 482*cdf0e10cSrcweir PROPERTY_MASTERPAGEMODE, 483*cdf0e10cSrcweir makeAny(bMasterPageMode), 484*cdf0e10cSrcweir makeAny(mbMasterPageMode)); 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir mbMasterPageMode = bMasterPageMode; 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir void DrawController::FireChangeLayerMode (bool bLayerMode) throw() 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir if (bLayerMode != mbLayerMode) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir FirePropertyChange( 498*cdf0e10cSrcweir PROPERTY_LAYERMODE, 499*cdf0e10cSrcweir makeAny(bLayerMode), 500*cdf0e10cSrcweir makeAny(mbLayerMode)); 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir mbLayerMode = bLayerMode; 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir void DrawController::FireSwitchCurrentPage (SdPage* pNewCurrentPage) throw() 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir SdrPage* pCurrentPage = mpCurrentPage.get(); 512*cdf0e10cSrcweir if (pNewCurrentPage != pCurrentPage) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir try 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir Any aNewValue ( 517*cdf0e10cSrcweir makeAny(Reference<drawing::XDrawPage>(pNewCurrentPage->getUnoPage(), UNO_QUERY))); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir Any aOldValue; 520*cdf0e10cSrcweir if (pCurrentPage != NULL) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir Reference<drawing::XDrawPage> xOldPage (pCurrentPage->getUnoPage(), UNO_QUERY); 523*cdf0e10cSrcweir aOldValue <<= xOldPage; 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir FirePropertyChange(PROPERTY_CURRENTPAGE, aNewValue, aOldValue); 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir mpCurrentPage.reset(pNewCurrentPage); 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir catch( uno::Exception& e ) 531*cdf0e10cSrcweir { 532*cdf0e10cSrcweir (void)e; 533*cdf0e10cSrcweir DBG_ERROR( 534*cdf0e10cSrcweir (::rtl::OString("sd::SdUnoDrawView::FireSwitchCurrentPage(), " 535*cdf0e10cSrcweir "exception caught: ") + 536*cdf0e10cSrcweir ::rtl::OUStringToOString( 537*cdf0e10cSrcweir comphelper::anyToString( cppu::getCaughtException() ), 538*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 )).getStr() ); 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir void DrawController::FirePropertyChange ( 547*cdf0e10cSrcweir sal_Int32 nHandle, 548*cdf0e10cSrcweir const Any& rNewValue, 549*cdf0e10cSrcweir const Any& rOldValue) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir try 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir fire (&nHandle, &rNewValue, &rOldValue, 1, sal_False); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir catch (RuntimeException aException) 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir // Ignore this exception. Exceptions should be handled in the 558*cdf0e10cSrcweir // fire() function so that all listeners are called. This is 559*cdf0e10cSrcweir // not the case at the moment, so we simply ignore the 560*cdf0e10cSrcweir // exception. 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir ViewShellBase* DrawController::GetViewShellBase (void) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir return mpBase; 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir void DrawController::ReleaseViewShellBase (void) 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir DisposeFrameworkControllers(); 579*cdf0e10cSrcweir mpBase = NULL; 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir //===== XControllerManager ============================================================== 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir Reference<XConfigurationController> SAL_CALL 588*cdf0e10cSrcweir DrawController::getConfigurationController (void) 589*cdf0e10cSrcweir throw (RuntimeException) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir ThrowIfDisposed(); 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir return mxConfigurationController; 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir Reference<XModuleController> SAL_CALL 600*cdf0e10cSrcweir DrawController::getModuleController (void) 601*cdf0e10cSrcweir throw (RuntimeException) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir ThrowIfDisposed(); 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir return mxModuleController; 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir //===== XUnoTunnel ============================================================ 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir const Sequence<sal_Int8>& DrawController::getUnoTunnelId (void) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir static ::com::sun::star::uno::Sequence<sal_Int8>* pSequence = NULL; 616*cdf0e10cSrcweir if (pSequence == NULL) 617*cdf0e10cSrcweir { 618*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard (::osl::Mutex::getGlobalMutex()); 619*cdf0e10cSrcweir if (pSequence == NULL) 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16); 622*cdf0e10cSrcweir rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True); 623*cdf0e10cSrcweir pSequence = &aSequence; 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir return *pSequence; 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir 632*cdf0e10cSrcweir sal_Int64 SAL_CALL DrawController::getSomething (const Sequence<sal_Int8>& rId) 633*cdf0e10cSrcweir throw (RuntimeException) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir sal_Int64 nResult = 0; 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir if (rId.getLength() == 16 638*cdf0e10cSrcweir && rtl_compareMemory(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir nResult = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 641*cdf0e10cSrcweir } 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir return nResult; 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir //===== Properties ============================================================ 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir void DrawController::FillPropertyTable ( 652*cdf0e10cSrcweir ::std::vector<beans::Property>& rProperties) 653*cdf0e10cSrcweir { 654*cdf0e10cSrcweir rProperties.push_back( 655*cdf0e10cSrcweir beans::Property( 656*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("VisibleArea") ), 657*cdf0e10cSrcweir PROPERTY_WORKAREA, 658*cdf0e10cSrcweir ::getCppuType((const ::com::sun::star::awt::Rectangle*)0), 659*cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY)); 660*cdf0e10cSrcweir rProperties.push_back( 661*cdf0e10cSrcweir beans::Property( 662*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("SubController") ), 663*cdf0e10cSrcweir PROPERTY_SUB_CONTROLLER, 664*cdf0e10cSrcweir ::getCppuType((const Reference<drawing::XDrawSubController>*)0), 665*cdf0e10cSrcweir beans::PropertyAttribute::BOUND)); 666*cdf0e10cSrcweir rProperties.push_back( 667*cdf0e10cSrcweir beans::Property( 668*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("CurrentPage") ), 669*cdf0e10cSrcweir PROPERTY_CURRENTPAGE, 670*cdf0e10cSrcweir ::getCppuType((const Reference< drawing::XDrawPage > *)0), 671*cdf0e10cSrcweir beans::PropertyAttribute::BOUND )); 672*cdf0e10cSrcweir rProperties.push_back( 673*cdf0e10cSrcweir beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("IsLayerMode") ), 674*cdf0e10cSrcweir PROPERTY_LAYERMODE, 675*cdf0e10cSrcweir ::getCppuBooleanType(), 676*cdf0e10cSrcweir beans::PropertyAttribute::BOUND )); 677*cdf0e10cSrcweir rProperties.push_back( 678*cdf0e10cSrcweir beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("IsMasterPageMode") ), 679*cdf0e10cSrcweir PROPERTY_MASTERPAGEMODE, 680*cdf0e10cSrcweir ::getCppuBooleanType(), 681*cdf0e10cSrcweir beans::PropertyAttribute::BOUND )); 682*cdf0e10cSrcweir rProperties.push_back( 683*cdf0e10cSrcweir beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ActiveLayer") ), 684*cdf0e10cSrcweir PROPERTY_ACTIVE_LAYER, 685*cdf0e10cSrcweir ::getCppuBooleanType(), 686*cdf0e10cSrcweir beans::PropertyAttribute::BOUND )); 687*cdf0e10cSrcweir rProperties.push_back( 688*cdf0e10cSrcweir beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomValue") ), 689*cdf0e10cSrcweir PROPERTY_ZOOMVALUE, 690*cdf0e10cSrcweir ::getCppuType((const sal_Int16*)0), 691*cdf0e10cSrcweir beans::PropertyAttribute::BOUND )); 692*cdf0e10cSrcweir rProperties.push_back( 693*cdf0e10cSrcweir beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomType") ), 694*cdf0e10cSrcweir PROPERTY_ZOOMTYPE, 695*cdf0e10cSrcweir ::getCppuType((const sal_Int16*)0), 696*cdf0e10cSrcweir beans::PropertyAttribute::BOUND )); 697*cdf0e10cSrcweir rProperties.push_back( 698*cdf0e10cSrcweir beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ViewOffset") ), 699*cdf0e10cSrcweir PROPERTY_VIEWOFFSET, 700*cdf0e10cSrcweir ::getCppuType((const ::com::sun::star::awt::Point*)0), 701*cdf0e10cSrcweir beans::PropertyAttribute::BOUND )); 702*cdf0e10cSrcweir rProperties.push_back( 703*cdf0e10cSrcweir beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("DrawViewMode") ), 704*cdf0e10cSrcweir PROPERTY_DRAWVIEWMODE, 705*cdf0e10cSrcweir ::getCppuType((const ::com::sun::star::awt::Point*)0), 706*cdf0e10cSrcweir beans::PropertyAttribute::BOUND|beans::PropertyAttribute::READONLY|beans::PropertyAttribute::MAYBEVOID )); 707*cdf0e10cSrcweir } 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir IPropertyArrayHelper & DrawController::getInfoHelper() 713*cdf0e10cSrcweir { 714*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir if (mpPropertyArrayHelper.get() == NULL) 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir ::std::vector<beans::Property> aProperties; 719*cdf0e10cSrcweir FillPropertyTable (aProperties); 720*cdf0e10cSrcweir Sequence<beans::Property> aPropertySequence (aProperties.size()); 721*cdf0e10cSrcweir for (unsigned int i=0; i<aProperties.size(); i++) 722*cdf0e10cSrcweir aPropertySequence[i] = aProperties[i]; 723*cdf0e10cSrcweir mpPropertyArrayHelper.reset(new OPropertyArrayHelper(aPropertySequence, sal_False)); 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir return *mpPropertyArrayHelper.get(); 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir Reference < beans::XPropertySetInfo > DrawController::getPropertySetInfo() 733*cdf0e10cSrcweir throw ( ::com::sun::star::uno::RuntimeException) 734*cdf0e10cSrcweir { 735*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 736*cdf0e10cSrcweir 737*cdf0e10cSrcweir static Reference < beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 738*cdf0e10cSrcweir return xInfo; 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir uno::Reference< form::runtime::XFormController > SAL_CALL DrawController::getFormController( const uno::Reference< form::XForm >& Form ) throw (uno::RuntimeException) 743*cdf0e10cSrcweir { 744*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell(); 747*cdf0e10cSrcweir SdrView* pSdrView = mpBase->GetDrawView(); 748*cdf0e10cSrcweir ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell(); 749*cdf0e10cSrcweir ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL; 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir uno::Reference< form::runtime::XFormController > xController( NULL ); 752*cdf0e10cSrcweir if ( pFormShell && pSdrView && pWindow ) 753*cdf0e10cSrcweir xController = pFormShell->GetFormController( Form, *pSdrView, *pWindow ); 754*cdf0e10cSrcweir return xController; 755*cdf0e10cSrcweir } 756*cdf0e10cSrcweir 757*cdf0e10cSrcweir ::sal_Bool SAL_CALL DrawController::isFormDesignMode( ) throw (uno::RuntimeException) 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir sal_Bool bIsDesignMode = sal_True; 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell(); 764*cdf0e10cSrcweir if ( pFormShell ) 765*cdf0e10cSrcweir bIsDesignMode = pFormShell->IsDesignMode(); 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir return bIsDesignMode; 768*cdf0e10cSrcweir } 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir void SAL_CALL DrawController::setFormDesignMode( ::sal_Bool _DesignMode ) throw (uno::RuntimeException) 771*cdf0e10cSrcweir { 772*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell(); 775*cdf0e10cSrcweir if ( pFormShell ) 776*cdf0e10cSrcweir pFormShell->SetDesignMode( _DesignMode ); 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir uno::Reference< awt::XControl > SAL_CALL DrawController::getControl( const uno::Reference< awt::XControlModel >& xModel ) throw (container::NoSuchElementException, uno::RuntimeException) 780*cdf0e10cSrcweir { 781*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell(); 784*cdf0e10cSrcweir SdrView* pSdrView = mpBase->GetDrawView(); 785*cdf0e10cSrcweir ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell(); 786*cdf0e10cSrcweir ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL; 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir uno::Reference< awt::XControl > xControl( NULL ); 789*cdf0e10cSrcweir if ( pFormShell && pSdrView && pWindow ) 790*cdf0e10cSrcweir pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xControl ); 791*cdf0e10cSrcweir return xControl; 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir sal_Bool DrawController::convertFastPropertyValue ( 798*cdf0e10cSrcweir Any & rConvertedValue, 799*cdf0e10cSrcweir Any & rOldValue, 800*cdf0e10cSrcweir sal_Int32 nHandle, 801*cdf0e10cSrcweir const Any& rValue) 802*cdf0e10cSrcweir throw ( com::sun::star::lang::IllegalArgumentException) 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir sal_Bool bResult = sal_False; 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir if (nHandle == PROPERTY_SUB_CONTROLLER) 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir rOldValue <<= mxSubController; 809*cdf0e10cSrcweir rConvertedValue <<= Reference<drawing::XDrawSubController>(rValue, UNO_QUERY); 810*cdf0e10cSrcweir bResult = (rOldValue != rConvertedValue); 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir else if (mxSubController.is()) 813*cdf0e10cSrcweir { 814*cdf0e10cSrcweir rConvertedValue = rValue; 815*cdf0e10cSrcweir try 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir rOldValue = mxSubController->getFastPropertyValue(nHandle); 818*cdf0e10cSrcweir bResult = (rOldValue != rConvertedValue); 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir catch(beans::UnknownPropertyException aException) 821*cdf0e10cSrcweir { 822*cdf0e10cSrcweir // The prperty is unknown and thus an illegal argument to this method. 823*cdf0e10cSrcweir throw com::sun::star::lang::IllegalArgumentException(); 824*cdf0e10cSrcweir } 825*cdf0e10cSrcweir } 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir return bResult; 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir void DrawController::setFastPropertyValue_NoBroadcast ( 834*cdf0e10cSrcweir sal_Int32 nHandle, 835*cdf0e10cSrcweir const Any& rValue) 836*cdf0e10cSrcweir throw ( com::sun::star::uno::Exception) 837*cdf0e10cSrcweir { 838*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 839*cdf0e10cSrcweir if (nHandle == PROPERTY_SUB_CONTROLLER) 840*cdf0e10cSrcweir SetSubController(Reference<drawing::XDrawSubController>(rValue, UNO_QUERY)); 841*cdf0e10cSrcweir else if (mxSubController.is()) 842*cdf0e10cSrcweir mxSubController->setFastPropertyValue(nHandle, rValue); 843*cdf0e10cSrcweir } 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir void DrawController::getFastPropertyValue ( 849*cdf0e10cSrcweir Any & rRet, 850*cdf0e10cSrcweir sal_Int32 nHandle ) const 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir switch( nHandle ) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir case PROPERTY_WORKAREA: 857*cdf0e10cSrcweir rRet <<= awt::Rectangle( 858*cdf0e10cSrcweir maLastVisArea.Left(), 859*cdf0e10cSrcweir maLastVisArea.Top(), 860*cdf0e10cSrcweir maLastVisArea.GetWidth(), 861*cdf0e10cSrcweir maLastVisArea.GetHeight()); 862*cdf0e10cSrcweir break; 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir case PROPERTY_SUB_CONTROLLER: 865*cdf0e10cSrcweir rRet <<= mxSubController; 866*cdf0e10cSrcweir break; 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir default: 869*cdf0e10cSrcweir if (mxSubController.is()) 870*cdf0e10cSrcweir rRet = mxSubController->getFastPropertyValue(nHandle); 871*cdf0e10cSrcweir break; 872*cdf0e10cSrcweir } 873*cdf0e10cSrcweir } 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir //----------------------------------------------------------------------------- 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir void DrawController::ProvideFrameworkControllers (void) 881*cdf0e10cSrcweir { 882*cdf0e10cSrcweir ::vos::OGuard aGuard (Application::GetSolarMutex()); 883*cdf0e10cSrcweir try 884*cdf0e10cSrcweir { 885*cdf0e10cSrcweir Reference<XController> xController (this); 886*cdf0e10cSrcweir const Reference<XComponentContext> xContext ( 887*cdf0e10cSrcweir ::comphelper::getProcessComponentContext() ); 888*cdf0e10cSrcweir mxConfigurationController = ConfigurationController::create( 889*cdf0e10cSrcweir xContext, 890*cdf0e10cSrcweir xController); 891*cdf0e10cSrcweir mxModuleController = ModuleController::create( 892*cdf0e10cSrcweir xContext, 893*cdf0e10cSrcweir xController); 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir catch (RuntimeException&) 896*cdf0e10cSrcweir { 897*cdf0e10cSrcweir mxConfigurationController = NULL; 898*cdf0e10cSrcweir mxModuleController = NULL; 899*cdf0e10cSrcweir } 900*cdf0e10cSrcweir } 901*cdf0e10cSrcweir 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir 904*cdf0e10cSrcweir 905*cdf0e10cSrcweir void DrawController::DisposeFrameworkControllers (void) 906*cdf0e10cSrcweir { 907*cdf0e10cSrcweir Reference<XComponent> xComponent (mxModuleController, UNO_QUERY); 908*cdf0e10cSrcweir if (xComponent.is()) 909*cdf0e10cSrcweir xComponent->dispose(); 910*cdf0e10cSrcweir 911*cdf0e10cSrcweir xComponent = Reference<XComponent>(mxConfigurationController, UNO_QUERY); 912*cdf0e10cSrcweir if (xComponent.is()) 913*cdf0e10cSrcweir xComponent->dispose(); 914*cdf0e10cSrcweir } 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir 919*cdf0e10cSrcweir void DrawController::ThrowIfDisposed (void) const 920*cdf0e10cSrcweir throw (::com::sun::star::lang::DisposedException) 921*cdf0e10cSrcweir { 922*cdf0e10cSrcweir if (rBHelper.bDisposed || rBHelper.bInDispose || mbDisposing) 923*cdf0e10cSrcweir { 924*cdf0e10cSrcweir OSL_TRACE ("Calling disposed DrawController object. Throwing exception:"); 925*cdf0e10cSrcweir throw lang::DisposedException ( 926*cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM( 927*cdf0e10cSrcweir "DrawController object has already been disposed")), 928*cdf0e10cSrcweir const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this))); 929*cdf0e10cSrcweir } 930*cdf0e10cSrcweir } 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir 936*cdf0e10cSrcweir } // end of namespace sd 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir 939