Update ooo320-m1
[ooovba.git] / reportdesign / inc / UndoActions.hxx
blob90e943ddd39f4e534392e43dbc5cdc5cbe85aead
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 "dllapi.h"
34 #include <svx/svdundo.hxx>
35 #include <tools/string.hxx>
36 /** === begin UNO includes === **/
37 #include <com/sun/star/util/XModifyListener.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
40 #include <com/sun/star/script/ScriptEvent.hpp>
41 #include <com/sun/star/script/XScriptListener.hpp>
42 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
43 #include <com/sun/star/container/XNameContainer.hpp>
44 #include <com/sun/star/container/ContainerEvent.hpp>
45 #include <com/sun/star/container/XNameContainer.hpp>
46 #include <com/sun/star/report/XReportComponent.hpp>
47 #include <com/sun/star/report/XReportDefinition.hpp>
48 #include <com/sun/star/report/XGroup.hpp>
49 /** === end UNO includes === **/
50 #include <cppuhelper/implbase3.hxx>
51 #include <comphelper/uno3.hxx>
52 #include <comphelper/sequence.hxx>
53 #include <svtools/lstner.hxx>
54 #include <svx/svdouno.hxx>
55 #include "RptModel.hxx"
57 #include <functional>
58 #include <memory>
59 #include <boost/shared_ptr.hpp>
61 FORWARD_DECLARE_INTERFACE(awt,XControl)
62 FORWARD_DECLARE_INTERFACE(awt,XControlContainer)
63 namespace dbaui
65 class IController;
67 namespace rptui
69 class OObjectBase;
71 enum Action
73 Inserted = 1,
74 Removed = 2
77 /** Helper class to allow std::mem_fun for SAL_CALL
79 class REPORTDESIGN_DLLPUBLIC OGroupHelper
81 ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > m_xGroup;
82 OGroupHelper(const OGroupHelper&);
83 OGroupHelper& operator=(const OGroupHelper&);
84 public:
85 OGroupHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup)
86 :m_xGroup(_xGroup)
89 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getHeader() { return m_xGroup->getHeader(); }
90 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getFooter() { return m_xGroup->getFooter(); }
91 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > getGroup() { return m_xGroup; }
93 inline ::sal_Bool getHeaderOn() { return m_xGroup->getHeaderOn(); }
94 inline ::sal_Bool getFooterOn() { return m_xGroup->getFooterOn(); }
96 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);
99 typedef com::sun::star::uno::Reference< ::com::sun::star::report::XSection > TSection;
101 /** Helper class to allow std::mem_fun for SAL_CALL
103 class REPORTDESIGN_DLLPUBLIC OReportHelper
105 ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xReport;
106 public:
107 OReportHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport)
108 :m_xReport(_xReport)
111 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportHeader() { return m_xReport->getReportHeader(); }
112 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportFooter() { return m_xReport->getReportFooter(); }
113 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageHeader() { return m_xReport->getPageHeader(); }
114 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageFooter() { return m_xReport->getPageFooter(); }
115 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getDetail() { return m_xReport->getDetail(); }
117 inline ::sal_Bool getReportHeaderOn() { return m_xReport->getReportHeaderOn(); }
118 inline ::sal_Bool getReportFooterOn() { return m_xReport->getReportFooterOn(); }
119 inline ::sal_Bool getPageHeaderOn() { return m_xReport->getPageHeaderOn(); }
120 inline ::sal_Bool getPageFooterOn() { return m_xReport->getPageFooterOn(); }
122 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);
125 class REPORTDESIGN_DLLPUBLIC UndoManagerListAction
127 private:
128 SfxUndoManager& m_rManager;
130 public:
131 UndoManagerListAction( SfxUndoManager& _rManager, const String& _rListActionComment )
132 :m_rManager( _rManager )
134 m_rManager.EnterListAction( _rListActionComment, String() );
136 ~UndoManagerListAction()
138 m_rManager.LeaveListAction();
142 class REPORTDESIGN_DLLPUBLIC OCommentUndoAction : public SdrUndoAction
144 protected:
145 String m_strComment; // undo, redo comment
146 ::dbaui::IController* m_pController;
148 public:
149 TYPEINFO();
150 OCommentUndoAction( SdrModel& rMod
151 ,USHORT nCommentID);
152 virtual ~OCommentUndoAction();
154 virtual UniString GetComment() const { return m_strComment; }
155 virtual void Undo();
156 virtual void Redo();
158 //==================================================================
159 // OUndoContainerAction
160 //==================================================================
161 class REPORTDESIGN_DLLPUBLIC OUndoContainerAction: public OCommentUndoAction
163 OUndoContainerAction(OUndoContainerAction&);
164 void operator =(OUndoContainerAction&);
165 protected:
166 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
167 m_xElement; // object not owned by the action
168 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
169 m_xOwnElement; // object owned by the action
170 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
171 m_xContainer;
172 ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
173 m_xSection;
174 Action m_eAction;
176 public:
177 OUndoContainerAction(SdrModel& rMod
178 ,Action _eAction
179 ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > _xContainer
180 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
181 ,USHORT _nCommentId);
182 virtual ~OUndoContainerAction();
184 virtual void Undo();
185 virtual void Redo();
187 protected:
188 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
189 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
192 //==================================================================
193 // OUndoReportSectionAction
194 //==================================================================
195 class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction : public OUndoContainerAction
197 OReportHelper m_aReportHelper;
198 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
199 ,OReportHelper> m_pMemberFunction;
200 public:
201 OUndoReportSectionAction(SdrModel& rMod
202 ,Action _eAction
203 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
204 ,OReportHelper> _pMemberFunction
205 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
206 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
207 ,USHORT _nCommentId);
209 protected:
210 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
211 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
214 //==================================================================
215 // OUndoGroupSectionAction
216 //==================================================================
217 class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction : public OUndoContainerAction
219 OGroupHelper m_aGroupHelper;
220 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
221 ,OGroupHelper> m_pMemberFunction;
222 public:
223 OUndoGroupSectionAction(SdrModel& rMod
224 ,Action _eAction
225 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
226 ,OGroupHelper> _pMemberFunction
227 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
228 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
229 ,USHORT _nCommentId);
231 protected:
232 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
233 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
236 ///==================================================================
237 /// ORptUndoPropertyAction
238 ///==================================================================
239 class REPORTDESIGN_DLLPUBLIC ORptUndoPropertyAction: public OCommentUndoAction
241 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xObj;
242 ::rtl::OUString m_aPropertyName;
243 ::com::sun::star::uno::Any m_aNewValue;
244 ::com::sun::star::uno::Any m_aOldValue;
246 /** sets either the old value or the new value again at the property set.
248 * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
250 void setProperty(sal_Bool _bOld);
251 protected:
252 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
254 public:
255 ORptUndoPropertyAction(SdrModel& rMod, const ::com::sun::star::beans::PropertyChangeEvent& evt);
257 virtual void Undo();
258 virtual void Redo();
260 virtual String GetComment() const;
263 //==================================================================
264 // OUndoPropertyReportSectionAction
265 //==================================================================
266 class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction : public ORptUndoPropertyAction
268 OReportHelper m_aReportHelper;
269 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
270 ,OReportHelper> m_pMemberFunction;
271 protected:
272 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
273 public:
274 OUndoPropertyReportSectionAction(SdrModel& rMod
275 ,const ::com::sun::star::beans::PropertyChangeEvent& evt
276 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
277 ,OReportHelper> _pMemberFunction
278 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
282 //==================================================================
283 // OUndoPropertyGroupSectionAction
284 //==================================================================
285 class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction : public ORptUndoPropertyAction
287 OGroupHelper m_aGroupHelper;
288 ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
289 ,OGroupHelper> m_pMemberFunction;
290 protected:
291 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
292 public:
293 OUndoPropertyGroupSectionAction(SdrModel& rMod
294 ,const ::com::sun::star::beans::PropertyChangeEvent& evt
295 ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
296 ,OGroupHelper> _pMemberFunction
297 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
302 #endif //RPTUI_UNDOACTIONS_HXX