xref: /AOO41X/main/svx/source/table/tableundo.hxx (revision 3334a7e6acdae9820fa1a6f556bb10129a8de6b2)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVX_TABLEUNDO_HXX_
25 #define _SVX_TABLEUNDO_HXX_
26 
27 #include <com/sun/star/container/XIndexAccess.hpp>
28 #include <com/sun/star/table/CellContentType.hpp>
29 
30 #include "svx/svdotable.hxx"
31 #include "svx/svdobj.hxx"
32 #include "svx/svdundo.hxx"
33 
34 #include "celltypes.hxx"
35 
36 namespace sdr { namespace properties {
37     class TextProperties;
38 } }
39 
40 class OutlinerParaObject;
41 
42 // -----------------------------------------------------------------------------
43 
44 namespace sdr { namespace table {
45 
46 class CellUndo : public SdrUndoAction, public sdr::ObjectUser
47 {
48 public:
49     CellUndo( const SdrObjectWeakRef& xObjRef, const CellRef& xCell );
50     virtual ~CellUndo();
51 
52     virtual void            Undo();
53     virtual void            Redo();
54     virtual sal_Bool            Merge( SfxUndoAction *pNextAction );
55 
56     void dispose();
57     virtual void ObjectInDestruction(const SdrObject& rObject);
58 
59 private:
60     struct Data
61     {
62         sdr::properties::TextProperties* mpProperties;
63         OutlinerParaObject* mpOutlinerParaObject;
64 
65         ::com::sun::star::table::CellContentType mnCellContentType;
66 
67         ::rtl::OUString msFormula;
68         double          mfValue;
69         ::sal_Int32     mnError;
70         ::sal_Bool      mbMerged;
71         ::sal_Int32     mnRowSpan;
72         ::sal_Int32     mnColSpan;
73 
Datasdr::table::CellUndo::Data74         Data() : mpProperties(0), mpOutlinerParaObject(0) {};
75     };
76 
77     void setDataToCell( const Data& rData );
78     void getDataFromCell( Data& rData );
79 
80     SdrObjectWeakRef mxObjRef;
81     CellRef mxCell;
82     Data maUndoData;
83     Data maRedoData;
84     bool mbUndo;
85 };
86 
87 // -----------------------------------------------------------------------------
88 
89 class InsertRowUndo : public SdrUndoAction
90 {
91 public:
92     InsertRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aNewRows );
93     virtual ~InsertRowUndo();
94 
95     virtual void            Undo();
96     virtual void            Redo();
97 
98 private:
99     TableModelRef mxTable;
100     sal_Int32 mnIndex;
101     RowVector maRows;
102     bool mbUndo;
103 };
104 
105 // -----------------------------------------------------------------------------
106 
107 class RemoveRowUndo : public SdrUndoAction
108 {
109 public:
110     RemoveRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aRemovedRows );
111     virtual ~RemoveRowUndo();
112 
113     virtual void            Undo();
114     virtual void            Redo();
115 
116 private:
117     TableModelRef mxTable;
118     sal_Int32 mnIndex;
119     RowVector maRows;
120     bool mbUndo;
121 };
122 
123 // -----------------------------------------------------------------------------
124 
125 class InsertColUndo : public SdrUndoAction
126 {
127 public:
128     InsertColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells );
129     virtual ~InsertColUndo();
130 
131     virtual void            Undo();
132     virtual void            Redo();
133 
134 private:
135     TableModelRef mxTable;
136     sal_Int32 mnIndex;
137     ColumnVector maColumns;
138     CellVector maCells;
139     bool mbUndo;
140 };
141 
142 // -----------------------------------------------------------------------------
143 
144 class RemoveColUndo : public SdrUndoAction
145 {
146 public:
147     RemoveColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells );
148     virtual ~RemoveColUndo();
149 
150     virtual void            Undo();
151     virtual void            Redo();
152 
153 private:
154     TableModelRef mxTable;
155     sal_Int32 mnIndex;
156     ColumnVector maColumns;
157     CellVector maCells;
158     bool mbUndo;
159 };
160 
161 // -----------------------------------------------------------------------------
162 
163 class TableColumnUndo : public SdrUndoAction
164 {
165 public:
166     TableColumnUndo( const TableColumnRef& xCol );
167     virtual ~TableColumnUndo();
168 
169     virtual void            Undo();
170     virtual void            Redo();
171     virtual sal_Bool            Merge( SfxUndoAction *pNextAction );
172 
173 private:
174     struct Data
175     {
176         sal_Int32   mnColumn;
177         sal_Int32   mnWidth;
178         sal_Bool    mbOptimalWidth;
179         sal_Bool    mbIsVisible;
180         sal_Bool    mbIsStartOfNewPage;
181         ::rtl::OUString maName;
182     };
183 
184     void setData( const Data& rData );
185     void getData( Data& rData );
186 
187     TableColumnRef mxCol;
188     Data maUndoData;
189     Data maRedoData;
190     bool mbHasRedoData;
191 };
192 
193 // -----------------------------------------------------------------------------
194 
195 class TableRowUndo : public SdrUndoAction
196 {
197 public:
198     TableRowUndo( const TableRowRef& xRow );
199     virtual ~TableRowUndo();
200 
201     virtual void            Undo();
202     virtual void            Redo();
203     virtual sal_Bool            Merge( SfxUndoAction *pNextAction );
204 
205 private:
206     struct Data
207     {
208         CellVector  maCells;
209         sal_Int32   mnRow;
210         sal_Int32   mnHeight;
211         sal_Bool    mbOptimalHeight;
212         sal_Bool    mbIsVisible;
213         sal_Bool    mbIsStartOfNewPage;
214         ::rtl::OUString maName;
215     };
216 
217     void setData( const Data& rData );
218     void getData( Data& rData );
219 
220     TableRowRef mxRow;
221     Data maUndoData;
222     Data maRedoData;
223     bool mbHasRedoData;
224 };
225 
226 // -----------------------------------------------------------------------------
227 
228 class TableStyleUndo : public SdrUndoAction
229 {
230 public:
231     TableStyleUndo( const SdrTableObj& rTableObj );
232 
233     virtual void            Undo();
234     virtual void            Redo();
235 
236 private:
237     SdrObjectWeakRef mxObjRef;
238 
239     struct Data
240     {
241         TableStyleSettings maSettings;
242         ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > mxTableStyle;
243     };
244 
245     void setData( const Data& rData );
246     void getData( Data& rData );
247 
248     Data maUndoData;
249     Data maRedoData;
250     bool mbHasRedoData;
251 };
252 
253 } }
254 
255 #endif
256