LibreOffice Module svx (master) 1
fmundo.hxx
Go to the documentation of this file.
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 INCLUDED_SVX_SOURCE_INC_FMUNDO_HXX
21#define INCLUDED_SVX_SOURCE_INC_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/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>
38
39
40#include <svl/lstner.hxx>
41
42class FmFormModel;
43class FmFormObj;
44class SdrObject;
45
47{
48 css::uno::Reference< css::beans::XPropertySet> xObj;
49 OUString aPropertyName;
50 css::uno::Any aNewValue;
51 css::uno::Any aOldValue;
52
53public:
54 FmUndoPropertyAction(FmFormModel& rMod, const css::beans::PropertyChangeEvent& evt);
55
56 virtual void Undo() override;
57 virtual void Redo() override;
58
59 virtual OUString GetComment() const override;
60
61};
62
64{
65public:
66 enum Action
67 {
69 Removed = 2
70 };
71
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;
78
79 virtual void Undo() override;
80 virtual void Redo() override;
81
82 static void DisposeElement( const css::uno::Reference< css::uno::XInterface >& xElem );
83
84private:
85 void implReInsert( );
86 void implReRemove( );
87
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
98};
99
101{
102 css::uno::Reference< css::awt::XControlModel> m_xReplaced;
104
105public:
106 FmUndoModelReplaceAction(FmFormModel& rMod, SdrUnoObj* pObject, const css::uno::Reference< css::awt::XControlModel>& xReplaced);
107 virtual ~FmUndoModelReplaceAction() override;
108
109 virtual void Undo() override;
110 virtual void Redo() override { Undo(); }
111
112 virtual OUString GetComment() const override;
113
114 static void DisposeElement( const css::uno::Reference< css::awt::XControlModel>& xReplaced );
115};
116
117
119 : public ::cppu::WeakImplHelper< css::beans::XPropertyChangeListener
120 , css::container::XContainerListener
121 , css::util::XModifyListener
122 >
123 , public SfxListener
124{
125public:
127 virtual ~FmXUndoEnvironment() override;
128
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();
133
134 void Lock() { osl_atomic_increment( &m_Locks ); }
135 void UnLock() { osl_atomic_decrement( &m_Locks ); }
136 bool IsLocked() const { return m_Locks != 0; }
137
138 // access control
139 struct Accessor { friend class FmFormModel; private: Accessor() { } };
140
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 );
144
145 // readonly-ness
146 void SetReadOnly( bool bRead, const Accessor& ) { bReadOnly = bRead; }
147 bool IsReadOnly() const {return bReadOnly;}
148
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);
153
154 static void Inserted(FmFormObj* pObj);
155 static void Removed(FmFormObj* pObj);
156
157private:
158 // XEventListener
159 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
160
161 // XPropertyChangeListener
162 virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override;
163
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;
168
169 // XModifyListener
170 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
171
172 void ModeChanged();
173 void dispose();
174
175 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
176
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);
180
181 void implSetModified();
182
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 );
185
189 oslInterlockedCount m_Locks;
190 ::osl::Mutex m_aMutex;
193 css::uno::Reference< css::script::XScriptListener > m_vbaListener;
194};
195
196
197#endif // INCLUDED_SVX_SOURCE_INC_FMUNDO_HXX
198
199/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~FmUndoContainerAction() override
Definition: fmundo.cxx:1057
sal_Int32 m_nIndex
Definition: fmundo.hxx:94
virtual void Redo() override
Definition: fmundo.cxx:1164
css::uno::Sequence< css::script::ScriptEventDescriptor > m_aEvents
Definition: fmundo.hxx:96
css::uno::Reference< css::container::XIndexContainer > m_xContainer
Definition: fmundo.hxx:89
virtual void Undo() override
Definition: fmundo.cxx:1135
static void DisposeElement(const css::uno::Reference< css::uno::XInterface > &xElem)
Definition: fmundo.cxx:1064
FmUndoContainerAction(FmFormModel &rMod, Action _eAction, const css::uno::Reference< css::container::XIndexContainer > &xCont, const css::uno::Reference< css::uno::XInterface > &xElem, sal_Int32 nIdx)
Definition: fmundo.cxx:1021
css::uno::Reference< css::uno::XInterface > m_xElement
Definition: fmundo.hxx:91
css::uno::Reference< css::uno::XInterface > m_xOwnElement
Definition: fmundo.hxx:93
FmUndoModelReplaceAction(FmFormModel &rMod, SdrUnoObj *pObject, const css::uno::Reference< css::awt::XControlModel > &xReplaced)
Definition: fmundo.cxx:1192
virtual void Undo() override
Definition: fmundo.cxx:1219
css::uno::Reference< css::awt::XControlModel > m_xReplaced
Definition: fmundo.hxx:102
SdrUnoObj * m_pObject
Definition: fmundo.hxx:103
static void DisposeElement(const css::uno::Reference< css::awt::XControlModel > &xReplaced)
Definition: fmundo.cxx:1207
virtual OUString GetComment() const override
Definition: fmundo.cxx:1258
virtual ~FmUndoModelReplaceAction() override
Definition: fmundo.cxx:1200
virtual void Redo() override
Definition: fmundo.hxx:110
virtual void Undo() override
Definition: fmundo.cxx:974
FmUndoPropertyAction(FmFormModel &rMod, const css::beans::PropertyChangeEvent &evt)
Definition: fmundo.cxx:960
virtual void Redo() override
Definition: fmundo.cxx:994
virtual OUString GetComment() const override
Definition: fmundo.cxx:1014
OUString aPropertyName
Definition: fmundo.hxx:49
css::uno::Any aOldValue
Definition: fmundo.hxx:51
css::uno::Any aNewValue
Definition: fmundo.hxx:50
css::uno::Reference< css::beans::XPropertySet > xObj
Definition: fmundo.hxx:48
oslInterlockedCount m_Locks
Definition: fmundo.hxx:189
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &rEvent) override
Definition: fmundo.cxx:764
void switchListening(const css::uno::Reference< css::uno::XInterface > &_rxObject, bool _bStartListening)
void RemoveElement(const css::uno::Reference< css::uno::XInterface > &Element)
Definition: fmundo.cxx:929
void AddForms(const css::uno::Reference< css::container::XNameContainer > &rForms)
Definition: fmundo.cxx:783
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: fmundo.cxx:510
void AddElement(const css::uno::Reference< css::uno::XInterface > &Element)
Definition: fmundo.cxx:916
void TogglePropertyListening(const css::uno::Reference< css::uno::XInterface > &Element)
Definition: fmundo.cxx:799
void Inserted(SdrObject *pObj)
Definition: fmundo.cxx:337
void * m_pPropertySetCache
Definition: fmundo.hxx:187
void implSetModified()
Definition: fmundo.cxx:738
virtual ~FmXUndoEnvironment() override
Definition: fmundo.cxx:188
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
Definition: fmundo.cxx:528
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &rEvent) override
Definition: fmundo.cxx:747
FmXUndoEnvironment(FmFormModel &_rModel)
Definition: fmundo.cxx:171
void Removed(SdrObject *pObj)
Definition: fmundo.cxx:446
bool IsLocked() const
Definition: fmundo.hxx:136
FmFormModel & rModel
Definition: fmundo.hxx:186
void SetReadOnly(bool bRead, const Accessor &)
Definition: fmundo.hxx:146
void switchListening(const css::uno::Reference< css::container::XIndexContainer > &_rxContainer, bool _bStartListening)
css::uno::Reference< css::script::XScriptListener > m_vbaListener
Definition: fmundo.hxx:193
::osl::Mutex m_aMutex
Definition: fmundo.hxx:190
void ModeChanged()
Definition: fmundo.cxx:245
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
Definition: fmundo.cxx:777
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: fmundo.cxx:288
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &rEvent) override
Definition: fmundo.cxx:723
::rtl::Reference< svxform::FormScriptingEnvironment > m_pScriptingEnv
Definition: fmundo.hxx:188
bool IsReadOnly() const
Definition: fmundo.hxx:147
void RemoveForms(const css::uno::Reference< css::container::XNameContainer > &rForms)
Definition: fmundo.cxx:791
Abstract DrawObject.
Definition: svdobj.hxx:260
Abstract base class (ABC) for all UndoActions of DrawingEngine.
Definition: svdundo.hxx:61
SdrModel & rMod
Definition: svdundo.hxx:63