Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / svx / source / inc / fmundo.hxx
blobc6ef1e3a46e78b1652caeeb3aab28206995db7e3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #ifndef _SVX_FMUNDO_HXX
30 #define _SVX_FMUNDO_HXX
32 #include <svx/svdundo.hxx>
33 #include <svx/svdouno.hxx>
34 #include "fmscriptingenv.hxx"
37 /** === begin UNO includes === **/
38 #include <com/sun/star/util/XModifyListener.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
41 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
42 #include <com/sun/star/script/ScriptEvent.hpp>
43 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
44 #include <com/sun/star/container/XIndexContainer.hpp>
45 #include <com/sun/star/container/XContainerListener.hpp>
46 #include <com/sun/star/container/ContainerEvent.hpp>
47 #include <com/sun/star/container/XNameContainer.hpp>
48 /** === end UNO includes === **/
49 #include <cppuhelper/implbase3.hxx>
52 #include <svl/lstner.hxx>
53 #include <comphelper/uno3.hxx>
55 class FmFormModel;
56 class FmFormObj;
57 class SdrObject;
58 class FmXFormView;
60 namespace com { namespace sun { namespace star {
61 namespace awt {
62 class XControl;
63 class XControlContainer;
65 }}}
67 //==================================================================
68 // FmUndoPropertyAction
69 //==================================================================
70 class FmUndoPropertyAction: public SdrUndoAction
72 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xObj;
73 ::rtl::OUString aPropertyName;
74 ::com::sun::star::uno::Any aNewValue;
75 ::com::sun::star::uno::Any aOldValue;
77 public:
78 FmUndoPropertyAction(FmFormModel& rMod, const ::com::sun::star::beans::PropertyChangeEvent& evt);
80 virtual void Undo();
81 virtual void Redo();
83 virtual rtl::OUString GetComment() const;
87 //==================================================================
88 // FmUndoContainerAction
89 //==================================================================
90 class FmUndoContainerAction: public SdrUndoAction
92 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
93 m_xContainer; // container which the action applies to
94 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
95 m_xElement; // object not owned by the action
96 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
97 m_xOwnElement; // object owned by the action
98 sal_Int32 m_nIndex; // index of the object within it's container
99 ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >
100 m_aEvents; // events of the object
102 public:
103 enum Action
105 Inserted = 1,
106 Removed = 2
109 private:
110 Action m_eAction;
112 public:
113 FmUndoContainerAction(FmFormModel& rMod,
114 Action _eAction,
115 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& xCont,
116 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xElem,
117 sal_Int32 nIdx = -1);
118 ~FmUndoContainerAction();
120 virtual void Undo();
121 virtual void Redo();
123 static void DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xElem );
125 protected:
126 void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
127 void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
130 //==================================================================
131 // FmUndoModelReplaceAction
132 //==================================================================
133 class FmUndoModelReplaceAction : public SdrUndoAction
135 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> m_xReplaced;
136 SdrUnoObj* m_pObject;
138 public:
139 FmUndoModelReplaceAction(FmFormModel& rMod, SdrUnoObj* pObject, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced);
140 ~FmUndoModelReplaceAction();
142 virtual void Undo();
143 virtual void Redo() { Undo(); }
145 virtual rtl::OUString GetComment() const;
147 static void DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced );
150 //========================================================================
151 class SVX_DLLPRIVATE FmXUndoEnvironment
152 : public ::cppu::WeakImplHelper3< ::com::sun::star::beans::XPropertyChangeListener
153 , ::com::sun::star::container::XContainerListener
154 , ::com::sun::star::util::XModifyListener
156 , public SfxListener
157 // public ::cppu::OWeakObject
159 FmFormModel& rModel;
161 void* m_pPropertySetCache;
162 ::svxform::PFormScriptingEnvironment m_pScriptingEnv;
163 oslInterlockedCount m_Locks;
164 ::osl::Mutex m_aMutex;
165 sal_Bool bReadOnly;
166 bool m_bDisposed;
168 public:
169 FmXUndoEnvironment(FmFormModel& _rModel);
170 ~FmXUndoEnvironment();
172 // UNO Anbindung
173 // SMART_UNO_DECLARATION(FmXUndoEnvironment, ::cppu::OWeakObject);
174 // virtual sal_Bool queryInterface(UsrUik, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>&);
175 // virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass>> getIdlClasses(void);
177 void Lock() { osl_incrementInterlockedCount( &m_Locks ); }
178 void UnLock() { osl_decrementInterlockedCount( &m_Locks ); }
179 sal_Bool IsLocked() const { return m_Locks != 0; }
181 // access control
182 struct Accessor { friend class FmFormModel; private: Accessor() { } };
184 // addition and removal of form collections
185 void AddForms( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& rForms );
186 void RemoveForms( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& rForms );
188 // readonly-ness
189 void SetReadOnly( sal_Bool bRead, const Accessor& ) { bReadOnly = bRead; }
190 sal_Bool IsReadOnly() const {return bReadOnly;}
192 protected:
193 // XEventListener
194 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
196 // XPropertyChangeListener
197 virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
199 // XContainerListener
200 virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
201 virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
202 virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
204 // XModifyListener
205 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
207 void ModeChanged();
208 void dispose();
210 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
212 private:
213 void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
214 void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
215 void TogglePropertyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
217 void implSetModified();
219 void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& _rxContainer, bool _bStartListening ) SAL_THROW(());
220 void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(());
221 ::com::sun::star::uno::Reference< com::sun::star::script::XScriptListener > m_vbaListener;
222 public:
223 // Methoden zur Zuordnung von Controls zu Forms,
224 // werden von der Seite und der UndoUmgebung genutzt
225 void Inserted(SdrObject* pObj);
226 void Removed(SdrObject* pObj);
228 void Inserted(FmFormObj* pObj);
229 void Removed(FmFormObj* pObj);
233 #endif //_SVX_FMUNDO_HXX
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */