Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / svx / source / inc / fmundo.hxx
blob02b8f4998766f6682c7de4468d3c0f7c15677b2e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SOURCE_INC_FMUNDO_HXX
21 #define INCLUDED_SVX_SOURCE_INC_FMUNDO_HXX
23 #include <svx/svdundo.hxx>
24 #include <svx/svdouno.hxx>
25 #include "fmscriptingenv.hxx"
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/ScriptEventDescriptor.hpp>
33 #include <com/sun/star/container/XIndexContainer.hpp>
34 #include <com/sun/star/container/XContainerListener.hpp>
35 #include <com/sun/star/container/ContainerEvent.hpp>
36 #include <com/sun/star/container/XNameContainer.hpp>
37 #include <cppuhelper/implbase.hxx>
40 #include <svl/lstner.hxx>
42 class FmFormModel;
43 class FmFormObj;
44 class SdrObject;
46 class FmUndoPropertyAction: public SdrUndoAction
48 css::uno::Reference< css::beans::XPropertySet> xObj;
49 OUString aPropertyName;
50 css::uno::Any aNewValue;
51 css::uno::Any aOldValue;
53 public:
54 FmUndoPropertyAction(FmFormModel& rMod, const css::beans::PropertyChangeEvent& evt);
56 virtual void Undo() override;
57 virtual void Redo() override;
59 virtual OUString GetComment() const override;
63 class FmUndoContainerAction final : public SdrUndoAction
65 public:
66 enum Action
68 Inserted = 1,
69 Removed = 2
72 FmUndoContainerAction(FmFormModel& rMod,
73 Action _eAction,
74 const css::uno::Reference< css::container::XIndexContainer >& xCont,
75 const css::uno::Reference< css::uno::XInterface >& xElem,
76 sal_Int32 nIdx);
77 virtual ~FmUndoContainerAction() override;
79 virtual void Undo() override;
80 virtual void Redo() override;
82 static void DisposeElement( const css::uno::Reference< css::uno::XInterface >& xElem );
84 private:
85 void implReInsert( );
86 void implReRemove( );
88 css::uno::Reference< css::container::XIndexContainer >
89 m_xContainer; // container which the action applies to
90 css::uno::Reference< css::uno::XInterface >
91 m_xElement; // object not owned by the action
92 css::uno::Reference< css::uno::XInterface >
93 m_xOwnElement; // object owned by the action
94 sal_Int32 m_nIndex; // index of the object within its container
95 css::uno::Sequence< css::script::ScriptEventDescriptor >
96 m_aEvents; // events of the object
97 Action m_eAction;
100 class FmUndoModelReplaceAction : public SdrUndoAction
102 css::uno::Reference< css::awt::XControlModel> m_xReplaced;
103 SdrUnoObj* m_pObject;
105 public:
106 FmUndoModelReplaceAction(FmFormModel& rMod, SdrUnoObj* pObject, const css::uno::Reference< css::awt::XControlModel>& xReplaced);
107 virtual ~FmUndoModelReplaceAction() override;
109 virtual void Undo() override;
110 virtual void Redo() override { Undo(); }
112 virtual OUString GetComment() const override;
114 static void DisposeElement( const css::uno::Reference< css::awt::XControlModel>& xReplaced );
118 class FmXUndoEnvironment final
119 : public ::cppu::WeakImplHelper< css::beans::XPropertyChangeListener
120 , css::container::XContainerListener
121 , css::util::XModifyListener
123 , public SfxListener
125 public:
126 FmXUndoEnvironment(FmFormModel& _rModel);
127 virtual ~FmXUndoEnvironment() override;
129 // UNO binding
130 // SMART_UNO_DECLARATION(FmXUndoEnvironment, ::cppu::OWeakObject);
131 // virtual sal_Bool queryInterface(UsrUik, css::uno::Reference< css::uno::XInterface>&);
132 // virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass>> getIdlClasses();
134 void Lock() { osl_atomic_increment( &m_Locks ); }
135 void UnLock() { osl_atomic_decrement( &m_Locks ); }
136 bool IsLocked() const { return m_Locks != 0; }
138 // access control
139 struct Accessor { friend class FmFormModel; private: Accessor() { } };
141 // addition and removal of form collections
142 void AddForms( const css::uno::Reference< css::container::XNameContainer>& rForms );
143 void RemoveForms( const css::uno::Reference< css::container::XNameContainer>& rForms );
145 // readonly-ness
146 void SetReadOnly( bool bRead, const Accessor& ) { bReadOnly = bRead; }
147 bool IsReadOnly() const {return bReadOnly;}
149 // Methods for assigning controls to forms,
150 // used by the page and the undo environment
151 void Inserted(SdrObject* pObj);
152 void Removed(SdrObject* pObj);
154 static void Inserted(FmFormObj* pObj);
155 static void Removed(FmFormObj* pObj);
157 private:
158 // XEventListener
159 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
161 // XPropertyChangeListener
162 virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override;
164 // XContainerListener
165 virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override;
166 virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override;
167 virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override;
169 // XModifyListener
170 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
172 void ModeChanged();
173 void dispose();
175 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
177 void AddElement(const css::uno::Reference< css::uno::XInterface>& Element);
178 void RemoveElement(const css::uno::Reference< css::uno::XInterface>& Element);
179 void TogglePropertyListening(const css::uno::Reference< css::uno::XInterface>& Element);
181 void implSetModified();
183 void switchListening( const css::uno::Reference< css::container::XIndexContainer >& _rxContainer, bool _bStartListening );
184 void switchListening( const css::uno::Reference< css::uno::XInterface >& _rxObject, bool _bStartListening );
186 FmFormModel& rModel;
187 void* m_pPropertySetCache;
188 ::rtl::Reference<svxform::FormScriptingEnvironment> m_pScriptingEnv;
189 oslInterlockedCount m_Locks;
190 ::osl::Mutex m_aMutex;
191 bool bReadOnly;
192 bool m_bDisposed;
193 css::uno::Reference< css::script::XScriptListener > m_vbaListener;
197 #endif // INCLUDED_SVX_SOURCE_INC_FMUNDO_HXX
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */