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>
37 #include <cppuhelper/implbase.hxx>
38 
39 
40 #include <svl/lstner.hxx>
41 
42 class FmFormModel;
43 class FmFormObj;
44 class 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 
53 public:
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 {
65 public:
66  enum Action
67  {
68  Inserted = 1,
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 
84 private:
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 
105 public:
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 {
125 public:
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 
157 private:
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;
191  bool bReadOnly;
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: */
css::uno::Reference< css::uno::XInterface > m_xOwnElement
Definition: fmundo.hxx:93
void * m_pPropertySetCache
Definition: fmundo.hxx:187
void TogglePropertyListening(const css::uno::Reference< css::uno::XInterface > &Element)
Definition: fmundo.cxx:801
virtual ~FmUndoContainerAction() override
Definition: fmundo.cxx:1059
css::uno::Reference< css::awt::XControlModel > m_xReplaced
Definition: fmundo.hxx:102
virtual void Undo() override
Definition: fmundo.cxx:976
void Inserted(SdrObject *pObj)
Definition: fmundo.cxx:338
void Removed(SdrObject *pObj)
Definition: fmundo.cxx:447
void switchListening(const css::uno::Reference< css::container::XIndexContainer > &_rxContainer, bool _bStartListening)
OUString aPropertyName
Definition: fmundo.hxx:49
virtual void Redo() override
Definition: fmundo.cxx:996
SdrUnoObj * m_pObject
Definition: fmundo.hxx:103
Abstract base class (ABC) for all UndoActions of DrawingEngine.
Definition: svdundo.hxx:54
virtual OUString GetComment() const override
Definition: fmundo.cxx:1260
FmXUndoEnvironment(FmFormModel &_rModel)
Definition: fmundo.cxx:172
virtual ~FmXUndoEnvironment() override
Definition: fmundo.cxx:189
bool IsReadOnly() const
Definition: fmundo.hxx:147
SdrModel & rMod
Definition: svdundo.hxx:57
FmUndoPropertyAction(FmFormModel &rMod, const css::beans::PropertyChangeEvent &evt)
Definition: fmundo.cxx:962
virtual OUString GetComment() const override
Definition: fmundo.cxx:1016
void RemoveElement(const css::uno::Reference< css::uno::XInterface > &Element)
Definition: fmundo.cxx:931
void AddElement(const css::uno::Reference< css::uno::XInterface > &Element)
Definition: fmundo.cxx:918
sal_Int32 m_nIndex
Definition: fmundo.hxx:94
static void DisposeElement(const css::uno::Reference< css::awt::XControlModel > &xReplaced)
Definition: fmundo.cxx:1209
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &rEvent) override
Definition: fmundo.cxx:749
oslInterlockedCount m_Locks
Definition: fmundo.hxx:189
static void DisposeElement(const css::uno::Reference< css::uno::XInterface > &xElem)
Definition: fmundo.cxx:1066
css::uno::Reference< css::uno::XInterface > m_xElement
Definition: fmundo.hxx:91
void implSetModified()
Definition: fmundo.cxx:740
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
Definition: fmundo.cxx:779
css::uno::Any aNewValue
Definition: fmundo.hxx:50
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: fmundo.cxx:289
void SetReadOnly(bool bRead, const Accessor &)
Definition: fmundo.hxx:146
bool IsLocked() const
Definition: fmundo.hxx:136
FmUndoModelReplaceAction(FmFormModel &rMod, SdrUnoObj *pObject, const css::uno::Reference< css::awt::XControlModel > &xReplaced)
Definition: fmundo.cxx:1194
virtual void Redo() override
Definition: fmundo.hxx:110
Abstract DrawObject.
Definition: svdobj.hxx:313
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
Definition: fmundo.cxx:530
FmFormModel & rModel
Definition: fmundo.hxx:186
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:1023
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &rEvent) override
Definition: fmundo.cxx:766
virtual void Undo() override
Definition: fmundo.cxx:1137
void ModeChanged()
Definition: fmundo.cxx:246
void AddForms(const css::uno::Reference< css::container::XNameContainer > &rForms)
Definition: fmundo.cxx:785
::rtl::Reference< svxform::FormScriptingEnvironment > m_pScriptingEnv
Definition: fmundo.hxx:188
css::uno::Reference< css::beans::XPropertySet > xObj
Definition: fmundo.hxx:48
virtual void Undo() override
Definition: fmundo.cxx:1221
css::uno::Reference< css::script::XScriptListener > m_vbaListener
Definition: fmundo.hxx:193
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: fmundo.cxx:512
void RemoveForms(const css::uno::Reference< css::container::XNameContainer > &rForms)
Definition: fmundo.cxx:793
css::uno::Reference< css::container::XIndexContainer > m_xContainer
Definition: fmundo.hxx:89
css::uno::Any aOldValue
Definition: fmundo.hxx:51
virtual void Redo() override
Definition: fmundo.cxx:1166
::osl::Mutex m_aMutex
Definition: fmundo.hxx:190
virtual ~FmUndoModelReplaceAction() override
Definition: fmundo.cxx:1202
css::uno::Sequence< css::script::ScriptEventDescriptor > m_aEvents
Definition: fmundo.hxx:96
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &rEvent) override
Definition: fmundo.cxx:725