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 <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>
29 #include <svx/svdundo.hxx>
46 /** Helper class to allow std::mem_fun for SAL_CALL
50 css::uno::Reference
< css::report::XGroup
> m_xGroup
;
51 OGroupHelper(const OGroupHelper
&) = delete;
52 OGroupHelper
& operator=(const OGroupHelper
&) = delete;
54 OGroupHelper(css::uno::Reference
< css::report::XGroup
> _xGroup
)
55 :m_xGroup(std::move(_xGroup
))
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
; }
62 bool getHeaderOn() { return m_xGroup
->getHeaderOn(); }
63 bool getFooterOn() { return m_xGroup
->getFooterOn(); }
65 static ::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> getMemberFunction(const css::uno::Reference
< css::report::XSection
>& _xSection
);
69 /** Helper class to allow std::mem_fun for SAL_CALL
73 css::uno::Reference
< css::report::XReportDefinition
> m_xReport
;
75 OReportHelper(css::uno::Reference
< css::report::XReportDefinition
> _xReport
)
76 :m_xReport(std::move(_xReport
))
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(); }
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(); }
90 static ::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> getMemberFunction(const css::uno::Reference
< css::report::XSection
>& _xSection
);
99 UndoContext( SfxUndoManager
& i_undoManager
, const OUString
& i_undoTitle
)
100 :m_rUndoManager( i_undoManager
)
102 m_rUndoManager
.EnterListAction( i_undoTitle
, OUString(), 0, ViewShellId(-1) );
107 m_rUndoManager
.LeaveListAction();
111 SfxUndoManager
& m_rUndoManager
;
120 UndoSuppressor( SfxUndoManager
& i_undoManager
)
121 :m_rUndoManager( i_undoManager
)
123 m_rUndoManager
.EnableUndo( false );
128 m_rUndoManager
.EnableUndo( true );
132 SfxUndoManager
& m_rUndoManager
;
136 //= OCommentUndoAction
138 class UNLESS_MERGELIBS_MORE(REPORTDESIGN_DLLPUBLIC
) OCommentUndoAction
: public SdrUndoAction
141 OUString m_strComment
; // undo, redo comment
142 ::dbaui::IController
* m_pController
;
145 OCommentUndoAction(SdrModel
& rMod
, TranslateId pCommentID
);
146 virtual ~OCommentUndoAction() override
;
148 virtual OUString
GetComment() const override
{ return m_strComment
; }
149 virtual void Undo() override
;
150 virtual void Redo() override
;
153 // OUndoContainerAction
155 class OUndoContainerAction
: public OCommentUndoAction
157 OUndoContainerAction(OUndoContainerAction
const &) = delete;
158 void operator =(OUndoContainerAction
const &) = delete;
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
>
169 OUndoContainerAction(SdrModel
& rMod
171 ,css::uno::Reference
< css::container::XIndexContainer
> xContainer
172 ,const css::uno::Reference
< css::uno::XInterface
>& xElem
173 ,TranslateId pCommentId
);
174 virtual ~OUndoContainerAction() override
;
176 virtual void Undo() override
;
177 virtual void Redo() override
;
180 virtual void implReInsert( );
181 virtual void implReRemove( );
185 // OUndoReportSectionAction
187 class OUndoReportSectionAction final
: public OUndoContainerAction
189 OReportHelper m_aReportHelper
;
190 ::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> m_pMemberFunction
;
192 OUndoReportSectionAction(SdrModel
& rMod
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
);
200 virtual void implReInsert( ) override
;
201 virtual void implReRemove( ) override
;
205 // OUndoGroupSectionAction
206 class OUndoGroupSectionAction final
: public OUndoContainerAction
208 OGroupHelper m_aGroupHelper
;
209 ::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> m_pMemberFunction
;
211 OUndoGroupSectionAction(SdrModel
& rMod
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
);
219 virtual void implReInsert( ) override
;
220 virtual void implReRemove( ) override
;
223 // ORptUndoPropertyAction
224 class ORptUndoPropertyAction
: public OCommentUndoAction
226 css::uno::Reference
< css::beans::XPropertySet
> m_xObj
;
227 OUString m_aPropertyName
;
228 css::uno::Any m_aNewValue
;
229 css::uno::Any m_aOldValue
;
231 /** sets either the old value or the new value again at the property set.
233 * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
235 void setProperty(bool _bOld
);
237 virtual css::uno::Reference
< css::beans::XPropertySet
> getObject();
240 ORptUndoPropertyAction(SdrModel
& rMod
, const css::beans::PropertyChangeEvent
& evt
);
242 virtual void Undo() override
;
243 virtual void Redo() override
;
245 virtual OUString
GetComment() const override
;
249 // OUndoPropertyReportSectionAction
251 class OUndoPropertyReportSectionAction final
: public ORptUndoPropertyAction
253 OReportHelper m_aReportHelper
;
254 ::std::function
<css::uno::Reference
< css::report::XSection
>(OReportHelper
*)> m_pMemberFunction
;
256 virtual css::uno::Reference
< css::beans::XPropertySet
> getObject() override
;
258 OUndoPropertyReportSectionAction(SdrModel
& rMod
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
266 // OUndoPropertyGroupSectionAction
268 class OUndoPropertyGroupSectionAction final
: public ORptUndoPropertyAction
270 OGroupHelper m_aGroupHelper
;
271 ::std::function
<css::uno::Reference
< css::report::XSection
>(OGroupHelper
*)> m_pMemberFunction
;
273 virtual css::uno::Reference
< css::beans::XPropertySet
> getObject() override
;
275 OUndoPropertyGroupSectionAction(SdrModel
& rMod
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
283 #endif // INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */