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