LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/inc - DrawController.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 2 0.0 %
Date: 2012-12-27 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10