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