LibreOffice Module reportdesign (master)  1
UndoActions.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 #ifndef INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
20 #define INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
21 
22 #include "dllapi.h"
23 
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
26 #include <com/sun/star/report/XReportDefinition.hpp>
27 #include <com/sun/star/report/XGroup.hpp>
28 
29 #include <svx/svdundo.hxx>
30 
31 #include <functional>
32 
33 namespace dbaui
34 {
35  class IController;
36 }
37 namespace rptui
38 {
39  enum Action
40  {
41  Inserted = 1,
42  Removed = 2
43  };
44 
48  {
49  css::uno::Reference< css::report::XGroup > m_xGroup;
50  OGroupHelper(const OGroupHelper&) = delete;
51  OGroupHelper& operator=(const OGroupHelper&) = delete;
52  public:
53  OGroupHelper(const css::uno::Reference< css::report::XGroup >& _xGroup)
54  :m_xGroup(_xGroup)
55  {
56  }
57  css::uno::Reference< css::report::XSection > getHeader() { return m_xGroup->getHeader(); }
58  css::uno::Reference< css::report::XSection > getFooter() { return m_xGroup->getFooter(); }
59  const css::uno::Reference< css::report::XGroup >& getGroup() const { return m_xGroup; }
60 
61  bool getHeaderOn() { return m_xGroup->getHeaderOn(); }
62  bool getFooterOn() { return m_xGroup->getFooterOn(); }
63 
64  static ::std::function<css::uno::Reference< css::report::XSection>(OGroupHelper *)> getMemberFunction(const css::uno::Reference< css::report::XSection >& _xSection);
65 
66  };
67 
71  {
72  css::uno::Reference< css::report::XReportDefinition > m_xReport;
73  public:
74  OReportHelper(const css::uno::Reference< css::report::XReportDefinition >& _xReport)
75  :m_xReport(_xReport)
76  {
77  }
78  css::uno::Reference< css::report::XSection > getReportHeader() { return m_xReport->getReportHeader(); }
79  css::uno::Reference< css::report::XSection > getReportFooter() { return m_xReport->getReportFooter(); }
80  css::uno::Reference< css::report::XSection > getPageHeader() { return m_xReport->getPageHeader(); }
81  css::uno::Reference< css::report::XSection > getPageFooter() { return m_xReport->getPageFooter(); }
82  css::uno::Reference< css::report::XSection > getDetail() { return m_xReport->getDetail(); }
83 
84  bool getReportHeaderOn() { return m_xReport->getReportHeaderOn(); }
85  bool getReportFooterOn() { return m_xReport->getReportFooterOn(); }
86  bool getPageHeaderOn() { return m_xReport->getPageHeaderOn(); }
87  bool getPageFooterOn() { return m_xReport->getPageFooterOn(); }
88 
89  static ::std::function<css::uno::Reference< css::report::XSection>(OReportHelper *)> getMemberFunction(const css::uno::Reference< css::report::XSection >& _xSection);
90  };
91 
92 
93  //= UndoContext
94 
96  {
97  public:
98  UndoContext( SfxUndoManager& i_undoManager, const OUString& i_undoTitle )
99  :m_rUndoManager( i_undoManager )
100  {
101  m_rUndoManager.EnterListAction( i_undoTitle, OUString(), 0, ViewShellId(-1) );
102  }
103 
105  {
107  }
108 
109  private:
111  };
112 
113 
114  //= UndoSuppressor
115 
117  {
118  public:
119  UndoSuppressor( SfxUndoManager& i_undoManager )
120  :m_rUndoManager( i_undoManager )
121  {
122  m_rUndoManager.EnableUndo( false );
123  }
124 
126  {
127  m_rUndoManager.EnableUndo( true );
128  }
129 
130  private:
132  };
133 
134 
135  //= OCommentUndoAction
136 
138  {
139  protected:
140  OUString m_strComment; // undo, redo comment
142 
143  public:
144  OCommentUndoAction(SdrModel& rMod, const char* pCommentID);
145  virtual ~OCommentUndoAction() override;
146 
147  virtual OUString GetComment() const override { return m_strComment; }
148  virtual void Undo() override;
149  virtual void Redo() override;
150  };
151 
152  // OUndoContainerAction
153 
155  {
156  OUndoContainerAction(OUndoContainerAction const &) = delete;
157  void operator =(OUndoContainerAction const &) = delete;
158  protected:
159  css::uno::Reference< css::uno::XInterface >
160  m_xElement; // object not owned by the action
161  css::uno::Reference< css::uno::XInterface >
162  m_xOwnElement; // object owned by the action
163  css::uno::Reference< css::container::XIndexContainer >
166 
167  public:
169  ,Action _eAction
170  ,const css::uno::Reference< css::container::XIndexContainer >& rContainer
171  ,const css::uno::Reference< css::uno::XInterface>& xElem
172  ,const char* pCommentId);
173  virtual ~OUndoContainerAction() override;
174 
175  virtual void Undo() override;
176  virtual void Redo() override;
177 
178  protected:
179  virtual void implReInsert( );
180  virtual void implReRemove( );
181  };
182 
183 
184  // OUndoReportSectionAction
185 
187  {
189  ::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> m_pMemberFunction;
190  public:
192  ,Action _eAction
193  ,::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> _pMemberFunction
194  ,const css::uno::Reference< css::report::XReportDefinition >& _xReport
195  ,const css::uno::Reference< css::uno::XInterface>& xElem
196  ,const char* pCommentId);
197 
198  private:
199  virtual void implReInsert( ) override;
200  virtual void implReRemove( ) override;
201  };
202 
203 
204  // OUndoGroupSectionAction
206  {
208  ::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> m_pMemberFunction;
209  public:
211  ,Action _eAction
212  ,::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> _pMemberFunction
213  ,const css::uno::Reference< css::report::XGroup >& _xGroup
214  ,const css::uno::Reference< css::uno::XInterface>& xElem
215  ,const char* pCommentId);
216 
217  private:
218  virtual void implReInsert( ) override;
219  virtual void implReRemove( ) override;
220  };
221 
222  // ORptUndoPropertyAction
224  {
225  css::uno::Reference< css::beans::XPropertySet> m_xObj;
226  OUString m_aPropertyName;
227  css::uno::Any m_aNewValue;
228  css::uno::Any m_aOldValue;
229 
234  void setProperty(bool _bOld);
235  protected:
236  virtual css::uno::Reference< css::beans::XPropertySet> getObject();
237 
238  public:
239  ORptUndoPropertyAction(SdrModel& rMod, const css::beans::PropertyChangeEvent& evt);
240 
241  virtual void Undo() override;
242  virtual void Redo() override;
243 
244  virtual OUString GetComment() const override;
245  };
246 
247 
248  // OUndoPropertyReportSectionAction
249 
251  {
253  ::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> m_pMemberFunction;
254 
255  virtual css::uno::Reference< css::beans::XPropertySet> getObject() override;
256  public:
258  ,const css::beans::PropertyChangeEvent& evt
259  ,::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> _pMemberFunction
260  ,const css::uno::Reference< css::report::XReportDefinition >& _xReport
261  );
262  };
263 
264 
265  // OUndoPropertyGroupSectionAction
266 
268  {
270  ::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> m_pMemberFunction;
271 
272  virtual css::uno::Reference< css::beans::XPropertySet> getObject() override;
273  public:
275  ,const css::beans::PropertyChangeEvent& evt
276  ,::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> _pMemberFunction
277  ,const css::uno::Reference< css::report::XGroup >& _xGroup
278  );
279  };
280 
281 }
282 #endif // INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
283 
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OGroupHelper(const OGroupHelper &)=delete
::dbaui::IController * m_pController
void operator=(OUndoContainerAction const &)=delete
void setProperty(bool _bOld)
sets either the old value or the new value again at the property set.
virtual void implReInsert() override
UndoSuppressor(SfxUndoManager &i_undoManager)
SfxUndoManager & m_rUndoManager
virtual css::uno::Reference< css::beans::XPropertySet > getObject() override
static::std::function< css::uno::Reference< css::report::XSection >OGroupHelper *)> getMemberFunction(const css::uno::Reference< css::report::XSection > &_xSection)
Definition: UndoActions.cxx:46
#define REPORTDESIGN_DLLPUBLIC
Definition: dllapi.h:28
static::std::function< css::uno::Reference< css::report::XSection >OReportHelper *)> getMemberFunction(const css::uno::Reference< css::report::XSection > &_xSection)
Definition: UndoActions.cxx:55
css::uno::Reference< css::report::XSection > getReportHeader()
Definition: UndoActions.hxx:78
virtual OUString GetComment() const override
virtual OUString GetComment() const override
virtual void Undo() override
OGroupHelper(const css::uno::Reference< css::report::XGroup > &_xGroup)
Definition: UndoActions.hxx:53
OReportHelper(const css::uno::Reference< css::report::XReportDefinition > &_xReport)
Definition: UndoActions.hxx:74
Helper class to allow std::mem_fun for SAL_CALL.
Definition: UndoActions.hxx:70
SdrModel & rMod
OUndoReportSectionAction(SdrModel &rMod, Action _eAction,::std::function< css::uno::Reference< css::report::XSection >(OReportHelper *)> _pMemberFunction, const css::uno::Reference< css::report::XReportDefinition > &_xReport, const css::uno::Reference< css::uno::XInterface > &xElem, const char *pCommentId)
void EnableUndo(bool bEnable)
virtual void implReInsert() override
::std::function< css::uno::Reference< css::report::XSection >OReportHelper *)> m_pMemberFunction
OUndoPropertyReportSectionAction(SdrModel &rMod, const css::beans::PropertyChangeEvent &evt,::std::function< css::uno::Reference< css::report::XSection >(OReportHelper *)> _pMemberFunction, const css::uno::Reference< css::report::XReportDefinition > &_xReport)
virtual void Redo() override
css::uno::Reference< css::report::XReportDefinition > m_xReport
Definition: UndoActions.hxx:72
::std::function< css::uno::Reference< css::report::XSection >OGroupHelper *)> m_pMemberFunction
UndoContext(SfxUndoManager &i_undoManager, const OUString &i_undoTitle)
Definition: UndoActions.hxx:98
css::uno::Reference< css::uno::XInterface > m_xElement
css::uno::Reference< css::report::XSection > getPageHeader()
Definition: UndoActions.hxx:80
virtual void implReRemove() override
css::uno::Reference< css::report::XSection > getDetail()
Definition: UndoActions.hxx:82
virtual css::uno::Reference< css::beans::XPropertySet > getObject() override
OGroupHelper & operator=(const OGroupHelper &)=delete
virtual css::uno::Reference< css::beans::XPropertySet > getObject()
const css::uno::Reference< css::report::XGroup > & getGroup() const
Definition: UndoActions.hxx:59
OUndoGroupSectionAction(SdrModel &rMod, Action _eAction,::std::function< css::uno::Reference< css::report::XSection >(OGroupHelper *)> _pMemberFunction, const css::uno::Reference< css::report::XGroup > &_xGroup, const css::uno::Reference< css::uno::XInterface > &xElem, const char *pCommentId)
css::uno::Reference< css::container::XIndexContainer > m_xContainer
size_t LeaveListAction()
SfxUndoManager & m_rUndoManager
css::uno::Reference< css::report::XSection > getHeader()
Definition: UndoActions.hxx:57
css::uno::Reference< css::beans::XPropertySet > m_xObj
css::uno::Reference< css::report::XGroup > m_xGroup
Definition: UndoActions.hxx:49
OUndoContainerAction(OUndoContainerAction const &)=delete
css::uno::Reference< css::uno::XInterface > m_xOwnElement
css::uno::Reference< css::report::XSection > getPageFooter()
Definition: UndoActions.hxx:81
OUndoPropertyGroupSectionAction(SdrModel &rMod, const css::beans::PropertyChangeEvent &evt,::std::function< css::uno::Reference< css::report::XSection >(OGroupHelper *)> _pMemberFunction, const css::uno::Reference< css::report::XGroup > &_xGroup)
virtual void implReRemove() override
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
virtual void Undo() override
ORptUndoPropertyAction(SdrModel &rMod, const css::beans::PropertyChangeEvent &evt)
css::uno::Reference< css::report::XSection > getReportFooter()
Definition: UndoActions.hxx:79
::std::function< css::uno::Reference< css::report::XSection >OReportHelper *)> m_pMemberFunction
css::uno::Reference< css::report::XSection > getFooter()
Definition: UndoActions.hxx:58
virtual void Redo() override
virtual ~OUndoContainerAction() override
::std::function< css::uno::Reference< css::report::XSection >OGroupHelper *)> m_pMemberFunction
Helper class to allow std::mem_fun for SAL_CALL.
Definition: UndoActions.hxx:47