Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / reportdesign / inc / UndoActions.hxx
blobfbdb23843d10af12eaa80e86c67764c7c978dbb4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef RPTUI_UNDOACTIONS_HXX
29 #define RPTUI_UNDOACTIONS_HXX
31 #include "dllapi.h"
33 #include "RptModel.hxx"
35 /** === begin UNO includes === **/
36 #include <com/sun/star/util/XModifyListener.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
39 #include <com/sun/star/script/ScriptEvent.hpp>
40 #include <com/sun/star/script/XScriptListener.hpp>
41 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
42 #include <com/sun/star/container/XNameContainer.hpp>
43 #include <com/sun/star/container/ContainerEvent.hpp>
44 #include <com/sun/star/container/XNameContainer.hpp>
45 #include <com/sun/star/report/XReportComponent.hpp>
46 #include <com/sun/star/report/XReportDefinition.hpp>
47 #include <com/sun/star/report/XGroup.hpp>
48 #include <com/sun/star/document/XUndoManager.hpp>
49 /** === end UNO includes === **/
51 #include <cppuhelper/implbase3.hxx>
52 #include <comphelper/uno3.hxx>
53 #include <comphelper/sequence.hxx>
54 #include <svl/lstner.hxx>
55 #include <svx/svdouno.hxx>
56 #include <svx/svdundo.hxx>
57 #include <tools/string.hxx>
59 #include <functional>
60 #include <memory>
61 #include <boost/shared_ptr.hpp>
63 namespace com { namespace sun { namespace star {
64 namespace awt {
65 class XControl;
66 class XControlContainer;
68 }}}
70 namespace dbaui
72 class IController;
74 namespace rptui
76 class OObjectBase;
78 enum Action
80 Inserted = 1,
81 Removed = 2
84 /** Helper class to allow std::mem_fun for SAL_CALL
86 class REPORTDESIGN_DLLPUBLIC OGroupHelper
88 ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > m_xGroup;
89 OGroupHelper(const OGroupHelper&);
90 OGroupHelper& operator=(const OGroupHelper&);
91 public:
92 OGroupHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup)
93 :m_xGroup(_xGroup)
96 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getHeader() { return m_xGroup->getHeader(); }
97 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getFooter() { return m_xGroup->getFooter(); }
98 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > getGroup() { return m_xGroup; }
100 inline ::sal_Bool getHeaderOn() { return m_xGroup->getHeaderOn(); }
101 inline ::sal_Bool getFooterOn() { return m_xGroup->getFooterOn(); }
103 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);
106 typedef com::sun::star::uno::Reference< ::com::sun::star::report::XSection > TSection;
108 /** Helper class to allow std::mem_fun for SAL_CALL
110 class REPORTDESIGN_DLLPUBLIC OReportHelper
112 ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xReport;
113 public:
114 OReportHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport)
115 :m_xReport(_xReport)
118 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportHeader() { return m_xReport->getReportHeader(); }
119 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportFooter() { return m_xReport->getReportFooter(); }
120 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageHeader() { return m_xReport->getPageHeader(); }
121 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageFooter() { return m_xReport->getPageFooter(); }
122 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getDetail() { return m_xReport->getDetail(); }
124 inline ::sal_Bool getReportHeaderOn() { return m_xReport->getReportHeaderOn(); }
125 inline ::sal_Bool getReportFooterOn() { return m_xReport->getReportFooterOn(); }
126 inline ::sal_Bool getPageHeaderOn() { return m_xReport->getPageHeaderOn(); }
127 inline ::sal_Bool getPageFooterOn() { return m_xReport->getPageFooterOn(); }
129 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);
132 //==================================================================================================================
133 //= UndoContext
134 //==================================================================================================================
135 class UndoContext
137 public:
138 UndoContext( SfxUndoManager& i_undoManager, const ::rtl::OUString& i_undoTitle )
139 :m_rUndoManager( i_undoManager )
141 m_rUndoManager.EnterListAction( i_undoTitle, String() );
144 ~UndoContext()
146 m_rUndoManager.LeaveListAction();
149 private:
150 SfxUndoManager& m_rUndoManager;
153 //==================================================================================================================
154 //= UndoSuppressor
155 //==================================================================================================================
156 class UndoSuppressor
158 public:
159 UndoSuppressor( SfxUndoManager& i_undoManager )
160 :m_rUndoManager( i_undoManager )
162 m_rUndoManager.EnableUndo( false );
165 ~UndoSuppressor()
167 m_rUndoManager.EnableUndo( true );
170 private:
171 SfxUndoManager& m_rUndoManager;
174 //==================================================================================================================
175 //= OCommentUndoAction
176 //==================================================================================================================
177 class REPORTDESIGN_DLLPUBLIC OCommentUndoAction : public SdrUndoAction
179 protected:
180 String m_strComment; // undo, redo comment
181 ::dbaui::IController* m_pController;
183 public:
184 TYPEINFO();
185 OCommentUndoAction( SdrModel& rMod
186 ,sal_uInt16 nCommentID);
187 virtual ~OCommentUndoAction();
189 virtual rtl::OUString GetComment() const { return m_strComment; }
190 virtual void Undo();
191 virtual void Redo();
193 //==================================================================
194 // OUndoContainerAction
195 //==================================================================
196 class REPORTDESIGN_DLLPUBLIC OUndoContainerAction: public OCommentUndoAction
198 OUndoContainerAction(OUndoContainerAction&);
199 void operator =(OUndoContainerAction&);
200 protected:
201 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
202 m_xElement; // object not owned by the action
203 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
204 m_xOwnElement; // object owned by the action
205 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
206 m_xContainer;
207 ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
208 m_xSection;
209 Action m_eAction;
211 public:
212 OUndoContainerAction(SdrModel& rMod
213 ,Action _eAction
214 ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > _xContainer
215 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
216 ,sal_uInt16 _nCommentId);
217 virtual ~OUndoContainerAction();
219 virtual void Undo();
220 virtual void Redo();
222 protected:
223 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
224 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
227 //==================================================================
228 // OUndoReportSectionAction
229 //==================================================================
230 class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction : public OUndoContainerAction
232 OReportHelper m_aReportHelper;
233 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
234 ,OReportHelper> m_pMemberFunction;
235 public:
236 OUndoReportSectionAction(SdrModel& rMod
237 ,Action _eAction
238 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
239 ,OReportHelper> _pMemberFunction
240 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
241 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
242 ,sal_uInt16 _nCommentId);
244 protected:
245 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
246 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
249 //==================================================================
250 // OUndoGroupSectionAction
251 //==================================================================
252 class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction : public OUndoContainerAction
254 OGroupHelper m_aGroupHelper;
255 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
256 ,OGroupHelper> m_pMemberFunction;
257 public:
258 OUndoGroupSectionAction(SdrModel& rMod
259 ,Action _eAction
260 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
261 ,OGroupHelper> _pMemberFunction
262 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
263 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
264 ,sal_uInt16 _nCommentId);
266 protected:
267 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
268 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
271 ///==================================================================
272 /// ORptUndoPropertyAction
273 ///==================================================================
274 class REPORTDESIGN_DLLPUBLIC ORptUndoPropertyAction: public OCommentUndoAction
276 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xObj;
277 ::rtl::OUString m_aPropertyName;
278 ::com::sun::star::uno::Any m_aNewValue;
279 ::com::sun::star::uno::Any m_aOldValue;
281 /** sets either the old value or the new value again at the property set.
283 * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
285 void setProperty(sal_Bool _bOld);
286 protected:
287 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
289 public:
290 ORptUndoPropertyAction(SdrModel& rMod, const ::com::sun::star::beans::PropertyChangeEvent& evt);
292 virtual void Undo();
293 virtual void Redo();
295 virtual rtl::OUString GetComment() const;
298 //==================================================================
299 // OUndoPropertyReportSectionAction
300 //==================================================================
301 class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction : public ORptUndoPropertyAction
303 OReportHelper m_aReportHelper;
304 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
305 ,OReportHelper> m_pMemberFunction;
306 protected:
307 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
308 public:
309 OUndoPropertyReportSectionAction(SdrModel& rMod
310 ,const ::com::sun::star::beans::PropertyChangeEvent& evt
311 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
312 ,OReportHelper> _pMemberFunction
313 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
317 //==================================================================
318 // OUndoPropertyGroupSectionAction
319 //==================================================================
320 class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction : public ORptUndoPropertyAction
322 OGroupHelper m_aGroupHelper;
323 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
324 ,OGroupHelper> m_pMemberFunction;
325 protected:
326 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
327 public:
328 OUndoPropertyGroupSectionAction(SdrModel& rMod
329 ,const ::com::sun::star::beans::PropertyChangeEvent& evt
330 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
331 ,OGroupHelper> _pMemberFunction
332 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
337 #endif //RPTUI_UNDOACTIONS_HXX
339 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */