1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
20 #define INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
24 #include "RptModel.hxx"
26 #include <com/sun/star/util/XModifyListener.hpp>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
29 #include <com/sun/star/container/XNameContainer.hpp>
30 #include <com/sun/star/container/ContainerEvent.hpp>
31 #include <com/sun/star/report/XReportDefinition.hpp>
32 #include <com/sun/star/report/XGroup.hpp>
33 #include <com/sun/star/document/XUndoManager.hpp>
35 #include <svl/lstner.hxx>
36 #include <svx/svdouno.hxx>
37 #include <svx/svdundo.hxx>
53 /** Helper class to allow std::mem_fun for SAL_CALL
55 class REPORTDESIGN_DLLPUBLIC OGroupHelper
57 css::uno::Reference
< css::report::XGroup
> m_xGroup
;
58 OGroupHelper(const OGroupHelper
&) = delete;
59 OGroupHelper
& operator=(const OGroupHelper
&) = delete;
61 OGroupHelper(const css::uno::Reference
< css::report::XGroup
>& _xGroup
)
65 css::uno::Reference
< css::report::XSection
> getHeader() { return m_xGroup
->getHeader(); }
66 css::uno::Reference
< css::report::XSection
> getFooter() { return m_xGroup
->getFooter(); }
67 const css::uno::Reference
< css::report::XGroup
>& getGroup() const { return m_xGroup
; }
69 bool getHeaderOn() { return m_xGroup
->getHeaderOn(); }
70 bool getFooterOn() { return m_xGroup
->getFooterOn(); }
72 static ::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> getMemberFunction(const css::uno::Reference
< css::report::XSection
>& _xSection
);
76 /** Helper class to allow std::mem_fun for SAL_CALL
78 class REPORTDESIGN_DLLPUBLIC OReportHelper
80 css::uno::Reference
< css::report::XReportDefinition
> m_xReport
;
82 OReportHelper(const css::uno::Reference
< css::report::XReportDefinition
>& _xReport
)
86 css::uno::Reference
< css::report::XSection
> getReportHeader() { return m_xReport
->getReportHeader(); }
87 css::uno::Reference
< css::report::XSection
> getReportFooter() { return m_xReport
->getReportFooter(); }
88 css::uno::Reference
< css::report::XSection
> getPageHeader() { return m_xReport
->getPageHeader(); }
89 css::uno::Reference
< css::report::XSection
> getPageFooter() { return m_xReport
->getPageFooter(); }
90 css::uno::Reference
< css::report::XSection
> getDetail() { return m_xReport
->getDetail(); }
92 bool getReportHeaderOn() { return m_xReport
->getReportHeaderOn(); }
93 bool getReportFooterOn() { return m_xReport
->getReportFooterOn(); }
94 bool getPageHeaderOn() { return m_xReport
->getPageHeaderOn(); }
95 bool getPageFooterOn() { return m_xReport
->getPageFooterOn(); }
97 static ::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> getMemberFunction(const css::uno::Reference
< css::report::XSection
>& _xSection
);
106 UndoContext( SfxUndoManager
& i_undoManager
, const OUString
& i_undoTitle
)
107 :m_rUndoManager( i_undoManager
)
109 m_rUndoManager
.EnterListAction( i_undoTitle
, OUString(), 0, ViewShellId(-1) );
114 m_rUndoManager
.LeaveListAction();
118 SfxUndoManager
& m_rUndoManager
;
127 UndoSuppressor( SfxUndoManager
& i_undoManager
)
128 :m_rUndoManager( i_undoManager
)
130 m_rUndoManager
.EnableUndo( false );
135 m_rUndoManager
.EnableUndo( true );
139 SfxUndoManager
& m_rUndoManager
;
143 //= OCommentUndoAction
145 class REPORTDESIGN_DLLPUBLIC OCommentUndoAction
: public SdrUndoAction
148 OUString m_strComment
; // undo, redo comment
149 ::dbaui::IController
* m_pController
;
152 OCommentUndoAction(SdrModel
& rMod
, const char* pCommentID
);
153 virtual ~OCommentUndoAction() override
;
155 virtual OUString
GetComment() const override
{ return m_strComment
; }
156 virtual void Undo() override
;
157 virtual void Redo() override
;
160 // OUndoContainerAction
162 class REPORTDESIGN_DLLPUBLIC OUndoContainerAction
: public OCommentUndoAction
164 OUndoContainerAction(OUndoContainerAction
const &) = delete;
165 void operator =(OUndoContainerAction
const &) = delete;
167 css::uno::Reference
< css::uno::XInterface
>
168 m_xElement
; // object not owned by the action
169 css::uno::Reference
< css::uno::XInterface
>
170 m_xOwnElement
; // object owned by the action
171 css::uno::Reference
< css::container::XIndexContainer
>
173 Action
const m_eAction
;
176 OUndoContainerAction(SdrModel
& rMod
178 ,const css::uno::Reference
< css::container::XIndexContainer
>& rContainer
179 ,const css::uno::Reference
< css::uno::XInterface
>& xElem
180 ,const char* pCommentId
);
181 virtual ~OUndoContainerAction() override
;
183 virtual void Undo() override
;
184 virtual void Redo() override
;
187 virtual void implReInsert( );
188 virtual void implReRemove( );
192 // OUndoReportSectionAction
194 class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction
: public OUndoContainerAction
196 OReportHelper m_aReportHelper
;
197 ::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> m_pMemberFunction
;
199 OUndoReportSectionAction(SdrModel
& rMod
201 ,::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> _pMemberFunction
202 ,const css::uno::Reference
< css::report::XReportDefinition
>& _xReport
203 ,const css::uno::Reference
< css::uno::XInterface
>& xElem
204 ,const char* pCommentId
);
207 virtual void implReInsert( ) override
;
208 virtual void implReRemove( ) override
;
212 // OUndoGroupSectionAction
213 class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction
: public OUndoContainerAction
215 OGroupHelper m_aGroupHelper
;
216 ::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> m_pMemberFunction
;
218 OUndoGroupSectionAction(SdrModel
& rMod
220 ,::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> _pMemberFunction
221 ,const css::uno::Reference
< css::report::XGroup
>& _xGroup
222 ,const css::uno::Reference
< css::uno::XInterface
>& xElem
223 ,const char* pCommentId
);
226 virtual void implReInsert( ) override
;
227 virtual void implReRemove( ) override
;
230 // ORptUndoPropertyAction
231 class REPORTDESIGN_DLLPUBLIC ORptUndoPropertyAction
: public OCommentUndoAction
233 css::uno::Reference
< css::beans::XPropertySet
> m_xObj
;
234 OUString
const m_aPropertyName
;
235 css::uno::Any
const m_aNewValue
;
236 css::uno::Any
const m_aOldValue
;
238 /** sets either the old value or the new value again at the property set.
240 * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
242 void setProperty(bool _bOld
);
244 virtual css::uno::Reference
< css::beans::XPropertySet
> getObject();
247 ORptUndoPropertyAction(SdrModel
& rMod
, const css::beans::PropertyChangeEvent
& evt
);
249 virtual void Undo() override
;
250 virtual void Redo() override
;
252 virtual OUString
GetComment() const override
;
256 // OUndoPropertyReportSectionAction
258 class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction
: public ORptUndoPropertyAction
260 OReportHelper m_aReportHelper
;
261 ::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> m_pMemberFunction
;
263 virtual css::uno::Reference
< css::beans::XPropertySet
> getObject() override
;
265 OUndoPropertyReportSectionAction(SdrModel
& rMod
266 ,const css::beans::PropertyChangeEvent
& evt
267 ,::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> _pMemberFunction
268 ,const css::uno::Reference
< css::report::XReportDefinition
>& _xReport
273 // OUndoPropertyGroupSectionAction
275 class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction
: public ORptUndoPropertyAction
277 OGroupHelper m_aGroupHelper
;
278 ::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> m_pMemberFunction
;
280 virtual css::uno::Reference
< css::beans::XPropertySet
> getObject() override
;
282 OUndoPropertyGroupSectionAction(SdrModel
& rMod
283 ,const css::beans::PropertyChangeEvent
& evt
284 ,::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> _pMemberFunction
285 ,const css::uno::Reference
< css::report::XGroup
>& _xGroup
290 #endif // INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */