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