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 <comphelper/sequence.hxx>
36 #include <svl/lstner.hxx>
37 #include <svx/svdouno.hxx>
38 #include <svx/svdundo.hxx>
54 /** Helper class to allow std::mem_fun for SAL_CALL
56 class REPORTDESIGN_DLLPUBLIC OGroupHelper
58 css::uno::Reference
< css::report::XGroup
> m_xGroup
;
59 OGroupHelper(const OGroupHelper
&) = delete;
60 OGroupHelper
& operator=(const OGroupHelper
&) = delete;
62 OGroupHelper(const css::uno::Reference
< css::report::XGroup
>& _xGroup
)
66 css::uno::Reference
< css::report::XSection
> getHeader() { return m_xGroup
->getHeader(); }
67 css::uno::Reference
< css::report::XSection
> getFooter() { return m_xGroup
->getFooter(); }
68 const css::uno::Reference
< css::report::XGroup
>& getGroup() { return m_xGroup
; }
70 bool getHeaderOn() { return m_xGroup
->getHeaderOn(); }
71 bool getFooterOn() { return m_xGroup
->getFooterOn(); }
73 static ::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> getMemberFunction(const css::uno::Reference
< css::report::XSection
>& _xSection
);
77 /** Helper class to allow std::mem_fun for SAL_CALL
79 class REPORTDESIGN_DLLPUBLIC OReportHelper
81 css::uno::Reference
< css::report::XReportDefinition
> m_xReport
;
83 OReportHelper(const css::uno::Reference
< css::report::XReportDefinition
>& _xReport
)
87 css::uno::Reference
< css::report::XSection
> getReportHeader() { return m_xReport
->getReportHeader(); }
88 css::uno::Reference
< css::report::XSection
> getReportFooter() { return m_xReport
->getReportFooter(); }
89 css::uno::Reference
< css::report::XSection
> getPageHeader() { return m_xReport
->getPageHeader(); }
90 css::uno::Reference
< css::report::XSection
> getPageFooter() { return m_xReport
->getPageFooter(); }
91 css::uno::Reference
< css::report::XSection
> getDetail() { return m_xReport
->getDetail(); }
93 bool getReportHeaderOn() { return m_xReport
->getReportHeaderOn(); }
94 bool getReportFooterOn() { return m_xReport
->getReportFooterOn(); }
95 bool getPageHeaderOn() { return m_xReport
->getPageHeaderOn(); }
96 bool getPageFooterOn() { return m_xReport
->getPageFooterOn(); }
98 static ::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> getMemberFunction(const css::uno::Reference
< css::report::XSection
>& _xSection
);
107 UndoContext( SfxUndoManager
& i_undoManager
, const OUString
& i_undoTitle
)
108 :m_rUndoManager( i_undoManager
)
110 m_rUndoManager
.EnterListAction( i_undoTitle
, OUString(), 0, ViewShellId(-1) );
115 m_rUndoManager
.LeaveListAction();
119 SfxUndoManager
& m_rUndoManager
;
128 UndoSuppressor( SfxUndoManager
& i_undoManager
)
129 :m_rUndoManager( i_undoManager
)
131 m_rUndoManager
.EnableUndo( false );
136 m_rUndoManager
.EnableUndo( true );
140 SfxUndoManager
& m_rUndoManager
;
144 //= OCommentUndoAction
146 class REPORTDESIGN_DLLPUBLIC OCommentUndoAction
: public SdrUndoAction
149 OUString m_strComment
; // undo, redo comment
150 ::dbaui::IController
* m_pController
;
153 OCommentUndoAction(SdrModel
& rMod
, const char* pCommentID
);
154 virtual ~OCommentUndoAction() override
;
156 virtual OUString
GetComment() const override
{ return m_strComment
; }
157 virtual void Undo() override
;
158 virtual void Redo() override
;
161 // OUndoContainerAction
163 class REPORTDESIGN_DLLPUBLIC OUndoContainerAction
: public OCommentUndoAction
165 OUndoContainerAction(OUndoContainerAction
&) = delete;
166 void operator =(OUndoContainerAction
&) = delete;
168 css::uno::Reference
< css::uno::XInterface
>
169 m_xElement
; // object not owned by the action
170 css::uno::Reference
< css::uno::XInterface
>
171 m_xOwnElement
; // object owned by the action
172 css::uno::Reference
< css::container::XIndexContainer
>
177 OUndoContainerAction(SdrModel
& rMod
179 ,const css::uno::Reference
< css::container::XIndexContainer
>& rContainer
180 ,const css::uno::Reference
< css::uno::XInterface
>& xElem
181 ,const char* pCommentId
);
182 virtual ~OUndoContainerAction() override
;
184 virtual void Undo() override
;
185 virtual void Redo() override
;
188 virtual void implReInsert( );
189 virtual void implReRemove( );
193 // OUndoReportSectionAction
195 class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction
: public OUndoContainerAction
197 OReportHelper m_aReportHelper
;
198 ::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> m_pMemberFunction
;
200 OUndoReportSectionAction(SdrModel
& rMod
202 ,::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> _pMemberFunction
203 ,const css::uno::Reference
< css::report::XReportDefinition
>& _xReport
204 ,const css::uno::Reference
< css::uno::XInterface
>& xElem
205 ,const char* pCommentId
);
208 virtual void implReInsert( ) override
;
209 virtual void implReRemove( ) override
;
213 // OUndoGroupSectionAction
214 class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction
: public OUndoContainerAction
216 OGroupHelper m_aGroupHelper
;
217 ::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> m_pMemberFunction
;
219 OUndoGroupSectionAction(SdrModel
& rMod
221 ,::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> _pMemberFunction
222 ,const css::uno::Reference
< css::report::XGroup
>& _xGroup
223 ,const css::uno::Reference
< css::uno::XInterface
>& xElem
224 ,const char* pCommentId
);
227 virtual void implReInsert( ) override
;
228 virtual void implReRemove( ) override
;
231 // ORptUndoPropertyAction
232 class REPORTDESIGN_DLLPUBLIC ORptUndoPropertyAction
: public OCommentUndoAction
234 css::uno::Reference
< css::beans::XPropertySet
> m_xObj
;
235 OUString m_aPropertyName
;
236 css::uno::Any m_aNewValue
;
237 css::uno::Any m_aOldValue
;
239 /** sets either the old value or the new value again at the property set.
241 * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
243 void setProperty(bool _bOld
);
245 virtual css::uno::Reference
< css::beans::XPropertySet
> getObject();
248 ORptUndoPropertyAction(SdrModel
& rMod
, const css::beans::PropertyChangeEvent
& evt
);
250 virtual void Undo() override
;
251 virtual void Redo() override
;
253 virtual OUString
GetComment() const override
;
257 // OUndoPropertyReportSectionAction
259 class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction
: public ORptUndoPropertyAction
261 OReportHelper m_aReportHelper
;
262 ::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> m_pMemberFunction
;
264 virtual css::uno::Reference
< css::beans::XPropertySet
> getObject() override
;
266 OUndoPropertyReportSectionAction(SdrModel
& rMod
267 ,const css::beans::PropertyChangeEvent
& evt
268 ,::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> _pMemberFunction
269 ,const css::uno::Reference
< css::report::XReportDefinition
>& _xReport
274 // OUndoPropertyGroupSectionAction
276 class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction
: public ORptUndoPropertyAction
278 OGroupHelper m_aGroupHelper
;
279 ::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> m_pMemberFunction
;
281 virtual css::uno::Reference
< css::beans::XPropertySet
> getObject() override
;
283 OUndoPropertyGroupSectionAction(SdrModel
& rMod
284 ,const css::beans::PropertyChangeEvent
& evt
285 ,::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> _pMemberFunction
286 ,const css::uno::Reference
< css::report::XGroup
>& _xGroup
291 #endif // INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
293 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */