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/ScriptEvent.hpp>
33 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
34 #include <com/sun/star/container/XIndexContainer.hpp>
35 #include <com/sun/star/container/XContainerListener.hpp>
36 #include <com/sun/star/container/ContainerEvent.hpp>
37 #include <com/sun/star/container/XNameContainer.hpp>
38 #include <cppuhelper/implbase.hxx>
39 
40 
41 #include <svl/lstner.hxx>
42 
43 class FmFormModel;
44 class FmFormObj;
45 class SdrObject;
46 
48 {
49  css::uno::Reference< css::beans::XPropertySet> xObj;
50  OUString const aPropertyName;
51  css::uno::Any const aNewValue;
52  css::uno::Any const aOldValue;
53 
54 public:
55  FmUndoPropertyAction(FmFormModel& rMod, const css::beans::PropertyChangeEvent& evt);
56 
57  virtual void Undo() override;
58  virtual void Redo() override;
59 
60  virtual OUString GetComment() const override;
61 
62 };
63 
65 {
66 public:
67  enum Action
68  {
69  Inserted = 1,
70  Removed = 2
71  };
72 
74  Action _eAction,
75  const css::uno::Reference< css::container::XIndexContainer >& xCont,
76  const css::uno::Reference< css::uno::XInterface >& xElem,
77  sal_Int32 nIdx);
78  virtual ~FmUndoContainerAction() override;
79 
80  virtual void Undo() override;
81  virtual void Redo() override;
82 
83  static void DisposeElement( const css::uno::Reference< css::uno::XInterface >& xElem );
84 
85 private:
86  void implReInsert( );
87  void implReRemove( );
88 
89  css::uno::Reference< css::container::XIndexContainer >
90  m_xContainer; // container which the action applies to
91  css::uno::Reference< css::uno::XInterface >
92  m_xElement; // object not owned by the action
93  css::uno::Reference< css::uno::XInterface >
94  m_xOwnElement; // object owned by the action
95  sal_Int32 m_nIndex; // index of the object within it's container
96  css::uno::Sequence< css::script::ScriptEventDescriptor >
97  m_aEvents; // events of the object
99 };
100 
102 {
103  css::uno::Reference< css::awt::XControlModel> m_xReplaced;
105 
106 public:
107  FmUndoModelReplaceAction(FmFormModel& rMod, SdrUnoObj* pObject, const css::uno::Reference< css::awt::XControlModel>& xReplaced);
108  virtual ~FmUndoModelReplaceAction() override;
109 
110  virtual void Undo() override;
111  virtual void Redo() override { Undo(); }
112 
113  virtual OUString GetComment() const override;
114 
115  static void DisposeElement( const css::uno::Reference< css::awt::XControlModel>& xReplaced );
116 };
117 
118 
120  : public ::cppu::WeakImplHelper< css::beans::XPropertyChangeListener
121  , css::container::XContainerListener
122  , css::util::XModifyListener
123  >
124  , public SfxListener
125 {
126 public:
128  virtual ~FmXUndoEnvironment() override;
129 
130  // UNO binding
131  // SMART_UNO_DECLARATION(FmXUndoEnvironment, ::cppu::OWeakObject);
132  // virtual sal_Bool queryInterface(UsrUik, css::uno::Reference< css::uno::XInterface>&);
133  // virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass>> getIdlClasses();
134 
135  void Lock() { osl_atomic_increment( &m_Locks ); }
136  void UnLock() { osl_atomic_decrement( &m_Locks ); }
137  bool IsLocked() const { return m_Locks != 0; }
138 
139  // access control
140  struct Accessor { friend class FmFormModel; private: Accessor() { } };
141 
142  // addition and removal of form collections
143  void AddForms( const css::uno::Reference< css::container::XNameContainer>& rForms );
144  void RemoveForms( const css::uno::Reference< css::container::XNameContainer>& rForms );
145 
146  // readonly-ness
147  void SetReadOnly( bool bRead, const Accessor& ) { bReadOnly = bRead; }
148  bool IsReadOnly() const {return bReadOnly;}
149 
150  // Methods for assigning controls to forms,
151  // used by the page and the undo environment
152  void Inserted(SdrObject* pObj);
153  void Removed(SdrObject* pObj);
154 
155  static void Inserted(FmFormObj* pObj);
156  static void Removed(FmFormObj* pObj);
157 
158 private:
159  // XEventListener
160  virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
161 
162  // XPropertyChangeListener
163  virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override;
164 
165  // XContainerListener
166  virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override;
167  virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override;
168  virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override;
169 
170  // XModifyListener
171  virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
172 
173  void ModeChanged();
174  void dispose();
175 
176  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
177 
178  void AddElement(const css::uno::Reference< css::uno::XInterface>& Element);
179  void RemoveElement(const css::uno::Reference< css::uno::XInterface>& Element);
180  void TogglePropertyListening(const css::uno::Reference< css::uno::XInterface>& Element);
181 
182  void implSetModified();
183 
184  void switchListening( const css::uno::Reference< css::container::XIndexContainer >& _rxContainer, bool _bStartListening );
185  void switchListening( const css::uno::Reference< css::uno::XInterface >& _rxObject, bool _bStartListening );
186 
190  oslInterlockedCount m_Locks;
191  ::osl::Mutex m_aMutex;
192  bool bReadOnly;
194  css::uno::Reference< css::script::XScriptListener > m_vbaListener;
195 };
196 
197 
198 #endif // INCLUDED_SVX_SOURCE_INC_FMUNDO_HXX
199 
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XInterface > m_xOwnElement
Definition: fmundo.hxx:94
void * m_pPropertySetCache
Definition: fmundo.hxx:188
void TogglePropertyListening(const css::uno::Reference< css::uno::XInterface > &Element)
Definition: fmundo.cxx:807
virtual ~FmUndoContainerAction() override
Definition: fmundo.cxx:1065
OUString const aPropertyName
Definition: fmundo.hxx:50
css::uno::Reference< css::awt::XControlModel > m_xReplaced
Definition: fmundo.hxx:103
virtual void Undo() override
Definition: fmundo.cxx:982
void Inserted(SdrObject *pObj)
Definition: fmundo.cxx:343
void Removed(SdrObject *pObj)
Definition: fmundo.cxx:452
void switchListening(const css::uno::Reference< css::container::XIndexContainer > &_rxContainer, bool _bStartListening)
virtual void Redo() override
Definition: fmundo.cxx:1002
SdrUnoObj * m_pObject
Definition: fmundo.hxx:104
Abstract base class (ABC) for all UndoActions of DrawingEngine.
Definition: svdundo.hxx:53
virtual OUString GetComment() const override
Definition: fmundo.cxx:1266
FmXUndoEnvironment(FmFormModel &_rModel)
Definition: fmundo.cxx:177
virtual ~FmXUndoEnvironment() override
Definition: fmundo.cxx:194
bool IsReadOnly() const
Definition: fmundo.hxx:148
SdrModel & rMod
Definition: svdundo.hxx:56
FmUndoPropertyAction(FmFormModel &rMod, const css::beans::PropertyChangeEvent &evt)
Definition: fmundo.cxx:968
virtual OUString GetComment() const override
Definition: fmundo.cxx:1022
css::uno::Any const aOldValue
Definition: fmundo.hxx:52
void RemoveElement(const css::uno::Reference< css::uno::XInterface > &Element)
Definition: fmundo.cxx:937
void AddElement(const css::uno::Reference< css::uno::XInterface > &Element)
Definition: fmundo.cxx:924
sal_Int32 m_nIndex
Definition: fmundo.hxx:95
static void DisposeElement(const css::uno::Reference< css::awt::XControlModel > &xReplaced)
Definition: fmundo.cxx:1215
css::uno::Any const aNewValue
Definition: fmundo.hxx:51
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &rEvent) override
Definition: fmundo.cxx:755
oslInterlockedCount m_Locks
Definition: fmundo.hxx:190
static void DisposeElement(const css::uno::Reference< css::uno::XInterface > &xElem)
Definition: fmundo.cxx:1072
css::uno::Reference< css::uno::XInterface > m_xElement
Definition: fmundo.hxx:92
void implSetModified()
Definition: fmundo.cxx:746
Action const m_eAction
Definition: fmundo.hxx:98
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
Definition: fmundo.cxx:785
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: fmundo.cxx:294
void SetReadOnly(bool bRead, const Accessor &)
Definition: fmundo.hxx:147
bool IsLocked() const
Definition: fmundo.hxx:137
FmUndoModelReplaceAction(FmFormModel &rMod, SdrUnoObj *pObject, const css::uno::Reference< css::awt::XControlModel > &xReplaced)
Definition: fmundo.cxx:1200
virtual void Redo() override
Definition: fmundo.hxx:111
Abstract DrawObject.
Definition: svdobj.hxx:312
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
Definition: fmundo.cxx:536
FmFormModel & rModel
Definition: fmundo.hxx:187
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:1029
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &rEvent) override
Definition: fmundo.cxx:772
virtual void Undo() override
Definition: fmundo.cxx:1143
void ModeChanged()
Definition: fmundo.cxx:251
void AddForms(const css::uno::Reference< css::container::XNameContainer > &rForms)
Definition: fmundo.cxx:791
::rtl::Reference< svxform::FormScriptingEnvironment > m_pScriptingEnv
Definition: fmundo.hxx:189
css::uno::Reference< css::beans::XPropertySet > xObj
Definition: fmundo.hxx:49
virtual void Undo() override
Definition: fmundo.cxx:1227
css::uno::Reference< css::script::XScriptListener > m_vbaListener
Definition: fmundo.hxx:194
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: fmundo.cxx:518
void RemoveForms(const css::uno::Reference< css::container::XNameContainer > &rForms)
Definition: fmundo.cxx:799
css::uno::Reference< css::container::XIndexContainer > m_xContainer
Definition: fmundo.hxx:90
virtual void Redo() override
Definition: fmundo.cxx:1172
::osl::Mutex m_aMutex
Definition: fmundo.hxx:191
virtual ~FmUndoModelReplaceAction() override
Definition: fmundo.cxx:1208
css::uno::Sequence< css::script::ScriptEventDescriptor > m_aEvents
Definition: fmundo.hxx:97
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &rEvent) override
Definition: fmundo.cxx:731