sync master with lastest vba changes
[ooovba.git] / reportdesign / inc / UndoActions.hxx
blobb43bad260474fdb6045e1f790c4911681daf0a1c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: UndoActions.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef RPTUI_UNDOACTIONS_HXX
31 #define RPTUI_UNDOACTIONS_HXX
33 #include <svx/svdundo.hxx>
34 #include <tools/string.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 /** === end UNO includes === **/
49 #include <cppuhelper/implbase3.hxx>
50 #include <comphelper/uno3.hxx>
51 #include <comphelper/sequence.hxx>
52 #include <svtools/lstner.hxx>
53 #include <svx/svdouno.hxx>
54 #include "RptModel.hxx"
55 #include "dllapi.h"
56 #include <functional>
57 #include <memory>
58 #include <boost/shared_ptr.hpp>
60 FORWARD_DECLARE_INTERFACE(awt,XControl)
61 FORWARD_DECLARE_INTERFACE(awt,XControlContainer)
62 namespace dbaui
64 class IController;
66 namespace rptui
68 class OObjectBase;
70 enum Action
72 Inserted = 1,
73 Removed = 2
76 /** Helper class to allow std::mem_fun for SAL_CALL
78 class REPORTDESIGN_DLLPUBLIC OGroupHelper
80 ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > m_xGroup;
81 OGroupHelper(const OGroupHelper&);
82 OGroupHelper& operator=(const OGroupHelper&);
83 public:
84 OGroupHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup)
85 :m_xGroup(_xGroup)
88 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getHeader() { return m_xGroup->getHeader(); }
89 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getFooter() { return m_xGroup->getFooter(); }
90 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > getGroup() { return m_xGroup; }
92 inline ::sal_Bool getHeaderOn() { return m_xGroup->getHeaderOn(); }
93 inline ::sal_Bool getFooterOn() { return m_xGroup->getFooterOn(); }
95 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);
98 typedef com::sun::star::uno::Reference< ::com::sun::star::report::XSection > TSection;
100 /** Helper class to allow std::mem_fun for SAL_CALL
102 class REPORTDESIGN_DLLPUBLIC OReportHelper
104 ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xReport;
105 public:
106 OReportHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport)
107 :m_xReport(_xReport)
110 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportHeader() { return m_xReport->getReportHeader(); }
111 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportFooter() { return m_xReport->getReportFooter(); }
112 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageHeader() { return m_xReport->getPageHeader(); }
113 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageFooter() { return m_xReport->getPageFooter(); }
114 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getDetail() { return m_xReport->getDetail(); }
116 inline ::sal_Bool getReportHeaderOn() { return m_xReport->getReportHeaderOn(); }
117 inline ::sal_Bool getReportFooterOn() { return m_xReport->getReportFooterOn(); }
118 inline ::sal_Bool getPageHeaderOn() { return m_xReport->getPageHeaderOn(); }
119 inline ::sal_Bool getPageFooterOn() { return m_xReport->getPageFooterOn(); }
121 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);
124 class REPORTDESIGN_DLLPUBLIC UndoManagerListAction
126 private:
127 SfxUndoManager& m_rManager;
129 public:
130 UndoManagerListAction( SfxUndoManager& _rManager, const String& _rListActionComment )
131 :m_rManager( _rManager )
133 m_rManager.EnterListAction( _rListActionComment, String() );
135 ~UndoManagerListAction()
137 m_rManager.LeaveListAction();
141 class REPORTDESIGN_DLLPUBLIC OCommentUndoAction : public SdrUndoAction
143 protected:
144 String m_strComment; // undo, redo comment
145 ::dbaui::IController* m_pController;
147 public:
148 TYPEINFO();
149 OCommentUndoAction( SdrModel& rMod
150 ,USHORT nCommentID);
151 virtual ~OCommentUndoAction();
153 virtual UniString GetComment() const { return m_strComment; }
154 virtual void Undo();
155 virtual void Redo();
157 //==================================================================
158 // OUndoContainerAction
159 //==================================================================
160 class REPORTDESIGN_DLLPUBLIC OUndoContainerAction: public OCommentUndoAction
162 OUndoContainerAction(OUndoContainerAction&);
163 void operator =(OUndoContainerAction&);
164 protected:
165 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
166 m_xElement; // object not owned by the action
167 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
168 m_xOwnElement; // object owned by the action
169 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
170 m_xContainer;
171 ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
172 m_xSection;
173 Action m_eAction;
175 public:
176 OUndoContainerAction(SdrModel& rMod
177 ,Action _eAction
178 ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > _xContainer
179 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
180 ,USHORT _nCommentId);
181 virtual ~OUndoContainerAction();
183 virtual void Undo();
184 virtual void Redo();
186 protected:
187 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
188 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
191 //==================================================================
192 // OUndoReportSectionAction
193 //==================================================================
194 class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction : public OUndoContainerAction
196 OReportHelper m_aReportHelper;
197 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
198 ,OReportHelper> m_pMemberFunction;
199 public:
200 OUndoReportSectionAction(SdrModel& rMod
201 ,Action _eAction
202 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
203 ,OReportHelper> _pMemberFunction
204 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
205 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
206 ,USHORT _nCommentId);
208 protected:
209 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
210 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
213 //==================================================================
214 // OUndoGroupSectionAction
215 //==================================================================
216 class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction : public OUndoContainerAction
218 OGroupHelper m_aGroupHelper;
219 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
220 ,OGroupHelper> m_pMemberFunction;
221 public:
222 OUndoGroupSectionAction(SdrModel& rMod
223 ,Action _eAction
224 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
225 ,OGroupHelper> _pMemberFunction
226 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
227 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
228 ,USHORT _nCommentId);
230 protected:
231 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
232 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
235 ///==================================================================
236 /// ORptUndoPropertyAction
237 ///==================================================================
238 class REPORTDESIGN_DLLPUBLIC ORptUndoPropertyAction: public OCommentUndoAction
240 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xObj;
241 ::rtl::OUString m_aPropertyName;
242 ::com::sun::star::uno::Any m_aNewValue;
243 ::com::sun::star::uno::Any m_aOldValue;
245 /** sets either the old value or the new value again at the property set.
247 * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
249 void setProperty(sal_Bool _bOld);
250 protected:
251 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
253 public:
254 ORptUndoPropertyAction(SdrModel& rMod, const ::com::sun::star::beans::PropertyChangeEvent& evt);
256 virtual void Undo();
257 virtual void Redo();
259 virtual String GetComment() const;
262 //==================================================================
263 // OUndoPropertyReportSectionAction
264 //==================================================================
265 class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction : public ORptUndoPropertyAction
267 OReportHelper m_aReportHelper;
268 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
269 ,OReportHelper> m_pMemberFunction;
270 protected:
271 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
272 public:
273 OUndoPropertyReportSectionAction(SdrModel& rMod
274 ,const ::com::sun::star::beans::PropertyChangeEvent& evt
275 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
276 ,OReportHelper> _pMemberFunction
277 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
281 //==================================================================
282 // OUndoPropertyGroupSectionAction
283 //==================================================================
284 class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction : public ORptUndoPropertyAction
286 OGroupHelper m_aGroupHelper;
287 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
288 ,OGroupHelper> m_pMemberFunction;
289 protected:
290 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
291 public:
292 OUndoPropertyGroupSectionAction(SdrModel& rMod
293 ,const ::com::sun::star::beans::PropertyChangeEvent& evt
294 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
295 ,OGroupHelper> _pMemberFunction
296 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
301 #endif //RPTUI_UNDOACTIONS_HXX