LCOV - code coverage report
Current view: top level - sd/source/ui/inc - DrawController.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 2 100.0 %
Date: 2012-08-25 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10