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

Generated by: LCOV version 1.10