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