bump product version to 5.0.4.1
[LibreOffice.git] / reportdesign / inc / UndoActions.hxx
blob72dd6193146f82ffc6f7f38b52f95b7aefb59249
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
22 #include "dllapi.h"
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/script/ScriptEvent.hpp>
30 #include <com/sun/star/script/XScriptListener.hpp>
31 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
32 #include <com/sun/star/container/XNameContainer.hpp>
33 #include <com/sun/star/container/ContainerEvent.hpp>
34 #include <com/sun/star/report/XReportComponent.hpp>
35 #include <com/sun/star/report/XReportDefinition.hpp>
36 #include <com/sun/star/report/XGroup.hpp>
37 #include <com/sun/star/document/XUndoManager.hpp>
39 #include <cppuhelper/implbase3.hxx>
40 #include <comphelper/uno3.hxx>
41 #include <comphelper/sequence.hxx>
42 #include <svl/lstner.hxx>
43 #include <svx/svdouno.hxx>
44 #include <svx/svdundo.hxx>
46 #include <functional>
48 namespace dbaui
50 class IController;
52 namespace rptui
54 enum Action
56 Inserted = 1,
57 Removed = 2
60 /** Helper class to allow std::mem_fun for SAL_CALL
62 class REPORTDESIGN_DLLPUBLIC OGroupHelper
64 ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > m_xGroup;
65 OGroupHelper(const OGroupHelper&) SAL_DELETED_FUNCTION;
66 OGroupHelper& operator=(const OGroupHelper&) SAL_DELETED_FUNCTION;
67 public:
68 OGroupHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup)
69 :m_xGroup(_xGroup)
72 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getHeader() { return m_xGroup->getHeader(); }
73 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getFooter() { return m_xGroup->getFooter(); }
74 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > getGroup() { return m_xGroup; }
76 inline bool getHeaderOn() { return m_xGroup->getHeaderOn(); }
77 inline bool getFooterOn() { return m_xGroup->getFooterOn(); }
79 static ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> , OGroupHelper> getMemberFunction(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection);
82 typedef com::sun::star::uno::Reference< ::com::sun::star::report::XSection > TSection;
84 /** Helper class to allow std::mem_fun for SAL_CALL
86 class REPORTDESIGN_DLLPUBLIC OReportHelper
88 ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xReport;
89 public:
90 OReportHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport)
91 :m_xReport(_xReport)
94 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportHeader() { return m_xReport->getReportHeader(); }
95 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportFooter() { return m_xReport->getReportFooter(); }
96 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageHeader() { return m_xReport->getPageHeader(); }
97 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageFooter() { return m_xReport->getPageFooter(); }
98 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getDetail() { return m_xReport->getDetail(); }
100 inline bool getReportHeaderOn() { return m_xReport->getReportHeaderOn(); }
101 inline bool getReportFooterOn() { return m_xReport->getReportFooterOn(); }
102 inline bool getPageHeaderOn() { return m_xReport->getPageHeaderOn(); }
103 inline bool getPageFooterOn() { return m_xReport->getPageFooterOn(); }
105 static ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> , OReportHelper> getMemberFunction(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection);
109 //= UndoContext
111 class UndoContext
113 public:
114 UndoContext( SfxUndoManager& i_undoManager, const OUString& i_undoTitle )
115 :m_rUndoManager( i_undoManager )
117 m_rUndoManager.EnterListAction( i_undoTitle, OUString() );
120 ~UndoContext()
122 m_rUndoManager.LeaveListAction();
125 private:
126 SfxUndoManager& m_rUndoManager;
130 //= UndoSuppressor
132 class UndoSuppressor
134 public:
135 UndoSuppressor( SfxUndoManager& i_undoManager )
136 :m_rUndoManager( i_undoManager )
138 m_rUndoManager.EnableUndo( false );
141 ~UndoSuppressor()
143 m_rUndoManager.EnableUndo( true );
146 private:
147 SfxUndoManager& m_rUndoManager;
151 //= OCommentUndoAction
153 class REPORTDESIGN_DLLPUBLIC OCommentUndoAction : public SdrUndoAction
155 protected:
156 OUString m_strComment; // undo, redo comment
157 ::dbaui::IController* m_pController;
159 public:
160 TYPEINFO_OVERRIDE();
161 OCommentUndoAction( SdrModel& rMod
162 ,sal_uInt16 nCommentID);
163 virtual ~OCommentUndoAction();
165 virtual OUString GetComment() const SAL_OVERRIDE { return m_strComment; }
166 virtual void Undo() SAL_OVERRIDE;
167 virtual void Redo() SAL_OVERRIDE;
170 // OUndoContainerAction
172 class REPORTDESIGN_DLLPUBLIC OUndoContainerAction: public OCommentUndoAction
174 OUndoContainerAction(OUndoContainerAction&) SAL_DELETED_FUNCTION;
175 void operator =(OUndoContainerAction&) SAL_DELETED_FUNCTION;
176 protected:
177 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
178 m_xElement; // object not owned by the action
179 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
180 m_xOwnElement; // object owned by the action
181 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
182 m_xContainer;
183 ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
184 m_xSection;
185 Action m_eAction;
187 public:
188 OUndoContainerAction(SdrModel& rMod
189 ,Action _eAction
190 ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rContainer
191 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
192 ,sal_uInt16 _nCommentId);
193 virtual ~OUndoContainerAction();
195 virtual void Undo() SAL_OVERRIDE;
196 virtual void Redo() SAL_OVERRIDE;
198 protected:
199 virtual void implReInsert( );
200 virtual void implReRemove( );
204 // OUndoReportSectionAction
206 class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction : public OUndoContainerAction
208 OReportHelper m_aReportHelper;
209 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
210 ,OReportHelper> m_pMemberFunction;
211 public:
212 OUndoReportSectionAction(SdrModel& rMod
213 ,Action _eAction
214 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
215 ,OReportHelper> _pMemberFunction
216 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
217 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
218 ,sal_uInt16 _nCommentId);
220 protected:
221 virtual void implReInsert( ) SAL_OVERRIDE;
222 virtual void implReRemove( ) SAL_OVERRIDE;
226 // OUndoGroupSectionAction
227 class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction : public OUndoContainerAction
229 OGroupHelper m_aGroupHelper;
230 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
231 ,OGroupHelper> m_pMemberFunction;
232 public:
233 OUndoGroupSectionAction(SdrModel& rMod
234 ,Action _eAction
235 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
236 ,OGroupHelper> _pMemberFunction
237 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
238 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
239 ,sal_uInt16 _nCommentId);
241 protected:
242 virtual void implReInsert( ) SAL_OVERRIDE;
243 virtual void implReRemove( ) SAL_OVERRIDE;
246 // ORptUndoPropertyAction
247 class REPORTDESIGN_DLLPUBLIC ORptUndoPropertyAction: public OCommentUndoAction
249 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xObj;
250 OUString m_aPropertyName;
251 ::com::sun::star::uno::Any m_aNewValue;
252 ::com::sun::star::uno::Any m_aOldValue;
254 /** sets either the old value or the new value again at the property set.
256 * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
258 void setProperty(bool _bOld);
259 protected:
260 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
262 public:
263 ORptUndoPropertyAction(SdrModel& rMod, const ::com::sun::star::beans::PropertyChangeEvent& evt);
265 virtual void Undo() SAL_OVERRIDE;
266 virtual void Redo() SAL_OVERRIDE;
268 virtual OUString GetComment() const SAL_OVERRIDE;
272 // OUndoPropertyReportSectionAction
274 class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction : public ORptUndoPropertyAction
276 OReportHelper m_aReportHelper;
277 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
278 ,OReportHelper> m_pMemberFunction;
279 protected:
280 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject() SAL_OVERRIDE;
281 public:
282 OUndoPropertyReportSectionAction(SdrModel& rMod
283 ,const ::com::sun::star::beans::PropertyChangeEvent& evt
284 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
285 ,OReportHelper> _pMemberFunction
286 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
291 // OUndoPropertyGroupSectionAction
293 class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction : public ORptUndoPropertyAction
295 OGroupHelper m_aGroupHelper;
296 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
297 ,OGroupHelper> m_pMemberFunction;
298 protected:
299 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject() SAL_OVERRIDE;
300 public:
301 OUndoPropertyGroupSectionAction(SdrModel& rMod
302 ,const ::com::sun::star::beans::PropertyChangeEvent& evt
303 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
304 ,OGroupHelper> _pMemberFunction
305 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
310 #endif // INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */