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 RPTUI_UNDOACTIONS_HXX
20 #define RPTUI_UNDOACTIONS_HXX
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>
45 #include <tools/string.hxx>
62 /** Helper class to allow std::mem_fun for SAL_CALL
64 class REPORTDESIGN_DLLPUBLIC OGroupHelper
66 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XGroup
> m_xGroup
;
67 OGroupHelper(const OGroupHelper
&);
68 OGroupHelper
& operator=(const OGroupHelper
&);
70 OGroupHelper(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XGroup
>& _xGroup
)
74 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getHeader() { return m_xGroup
->getHeader(); }
75 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getFooter() { return m_xGroup
->getFooter(); }
76 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XGroup
> getGroup() { return m_xGroup
; }
78 inline ::sal_Bool
getHeaderOn() { return m_xGroup
->getHeaderOn(); }
79 inline ::sal_Bool
getFooterOn() { return m_xGroup
->getFooterOn(); }
81 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
);
84 typedef com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> TSection
;
86 /** Helper class to allow std::mem_fun for SAL_CALL
88 class REPORTDESIGN_DLLPUBLIC OReportHelper
90 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportDefinition
> m_xReport
;
92 OReportHelper(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportDefinition
>& _xReport
)
96 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getReportHeader() { return m_xReport
->getReportHeader(); }
97 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getReportFooter() { return m_xReport
->getReportFooter(); }
98 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getPageHeader() { return m_xReport
->getPageHeader(); }
99 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getPageFooter() { return m_xReport
->getPageFooter(); }
100 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getDetail() { return m_xReport
->getDetail(); }
102 inline ::sal_Bool
getReportHeaderOn() { return m_xReport
->getReportHeaderOn(); }
103 inline ::sal_Bool
getReportFooterOn() { return m_xReport
->getReportFooterOn(); }
104 inline ::sal_Bool
getPageHeaderOn() { return m_xReport
->getPageHeaderOn(); }
105 inline ::sal_Bool
getPageFooterOn() { return m_xReport
->getPageFooterOn(); }
107 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
);
110 //==================================================================================================================
112 //==================================================================================================================
116 UndoContext( SfxUndoManager
& i_undoManager
, const OUString
& i_undoTitle
)
117 :m_rUndoManager( i_undoManager
)
119 m_rUndoManager
.EnterListAction( i_undoTitle
, String() );
124 m_rUndoManager
.LeaveListAction();
128 SfxUndoManager
& m_rUndoManager
;
131 //==================================================================================================================
133 //==================================================================================================================
137 UndoSuppressor( SfxUndoManager
& i_undoManager
)
138 :m_rUndoManager( i_undoManager
)
140 m_rUndoManager
.EnableUndo( false );
145 m_rUndoManager
.EnableUndo( true );
149 SfxUndoManager
& m_rUndoManager
;
152 //==================================================================================================================
153 //= OCommentUndoAction
154 //==================================================================================================================
155 class REPORTDESIGN_DLLPUBLIC OCommentUndoAction
: public SdrUndoAction
158 String m_strComment
; // undo, redo comment
159 ::dbaui::IController
* m_pController
;
163 OCommentUndoAction( SdrModel
& rMod
164 ,sal_uInt16 nCommentID
);
165 virtual ~OCommentUndoAction();
167 virtual OUString
GetComment() const { return m_strComment
; }
171 //==================================================================
172 // OUndoContainerAction
173 //==================================================================
174 class REPORTDESIGN_DLLPUBLIC OUndoContainerAction
: public OCommentUndoAction
176 OUndoContainerAction(OUndoContainerAction
&);
177 void operator =(OUndoContainerAction
&);
179 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
180 m_xElement
; // object not owned by the action
181 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
182 m_xOwnElement
; // object owned by the action
183 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>
185 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
190 OUndoContainerAction(SdrModel
& rMod
192 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
> _xContainer
193 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xElem
194 ,sal_uInt16 _nCommentId
);
195 virtual ~OUndoContainerAction();
201 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
202 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
205 //==================================================================
206 // OUndoReportSectionAction
207 //==================================================================
208 class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction
: public OUndoContainerAction
210 OReportHelper m_aReportHelper
;
211 ::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
212 ,OReportHelper
> m_pMemberFunction
;
214 OUndoReportSectionAction(SdrModel
& rMod
216 ,::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
217 ,OReportHelper
> _pMemberFunction
218 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportDefinition
>& _xReport
219 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xElem
220 ,sal_uInt16 _nCommentId
);
223 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
224 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
227 //==================================================================
228 // OUndoGroupSectionAction
229 //==================================================================
230 class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction
: public OUndoContainerAction
232 OGroupHelper m_aGroupHelper
;
233 ::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
234 ,OGroupHelper
> m_pMemberFunction
;
236 OUndoGroupSectionAction(SdrModel
& rMod
238 ,::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
239 ,OGroupHelper
> _pMemberFunction
240 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XGroup
>& _xGroup
241 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xElem
242 ,sal_uInt16 _nCommentId
);
245 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
246 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
249 ///==================================================================
250 /// ORptUndoPropertyAction
251 ///==================================================================
252 class REPORTDESIGN_DLLPUBLIC ORptUndoPropertyAction
: public OCommentUndoAction
254 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> m_xObj
;
255 OUString m_aPropertyName
;
256 ::com::sun::star::uno::Any m_aNewValue
;
257 ::com::sun::star::uno::Any m_aOldValue
;
259 /** sets either the old value or the new value again at the property set.
261 * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
263 void setProperty(sal_Bool _bOld
);
265 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getObject();
268 ORptUndoPropertyAction(SdrModel
& rMod
, const ::com::sun::star::beans::PropertyChangeEvent
& evt
);
273 virtual OUString
GetComment() const;
276 //==================================================================
277 // OUndoPropertyReportSectionAction
278 //==================================================================
279 class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction
: public ORptUndoPropertyAction
281 OReportHelper m_aReportHelper
;
282 ::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
283 ,OReportHelper
> m_pMemberFunction
;
285 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getObject();
287 OUndoPropertyReportSectionAction(SdrModel
& rMod
288 ,const ::com::sun::star::beans::PropertyChangeEvent
& evt
289 ,::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
290 ,OReportHelper
> _pMemberFunction
291 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportDefinition
>& _xReport
295 //==================================================================
296 // OUndoPropertyGroupSectionAction
297 //==================================================================
298 class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction
: public ORptUndoPropertyAction
300 OGroupHelper m_aGroupHelper
;
301 ::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
302 ,OGroupHelper
> m_pMemberFunction
;
304 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getObject();
306 OUndoPropertyGroupSectionAction(SdrModel
& rMod
307 ,const ::com::sun::star::beans::PropertyChangeEvent
& evt
308 ,::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
309 ,OGroupHelper
> _pMemberFunction
310 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XGroup
>& _xGroup
315 #endif //RPTUI_UNDOACTIONS_HXX
317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */