LCOV - code coverage report
Current view: top level - svx/source/inc - fmundo.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 8 87.5 %
Date: 2012-08-25 Functions: 8 9 88.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2 50.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 _SVX_FMUNDO_HXX
      30                 :            : #define _SVX_FMUNDO_HXX
      31                 :            : 
      32                 :            : #include <svx/svdundo.hxx>
      33                 :            : #include <svx/svdouno.hxx>
      34                 :            : #include "fmscriptingenv.hxx"
      35                 :            : 
      36                 :            : 
      37                 :            : #include <com/sun/star/util/XModifyListener.hpp>
      38                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      39                 :            : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
      40                 :            : #include <com/sun/star/beans/PropertyChangeEvent.hpp>
      41                 :            : #include <com/sun/star/script/ScriptEvent.hpp>
      42                 :            : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      43                 :            : #include <com/sun/star/container/XIndexContainer.hpp>
      44                 :            : #include <com/sun/star/container/XContainerListener.hpp>
      45                 :            : #include <com/sun/star/container/ContainerEvent.hpp>
      46                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      47                 :            : #include <cppuhelper/implbase3.hxx>
      48                 :            : 
      49                 :            : 
      50                 :            : #include <svl/lstner.hxx>
      51                 :            : #include <comphelper/uno3.hxx>
      52                 :            : 
      53                 :            : class FmFormModel;
      54                 :            : class FmFormObj;
      55                 :            : class SdrObject;
      56                 :            : 
      57                 :            : //==================================================================
      58                 :            : // FmUndoPropertyAction
      59                 :            : //==================================================================
      60         [ -  + ]:      22180 : class FmUndoPropertyAction: public SdrUndoAction
      61                 :            : {
      62                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xObj;
      63                 :            :     ::rtl::OUString         aPropertyName;
      64                 :            :     ::com::sun::star::uno::Any          aNewValue;
      65                 :            :     ::com::sun::star::uno::Any          aOldValue;
      66                 :            : 
      67                 :            : public:
      68                 :            :     FmUndoPropertyAction(FmFormModel& rMod, const ::com::sun::star::beans::PropertyChangeEvent& evt);
      69                 :            : 
      70                 :            :     virtual void Undo();
      71                 :            :     virtual void Redo();
      72                 :            : 
      73                 :            :     virtual rtl::OUString GetComment() const;
      74                 :            : 
      75                 :            : };
      76                 :            : 
      77                 :            : //==================================================================
      78                 :            : // FmUndoContainerAction
      79                 :            : //==================================================================
      80                 :            : class FmUndoContainerAction: public SdrUndoAction
      81                 :            : {
      82                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
      83                 :            :                     m_xContainer;   // container which the action applies to
      84                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
      85                 :            :                     m_xElement;     // object not owned by the action
      86                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
      87                 :            :                     m_xOwnElement;  // object owned by the action
      88                 :            :     sal_Int32       m_nIndex;       // index of the object within it's container
      89                 :            :     ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >
      90                 :            :                     m_aEvents;      // events of the object
      91                 :            : 
      92                 :            : public:
      93                 :            :     enum Action
      94                 :            :     {
      95                 :            :         Inserted = 1,
      96                 :            :         Removed  = 2
      97                 :            :     };
      98                 :            : 
      99                 :            : private:
     100                 :            :     Action              m_eAction;
     101                 :            : 
     102                 :            : public:
     103                 :            :     FmUndoContainerAction(FmFormModel& rMod,
     104                 :            :                           Action _eAction,
     105                 :            :                           const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& xCont,
     106                 :            :                           const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xElem,
     107                 :            :                           sal_Int32 nIdx = -1);
     108                 :            :     ~FmUndoContainerAction();
     109                 :            : 
     110                 :            :     virtual void Undo();
     111                 :            :     virtual void Redo();
     112                 :            : 
     113                 :            :     static void DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xElem );
     114                 :            : 
     115                 :            : protected:
     116                 :            :     void    implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
     117                 :            :     void    implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
     118                 :            : };
     119                 :            : 
     120                 :            : //==================================================================
     121                 :            : // FmUndoModelReplaceAction
     122                 :            : //==================================================================
     123                 :            : class FmUndoModelReplaceAction : public SdrUndoAction
     124                 :            : {
     125                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> m_xReplaced;
     126                 :            :     SdrUnoObj*          m_pObject;
     127                 :            : 
     128                 :            : public:
     129                 :            :     FmUndoModelReplaceAction(FmFormModel& rMod, SdrUnoObj* pObject, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced);
     130                 :            :     ~FmUndoModelReplaceAction();
     131                 :            : 
     132                 :            :     virtual void Undo();
     133                 :          0 :     virtual void Redo() { Undo(); }
     134                 :            : 
     135                 :            :     virtual rtl::OUString GetComment() const;
     136                 :            : 
     137                 :            :     static void DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced );
     138                 :            : };
     139                 :            : 
     140                 :            : //========================================================================
     141                 :            : class SVX_DLLPRIVATE FmXUndoEnvironment
     142                 :            :     : public ::cppu::WeakImplHelper3<   ::com::sun::star::beans::XPropertyChangeListener
     143                 :            :                                     ,   ::com::sun::star::container::XContainerListener
     144                 :            :                                     ,   ::com::sun::star::util::XModifyListener
     145                 :            :                                     >
     146                 :            :     , public SfxListener
     147                 :            :                            //   public ::cppu::OWeakObject
     148                 :            : {
     149                 :            :     FmFormModel& rModel;
     150                 :            : 
     151                 :            :     void*                                   m_pPropertySetCache;
     152                 :            :     ::svxform::PFormScriptingEnvironment    m_pScriptingEnv;
     153                 :            :     oslInterlockedCount                     m_Locks;
     154                 :            :     ::osl::Mutex                            m_aMutex;
     155                 :            :     sal_Bool                                bReadOnly;
     156                 :            :     bool                                    m_bDisposed;
     157                 :            : 
     158                 :            : public:
     159                 :            :     FmXUndoEnvironment(FmFormModel& _rModel);
     160                 :            :     ~FmXUndoEnvironment();
     161                 :            : 
     162                 :            :     // UNO Anbindung
     163                 :            :     //  SMART_UNO_DECLARATION(FmXUndoEnvironment, ::cppu::OWeakObject);
     164                 :            :     //  virtual sal_Bool queryInterface(UsrUik, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>&);
     165                 :            :     //  virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass>>    getIdlClasses(void);
     166                 :            : 
     167                 :        701 :     void Lock() { osl_incrementInterlockedCount( &m_Locks ); }
     168                 :        701 :     void UnLock() { osl_decrementInterlockedCount( &m_Locks ); }
     169                 :      14992 :     sal_Bool IsLocked() const { return m_Locks != 0; }
     170                 :            : 
     171                 :            :     // access control
     172                 :       2024 :     struct Accessor { friend class FmFormModel; private: Accessor() { } };
     173                 :            : 
     174                 :            :     // addition and removal of form collections
     175                 :            :     void AddForms( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& rForms );
     176                 :            :     void RemoveForms( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& rForms );
     177                 :            : 
     178                 :            :     // readonly-ness
     179                 :       2024 :     void SetReadOnly( sal_Bool bRead, const Accessor& ) { bReadOnly = bRead; }
     180                 :       2024 :     sal_Bool IsReadOnly() const {return bReadOnly;}
     181                 :            : 
     182                 :            : protected:
     183                 :            :     // XEventListener
     184                 :            :     virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
     185                 :            : 
     186                 :            :     // XPropertyChangeListener
     187                 :            :     virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
     188                 :            : 
     189                 :            :     // XContainerListener
     190                 :            :     virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
     191                 :            :     virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
     192                 :            :     virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
     193                 :            : 
     194                 :            :     // XModifyListener
     195                 :            :     virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
     196                 :            : 
     197                 :            :     void ModeChanged();
     198                 :            :     void dispose();
     199                 :            : 
     200                 :            :     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     201                 :            : 
     202                 :            : private:
     203                 :            :     void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
     204                 :            :     void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
     205                 :            :     void TogglePropertyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
     206                 :            : 
     207                 :            :     void    implSetModified();
     208                 :            : 
     209                 :            :     void    switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& _rxContainer, bool _bStartListening ) SAL_THROW(());
     210                 :            :     void    switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(());
     211                 :            :     ::com::sun::star::uno::Reference< com::sun::star::script::XScriptListener > m_vbaListener;
     212                 :            : public:
     213                 :            :     // Methoden zur Zuordnung von Controls zu Forms,
     214                 :            :     // werden von der Seite und der UndoUmgebung genutzt
     215                 :            :     void Inserted(SdrObject* pObj);
     216                 :            :     void Removed(SdrObject* pObj);
     217                 :            : 
     218                 :            :     void Inserted(FmFormObj* pObj);
     219                 :            :     void Removed(FmFormObj* pObj);
     220                 :            : };
     221                 :            : 
     222                 :            : 
     223                 :            : #endif  //_SVX_FMUNDO_HXX
     224                 :            : 
     225                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10