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#include <utility>
33
34namespace dbaui
35{
36 class IController;
37}
38namespace rptui
39{
40 enum Action
41 {
43 Removed = 2
44 };
45
49 {
50 css::uno::Reference< css::report::XGroup > m_xGroup;
51 OGroupHelper(const OGroupHelper&) = delete;
53 public:
54 OGroupHelper(css::uno::Reference< css::report::XGroup > _xGroup)
55 :m_xGroup(std::move(_xGroup))
56 {
57 }
58 css::uno::Reference< css::report::XSection > getHeader() { return m_xGroup->getHeader(); }
59 css::uno::Reference< css::report::XSection > getFooter() { return m_xGroup->getFooter(); }
60 const css::uno::Reference< css::report::XGroup >& getGroup() const { return m_xGroup; }
61
62 bool getHeaderOn() { return m_xGroup->getHeaderOn(); }
63 bool getFooterOn() { return m_xGroup->getFooterOn(); }
64
65 static ::std::function<css::uno::Reference< css::report::XSection>(OGroupHelper *)> getMemberFunction(const css::uno::Reference< css::report::XSection >& _xSection);
66
67 };
68
72 {
73 css::uno::Reference< css::report::XReportDefinition > m_xReport;
74 public:
75 OReportHelper(css::uno::Reference< css::report::XReportDefinition > _xReport)
76 :m_xReport(std::move(_xReport))
77 {
78 }
79 css::uno::Reference< css::report::XSection > getReportHeader() { return m_xReport->getReportHeader(); }
80 css::uno::Reference< css::report::XSection > getReportFooter() { return m_xReport->getReportFooter(); }
81 css::uno::Reference< css::report::XSection > getPageHeader() { return m_xReport->getPageHeader(); }
82 css::uno::Reference< css::report::XSection > getPageFooter() { return m_xReport->getPageFooter(); }
83 css::uno::Reference< css::report::XSection > getDetail() { return m_xReport->getDetail(); }
84
85 bool getReportHeaderOn() { return m_xReport->getReportHeaderOn(); }
86 bool getReportFooterOn() { return m_xReport->getReportFooterOn(); }
87 bool getPageHeaderOn() { return m_xReport->getPageHeaderOn(); }
88 bool getPageFooterOn() { return m_xReport->getPageFooterOn(); }
89
90 static ::std::function<css::uno::Reference< css::report::XSection>(OReportHelper *)> getMemberFunction(const css::uno::Reference< css::report::XSection >& _xSection);
91 };
92
93
94 //= UndoContext
95
97 {
98 public:
99 UndoContext( SfxUndoManager& i_undoManager, const OUString& i_undoTitle )
100 :m_rUndoManager( i_undoManager )
101 {
102 m_rUndoManager.EnterListAction( i_undoTitle, OUString(), 0, ViewShellId(-1) );
103 }
104
106 {
108 }
109
110 private:
112 };
113
114
115 //= UndoSuppressor
116
118 {
119 public:
121 :m_rUndoManager( i_undoManager )
122 {
123 m_rUndoManager.EnableUndo( false );
124 }
125
127 {
129 }
130
131 private:
133 };
134
135
136 //= OCommentUndoAction
137
139 {
140 protected:
141 OUString m_strComment; // undo, redo comment
143
144 public:
145 OCommentUndoAction(SdrModel& rMod, TranslateId pCommentID);
146 virtual ~OCommentUndoAction() override;
147
148 virtual OUString GetComment() const override { return m_strComment; }
149 virtual void Undo() override;
150 virtual void Redo() override;
151 };
152
153 // OUndoContainerAction
154
156 {
158 void operator =(OUndoContainerAction const &) = delete;
159 protected:
160 css::uno::Reference< css::uno::XInterface >
161 m_xElement; // object not owned by the action
162 css::uno::Reference< css::uno::XInterface >
163 m_xOwnElement; // object owned by the action
164 css::uno::Reference< css::container::XIndexContainer >
167
168 public:
170 ,Action _eAction
171 ,css::uno::Reference< css::container::XIndexContainer > xContainer
172 ,const css::uno::Reference< css::uno::XInterface>& xElem
173 ,TranslateId pCommentId);
174 virtual ~OUndoContainerAction() override;
175
176 virtual void Undo() override;
177 virtual void Redo() override;
178
179 protected:
180 virtual void implReInsert( );
181 virtual void implReRemove( );
182 };
183
184
185 // OUndoReportSectionAction
186
188 {
190 ::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> m_pMemberFunction;
191 public:
193 ,Action _eAction
194 ,::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> _pMemberFunction
195 ,const css::uno::Reference< css::report::XReportDefinition >& _xReport
196 ,const css::uno::Reference< css::uno::XInterface>& xElem
197 ,TranslateId pCommentId);
198
199 private:
200 virtual void implReInsert( ) override;
201 virtual void implReRemove( ) override;
202 };
203
204
205 // OUndoGroupSectionAction
207 {
209 ::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> m_pMemberFunction;
210 public:
212 ,Action _eAction
213 ,::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> _pMemberFunction
214 ,const css::uno::Reference< css::report::XGroup >& _xGroup
215 ,const css::uno::Reference< css::uno::XInterface>& xElem
216 ,TranslateId pCommentId);
217
218 private:
219 virtual void implReInsert( ) override;
220 virtual void implReRemove( ) override;
221 };
222
223 // ORptUndoPropertyAction
225 {
226 css::uno::Reference< css::beans::XPropertySet> m_xObj;
228 css::uno::Any m_aNewValue;
229 css::uno::Any m_aOldValue;
230
235 void setProperty(bool _bOld);
236 protected:
237 virtual css::uno::Reference< css::beans::XPropertySet> getObject();
238
239 public:
240 ORptUndoPropertyAction(SdrModel& rMod, const css::beans::PropertyChangeEvent& evt);
241
242 virtual void Undo() override;
243 virtual void Redo() override;
244
245 virtual OUString GetComment() const override;
246 };
247
248
249 // OUndoPropertyReportSectionAction
250
252 {
254 ::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> m_pMemberFunction;
255
256 virtual css::uno::Reference< css::beans::XPropertySet> getObject() override;
257 public:
259 ,const css::beans::PropertyChangeEvent& evt
260 ,::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> _pMemberFunction
261 ,const css::uno::Reference< css::report::XReportDefinition >& _xReport
262 );
263 };
264
265
266 // OUndoPropertyGroupSectionAction
267
269 {
271 ::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> m_pMemberFunction;
272
273 virtual css::uno::Reference< css::beans::XPropertySet> getObject() override;
274 public:
276 ,const css::beans::PropertyChangeEvent& evt
277 ,::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> _pMemberFunction
278 ,const css::uno::Reference< css::report::XGroup >& _xGroup
279 );
280 };
281
282}
283#endif // INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
284
285/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdrModel & rMod
size_t LeaveListAction()
void EnableUndo(bool bEnable)
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
virtual OUString GetComment() const override
::dbaui::IController * m_pController
Helper class to allow std::mem_fun for SAL_CALL.
Definition: UndoActions.hxx:49
css::uno::Reference< css::report::XSection > getHeader()
Definition: UndoActions.hxx:58
css::uno::Reference< css::report::XSection > getFooter()
Definition: UndoActions.hxx:59
static ::std::function< css::uno::Reference< css::report::XSection >(OGroupHelper *)> getMemberFunction(const css::uno::Reference< css::report::XSection > &_xSection)
Definition: UndoActions.cxx:46
css::uno::Reference< css::report::XGroup > m_xGroup
Definition: UndoActions.hxx:50
OGroupHelper(const OGroupHelper &)=delete
OGroupHelper(css::uno::Reference< css::report::XGroup > _xGroup)
Definition: UndoActions.hxx:54
const css::uno::Reference< css::report::XGroup > & getGroup() const
Definition: UndoActions.hxx:60
OGroupHelper & operator=(const OGroupHelper &)=delete
Helper class to allow std::mem_fun for SAL_CALL.
Definition: UndoActions.hxx:72
css::uno::Reference< css::report::XSection > getPageFooter()
Definition: UndoActions.hxx:82
OReportHelper(css::uno::Reference< css::report::XReportDefinition > _xReport)
Definition: UndoActions.hxx:75
css::uno::Reference< css::report::XReportDefinition > m_xReport
Definition: UndoActions.hxx:73
css::uno::Reference< css::report::XSection > getReportFooter()
Definition: UndoActions.hxx:80
css::uno::Reference< css::report::XSection > getDetail()
Definition: UndoActions.hxx:83
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:79
css::uno::Reference< css::report::XSection > getPageHeader()
Definition: UndoActions.hxx:81
ORptUndoPropertyAction(SdrModel &rMod, const css::beans::PropertyChangeEvent &evt)
virtual void Redo() override
css::uno::Reference< css::beans::XPropertySet > m_xObj
void setProperty(bool _bOld)
sets either the old value or the new value again at the property set.
virtual css::uno::Reference< css::beans::XPropertySet > getObject()
virtual OUString GetComment() const override
virtual void Undo() override
css::uno::Reference< css::container::XIndexContainer > m_xContainer
virtual void Undo() override
void operator=(OUndoContainerAction const &)=delete
OUndoContainerAction(SdrModel &rMod, Action _eAction, css::uno::Reference< css::container::XIndexContainer > xContainer, const css::uno::Reference< css::uno::XInterface > &xElem, TranslateId pCommentId)
css::uno::Reference< css::uno::XInterface > m_xElement
css::uno::Reference< css::uno::XInterface > m_xOwnElement
virtual void Redo() override
OUndoContainerAction(OUndoContainerAction const &)=delete
virtual ~OUndoContainerAction() override
virtual void implReRemove() override
virtual void implReInsert() override
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, TranslateId pCommentId)
::std::function< css::uno::Reference< css::report::XSection >(OGroupHelper *)> m_pMemberFunction
::std::function< css::uno::Reference< css::report::XSection >(OGroupHelper *)> m_pMemberFunction
virtual css::uno::Reference< css::beans::XPropertySet > getObject() override
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)
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)
::std::function< css::uno::Reference< css::report::XSection >(OReportHelper *)> m_pMemberFunction
virtual css::uno::Reference< css::beans::XPropertySet > getObject() override
virtual void implReRemove() override
virtual void implReInsert() override
::std::function< css::uno::Reference< css::report::XSection >(OReportHelper *)> m_pMemberFunction
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, TranslateId pCommentId)
SfxUndoManager & m_rUndoManager
UndoContext(SfxUndoManager &i_undoManager, const OUString &i_undoTitle)
Definition: UndoActions.hxx:99
SfxUndoManager & m_rUndoManager
UndoSuppressor(SfxUndoManager &i_undoManager)
#define REPORTDESIGN_DLLPUBLIC
Definition: dllapi.h:28
@ Inserted
Definition: UndoActions.hxx:42