update dev300-m58
[ooovba.git] / svx / source / inc / fmundo.hxx
blob67d88b834d5d3ed3907f41cac1774acf20e639ce
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmundo.hxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVX_FMUNDO_HXX
32 #define _SVX_FMUNDO_HXX
34 #include <svx/svdundo.hxx>
35 #include <svx/svdouno.hxx>
36 #include "fmscriptingenv.hxx"
39 /** === begin UNO includes === **/
40 #include <com/sun/star/util/XModifyListener.hpp>
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
43 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
44 #include <com/sun/star/script/ScriptEvent.hpp>
45 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
46 #include <com/sun/star/container/XIndexContainer.hpp>
47 #include <com/sun/star/container/XContainerListener.hpp>
48 #include <com/sun/star/container/ContainerEvent.hpp>
49 #include <com/sun/star/container/XNameContainer.hpp>
50 /** === end UNO includes === **/
51 #include <cppuhelper/implbase3.hxx>
54 #include <svtools/lstner.hxx>
55 #include <comphelper/uno3.hxx>
57 class FmFormModel;
58 class FmFormObj;
59 class SdrObject;
60 class FmXFormView;
62 FORWARD_DECLARE_INTERFACE(awt,XControl)
63 FORWARD_DECLARE_INTERFACE(awt,XControlContainer)
64 //FORWARD_DECLARE_INTERFACE(uno,Reference)
66 //==================================================================
67 // FmUndoPropertyAction
68 //==================================================================
69 class FmUndoPropertyAction: public SdrUndoAction
71 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xObj;
72 ::rtl::OUString aPropertyName;
73 ::com::sun::star::uno::Any aNewValue;
74 ::com::sun::star::uno::Any aOldValue;
76 public:
77 FmUndoPropertyAction(FmFormModel& rMod, const ::com::sun::star::beans::PropertyChangeEvent& evt);
79 virtual void Undo();
80 virtual void Redo();
82 virtual String GetComment() const;
86 //==================================================================
87 // FmUndoContainerAction
88 //==================================================================
89 class FmUndoContainerAction: public SdrUndoAction
91 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
92 m_xContainer; // container which the action applies to
93 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
94 m_xElement; // object not owned by the action
95 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
96 m_xOwnElement; // object owned by the action
97 sal_Int32 m_nIndex; // index of the object within it's container
98 ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >
99 m_aEvents; // events of the object
101 public:
102 enum Action
104 Inserted = 1,
105 Removed = 2
108 private:
109 Action m_eAction;
111 public:
112 FmUndoContainerAction(FmFormModel& rMod,
113 Action _eAction,
114 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& xCont,
115 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xElem,
116 sal_Int32 nIdx = -1);
117 ~FmUndoContainerAction();
119 virtual void Undo();
120 virtual void Redo();
122 static void DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xElem );
124 protected:
125 void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
126 void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
129 //==================================================================
130 // FmUndoModelReplaceAction
131 //==================================================================
132 class FmUndoModelReplaceAction : public SdrUndoAction
134 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> m_xReplaced;
135 SdrUnoObj* m_pObject;
137 public:
138 FmUndoModelReplaceAction(FmFormModel& rMod, SdrUnoObj* pObject, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced);
139 ~FmUndoModelReplaceAction();
141 virtual void Undo();
142 virtual void Redo() { Undo(); }
144 virtual String GetComment() const;
146 static void DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced );
149 //========================================================================
150 class SVX_DLLPRIVATE FmXUndoEnvironment
151 : public ::cppu::WeakImplHelper3< ::com::sun::star::beans::XPropertyChangeListener
152 , ::com::sun::star::container::XContainerListener
153 , ::com::sun::star::util::XModifyListener
155 , public SfxListener
156 // public ::cppu::OWeakObject
158 FmFormModel& rModel;
160 void* m_pPropertySetCache;
161 ::svxform::PFormScriptingEnvironment m_pScriptingEnv;
162 oslInterlockedCount m_Locks;
163 ::osl::Mutex m_aMutex;
164 sal_Bool bReadOnly;
165 bool m_bDisposed;
167 public:
168 FmXUndoEnvironment(FmFormModel& _rModel);
169 ~FmXUndoEnvironment();
171 // UNO Anbindung
172 // SMART_UNO_DECLARATION(FmXUndoEnvironment, ::cppu::OWeakObject);
173 // virtual sal_Bool queryInterface(UsrUik, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>&);
174 // virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass>> getIdlClasses(void);
176 void Lock() { osl_incrementInterlockedCount( &m_Locks ); }
177 void UnLock() { osl_decrementInterlockedCount( &m_Locks ); }
178 sal_Bool IsLocked() const { return m_Locks != 0; }
180 // access control
181 struct Accessor { friend class FmFormModel; private: Accessor() { } };
183 // addition and removal of form collections
184 void AddForms( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& rForms );
185 void RemoveForms( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& rForms );
187 // readonly-ness
188 void SetReadOnly( sal_Bool bRead, const Accessor& ) { bReadOnly = bRead; }
189 sal_Bool IsReadOnly() const {return bReadOnly;}
191 protected:
192 // XEventListener
193 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
195 // XPropertyChangeListener
196 virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
198 // XContainerListener
199 virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
200 virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
201 virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
203 // XModifyListener
204 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
206 void ModeChanged();
207 void dispose();
209 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
211 private:
212 void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
213 void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
214 void TogglePropertyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
216 void implSetModified();
218 void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& _rxContainer, bool _bStartListening ) SAL_THROW(());
219 void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(());
220 ::com::sun::star::uno::Reference< com::sun::star::script::XScriptListener > m_vbaListener;
221 public:
222 // Methoden zur Zuordnung von Controls zu Forms,
223 // werden von der Seite und der UndoUmgebung genutzt
224 void Inserted(SdrObject* pObj);
225 void Removed(SdrObject* pObj);
227 void Inserted(FmFormObj* pObj);
228 void Removed(FmFormObj* pObj);
232 #endif //_SVX_FMUNDO_HXX