Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / svx / source / table / tableundo.hxx
blob2e1bc12c7ecdfbba2451cda1a7638c41d1cd13ba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_SVX_SOURCE_TABLE_TABLEUNDO_HXX
21 #define INCLUDED_SVX_SOURCE_TABLE_TABLEUNDO_HXX
23 #include <com/sun/star/container/XIndexAccess.hpp>
25 #include <svx/svdotable.hxx>
26 #include <svx/svdobj.hxx>
27 #include <svx/svdundo.hxx>
28 #include <svx/sdrobjectuser.hxx>
30 #include <celltypes.hxx>
32 namespace sdr::properties {
33 class TextProperties;
36 class OutlinerParaObject;
39 namespace sdr::table {
41 class CellUndo : public SdrUndoAction, public sdr::ObjectUser
43 public:
44 CellUndo( const tools::WeakReference<SdrObject>& xObjRef, const CellRef& xCell );
45 virtual ~CellUndo() override;
47 virtual void Undo() override;
48 virtual void Redo() override;
49 virtual bool Merge( SfxUndoAction *pNextAction ) override;
51 void dispose();
52 virtual void ObjectInDestruction(const SdrObject& rObject) override;
54 private:
55 struct Data
57 sdr::properties::TextProperties* mpProperties;
58 OutlinerParaObject* mpOutlinerParaObject;
60 OUString msFormula;
61 double mfValue;
62 ::sal_Int32 mnError;
63 bool mbMerged;
64 ::sal_Int32 mnRowSpan;
65 ::sal_Int32 mnColSpan;
67 Data()
68 : mpProperties(nullptr)
69 , mpOutlinerParaObject(nullptr)
70 , mfValue(0)
71 , mnError(0)
72 , mbMerged(false)
73 , mnRowSpan(0)
74 , mnColSpan(0)
79 void setDataToCell( const Data& rData );
80 void getDataFromCell( Data& rData );
82 tools::WeakReference<SdrObject> mxObjRef;
83 CellRef mxCell;
84 Data maUndoData;
85 Data maRedoData;
86 bool mbUndo;
90 class InsertRowUndo : public SdrUndoAction
92 public:
93 InsertRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aNewRows );
94 virtual ~InsertRowUndo() override;
96 virtual void Undo() override;
97 virtual void Redo() override;
99 private:
100 TableModelRef mxTable;
101 sal_Int32 mnIndex;
102 RowVector maRows;
103 bool mbUndo;
107 class RemoveRowUndo : public SdrUndoAction
109 public:
110 RemoveRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aRemovedRows );
111 virtual ~RemoveRowUndo() override;
113 virtual void Undo() override;
114 virtual void Redo() override;
116 private:
117 TableModelRef mxTable;
118 sal_Int32 mnIndex;
119 RowVector maRows;
120 bool mbUndo;
124 class InsertColUndo : public SdrUndoAction
126 public:
127 InsertColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells );
128 virtual ~InsertColUndo() override;
130 virtual void Undo() override;
131 virtual void Redo() override;
133 private:
134 TableModelRef mxTable;
135 sal_Int32 mnIndex;
136 ColumnVector maColumns;
137 CellVector maCells;
138 bool mbUndo;
142 class RemoveColUndo : public SdrUndoAction
144 public:
145 RemoveColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells );
146 virtual ~RemoveColUndo() override;
148 virtual void Undo() override;
149 virtual void Redo() override;
151 private:
152 TableModelRef mxTable;
153 sal_Int32 mnIndex;
154 ColumnVector maColumns;
155 CellVector maCells;
156 bool mbUndo;
160 class TableColumnUndo : public SdrUndoAction
162 public:
163 explicit TableColumnUndo( const TableColumnRef& xCol );
164 virtual ~TableColumnUndo() override;
166 virtual void Undo() override;
167 virtual void Redo() override;
168 virtual bool Merge( SfxUndoAction *pNextAction ) override;
170 private:
171 struct Data
173 sal_Int32 mnColumn;
174 sal_Int32 mnWidth;
175 bool mbOptimalWidth;
176 bool mbIsVisible;
177 bool mbIsStartOfNewPage;
178 OUString maName;
180 Data()
181 : mnColumn(0)
182 , mnWidth(0)
183 , mbOptimalWidth(false)
184 , mbIsVisible(false)
185 , mbIsStartOfNewPage(false)
190 void setData( const Data& rData );
191 void getData( Data& rData );
193 TableColumnRef mxCol;
194 Data maUndoData;
195 Data maRedoData;
196 bool mbHasRedoData;
200 class TableRowUndo : public SdrUndoAction
202 public:
203 explicit TableRowUndo( const TableRowRef& xRow );
204 virtual ~TableRowUndo() override;
206 virtual void Undo() override;
207 virtual void Redo() override;
208 virtual bool Merge( SfxUndoAction *pNextAction ) override;
210 private:
211 struct Data
213 sal_Int32 mnRow;
214 sal_Int32 mnHeight;
215 bool mbOptimalHeight;
216 bool mbIsVisible;
217 bool mbIsStartOfNewPage;
218 OUString maName;
221 void setData( const Data& rData );
222 void getData( Data& rData );
224 TableRowRef mxRow;
225 Data maUndoData;
226 Data maRedoData;
227 bool mbHasRedoData;
230 class TableStyleUndo : public SdrUndoAction
232 public:
233 explicit TableStyleUndo( const SdrTableObj& rTableObj );
235 virtual void Undo() override;
236 virtual void Redo() override;
238 private:
239 tools::WeakReference<SdrTableObj> mxObjRef;
241 struct Data
243 TableStyleSettings maSettings;
244 css::uno::Reference< css::container::XIndexAccess > mxTableStyle;
247 void setData( const Data& rData );
248 void getData( Data& rData );
250 Data maUndoData;
251 Data maRedoData;
252 bool mbHasRedoData;
257 #endif
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */