1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SW_UNDO_TABLE_HXX
#define SW_UNDO_TABLE_HXX
#include <undobj.hxx>
#include <memory>
#include <vector>
#include <set>
#include <swtypes.hxx>
#include <itabenum.hxx>
#include "boost/noncopyable.hpp"
#include "boost/scoped_ptr.hpp"
class SfxItemSet;
struct SwSaveRowSpan;
class _SaveTable;
class SwDDEFieldType;
class SwUndoSaveSections;
class SwUndoMoves;
class SwUndoDelete;
class SwSelBoxes;
class SwTblToTxtSaves;
class SwTable;
class SwTableBox;
class SwStartNode;
class SwTableNode;
class SwTableAutoFmt;
class SwTableSortBoxes;
class SwUndoInsTbl : public SwUndo
{
String sTblNm;
SwInsertTableOptions aInsTblOpts;
SwDDEFieldType* pDDEFldType;
std::vector<sal_uInt16> *pColWidth;
SwRedlineData* pRedlData;
SwTableAutoFmt* pAutoFmt;
sal_uLong nSttNode;
sal_uInt16 nRows, nCols;
sal_uInt16 nAdjust;
public:
SwUndoInsTbl( const SwPosition&, sal_uInt16 nCols, sal_uInt16 nRows,
sal_uInt16 eAdjust, const SwInsertTableOptions& rInsTblOpts,
const SwTableAutoFmt* pTAFmt, const std::vector<sal_uInt16> *pColArr,
const String & rName);
virtual ~SwUndoInsTbl();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual void RepeatImpl( ::sw::RepeatContext & );
virtual SwRewriter GetRewriter() const;
};
class SwUndoTxtToTbl : public SwUndo, public SwUndRng
{
String sTblNm;
SwInsertTableOptions aInsTblOpts;
std::vector<sal_uLong>* pDelBoxes;
SwTableAutoFmt* pAutoFmt;
SwHistory* pHistory;
sal_Unicode cTrenner;
sal_uInt16 nAdjust;
sal_Bool bSplitEnd : 1;
public:
SwUndoTxtToTbl( const SwPaM&, const SwInsertTableOptions&, sal_Unicode,
sal_uInt16,
const SwTableAutoFmt* pAFmt );
virtual ~SwUndoTxtToTbl();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual void RepeatImpl( ::sw::RepeatContext & );
SwHistory& GetHistory(); // will be created if necessary
void AddFillBox( const SwTableBox& rBox );
};
class SwUndoTblToTxt : public SwUndo
{
String sTblNm;
SwDDEFieldType* pDDEFldType;
_SaveTable* pTblSave;
SwTblToTxtSaves* pBoxSaves;
SwHistory* pHistory;
sal_uLong nSttNd, nEndNd;
sal_uInt16 nAdjust;
sal_Unicode cTrenner;
sal_uInt16 nHdlnRpt;
sal_Bool bCheckNumFmt : 1;
public:
SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh );
virtual ~SwUndoTblToTxt();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual void RepeatImpl( ::sw::RepeatContext & );
void SetRange( const SwNodeRange& );
void AddBoxPos( SwDoc& rDoc, sal_uLong nNdIdx, sal_uLong nEndIdx,
xub_StrLen nCntntIdx = STRING_MAXLEN);
};
class SwUndoAttrTbl : public SwUndo
{
sal_uLong nSttNode;
_SaveTable* pSaveTbl;
sal_Bool bClearTabCol : 1;
public:
SwUndoAttrTbl( const SwTableNode& rTblNd, sal_Bool bClearTabCols = sal_False );
virtual ~SwUndoAttrTbl();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
};
class SwUndoTblNumFmt;
class SwUndoTblAutoFmt : public SwUndo
{
sal_uLong nSttNode;
_SaveTable* pSaveTbl;
::std::vector< ::boost::shared_ptr<SwUndoTblNumFmt> > m_Undos;
sal_Bool bSaveCntntAttr;
void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext);
public:
SwUndoTblAutoFmt( const SwTableNode& rTblNd, const SwTableAutoFmt& );
virtual ~SwUndoTblAutoFmt();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
void SaveBoxCntnt( const SwTableBox& rBox );
};
class SwUndoTblNdsChg : public SwUndo, private boost::noncopyable
{
_SaveTable* pSaveTbl;
std::set<sal_uLong> aBoxes;
struct _BoxMove
{
sal_uLong index; ///< Index of this box.
bool hasMoved; ///< Has this box been moved already.
_BoxMove(sal_uLong idx, bool moved=false) : index(idx), hasMoved(moved) {};
bool operator<(const _BoxMove other) const { return index < other.index; };
};
boost::scoped_ptr< std::set<_BoxMove> > pNewSttNds;
boost::scoped_ptr< SwUndoSaveSections > pDelSects;
long nMin, nMax; // for redo of delete column
sal_uLong nSttNode, nCurrBox;
sal_uInt16 nCount, nRelDiff, nAbsDiff, nSetColType;
sal_Bool bFlag;
sal_Bool bSameHeight; // only used for SplitRow
public:
SwUndoTblNdsChg( SwUndoId UndoId,
const SwSelBoxes& rBoxes,
const SwTableNode& rTblNd,
long nMn, long nMx,
sal_uInt16 nCnt, sal_Bool bFlg, sal_Bool bSameHeight );
// for SetColWidth
SwUndoTblNdsChg( SwUndoId UndoId, const SwSelBoxes& rBoxes,
const SwTableNode& rTblNd );
virtual ~SwUndoTblNdsChg();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld );
void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld,
const SwSelBoxes& rBoxes, const std::vector<sal_uLong> &rNodeCnts );
void SaveSection( SwStartNode* pSttNd );
void ReNewBoxes( const SwSelBoxes& rBoxes );
void SetColWidthParam( sal_uLong nBoxIdx, sal_uInt16 nMode, sal_uInt16 nType,
SwTwips nAbsDif, SwTwips nRelDif )
{
nCurrBox = nBoxIdx;
nCount = nMode;
nSetColType = nType;
nAbsDiff = (sal_uInt16)nAbsDif;
nRelDiff = (sal_uInt16)nRelDif;
}
};
class SwUndoTblMerge : public SwUndo, private SwUndRng
{
sal_uLong nTblNode;
_SaveTable* pSaveTbl;
std::set<sal_uLong> aBoxes;
std::vector<sal_uLong> aNewSttNds;
SwUndoMoves* pMoves;
SwHistory* pHistory;
public:
SwUndoTblMerge( const SwPaM& rTblSel );
virtual ~SwUndoTblMerge();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
void MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& rPos );
void SetSelBoxes( const SwSelBoxes& rBoxes );
void AddNewBox( sal_uLong nSttNdIdx )
{ aNewSttNds.push_back( nSttNdIdx ); }
void SaveCollection( const SwTableBox& rBox );
};
class SwUndoTblNumFmt : public SwUndo
{
SfxItemSet *pBoxSet;
SwHistory* pHistory;
String aStr, aNewFml;
sal_uLong nFmtIdx, nNewFmtIdx;
double fNum, fNewNum;
sal_uLong nNode;
sal_uLong nNdPos;
sal_Bool bNewFmt : 1;
sal_Bool bNewFml : 1;
sal_Bool bNewValue : 1;
public:
SwUndoTblNumFmt( const SwTableBox& rBox, const SfxItemSet* pNewSet = 0 );
virtual ~SwUndoTblNumFmt();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
void SetNumFmt( sal_uLong nNewNumFmtIdx, const double& rNewNumber )
{ nFmtIdx = nNewNumFmtIdx; fNum = rNewNumber; }
void SetBox( const SwTableBox& rBox );
};
class _UndoTblCpyTbl_Entries;
class SwUndoTblCpyTbl : public SwUndo
{
_UndoTblCpyTbl_Entries* pArr;
SwUndoTblNdsChg* pInsRowUndo;
//b6341295: When redlining is active, PrepareRedline has to create the
//redlining attributes for the new and the old table cell content
SwUndo* PrepareRedline( SwDoc* pDoc, const SwTableBox& rBox,
const SwPosition& rPos, bool& rJoin, bool bRedo );
public:
SwUndoTblCpyTbl();
virtual ~SwUndoTblCpyTbl();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
void AddBoxBefore( const SwTableBox& rBox, sal_Bool bDelCntnt );
void AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex& rIdx,
sal_Bool bDelCntnt );
sal_Bool IsEmpty() const;
sal_Bool InsertRow( SwTable& rTbl, const SwSelBoxes& rBoxes, sal_uInt16 nCnt );
};
class SwUndoCpyTbl : public SwUndo
{
SwUndoDelete* pDel;
sal_uLong nTblNode;
public:
SwUndoCpyTbl();
virtual ~SwUndoCpyTbl();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
void SetTableSttIdx( sal_uLong nIdx ) { nTblNode = nIdx; }
};
class SwUndoSplitTbl : public SwUndo
{
sal_uLong nTblNode, nOffset;
SwSaveRowSpan* mpSaveRowSpan; // stores row span values at the splitting row
_SaveTable* pSavTbl;
SwHistory* pHistory;
sal_uInt16 nMode, nFmlEnd;
sal_Bool bCalcNewSize;
public:
SwUndoSplitTbl( const SwTableNode& rTblNd, SwSaveRowSpan* pRowSp,
sal_uInt16 nMode, sal_Bool bCalcNewSize );
virtual ~SwUndoSplitTbl();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual void RepeatImpl( ::sw::RepeatContext & );
void SetTblNodeOffset( sal_uLong nIdx ) { nOffset = nIdx - nTblNode; }
SwHistory* GetHistory() { return pHistory; }
void SaveFormula( SwHistory& rHistory );
};
class SwUndoMergeTbl : public SwUndo
{
String aName;
sal_uLong nTblNode;
_SaveTable* pSavTbl, *pSavHdl;
SwHistory* pHistory;
sal_uInt16 nMode;
sal_Bool bWithPrev;
public:
SwUndoMergeTbl( const SwTableNode& rTblNd, const SwTableNode& rDelTblNd,
sal_Bool bWithPrev, sal_uInt16 nMode );
virtual ~SwUndoMergeTbl();
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual void RepeatImpl( ::sw::RepeatContext & );
void SaveFormula( SwHistory& rHistory );
};
//--------------------------------------------------------------------
class SwUndoTblHeadline : public SwUndo
{
sal_uLong nTblNd;
sal_uInt16 nOldHeadline;
sal_uInt16 nNewHeadline;
public:
SwUndoTblHeadline( const SwTable&, sal_uInt16 nOldHdl, sal_uInt16 nNewHdl );
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual void RepeatImpl( ::sw::RepeatContext & );
};
#endif // SW_UNDO_TABLE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|