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>
61 /** Helper class to allow std::mem_fun for SAL_CALL
63 class REPORTDESIGN_DLLPUBLIC OGroupHelper
65 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XGroup
> m_xGroup
;
66 OGroupHelper(const OGroupHelper
&);
67 OGroupHelper
& operator=(const OGroupHelper
&);
69 OGroupHelper(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XGroup
>& _xGroup
)
73 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getHeader() { return m_xGroup
->getHeader(); }
74 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getFooter() { return m_xGroup
->getFooter(); }
75 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XGroup
> getGroup() { return m_xGroup
; }
77 inline ::sal_Bool
getHeaderOn() { return m_xGroup
->getHeaderOn(); }
78 inline ::sal_Bool
getFooterOn() { return m_xGroup
->getFooterOn(); }
80 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
);
83 typedef com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> TSection
;
85 /** Helper class to allow std::mem_fun for SAL_CALL
87 class REPORTDESIGN_DLLPUBLIC OReportHelper
89 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportDefinition
> m_xReport
;
91 OReportHelper(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportDefinition
>& _xReport
)
95 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getReportHeader() { return m_xReport
->getReportHeader(); }
96 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getReportFooter() { return m_xReport
->getReportFooter(); }
97 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getPageHeader() { return m_xReport
->getPageHeader(); }
98 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getPageFooter() { return m_xReport
->getPageFooter(); }
99 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getDetail() { return m_xReport
->getDetail(); }
101 inline ::sal_Bool
getReportHeaderOn() { return m_xReport
->getReportHeaderOn(); }
102 inline ::sal_Bool
getReportFooterOn() { return m_xReport
->getReportFooterOn(); }
103 inline ::sal_Bool
getPageHeaderOn() { return m_xReport
->getPageHeaderOn(); }
104 inline ::sal_Bool
getPageFooterOn() { return m_xReport
->getPageFooterOn(); }
106 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 //==================================================================================================================
111 //==================================================================================================================
115 UndoContext( SfxUndoManager
& i_undoManager
, const OUString
& i_undoTitle
)
116 :m_rUndoManager( i_undoManager
)
118 m_rUndoManager
.EnterListAction( i_undoTitle
, OUString() );
123 m_rUndoManager
.LeaveListAction();
127 SfxUndoManager
& m_rUndoManager
;
130 //==================================================================================================================
132 //==================================================================================================================
136 UndoSuppressor( SfxUndoManager
& i_undoManager
)
137 :m_rUndoManager( i_undoManager
)
139 m_rUndoManager
.EnableUndo( false );
144 m_rUndoManager
.EnableUndo( true );
148 SfxUndoManager
& m_rUndoManager
;
151 //==================================================================================================================
152 //= OCommentUndoAction
153 //==================================================================================================================
154 class REPORTDESIGN_DLLPUBLIC OCommentUndoAction
: public SdrUndoAction
157 OUString m_strComment
; // undo, redo comment
158 ::dbaui::IController
* m_pController
;
162 OCommentUndoAction( SdrModel
& rMod
163 ,sal_uInt16 nCommentID
);
164 virtual ~OCommentUndoAction();
166 virtual OUString
GetComment() const { return m_strComment
; }
170 //==================================================================
171 // OUndoContainerAction
172 //==================================================================
173 class REPORTDESIGN_DLLPUBLIC OUndoContainerAction
: public OCommentUndoAction
175 OUndoContainerAction(OUndoContainerAction
&);
176 void operator =(OUndoContainerAction
&);
178 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
179 m_xElement
; // object not owned by the action
180 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
181 m_xOwnElement
; // object owned by the action
182 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>
184 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
189 OUndoContainerAction(SdrModel
& rMod
191 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
> _xContainer
192 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xElem
193 ,sal_uInt16 _nCommentId
);
194 virtual ~OUndoContainerAction();
200 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
201 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
204 //==================================================================
205 // OUndoReportSectionAction
206 //==================================================================
207 class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction
: public OUndoContainerAction
209 OReportHelper m_aReportHelper
;
210 ::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
211 ,OReportHelper
> m_pMemberFunction
;
213 OUndoReportSectionAction(SdrModel
& rMod
215 ,::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
216 ,OReportHelper
> _pMemberFunction
217 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportDefinition
>& _xReport
218 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xElem
219 ,sal_uInt16 _nCommentId
);
222 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
223 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
226 //==================================================================
227 // OUndoGroupSectionAction
228 //==================================================================
229 class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction
: public OUndoContainerAction
231 OGroupHelper m_aGroupHelper
;
232 ::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
233 ,OGroupHelper
> m_pMemberFunction
;
235 OUndoGroupSectionAction(SdrModel
& rMod
237 ,::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
238 ,OGroupHelper
> _pMemberFunction
239 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XGroup
>& _xGroup
240 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xElem
241 ,sal_uInt16 _nCommentId
);
244 virtual void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
245 virtual void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception
) );
248 ///==================================================================
249 /// ORptUndoPropertyAction
250 ///==================================================================
251 class REPORTDESIGN_DLLPUBLIC ORptUndoPropertyAction
: public OCommentUndoAction
253 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> m_xObj
;
254 OUString m_aPropertyName
;
255 ::com::sun::star::uno::Any m_aNewValue
;
256 ::com::sun::star::uno::Any m_aOldValue
;
258 /** sets either the old value or the new value again at the property set.
260 * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
262 void setProperty(sal_Bool _bOld
);
264 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getObject();
267 ORptUndoPropertyAction(SdrModel
& rMod
, const ::com::sun::star::beans::PropertyChangeEvent
& evt
);
272 virtual OUString
GetComment() const;
275 //==================================================================
276 // OUndoPropertyReportSectionAction
277 //==================================================================
278 class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction
: public ORptUndoPropertyAction
280 OReportHelper m_aReportHelper
;
281 ::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
282 ,OReportHelper
> m_pMemberFunction
;
284 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getObject();
286 OUndoPropertyReportSectionAction(SdrModel
& rMod
287 ,const ::com::sun::star::beans::PropertyChangeEvent
& evt
288 ,::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
289 ,OReportHelper
> _pMemberFunction
290 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportDefinition
>& _xReport
294 //==================================================================
295 // OUndoPropertyGroupSectionAction
296 //==================================================================
297 class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction
: public ORptUndoPropertyAction
299 OGroupHelper m_aGroupHelper
;
300 ::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
301 ,OGroupHelper
> m_pMemberFunction
;
303 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getObject();
305 OUndoPropertyGroupSectionAction(SdrModel
& rMod
306 ,const ::com::sun::star::beans::PropertyChangeEvent
& evt
307 ,::std::mem_fun_t
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>
308 ,OGroupHelper
> _pMemberFunction
309 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XGroup
>& _xGroup
314 #endif //RPTUI_UNDOACTIONS_HXX
316 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */