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