xref: /trunk/main/svx/source/table/tableundo.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 
28 #ifndef _SVX_TABLEUNDO_HXX_
29 #define _SVX_TABLEUNDO_HXX_
30 
31 #include <com/sun/star/container/XIndexAccess.hpp>
32 #include <com/sun/star/table/CellContentType.hpp>
33 
34 #include "svx/svdotable.hxx"
35 #include "svx/svdobj.hxx"
36 #include "svx/svdundo.hxx"
37 
38 #include "celltypes.hxx"
39 
40 namespace sdr { namespace properties {
41     class TextProperties;
42 } }
43 
44 class OutlinerParaObject;
45 
46 // -----------------------------------------------------------------------------
47 
48 namespace sdr { namespace table {
49 
50 class CellUndo : public SdrUndoAction, public sdr::ObjectUser
51 {
52 public:
53     CellUndo( const SdrObjectWeakRef& xObjRef, const CellRef& xCell );
54     virtual ~CellUndo();
55 
56     virtual void            Undo();
57     virtual void            Redo();
58     virtual sal_Bool            Merge( SfxUndoAction *pNextAction );
59 
60     void dispose();
61     virtual void ObjectInDestruction(const SdrObject& rObject);
62 
63 private:
64     struct Data
65     {
66         sdr::properties::TextProperties* mpProperties;
67         OutlinerParaObject* mpOutlinerParaObject;
68 
69         ::com::sun::star::table::CellContentType mnCellContentType;
70 
71         ::rtl::OUString msFormula;
72         double          mfValue;
73         ::sal_Int32     mnError;
74         ::sal_Bool      mbMerged;
75         ::sal_Int32     mnRowSpan;
76         ::sal_Int32     mnColSpan;
77 
78         Data() : mpProperties(0), mpOutlinerParaObject(0) {};
79     };
80 
81     void setDataToCell( const Data& rData );
82     void getDataFromCell( Data& rData );
83 
84     SdrObjectWeakRef mxObjRef;
85     CellRef mxCell;
86     Data maUndoData;
87     Data maRedoData;
88     bool mbUndo;
89 };
90 
91 // -----------------------------------------------------------------------------
92 
93 class InsertRowUndo : public SdrUndoAction
94 {
95 public:
96     InsertRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aNewRows );
97     virtual ~InsertRowUndo();
98 
99     virtual void            Undo();
100     virtual void            Redo();
101 
102 private:
103     TableModelRef mxTable;
104     sal_Int32 mnIndex;
105     RowVector maRows;
106     bool mbUndo;
107 };
108 
109 // -----------------------------------------------------------------------------
110 
111 class RemoveRowUndo : public SdrUndoAction
112 {
113 public:
114     RemoveRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aRemovedRows );
115     virtual ~RemoveRowUndo();
116 
117     virtual void            Undo();
118     virtual void            Redo();
119 
120 private:
121     TableModelRef mxTable;
122     sal_Int32 mnIndex;
123     RowVector maRows;
124     bool mbUndo;
125 };
126 
127 // -----------------------------------------------------------------------------
128 
129 class InsertColUndo : public SdrUndoAction
130 {
131 public:
132     InsertColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells );
133     virtual ~InsertColUndo();
134 
135     virtual void            Undo();
136     virtual void            Redo();
137 
138 private:
139     TableModelRef mxTable;
140     sal_Int32 mnIndex;
141     ColumnVector maColumns;
142     CellVector maCells;
143     bool mbUndo;
144 };
145 
146 // -----------------------------------------------------------------------------
147 
148 class RemoveColUndo : public SdrUndoAction
149 {
150 public:
151     RemoveColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells );
152     virtual ~RemoveColUndo();
153 
154     virtual void            Undo();
155     virtual void            Redo();
156 
157 private:
158     TableModelRef mxTable;
159     sal_Int32 mnIndex;
160     ColumnVector maColumns;
161     CellVector maCells;
162     bool mbUndo;
163 };
164 
165 // -----------------------------------------------------------------------------
166 
167 class TableColumnUndo : public SdrUndoAction
168 {
169 public:
170     TableColumnUndo( const TableColumnRef& xCol );
171     virtual ~TableColumnUndo();
172 
173     virtual void            Undo();
174     virtual void            Redo();
175     virtual sal_Bool            Merge( SfxUndoAction *pNextAction );
176 
177 private:
178     struct Data
179     {
180         sal_Int32   mnColumn;
181         sal_Int32   mnWidth;
182         sal_Bool    mbOptimalWidth;
183         sal_Bool    mbIsVisible;
184         sal_Bool    mbIsStartOfNewPage;
185         ::rtl::OUString maName;
186     };
187 
188     void setData( const Data& rData );
189     void getData( Data& rData );
190 
191     TableColumnRef mxCol;
192     Data maUndoData;
193     Data maRedoData;
194     bool mbHasRedoData;
195 };
196 
197 // -----------------------------------------------------------------------------
198 
199 class TableRowUndo : public SdrUndoAction
200 {
201 public:
202     TableRowUndo( const TableRowRef& xRow );
203     virtual ~TableRowUndo();
204 
205     virtual void            Undo();
206     virtual void            Redo();
207     virtual sal_Bool            Merge( SfxUndoAction *pNextAction );
208 
209 private:
210     struct Data
211     {
212         CellVector  maCells;
213         sal_Int32   mnRow;
214         sal_Int32   mnHeight;
215         sal_Bool    mbOptimalHeight;
216         sal_Bool    mbIsVisible;
217         sal_Bool    mbIsStartOfNewPage;
218         ::rtl::OUString maName;
219     };
220 
221     void setData( const Data& rData );
222     void getData( Data& rData );
223 
224     TableRowRef mxRow;
225     Data maUndoData;
226     Data maRedoData;
227     bool mbHasRedoData;
228 };
229 
230 // -----------------------------------------------------------------------------
231 
232 class TableStyleUndo : public SdrUndoAction
233 {
234 public:
235     TableStyleUndo( const SdrTableObj& rTableObj );
236 
237     virtual void            Undo();
238     virtual void            Redo();
239 
240 private:
241     SdrObjectWeakRef mxObjRef;
242 
243     struct Data
244     {
245         TableStyleSettings maSettings;
246         ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > mxTableStyle;
247     };
248 
249     void setData( const Data& rData );
250     void getData( Data& rData );
251 
252     Data maUndoData;
253     Data maRedoData;
254     bool mbHasRedoData;
255 };
256 
257 } }
258 
259 #endif
260