LibreOffice Module sw (master)  1
untbl.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <UndoTable.hxx>
21 #include <UndoRedline.hxx>
22 #include <UndoDelete.hxx>
23 #include <UndoSplitMove.hxx>
24 #include <UndoCore.hxx>
25 #include <fesh.hxx>
26 #include <hintids.hxx>
27 #include <hints.hxx>
28 #include <doc.hxx>
29 #include <docredln.hxx>
30 #include <IDocumentUndoRedo.hxx>
35 #include <editsh.hxx>
36 #include <docary.hxx>
37 #include <ndtxt.hxx>
38 #include <swtable.hxx>
39 #include <pam.hxx>
40 #include <tblsel.hxx>
41 #include <swundo.hxx>
42 #include <rolbck.hxx>
43 #include <ddefld.hxx>
44 #include <tabfrm.hxx>
45 #include <rowfrm.hxx>
46 #include <cellfrm.hxx>
47 #include <swcache.hxx>
48 #include <tblafmt.hxx>
49 #include <poolfmt.hxx>
50 #include <mvsave.hxx>
51 #include <cellatr.hxx>
52 #include <swtblfmt.hxx>
53 #include <swddetbl.hxx>
54 #include <redline.hxx>
55 #include <node2lay.hxx>
56 #include <tblrwcl.hxx>
57 #include <fmtanchr.hxx>
58 #include <strings.hrc>
59 #include <unochart.hxx>
60 #include <calbck.hxx>
61 
62 #include <memory>
63 #include <utility>
64 #include <vector>
65 
66 #ifdef DBG_UTIL
67 #define CHECK_TABLE(t) (t).CheckConsistency();
68 #else
69 #define CHECK_TABLE(t)
70 #endif
71 
72 #ifdef DBG_UTIL
73  #define DEBUG_REDLINE( pDoc ) sw_DebugRedline( pDoc );
74 #else
75  #define DEBUG_REDLINE( pDoc )
76 #endif
77 
78 typedef std::vector<std::shared_ptr<SfxItemSet> > SfxItemSets;
79 
81 {
83  std::unique_ptr<SfxItemSet> pBoxNumAttr;
84  std::unique_ptr<SwUndo> pUndo;
85 
86  // Was the last paragraph of the new and the first paragraph of the old content joined?
87  bool bJoin; // For redlining only
88 
89  explicit UndoTableCpyTable_Entry( const SwTableBox& rBox );
90 };
91 
92 namespace {
93 
94 class SaveBox;
95 class SaveLine;
96 
97 }
98 
99 class SaveTable
100 {
101  friend SaveBox;
102  friend SaveLine;
104  std::unique_ptr<SaveLine> m_pLine;
108  sal_uInt16 const m_nLineCount;
109  bool m_bModifyBox : 1;
110  bool const m_bSaveFormula : 1;
111  bool m_bNewModel : 1;
112 
113  SaveTable(const SaveTable&) = delete;
114  SaveTable& operator=(const SaveTable&) = delete;
115 
116 public:
117  SaveTable( const SwTable& rTable, sal_uInt16 nLnCnt = USHRT_MAX,
118  bool bSaveFormula = true );
119 
120  sal_uInt16 AddFormat( SwFrameFormat* pFormat, bool bIsLine );
121  void NewFrameFormat( const SwTableLine* , const SwTableBox*, sal_uInt16 nFormatPos,
122  SwFrameFormat* pOldFormat );
123 
124  void RestoreAttr( SwTable& rTable, bool bModifyBox = false );
125  void SaveContentAttrs( SwDoc* pDoc );
126  void CreateNew( SwTable& rTable, bool bCreateFrames = true,
127  bool bRestoreChart = true );
128  bool IsNewModel() const { return m_bNewModel; }
129 };
130 
131 namespace {
132 
133 class SaveLine
134 {
135  friend SaveTable;
136  friend class SaveBox;
137 
138  SaveLine* pNext;
139  SaveBox* pBox;
140  sal_uInt16 nItemSet;
141 
142  SaveLine(const SaveLine&) = delete;
143  SaveLine& operator=(const SaveLine&) = delete;
144 
145 public:
146  SaveLine( SaveLine* pPrev, const SwTableLine& rLine, SaveTable& rSTable );
147  ~SaveLine();
148 
149  void RestoreAttr( SwTableLine& rLine, SaveTable& rSTable );
150  void SaveContentAttrs( SwDoc* pDoc );
151 
152  void CreateNew( SwTable& rTable, SwTableBox& rParent, SaveTable& rSTable );
153 };
154 
155 class SaveBox
156 {
157  friend class SaveLine;
158 
159  SaveBox* pNext;
160  sal_uLong nSttNode;
161  long nRowSpan;
162  sal_uInt16 nItemSet;
163  union
164  {
165  SfxItemSets* pContentAttrs;
166  SaveLine* pLine;
167  } Ptrs;
168 
169 public:
170  SaveBox( SaveBox* pPrev, const SwTableBox& rBox, SaveTable& rSTable );
171  ~SaveBox();
172 
173  void RestoreAttr( SwTableBox& rBox, SaveTable& rSTable );
174  void SaveContentAttrs( SwDoc* pDoc );
175 
176  void CreateNew( SwTable& rTable, SwTableLine& rParent, SaveTable& rSTable );
177 };
178 
179 }
180 
181 #if OSL_DEBUG_LEVEL > 0
182 static void CheckTable( const SwTable& );
183 #define CHECKTABLE(t) CheckTable( t );
184 #else
185 #define CHECKTABLE(t)
186 #endif
187 
188 /* #130880: Crash in undo of table to text when the table has (freshly) merged cells
189 The order of cell content nodes in the nodes array is not given by the recursive table structure.
190 The algorithm must not rely on this even it holds for a fresh loaded table in odt file format.
191 So we need to remember not only the start node position but the end node position as well.
192 */
193 
195 {
198  sal_Int32 const m_nContent;
199  std::unique_ptr<SwHistory> m_pHstry;
200  // metadata references for first and last paragraph in cell
201  std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart;
202  std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd;
203 
204  SwTableToTextSave( SwDoc& rDoc, sal_uLong nNd, sal_uLong nEndIdx, sal_Int32 nContent );
205 
206 private:
207  SwTableToTextSave(const SwTableToTextSave&) = delete;
209 
210 };
211 
212 sal_uInt16 const aSave_BoxContentSet[] = {
218  0 };
219 
220 SwUndoInsTable::SwUndoInsTable( const SwPosition& rPos, sal_uInt16 nCl, sal_uInt16 nRw,
221  sal_uInt16 nAdj, const SwInsertTableOptions& rInsTableOpts,
222  const SwTableAutoFormat* pTAFormat,
223  const std::vector<sal_uInt16> *pColArr,
224  const OUString & rName)
225  : SwUndo( SwUndoId::INSTABLE, rPos.GetDoc() ),
226  m_aInsTableOptions( rInsTableOpts ),
227  m_nStartNode( rPos.nNode.GetIndex() ), m_nRows( nRw ), m_nColumns( nCl ), m_nAdjust( nAdj )
228 {
229  if( pColArr )
230  {
231  m_pColumnWidth.reset( new std::vector<sal_uInt16>(*pColArr) );
232  }
233  if( pTAFormat )
234  m_pAutoFormat.reset( new SwTableAutoFormat( *pTAFormat ) );
235 
236  // consider redline
237  SwDoc& rDoc = *rPos.nNode.GetNode().GetDoc();
239  {
240  m_pRedlineData.reset( new SwRedlineData( RedlineType::Insert, rDoc.getIDocumentRedlineAccess().GetRedlineAuthor() ) );
242  }
243 
244  m_sTableName = rName;
245 }
246 
248 {
249  m_pDDEFieldType.reset();
250  m_pColumnWidth.reset();
251  m_pRedlineData.reset();
252  m_pAutoFormat.reset();
253 }
254 
256 {
257  SwDoc & rDoc = rContext.GetDoc();
258  SwNodeIndex aIdx( rDoc.GetNodes(), m_nStartNode );
259 
260  SwTableNode* pTableNd = aIdx.GetNode().GetTableNode();
261  OSL_ENSURE( pTableNd, "no TableNode" );
262  pTableNd->DelFrames();
263 
265  rDoc.getIDocumentRedlineAccess().DeleteRedline( *pTableNd, true, RedlineType::Any );
267 
268  // move hard page breaks into next node
269  SwContentNode* pNextNd = rDoc.GetNodes()[ pTableNd->EndOfSectionIndex()+1 ]->GetContentNode();
270  if( pNextNd )
271  {
272  SwFrameFormat* pTableFormat = pTableNd->GetTable().GetFrameFormat();
273  const SfxPoolItem *pItem;
274 
275  if( SfxItemState::SET == pTableFormat->GetItemState( RES_PAGEDESC,
276  false, &pItem ) )
277  pNextNd->SetAttr( *pItem );
278 
279  if( SfxItemState::SET == pTableFormat->GetItemState( RES_BREAK,
280  false, &pItem ) )
281  pNextNd->SetAttr( *pItem );
282  }
283 
284  m_sTableName = pTableNd->GetTable().GetFrameFormat()->GetName();
285  if( auto pDDETable = dynamic_cast<const SwDDETable *>(&pTableNd->GetTable()) )
286  m_pDDEFieldType.reset(static_cast<SwDDEFieldType*>(pDDETable->GetDDEFieldType()->Copy().release()));
287 
288  rDoc.GetNodes().Delete( aIdx, pTableNd->EndOfSectionIndex() -
289  aIdx.GetIndex() + 1 );
290 
291  SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
292  rPam.DeleteMark();
293  rPam.GetPoint()->nNode = aIdx;
294  rPam.GetPoint()->nContent.Assign( rPam.GetContentNode(), 0 );
295 }
296 
298 {
299  SwDoc & rDoc = rContext.GetDoc();
300 
301  SwPosition const aPos(SwNodeIndex(rDoc.GetNodes(), m_nStartNode));
302  const SwTable* pTable = rDoc.InsertTable( m_aInsTableOptions, aPos, m_nRows, m_nColumns,
303  m_nAdjust,
304  m_pAutoFormat.get(), m_pColumnWidth.get() );
306  static_cast<SwFrameFormat*>(pTable->GetFrameFormat())->SetName( m_sTableName );
307  SwTableNode* pTableNode = rDoc.GetNodes()[m_nStartNode]->GetTableNode();
308 
309  if( m_pDDEFieldType )
310  {
312  *m_pDDEFieldType));
313  std::unique_ptr<SwDDETable> pDDETable(new SwDDETable( pTableNode->GetTable(), pNewType ));
314  pTableNode->SetNewTable( std::move(pDDETable) );
315  m_pDDEFieldType.reset();
316  }
317 
321  {
322  SwPaM aPam( *pTableNode->EndOfSectionNode(), *pTableNode, 1 );
323  SwContentNode* pCNd = aPam.GetContentNode( false );
324  if( pCNd )
325  aPam.GetMark()->nContent.Assign( pCNd, 0 );
326 
328  {
331 
334  }
335  else
337  }
338 }
339 
341 {
342  rContext.GetDoc().InsertTable(
345 }
346 
348 {
349  SwRewriter aRewriter;
350 
351  aRewriter.AddRule(UndoArg1, SwResId(STR_START_QUOTE));
352  aRewriter.AddRule(UndoArg2, m_sTableName);
353  aRewriter.AddRule(UndoArg3, SwResId(STR_END_QUOTE));
354 
355  return aRewriter;
356 }
357 
358 SwTableToTextSave::SwTableToTextSave( SwDoc& rDoc, sal_uLong nNd, sal_uLong nEndIdx, sal_Int32 nCnt )
359  : m_nSttNd( nNd ), m_nEndNd( nEndIdx), m_nContent( nCnt )
360 {
361  // keep attributes of the joined node
362  SwTextNode* pNd = rDoc.GetNodes()[ nNd ]->GetTextNode();
363  if( pNd )
364  {
365  m_pHstry.reset( new SwHistory );
366 
367  m_pHstry->Add( pNd->GetTextColl(), nNd, SwNodeType::Text );
368  if ( pNd->GetpSwpHints() )
369  {
370  m_pHstry->CopyAttr( pNd->GetpSwpHints(), nNd, 0,
371  pNd->GetText().getLength(), false );
372  }
373  if( pNd->HasSwAttrSet() )
374  m_pHstry->CopyFormatAttr( *pNd->GetpSwAttrSet(), nNd );
375 
376  if( !m_pHstry->Count() )
377  {
378  m_pHstry.reset();
379  }
380 
381  // METADATA: store
383  }
384 
385  // we also need to store the metadata reference of the _last_ paragraph
386  // we subtract 1 to account for the removed cell start/end node pair
387  // (after SectionUp, the end of the range points to the node after the cell)
388  if ( nEndIdx - 1 > nNd )
389  {
390  SwTextNode* pLastNode( rDoc.GetNodes()[ nEndIdx - 1 ]->GetTextNode() );
391  if( pLastNode )
392  {
393  // METADATA: store
394  m_pMetadataUndoEnd = pLastNode->CreateUndo();
395  }
396  }
397 }
398 
400  : SwUndo( SwUndoId::TABLETOTEXT, rTable.GetFrameFormat()->GetDoc() ),
401  sTableNm( rTable.GetFrameFormat()->GetName() ),
402  nSttNd( 0 ), nEndNd( 0 ),
403  cSeparator( cCh ), nHdlnRpt( rTable.GetRowsToRepeat() )
404 {
405  pTableSave.reset( new SaveTable( rTable ) );
406  m_vBoxSaves.reserve(rTable.GetTabSortBoxes().size());
407 
408  if( auto pDDETable = dynamic_cast<const SwDDETable *>(&rTable) )
409  pDDEFieldType.reset(static_cast<SwDDEFieldType*>(pDDETable->GetDDEFieldType()->Copy().release()));
410 
412 
413  pHistory.reset(new SwHistory);
414  const SwTableNode* pTableNd = rTable.GetTableNode();
415  sal_uLong nTableStt = pTableNd->GetIndex(), nTableEnd = pTableNd->EndOfSectionIndex();
416 
417  const SwFrameFormats& rFrameFormatTable = *pTableNd->GetDoc()->GetSpzFrameFormats();
418  for( size_t n = 0; n < rFrameFormatTable.size(); ++n )
419  {
420  SwFrameFormat* pFormat = rFrameFormatTable[ n ];
421  SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor();
422  SwPosition const*const pAPos = pAnchor->GetContentAnchor();
423  if (pAPos &&
424  ((RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId()) ||
425  (RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId())) &&
426  nTableStt <= pAPos->nNode.GetIndex() &&
427  pAPos->nNode.GetIndex() < nTableEnd )
428  {
429  pHistory->AddChangeFlyAnchor(*pFormat);
430  }
431  }
432 
433  if( !pHistory->Count() )
434  {
435  pHistory.reset();
436  }
437 }
438 
440 {
441  pDDEFieldType.reset();
442  pTableSave.reset();
443  m_vBoxSaves.clear();
444  pHistory.reset();
445 }
446 
448 {
449  SwDoc & rDoc = rContext.GetDoc();
450  SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
451 
452  SwNodeIndex aFrameIdx( rDoc.GetNodes(), nSttNd );
453  SwNodeIndex aEndIdx( rDoc.GetNodes(), nEndNd );
454 
455  pPam->GetPoint()->nNode = aFrameIdx;
456  pPam->SetMark();
457  pPam->GetPoint()->nNode = aEndIdx;
458  rDoc.DelNumRules( *pPam );
459  pPam->DeleteMark();
460 
461  // now collect all Uppers
462  SwNode2LayoutSaveUpperFrames aNode2Layout(aFrameIdx.GetNode());
463 
464  // create TableNode structure
466  pTableNd->GetTable().SetTableModel( pTableSave->IsNewModel() );
467  SwTableFormat* pTableFormat = rDoc.MakeTableFrameFormat( sTableNm, rDoc.GetDfltFrameFormat() );
468  pTableNd->GetTable().RegisterToFormat( *pTableFormat );
469  pTableNd->GetTable().SetRowsToRepeat( nHdlnRpt );
470 
471  // create old table structure
472  pTableSave->CreateNew( pTableNd->GetTable() );
473 
474  if( pDDEFieldType )
475  {
477  *pDDEFieldType));
478  std::unique_ptr<SwDDETable> pDDETable( new SwDDETable( pTableNd->GetTable(), pNewType ) );
479  pTableNd->SetNewTable( std::move(pDDETable), false );
480  pDDEFieldType.reset();
481  }
482 
483  if( bCheckNumFormat )
484  {
485  SwTableSortBoxes& rBxs = pTableNd->GetTable().GetTabSortBoxes();
486  for (size_t nBoxes = rBxs.size(); nBoxes; )
487  {
488  rDoc.ChkBoxNumFormat( *rBxs[ --nBoxes ], false );
489  }
490  }
491 
492  if( pHistory )
493  {
494  sal_uInt16 nTmpEnd = pHistory->GetTmpEnd();
495  pHistory->TmpRollback( &rDoc, 0 );
496  pHistory->SetTmpEnd( nTmpEnd );
497  }
498 
499  aNode2Layout.RestoreUpperFrames( rDoc.GetNodes(),
500  pTableNd->GetIndex(), pTableNd->GetIndex()+1 );
501 
502  // Is a table selection requested?
503  pPam->DeleteMark();
504  pPam->GetPoint()->nNode = *pTableNd->EndOfSectionNode();
505  pPam->SetMark();
506  pPam->GetPoint()->nNode = *pPam->GetNode().StartOfSectionNode();
507  pPam->Move( fnMoveForward, GoInContent );
508  pPam->Exchange();
509  pPam->Move( fnMoveBackward, GoInContent );
510 
511  ClearFEShellTabCols(rDoc, nullptr);
512 }
513 
514 // located in untbl.cxx and only an Undo object is allowed to call it
516  const SwTableToTextSaves& rSavedData )
517 {
518  SwNodeIndex aSttIdx( *this, nSttNd );
519  SwNodeIndex aEndIdx( *this, nEndNd+1 );
520 
521  SwTableNode * pTableNd = new SwTableNode( aSttIdx );
522  SwEndNode* pEndNd = new SwEndNode( aEndIdx, *pTableNd );
523 
524  aEndIdx = *pEndNd;
525 
526  /* Set pTableNd as start of section for all nodes in [nSttNd, nEndNd].
527  Delete all Frames attached to the nodes in that range. */
528  SwNode* pNd;
529  {
530  sal_uLong n, nTmpEnd = aEndIdx.GetIndex();
531  for( n = pTableNd->GetIndex() + 1; n < nTmpEnd; ++n )
532  {
533  if( ( pNd = (*this)[ n ] )->IsContentNode() )
534  static_cast<SwContentNode*>(pNd)->DelFrames(nullptr);
535  pNd->m_pStartOfSection = pTableNd;
536  }
537  }
538 
539  // than create table structure partially. First a single line that contains
540  // all boxes. The correct structure is then taken from SaveStruct.
541  SwTableBoxFormat* pBoxFormat = GetDoc()->MakeTableBoxFormat();
542  SwTableLineFormat* pLineFormat = GetDoc()->MakeTableLineFormat();
543  SwTableLine* pLine = new SwTableLine( pLineFormat, rSavedData.size(), nullptr );
544  pTableNd->GetTable().GetTabLines().insert( pTableNd->GetTable().GetTabLines().begin(), pLine );
545 
546  const std::shared_ptr<sw::mark::ContentIdxStore> pContentStore(sw::mark::ContentIdxStore::Create());
547  for( size_t n = rSavedData.size(); n; )
548  {
549  const SwTableToTextSave *const pSave = rSavedData[ --n ].get();
550  // if the start node was merged with last from prev. cell,
551  // subtract 1 from index to get the merged paragraph, and split that
552  aSttIdx = pSave->m_nSttNd - ( ( SAL_MAX_INT32 != pSave->m_nContent ) ? 1 : 0);
553  SwTextNode* pTextNd = aSttIdx.GetNode().GetTextNode();
554 
555  if( SAL_MAX_INT32 != pSave->m_nContent )
556  {
557  // split at ContentPosition, delete previous char (= separator)
558  OSL_ENSURE( pTextNd, "Where is my TextNode?" );
559  SwIndex aCntPos( pTextNd, pSave->m_nContent - 1 );
560 
561  pTextNd->EraseText( aCntPos, 1 );
562 
563  std::function<void (SwTextNode *, sw::mark::RestoreMode)> restoreFunc(
564  [&](SwTextNode *const pNewNode, sw::mark::RestoreMode const eMode)
565  {
566  if (!pContentStore->Empty())
567  {
568  pContentStore->Restore(*pNewNode, pSave->m_nContent, pSave->m_nContent + 1, eMode);
569  }
570  });
571  pTextNd->SplitContentNode(
572  SwPosition(aSttIdx, aCntPos), &restoreFunc);
573  }
574  else
575  {
576  pContentStore->Clear();
577  if( pTextNd )
578  pContentStore->Save( GetDoc(), aSttIdx.GetIndex(), pTextNd->GetText().getLength() );
579  }
580 
581  if( pTextNd )
582  {
583  // METADATA: restore
585  if( pTextNd->HasSwAttrSet() )
586  pTextNd->ResetAllAttr();
587 
588  if( pTextNd->GetpSwpHints() )
589  pTextNd->ClearSwpHintsArr( false );
590  }
591 
592  if( pSave->m_pHstry )
593  {
594  sal_uInt16 nTmpEnd = pSave->m_pHstry->GetTmpEnd();
595  pSave->m_pHstry->TmpRollback( GetDoc(), 0 );
596  pSave->m_pHstry->SetTmpEnd( nTmpEnd );
597  }
598 
599  // METADATA: restore
600  // end points to node after cell
601  if ( pSave->m_nEndNd - 1 > pSave->m_nSttNd )
602  {
603  SwTextNode* pLastNode = (*this)[ pSave->m_nEndNd - 1 ]->GetTextNode();
604  if (pLastNode)
605  {
606  pLastNode->RestoreMetadata(pSave->m_pMetadataUndoEnd);
607  }
608  }
609 
610  aEndIdx = pSave->m_nEndNd;
611  SwStartNode* pSttNd = new SwStartNode( aSttIdx, SwNodeType::Start,
613  pSttNd->m_pStartOfSection = pTableNd;
614  new SwEndNode( aEndIdx, *pSttNd );
615 
616  for( sal_uLong i = aSttIdx.GetIndex(); i < aEndIdx.GetIndex()-1; ++i )
617  {
618  pNd = (*this)[ i ];
619  pNd->m_pStartOfSection = pSttNd;
620  if( pNd->IsStartNode() )
621  i = pNd->EndOfSectionIndex();
622  }
623 
624  SwTableBox* pBox = new SwTableBox( pBoxFormat, *pSttNd, pLine );
625  pLine->GetTabBoxes().insert( pLine->GetTabBoxes().begin(), pBox );
626  }
627  return pTableNd;
628 }
629 
631 {
632  SwDoc & rDoc = rContext.GetDoc();
633  SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
634 
635  pPam->GetPoint()->nNode = nSttNd;
636  pPam->GetPoint()->nContent.Assign( nullptr, 0 );
637  SwNodeIndex aSaveIdx( pPam->GetPoint()->nNode, -1 );
638 
639  pPam->SetMark(); // log off all indices
640  pPam->DeleteMark();
641 
642  SwTableNode* pTableNd = pPam->GetNode().GetTableNode();
643  OSL_ENSURE( pTableNd, "Could not find any TableNode" );
644 
645  if( auto pDDETable = dynamic_cast<const SwDDETable *>(&pTableNd->GetTable()) )
646  pDDEFieldType.reset(static_cast<SwDDEFieldType*>(pDDETable->GetDDEFieldType()->Copy().release()));
647 
648  rDoc.TableToText( pTableNd, cSeparator );
649 
650  ++aSaveIdx;
651  SwContentNode* pCNd = aSaveIdx.GetNode().GetContentNode();
652  if( !pCNd && nullptr == ( pCNd = rDoc.GetNodes().GoNext( &aSaveIdx ) ) &&
653  nullptr == ( pCNd = SwNodes::GoPrevious( &aSaveIdx )) )
654  {
655  OSL_FAIL( "Where is the TextNode now?" );
656  }
657 
658  pPam->GetPoint()->nNode = aSaveIdx;
659  pPam->GetPoint()->nContent.Assign( pCNd, 0 );
660 
661  pPam->SetMark(); // log off all indices
662  pPam->DeleteMark();
663 }
664 
666 {
667  SwPaM *const pPam = & rContext.GetRepeatPaM();
668  SwTableNode *const pTableNd = pPam->GetNode().FindTableNode();
669  if( pTableNd )
670  {
671  // move cursor out of table
672  pPam->GetPoint()->nNode = *pTableNd->EndOfSectionNode();
673  pPam->Move( fnMoveForward, GoInContent );
674  pPam->SetMark();
675  pPam->DeleteMark();
676 
677  rContext.GetDoc().TableToText( pTableNd, cSeparator );
678  }
679 }
680 
682 {
683  nSttNd = rRg.aStart.GetIndex();
684  nEndNd = rRg.aEnd.GetIndex();
685 }
686 
687 void SwUndoTableToText::AddBoxPos( SwDoc& rDoc, sal_uLong nNdIdx, sal_uLong nEndIdx, sal_Int32 nContentIdx )
688 {
689  m_vBoxSaves.push_back(std::make_unique<SwTableToTextSave>(rDoc, nNdIdx, nEndIdx, nContentIdx));
690 }
691 
693  const SwInsertTableOptions& rInsTableOpts,
694  sal_Unicode cCh, sal_uInt16 nAdj,
695  const SwTableAutoFormat* pAFormat )
696  : SwUndo( SwUndoId::TEXTTOTABLE, rRg.GetDoc() ), SwUndRng( rRg ), aInsTableOpts( rInsTableOpts ),
697  pHistory( nullptr ), cSeparator( cCh ), nAdjust( nAdj )
698 {
699  if( pAFormat )
700  pAutoFormat.reset( new SwTableAutoFormat( *pAFormat ) );
701 
702  const SwPosition* pEnd = rRg.End();
703  SwNodes& rNds = rRg.GetDoc()->GetNodes();
704  bSplitEnd = pEnd->nContent.GetIndex() && ( pEnd->nContent.GetIndex()
705  != pEnd->nNode.GetNode().GetContentNode()->Len() ||
706  pEnd->nNode.GetIndex() >= rNds.GetEndOfContent().GetIndex()-1 );
707 }
708 
710 {
711  pAutoFormat.reset();
712 }
713 
715 {
716  SwDoc & rDoc = rContext.GetDoc();
717 
718  sal_uLong nTableNd = m_nSttNode;
719  if( m_nSttContent )
720  ++nTableNd; // Node was split previously
721  SwNodeIndex aIdx( rDoc.GetNodes(), nTableNd );
722  SwTableNode *const pTNd = aIdx.GetNode().GetTableNode();
723  OSL_ENSURE( pTNd, "Could not find a TableNode" );
724 
725  RemoveIdxFromSection( rDoc, nTableNd );
726 
727  sTableNm = pTNd->GetTable().GetFrameFormat()->GetName();
728 
729  if( pHistory )
730  {
731  pHistory->TmpRollback( &rDoc, 0 );
733  }
734 
735  if( !mvDelBoxes.empty() )
736  {
737  pTNd->DelFrames();
738  SwTable& rTable = pTNd->GetTable();
739  for( size_t n = mvDelBoxes.size(); n; )
740  {
741  SwTableBox* pBox = rTable.GetTableBox( mvDelBoxes[ --n ] );
742  if( pBox )
743  ::DeleteBox_( rTable, pBox, nullptr, false, false );
744  else {
745  OSL_ENSURE( false, "Where is my box?" );
746  }
747  }
748  }
749 
750  SwNodeIndex aEndIdx( *pTNd->EndOfSectionNode() );
751  rDoc.TableToText( pTNd, 0x0b == cSeparator ? 0x09 : cSeparator );
752 
753  // join again at start?
754  SwPaM aPam(rDoc.GetNodes().GetEndOfContent());
755  SwPosition *const pPos = aPam.GetPoint();
756  if( m_nSttContent )
757  {
758  pPos->nNode = nTableNd;
759  pPos->nContent.Assign(pPos->nNode.GetNode().GetContentNode(), 0);
760  if (aPam.Move(fnMoveBackward, GoInContent))
761  {
762  SwNodeIndex & rIdx = aPam.GetPoint()->nNode;
763 
764  // than move, relatively, the Cursor/etc. again
765  RemoveIdxRel( rIdx.GetIndex()+1, *pPos );
766 
767  rIdx.GetNode().GetContentNode()->JoinNext();
768  }
769  }
770 
771  // join again at end?
772  if( bSplitEnd )
773  {
774  SwNodeIndex& rIdx = pPos->nNode;
775  rIdx = m_nEndNode;
776  SwTextNode* pTextNd = rIdx.GetNode().GetTextNode();
777  if( pTextNd && pTextNd->CanJoinNext() )
778  {
779  aPam.GetMark()->nContent.Assign( nullptr, 0 );
780  aPam.GetPoint()->nContent.Assign( nullptr, 0 );
781 
782  // than move, relatively, the Cursor/etc. again
783  pPos->nContent.Assign(pTextNd, pTextNd->GetText().getLength());
784  RemoveIdxRel( m_nEndNode + 1, *pPos );
785 
786  pTextNd->JoinNext();
787  }
788  }
789 
790  AddUndoRedoPaM(rContext);
791 }
792 
794 {
795  SwPaM & rPam( AddUndoRedoPaM(rContext) );
796  RemoveIdxFromRange(rPam, false);
797  SetPaM(rPam);
798 
799  SwTable const*const pTable = rContext.GetDoc().TextToTable(
800  aInsTableOpts, rPam, cSeparator, nAdjust, pAutoFormat.get() );
801  static_cast<SwFrameFormat*>(pTable->GetFrameFormat())->SetName( sTableNm );
802 }
803 
805 {
806  // no Table In Table
807  if (!rContext.GetRepeatPaM().GetNode().FindTableNode())
808  {
809  rContext.GetDoc().TextToTable( aInsTableOpts, rContext.GetRepeatPaM(),
811  pAutoFormat.get() );
812  }
813 }
814 
816 {
817  mvDelBoxes.push_back( rBox.GetSttIdx() );
818 }
819 
821 {
822  if( !pHistory )
823  pHistory = new SwHistory;
824  return *pHistory;
825 }
826 
827 SwUndoTableHeadline::SwUndoTableHeadline( const SwTable& rTable, sal_uInt16 nOldHdl,
828  sal_uInt16 nNewHdl )
829  : SwUndo( SwUndoId::TABLEHEADLINE, rTable.GetFrameFormat()->GetDoc() ),
830  nOldHeadline( nOldHdl ),
831  nNewHeadline( nNewHdl )
832 {
833  OSL_ENSURE( !rTable.GetTabSortBoxes().empty(), "Table without content" );
834  const SwStartNode *pSttNd = rTable.GetTabSortBoxes()[ 0 ]->GetSttNd();
835  OSL_ENSURE( pSttNd, "Box without content" );
836 
837  nTableNd = pSttNd->StartOfSectionIndex();
838 }
839 
841 {
842  SwDoc & rDoc = rContext.GetDoc();
843  SwTableNode* pTNd = rDoc.GetNodes()[ nTableNd ]->GetTableNode();
844  OSL_ENSURE( pTNd, "could not find any TableNode" );
845 
846  rDoc.SetRowsToRepeat( pTNd->GetTable(), nOldHeadline );
847 }
848 
850 {
851  SwDoc & rDoc = rContext.GetDoc();
852 
853  SwTableNode* pTNd = rDoc.GetNodes()[ nTableNd ]->GetTableNode();
854  OSL_ENSURE( pTNd, "could not find any TableNode" );
855 
856  rDoc.SetRowsToRepeat( pTNd->GetTable(), nNewHeadline );
857 }
858 
860 {
861  SwTableNode *const pTableNd =
862  rContext.GetRepeatPaM().GetNode().FindTableNode();
863  if( pTableNd )
864  {
865  rContext.GetDoc().SetRowsToRepeat( pTableNd->GetTable(), nNewHeadline );
866  }
867 }
868 
869 SaveTable::SaveTable( const SwTable& rTable, sal_uInt16 nLnCnt, bool bSaveFormula )
870  : m_aTableSet(*rTable.GetFrameFormat()->GetAttrSet().GetPool(), aTableSetRange),
871  m_pSwTable(&rTable), m_nLineCount(nLnCnt), m_bSaveFormula(bSaveFormula)
872 {
873  m_bModifyBox = false;
874  m_bNewModel = rTable.IsNewModel();
876  m_pLine.reset( new SaveLine( nullptr, *rTable.GetTabLines()[ 0 ], *this ) );
877 
878  SaveLine* pLn = m_pLine.get();
879  if( USHRT_MAX == nLnCnt )
880  nLnCnt = rTable.GetTabLines().size();
881  for( sal_uInt16 n = 1; n < nLnCnt; ++n )
882  pLn = new SaveLine( pLn, *rTable.GetTabLines()[ n ], *this );
883 
885  m_pSwTable = nullptr;
886 }
887 
888 sal_uInt16 SaveTable::AddFormat( SwFrameFormat* pFormat, bool bIsLine )
889 {
890  size_t nRet = m_aFrameFormats.GetPos(pFormat);
891  if( SIZE_MAX == nRet )
892  {
893  // Create copy of ItemSet
894  auto pSet = std::make_shared<SfxItemSet>( *pFormat->GetAttrSet().GetPool(),
896  pSet->Put( pFormat->GetAttrSet() );
897  // When a formula is set, never save the value. It possibly must be
898  // recalculated.
899  // Save formulas always in plain text.
900  const SfxPoolItem* pItem;
901  if( SfxItemState::SET == pSet->GetItemState( RES_BOXATR_FORMULA, true, &pItem ))
902  {
903  pSet->ClearItem( RES_BOXATR_VALUE );
904  if (m_pSwTable && m_bSaveFormula)
905  {
907  aMsgHint.m_eFlags = TBL_BOXNAME;
908  SwTableBoxFormula* pFormulaItem = const_cast<SwTableBoxFormula*>(static_cast<const SwTableBoxFormula*>(pItem));
909  pFormulaItem->ChgDefinedIn( pFormat );
910  pFormulaItem->ChangeState( &aMsgHint );
911  pFormulaItem->ChgDefinedIn( nullptr );
912  }
913  }
914  nRet = m_aSets.size();
915  m_aSets.push_back(pSet);
916  m_aFrameFormats.insert(m_aFrameFormats.begin() + nRet, pFormat);
917  }
918  return static_cast<sal_uInt16>(nRet);
919 }
920 
921 void SaveTable::RestoreAttr( SwTable& rTable, bool bMdfyBox )
922 {
923  m_bModifyBox = bMdfyBox;
924 
925  // first, get back attributes of TableFrameFormat
926  SwFrameFormat* pFormat = rTable.GetFrameFormat();
927  SfxItemSet& rFormatSet = const_cast<SfxItemSet&>(static_cast<SfxItemSet const &>(pFormat->GetAttrSet()));
928  rFormatSet.ClearItem();
929  rFormatSet.Put(m_aTableSet);
930 
931  if( pFormat->IsInCache() )
932  {
933  SwFrame::GetCache().Delete( pFormat );
934  pFormat->SetInCache( false );
935  }
936 
937  // for safety, invalidate all TableFrames
938  SwIterator<SwTabFrame,SwFormat> aIter( *pFormat );
939  for( SwTabFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() )
940  if( pLast->GetTable() == &rTable )
941  {
942  pLast->InvalidateAll();
943  pLast->SetCompletePaint();
944  }
945 
946  // fill FrameFormats with defaults (0)
947  pFormat = nullptr;
948  for (size_t n = m_aSets.size(); n; --n)
949  m_aFrameFormats.push_back(pFormat);
950 
951  const size_t nLnCnt = (USHRT_MAX == m_nLineCount)
952  ? rTable.GetTabLines().size()
953  : m_nLineCount;
954 
955  SaveLine* pLn = m_pLine.get();
956  for( size_t n = 0; n < nLnCnt; ++n, pLn = pLn->pNext )
957  {
958  if( !pLn )
959  {
960  OSL_ENSURE( false, "Number of lines changed" );
961  break;
962  }
963 
964  pLn->RestoreAttr( *rTable.GetTabLines()[ n ], *this );
965  }
966 
968  m_bModifyBox = false;
969 }
970 
972 {
973  m_pLine->SaveContentAttrs(pDoc);
974 }
975 
976 void SaveTable::CreateNew( SwTable& rTable, bool bCreateFrames,
977  bool bRestoreChart )
978 {
979  FndBox_ aTmpBox( nullptr, nullptr );
980  aTmpBox.DelFrames( rTable );
981 
982  // first, get back attributes of TableFrameFormat
983  SwFrameFormat* pFormat = rTable.GetFrameFormat();
984  SfxItemSet& rFormatSet = const_cast<SfxItemSet&>(static_cast<SfxItemSet const &>(pFormat->GetAttrSet()));
985  rFormatSet.ClearItem();
986  rFormatSet.Put(m_aTableSet);
987 
988  if( pFormat->IsInCache() )
989  {
990  SwFrame::GetCache().Delete( pFormat );
991  pFormat->SetInCache( false );
992  }
993 
994  // SwTableBox must have a format - the SwTableBox takes ownership of it
995  SwTableBoxFormat *const pNewFormat(pFormat->GetDoc()->MakeTableBoxFormat());
996  SwTableBox aParent(pNewFormat, rTable.GetTabLines().size(), nullptr);
997 
998  // fill FrameFormats with defaults (0)
999  pFormat = nullptr;
1000  for( size_t n = m_aSets.size(); n; --n )
1001  m_aFrameFormats.push_back(pFormat);
1002 
1003  m_pLine->CreateNew(rTable, aParent, *this);
1005 
1006  // add new lines, delete old ones
1007  const size_t nOldLines = (USHRT_MAX == m_nLineCount)
1008  ? rTable.GetTabLines().size()
1009  : m_nLineCount;
1010 
1011  SwDoc *pDoc = rTable.GetFrameFormat()->GetDoc();
1013  size_t n = 0;
1014  for( ; n < aParent.GetTabLines().size(); ++n )
1015  {
1016  SwTableLine* pLn = aParent.GetTabLines()[ n ];
1017  pLn->SetUpper( nullptr );
1018  if( n < nOldLines )
1019  {
1020  SwTableLine* pOld = rTable.GetTabLines()[ n ];
1021 
1022  // TL_CHART2: notify chart about boxes to be removed
1023  const SwTableBoxes &rBoxes = pOld->GetTabBoxes();
1024  const size_t nBoxes = rBoxes.size();
1025  for (size_t k = 0; k < nBoxes; ++k)
1026  {
1027  SwTableBox *pBox = rBoxes[k];
1028  if (pPCD)
1029  pPCD->DeleteBox( &rTable, *pBox );
1030  }
1031 
1032  rTable.GetTabLines()[n] = pLn;
1033  delete pOld;
1034  }
1035  else
1036  rTable.GetTabLines().insert( rTable.GetTabLines().begin() + n, pLn );
1037  }
1038 
1039  if( n < nOldLines )
1040  {
1041  // remove remaining lines...
1042  for (size_t k1 = 0; k1 < nOldLines - n; ++k1)
1043  {
1044  const SwTableBoxes &rBoxes = rTable.GetTabLines()[n + k1]->GetTabBoxes();
1045  const size_t nBoxes = rBoxes.size();
1046  for (size_t k2 = 0; k2 < nBoxes; ++k2)
1047  {
1048  SwTableBox *pBox = rBoxes[k2];
1049  // TL_CHART2: notify chart about boxes to be removed
1050  if (pPCD)
1051  pPCD->DeleteBox( &rTable, *pBox );
1052  }
1053  }
1054 
1055  for( SwTableLines::const_iterator it = rTable.GetTabLines().begin() + n;
1056  it != rTable.GetTabLines().begin() + nOldLines; ++it )
1057  delete *it;
1058  rTable.GetTabLines().erase( rTable.GetTabLines().begin() + n, rTable.GetTabLines().begin() + nOldLines );
1059  }
1060 
1061  aParent.GetTabLines().erase( aParent.GetTabLines().begin(), aParent.GetTabLines().begin() + n );
1062  assert(aParent.GetTabLines().empty());
1063 
1064  if( bCreateFrames )
1065  aTmpBox.MakeFrames( rTable );
1066  if( bRestoreChart )
1067  {
1068  // TL_CHART2: need to inform chart of probably changed cell names
1069  pDoc->UpdateCharts( rTable.GetFrameFormat()->GetName() );
1070  }
1071 }
1072 
1073 void SaveTable::NewFrameFormat( const SwTableLine* pTableLn, const SwTableBox* pTableBx,
1074  sal_uInt16 nFormatPos, SwFrameFormat* pOldFormat )
1075 {
1076  SwDoc* pDoc = pOldFormat->GetDoc();
1077 
1078  SwFrameFormat* pFormat = m_aFrameFormats[ nFormatPos ];
1079  if( !pFormat )
1080  {
1081  if( pTableLn )
1082  pFormat = pDoc->MakeTableLineFormat();
1083  else
1084  pFormat = pDoc->MakeTableBoxFormat();
1085  pFormat->SetFormatAttr(*m_aSets[nFormatPos]);
1086  m_aFrameFormats[nFormatPos] = pFormat;
1087  }
1088 
1089  // first re-assign Frames
1090  SwIterator<SwLayoutFrame,SwFormat> aIter( *pOldFormat );
1091  for( SwFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() )
1092  {
1093  if( pTableLn ? static_cast<SwRowFrame*>(pLast)->GetTabLine() == pTableLn
1094  : static_cast<SwCellFrame*>(pLast)->GetTabBox() == pTableBx )
1095  {
1096  pLast->RegisterToFormat(*pFormat);
1097  pLast->InvalidateAll();
1098  pLast->ReinitializeFrameSizeAttrFlags();
1099  if ( !pTableLn )
1100  {
1101  static_cast<SwCellFrame*>(pLast)->SetDerivedVert( false );
1102  static_cast<SwCellFrame*>(pLast)->CheckDirChange();
1103  }
1104  }
1105  }
1106 
1107  // than re-assign myself
1108  if ( pTableLn )
1109  const_cast<SwTableLine*>(pTableLn)->RegisterToFormat( *pFormat );
1110  else if ( pTableBx )
1111  const_cast<SwTableBox*>(pTableBx)->RegisterToFormat( *pFormat );
1112 
1113  if (m_bModifyBox && !pTableLn)
1114  {
1115  const SfxPoolItem& rOld = pOldFormat->GetFormatAttr( RES_BOXATR_FORMAT ),
1116  & rNew = pFormat->GetFormatAttr( RES_BOXATR_FORMAT );
1117  if( rOld != rNew )
1118  pFormat->ModifyNotification( &rOld, &rNew );
1119  }
1120 
1121  if( !pOldFormat->HasWriterListeners() )
1122  delete pOldFormat;
1123 }
1124 
1125 SaveLine::SaveLine( SaveLine* pPrev, const SwTableLine& rLine, SaveTable& rSTable )
1126  : pNext( nullptr )
1127 {
1128  if( pPrev )
1129  pPrev->pNext = this;
1130 
1131  nItemSet = rSTable.AddFormat( rLine.GetFrameFormat(), true );
1132 
1133  pBox = new SaveBox( nullptr, *rLine.GetTabBoxes()[ 0 ], rSTable );
1134  SaveBox* pBx = pBox;
1135  for( size_t n = 1; n < rLine.GetTabBoxes().size(); ++n )
1136  pBx = new SaveBox( pBx, *rLine.GetTabBoxes()[ n ], rSTable );
1137 }
1138 
1139 SaveLine::~SaveLine()
1140 {
1141  delete pBox;
1142  delete pNext;
1143 }
1144 
1145 void SaveLine::RestoreAttr( SwTableLine& rLine, SaveTable& rSTable )
1146 {
1147  rSTable.NewFrameFormat( &rLine, nullptr, nItemSet, rLine.GetFrameFormat() );
1148 
1149  SaveBox* pBx = pBox;
1150  for( size_t n = 0; n < rLine.GetTabBoxes().size(); ++n, pBx = pBx->pNext )
1151  {
1152  if( !pBx )
1153  {
1154  OSL_ENSURE( false, "Number of boxes changed" );
1155  break;
1156  }
1157  pBx->RestoreAttr( *rLine.GetTabBoxes()[ n ], rSTable );
1158  }
1159 }
1160 
1161 void SaveLine::SaveContentAttrs( SwDoc* pDoc )
1162 {
1163  pBox->SaveContentAttrs( pDoc );
1164  if( pNext )
1165  pNext->SaveContentAttrs( pDoc );
1166 }
1167 
1168 void SaveLine::CreateNew( SwTable& rTable, SwTableBox& rParent, SaveTable& rSTable )
1169 {
1170  SwTableLineFormat* pFormat = static_cast<SwTableLineFormat*>(rSTable.m_aFrameFormats[ nItemSet ]);
1171  if( !pFormat )
1172  {
1173  SwDoc* pDoc = rTable.GetFrameFormat()->GetDoc();
1174  pFormat = pDoc->MakeTableLineFormat();
1175  pFormat->SetFormatAttr(*rSTable.m_aSets[nItemSet]);
1176  rSTable.m_aFrameFormats[nItemSet] = pFormat;
1177  }
1178  SwTableLine* pNew = new SwTableLine( pFormat, 1, &rParent );
1179 
1180  rParent.GetTabLines().push_back( pNew );
1181 
1182  pBox->CreateNew( rTable, *pNew, rSTable );
1183 
1184  if( pNext )
1185  pNext->CreateNew( rTable, rParent, rSTable );
1186 }
1187 
1188 SaveBox::SaveBox( SaveBox* pPrev, const SwTableBox& rBox, SaveTable& rSTable )
1189  : pNext( nullptr ), nSttNode( ULONG_MAX ), nRowSpan(0)
1190 {
1191  Ptrs.pLine = nullptr;
1192 
1193  if( pPrev )
1194  pPrev->pNext = this;
1195 
1196  nItemSet = rSTable.AddFormat( rBox.GetFrameFormat(), false );
1197 
1198  if( rBox.GetSttNd() )
1199  {
1200  nSttNode = rBox.GetSttIdx();
1201  nRowSpan = rBox.getRowSpan();
1202  }
1203  else
1204  {
1205  Ptrs.pLine = new SaveLine( nullptr, *rBox.GetTabLines()[ 0 ], rSTable );
1206 
1207  SaveLine* pLn = Ptrs.pLine;
1208  for( size_t n = 1; n < rBox.GetTabLines().size(); ++n )
1209  pLn = new SaveLine( pLn, *rBox.GetTabLines()[ n ], rSTable );
1210  }
1211 }
1212 
1213 SaveBox::~SaveBox()
1214 {
1215  if( ULONG_MAX == nSttNode ) // no EndBox
1216  delete Ptrs.pLine;
1217  else
1218  delete Ptrs.pContentAttrs;
1219  delete pNext;
1220 }
1221 
1222 void SaveBox::RestoreAttr( SwTableBox& rBox, SaveTable& rSTable )
1223 {
1224  rSTable.NewFrameFormat( nullptr, &rBox, nItemSet, rBox.GetFrameFormat() );
1225 
1226  if( ULONG_MAX == nSttNode ) // no EndBox
1227  {
1228  if( rBox.GetTabLines().empty() )
1229  {
1230  OSL_ENSURE( false, "Number of lines changed" );
1231  }
1232  else
1233  {
1234  SaveLine* pLn = Ptrs.pLine;
1235  for( size_t n = 0; n < rBox.GetTabLines().size(); ++n, pLn = pLn->pNext )
1236  {
1237  if( !pLn )
1238  {
1239  OSL_ENSURE( false, "Number of lines changed" );
1240  break;
1241  }
1242 
1243  pLn->RestoreAttr( *rBox.GetTabLines()[ n ], rSTable );
1244  }
1245  }
1246  }
1247  else if( rBox.GetSttNd() && rBox.GetSttIdx() == nSttNode )
1248  {
1249  if( Ptrs.pContentAttrs )
1250  {
1251  SwNodes& rNds = rBox.GetFrameFormat()->GetDoc()->GetNodes();
1252  sal_uInt16 nSet = 0;
1253  sal_uLong nEnd = rBox.GetSttNd()->EndOfSectionIndex();
1254  for( sal_uLong n = nSttNode + 1; n < nEnd; ++n )
1255  {
1256  SwContentNode* pCNd = rNds[ n ]->GetContentNode();
1257  if( pCNd )
1258  {
1259  std::shared_ptr<SfxItemSet> pSet( (*Ptrs.pContentAttrs)[ nSet++ ] );
1260  if( pSet )
1261  {
1262  sal_uInt16 const *pRstAttr = aSave_BoxContentSet;
1263  while( *pRstAttr )
1264  {
1265  pCNd->ResetAttr( *pRstAttr, *(pRstAttr+1) );
1266  pRstAttr += 2;
1267  }
1268  pCNd->SetAttr( *pSet );
1269  }
1270  else
1271  pCNd->ResetAllAttr();
1272  }
1273  }
1274  }
1275  }
1276  else
1277  {
1278  OSL_ENSURE( false, "Box not anymore at the same node" );
1279  }
1280 }
1281 
1282 void SaveBox::SaveContentAttrs( SwDoc* pDoc )
1283 {
1284  if( ULONG_MAX == nSttNode ) // no EndBox
1285  {
1286  // continue in current line
1287  Ptrs.pLine->SaveContentAttrs( pDoc );
1288  }
1289  else
1290  {
1291  sal_uLong nEnd = pDoc->GetNodes()[ nSttNode ]->EndOfSectionIndex();
1292  Ptrs.pContentAttrs = new SfxItemSets;
1293  for( sal_uLong n = nSttNode + 1; n < nEnd; ++n )
1294  {
1295  SwContentNode* pCNd = pDoc->GetNodes()[ n ]->GetContentNode();
1296  if( pCNd )
1297  {
1298  std::shared_ptr<SfxItemSet> pSet;
1299  if( pCNd->HasSwAttrSet() )
1300  {
1301  pSet.reset( new SfxItemSet( pDoc->GetAttrPool(),
1302  aSave_BoxContentSet ) );
1303  pSet->Put( *pCNd->GetpSwAttrSet() );
1304  }
1305 
1306  Ptrs.pContentAttrs->push_back( pSet );
1307  }
1308  }
1309  }
1310  if( pNext )
1311  pNext->SaveContentAttrs( pDoc );
1312 }
1313 
1314 void SaveBox::CreateNew( SwTable& rTable, SwTableLine& rParent, SaveTable& rSTable )
1315 {
1316  SwTableBoxFormat* pFormat = static_cast<SwTableBoxFormat*>(rSTable.m_aFrameFormats[ nItemSet ]);
1317  if( !pFormat )
1318  {
1319  SwDoc* pDoc = rTable.GetFrameFormat()->GetDoc();
1320  pFormat = pDoc->MakeTableBoxFormat();
1321  pFormat->SetFormatAttr(*rSTable.m_aSets[nItemSet]);
1322  rSTable.m_aFrameFormats[nItemSet] = pFormat;
1323  }
1324 
1325  if( ULONG_MAX == nSttNode ) // no EndBox
1326  {
1327  SwTableBox* pNew = new SwTableBox( pFormat, 1, &rParent );
1328  rParent.GetTabBoxes().push_back( pNew );
1329 
1330  Ptrs.pLine->CreateNew( rTable, *pNew, rSTable );
1331  }
1332  else
1333  {
1334  // search box for StartNode in old table
1335  SwTableBox* pBox = rTable.GetTableBox( nSttNode );
1336  if (pBox)
1337  {
1338  SwFrameFormat* pOld = pBox->GetFrameFormat();
1339  pBox->RegisterToFormat( *pFormat );
1340  if( !pOld->HasWriterListeners() )
1341  delete pOld;
1342 
1343  pBox->setRowSpan( nRowSpan );
1344 
1345  SwTableBoxes* pTBoxes = &pBox->GetUpper()->GetTabBoxes();
1346  pTBoxes->erase( std::find( pTBoxes->begin(), pTBoxes->end(), pBox ) );
1347 
1348  pBox->SetUpper( &rParent );
1349  pTBoxes = &rParent.GetTabBoxes();
1350  pTBoxes->push_back( pBox );
1351  }
1352  }
1353 
1354  if( pNext )
1355  pNext->CreateNew( rTable, rParent, rSTable );
1356 }
1357 
1358 // UndoObject for attribute changes on table
1359 SwUndoAttrTable::SwUndoAttrTable( const SwTableNode& rTableNd, bool bClearTabCols )
1360  : SwUndo( SwUndoId::TABLE_ATTR, rTableNd.GetDoc() ),
1361  nSttNode( rTableNd.GetIndex() )
1362 {
1363  bClearTabCol = bClearTabCols;
1364  pSaveTable.reset( new SaveTable( rTableNd.GetTable() ) );
1365 }
1366 
1368 {
1369 }
1370 
1372 {
1373  SwDoc & rDoc = rContext.GetDoc();
1374  SwTableNode* pTableNd = rDoc.GetNodes()[ nSttNode ]->GetTableNode();
1375  OSL_ENSURE( pTableNd, "no TableNode" );
1376 
1377  if (pTableNd)
1378  {
1379  SaveTable* pOrig = new SaveTable( pTableNd->GetTable() );
1380  pSaveTable->RestoreAttr( pTableNd->GetTable() );
1381  pSaveTable.reset( pOrig );
1382  }
1383 
1384  if( bClearTabCol )
1385  {
1386  ClearFEShellTabCols(rDoc, nullptr);
1387  }
1388 }
1389 
1391 {
1392  UndoImpl(rContext);
1393 }
1394 
1395 // UndoObject for AutoFormat on Table
1397  const SwTableAutoFormat& rAFormat )
1398  : SwUndo( SwUndoId::TABLE_AUTOFMT, rTableNd.GetDoc() )
1399  , m_TableStyleName(rTableNd.GetTable().GetTableStyleName())
1400  , nSttNode( rTableNd.GetIndex() )
1401  , bSaveContentAttr( false )
1402  , m_nRepeatHeading(rTableNd.GetTable().GetRowsToRepeat())
1403 {
1404  pSaveTable.reset( new SaveTable( rTableNd.GetTable() ) );
1405 
1406  if( rAFormat.IsFont() || rAFormat.IsJustify() )
1407  {
1408  // then also go over the ContentNodes of the EndBoxes and collect
1409  // all paragraph attributes
1410  pSaveTable->SaveContentAttrs( const_cast<SwDoc*>(rTableNd.GetDoc()) );
1411  bSaveContentAttr = true;
1412  }
1413 }
1414 
1416 {
1417 }
1418 
1420 {
1421  m_Undos.push_back(std::make_shared<SwUndoTableNumFormat>(rBox));
1422 }
1423 
1424 void
1426 {
1427  SwDoc & rDoc = rContext.GetDoc();
1428  SwTableNode* pTableNd = rDoc.GetNodes()[ nSttNode ]->GetTableNode();
1429  OSL_ENSURE( pTableNd, "no TableNode" );
1430 
1431  SwTable& table = pTableNd->GetTable();
1432  if (table.GetTableStyleName() != m_TableStyleName)
1433  {
1434  OUString const temp(table.GetTableStyleName());
1436  m_TableStyleName = temp;
1437  }
1438  SaveTable* pOrig = new SaveTable( table );
1439  // then go also over the ContentNodes of the EndBoxes and collect
1440  // all paragraph attributes
1441  if( bSaveContentAttr )
1442  pOrig->SaveContentAttrs( &rDoc );
1443 
1444  if (bUndo)
1445  {
1446  for (size_t n = m_Undos.size(); 0 < n; --n)
1447  {
1448  m_Undos.at(n-1)->UndoImpl(rContext);
1449  }
1450 
1452  }
1453 
1454  pSaveTable->RestoreAttr( pTableNd->GetTable(), !bUndo );
1455  pSaveTable.reset( pOrig );
1456 }
1457 
1459 {
1460  UndoRedo(true, rContext);
1461 }
1462 
1464 {
1465  UndoRedo(false, rContext);
1466 }
1467 
1469  const SwSelBoxes& rBoxes,
1470  const SwTableNode& rTableNd,
1471  long nMn, long nMx,
1472  sal_uInt16 nCnt, bool bFlg, bool bSmHght )
1473  : SwUndo( nAction, rTableNd.GetDoc() ),
1474  m_nMin( nMn ), m_nMax( nMx ),
1475  m_nSttNode( rTableNd.GetIndex() ),
1476  m_nCount( nCnt ),
1477  m_bFlag( bFlg ),
1478  m_bSameHeight( bSmHght )
1479 {
1480  const SwTable& rTable = rTableNd.GetTable();
1481  m_pSaveTable.reset( new SaveTable( rTable ) );
1482 
1483  // and remember selection
1484  ReNewBoxes( rBoxes );
1485 }
1486 
1488 {
1489  if (rBoxes.size() != m_Boxes.size())
1490  {
1491  m_Boxes.clear();
1492  for (size_t n = 0; n < rBoxes.size(); ++n)
1493  {
1494  m_Boxes.insert( rBoxes[n]->GetSttIdx() );
1495  }
1496  }
1497 }
1498 
1500 {
1501 }
1502 
1504  const SwTableSortBoxes& rOld )
1505 {
1506  const SwTable& rTable = rTableNd.GetTable();
1507  const SwTableSortBoxes& rTableBoxes = rTable.GetTabSortBoxes();
1508 
1509  OSL_ENSURE( ! IsDelBox(), "wrong Action" );
1510  m_pNewSttNds.reset( new std::set<BoxMove> );
1511 
1512  size_t i = 0;
1513  for (size_t n = 0; n < rOld.size(); ++i)
1514  {
1515  if( rOld[ n ] == rTableBoxes[ i ] )
1516  ++n;
1517  else
1518  // new box: insert sorted
1519  m_pNewSttNds->insert( BoxMove(rTableBoxes[ i ]->GetSttIdx()) );
1520  }
1521 
1522  for( ; i < rTableBoxes.size(); ++i )
1523  // new box: insert sorted
1524  m_pNewSttNds->insert( BoxMove(rTableBoxes[ i ]->GetSttIdx()) );
1525 }
1526 
1527 static SwTableLine* lcl_FindTableLine( const SwTable& rTable,
1528  const SwTableBox& rBox )
1529 {
1530  SwTableLine* pRet = nullptr;
1531  // i63949: For nested cells we have to take nLineNo - 1, too, not 0!
1532  const SwTableLines &rTableLines = ( rBox.GetUpper()->GetUpper() != nullptr ) ?
1533  rBox.GetUpper()->GetUpper()->GetTabLines()
1534  : rTable.GetTabLines();
1535  const SwTableLine* pLine = rBox.GetUpper();
1536  sal_uInt16 nLineNo = rTableLines.GetPos( pLine );
1537  pRet = rTableLines[nLineNo - 1];
1538 
1539  return pRet;
1540 }
1541 
1542 static const SwTableLines& lcl_FindParentLines( const SwTable& rTable,
1543  const SwTableBox& rBox )
1544 {
1545  const SwTableLines& rRet =
1546  ( rBox.GetUpper()->GetUpper() != nullptr ) ?
1547  rBox.GetUpper()->GetUpper()->GetTabLines() :
1548  rTable.GetTabLines();
1549 
1550  return rRet;
1551 }
1552 
1554  const SwTableSortBoxes& rOld,
1555  const SwSelBoxes& rBoxes,
1556  const std::vector<sal_uLong> &rNodeCnts )
1557 {
1558  const SwTable& rTable = rTableNd.GetTable();
1559  const SwTableSortBoxes& rTableBoxes = rTable.GetTabSortBoxes();
1560 
1561  OSL_ENSURE( ! IsDelBox(), "wrong Action" );
1562  m_pNewSttNds.reset( new std::set<BoxMove> );
1563 
1564  OSL_ENSURE( rTable.IsNewModel() || rOld.size() + m_nCount * rBoxes.size() == rTableBoxes.size(),
1565  "unexpected boxes" );
1566  OSL_ENSURE( rOld.size() <= rTableBoxes.size(), "more unexpected boxes" );
1567  for (size_t n = 0, i = 0; i < rTableBoxes.size(); ++i)
1568  {
1569  if( ( n < rOld.size() ) &&
1570  ( rOld[ n ] == rTableBoxes[ i ] ) )
1571  {
1572  // box already known? Then nothing to be done.
1573  ++n;
1574  }
1575  else
1576  {
1577  // new box found: insert (obey sort order)
1578  const SwTableBox* pBox = rTableBoxes[ i ];
1579 
1580  // find the source box. It must be one in rBoxes.
1581  // We found the right one if it's in the same column as pBox.
1582  // No, if more than one selected cell in the same column has been split,
1583  // we have to look for the nearest one (i65201)!
1584  const SwTableBox* pSourceBox = nullptr;
1585  const SwTableBox* pCheckBox = nullptr;
1586  const SwTableLine* pBoxLine = pBox->GetUpper();
1587  sal_uInt16 nLineDiff = lcl_FindParentLines(rTable,*pBox).GetPos(pBoxLine);
1588  sal_uInt16 nLineNo = 0;
1589  for (size_t j = 0; j < rBoxes.size(); ++j)
1590  {
1591  pCheckBox = rBoxes[j];
1592  if( pCheckBox->GetUpper()->GetUpper() == pBox->GetUpper()->GetUpper() )
1593  {
1594  const SwTableLine* pCheckLine = pCheckBox->GetUpper();
1595  sal_uInt16 nCheckLine = lcl_FindParentLines( rTable, *pCheckBox ).
1596  GetPos( pCheckLine );
1597  if( ( !pSourceBox || nCheckLine > nLineNo ) && nCheckLine < nLineDiff )
1598  {
1599  nLineNo = nCheckLine;
1600  pSourceBox = pCheckBox;
1601  }
1602  }
1603  }
1604 
1605  // find the line number difference
1606  // (to help determine bNodesMoved flag below)
1607  nLineDiff = nLineDiff - nLineNo;
1608  OSL_ENSURE( pSourceBox, "Split source box not found!" );
1609  // find out how many nodes the source box used to have
1610  // (to help determine bNodesMoved flag below)
1611  size_t nNdsPos = 0;
1612  while( rBoxes[ nNdsPos ] != pSourceBox )
1613  ++nNdsPos;
1614  sal_uLong nNodes = rNodeCnts[ nNdsPos ];
1615 
1616  // When a new table cell is created, it either gets a new
1617  // node, or it gets node(s) from elsewhere. The undo must
1618  // know, of course, and thus we must determine here just
1619  // where pBox's nodes are from:
1620  // If 1) the source box has lost nodes, and
1621  // 2) we're in the node range that got nodes
1622  // then pBox received nodes from elsewhere.
1623  // If bNodesMoved is set for pBox the undo must move the
1624  // boxes back, otherwise it must delete them.
1625  bool bNodesMoved = pSourceBox &&
1626  ( nNodes != ( pSourceBox->GetSttNd()->EndOfSectionIndex() -
1627  pSourceBox->GetSttIdx() ) )
1628  && ( nNodes - 1 > nLineDiff );
1629  m_pNewSttNds->insert( BoxMove(pBox->GetSttIdx(), bNodesMoved) );
1630  }
1631  }
1632 }
1633 
1635 {
1636  OSL_ENSURE( IsDelBox(), "wrong Action" );
1637  if (m_pDelSects == nullptr)
1638  m_pDelSects.reset(new SwUndoSaveSections);
1639 
1640  SwTableNode* pTableNd = pSttNd->FindTableNode();
1641  std::unique_ptr<SwUndoSaveSection, o3tl::default_delete<SwUndoSaveSection>> pSave(new SwUndoSaveSection);
1642  pSave->SaveSection( SwNodeIndex( *pSttNd ));
1643 
1644  m_pDelSects->push_back(std::move(pSave));
1645  m_nSttNode = pTableNd->GetIndex();
1646 }
1647 
1649 {
1650  SwDoc & rDoc = rContext.GetDoc();
1651  SwNodeIndex aIdx( rDoc.GetNodes(), m_nSttNode );
1652 
1653  SwTableNode *const pTableNd = aIdx.GetNode().GetTableNode();
1654  OSL_ENSURE( pTableNd, "no TableNode" );
1655 
1656  SwTableFormulaUpdate aMsgHint( &pTableNd->GetTable() );
1657  aMsgHint.m_eFlags = TBL_BOXPTR;
1658  rDoc.getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
1659 
1660  CHECK_TABLE( pTableNd->GetTable() )
1661 
1662  FndBox_ aTmpBox( nullptr, nullptr );
1663  // ? TL_CHART2: notification or locking of controller required ?
1664 
1666  SwSelBoxes aDelBoxes;
1667  std::vector< std::pair<SwTableBox *, sal_uLong> > aDelNodes;
1668  if( IsDelBox() )
1669  {
1670  // Trick: add missing boxes in any line, they will be connected
1671  // correctly when calling CreateNew
1672  SwTableBox* pCpyBox = pTableNd->GetTable().GetTabSortBoxes()[0];
1673  SwTableBoxes& rLnBoxes = pCpyBox->GetUpper()->GetTabBoxes();
1674 
1675  // restore sections
1676  for (size_t n = m_pDelSects->size(); n; )
1677  {
1678  SwUndoSaveSection *const pSave = (*m_pDelSects)[ --n ].get();
1679  pSave->RestoreSection( &rDoc, &aIdx, SwTableBoxStartNode );
1680  if( pSave->GetHistory() )
1681  pSave->GetHistory()->Rollback( &rDoc );
1682  SwTableBox* pBox = new SwTableBox( static_cast<SwTableBoxFormat*>(pCpyBox->GetFrameFormat()), aIdx,
1683  pCpyBox->GetUpper() );
1684  rLnBoxes.push_back( pBox );
1685  }
1686  m_pDelSects->clear();
1687  }
1688  else if( !m_pNewSttNds->empty() )
1689  {
1690  // Then the nodes have be moved and not deleted!
1691  // But for that we need a temp array.
1692  std::vector<BoxMove> aTmp( m_pNewSttNds->begin(), m_pNewSttNds->end() );
1693 
1694  // backwards
1695  for (size_t n = aTmp.size(); n > 0 ; )
1696  {
1697  --n;
1698  // delete box from table structure
1699  sal_uLong nIdx = aTmp[n].index;
1700  SwTableBox* pBox = pTableNd->GetTable().GetTableBox( nIdx );
1701  OSL_ENSURE( pBox, "Where is my TableBox?" );
1702 
1703  // TL_CHART2: notify chart about box to be removed
1704  if (pPCD)
1705  pPCD->DeleteBox( &pTableNd->GetTable(), *pBox );
1706 
1707  // insert _before_ deleting the section - otherwise the box
1708  // has no start node so all boxes sort equal in SwSelBoxes
1709  aDelBoxes.insert(pBox);
1710 
1711  if( aTmp[n].hasMoved )
1712  {
1713  SwNodeRange aRg( *pBox->GetSttNd(), 1,
1714  *pBox->GetSttNd()->EndOfSectionNode() );
1715 
1716  SwTableLine* pLine = lcl_FindTableLine( pTableNd->GetTable(), *pBox );
1717  SwNodeIndex aInsPos( *(pLine->GetTabBoxes()[0]->GetSttNd()), 2 );
1718 
1719  // adjust all StartNode indices
1720  size_t i = n;
1721  sal_uLong nSttIdx = aInsPos.GetIndex() - 2,
1722  nNdCnt = aRg.aEnd.GetIndex() - aRg.aStart.GetIndex();
1723  while( i && aTmp[ --i ].index > nSttIdx )
1724  aTmp[ i ].index += nNdCnt;
1725 
1726  // first delete box
1727  delete pBox;
1728  // than move nodes
1729  rDoc.GetNodes().MoveNodes( aRg, rDoc.GetNodes(), aInsPos, false );
1730  }
1731  else
1732  {
1733  aDelNodes.emplace_back(pBox, nIdx);
1734  }
1735  }
1736  }
1737  else
1738  {
1739  // Remove nodes from nodes array (backwards!)
1740  std::set<BoxMove>::reverse_iterator it;
1741  for( it = m_pNewSttNds->rbegin(); it != m_pNewSttNds->rend(); ++it )
1742  {
1743  sal_uLong nIdx = (*it).index;
1744  SwTableBox* pBox = pTableNd->GetTable().GetTableBox( nIdx );
1745  OSL_ENSURE( pBox, "Where's my table box?" );
1746  // TL_CHART2: notify chart about box to be removed
1747  if (pPCD)
1748  pPCD->DeleteBox( &pTableNd->GetTable(), *pBox );
1749  aDelBoxes.insert(pBox);
1750  aDelNodes.emplace_back(pBox, nIdx);
1751  }
1752  }
1753 
1754  // fdo#57197: before deleting the SwTableBoxes, delete the SwTabFrames
1755  aTmpBox.SetTableLines(aDelBoxes, pTableNd->GetTable());
1756  aTmpBox.DelFrames(pTableNd->GetTable());
1757 
1758  // do this _after_ deleting Frames because disposing SwAccessible requires
1759  // connection to the nodes, see SwAccessibleChild::IsAccessible()
1760  for (const std::pair<SwTableBox *, sal_uLong> & rDelNode : aDelNodes)
1761  {
1762  // first disconnect box from node, otherwise ~SwTableBox would
1763  // access pBox->pSttNd, deleted by DeleteSection
1764  rDelNode.first->RemoveFromTable();
1765  rDoc.getIDocumentContentOperations().DeleteSection(rDoc.GetNodes()[ rDelNode.second ]);
1766  }
1767 
1768  // Remove boxes from table structure
1769  for( size_t n = 0; n < aDelBoxes.size(); ++n )
1770  {
1771  SwTableBox* pCurrBox = aDelBoxes[n];
1772  SwTableBoxes* pTBoxes = &pCurrBox->GetUpper()->GetTabBoxes();
1773  pTBoxes->erase( std::find( pTBoxes->begin(), pTBoxes->end(), pCurrBox ) );
1774  delete pCurrBox;
1775  }
1776 
1777  m_pSaveTable->CreateNew( pTableNd->GetTable(), true, false );
1778 
1779  // TL_CHART2: need to inform chart of probably changed cell names
1780  rDoc.UpdateCharts( pTableNd->GetTable().GetFrameFormat()->GetName() );
1781 
1782  if( IsDelBox() )
1783  m_nSttNode = pTableNd->GetIndex();
1784  ClearFEShellTabCols(rDoc, nullptr);
1785  CHECK_TABLE( pTableNd->GetTable() )
1786 }
1787 
1789 {
1790  SwDoc & rDoc = rContext.GetDoc();
1791 
1792  SwTableNode* pTableNd = rDoc.GetNodes()[ m_nSttNode ]->GetTableNode();
1793  OSL_ENSURE( pTableNd, "no TableNode" );
1794  CHECK_TABLE( pTableNd->GetTable() )
1795 
1796  SwSelBoxes aSelBoxes;
1797  for (const auto& rBox : m_Boxes)
1798  {
1799  SwTableBox* pBox = pTableNd->GetTable().GetTableBox( rBox );
1800  aSelBoxes.insert( pBox );
1801  }
1802 
1803  // create SelBoxes and call InsertCell/-Row/SplitTable
1804  switch( GetId() )
1805  {
1807  rDoc.InsertCol( aSelBoxes, m_nCount, m_bFlag );
1808  break;
1809 
1811  rDoc.InsertRow( aSelBoxes, m_nCount, m_bFlag );
1812  break;
1813 
1814  case SwUndoId::TABLE_SPLIT:
1815  rDoc.SplitTable( aSelBoxes, m_bFlag, m_nCount, m_bSameHeight );
1816  break;
1818  case SwUndoId::ROW_DELETE:
1819  case SwUndoId::COL_DELETE:
1820  {
1821  SwTableFormulaUpdate aMsgHint( &pTableNd->GetTable() );
1822  aMsgHint.m_eFlags = TBL_BOXPTR;
1823  rDoc.getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
1824  SwTable &rTable = pTableNd->GetTable();
1825  if( m_nMax > m_nMin && rTable.IsNewModel() )
1826  rTable.PrepareDeleteCol( m_nMin, m_nMax );
1827  rTable.DeleteSel( &rDoc, aSelBoxes, nullptr, this, true, true );
1828  m_nSttNode = pTableNd->GetIndex();
1829  }
1830  break;
1831  default:
1832  ;
1833  }
1834  ClearFEShellTabCols(rDoc, nullptr);
1835  CHECK_TABLE( pTableNd->GetTable() )
1836 }
1837 
1839  : SwUndo( SwUndoId::TABLE_MERGE, rTableSel.GetDoc() ), SwUndRng( rTableSel )
1840 {
1841  const SwTableNode* pTableNd = rTableSel.GetNode().FindTableNode();
1842  OSL_ENSURE( pTableNd, "Where is the TableNode?" );
1843  pSaveTable.reset( new SaveTable( pTableNd->GetTable() ) );
1844  nTableNode = pTableNd->GetIndex();
1845 }
1846 
1848 {
1849  pSaveTable.reset();
1850  m_vMoves.clear();
1851  pHistory.reset();
1852 }
1853 
1855 {
1856  SwDoc & rDoc = rContext.GetDoc();
1857  SwNodeIndex aIdx( rDoc.GetNodes(), nTableNode );
1858 
1859  SwTableNode *const pTableNd = aIdx.GetNode().GetTableNode();
1860  OSL_ENSURE( pTableNd, "no TableNode" );
1861 
1862  SwTableFormulaUpdate aMsgHint( &pTableNd->GetTable() );
1863  aMsgHint.m_eFlags = TBL_BOXPTR;
1864  rDoc.getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
1865 
1866  FndBox_ aTmpBox( nullptr, nullptr );
1867  // ? TL_CHART2: notification or locking of controller required ?
1868 
1869  // 1. restore deleted boxes:
1870  // Trick: add missing boxes in any line, they will be connected
1871  // correctly when calling CreateNew
1872  SwTableBox *pBox, *pCpyBox = pTableNd->GetTable().GetTabSortBoxes()[0];
1873  SwTableBoxes& rLnBoxes = pCpyBox->GetUpper()->GetTabBoxes();
1874 
1875  CHECKTABLE(pTableNd->GetTable())
1876 
1877  SwSelBoxes aSelBoxes;
1879 
1880  for (const auto& rBox : m_Boxes)
1881  {
1882  aIdx = rBox;
1883  SwStartNode* pSttNd = rDoc.GetNodes().MakeTextSection( aIdx,
1884  SwTableBoxStartNode, pColl );
1885  pBox = new SwTableBox( static_cast<SwTableBoxFormat*>(pCpyBox->GetFrameFormat()), *pSttNd,
1886  pCpyBox->GetUpper() );
1887  rLnBoxes.push_back( pBox );
1888 
1889  aSelBoxes.insert( pBox );
1890  }
1891 
1892  CHECKTABLE(pTableNd->GetTable())
1893 
1895  // 2. deleted the inserted boxes
1896  // delete nodes (from last to first)
1897  for( size_t n = aNewSttNds.size(); n; )
1898  {
1899  // remove box from table structure
1900  sal_uLong nIdx = aNewSttNds[ --n ];
1901 
1902  if( !nIdx && n )
1903  {
1904  nIdx = aNewSttNds[ --n ];
1905  pBox = pTableNd->GetTable().GetTableBox( nIdx );
1906  OSL_ENSURE( pBox, "Where is my TableBox?" );
1907 
1908  if( !pSaveTable->IsNewModel() )
1910  *pBox->GetSttNd()->EndOfSectionNode() ), pColl );
1911 
1912  // this was the separator -> restore moved ones
1913  for (size_t i = m_vMoves.size(); i; )
1914  {
1915  SwTextNode* pTextNd = nullptr;
1916  sal_Int32 nDelPos = 0;
1917  SwUndoMove *const pUndo = m_vMoves[ --i ].get();
1918  if( !pUndo->IsMoveRange() )
1919  {
1920  pTextNd = rDoc.GetNodes()[ pUndo->GetDestSttNode() ]->GetTextNode();
1921  nDelPos = pUndo->GetDestSttContent() - 1;
1922  }
1923  pUndo->UndoImpl(rContext);
1924  if( pUndo->IsMoveRange() )
1925  {
1926  // delete the unnecessary node
1927  aIdx = pUndo->GetEndNode();
1928  SwContentNode *pCNd = aIdx.GetNode().GetContentNode();
1929  if( pCNd )
1930  {
1931  SwNodeIndex aTmp( aIdx, -1 );
1932  SwContentNode *pMove = aTmp.GetNode().GetContentNode();
1933  if( pMove )
1934  pCNd->MoveTo( *pMove );
1935  }
1936  rDoc.GetNodes().Delete( aIdx );
1937  }
1938  else if( pTextNd )
1939  {
1940  // also delete not needed attributes
1941  SwIndex aTmpIdx( pTextNd, nDelPos );
1942  if( pTextNd->GetpSwpHints() && pTextNd->GetpSwpHints()->Count() )
1943  pTextNd->RstTextAttr( aTmpIdx, pTextNd->GetText().getLength() - nDelPos + 1 );
1944  // delete separator
1945  pTextNd->EraseText( aTmpIdx, 1 );
1946  }
1947  }
1948  nIdx = pBox->GetSttIdx();
1949  }
1950  else
1951  pBox = pTableNd->GetTable().GetTableBox( nIdx );
1952 
1953  if( !pSaveTable->IsNewModel() )
1954  {
1955  // TL_CHART2: notify chart about box to be removed
1956  if (pPCD)
1957  pPCD->DeleteBox( &pTableNd->GetTable(), *pBox );
1958 
1959  SwTableBoxes* pTBoxes = &pBox->GetUpper()->GetTabBoxes();
1960  pTBoxes->erase( std::find(pTBoxes->begin(), pTBoxes->end(), pBox ) );
1961 
1962  // delete indices from section
1963  {
1964  SwNodeIndex aTmpIdx( *pBox->GetSttNd() );
1965  SwDoc::CorrAbs( SwNodeIndex( aTmpIdx, 1 ),
1966  SwNodeIndex( *aTmpIdx.GetNode().EndOfSectionNode() ),
1967  SwPosition( aTmpIdx, SwIndex( nullptr, 0 )), true );
1968  }
1969 
1970  delete pBox;
1971  rDoc.getIDocumentContentOperations().DeleteSection( rDoc.GetNodes()[ nIdx ] );
1972  }
1973  }
1974  CHECKTABLE(pTableNd->GetTable())
1975 
1976  pSaveTable->CreateNew( pTableNd->GetTable(), true, false );
1977 
1978  // TL_CHART2: need to inform chart of probably changed cell names
1979  rDoc.UpdateCharts( pTableNd->GetTable().GetFrameFormat()->GetName() );
1980 
1981  if( pHistory )
1982  {
1983  pHistory->TmpRollback( &rDoc, 0 );
1984  pHistory->SetTmpEnd( pHistory->Count() );
1985  }
1986  SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
1987  pPam->DeleteMark();
1988  pPam->GetPoint()->nNode = m_nSttNode;
1989  pPam->GetPoint()->nContent.Assign( pPam->GetContentNode(), m_nSttContent );
1990  pPam->SetMark();
1991  pPam->DeleteMark();
1992 
1993  CHECKTABLE(pTableNd->GetTable())
1994  ClearFEShellTabCols(rDoc, nullptr);
1995 }
1996 
1998 {
1999  SwDoc & rDoc = rContext.GetDoc();
2000  SwPaM & rPam( AddUndoRedoPaM(rContext) );
2001  rDoc.MergeTable(rPam);
2002 }
2003 
2005 {
2006  SwNodeIndex aTmp( rRg.aStart, -1 ), aTmp2( rPos, -1 );
2007  std::unique_ptr<SwUndoMove> pUndo(new SwUndoMove( pDoc, rRg, rPos ));
2008  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
2009  pDoc->getIDocumentContentOperations().MoveNodeRange( rRg, rPos, pSaveTable->IsNewModel() ?
2012  ++aTmp;
2013  ++aTmp2;
2014  pUndo->SetDestRange( aTmp2, rPos, aTmp );
2015 
2016  m_vMoves.push_back(std::move(pUndo));
2017 }
2018 
2020 {
2021  // memorize selection
2022  for (size_t n = 0; n < rBoxes.size(); ++n)
2023  {
2024  m_Boxes.insert(rBoxes[n]->GetSttIdx());
2025  }
2026 
2027  // as separator for inserts of new boxes after shifting
2028  aNewSttNds.push_back( sal_uLong(0) );
2029 
2030  // The new table model does not delete overlapped cells (by row span),
2031  // so the rBoxes array might be empty even some cells have been merged.
2032  if( !rBoxes.empty() )
2033  nTableNode = rBoxes[ 0 ]->GetSttNd()->FindTableNode()->GetIndex();
2034 }
2035 
2037 {
2038  if( !pHistory )
2039  pHistory.reset(new SwHistory);
2040 
2041  SwNodeIndex aIdx( *rBox.GetSttNd(), 1 );
2042  SwContentNode* pCNd = aIdx.GetNode().GetContentNode();
2043  if( !pCNd )
2044  pCNd = aIdx.GetNodes().GoNext( &aIdx );
2045 
2046  pHistory->Add( pCNd->GetFormatColl(), aIdx.GetIndex(), pCNd->GetNodeType());
2047  if( pCNd->HasSwAttrSet() )
2048  pHistory->CopyFormatAttr( *pCNd->GetpSwAttrSet(), aIdx.GetIndex() );
2049 }
2050 
2052  const SfxItemSet* pNewSet )
2053  : SwUndo(SwUndoId::TBLNUMFMT, rBox.GetFrameFormat()->GetDoc())
2054  , m_nFormatIdx(getSwDefaultTextFormat())
2055  , m_nNewFormatIdx(0)
2056  , m_fNum(0.0)
2057  , m_fNewNum(0.0)
2058  , m_bNewFormat(false)
2059  , m_bNewFormula(false)
2060  , m_bNewValue(false)
2061 {
2062  m_nNode = rBox.GetSttIdx();
2063 
2064  m_nNodePos = rBox.IsValidNumTextNd( nullptr == pNewSet );
2065  SwDoc* pDoc = rBox.GetFrameFormat()->GetDoc();
2066 
2067  if( ULONG_MAX != m_nNodePos )
2068  {
2069  SwTextNode* pTNd = pDoc->GetNodes()[ m_nNodePos ]->GetTextNode();
2070 
2071  m_pHistory.reset(new SwHistory);
2072  SwRegHistory aRHst( *rBox.GetSttNd(), m_pHistory.get() );
2073  // always save all text atttibutes because of possibly overlapping
2074  // areas of on/off
2075  m_pHistory->CopyAttr( pTNd->GetpSwpHints(), m_nNodePos, 0,
2076  pTNd->GetText().getLength(), true );
2077 
2078  if( pTNd->HasSwAttrSet() )
2079  m_pHistory->CopyFormatAttr( *pTNd->GetpSwAttrSet(), m_nNodePos );
2080 
2081  m_aStr = pTNd->GetText();
2082  if( pTNd->GetpSwpHints() )
2083  pTNd->GetpSwpHints()->DeRegister();
2084  }
2085 
2086  m_pBoxSet.reset( new SfxItemSet( pDoc->GetAttrPool(), aTableBoxSetRange ) );
2087  m_pBoxSet->Put( rBox.GetFrameFormat()->GetAttrSet() );
2088 
2089  if( pNewSet )
2090  {
2091  const SfxPoolItem* pItem;
2092  if( SfxItemState::SET == pNewSet->GetItemState( RES_BOXATR_FORMAT,
2093  false, &pItem ))
2094  {
2095  m_bNewFormat = true;
2096  m_nNewFormatIdx = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
2097  }
2098  if( SfxItemState::SET == pNewSet->GetItemState( RES_BOXATR_FORMULA,
2099  false, &pItem ))
2100  {
2101  m_bNewFormula = true;
2102  m_aNewFormula = static_cast<const SwTableBoxFormula*>(pItem)->GetFormula();
2103  }
2104  if( SfxItemState::SET == pNewSet->GetItemState( RES_BOXATR_VALUE,
2105  false, &pItem ))
2106  {
2107  m_bNewValue = true;
2108  m_fNewNum = static_cast<const SwTableBoxValue*>(pItem)->GetValue();
2109  }
2110  }
2111 
2112  // is a history needed at all?
2113  if (m_pHistory && !m_pHistory->Count())
2114  {
2115  m_pHistory.reset();
2116  }
2117 }
2118 
2120 {
2121  m_pHistory.reset();
2122  m_pBoxSet.reset();
2123 }
2124 
2126 {
2127  OSL_ENSURE( m_pBoxSet, "Where's the stored item set?" );
2128 
2129  SwDoc & rDoc = rContext.GetDoc();
2130  SwStartNode* pSttNd = rDoc.GetNodes()[ m_nNode ]->
2131  FindSttNodeByType( SwTableBoxStartNode );
2132  OSL_ENSURE( pSttNd, "without StartNode no TableBox" );
2133  SwTableBox* pBox = pSttNd->FindTableNode()->GetTable().GetTableBox(
2134  pSttNd->GetIndex() );
2135  OSL_ENSURE( pBox, "found no TableBox" );
2136 
2137  SwTableBoxFormat* pFormat = rDoc.MakeTableBoxFormat();
2138  pFormat->SetFormatAttr( *m_pBoxSet );
2139  pBox->ChgFrameFormat( pFormat );
2140 
2141  if( ULONG_MAX == m_nNodePos )
2142  return;
2143 
2144  SwTextNode* pTextNd = rDoc.GetNodes()[ m_nNodePos ]->GetTextNode();
2145  // If more than one node was deleted then all "node" attributes were also
2146  // saved
2147  if( pTextNd->HasSwAttrSet() )
2148  pTextNd->ResetAllAttr();
2149 
2150  if( pTextNd->GetpSwpHints() && !m_aStr.isEmpty() )
2151  pTextNd->ClearSwpHintsArr( true );
2152 
2153  // ChgTextToNum(..) only acts when the strings are different. We need to do
2154  // the same here.
2155  if( pTextNd->GetText() != m_aStr )
2156  {
2157  rDoc.getIDocumentRedlineAccess().DeleteRedline( *( pBox->GetSttNd() ), false, RedlineType::Any );
2158 
2159  SwIndex aIdx( pTextNd, 0 );
2160  if( !m_aStr.isEmpty() )
2161  {
2162  pTextNd->EraseText( aIdx );
2163  pTextNd->InsertText( m_aStr, aIdx,
2165  }
2166  }
2167 
2168  if( m_pHistory )
2169  {
2170  sal_uInt16 nTmpEnd = m_pHistory->GetTmpEnd();
2171  m_pHistory->TmpRollback( &rDoc, 0 );
2172  m_pHistory->SetTmpEnd( nTmpEnd );
2173  }
2174 
2175  SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
2176  pPam->DeleteMark();
2177  pPam->GetPoint()->nNode = m_nNode + 1;
2178  pPam->GetPoint()->nContent.Assign( pTextNd, 0 );
2179 }
2180 
2181 namespace {
2182 
2188 class RedlineFlagsInternGuard
2189 {
2190  SwDoc& mrDoc;
2191  RedlineFlags const meOldRedlineFlags;
2192 
2193 public:
2194  RedlineFlagsInternGuard(
2195  SwDoc& rDoc, // change mode of this document
2196  RedlineFlags eNewRedlineFlags, // new redline mode
2197  RedlineFlags eRedlineFlagsMask /*change only bits set in this mask*/);
2198 
2199  ~RedlineFlagsInternGuard();
2200 };
2201 
2202 }
2203 
2204 RedlineFlagsInternGuard::RedlineFlagsInternGuard(
2205  SwDoc& rDoc,
2206  RedlineFlags eNewRedlineFlags,
2207  RedlineFlags eRedlineFlagsMask )
2208  : mrDoc( rDoc ),
2209  meOldRedlineFlags( rDoc.getIDocumentRedlineAccess().GetRedlineFlags() )
2210 {
2211  mrDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( ( meOldRedlineFlags & ~eRedlineFlagsMask ) |
2212  ( eNewRedlineFlags & eRedlineFlagsMask ) );
2213 }
2214 
2215 RedlineFlagsInternGuard::~RedlineFlagsInternGuard()
2216 {
2217  mrDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( meOldRedlineFlags );
2218 }
2219 
2221 {
2222  // Could the box be changed?
2223  if( !m_pBoxSet )
2224  return ;
2225 
2226  SwDoc & rDoc = rContext.GetDoc();
2227  SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
2228 
2229  pPam->DeleteMark();
2230  pPam->GetPoint()->nNode = m_nNode;
2231 
2232  SwNode * pNd = & pPam->GetPoint()->nNode.GetNode();
2234  assert(pSttNd && "without StartNode no TableBox");
2235  SwTableBox* pBox = pSttNd->FindTableNode()->GetTable().GetTableBox(
2236  pSttNd->GetIndex() );
2237  OSL_ENSURE( pBox, "found no TableBox" );
2238 
2239  SwFrameFormat* pBoxFormat = pBox->ClaimFrameFormat();
2241  {
2242  SfxItemSet aBoxSet( rDoc.GetAttrPool(),
2244 
2245  // Resetting attributes is not enough. In addition, take care that the
2246  // text will be also formatted correctly.
2247  pBoxFormat->LockModify();
2248 
2249  if( m_bNewFormula )
2250  aBoxSet.Put( SwTableBoxFormula( m_aNewFormula ));
2251  else
2252  pBoxFormat->ResetFormatAttr( RES_BOXATR_FORMULA );
2253  if( m_bNewFormat )
2254  aBoxSet.Put( SwTableBoxNumFormat( m_nNewFormatIdx ));
2255  else
2256  pBoxFormat->ResetFormatAttr( RES_BOXATR_FORMAT );
2257  if( m_bNewValue )
2258  aBoxSet.Put( SwTableBoxValue( m_fNewNum ));
2259  else
2260  pBoxFormat->ResetFormatAttr( RES_BOXATR_VALUE );
2261  pBoxFormat->UnlockModify();
2262 
2263  // dvo: When redlining is (was) enabled, setting the attribute
2264  // will also change the cell content. To allow this, the
2265  // RedlineFlags::Ignore flag must be removed during Redo. #108450#
2266  RedlineFlagsInternGuard aGuard( rDoc, RedlineFlags::NONE, RedlineFlags::Ignore );
2267  pBoxFormat->SetFormatAttr( aBoxSet );
2268  }
2269  else if( getSwDefaultTextFormat() != m_nFormatIdx )
2270  {
2271  SfxItemSet aBoxSet( rDoc.GetAttrPool(),
2273 
2274  aBoxSet.Put( SwTableBoxNumFormat( m_nFormatIdx ));
2275  aBoxSet.Put( SwTableBoxValue( m_fNum ));
2276 
2277  // Resetting attributes is not enough. In addition, take care that the
2278  // text will be also formatted correctly.
2279  pBoxFormat->LockModify();
2280  pBoxFormat->ResetFormatAttr( RES_BOXATR_FORMULA );
2281  pBoxFormat->UnlockModify();
2282 
2283  // dvo: When redlining is (was) enabled, setting the attribute
2284  // will also change the cell content. To allow this, the
2285  // RedlineFlags::Ignore flag must be removed during Redo. #108450#
2286  RedlineFlagsInternGuard aGuard( rDoc, RedlineFlags::NONE, RedlineFlags::Ignore );
2287  pBoxFormat->SetFormatAttr( aBoxSet );
2288  }
2289  else
2290  {
2291  // it's no number
2292 
2293  // Resetting attributes is not enough. In addition, take care that the
2294  // text will be also formatted correctly.
2295  pBoxFormat->SetFormatAttr( *GetDfltAttr( RES_BOXATR_FORMAT ));
2296 
2298  }
2299 
2300  if( m_bNewFormula )
2301  {
2302  // No matter what was set, an update of the table is always a good idea
2303  SwTableFormulaUpdate aTableUpdate( &pSttNd->FindTableNode()->GetTable() );
2304  rDoc.getIDocumentFieldsAccess().UpdateTableFields( &aTableUpdate );
2305  }
2306 
2307  if( !pNd->IsContentNode() )
2308  pNd = rDoc.GetNodes().GoNext( &pPam->GetPoint()->nNode );
2309  pPam->GetPoint()->nContent.Assign( static_cast<SwContentNode*>(pNd), 0 );
2310 }
2311 
2313 {
2314  m_nNode = rBox.GetSttIdx();
2315 }
2316 
2318  : nBoxIdx( rBox.GetSttIdx() ), nOffset( 0 ),
2319  bJoin( false )
2320 {
2321 }
2322 
2324  : SwUndo( SwUndoId::TBLCPYTBL, pDoc )
2325 {
2326 }
2327 
2329 {
2330  m_vArr.clear();
2331  pInsRowUndo.reset();
2332 }
2333 
2335 {
2336  SwDoc & rDoc = rContext.GetDoc();
2337  DEBUG_REDLINE( &rDoc )
2338 
2339  SwTableNode* pTableNd = nullptr;
2340  for (size_t n = m_vArr.size(); n; )
2341  {
2342  UndoTableCpyTable_Entry *const pEntry = m_vArr[ --n ].get();
2343  sal_uLong nSttPos = pEntry->nBoxIdx + pEntry->nOffset;
2344  SwStartNode* pSNd = rDoc.GetNodes()[ nSttPos ]->StartOfSectionNode();
2345  if( !pTableNd )
2346  pTableNd = pSNd->FindTableNode();
2347 
2348  SwTableBox& rBox = *pTableNd->GetTable().GetTableBox( nSttPos );
2349 
2350  SwNodeIndex aInsIdx( *rBox.GetSttNd(), 1 );
2351  rDoc.GetNodes().MakeTextNode( aInsIdx, rDoc.GetDfltTextFormatColl() );
2352 
2353  // b62341295: Redline for copying tables
2354  const SwNode *pEndNode = rBox.GetSttNd()->EndOfSectionNode();
2355  SwPaM aPam( aInsIdx.GetNode(), *pEndNode );
2356  std::unique_ptr<SwUndoDelete> pUndo;
2357 
2359  {
2360  bool bDeleteCompleteParagraph = false;
2361  bool bShiftPam = false;
2362  // There are a couple of different situations to consider during redlining
2363  if( pEntry->pUndo )
2364  {
2365  SwUndoDelete *const pUndoDelete =
2366  dynamic_cast<SwUndoDelete*>(pEntry->pUndo.get());
2367  SwUndoRedlineDelete *const pUndoRedlineDelete =
2368  dynamic_cast<SwUndoRedlineDelete*>(pEntry->pUndo.get());
2369  assert(pUndoDelete || pUndoRedlineDelete);
2370  if (pUndoRedlineDelete)
2371  {
2372  // The old content was not empty or he has been merged with the new content
2373  bDeleteCompleteParagraph = !pEntry->bJoin; // bJoin is set when merged
2374  // Set aTmpIdx to the beginning of the old content
2375  SwNodeIndex aTmpIdx( *pEndNode,
2376  pUndoRedlineDelete->NodeDiff()-1 );
2377  SwTextNode *pText = aTmpIdx.GetNode().GetTextNode();
2378  if( pText )
2379  {
2380  aPam.GetPoint()->nNode = *pText;
2381  aPam.GetPoint()->nContent.Assign( pText,
2382  pUndoRedlineDelete->ContentStart() );
2383  }
2384  else
2385  *aPam.GetPoint() = SwPosition( aTmpIdx );
2386  }
2387  else if (pUndoDelete && pUndoDelete->IsDelFullPara())
2388  {
2389  // When the old content was an empty paragraph, but could not be joined
2390  // with the new content (e.g. because of a section or table)
2391  // We "save" the aPam.Point, we go one step backwards (because later on the
2392  // empty paragraph will be inserted by the undo) and set the "ShiftPam-flag
2393  // for step forward later on.
2394  bDeleteCompleteParagraph = true;
2395  bShiftPam = true;
2396  SwNodeIndex aTmpIdx( *pEndNode, -1 );
2397  SwTextNode *pText = aTmpIdx.GetNode().GetTextNode();
2398  if( pText )
2399  {
2400  aPam.GetPoint()->nNode = *pText;
2401  aPam.GetPoint()->nContent.Assign( pText, 0 );
2402  }
2403  else
2404  *aPam.GetPoint() = SwPosition( aTmpIdx );
2405  }
2406  }
2407  rDoc.getIDocumentRedlineAccess().DeleteRedline( aPam, true, RedlineType::Any );
2408 
2409  if( pEntry->pUndo )
2410  {
2411  pEntry->pUndo->UndoImpl(rContext);
2412  pEntry->pUndo.reset();
2413  }
2414  if( bShiftPam )
2415  {
2416  // The aPam.Point is at the moment at the last position of the new content and has to be
2417  // moved to the first position of the old content for the SwUndoDelete operation
2418  SwNodeIndex aTmpIdx( aPam.GetPoint()->nNode, 1 );
2419  SwTextNode *pText = aTmpIdx.GetNode().GetTextNode();
2420  if( pText )
2421  {
2422  aPam.GetPoint()->nNode = *pText;
2423  aPam.GetPoint()->nContent.Assign( pText, 0 );
2424  }
2425  else
2426  *aPam.GetPoint() = SwPosition( aTmpIdx );
2427  }
2428  pUndo = std::make_unique<SwUndoDelete>( aPam, bDeleteCompleteParagraph, true );
2429  }
2430  else
2431  {
2432  pUndo = std::make_unique<SwUndoDelete>( aPam, true );
2433  if( pEntry->pUndo )
2434  {
2435  pEntry->pUndo->UndoImpl(rContext);
2436  pEntry->pUndo.reset();
2437  }
2438  }
2439  pEntry->pUndo = std::move(pUndo);
2440 
2441  aInsIdx = rBox.GetSttIdx() + 1;
2442  rDoc.GetNodes().Delete( aInsIdx );
2443 
2444  SfxItemSet aTmpSet(
2445  rDoc.GetAttrPool(),
2446  svl::Items<
2449  aTmpSet.Put( rBox.GetFrameFormat()->GetAttrSet() );
2450  if( aTmpSet.Count() )
2451  {
2452  SwFrameFormat* pBoxFormat = rBox.ClaimFrameFormat();
2453  pBoxFormat->ResetFormatAttr( RES_BOXATR_FORMAT, RES_BOXATR_VALUE );
2454  pBoxFormat->ResetFormatAttr( RES_VERT_ORIENT );
2455  }
2456 
2457  if( pEntry->pBoxNumAttr )
2458  {
2459  rBox.ClaimFrameFormat()->SetFormatAttr( *pEntry->pBoxNumAttr );
2460  pEntry->pBoxNumAttr.reset();
2461  }
2462 
2463  if( aTmpSet.Count() )
2464  {
2465  pEntry->pBoxNumAttr = std::make_unique<SfxItemSet>(
2466  rDoc.GetAttrPool(),
2467  svl::Items<
2470  pEntry->pBoxNumAttr->Put( aTmpSet );
2471  }
2472 
2473  pEntry->nOffset = rBox.GetSttIdx() - pEntry->nBoxIdx;
2474  }
2475 
2476  if( pInsRowUndo )
2477  {
2478  pInsRowUndo->UndoImpl(rContext);
2479  }
2480  DEBUG_REDLINE( &rDoc )
2481 }
2482 
2484 {
2485  SwDoc & rDoc = rContext.GetDoc();
2486  DEBUG_REDLINE( &rDoc )
2487 
2488  if( pInsRowUndo )
2489  {
2490  pInsRowUndo->RedoImpl(rContext);
2491  }
2492 
2493  SwTableNode* pTableNd = nullptr;
2494  for (size_t n = 0; n < m_vArr.size(); ++n)
2495  {
2496  UndoTableCpyTable_Entry *const pEntry = m_vArr[ n ].get();
2497  sal_uLong nSttPos = pEntry->nBoxIdx + pEntry->nOffset;
2498  SwStartNode* pSNd = rDoc.GetNodes()[ nSttPos ]->StartOfSectionNode();
2499  if( !pTableNd )
2500  pTableNd = pSNd->FindTableNode();
2501 
2502  SwTableBox& rBox = *pTableNd->GetTable().GetTableBox( nSttPos );
2503 
2504  SwNodeIndex aInsIdx( *rBox.GetSttNd(), 1 );
2505 
2506  // b62341295: Redline for copying tables - Start.
2507  rDoc.GetNodes().MakeTextNode( aInsIdx, rDoc.GetDfltTextFormatColl() );
2508  SwPaM aPam( aInsIdx.GetNode(), *rBox.GetSttNd()->EndOfSectionNode());
2509  std::unique_ptr<SwUndo> pUndo = IDocumentRedlineAccess::IsRedlineOn( GetRedlineFlags() ) ? nullptr : std::make_unique<SwUndoDelete>( aPam, true );
2510  if( pEntry->pUndo )
2511  {
2512  pEntry->pUndo->UndoImpl(rContext);
2514  {
2515  // PrepareRedline has to be called with the beginning of the old content
2516  // When new and old content has been joined, the rIter.pAktPam has been set
2517  // by the Undo operation to this point.
2518  // Otherwise aInsIdx has been moved during the Undo operation
2519  if( pEntry->bJoin )
2520  {
2521  SwPaM const& rLastPam =
2523  pUndo = PrepareRedline( &rDoc, rBox, *rLastPam.GetPoint(),
2524  pEntry->bJoin, true );
2525  }
2526  else
2527  {
2528  SwPosition aTmpPos( aInsIdx );
2529  pUndo = PrepareRedline( &rDoc, rBox, aTmpPos, pEntry->bJoin, true );
2530  }
2531  }
2532  pEntry->pUndo.reset();
2533  }
2534  pEntry->pUndo = std::move(pUndo);
2535  // b62341295: Redline for copying tables - End.
2536 
2537  aInsIdx = rBox.GetSttIdx() + 1;
2538  rDoc.GetNodes().Delete( aInsIdx );
2539 
2540  SfxItemSet aTmpSet(
2541  rDoc.GetAttrPool(),
2542  svl::Items<
2545  aTmpSet.Put( rBox.GetFrameFormat()->GetAttrSet() );
2546  if( aTmpSet.Count() )
2547  {
2548  SwFrameFormat* pBoxFormat = rBox.ClaimFrameFormat();
2549  pBoxFormat->ResetFormatAttr( RES_BOXATR_FORMAT, RES_BOXATR_VALUE );
2550  pBoxFormat->ResetFormatAttr( RES_VERT_ORIENT );
2551  }
2552  if( pEntry->pBoxNumAttr )
2553  {
2554  rBox.ClaimFrameFormat()->SetFormatAttr( *pEntry->pBoxNumAttr );
2555  pEntry->pBoxNumAttr.reset();
2556  }
2557 
2558  if( aTmpSet.Count() )
2559  {
2560  pEntry->pBoxNumAttr = std::make_unique<SfxItemSet>(
2561  rDoc.GetAttrPool(),
2562  svl::Items<
2565  pEntry->pBoxNumAttr->Put( aTmpSet );
2566  }
2567 
2568  pEntry->nOffset = rBox.GetSttIdx() - pEntry->nBoxIdx;
2569  }
2570  DEBUG_REDLINE( &rDoc )
2571 }
2572 
2573 void SwUndoTableCpyTable::AddBoxBefore( const SwTableBox& rBox, bool bDelContent )
2574 {
2575  if (!m_vArr.empty() && !bDelContent)
2576  return;
2577 
2578  UndoTableCpyTable_Entry* pEntry = new UndoTableCpyTable_Entry( rBox );
2579  m_vArr.push_back(std::unique_ptr<UndoTableCpyTable_Entry>(pEntry));
2580 
2581  SwDoc* pDoc = rBox.GetFrameFormat()->GetDoc();
2582  DEBUG_REDLINE( pDoc )
2583  if( bDelContent )
2584  {
2585  SwNodeIndex aInsIdx( *rBox.GetSttNd(), 1 );
2586  pDoc->GetNodes().MakeTextNode( aInsIdx, pDoc->GetDfltTextFormatColl() );
2587  SwPaM aPam( aInsIdx.GetNode(), *rBox.GetSttNd()->EndOfSectionNode() );
2588 
2589  if( !pDoc->getIDocumentRedlineAccess().IsRedlineOn() )
2590  pEntry->pUndo = std::make_unique<SwUndoDelete>( aPam, true );
2591  }
2592 
2593  pEntry->pBoxNumAttr = std::make_unique<SfxItemSet>(
2594  pDoc->GetAttrPool(),
2595  svl::Items<
2598  pEntry->pBoxNumAttr->Put( rBox.GetFrameFormat()->GetAttrSet() );
2599  if( !pEntry->pBoxNumAttr->Count() )
2600  {
2601  pEntry->pBoxNumAttr.reset();
2602  }
2603  DEBUG_REDLINE( pDoc )
2604 }
2605 
2606 void SwUndoTableCpyTable::AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex& rIdx, bool bDelContent )
2607 {
2608  UndoTableCpyTable_Entry *const pEntry = m_vArr.back().get();
2609 
2610  // If the content was deleted then remove also the temporarily created node
2611  if( bDelContent )
2612  {
2613  SwDoc* pDoc = rBox.GetFrameFormat()->GetDoc();
2614  DEBUG_REDLINE( pDoc )
2615 
2616  if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() )
2617  {
2618  SwPosition aTmpPos( rIdx );
2619  pEntry->pUndo = PrepareRedline( pDoc, rBox, aTmpPos, pEntry->bJoin, false );
2620  }
2621  SwNodeIndex aDelIdx( *rBox.GetSttNd(), 1 );
2622  rBox.GetFrameFormat()->GetDoc()->GetNodes().Delete( aDelIdx );
2623  DEBUG_REDLINE( pDoc )
2624  }
2625 
2626  pEntry->nOffset = rBox.GetSttIdx() - pEntry->nBoxIdx;
2627 }
2628 
2629 // PrepareRedline is called from AddBoxAfter() and from Redo() in slightly different situations.
2630 // bRedo is set by calling from Redo()
2631 // rJoin is false by calling from AddBoxAfter() and will be set if the old and new content has
2632 // been merged.
2633 // rJoin is true if Redo() is calling and the content has already been merged
2634 
2635 std::unique_ptr<SwUndo> SwUndoTableCpyTable::PrepareRedline( SwDoc* pDoc, const SwTableBox& rBox,
2636  const SwPosition& rPos, bool& rJoin, bool bRedo )
2637 {
2638  std::unique_ptr<SwUndo> pUndo;
2639  // b62341295: Redline for copying tables
2640  // What's to do?
2641  // Mark the cell content before rIdx as insertion,
2642  // mark the cell content behind rIdx as deletion
2643  // merge text nodes at rIdx if possible
2646  SwPosition aInsertEnd( rPos );
2647  SwTextNode* pText;
2648  if( !rJoin )
2649  {
2650  // If the content is not merged, the end of the insertion is at the end of the node
2651  // _before_ the given position rPos
2652  --aInsertEnd.nNode;
2653  pText = aInsertEnd.nNode.GetNode().GetTextNode();
2654  if( pText )
2655  {
2656  aInsertEnd.nContent.Assign(pText, pText->GetText().getLength());
2657  if( !bRedo && rPos.nNode.GetNode().GetTextNode() )
2658  { // Try to merge, if not called by Redo()
2659  rJoin = true;
2660  pText->JoinNext();
2661  }
2662  }
2663  else
2664  aInsertEnd.nContent.Assign(nullptr, 0);
2665  }
2666  // For joined (merged) contents the start of deletion and end of insertion are identical
2667  // otherwise adjacent nodes.
2668  SwPosition aDeleteStart( rJoin ? aInsertEnd : rPos );
2669  if( !rJoin )
2670  {
2671  pText = aDeleteStart.nNode.GetNode().GetTextNode();
2672  if( pText )
2673  aDeleteStart.nContent.Assign( pText, 0 );
2674  }
2675  SwPosition aCellEnd( SwNodeIndex( *rBox.GetSttNd()->EndOfSectionNode(), -1 ) );
2676  pText = aCellEnd.nNode.GetNode().GetTextNode();
2677  if( pText )
2678  aCellEnd.nContent.Assign(pText, pText->GetText().getLength());
2679  if( aDeleteStart != aCellEnd )
2680  { // If the old (deleted) part is not empty, here we are...
2681  SwPaM aDeletePam( aDeleteStart, aCellEnd );
2682  pUndo = std::make_unique<SwUndoRedlineDelete>( aDeletePam, SwUndoId::DELETE );
2683  pDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( RedlineType::Delete, aDeletePam ), true );
2684  }
2685  else if( !rJoin ) // If the old part is empty and joined, we are finished
2686  { // if it is not joined, we have to delete this empty paragraph
2687  aCellEnd = SwPosition(
2688  SwNodeIndex( *rBox.GetSttNd()->EndOfSectionNode() ));
2689  SwPaM aTmpPam( aDeleteStart, aCellEnd );
2690  pUndo = std::make_unique<SwUndoDelete>( aTmpPam, true );
2691  }
2692  SwPosition aCellStart( SwNodeIndex( *rBox.GetSttNd(), 2 ) );
2693  pText = aCellStart.nNode.GetNode().GetTextNode();
2694  if( pText )
2695  aCellStart.nContent.Assign( pText, 0 );
2696  if( aCellStart != aInsertEnd ) // An empty insertion will not been marked
2697  {
2698  SwPaM aTmpPam( aCellStart, aInsertEnd );
2699  pDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( RedlineType::Insert, aTmpPam ), true );
2700  }
2701 
2703  return pUndo;
2704 }
2705 
2707  sal_uInt16 nCnt )
2708 {
2709  SwTableNode* pTableNd = const_cast<SwTableNode*>(rTable.GetTabSortBoxes()[0]->
2710  GetSttNd()->FindTableNode());
2711 
2712  pInsRowUndo.reset( new SwUndoTableNdsChg( SwUndoId::TABLE_INSROW, rBoxes, *pTableNd,
2713  0, 0, nCnt, true, false ) );
2714  SwTableSortBoxes aTmpLst( rTable.GetTabSortBoxes() );
2715 
2716  bool bRet = rTable.InsertRow( rTable.GetFrameFormat()->GetDoc(), rBoxes, nCnt, /*bBehind*/true );
2717  if( bRet )
2718  pInsRowUndo->SaveNewBoxes( *pTableNd, aTmpLst );
2719  else
2720  {
2721  pInsRowUndo.reset();
2722  }
2723  return bRet;
2724 }
2725 
2727 {
2728  return !pInsRowUndo && m_vArr.empty();
2729 }
2730 
2732  : SwUndo( SwUndoId::CPYTBL, pDoc ), nTableNode( 0 )
2733 {
2734 }
2735 
2737 {
2738 }
2739 
2741 {
2742  SwDoc & rDoc = rContext.GetDoc();
2743  SwTableNode* pTNd = rDoc.GetNodes()[ nTableNode ]->GetTableNode();
2744 
2745  // move hard page breaks into next node
2746  SwContentNode* pNextNd = rDoc.GetNodes()[ pTNd->EndOfSectionIndex()+1 ]->GetContentNode();
2747  if( pNextNd )
2748  {
2749  SwFrameFormat* pTableFormat = pTNd->GetTable().GetFrameFormat();
2750  const SfxPoolItem *pItem;
2751 
2752  if( SfxItemState::SET == pTableFormat->GetItemState( RES_PAGEDESC,
2753  false, &pItem ) )
2754  pNextNd->SetAttr( *pItem );
2755 
2756  if( SfxItemState::SET == pTableFormat->GetItemState( RES_BREAK,
2757  false, &pItem ) )
2758  pNextNd->SetAttr( *pItem );
2759  }
2760 
2761  SwPaM aPam( *pTNd, *pTNd->EndOfSectionNode(), 0 , 1 );
2762  pDel.reset( new SwUndoDelete( aPam, true ) );
2763 }
2764 
2766 {
2767  pDel->UndoImpl(rContext);
2768  pDel.reset();
2769 }
2770 
2772  std::unique_ptr<SwSaveRowSpan> pRowSp, SplitTable_HeadlineOption eMode, bool bNewSize )
2773  : SwUndo( SwUndoId::SPLIT_TABLE, rTableNd.GetDoc() ),
2774  nTableNode( rTableNd.GetIndex() ), nOffset( 0 ), mpSaveRowSpan( std::move(pRowSp) ),
2775  nMode( eMode ), nFormulaEnd( 0 ), bCalcNewSize( bNewSize )
2776 {
2777  switch( nMode )
2778  {
2780  pHistory.reset(new SwHistory);
2781  [[fallthrough]];
2784  pSavTable.reset(new SaveTable( rTableNd.GetTable(), 1, false ));
2785  break;
2786  default: break;
2787  }
2788 }
2789 
2791 {
2792  pSavTable.reset();
2793  pHistory.reset();
2794  mpSaveRowSpan.reset();
2795 }
2796 
2798 {
2799  SwDoc *const pDoc = & rContext.GetDoc();
2800  SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
2801 
2802  SwNodeIndex& rIdx = pPam->GetPoint()->nNode;
2803  rIdx = nTableNode + nOffset;
2804  pPam->GetPoint()->nContent.Assign(rIdx.GetNode().GetContentNode(), 0);
2805  assert(rIdx.GetNode().GetContentNode()->Len() == 0); // empty para inserted
2806 
2807  {
2808  // avoid asserts from ~SwIndexReg
2809  SwNodeIndex const idx(pDoc->GetNodes(), nTableNode + nOffset);
2810  {
2811  SwPaM pam(idx);
2813  ::PaMCorrAbs(*pPam, *pam.GetPoint());
2814  }
2815 
2816  // remove implicitly created paragraph again
2817  pDoc->GetNodes().Delete( idx );
2818  }
2819 
2820  rIdx = nTableNode + nOffset;
2821  SwTableNode* pTableNd = rIdx.GetNode().GetTableNode();
2822  SwTable& rTable = pTableNd->GetTable();
2823 
2824  SwTableFormulaUpdate aMsgHint( &rTable );
2825  aMsgHint.m_eFlags = TBL_BOXPTR;
2826  pDoc->getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
2827 
2828  switch( nMode )
2829  {
2831  if( pHistory )
2832  pHistory->TmpRollback( pDoc, nFormulaEnd );
2833  [[fallthrough]];
2836  {
2837  pSavTable->CreateNew( rTable, false );
2838  pSavTable->RestoreAttr( rTable );
2839  }
2840  break;
2841 
2843  // the created first line has to be removed again
2844  {
2845  SwSelBoxes aSelBoxes;
2846  SwTableBox* pBox = rTable.GetTableBox( nTableNode + nOffset + 1 );
2847  SwTable::SelLineFromBox( pBox, aSelBoxes );
2848  FndBox_ aTmpBox( nullptr, nullptr );
2849  aTmpBox.SetTableLines( aSelBoxes, rTable );
2850  aTmpBox.DelFrames( rTable );
2851  rTable.DeleteSel( pDoc, aSelBoxes, nullptr, nullptr, false, false );
2852  }
2853  break;
2854  default: break;
2855  }
2856 
2857  pDoc->GetNodes().MergeTable( rIdx );
2858 
2859  if( pHistory )
2860  {
2861  pHistory->TmpRollback( pDoc, 0 );
2862  pHistory->SetTmpEnd( pHistory->Count() );
2863  }
2864  if( mpSaveRowSpan )
2865  {
2866  pTableNd = rIdx.GetNode().FindTableNode();
2867  if( pTableNd )
2868  pTableNd->GetTable().RestoreRowSpan( *mpSaveRowSpan );
2869  }
2870  ClearFEShellTabCols(*pDoc, nullptr);
2871 }
2872 
2874 {
2875  SwDoc *const pDoc = & rContext.GetDoc();
2876  SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
2877 
2878  pPam->DeleteMark();
2879  pPam->GetPoint()->nNode = nTableNode;
2880  pDoc->SplitTable( *pPam->GetPoint(), nMode, bCalcNewSize );
2881 
2882  ClearFEShellTabCols(*pDoc, nullptr);
2883 }
2884 
2886 {
2887  SwPaM *const pPam = & rContext.GetRepeatPaM();
2888  SwDoc *const pDoc = & rContext.GetDoc();
2889 
2890  pDoc->SplitTable( *pPam->GetPoint(), nMode, bCalcNewSize );
2891  ClearFEShellTabCols(*pDoc, nullptr);
2892 }
2893 
2895 {
2896  if( !pHistory )
2897  pHistory.reset(new SwHistory);
2898 
2899  nFormulaEnd = rHistory.Count();
2900  pHistory->Move( 0, &rHistory );
2901 }
2902 
2904  const SwTableNode& rDelTableNd,
2905  bool bWithPrv, sal_uInt16 nMd )
2906  : SwUndo( SwUndoId::MERGE_TABLE, rTableNd.GetDoc() ),
2907  nMode( nMd ), bWithPrev( bWithPrv )
2908 {
2909  // memorize end node of the last table cell that'll stay in position
2910  if( bWithPrev )
2911  nTableNode = rDelTableNd.EndOfSectionIndex() - 1;
2912  else
2913  nTableNode = rTableNd.EndOfSectionIndex() - 1;
2914 
2915  aName = rDelTableNd.GetTable().GetFrameFormat()->GetName();
2916  pSavTable.reset(new SaveTable( rDelTableNd.GetTable() ));
2917 
2918  if (bWithPrev)
2919  pSavHdl.reset( new SaveTable( rTableNd.GetTable(), 1 ) );
2920 }
2921 
2923 {
2924  pSavTable.reset();
2925  pSavHdl.reset();
2926  pHistory.reset();
2927 }
2928 
2930 {
2931  SwDoc *const pDoc = & rContext.GetDoc();
2932  SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
2933 
2934  pPam->DeleteMark();
2935  SwNodeIndex& rIdx = pPam->GetPoint()->nNode;
2936  rIdx = nTableNode;
2937 
2938  SwTableNode* pTableNd = rIdx.GetNode().FindTableNode();
2939  SwTable* pTable = &pTableNd->GetTable();
2940 
2941  SwTableFormulaUpdate aMsgHint( pTable );
2942  aMsgHint.m_eFlags = TBL_BOXPTR;
2943  pDoc->getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
2944 
2945  // get lines for layout update
2946  FndBox_ aFndBox( nullptr, nullptr );
2947  aFndBox.SetTableLines( *pTable );
2948  aFndBox.DelFrames( *pTable );
2949  // ? TL_CHART2: notification or locking of controller required ?
2950 
2951  SwTableNode* pNew = pDoc->GetNodes().SplitTable( rIdx );
2952 
2953  // update layout
2954  aFndBox.MakeFrames( *pTable );
2955  // ? TL_CHART2: notification or locking of controller required ?
2956 
2957  if( bWithPrev )
2958  {
2959  // move name
2960  pNew->GetTable().GetFrameFormat()->SetName( pTable->GetFrameFormat()->GetName() );
2961  pSavHdl->RestoreAttr( pNew->GetTable() );
2962  }
2963  else
2964  pTable = &pNew->GetTable();
2965 
2966  pTable->GetFrameFormat()->SetName( aName );
2967  pSavTable->RestoreAttr( *pTable );
2968 
2969  if( pHistory )
2970  {
2971  pHistory->TmpRollback( pDoc, 0 );
2972  pHistory->SetTmpEnd( pHistory->Count() );
2973  }
2974 
2975  // create frames for the new table
2976  SwNodeIndex aTmpIdx( *pNew );
2977  pNew->MakeOwnFrames(&aTmpIdx);
2978 
2979  // position cursor somewhere in content
2980  SwContentNode* pCNd = pDoc->GetNodes().GoNext( &rIdx );
2981  pPam->GetPoint()->nContent.Assign( pCNd, 0 );
2982 
2983  ClearFEShellTabCols(*pDoc, nullptr);
2984 
2985  // TL_CHART2: need to inform chart of probably changed cell names
2987  if (pPCD)
2988  {
2989  pDoc->UpdateCharts( pTable->GetFrameFormat()->GetName() );
2990  pDoc->UpdateCharts( pNew->GetTable().GetFrameFormat()->GetName() );
2991  }
2992 }
2993 
2995 {
2996  SwDoc *const pDoc = & rContext.GetDoc();
2997  SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
2998 
2999  pPam->DeleteMark();
3000  pPam->GetPoint()->nNode = nTableNode;
3001  if( bWithPrev )
3002  pPam->GetPoint()->nNode = nTableNode + 3;
3003  else
3004  pPam->GetPoint()->nNode = nTableNode;
3005 
3006  pDoc->MergeTable( *pPam->GetPoint(), bWithPrev, nMode );
3007 
3008  ClearFEShellTabCols(*pDoc, nullptr);
3009 }
3010 
3012 {
3013  SwDoc *const pDoc = & rContext.GetDoc();
3014  SwPaM *const pPam = & rContext.GetRepeatPaM();
3015 
3016  pDoc->MergeTable( *pPam->GetPoint(), bWithPrev, nMode );
3017  ClearFEShellTabCols(*pDoc, nullptr);
3018 }
3019 
3021 {
3022  if( !pHistory )
3023  pHistory.reset( new SwHistory );
3024  pHistory->Move( 0, &rHistory );
3025 }
3026 
3027 void InsertSort( std::vector<sal_uInt16>& rArr, sal_uInt16 nIdx )
3028 {
3029  size_t nO = rArr.size();
3030  size_t nU = 0;
3031  if( nO > 0 )
3032  {
3033  nO--;
3034  while( nU <= nO )
3035  {
3036  const size_t nM = nU + ( nO - nU ) / 2;
3037  if ( rArr[nM] == nIdx )
3038  {
3039  OSL_FAIL( "Index already exists. This should never happen." );
3040  return;
3041  }
3042  if( rArr[nM] < nIdx )
3043  nU = nM + 1;
3044  else if( nM == 0 )
3045  break;
3046  else
3047  nO = nM - 1;
3048  }
3049  }
3050  rArr.insert( rArr.begin() + nU, nIdx );
3051 }
3052 
3053 #if OSL_DEBUG_LEVEL > 0
3054 void CheckTable( const SwTable& rTable )
3055 {
3056  const SwNodes& rNds = rTable.GetFrameFormat()->GetDoc()->GetNodes();
3057  const SwTableSortBoxes& rSrtArr = rTable.GetTabSortBoxes();
3058  for (size_t n = 0; n < rSrtArr.size(); ++n)
3059  {
3060  const SwTableBox* pBox = rSrtArr[ n ];
3061  const SwNode* pNd = pBox->GetSttNd();
3062  OSL_ENSURE( rNds[ pBox->GetSttIdx() ] == pNd, "Box with wrong StartNode" );
3063  }
3064 }
3065 #endif
3066 
3067 SwUndoTableStyleMake::SwUndoTableStyleMake(const OUString& rName, const SwDoc* pDoc)
3068  : SwUndo(SwUndoId::TBLSTYLE_CREATE, pDoc),
3069  m_sName(rName)
3070 { }
3071 
3073 { }
3074 
3076 {
3077  m_pAutoFormat = rContext.GetDoc().DelTableStyle(m_sName, true);
3078 }
3079 
3081 {
3082  if (m_pAutoFormat)
3083  {
3084  SwTableAutoFormat* pFormat = rContext.GetDoc().MakeTableStyle(m_sName, true);
3085  if (pFormat)
3086  {
3087  *pFormat = *m_pAutoFormat;
3088  m_pAutoFormat.reset();
3089  }
3090  }
3091 }
3092 
3094 {
3095  SwRewriter aResult;
3096  aResult.AddRule(UndoArg1, m_sName);
3097  return aResult;
3098 }
3099 
3100 SwUndoTableStyleDelete::SwUndoTableStyleDelete(std::unique_ptr<SwTableAutoFormat> pAutoFormat, const std::vector<SwTable*>& rAffectedTables, const SwDoc* pDoc)
3101  : SwUndo(SwUndoId::TBLSTYLE_DELETE, pDoc),
3102  m_pAutoFormat(std::move(pAutoFormat)),
3103  m_rAffectedTables(rAffectedTables)
3104 { }
3105 
3107 { }
3108 
3110 {
3111  SwTableAutoFormat* pNewFormat = rContext.GetDoc().MakeTableStyle(m_pAutoFormat->GetName(), true);
3112  *pNewFormat = *m_pAutoFormat;
3113  for (size_t i=0; i < m_rAffectedTables.size(); i++)
3114  m_rAffectedTables[i]->SetTableStyleName(m_pAutoFormat->GetName());
3115 }
3116 
3118 {
3119  // Don't need to remember deleted table style nor affected tables, because they must be the same as these already known.
3120  rContext.GetDoc().DelTableStyle(m_pAutoFormat->GetName());
3121 }
3122 
3124 {
3125  SwRewriter aResult;
3126  aResult.AddRule(UndoArg1, m_pAutoFormat->GetName());
3127  return aResult;
3128 }
3129 
3131  : SwUndo(SwUndoId::TBLSTYLE_UPDATE, pDoc)
3132  , m_pOldFormat(new SwTableAutoFormat(rOldFormat))
3133  , m_pNewFormat(new SwTableAutoFormat(rNewFormat))
3134 { }
3135 
3137 { }
3138 
3140 {
3141  rContext.GetDoc().ChgTableStyle(m_pNewFormat->GetName(), *m_pOldFormat);
3142 }
3143 
3145 {
3146  rContext.GetDoc().ChgTableStyle(m_pNewFormat->GetName(), *m_pNewFormat);
3147 }
3148 
3150 {
3151  SwRewriter aResult;
3152  aResult.AddRule(UndoArg1, m_pNewFormat->GetName());
3153  return aResult;
3154 }
3155 
3156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwStartNode * FindSttNodeByType(SwStartNodeType eTyp)
Definition: node.cxx:753
SwTableFormat * MakeTableFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom)
Definition: docfmt.cxx:791
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: untbl.cxx:3093
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
Starts a section of nodes in the document model.
Definition: node.hxx:303
SwPaM & AddUndoRedoPaM(::sw::UndoRedoContext &, bool const bCorrToContent=false) const
Definition: undobj.cxx:105
Base class of the Writer layout elements.
Definition: frame.hxx:295
OUString const sTableNm
Definition: UndoTable.hxx:101
virtual sal_Int32 Len() const
Definition: node.cxx:1180
#define RES_CHRATR_WEIGHT
Definition: hintids.hxx:84
void DeleteMark()
Definition: pam.hxx:177
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: untbl.cxx:3011
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unmove.cxx:155
sal_uLong GetIndex() const
Definition: node.hxx:282
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:297
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
virtual ~SwUndoAttrTable() override
Definition: untbl.cxx:1367
SwTableLineFormat * MakeTableLineFormat()
Definition: docfmt.cxx:1703
SwStartNode * m_pStartOfSection
Definition: node.hxx:112
SwUndoTextToTable(const SwPaM &, const SwInsertTableOptions &, sal_Unicode, sal_uInt16, const SwTableAutoFormat *pAFormat)
Definition: untbl.cxx:692
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:915
void Add(SwClient *pDepend)
Definition: calbck.cxx:217
std::unique_ptr< SwDDEFieldType > m_pDDEFieldType
Definition: UndoTable.hxx:50
void SetRowsToRepeat(sal_uInt16 nNumOfRows)
Definition: swtable.hxx:194
friend SaveLine
Definition: untbl.cxx:102
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:1854
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
Marks a position in the document model.
Definition: pam.hxx:35
sal_uLong nOffset
Definition: untbl.cxx:82
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:2740
SwUndoTableStyleUpdate(const SwTableAutoFormat &rNewFormat, const SwTableAutoFormat &rOldFormat, const SwDoc *pDoc)
Definition: untbl.cxx:3130
std::unique_ptr< SaveTable > pSaveTable
Definition: UndoTable.hxx:128
virtual ~SwUndoTableMerge() override
Definition: untbl.cxx:1847
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:2483
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:1371
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
Definition: swtable.cxx:1343
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: untbl.cxx:665
#define RES_CHRATR_FONTSIZE
Definition: hintids.hxx:77
sal_uLong nOffset
Definition: UndoTable.hxx:311
bool IsInsTableFormatNum() const
Definition: doc.cxx:1701
bool TableToText(const SwTableNode *pTableNd, sal_Unicode cCh)
Table to Text.
Definition: ndtbl.cxx:1446
const OUString & GetText() const
Definition: ndtxt.hxx:210
#define CHECKTABLE(t)
Definition: untbl.cxx:183
bool GotoPrevTable(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosTable, bool bInReadOnly)
Definition: trvltbl.cxx:480
sal_uLong GetSttIdx() const
Definition: swtable.cxx:1879
SwUndoId
Definition: swundo.hxx:29
virtual sal_uInt16 ResetAllAttr() override
Definition: ndtxt.cxx:5141
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:218
std::string GetValue
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:1788
virtual SwPaM & CreateNewShellCursor()=0
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
std::unique_ptr< SwTableAutoFormat > m_pNewFormat
Definition: UndoTable.hxx:404
bool Rollback(SwDoc *pDoc, sal_uInt16 nStart=0)
Definition: rolbck.cxx:1157
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: untbl.cxx:804
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
SwNodeIndex nNode
Definition: pam.hxx:37
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:2797
SwInsertTableOptions const aInsTableOpts
Definition: UndoTable.hxx:76
sal_uLong m_nFormatIdx
Definition: UndoTable.hxx:243
std::unique_ptr< SwHistory > m_pHistory
Definition: UndoTable.hxx:240
sal_uLong nTableNode
Definition: UndoTable.hxx:296
sal_uIntPtr sal_uLong
SwPaM & GetRepeatPaM()
Definition: UndoCore.hxx:128
void ReNewBoxes(const SwSelBoxes &rBoxes)
Definition: untbl.cxx:1487
std::vector< SwTable * > m_rAffectedTables
Definition: UndoTable.hxx:390
std::vector< sal_uLong > mvDelBoxes
Definition: UndoTable.hxx:77
SwUndoTableToText(const SwTable &rTable, sal_Unicode cCh)
Definition: untbl.cxx:399
static SwCache & GetCache()
Definition: frame.hxx:500
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:30
sal_Int32 const m_nContent
Definition: untbl.cxx:198
sal_uLong m_nEndNode
Definition: undobj.hxx:223
sal_uLong nEndNd
Definition: UndoTable.hxx:106
SwUndoSplitTable(const SwTableNode &rTableNd, std::unique_ptr< SwSaveRowSpan > pRowSp, SplitTable_HeadlineOption nMode, bool bCalcNewSize)
Definition: untbl.cxx:2771
sal_Int64 n
bool const m_bSameHeight
Definition: UndoTable.hxx:183
OUString sTableNm
Definition: UndoTable.hxx:75
bool IsEmpty() const
Definition: untbl.cxx:2726
Definition: doc.hxx:185
TElementType * Next()
Definition: calbck.hxx:373
std::unique_ptr< SwHistory > m_pHstry
Definition: untbl.cxx:199
void DelFrames(SwTable &rTable)
Definition: tblsel.cxx:2164
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:2994
void SetRedlineFlags(RedlineFlags eMode)
Definition: undobj.hxx:119
#define RES_CHRATR_FONT
Definition: hintids.hxx:76
void SetInCache(bool bNew)
Definition: calbck.hxx:215
SwUndoTableHeadline(const SwTable &, sal_uInt16 nOldHdl, sal_uInt16 nNewHdl)
Definition: untbl.cxx:827
void push_back(SwTableLine *pLine)
Definition: swtable.hxx:90
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1294
SwTableLine is one table row in the document model.
Definition: swtable.hxx:344
SwNode & GetNode() const
Definition: ndindex.hxx:119
const SwHistory * GetHistory() const
Definition: undobj.hxx:214
bool TmpRollback(SwDoc *pDoc, sal_uInt16 nStart, bool ToFirst=true)
Definition: rolbck.cxx:1172
SwTextNode * SplitContentNode(const SwPosition &, std::function< void(SwTextNode *, sw::mark::RestoreMode)> const *pContentIndexRestore)
Definition: ndtxt.cxx:410
bool const m_bSaveFormula
Definition: untbl.cxx:110
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:143
friend SaveBox
Definition: untbl.cxx:101
std::unique_ptr< SaveTable > pTableSave
Definition: UndoTable.hxx:103
iterator begin()
Definition: swtable.hxx:75
static void RemoveIdxFromSection(SwDoc &, sal_uLong nSttIdx, const sal_uLong *pEndIdx=nullptr)
Definition: undobj.cxx:113
std::unique_ptr< SwUndo > pUndo
Definition: untbl.cxx:84
bool InsertRow(SwDoc *, const SwSelBoxes &rBoxes, sal_uInt16 nCnt, bool bBehind)
SwTable::InsertRow(..) inserts one or more rows before or behind the selected boxes.
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:314
void ChangeState(const SfxPoolItem *pItem)
Definition: cellatr.cxx:106
SwUndoId GetId() const
Definition: undobj.hxx:100
bool HasWriterListeners() const
Definition: calbck.hxx:208
bool CanJoinNext(SwNodeIndex *pIdx=nullptr) const
Is it possible to join two nodes? In pIdx the second position can be returned.
Definition: node.cxx:1788
virtual SwContentNode * JoinNext() override
Definition: ndtxt.cxx:938
void setRowSpan(long nNewRowSpan)
Definition: swtable.cxx:106
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:201
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:738
IShellCursorSupplier & GetCursorSupplier()
Definition: UndoCore.hxx:96
std::unique_ptr< SwHistory > pHistory
Definition: UndoTable.hxx:339
size_t GetPos(const SwFormat *p) const
Definition: docary.hxx:165
virtual ~SwUndoTableStyleUpdate() override
Definition: untbl.cxx:3136
size_type size() const
Definition: swtable.hxx:74
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:840
std::unique_ptr< SwUndoDelete > pDel
Definition: UndoTable.hxx:295
void RegisterToFormat(SwFormat &rFormat)
Definition: swtable.cxx:2759
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:3117
std::unique_ptr< SwTableAutoFormat > m_pAutoFormat
Definition: UndoTable.hxx:375
SwUndoTableStyleDelete(std::unique_ptr< SwTableAutoFormat > pAutoFormat, const std::vector< SwTable * > &rAffectedTables, const SwDoc *pDoc)
Definition: untbl.cxx:3100
std::unique_ptr< SwTableAutoFormat > m_pOldFormat
Definition: UndoTable.hxx:404
void SaveNewBoxes(const SwTableNode &rTableNd, const SwTableSortBoxes &rOld)
Definition: untbl.cxx:1503
SaveTable(const SaveTable &)=delete
std::unique_ptr< SwSaveRowSpan > mpSaveRowSpan
Definition: UndoTable.hxx:312
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:356
void Delete(const SwNodeIndex &rPos, sal_uLong nNodes=1)
delete nodes
Definition: nodes.cxx:1065
bool IsFont() const
Definition: tblafmt.hxx:219
SwUndoTableNumFormat(const SwTableBox &rBox, const SfxItemSet *pNewSet=nullptr)
Definition: untbl.cxx:2051
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:2929
sal_uInt16 sal_Unicode
std::vector< std::shared_ptr< SwUndoTableNumFormat > > m_Undos
Definition: UndoTable.hxx:147
SwFrameFormatsV m_aFrameFormats
Definition: untbl.cxx:107
bool IsDelFullPara() const
Definition: UndoDelete.hxx:100
OUString m_sName
SwUndoTableCpyTable(const SwDoc *pDoc)
Definition: untbl.cxx:2323
SwTableNode * GetTableNode()
Definition: node.hxx:599
void MoveTo(SwIndexReg &rArr)
Definition: index.cxx:279
virtual ~SwUndoTableNdsChg() override
Definition: untbl.cxx:1499
SwInsertTableOptions const m_aInsTableOptions
Definition: UndoTable.hxx:49
sal_uInt16 const aSave_BoxContentSet[]
Definition: untbl.cxx:212
SwIndex nContent
Definition: pam.hxx:38
bool empty() const
Definition: docary.hxx:367
bool IsJustify() const
Definition: tblafmt.hxx:220
SwTableNode * SplitTable(const SwNodeIndex &rPos, bool bAfter=true, bool bCalcNewSize=false)
Splits a table at the base-line which contains the index.
Definition: ndtbl.cxx:3315
sal_uLong nSttNd
Definition: UndoTable.hxx:106
const SwTable * m_pSwTable
Definition: untbl.cxx:105
friend class SwStartNode
Definition: ndarr.hxx:93
SwNodeIndex aStart
Definition: ndindex.hxx:132
Unsorted, undeleting SwFrameFormat vector.
Definition: docary.hxx:279
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:425
sal_Int32 GetDestSttContent() const
const SwTextFormatColl * GetDfltTextFormatColl() const
Definition: doc.hxx:773
static bool IsRedlineOn(const RedlineFlags eM)
SwDoc & GetDoc() const
Definition: UndoCore.hxx:126
const OUString & GetName() const
Definition: format.hxx:111
void SetTableModel(bool bNew)
Definition: swtable.hxx:184
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
std::unique_ptr< SwTableAutoFormat > m_pAutoFormat
Definition: UndoTable.hxx:389
virtual void UpdateTableFields(SfxPoolItem *pHt)=0
void AddBoxPos(SwDoc &rDoc, sal_uLong nNdIdx, sal_uLong nEndIdx, sal_Int32 nContentIdx=SAL_MAX_INT32)
Definition: untbl.cxx:687
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:255
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2454
bool IsStartNode() const
Definition: node.hxx:624
SwUndoMergeTable(const SwTableNode &rTableNd, const SwTableNode &rDelTableNd, bool bWithPrev, sal_uInt16 nMode)
Definition: untbl.cxx:2903
Mode eMode
iterator insert(iterator aIt, SwTableLine *pLine)
Definition: swtable.hxx:84
virtual ~SwUndoSplitTable() override
Definition: untbl.cxx:2790
const SwTable & GetTable() const
Definition: node.hxx:497
sal_uInt16 const nOldHeadline
Definition: UndoTable.hxx:359
virtual void DeleteSection(SwNode *pNode)=0
Delete section containing the node.
const SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
Definition: hints.cxx:153
bool IsNewModel() const
Definition: untbl.cxx:128
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd
Definition: untbl.cxx:202
const OUString & GetTableStyleName() const
Return the table style name of this table.
Definition: swtable.hxx:188
std::unique_ptr< SaveTable > m_pSaveTable
Definition: UndoTable.hxx:168
void UpdateCharts(const OUString &rName) const
Definition: docchart.cxx:123
sal_uLong m_nNewFormatIdx
Definition: UndoTable.hxx:243
std::unique_ptr< SwHistory > pHistory
Definition: UndoTable.hxx:314
size_type size() const
SwDoc & GetDoc() const
Definition: UndoCore.hxx:94
static void RemoveIdxFromRange(SwPaM &rPam, bool bMoveNext)
Definition: undobj.cxx:123
SwAttrPool * GetPool() const
Definition: swatrset.hxx:190
RedlineFlags GetRedlineFlags() const
Definition: undobj.hxx:118
std::vector< SwTableLine * >::const_iterator const_iterator
Definition: swtable.hxx:68
sal_uLong IsValidNumTextNd(bool bCheckAttr=true) const
Definition: swtable.cxx:2465
UndoTableCpyTable_Entry(const SwTableBox &rBox)
Definition: untbl.cxx:2317
void InsertRow(const SwCursor &rCursor, sal_uInt16 nCnt=1, bool bBehind=true)
Definition: ndtbl.cxx:1757
virtual void ModifyNotification(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.hxx:154
Specific frame formats (frames, DrawObjects).
Definition: docary.hxx:201
bool bJoin
Definition: untbl.cxx:87
void MakeFrames(SwTable &rTable)
Definition: tblsel.cxx:2325
SwHistory * pHistory
Definition: UndoTable.hxx:79
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
static const SwTableLines & lcl_FindParentLines(const SwTable &rTable, const SwTableBox &rBox)
Definition: untbl.cxx:1542
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: node.cxx:1596
SwStartNode * MakeTextSection(const SwNodeIndex &rWhere, SwStartNodeType eSttNdTyp, SwTextFormatColl *pColl)
Definition: nodes.cxx:1877
void DelNumRules(const SwPaM &, SwRootFrame const *pLayout=nullptr)
Definition: docnum.cxx:1322
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:259
virtual std::size_t GetRedlineAuthor()=0
#define RES_CHRATR_COLOR
Definition: hintids.hxx:72
sal_uInt16 const aTableSetRange[]
Definition: init.cxx:192
sal_Unicode const cSeparator
Definition: UndoTable.hxx:107
bool IsContentNode() const
Definition: node.hxx:628
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
std::unique_ptr< SaveTable > pSaveTable
Definition: UndoTable.hxx:146
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:443
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:495
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
virtual ~SwUndoCpyTable() override
Definition: untbl.cxx:2736
void RstTextAttr(const SwIndex &rIdx, const sal_Int32 nLen, const sal_uInt16 nWhich=0, const SfxItemSet *pSet=nullptr, const bool bInclRefToxMark=false, const bool bExactRange=false)
delete all attributes.
Definition: txtedt.cxx:356
Style of a layout element.
Definition: frmfmt.hxx:57
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:3144
size_t Count() const
Definition: ndhints.hxx:142
void DeRegister()
deregister the currently registered History
Definition: ndhints.hxx:197
void RestoreRowSpan(const SwSaveRowSpan &)
#define SAL_MAX_INT32
virtual ~SwUndoTableAutoFormat() override
Definition: untbl.cxx:1415
sal_Int32 ContentStart() const
Definition: UndoRedline.hxx:72
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SetTableLines(const SwSelBoxes &rBoxes, const SwTable &rTable)
Definition: tblsel.cxx:2102
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
OUString const m_sName
Definition: UndoTable.hxx:374
bool InsertRow(SwTable &rTable, const SwSelBoxes &rBoxes, sal_uInt16 nCnt)
Definition: untbl.cxx:2706
sal_uLong m_nEndNd
Definition: untbl.cxx:197
const SwPosition * GetPoint() const
Definition: pam.hxx:207
#define DEBUG_REDLINE(pDoc)
Definition: untbl.cxx:73
iterator begin()
Definition: docary.hxx:92
static SwSelBoxes & SelLineFromBox(const SwTableBox *pBox, SwSelBoxes &rBoxes, bool bToTop=true)
Definition: tblcpy.cxx:1026
bool empty() const
Definition: swtable.hxx:73
sal_uInt16 AddFormat(SwFrameFormat *pFormat, bool bIsLine)
Definition: untbl.cxx:888
SwTableToTextSave(SwDoc &rDoc, sal_uLong nNd, sal_uLong nEndIdx, sal_Int32 nContent)
Definition: untbl.cxx:358
bool DeleteSel(SwDoc *, const SwSelBoxes &rBoxes, const SwSelBoxes *pMerged, SwUndo *pUndo, const bool bDelMakeFrames, const bool bCorrBorder)
Definition: tblrwcl.cxx:931
SwUndoTableStyleMake(const OUString &rName, const SwDoc *pDoc)
Definition: untbl.cxx:3067
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:317
virtual ~SwUndoTableToText() override
Definition: untbl.cxx:439
SwUndoTableAutoFormat(const SwTableNode &rTableNd, const SwTableAutoFormat &)
Definition: untbl.cxx:1396
std::vector< std::unique_ptr< SwTableToTextSave >> SwTableToTextSaves
Definition: ndarr.hxx:85
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
void NewFrameFormat(const SwTableLine *, const SwTableBox *, sal_uInt16 nFormatPos, SwFrameFormat *pOldFormat)
Definition: untbl.cxx:1073
virtual SwChartDataProvider * GetChartDataProvider(bool bCreate=false) const =0
returns or creates the data-provider for chart
#define RES_VERT_ORIENT
Definition: hintids.hxx:209
virtual ~SwUndoTableCpyTable() override
Definition: untbl.cxx:2328
void SaveFormula(SwHistory &rHistory)
Definition: untbl.cxx:3020
TElementType * First()
Definition: calbck.hxx:342
int i
virtual bool DeleteRedline(const SwPaM &rPam, bool bSaveInUndo, RedlineType nDelType)=0
sal_uInt16 const m_nLineCount
Definition: untbl.cxx:108
void CreateNew(SwTable &rTable, bool bCreateFrames=true, bool bRestoreChart=true)
Definition: untbl.cxx:976
SwContentNode * GetContentNode()
Definition: node.hxx:615
std::unique_ptr< SaveTable > pSavTable
Definition: UndoTable.hxx:338
FlyAnchors.
Definition: fmtanchr.hxx:34
void SetSelBoxes(const SwSelBoxes &rBoxes)
Definition: untbl.cxx:2019
SplitTable_HeadlineOption
Definition: tblenum.hxx:53
static std::unique_ptr< SwUndo > PrepareRedline(SwDoc *pDoc, const SwTableBox &rBox, const SwPosition &rPos, bool &rJoin, bool bRedo)
Definition: untbl.cxx:2635
std::unique_ptr< SfxItemSet > m_pBoxSet
Definition: UndoTable.hxx:239
void ChgTableStyle(const OUString &rName, const SwTableAutoFormat &rNewFormat)
Definition: ndtbl.cxx:4607
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:1390
SwDoc * GetDoc()
Definition: node.hxx:702
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: untbl.cxx:3149
SwDoc * GetDoc() const
Definition: pam.hxx:243
std::unique_ptr< SwTableAutoFormat > m_pAutoFormat
Definition: UndoTable.hxx:53
sal_uLong m_nSttNode
Definition: UndoTable.hxx:180
Marks a character position inside a document model node.
Definition: index.hxx:37
std::unique_ptr< SwHistory > pHistory
Definition: UndoTable.hxx:105
void UnlockModify()
Definition: calbck.hxx:214
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:29
SplitTable_HeadlineOption const nMode
Definition: UndoTable.hxx:315
void LockModify()
Definition: calbck.hxx:213
std::shared_ptr< MetadatableUndo > CreateUndo() const
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:366
sal_uInt16 const nMode
Definition: UndoTable.hxx:340
sal_uInt16 const aTableBoxSetRange[]
Definition: init.cxx:220
void SaveContentAttrs(SwDoc *pDoc)
Definition: untbl.cxx:971
sal_uInt16 const m_nRepeatHeading
Definition: UndoTable.hxx:149
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:849
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: untbl.cxx:347
void MakeOwnFrames(SwNodeIndex *pIdxBehind)
Creates the frms for the table node (i.e. the TabFrames).
Definition: ndtbl.cxx:2375
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:396
virtual ~SwUndoTableNumFormat() override
Definition: untbl.cxx:2119
Marks a node in the document model.
Definition: ndindex.hxx:31
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:425
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart
Definition: untbl.cxx:201
virtual sal_uInt16 ResetAllAttr()
Definition: node.cxx:1683
bool HasSwAttrSet() const
Definition: node.hxx:444
const SwTable * TextToTable(const SwInsertTableOptions &rInsTableOpts, const SwPaM &rRange, sal_Unicode cCh, sal_Int16 eAdjust, const SwTableAutoFormat *)
Text to Table.
Definition: ndtbl.cxx:619
OUString SwResId(const char *pId)
Definition: swmodule.cxx:178
void MoveBoxContent(SwDoc *pDoc, SwNodeRange &rRg, SwNodeIndex &rPos)
Definition: untbl.cxx:2004
sal_uInt16 m_nColumns
Definition: UndoTable.hxx:55
#define RES_BOXATR_VALUE
Definition: hintids.hxx:265
tuple index
bool empty() const
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
void UndoRedo(bool const bUndo,::sw::UndoRedoContext &rContext)
Definition: untbl.cxx:1425
SfxItemSets m_aSets
Definition: untbl.cxx:106
IDocumentChartDataProviderAccess const & getIDocumentChartDataProviderAccess() const
Definition: doc.cxx:226
void ChgDefinedIn(const SwModify *pNew)
Definition: cellatr.hxx:65
bool m_bModifyBox
Definition: untbl.cxx:109
virtual bool MoveNodeRange(SwNodeRange &, SwNodeIndex &, SwMoveFlags)=0
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:2765
SwTableNode * UndoTableToText(sal_uLong nStt, sal_uLong nEnd, const SwTableToTextSaves &rSavedData)
Is in untbl.cxx and may called only by Undo-object.
Definition: untbl.cxx:515
#define CHECK_TABLE(t)
Definition: untbl.cxx:67
SwTableLines & GetTabLines()
Definition: swtable.hxx:198
std::unique_ptr< SwTableAutoFormat > DelTableStyle(const OUString &rName, bool bBroadcast=false)
Definition: ndtbl.cxx:4573
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
sal_uInt16 const aTableLineSetRange[]
Definition: init.cxx:208
void AddBoxBefore(const SwTableBox &rBox, bool bDelContent)
Definition: untbl.cxx:2573
sal_uInt16 nFormulaEnd
Definition: UndoTable.hxx:316
std::unique_ptr< SfxItemSet > pBoxNumAttr
Definition: untbl.cxx:83
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: untbl.cxx:2885
RestoreMode
Definition: mvsave.hxx:70
iterator insert(iterator aIt, Value const &rVal)
Definition: docary.hxx:99
SwTableLines & GetTabLines()
Definition: swtable.hxx:418
void push_back(Value const &rVal)
Definition: docary.hxx:105
TableMergeErr MergeTable(SwPaM &rPam)
Definition: ndtbl.cxx:2212
SwDoc * GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:302
const SwFrameFormat * GetDfltFrameFormat() const
Definition: doc.hxx:741
std::unique_ptr< std::set< BoxMove > > m_pNewSttNds
Definition: UndoTable.hxx:177
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:1997
sal_uInt16 Count() const
Definition: rolbck.hxx:372
sal_uLong m_nSttNode
Definition: undobj.hxx:223
virtual ~SwUndoTableStyleDelete() override
Definition: untbl.cxx:3106
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
void Delete(const void *pOwner, sal_uInt16 nIndex)
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:793
ignore Redlines
void SaveSection(SwStartNode *pSttNd)
Definition: untbl.cxx:1634
std::unique_ptr< SaveLine > m_pLine
Definition: untbl.cxx:104
void EraseText(const SwIndex &rIdx, const sal_Int32 nCount=SAL_MAX_INT32, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
delete text content ATTENTION: must not be called with a range that overlaps the start of an attribut...
Definition: ndtxt.cxx:2659
OUString InsertText(const OUString &rStr, const SwIndex &rIdx, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
insert text content
Definition: ndtxt.cxx:2276
std::vector< std::unique_ptr< SwUndoSaveSection, o3tl::default_delete< SwUndoSaveSection >>> SwUndoSaveSections
Definition: UndoTable.hxx:164
sal_Int16 m_nCount
void ClearSwpHintsArr(bool bDelFields)
Definition: thints.cxx:3365
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
virtual bool SplitRedline(const SwPaM &rPam)=0
void RestoreAttr(SwTable &rTable, bool bModifyBox=false)
Definition: untbl.cxx:921
void RestoreSection(SwDoc *pDoc, SwNodeIndex *pIdx, sal_uInt16 nSectType)
Definition: undobj.cxx:1246
SwTableBoxes & GetTabBoxes()
Definition: swtable.hxx:354
sal_uInt16 const m_nAdjust
Definition: UndoTable.hxx:56
SaveTable & operator=(const SaveTable &)=delete
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:650
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:103
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:334
static void CheckTable(const SwTable &)
Definition: untbl.cxx:3054
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:439
virtual bool SetAttr(const SfxPoolItem &)
made virtual
Definition: node.cxx:1484
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:3075
bool IsInCache() const
Definition: calbck.hxx:219
void SetPaM(SwPaM &, bool bCorrToContent=false) const
Definition: undobj.cxx:77
void ChgFrameFormat(SwTableBoxFormat *pNewFormat, bool bNeedToReregister=true)
Definition: swtable.cxx:1741
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:2125
SwMoveFnCollection const & fnTableStart
Definition: paminit.cxx:52
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:447
long getRowSpan() const
Definition: swtable.cxx:101
std::vector< std::unique_ptr< UndoTableCpyTable_Entry > > m_vArr
Definition: UndoTable.hxx:269
void CorrAbs(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset=0, bool bMoveCursor=false)
Definition: doccorr.cxx:162
sal_uInt16 m_nCount
Definition: UndoTable.hxx:181
sal_uLong nTableNode
Definition: UndoTable.hxx:337
virtual SwPaM & GetCurrentShellCursor()=0
bool SplitTable(const SwSelBoxes &rBoxes, bool bVert, sal_uInt16 nCnt, bool bSameHeight=false)
Split up/merge Boxes in the Table.
Definition: ndtbl.cxx:2146
#define RES_CHRATR_POSTURE
Definition: hintids.hxx:80
bool const bWithPrev
Definition: UndoTable.hxx:341
virtual SwFieldType * InsertFieldType(const SwFieldType &)=0
sal_uInt16 m_nRows
Definition: UndoTable.hxx:55
SwUndoTableMerge(const SwPaM &rTableSel)
Definition: untbl.cxx:1838
bool MoveTable(SwWhichTable, SwMoveFnCollection const &)
Definition: trvltbl.cxx:681
static std::shared_ptr< ContentIdxStore > Create()
void InsertSort(std::vector< sal_uInt16 > &rArr, sal_uInt16 nIdx)
Definition: untbl.cxx:3027
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:253
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
void SetTableStyleName(const OUString &rName)
Set the new table style name for this table.
Definition: swtable.hxx:191
SwUndoTableNdsChg(SwUndoTableNdsChg const &)=delete
sal_Int32 GetIndex() const
Definition: index.hxx:95
sal_uLong GetEndNode() const
void SaveCollection(const SwTableBox &rBox)
Definition: untbl.cxx:2036
virtual bool IsRedlineOn() const =0
Query if redlining is on.
SwNodes & GetNodes()
Definition: doc.hxx:403
SwHistory & GetHistory()
Definition: untbl.cxx:820
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
static SwTableLine * lcl_FindTableLine(const SwTable &rTable, const SwTableBox &rBox)
Definition: untbl.cxx:1527
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:1463
SwUndo(SwUndoId const nId, const SwDoc *pDoc)
Definition: undobj.cxx:158
const SwPosition * End() const
Definition: pam.hxx:217
SwNodeIndex aEnd
Definition: ndindex.hxx:133
std::unique_ptr< SaveTable > pSavTable
Definition: UndoTable.hxx:313
void ClearFEShellTabCols(SwDoc &rDoc, SwTabFrame const *const pFrame)
Definition: fetab.cxx:2084
sal_uInt16 const nAdjust
Definition: UndoTable.hxx:81
sal_uInt16 SetTmpEnd(sal_uInt16 nTmpEnd)
Definition: rolbck.cxx:1197
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
void PaMCorrAbs(const SwPaM &rRange, const SwPosition &rNewPos)
Function declarations so that everything below the CursorShell can move the Cursor once in a while...
Definition: doccorr.cxx:85
#define RES_PARATR_ADJUST
Definition: hintids.hxx:163
SwUndoCpyTable(const SwDoc *pDoc)
Definition: untbl.cxx:2731
std::vector< std::shared_ptr< SfxItemSet > > SfxItemSets
Definition: untbl.cxx:78
const SfxPoolItem & GetFormatAttr(sal_uInt16 nWhich, bool bInParents=true) const
If bInParents is FALSE, search only in this format for attribute.
Definition: format.cxx:377
bool m_bNewModel
Definition: untbl.cxx:111
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:630
void RegisterToFormat(SwFormat &rFormat)
Definition: atrfrm.cxx:2625
void InsertCol(const SwCursor &rCursor, sal_uInt16 nCnt=1, bool bBehind=true)
Inserting Columns/Rows.
Definition: ndtbl.cxx:1699
virtual SwContentNode * JoinNext()
Definition: node.cxx:1450
sal_Unicode const cSeparator
Definition: UndoTable.hxx:80
virtual ~SwUndoTableStyleMake() override
Definition: untbl.cxx:3072
sal_uInt16 const nHdlnRpt
Definition: UndoTable.hxx:108
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1705
static void RemoveIdxRel(sal_uLong, const SwPosition &)
Definition: undobj.cxx:150
void SetRowsToRepeat(SwTable &rTable, sal_uInt16 nSet)
Definition: ndtbl.cxx:2870
std::unique_ptr< SwRedlineData > m_pRedlineData
Definition: UndoTable.hxx:52
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
#define RES_CHRATR_SHADOWED
Definition: hintids.hxx:82
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:2873
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:349
SwTableBox * GetUpper()
Definition: swtable.hxx:362
virtual ~SwUndoInsTable() override
Definition: untbl.cxx:247
sal_uLong nSttNode
Definition: UndoTable.hxx:127
void PrepareDeleteCol(long nMin, long nMax)
SwTable::PrepareDeleteCol(..) adjusts the widths of the neighbour cells of a cell selection for an up...
virtual ~SwUndoMergeTable() override
Definition: untbl.cxx:2922
void SetUpper(SwTableBox *pNew)
Definition: swtable.hxx:364
bool MergeTable(const SwNodeIndex &rPos, bool bWithPrev=true, sal_uInt16 nMode=0)
Two Tables that are following one another are merged.
Definition: ndtbl.cxx:3494
sal_uLong const m_nSttNd
Definition: untbl.cxx:196
void DeleteBox_(SwTable &rTable, SwTableBox *pBox, SwUndo *pUndo, bool bCalcNewSize, const bool bCorrBorder, SwShareBoxFormats *pShareFormats)
Definition: tblrwcl.cxx:649
void SetUpper(SwTableLine *pNew)
Definition: swtable.hxx:423
OUString m_sTableName
Definition: UndoTable.hxx:48
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
#define RES_CHRATR_CROSSEDOUT
Definition: hintids.hxx:74
SwTableToTextSave & operator=(const SwTableToTextSave &)=delete
sal_uInt16 GetPos(const SwTableLine *pBox) const
Definition: swtable.hxx:96
size_t size() const
Definition: docary.hxx:225
std::set< sal_uLong > m_Boxes
Definition: UndoTable.hxx:169
SwUndoInsTable(const SwPosition &, sal_uInt16 nCols, sal_uInt16 nRows, sal_uInt16 eAdjust, const SwInsertTableOptions &rInsTableOpts, const SwTableAutoFormat *pTAFormat, const std::vector< sal_uInt16 > *pColArr, const OUString &rName)
Definition: untbl.cxx:220
Ends a section of nodes in the document model.
Definition: node.hxx:333
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:1648
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: untbl.cxx:859
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:469
std::unique_ptr< SwUndoSaveSections > m_pDelSects
Definition: UndoTable.hxx:178
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:714
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:3080
TableFormulaUpdateFlags m_eFlags
Definition: hints.hxx:208
virtual const SwRedlineTable & GetRedlineTable() const =0
Definition: untbl.cxx:80
void SetNewTable(std::unique_ptr< SwTable >, bool bNewFrames=true)
Definition: ndtbl.cxx:2454
std::pair< const_iterator, bool > insert(Value &&x)
void DeleteBox(const SwTable *pTable, const SwTableBox &rBox)
Definition: unochart.cxx:1447
virtual ~SwUndoTextToTable() override
Definition: untbl.cxx:709
#define RES_PAGEDESC
Definition: hintids.hxx:200
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: untbl.cxx:3123
#define RES_BREAK
Definition: hintids.hxx:201
sal_uLong nTableNode
Definition: UndoTable.hxx:311
void SetBox(const SwTableBox &rBox)
Definition: untbl.cxx:2312
bool IsNewModel() const
Definition: swtable.hxx:185
std::unique_ptr< SwDDEFieldType > pDDEFieldType
Definition: UndoTable.hxx:102
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:2334
SwTableLine * GetUpper()
Definition: swtable.hxx:421
long NodeDiff() const
Definition: UndoRedline.hxx:71
sal_uLong GetDestSttNode() const
const SwTable * InsertTable(const SwInsertTableOptions &rInsTableOpts, const SwPosition &rPos, sal_uInt16 nRows, sal_uInt16 nCols, sal_Int16 eAdjust, const SwTableAutoFormat *pTAFormat=nullptr, const std::vector< sal_uInt16 > *pColArr=nullptr, bool bCalledFromShell=false, bool bNewModel=true)
Insert new table at position.
Definition: ndtbl.cxx:328
void SetRange(const SwNodeRange &)
Definition: untbl.cxx:681
void AddFillBox(const SwTableBox &rBox)
Definition: untbl.cxx:815
sal_uInt16 const nNewHeadline
Definition: UndoTable.hxx:360
void SaveFormula(SwHistory &rHistory)
Definition: untbl.cxx:2894
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: untbl.cxx:340
sal_uLong m_nStartNode
Definition: UndoTable.hxx:54
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:2220
bool const m_bFlag
Definition: UndoTable.hxx:182
void RestoreMetadata(std::shared_ptr< MetadatableUndo > const &i_pUndo)
sal_uLong nBoxIdx
Definition: untbl.cxx:82
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1277
std::unique_ptr< std::vector< sal_uInt16 > > m_pColumnWidth
Definition: UndoTable.hxx:51
std::unique_ptr< SwTableAutoFormat > pAutoFormat
Definition: UndoTable.hxx:78
bool IsDelBox() const
Definition: undobj.cxx:179
std::unique_ptr< SwUndoTableNdsChg > pInsRowUndo
Definition: UndoTable.hxx:270
constexpr sal_uInt32 getSwDefaultTextFormat()
The number formatter's default locale's @ Text format.
Definition: cellatr.hxx:34
bool IsMoveRange() const
no RedlineFlags
bool const bCalcNewSize
Definition: UndoTable.hxx:317
sal_Int32 m_nSttContent
Definition: undobj.hxx:224
std::unique_ptr< SaveTable > pSavHdl
Definition: UndoTable.hxx:338
SfxItemSet m_aTableSet
Definition: untbl.cxx:103
SwCellFrame is one table cell in the document layout.
Definition: cellfrm.hxx:30
SwTableAutoFormat * MakeTableStyle(const OUString &rName, bool bBroadcast=false)
Definition: ndtbl.cxx:4553
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:3139
SwTableToTextSaves m_vBoxSaves
Definition: UndoTable.hxx:104
SwTableBoxFormat * MakeTableBoxFormat()
Definition: docfmt.cxx:1696
iterator erase(iterator aIt)
Definition: swtable.hxx:82
#define RES_BOXATR_FORMAT
Definition: hintids.hxx:263
void AddBoxAfter(const SwTableBox &rBox, const SwNodeIndex &rIdx, bool bDelContent)
Definition: untbl.cxx:2606
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1313
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
void ChkBoxNumFormat(SwTableBox &rCurrentBox, bool bCallUpdate)
Definition: ndtbl.cxx:4010
SwTextNode * MakeTextNode(const SwNodeIndex &rWhere, SwTextFormatColl *pColl, bool bNewFrames=true)
Implementations of "Make...Node" are in the given .cxx-files.
Definition: ndtxt.cxx:103
bool MoveNodes(const SwNodeRange &, SwNodes &rNodes, const SwNodeIndex &, bool bNewFrames=true)
move the node pointer
Definition: nodes.cxx:394
#define RES_BOXATR_FORMULA
Definition: hintids.hxx:264
SwNodeIndex & Assign(SwNodes const &rNds, sal_uLong)
Definition: ndindex.hxx:272
SwTableNode * GetTableNode() const
Definition: swtable.cxx:1926
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:3109
SwUndoAttrTable(const SwTableNode &rTableNd, bool bClearTabCols=false)
Definition: untbl.cxx:1359
Base class of the Writer document model elements.
Definition: node.hxx:79
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:836
void SaveBoxContent(const SwTableBox &rBox)
Definition: untbl.cxx:1419
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: untbl.cxx:1458