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 SW_UNDO_TABLE_HXX 25 #define SW_UNDO_TABLE_HXX 26 27 #include <undobj.hxx> 28 29 #ifndef _SVSTDARR_HXX 30 #define _SVSTDARR_USHORTS 31 #define _SVSTDARR_ULONGS 32 #define _SVSTDARR_BOOLS 33 #define _SVSTDARR_BYTES 34 #define _SVSTDARR_USHORTSSORT 35 #include <svl/svstdarr.hxx> 36 #endif 37 38 #include <swtypes.hxx> 39 #include <itabenum.hxx> 40 41 42 class SfxItemSet; 43 44 struct SwSaveRowSpan; 45 class _SaveTable; 46 class SwDDEFieldType; 47 class SwUndoSaveSections; 48 class SwUndoMoves; 49 class SwUndoDelete; 50 class SwSelBoxes; 51 class SwTblToTxtSaves; 52 class SwTable; 53 class SwTableBox; 54 class SwStartNode; 55 class SwTableNode; 56 class SwTableAutoFmt; 57 class SwTableSortBoxes; 58 59 60 class SwUndoInsTbl : public SwUndo 61 { 62 String sTblNm; 63 SwInsertTableOptions aInsTblOpts; 64 SwDDEFieldType* pDDEFldType; 65 SvUShorts* pColWidth; 66 SwRedlineData* pRedlData; 67 SwTableAutoFmt* pAutoFmt; 68 sal_uLong nSttNode; 69 sal_uInt16 nRows, nCols; 70 sal_uInt16 nAdjust; 71 72 public: 73 SwUndoInsTbl( const SwPosition&, sal_uInt16 nCols, sal_uInt16 nRows, 74 sal_uInt16 eAdjust, const SwInsertTableOptions& rInsTblOpts, 75 const SwTableAutoFmt* pTAFmt, const SvUShorts* pColArr, 76 const String & rName); 77 78 virtual ~SwUndoInsTbl(); 79 80 virtual void UndoImpl( ::sw::UndoRedoContext & ); 81 virtual void RedoImpl( ::sw::UndoRedoContext & ); 82 virtual void RepeatImpl( ::sw::RepeatContext & ); 83 84 virtual SwRewriter GetRewriter() const; 85 86 }; 87 88 class SwUndoTxtToTbl : public SwUndo, public SwUndRng 89 { 90 String sTblNm; 91 SwInsertTableOptions aInsTblOpts; 92 SvULongs* pDelBoxes; 93 SwTableAutoFmt* pAutoFmt; 94 SwHistory* pHistory; 95 sal_Unicode cTrenner; 96 sal_uInt16 nAdjust; 97 sal_Bool bSplitEnd : 1; 98 99 public: 100 SwUndoTxtToTbl( const SwPaM&, const SwInsertTableOptions&, sal_Unicode, 101 sal_uInt16, 102 const SwTableAutoFmt* pAFmt ); 103 104 virtual ~SwUndoTxtToTbl(); 105 106 107 virtual void UndoImpl( ::sw::UndoRedoContext & ); 108 virtual void RedoImpl( ::sw::UndoRedoContext & ); 109 virtual void RepeatImpl( ::sw::RepeatContext & ); 110 111 SwHistory& GetHistory(); // will be created if necessary 112 void AddFillBox( const SwTableBox& rBox ); 113 }; 114 115 class SwUndoTblToTxt : public SwUndo 116 { 117 String sTblNm; 118 SwDDEFieldType* pDDEFldType; 119 _SaveTable* pTblSave; 120 SwTblToTxtSaves* pBoxSaves; 121 SwHistory* pHistory; 122 sal_uLong nSttNd, nEndNd; 123 sal_uInt16 nAdjust; 124 sal_Unicode cTrenner; 125 sal_uInt16 nHdlnRpt; 126 sal_Bool bCheckNumFmt : 1; 127 128 public: 129 SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh ); 130 131 virtual ~SwUndoTblToTxt(); 132 133 virtual void UndoImpl( ::sw::UndoRedoContext & ); 134 virtual void RedoImpl( ::sw::UndoRedoContext & ); 135 virtual void RepeatImpl( ::sw::RepeatContext & ); 136 137 void SetRange( const SwNodeRange& ); 138 void AddBoxPos( SwDoc& rDoc, sal_uLong nNdIdx, sal_uLong nEndIdx, 139 xub_StrLen nCntntIdx = STRING_MAXLEN); 140 }; 141 142 class SwUndoAttrTbl : public SwUndo 143 { 144 sal_uLong nSttNode; 145 _SaveTable* pSaveTbl; 146 sal_Bool bClearTabCol : 1; 147 public: 148 SwUndoAttrTbl( const SwTableNode& rTblNd, sal_Bool bClearTabCols = sal_False ); 149 150 virtual ~SwUndoAttrTbl(); 151 152 virtual void UndoImpl( ::sw::UndoRedoContext & ); 153 virtual void RedoImpl( ::sw::UndoRedoContext & ); 154 }; 155 156 class SwUndoTblNumFmt; 157 158 class SwUndoTblAutoFmt : public SwUndo 159 { 160 sal_uLong nSttNode; 161 _SaveTable* pSaveTbl; 162 ::std::vector< ::boost::shared_ptr<SwUndoTblNumFmt> > m_Undos; 163 sal_Bool bSaveCntntAttr; 164 165 void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext); 166 167 public: 168 SwUndoTblAutoFmt( const SwTableNode& rTblNd, const SwTableAutoFmt& ); 169 170 virtual ~SwUndoTblAutoFmt(); 171 172 virtual void UndoImpl( ::sw::UndoRedoContext & ); 173 virtual void RedoImpl( ::sw::UndoRedoContext & ); 174 175 void SaveBoxCntnt( const SwTableBox& rBox ); 176 }; 177 178 class SwUndoTblNdsChg : public SwUndo 179 { 180 _SaveTable* pSaveTbl; 181 SvULongs aBoxes; 182 183 union { 184 SvULongs* pNewSttNds; 185 SwUndoSaveSections* pDelSects; 186 } Ptrs; 187 SvBools aMvBoxes; // for SplitRow (split Nodes of Box) 188 long nMin, nMax; // for redo of delete column 189 sal_uLong nSttNode, nCurrBox; 190 sal_uInt16 nCount, nRelDiff, nAbsDiff, nSetColType; 191 sal_Bool bFlag; 192 sal_Bool bSameHeight; // only used for SplitRow 193 public: 194 SwUndoTblNdsChg( SwUndoId UndoId, 195 const SwSelBoxes& rBoxes, 196 const SwTableNode& rTblNd, 197 long nMn, long nMx, 198 sal_uInt16 nCnt, sal_Bool bFlg, sal_Bool bSameHeight ); 199 200 // for SetColWidth 201 SwUndoTblNdsChg( SwUndoId UndoId, const SwSelBoxes& rBoxes, 202 const SwTableNode& rTblNd ); 203 204 virtual ~SwUndoTblNdsChg(); 205 206 virtual void UndoImpl( ::sw::UndoRedoContext & ); 207 virtual void RedoImpl( ::sw::UndoRedoContext & ); 208 209 void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld ); 210 void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld, 211 const SwSelBoxes& rBoxes, const SvULongs& rNodeCnts ); 212 void SaveSection( SwStartNode* pSttNd ); 213 void ReNewBoxes( const SwSelBoxes& rBoxes ); 214 215 SetColWidthParam(sal_uLong nBoxIdx,sal_uInt16 nMode,sal_uInt16 nType,SwTwips nAbsDif,SwTwips nRelDif)216 void SetColWidthParam( sal_uLong nBoxIdx, sal_uInt16 nMode, sal_uInt16 nType, 217 SwTwips nAbsDif, SwTwips nRelDif ) 218 { 219 nCurrBox = nBoxIdx; 220 nCount = nMode; 221 nSetColType = nType; 222 nAbsDiff = (sal_uInt16)nAbsDif; 223 nRelDiff = (sal_uInt16)nRelDif; 224 } 225 226 }; 227 228 class SwUndoTblMerge : public SwUndo, private SwUndRng 229 { 230 sal_uLong nTblNode; 231 _SaveTable* pSaveTbl; 232 SvULongs aBoxes, aNewSttNds; 233 SwUndoMoves* pMoves; 234 SwHistory* pHistory; 235 236 public: 237 SwUndoTblMerge( const SwPaM& rTblSel ); 238 239 virtual ~SwUndoTblMerge(); 240 241 virtual void UndoImpl( ::sw::UndoRedoContext & ); 242 virtual void RedoImpl( ::sw::UndoRedoContext & ); 243 244 void MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& rPos ); 245 246 void SetSelBoxes( const SwSelBoxes& rBoxes ); 247 AddNewBox(sal_uLong nSttNdIdx)248 void AddNewBox( sal_uLong nSttNdIdx ) 249 { aNewSttNds.Insert( nSttNdIdx, aNewSttNds.Count() ); } 250 251 void SaveCollection( const SwTableBox& rBox ); 252 253 }; 254 255 256 class SwUndoTblNumFmt : public SwUndo 257 { 258 SfxItemSet *pBoxSet; 259 SwHistory* pHistory; 260 String aStr, aNewFml; 261 262 sal_uLong nFmtIdx, nNewFmtIdx; 263 double fNum, fNewNum; 264 sal_uLong nNode; 265 sal_uLong nNdPos; 266 267 sal_Bool bNewFmt : 1; 268 sal_Bool bNewFml : 1; 269 sal_Bool bNewValue : 1; 270 271 public: 272 SwUndoTblNumFmt( const SwTableBox& rBox, const SfxItemSet* pNewSet = 0 ); 273 274 virtual ~SwUndoTblNumFmt(); 275 276 virtual void UndoImpl( ::sw::UndoRedoContext & ); 277 virtual void RedoImpl( ::sw::UndoRedoContext & ); 278 SetNumFmt(sal_uLong nNewNumFmtIdx,const double & rNewNumber)279 void SetNumFmt( sal_uLong nNewNumFmtIdx, const double& rNewNumber ) 280 { nFmtIdx = nNewNumFmtIdx; fNum = rNewNumber; } 281 void SetBox( const SwTableBox& rBox ); 282 }; 283 284 class _UndoTblCpyTbl_Entries; 285 286 class SwUndoTblCpyTbl : public SwUndo 287 { 288 _UndoTblCpyTbl_Entries* pArr; 289 SwUndoTblNdsChg* pInsRowUndo; 290 291 //b6341295: When redlining is active, PrepareRedline has to create the 292 //redlining attributes for the new and the old table cell content 293 SwUndo* PrepareRedline( SwDoc* pDoc, const SwTableBox& rBox, 294 const SwPosition& rPos, bool& rJoin, bool bRedo ); 295 public: 296 SwUndoTblCpyTbl(); 297 298 virtual ~SwUndoTblCpyTbl(); 299 300 virtual void UndoImpl( ::sw::UndoRedoContext & ); 301 virtual void RedoImpl( ::sw::UndoRedoContext & ); 302 303 void AddBoxBefore( const SwTableBox& rBox, sal_Bool bDelCntnt ); 304 void AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex& rIdx, 305 sal_Bool bDelCntnt ); 306 307 sal_Bool IsEmpty() const; 308 sal_Bool InsertRow( SwTable& rTbl, const SwSelBoxes& rBoxes, sal_uInt16 nCnt ); 309 }; 310 311 class SwUndoCpyTbl : public SwUndo 312 { 313 SwUndoDelete* pDel; 314 sal_uLong nTblNode; 315 public: 316 SwUndoCpyTbl(); 317 318 virtual ~SwUndoCpyTbl(); 319 320 virtual void UndoImpl( ::sw::UndoRedoContext & ); 321 virtual void RedoImpl( ::sw::UndoRedoContext & ); 322 SetTableSttIdx(sal_uLong nIdx)323 void SetTableSttIdx( sal_uLong nIdx ) { nTblNode = nIdx; } 324 }; 325 326 class SwUndoSplitTbl : public SwUndo 327 { 328 sal_uLong nTblNode, nOffset; 329 SwSaveRowSpan* mpSaveRowSpan; // stores row span values at the splitting row 330 _SaveTable* pSavTbl; 331 SwHistory* pHistory; 332 sal_uInt16 nMode, nFmlEnd; 333 sal_Bool bCalcNewSize; 334 public: 335 SwUndoSplitTbl( const SwTableNode& rTblNd, SwSaveRowSpan* pRowSp, 336 sal_uInt16 nMode, sal_Bool bCalcNewSize ); 337 338 virtual ~SwUndoSplitTbl(); 339 340 virtual void UndoImpl( ::sw::UndoRedoContext & ); 341 virtual void RedoImpl( ::sw::UndoRedoContext & ); 342 virtual void RepeatImpl( ::sw::RepeatContext & ); 343 SetTblNodeOffset(sal_uLong nIdx)344 void SetTblNodeOffset( sal_uLong nIdx ) { nOffset = nIdx - nTblNode; } GetHistory()345 SwHistory* GetHistory() { return pHistory; } 346 void SaveFormula( SwHistory& rHistory ); 347 }; 348 349 class SwUndoMergeTbl : public SwUndo 350 { 351 String aName; 352 sal_uLong nTblNode; 353 _SaveTable* pSavTbl, *pSavHdl; 354 SwHistory* pHistory; 355 sal_uInt16 nMode; 356 sal_Bool bWithPrev; 357 public: 358 SwUndoMergeTbl( const SwTableNode& rTblNd, const SwTableNode& rDelTblNd, 359 sal_Bool bWithPrev, sal_uInt16 nMode ); 360 361 virtual ~SwUndoMergeTbl(); 362 363 virtual void UndoImpl( ::sw::UndoRedoContext & ); 364 virtual void RedoImpl( ::sw::UndoRedoContext & ); 365 virtual void RepeatImpl( ::sw::RepeatContext & ); 366 367 void SaveFormula( SwHistory& rHistory ); 368 }; 369 370 371 //-------------------------------------------------------------------- 372 373 class SwUndoTblHeadline : public SwUndo 374 { 375 sal_uLong nTblNd; 376 sal_uInt16 nOldHeadline; 377 sal_uInt16 nNewHeadline; 378 public: 379 SwUndoTblHeadline( const SwTable&, sal_uInt16 nOldHdl, sal_uInt16 nNewHdl ); 380 381 virtual void UndoImpl( ::sw::UndoRedoContext & ); 382 virtual void RedoImpl( ::sw::UndoRedoContext & ); 383 virtual void RepeatImpl( ::sw::RepeatContext & ); 384 }; 385 386 #endif // SW_UNDO_TABLE_HXX 387 388