1c45d927aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5c45d927aSAndrew Rist * distributed with this work for additional information 6c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8c45d927aSAndrew Rist * "License"); you may not use this file except in compliance 9c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14c45d927aSAndrew Rist * software distributed under the License is distributed on an 15c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16c45d927aSAndrew Rist * KIND, either express or implied. See the License for the 17c45d927aSAndrew Rist * specific language governing permissions and limitations 18c45d927aSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20c45d927aSAndrew Rist *************************************************************/ 21c45d927aSAndrew Rist 22c45d927aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SD_DRAW_CONTROLLER_HXX 25cdf0e10cSrcweir #define SD_DRAW_CONTROLLER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "ViewShell.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <osl/mutex.hxx> 30cdf0e10cSrcweir #include <cppuhelper/propshlp.hxx> 31cdf0e10cSrcweir #include <sfx2/sfxbasecontroller.hxx> 32cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp> 33cdf0e10cSrcweir #include <com/sun/star/view/XFormLayerAccess.hpp> 34cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawSubController.hpp> 35cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp> 36cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp> 37cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp> 38cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ModuleController.hpp> 39cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 40cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 41cdf0e10cSrcweir #include <comphelper/uno3.hxx> 42cdf0e10cSrcweir #include <cppuhelper/implbase7.hxx> 43cdf0e10cSrcweir #include <tools/weakbase.hxx> 44cdf0e10cSrcweir #include <memory> 45cdf0e10cSrcweir #include <vector> 46cdf0e10cSrcweir #include <boost/scoped_ptr.hpp> 47cdf0e10cSrcweir 48cdf0e10cSrcweir class SfxViewShell; 49cdf0e10cSrcweir class SdXImpressDocument; 50cdf0e10cSrcweir 51cdf0e10cSrcweir namespace css = ::com::sun::star; 52cdf0e10cSrcweir 53cdf0e10cSrcweir namespace sd { 54cdf0e10cSrcweir 55cdf0e10cSrcweir typedef ::cppu::ImplInheritanceHelper7 < 56cdf0e10cSrcweir SfxBaseController, 57cdf0e10cSrcweir ::com::sun::star::view::XSelectionSupplier, 58cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo, 59cdf0e10cSrcweir ::com::sun::star::drawing::XDrawView, 60cdf0e10cSrcweir ::com::sun::star::view::XSelectionChangeListener, 61cdf0e10cSrcweir ::com::sun::star::view::XFormLayerAccess, 62cdf0e10cSrcweir ::com::sun::star::drawing::framework::XControllerManager, 63cdf0e10cSrcweir ::com::sun::star::lang::XUnoTunnel 64cdf0e10cSrcweir > DrawControllerInterfaceBase; 65cdf0e10cSrcweir 66cdf0e10cSrcweir class BroadcastHelperOwner 67cdf0e10cSrcweir { 68cdf0e10cSrcweir public: 69cdf0e10cSrcweir BroadcastHelperOwner (::osl::Mutex& rMutex) : maBroadcastHelper(rMutex) {}; 70cdf0e10cSrcweir ::cppu::OBroadcastHelper maBroadcastHelper; 71cdf0e10cSrcweir }; 72cdf0e10cSrcweir 73cdf0e10cSrcweir class DrawSubController; 74cdf0e10cSrcweir class ViewShellBase; 75cdf0e10cSrcweir class ViewShell; 76cdf0e10cSrcweir class View; 77cdf0e10cSrcweir 78cdf0e10cSrcweir 79cdf0e10cSrcweir /** The DrawController is the UNO controller for Impress and Draw. It 80cdf0e10cSrcweir relies objects that implement the DrawSubController interface for view 81cdf0e10cSrcweir specific behaviour. The life time of the DrawController is roughly that 82cdf0e10cSrcweir of ViewShellBase but note that the DrawController can (in the case of a 83cdf0e10cSrcweir reload) outlive the ViewShellBase. 84cdf0e10cSrcweir 85cdf0e10cSrcweir The implementation of the XControllerManager interface is not yet in its 86cdf0e10cSrcweir final form. 87cdf0e10cSrcweir */ 88cdf0e10cSrcweir class DrawController 89cdf0e10cSrcweir : public DrawControllerInterfaceBase, 90cdf0e10cSrcweir private BroadcastHelperOwner, 91cdf0e10cSrcweir public ::cppu::OPropertySetHelper 92cdf0e10cSrcweir { 93cdf0e10cSrcweir public: 94cdf0e10cSrcweir enum PropertyHandle { 95cdf0e10cSrcweir PROPERTY_WORKAREA = 0, 96cdf0e10cSrcweir PROPERTY_SUB_CONTROLLER = 1, 97cdf0e10cSrcweir PROPERTY_CURRENTPAGE = 2, 98cdf0e10cSrcweir PROPERTY_MASTERPAGEMODE = 3, 99cdf0e10cSrcweir PROPERTY_LAYERMODE = 4, 100cdf0e10cSrcweir PROPERTY_ACTIVE_LAYER = 5, 101cdf0e10cSrcweir PROPERTY_ZOOMTYPE = 6, 102cdf0e10cSrcweir PROPERTY_ZOOMVALUE = 7, 103cdf0e10cSrcweir PROPERTY_VIEWOFFSET = 8, 104cdf0e10cSrcweir PROPERTY_DRAWVIEWMODE = 9 105cdf0e10cSrcweir }; 106cdf0e10cSrcweir 107cdf0e10cSrcweir /** Create a new DrawController object for the given ViewShellBase. 108cdf0e10cSrcweir */ 109cdf0e10cSrcweir DrawController (ViewShellBase& rBase) throw(); 110cdf0e10cSrcweir 111cdf0e10cSrcweir virtual ~DrawController (void) throw(); 112cdf0e10cSrcweir 113cdf0e10cSrcweir /** Replace the currently used sub controller with the given one. This 114cdf0e10cSrcweir new sub controller is used from now on for the view (that is the 115cdf0e10cSrcweir main view shell to be precise) specific tasks. Call this method 116cdf0e10cSrcweir with a suitable sub controller whenever the view shell in the center 117cdf0e10cSrcweir pane is exchanged. 118cdf0e10cSrcweir @param pSubController 119cdf0e10cSrcweir The ViewShell specific sub controller or NULL when (temporarily 120cdf0e10cSrcweir while switching to another one) there is no ViewShell displayed 121cdf0e10cSrcweir in the center pane. 122cdf0e10cSrcweir */ 123cdf0e10cSrcweir void SetSubController ( 124cdf0e10cSrcweir const css::uno::Reference<css::drawing::XDrawSubController>& rxSubController); 125cdf0e10cSrcweir 126cdf0e10cSrcweir /** Call this method when the VisArea has changed. 127cdf0e10cSrcweir */ 128cdf0e10cSrcweir void FireVisAreaChanged (const Rectangle& rVisArea) throw(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir /** Call this method when the selection has changed. 131cdf0e10cSrcweir */ 132cdf0e10cSrcweir void FireSelectionChangeListener (void) throw(); 133cdf0e10cSrcweir 134cdf0e10cSrcweir /** Call this method when the edit mode has changed. 135cdf0e10cSrcweir */ 136cdf0e10cSrcweir void FireChangeEditMode (bool bMasterPageMode) throw(); 137cdf0e10cSrcweir 138cdf0e10cSrcweir /** Call this method when the layer mode has changed. 139cdf0e10cSrcweir */ 140cdf0e10cSrcweir void FireChangeLayerMode (bool bLayerMode) throw(); 141cdf0e10cSrcweir 142cdf0e10cSrcweir /** Call this method when there is a new current page. 143cdf0e10cSrcweir */ 144cdf0e10cSrcweir void FireSwitchCurrentPage (SdPage* pCurrentPage) throw(); 145cdf0e10cSrcweir 146*65be1ea2SAndre Fischer /** Broadcast a sidebar context change that is caused by a view 147*65be1ea2SAndre Fischer switch. 148*65be1ea2SAndre Fischer */ 149*65be1ea2SAndre Fischer void BroadcastContextChange (void) const; 150*65be1ea2SAndre Fischer 151cdf0e10cSrcweir /** Return a pointer to the ViewShellBase object that the DrawController 152cdf0e10cSrcweir is connected to. 153cdf0e10cSrcweir @return 154cdf0e10cSrcweir The returned pointer is <NULL/> after a call to 155cdf0e10cSrcweir ReleaseViewShellBase(). 156cdf0e10cSrcweir */ 157cdf0e10cSrcweir ViewShellBase* GetViewShellBase (void); 158cdf0e10cSrcweir 159cdf0e10cSrcweir /** This method is typically called from the destructor of ViewShellBase 160cdf0e10cSrcweir to tell the DrawController that it and its members must not access 161cdf0e10cSrcweir the ViewShellBase anymore. 162cdf0e10cSrcweir After this call the DrawController is semi-disposed. 163cdf0e10cSrcweir */ 164cdf0e10cSrcweir void ReleaseViewShellBase (void); 165cdf0e10cSrcweir 166cdf0e10cSrcweir static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void); 167cdf0e10cSrcweir 168cdf0e10cSrcweir DECLARE_XINTERFACE() 169cdf0e10cSrcweir DECLARE_XTYPEPROVIDER() 170cdf0e10cSrcweir 171cdf0e10cSrcweir // XComponent 172cdf0e10cSrcweir virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException ); 173cdf0e10cSrcweir virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 174cdf0e10cSrcweir virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 175cdf0e10cSrcweir 176cdf0e10cSrcweir // XController 177cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL suspend( ::sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException); 178cdf0e10cSrcweir 179cdf0e10cSrcweir // XServiceInfo 180cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); 181cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); 182cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); 183cdf0e10cSrcweir 184cdf0e10cSrcweir // XSelectionSupplier 185cdf0e10cSrcweir virtual sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& aSelection ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 186cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getSelection( ) throw(::com::sun::star::uno::RuntimeException); 187cdf0e10cSrcweir virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 188cdf0e10cSrcweir virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 189cdf0e10cSrcweir 190cdf0e10cSrcweir // XPropertySet 191cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 192cdf0e10cSrcweir 193cdf0e10cSrcweir // XFormLayerAccess 194cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > SAL_CALL getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& Form ) throw (::com::sun::star::uno::RuntimeException); 195cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL isFormDesignMode( ) throw (::com::sun::star::uno::RuntimeException); 196cdf0e10cSrcweir virtual void SAL_CALL setFormDesignMode( ::sal_Bool DesignMode ) throw (::com::sun::star::uno::RuntimeException); 197cdf0e10cSrcweir 198cdf0e10cSrcweir // XControlAccess 199cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& xModel ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); 200cdf0e10cSrcweir 201cdf0e10cSrcweir // XDrawView 202cdf0e10cSrcweir virtual void SAL_CALL 203cdf0e10cSrcweir setCurrentPage ( 204cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 205cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPage >& xPage) 206cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 207cdf0e10cSrcweir 208cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 209cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPage > SAL_CALL 210cdf0e10cSrcweir getCurrentPage (void) 211cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 212cdf0e10cSrcweir 213cdf0e10cSrcweir 214cdf0e10cSrcweir // lang::XEventListener 215cdf0e10cSrcweir virtual void SAL_CALL 216cdf0e10cSrcweir disposing (const ::com::sun::star::lang::EventObject& rEventObject) 217cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 218cdf0e10cSrcweir 219cdf0e10cSrcweir 220cdf0e10cSrcweir // view::XSelectionChangeListener 221cdf0e10cSrcweir virtual void SAL_CALL 222cdf0e10cSrcweir selectionChanged (const ::com::sun::star::lang::EventObject& rEvent) 223cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 224cdf0e10cSrcweir 225cdf0e10cSrcweir 226cdf0e10cSrcweir // XControllerManager 227cdf0e10cSrcweir 228cdf0e10cSrcweir virtual css::uno::Reference<css::drawing::framework::XConfigurationController> SAL_CALL 229cdf0e10cSrcweir getConfigurationController (void) 230cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 231cdf0e10cSrcweir 232cdf0e10cSrcweir virtual css::uno::Reference<css::drawing::framework::XModuleController> SAL_CALL 233cdf0e10cSrcweir getModuleController (void) 234cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 235cdf0e10cSrcweir 236cdf0e10cSrcweir 237cdf0e10cSrcweir // XUnoTunnel 238cdf0e10cSrcweir 239cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId) 240cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException); 241cdf0e10cSrcweir 242cdf0e10cSrcweir protected: 243cdf0e10cSrcweir /** This method must return the name to index table. This table 244cdf0e10cSrcweir contains all property names and types of this object. 245cdf0e10cSrcweir */ 246cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 247cdf0e10cSrcweir 248cdf0e10cSrcweir virtual void FillPropertyTable ( 249cdf0e10cSrcweir ::std::vector< ::com::sun::star::beans::Property>& rProperties); 250cdf0e10cSrcweir 251cdf0e10cSrcweir /** 252cdf0e10cSrcweir * The same as getFastProperyValue, but return the value through 253cdf0e10cSrcweir * rValue and nHandle is always valid. 254cdf0e10cSrcweir */ 255cdf0e10cSrcweir virtual void SAL_CALL getFastPropertyValue( 256cdf0e10cSrcweir ::com::sun::star::uno::Any& rValue, 257cdf0e10cSrcweir sal_Int32 nHandle ) const; 258cdf0e10cSrcweir 259cdf0e10cSrcweir /** Convert the value rValue and return the result in rConvertedValue and the 260cdf0e10cSrcweir old value in rOldValue. 261cdf0e10cSrcweir After this call the vetoable listeners are notified. 262cdf0e10cSrcweir 263cdf0e10cSrcweir @param rConvertedValue 264cdf0e10cSrcweir The converted value. Only set if return is true. 265cdf0e10cSrcweir @param rOldValue 266cdf0e10cSrcweir The old value. Only set if return is true. 267cdf0e10cSrcweir @param nHandle 268cdf0e10cSrcweir The handle of the proberty. 269cdf0e10cSrcweir @return 270cdf0e10cSrcweir <TRUE/> if the value is converted successfully. 271cdf0e10cSrcweir @throws IllegalArgumentException 272cdf0e10cSrcweir */ 273cdf0e10cSrcweir virtual sal_Bool SAL_CALL convertFastPropertyValue( 274cdf0e10cSrcweir ::com::sun::star::uno::Any & rConvertedValue, 275cdf0e10cSrcweir ::com::sun::star::uno::Any & rOldValue, 276cdf0e10cSrcweir sal_Int32 nHandle, 277cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue ) 278cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException); 279cdf0e10cSrcweir 280cdf0e10cSrcweir /** The same as setFastProperyValue, but no exception is thrown and nHandle 281cdf0e10cSrcweir is always valid. You must not broadcast the changes in this method. 282cdf0e10cSrcweir */ 283cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 284cdf0e10cSrcweir sal_Int32 nHandle, 285cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue ) 286cdf0e10cSrcweir throw (::com::sun::star::uno::Exception); 287cdf0e10cSrcweir 288cdf0e10cSrcweir /** When the called object has been disposed already this method throws 289cdf0e10cSrcweir a Disposed exception and does not return. 290cdf0e10cSrcweir */ 291cdf0e10cSrcweir void ThrowIfDisposed (void) const 292cdf0e10cSrcweir throw (::com::sun::star::lang::DisposedException); 293cdf0e10cSrcweir 294cdf0e10cSrcweir using cppu::OPropertySetHelper::disposing; 295cdf0e10cSrcweir using cppu::OPropertySetHelper::getFastPropertyValue; 296cdf0e10cSrcweir 297cdf0e10cSrcweir private: 298cdf0e10cSrcweir /** This pointer to the ViewShellBase can be NULL (after a call to 299cdf0e10cSrcweir ReleaseViewShellBase()). 300cdf0e10cSrcweir */ 301cdf0e10cSrcweir ViewShellBase* mpBase; 302cdf0e10cSrcweir 303cdf0e10cSrcweir Rectangle maLastVisArea; 304cdf0e10cSrcweir ::tools::WeakReference<SdrPage> mpCurrentPage; 305cdf0e10cSrcweir bool mbMasterPageMode; 306cdf0e10cSrcweir bool mbLayerMode; 307cdf0e10cSrcweir 308cdf0e10cSrcweir /** This flag indicates whether the called DrawController is being 309cdf0e10cSrcweir disposed or already has been disposed. 310cdf0e10cSrcweir */ 311cdf0e10cSrcweir bool mbDisposing; 312cdf0e10cSrcweir 313cdf0e10cSrcweir ::std::auto_ptr< ::cppu::IPropertyArrayHelper> mpPropertyArrayHelper; 314cdf0e10cSrcweir 315cdf0e10cSrcweir /** The current sub controller. May be NULL. 316cdf0e10cSrcweir */ 317cdf0e10cSrcweir css::uno::Reference<css::drawing::XDrawSubController> mxSubController; 318cdf0e10cSrcweir 319cdf0e10cSrcweir css::uno::Reference< 320cdf0e10cSrcweir css::drawing::framework::XConfigurationController> mxConfigurationController; 321cdf0e10cSrcweir css::uno::Reference< 322cdf0e10cSrcweir css::drawing::framework::XModuleController> mxModuleController; 323cdf0e10cSrcweir 324cdf0e10cSrcweir /** Send an event to all relevant property listeners that a 325cdf0e10cSrcweir property has changed its value. The fire() method of the 326cdf0e10cSrcweir OPropertySetHelper is wrapped by this method to handle 327cdf0e10cSrcweir exceptions thrown by called listeners. 328cdf0e10cSrcweir */ 329cdf0e10cSrcweir void FirePropertyChange ( 330cdf0e10cSrcweir sal_Int32 nHandle, 331cdf0e10cSrcweir const ::com::sun::star::uno::Any& rNewValue, 332cdf0e10cSrcweir const ::com::sun::star::uno::Any& rOldValue); 333cdf0e10cSrcweir 334cdf0e10cSrcweir void ProvideFrameworkControllers (void); 335cdf0e10cSrcweir void DisposeFrameworkControllers (void); 336cdf0e10cSrcweir }; 337cdf0e10cSrcweir 338cdf0e10cSrcweir } // end of namespace sd 339cdf0e10cSrcweir 340cdf0e10cSrcweir #endif 341