LCOV - code coverage report
Current view: top level - sd/source/ui/inc - DrawController.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 2 0.0 %
Date: 2014-04-14 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 INCLUDED_SD_SOURCE_UI_INC_DRAWCONTROLLER_HXX
      21             : #define INCLUDED_SD_SOURCE_UI_INC_DRAWCONTROLLER_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 <com/sun/star/drawing/XLayer.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             :         ,PROPERTY_UPDATEACC = 10
      96             :         ,PROPERTY_PAGE_CHANGE = 11
      97             :     };
      98             : 
      99             :     /** Create a new DrawController object for the given ViewShellBase.
     100             :     */
     101             :     DrawController (ViewShellBase& rBase) throw();
     102             : 
     103             :     virtual ~DrawController (void) throw();
     104             : 
     105             :     /** Replace the currently used sub controller with the given one.  This
     106             :         new sub controller is used from now on for the view (that is the
     107             :         main view shell to be precise) specific tasks.  Call this method
     108             :         with a suitable sub controller whenever the view shell in the center
     109             :         pane is exchanged.
     110             :         @param pSubController
     111             :             The ViewShell specific sub controller or NULL when (temporarily
     112             :             while switching to another one) there is no ViewShell displayed
     113             :             in the center pane.
     114             :     */
     115             :     void SetSubController (
     116             :         const css::uno::Reference<css::drawing::XDrawSubController>& rxSubController);
     117             : 
     118             :     /** Call this method when the VisArea has changed.
     119             :     */
     120             :     void FireVisAreaChanged (const Rectangle& rVisArea) throw();
     121             : 
     122             :     /** Call this method when the selection has changed.
     123             :     */
     124             :     void FireSelectionChangeListener (void) throw();
     125             : 
     126             :     /** Call this method when the edit mode has changed.
     127             :     */
     128             :     void FireChangeEditMode (bool bMasterPageMode) throw();
     129             : 
     130             :     /** Call this method when the layer mode has changed.
     131             :     */
     132             :     void FireChangeLayerMode (bool bLayerMode) throw();
     133             : 
     134             :     /** Call this method when there is a new current page.
     135             :     */
     136             :     void FireSwitchCurrentPage (SdPage* pCurrentPage) throw();
     137             : 
     138             :     /** Broadcast a sidebar context change that is caused by a view
     139             :         switch.
     140             :     */
     141             :     void BroadcastContextChange (void) const;
     142             :     void NotifyAccUpdate();
     143             :     void fireChangeLayer( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer>* pCurrentLayer ) throw();
     144             :     // change the parameter to int
     145             :     //void fireSwitchCurrentPage( String pageName) throw();
     146             :     void fireSwitchCurrentPage( sal_Int32 pageIndex) throw();
     147             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer>* mpCurrentLayer;
     148             : 
     149             :     /** Return a pointer to the ViewShellBase object that the DrawController
     150             :         is connected to.
     151             :         @return
     152             :             The returned pointer is <NULL/> after a call to
     153             :             ReleaseViewShellBase().
     154             :     */
     155             :     ViewShellBase* GetViewShellBase (void);
     156             : 
     157             :     /** This method is typically called from the destructor of ViewShellBase
     158             :         to tell the DrawController that it and its members must not access
     159             :         the ViewShellBase anymore.
     160             :         After this call the DrawController is semi-disposed.
     161             :     */
     162             :     void ReleaseViewShellBase (void);
     163             : 
     164             :     static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
     165             : 
     166             :     DECLARE_XINTERFACE()
     167             :     DECLARE_XTYPEPROVIDER()
     168             : 
     169             :     // XComponent
     170             :     virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     171             :     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     172             :     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     173             : 
     174             :     // XController
     175             :     virtual sal_Bool SAL_CALL suspend( sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     176             : 
     177             :     // XServiceInfo
     178             :     virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     179             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     180             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     181             : 
     182             :     // XSelectionSupplier
     183             :     virtual sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& aSelection ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     184             :     virtual ::com::sun::star::uno::Any SAL_CALL getSelection(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     185             :     virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     186             :     virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     187             : 
     188             :     // XPropertySet
     189             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     190             : 
     191             :     // XFormLayerAccess
     192             :     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, std::exception) SAL_OVERRIDE;
     193             :     virtual sal_Bool SAL_CALL isFormDesignMode(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     194             :     virtual void SAL_CALL setFormDesignMode( sal_Bool DesignMode ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     195             : 
     196             :     // XControlAccess
     197             :     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, std::exception) SAL_OVERRIDE;
     198             : 
     199             :     // XDrawView
     200             :     virtual void SAL_CALL
     201             :         setCurrentPage (
     202             :             const ::com::sun::star::uno::Reference<
     203             :             ::com::sun::star::drawing::XDrawPage >& xPage)
     204             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     205             : 
     206             :     virtual ::com::sun::star::uno::Reference<
     207             :         ::com::sun::star::drawing::XDrawPage > SAL_CALL
     208             :         getCurrentPage (void)
     209             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     210             : 
     211             : 
     212             :     // lang::XEventListener
     213             :     virtual void SAL_CALL
     214             :         disposing (const ::com::sun::star::lang::EventObject& rEventObject)
     215             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     216             : 
     217             : 
     218             :     // view::XSelectionChangeListener
     219             :     virtual void  SAL_CALL
     220             :         selectionChanged (const ::com::sun::star::lang::EventObject& rEvent)
     221             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     222             : 
     223             : 
     224             :     // XControllerManager
     225             : 
     226             :     virtual css::uno::Reference<css::drawing::framework::XConfigurationController> SAL_CALL
     227             :         getConfigurationController (void)
     228             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     229             : 
     230             :     virtual css::uno::Reference<css::drawing::framework::XModuleController> SAL_CALL
     231             :         getModuleController (void)
     232             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     233             : 
     234             : 
     235             :     // XUnoTunnel
     236             : 
     237             :     virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId)
     238             :         throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     239             : 
     240             : protected:
     241             :     /** This method must return the name to index table. This table
     242             :         contains all property names and types of this object.
     243             :      */
     244             :     virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
     245             : 
     246             :     virtual void FillPropertyTable (
     247             :         ::std::vector< ::com::sun::star::beans::Property>& rProperties);
     248             : 
     249             :     /**
     250             :      * The same as getFastProperyValue, but return the value through
     251             :      * rValue and nHandle is always valid.
     252             :      */
     253             :     virtual void SAL_CALL getFastPropertyValue(
     254             :         ::com::sun::star::uno::Any& rValue,
     255             :         sal_Int32 nHandle ) const SAL_OVERRIDE;
     256             : 
     257             :     /** Convert the value rValue and return the result in rConvertedValue and the
     258             :         old value in rOldValue.
     259             :         After this call the vetoable listeners are notified.
     260             : 
     261             :         @param rConvertedValue
     262             :             The converted value. Only set if return is true.
     263             :         @param rOldValue
     264             :             The old value. Only set if return is true.
     265             :         @param nHandle
     266             :             The handle of the proberty.
     267             :         @return
     268             :             <TRUE/> if the value is converted successfully.
     269             :         @throws IllegalArgumentException
     270             :      */
     271             :     virtual sal_Bool SAL_CALL convertFastPropertyValue(
     272             :         ::com::sun::star::uno::Any & rConvertedValue,
     273             :         ::com::sun::star::uno::Any & rOldValue,
     274             :         sal_Int32 nHandle,
     275             :         const ::com::sun::star::uno::Any& rValue )
     276             :         throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
     277             : 
     278             :     /** The same as setFastProperyValue, but no exception is thrown and nHandle
     279             :         is always valid. You must not broadcast the changes in this method.
     280             :      */
     281             :     virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
     282             :         sal_Int32 nHandle,
     283             :         const ::com::sun::star::uno::Any& rValue )
     284             :         throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
     285             : 
     286             :     /** When the called object has been disposed already this method throws
     287             :         a Disposed exception and does not return.
     288             :     */
     289             :     void ThrowIfDisposed (void) const
     290             :         throw (::com::sun::star::lang::DisposedException);
     291             : 
     292             :     using cppu::OPropertySetHelper::disposing;
     293             :     using cppu::OPropertySetHelper::getFastPropertyValue;
     294             : 
     295             : private:
     296             :     const ::com::sun::star::uno::Type m_aSelectionTypeIdentifier;
     297             : 
     298             :     /** This pointer to the ViewShellBase can be NULL (after a call to
     299             :         ReleaseViewShellBase()).
     300             :     */
     301             :     ViewShellBase* mpBase;
     302             : 
     303             :     Rectangle maLastVisArea;
     304             :     ::tools::WeakReference<SdrPage> mpCurrentPage;
     305             :     bool mbMasterPageMode;
     306             :     bool mbLayerMode;
     307             : 
     308             :     /** This flag indicates whether the called DrawController is being
     309             :         disposed or already has been disposed.
     310             :     */
     311             :     bool mbDisposing;
     312             : 
     313             :     ::std::auto_ptr< ::cppu::IPropertyArrayHelper> mpPropertyArrayHelper;
     314             : 
     315             :     /** The current sub controller.  May be NULL.
     316             :     */
     317             :     css::uno::Reference<css::drawing::XDrawSubController> mxSubController;
     318             : 
     319             :     css::uno::Reference<
     320             :         css::drawing::framework::XConfigurationController> mxConfigurationController;
     321             :     css::uno::Reference<
     322             :         css::drawing::framework::XModuleController> mxModuleController;
     323             : 
     324             :     /** Send an event to all relevant property listeners that a
     325             :         property has changed its value.  The fire() method of the
     326             :         OPropertySetHelper is wrapped by this method to handle
     327             :         exceptions thrown by called listeners.
     328             :     */
     329             :     void FirePropertyChange (
     330             :         sal_Int32 nHandle,
     331             :         const ::com::sun::star::uno::Any& rNewValue,
     332             :         const ::com::sun::star::uno::Any& rOldValue);
     333             : 
     334             :     void ProvideFrameworkControllers (void);
     335             :     void DisposeFrameworkControllers (void);
     336             : };
     337             : 
     338             : } // end of namespace sd
     339             : 
     340             : #endif
     341             : 
     342             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10