1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef RPTUI_UNDO_HXX
28 #define RPTUI_UNDO_HXX
29 
30 #include "UndoActions.hxx"
31 #include <functional>
32 
33 FORWARD_DECLARE_INTERFACE(awt,XControl)
34 FORWARD_DECLARE_INTERFACE(awt,XControlContainer)
35 FORWARD_DECLARE_INTERFACE(drawing,XShape)
36 namespace dbaui
37 {
38 	class IController;
39 }
40 namespace rptui
41 {
42 	class OObjectBase;
43 
44 
45 	/** \class OSectionUndo
46      * Undo class for section add and remove.
47      */
48     class OSectionUndo : public OCommentUndoAction
49     {
50         OSectionUndo(const OSectionUndo&);
51         void operator =(const OSectionUndo&);
52     protected:
53         ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> >
54                                                     m_aControls;
55         ::std::vector< ::std::pair< ::rtl::OUString ,::com::sun::star::uno::Any> >
56                                                     m_aValues;
57 		Action										m_eAction;
58 		sal_uInt16									m_nSlot;
59         bool                                        m_bInserted;
60 
61         virtual void    implReInsert( ) = 0;
62 		virtual void    implReRemove( ) = 0;
63 
64         void collectControls(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection);
65     public:
66         TYPEINFO();
67         OSectionUndo(	OReportModel& rMod
68 						,sal_uInt16 _nSlot
69 						,Action _eAction
70 						,sal_uInt16 nCommentID);
71         virtual ~OSectionUndo();
72 
73         virtual void		Undo();
74 		virtual void		Redo();
75     };
76 
77 	/** Undo action for the group header, footer, page header, footer
78 	*/
79 	class OReportSectionUndo : public OSectionUndo
80 	{
81 		OReportHelper								m_aReportHelper;
82 		::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
83 									,OReportHelper> m_pMemberFunction;
84 
85 		void    implReInsert( );
86 		void    implReRemove( );
87         OReportSectionUndo(const OReportSectionUndo&);
88         void operator =(const OReportSectionUndo&);
89 	public:
90         TYPEINFO();
91 		//OReportSectionUndo(	 const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection
92 		OReportSectionUndo(	OReportModel& rMod
93 							,sal_uInt16 _nSlot
94 							,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
95 							    ,OReportHelper> _pMemberFunction
96 							,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
97 							,Action _eAction
98 							,sal_uInt16 nCommentID);
99         virtual ~OReportSectionUndo();
100 	};
101 
102 	/** Undo action for the group header, footer
103 	*/
104 	class OGroupSectionUndo : public OSectionUndo
105 	{
106 		OGroupHelper								m_aGroupHelper;
107 		::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
108 									,OGroupHelper> m_pMemberFunction;
109 
110         mutable ::rtl::OUString                     m_sName;
111 
112 		void    implReInsert( );
113 		void    implReRemove( );
114         OGroupSectionUndo(const OGroupSectionUndo&);
115         void operator =(const OGroupSectionUndo&);
116 	public:
117         TYPEINFO();
118 		//OGroupSectionUndo(	 const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection
119 		OGroupSectionUndo(	OReportModel& rMod
120 							,sal_uInt16 _nSlot
121 							,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
122 											,OGroupHelper> _pMemberFunction
123 							,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
124 							,Action _eAction
125 							,sal_uInt16 nCommentID);
126 
127         virtual String		GetComment() const;
128 	};
129 
130 	/** /class OGroupUndo
131      * \brief Undo action for removing a group object.
132 	*/
133 	class OGroupUndo : public OCommentUndoAction
134 	{
135 		::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup>				m_xGroup; ///<! the group for the undo redo action
136 		::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >	m_xReportDefinition; ///<! the parent report definition
137 		Action																			m_eAction; ///<! the current action
138 		sal_Int32																		m_nLastPosition; ///<! the last position of the group
139 
140 		void    implReInsert( );
141 		void    implReRemove( );
142 	public:
143         TYPEINFO();
144 		OGroupUndo(OReportModel& rMod
145 					,sal_uInt16 nCommentID
146 					,Action	_eAction
147 					,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup>& _xGroup
148 					,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReportDefinition);
149 		virtual void		Undo();
150 		virtual void		Redo();
151 	};
152 }
153 #endif // RPTUI_UNDO_HXX
154