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