tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / svx / source / inc / fmundo.hxx
blobc2e5bde2927690eb901f77710825ddd25a9af4f5
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"
27 #include <com/sun/star/util/XModifyListener.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
30 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
31 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
32 #include <com/sun/star/container/XIndexContainer.hpp>
33 #include <com/sun/star/container/XContainerListener.hpp>
34 #include <com/sun/star/container/ContainerEvent.hpp>
35 #include <com/sun/star/container/XNameContainer.hpp>
36 #include <cppuhelper/implbase.hxx>
39 #include <svl/lstner.hxx>
40 #include <memory>
41 #include <map>
43 class FmFormModel;
44 class FmFormObj;
45 class SdrObject;
46 struct PropertySetInfo;
47 class ScriptEventListenerWrapper;
49 class FmUndoPropertyAction final : public SdrUndoAction
51 css::uno::Reference< css::beans::XPropertySet> xObj;
52 OUString aPropertyName;
53 css::uno::Any aNewValue;
54 css::uno::Any aOldValue;
56 public:
57 FmUndoPropertyAction(FmFormModel& rMod, const css::beans::PropertyChangeEvent& evt);
59 virtual void Undo() override;
60 virtual void Redo() override;
62 virtual OUString GetComment() const override;
66 class FmUndoContainerAction final : public SdrUndoAction
68 public:
69 enum Action
71 Inserted = 1,
72 Removed = 2
75 FmUndoContainerAction(FmFormModel& rMod,
76 Action _eAction,
77 const css::uno::Reference< css::container::XIndexContainer >& xCont,
78 const css::uno::Reference< css::uno::XInterface >& xElem,
79 sal_Int32 nIdx);
80 virtual ~FmUndoContainerAction() override;
82 virtual void Undo() override;
83 virtual void Redo() override;
85 static void DisposeElement( const css::uno::Reference< css::uno::XInterface >& xElem );
87 private:
88 void implReInsert( );
89 void implReRemove( );
91 css::uno::Reference< css::container::XIndexContainer >
92 m_xContainer; // container which the action applies to
93 css::uno::Reference< css::uno::XInterface >
94 m_xElement; // object not owned by the action
95 css::uno::Reference< css::uno::XInterface >
96 m_xOwnElement; // object owned by the action
97 sal_Int32 m_nIndex; // index of the object within its container
98 css::uno::Sequence< css::script::ScriptEventDescriptor >
99 m_aEvents; // events of the object
100 Action m_eAction;
103 class FmUndoModelReplaceAction final : public SdrUndoAction
105 css::uno::Reference< css::awt::XControlModel> m_xReplaced;
106 SdrUnoObj* m_pObject;
108 public:
109 FmUndoModelReplaceAction(FmFormModel& rMod, SdrUnoObj* pObject, const css::uno::Reference< css::awt::XControlModel>& xReplaced);
110 virtual ~FmUndoModelReplaceAction() override;
112 virtual void Undo() override;
113 virtual void Redo() override { Undo(); }
115 virtual OUString GetComment() const override;
117 static void DisposeElement( const css::uno::Reference< css::awt::XControlModel>& xReplaced );
120 typedef std::map<css::uno::Reference< css::beans::XPropertySet >, PropertySetInfo> PropertySetInfoCache;
122 class FmXUndoEnvironment final
123 : public ::cppu::WeakImplHelper< css::beans::XPropertyChangeListener
124 , css::container::XContainerListener
125 , css::util::XModifyListener
127 , public SfxListener
129 public:
130 FmXUndoEnvironment(FmFormModel& _rModel);
131 virtual ~FmXUndoEnvironment() override;
133 // UNO binding
134 // SMART_UNO_DECLARATION(FmXUndoEnvironment, ::cppu::OWeakObject);
135 // virtual sal_Bool queryInterface(UsrUik, css::uno::Reference< css::uno::XInterface>&);
136 // virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass>> getIdlClasses();
138 void Lock() { osl_atomic_increment( &m_Locks ); }
139 void UnLock() { osl_atomic_decrement( &m_Locks ); }
140 bool IsLocked() const { return m_Locks != 0; }
142 // access control
143 struct Accessor { friend class FmFormModel; private: Accessor() { } };
145 // addition and removal of form collections
146 void AddForms( const css::uno::Reference< css::container::XNameContainer>& rForms );
147 void RemoveForms( const css::uno::Reference< css::container::XNameContainer>& rForms );
149 // readonly-ness
150 void SetReadOnly( bool bRead, const Accessor& ) { bReadOnly = bRead; }
151 bool IsReadOnly() const {return bReadOnly;}
153 // Methods for assigning controls to forms,
154 // used by the page and the undo environment
155 void Inserted(SdrObject* pObj);
156 void Removed(SdrObject* pObj);
158 static void Inserted(FmFormObj* pObj);
159 static void Removed(FmFormObj* pObj);
161 private:
162 // XEventListener
163 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
165 // XPropertyChangeListener
166 virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override;
168 // XContainerListener
169 virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override;
170 virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override;
171 virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override;
173 // XModifyListener
174 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
176 void ModeChanged();
177 void dispose();
179 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
181 void AddElement(const css::uno::Reference< css::uno::XInterface>& Element);
182 void RemoveElement(const css::uno::Reference< css::uno::XInterface>& Element);
183 void TogglePropertyListening(const css::uno::Reference< css::uno::XInterface>& Element);
185 void implSetModified();
187 void switchListening( const css::uno::Reference< css::container::XIndexContainer >& _rxContainer, bool _bStartListening );
188 void switchListening( const css::uno::Reference< css::uno::XInterface >& _rxObject, bool _bStartListening );
190 FmFormModel& rModel;
191 std::unique_ptr<PropertySetInfoCache> m_pPropertySetCache;
192 ::rtl::Reference<svxform::FormScriptingEnvironment> m_pScriptingEnv;
193 oslInterlockedCount m_Locks;
194 ::osl::Mutex m_aMutex;
195 bool bReadOnly;
196 bool m_bDisposed;
197 rtl::Reference< ScriptEventListenerWrapper > m_vbaListener;
201 #endif // INCLUDED_SVX_SOURCE_INC_FMUNDO_HXX
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */