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