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