LibreOffice Module sw (master) 1
rolbck.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 <rolbck.hxx>
21
22#include <libxml/xmlwriter.h>
23
24#include <svl/itemiter.hxx>
26#include <hints.hxx>
27#include <hintids.hxx>
28#include <fmtftn.hxx>
29#include <fchrfmt.hxx>
30#include <fmtflcnt.hxx>
31#include <fmtrfmrk.hxx>
32#include <fmtfld.hxx>
33#include <fmtpdsc.hxx>
34#include <txtfld.hxx>
35#include <txtrfmrk.hxx>
36#include <txttxmrk.hxx>
37#include <txtftn.hxx>
38#include <txtflcnt.hxx>
39#include <fmtanchr.hxx>
40#include <fmtcnct.hxx>
41#include <frmfmt.hxx>
42#include <ftnidx.hxx>
43#include <doc.hxx>
44#include <IDocumentUndoRedo.hxx>
47#include <docary.hxx>
48#include <ndtxt.hxx>
49#include <paratr.hxx>
50#include <cellatr.hxx>
51#include <fldbas.hxx>
52#include <pam.hxx>
53#include <swtable.hxx>
54#include <UndoCore.hxx>
55#include <IMark.hxx>
56#include <charfmt.hxx>
57#include <strings.hrc>
58#include <bookmark.hxx>
59#include <frameformats.hxx>
60#include <memory>
61#include <utility>
62
64{
65 return OUString();
66}
67
69{
70 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHistoryHint"));
71 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
72 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"), BAD_CAST(typeid(*this).name()));
73 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_eWhichId"),
74 BAD_CAST(OString::number(m_eWhichId).getStr()));
75 (void)xmlTextWriterEndElement(pWriter);
76}
77
80 , m_pAttr( pFormatHt->Clone() )
81 , m_nNodeIndex( nNd )
82{
83 switch ( m_pAttr->Which() )
84 {
85 case RES_PAGEDESC:
86 static_cast<SwFormatPageDesc&>(*m_pAttr).ChgDefinedIn( nullptr );
87 break;
88 case RES_PARATR_DROP:
89 static_cast<SwFormatDrop&>(*m_pAttr).ChgDefinedIn(nullptr);
90 break;
92 {
93 // save formulas always in plain text
94 SwTableBoxFormula& rNew = static_cast<SwTableBoxFormula&>(*m_pAttr);
95 if ( rNew.IsIntrnlName() )
96 {
97 const SwTableBoxFormula& rOld =
98 *static_cast<const SwTableBoxFormula*>(pFormatHt);
99 const SwNode* pNd = rOld.GetNodeOfFormula();
100 if ( pNd )
101 {
102 const SwTableNode* pTableNode = pNd->FindTableNode();
103 if (pTableNode)
104 {
105 auto pCpyTable = const_cast<SwTable*>(&pTableNode->GetTable());
107 rNew.ChgDefinedIn(rOld.GetDefinedIn());
108 rNew.ToRelBoxNm(pCpyTable);
109 }
110 }
111 }
112 rNew.ChgDefinedIn( nullptr );
113 }
114 break;
115 }
116}
117
119{
120 OUString aResult;
121
122 switch (m_pAttr->Which())
123 {
124 case RES_BREAK:
125 switch (static_cast<SvxFormatBreakItem &>(*m_pAttr).GetBreak())
126 {
127 case SvxBreak::PageBefore:
128 case SvxBreak::PageAfter:
129 case SvxBreak::PageBoth:
130 aResult = SwResId(STR_UNDO_PAGEBREAKS);
131
132 break;
133 case SvxBreak::ColumnBefore:
134 case SvxBreak::ColumnAfter:
135 case SvxBreak::ColumnBoth:
136 aResult = SwResId(STR_UNDO_COLBRKS);
137
138 break;
139 default:
140 break;
141 }
142 break;
143 default:
144 break;
145 }
146
147 return aResult;
148}
149
151{
152 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHistorySetFormat"));
153 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nNodeIndex"),
154 BAD_CAST(OString::number(sal_Int32(m_nNodeIndex)).getStr()));
156
157 if (m_pAttr)
158 {
159 m_pAttr->dumpAsXml(pWriter);
160 }
161
162 (void)xmlTextWriterEndElement(pWriter);
163}
164
165void SwHistorySetFormat::SetInDoc( SwDoc* pDoc, bool bTmpSet )
166{
167 SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ];
168 if ( pNode->IsContentNode() )
169 {
170 static_cast<SwContentNode*>(pNode)->SetAttr( *m_pAttr );
171 }
172 else if ( pNode->IsTableNode() )
173 {
174 static_cast<SwTableNode*>(pNode)->GetTable().GetFrameFormat()->SetFormatAttr(
175 *m_pAttr );
176 }
177 else if ( pNode->IsStartNode() && (SwTableBoxStartNode ==
178 static_cast<SwStartNode*>(pNode)->GetStartNodeType()) )
179 {
180 SwTableNode* pTNd = pNode->FindTableNode();
181 if ( pTNd )
182 {
183 SwTableBox* pBox = pTNd->GetTable().GetTableBox( m_nNodeIndex );
184 if (pBox)
185 {
187 }
188 }
189 }
190
191 if ( !bTmpSet )
192 {
193 m_pAttr.reset();
194 }
195}
196
198{
199}
200
203 , m_nNodeIndex( nNodeIdx )
204 , m_nWhich( pFormatHt->Which() )
205{
206}
207
209{
210 SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ];
211 if ( pNode->IsContentNode() )
212 {
213 static_cast<SwContentNode*>(pNode)->ResetAttr( m_nWhich );
214 }
215 else if ( pNode->IsTableNode() )
216 {
217 static_cast<SwTableNode*>(pNode)->GetTable().GetFrameFormat()->
218 ResetFormatAttr( m_nWhich );
219 }
220}
221
224 , m_nNodeIndex( nNodePos )
225 , m_nStart( pTextHt->GetStart() )
226 , m_nEnd( pTextHt->GetAnyEnd() )
227 , m_bFormatIgnoreStart(pTextHt->IsFormatIgnoreStart())
228 , m_bFormatIgnoreEnd (pTextHt->IsFormatIgnoreEnd ())
229{
230 // Caution: the following attributes generate no format attributes:
231 // - NoLineBreak, NoHyphen, Inserted, Deleted
232 // These cases must be handled separately !!!
233
234 // a little bit complicated but works: first assign a copy of the
235 // default value and afterwards the values from text attribute
236 if ( RES_TXTATR_CHARFMT == pTextHt->Which() )
237 {
238 m_pAttr.reset( new SwFormatCharFormat( pTextHt->GetCharFormat().GetCharFormat() ) );
239 }
240 else
241 {
242 m_pAttr.reset( pTextHt->GetAttr().Clone() );
243 }
244}
245
247{
248}
249
251{
252 if (!m_pAttr)
253 return;
254
255 if ( RES_TXTATR_CHARFMT == m_pAttr->Which() )
256 {
257 // ask the Doc if the CharFormat still exists
258 if (!pDoc->GetCharFormats()->ContainsFormat(static_cast<SwFormatCharFormat&>(*m_pAttr).GetCharFormat()))
259 return; // do not set, format does not exist
260 }
261
262 SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
263 OSL_ENSURE( pTextNd, "SwHistorySetText::SetInDoc: not a TextNode" );
264
265 if ( !pTextNd )
266 return;
267
268 SwTextAttr *const pAttr = pTextNd->InsertItem(*m_pAttr, m_nStart, m_nEnd,
271 // shouldn't be possible to hit any error/merging path from here
272 assert(pAttr);
274 {
275 pAttr->SetFormatIgnoreStart(true);
276 }
278 {
279 pAttr->SetFormatIgnoreEnd(true);
280 }
281}
282
285 , m_pField( new SwFormatField( *pTextField->GetFormatField().GetField() ) )
286{
287 // only copy if not Sys-FieldType
288 SwDoc& rDoc = pTextField->GetTextNode().GetDoc();
289
290 m_nFieldWhich = m_pField->GetField()->GetTyp()->Which();
296 {
297 m_pFieldType = m_pField->GetField()->GetTyp()->Copy();
298 m_pField->GetField()->ChgTyp( m_pFieldType.get() ); // change field type
299 }
300 m_nNodeIndex = nNodePos;
301 m_nPos = pTextField->GetStart();
302}
303
305{
306 return m_pField->GetField()->GetDescription();
307}
308
310{
311}
312
314{
315 if (!m_pField)
316 return;
317
318 SwFieldType* pNewFieldType = m_pFieldType.get();
319 if ( !pNewFieldType )
320 {
321 pNewFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType( m_nFieldWhich );
322 }
323 else
324 {
325 // register type with the document
326 pNewFieldType = pDoc->getIDocumentFieldsAccess().InsertFieldType( *m_pFieldType );
327 }
328
329 m_pField->GetField()->ChgTyp( pNewFieldType ); // change field type
330
331 SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
332 OSL_ENSURE( pTextNd, "SwHistorySetTextField: no TextNode" );
333
334 if ( pTextNd )
335 {
336 pTextNd->InsertItem( *m_pField, m_nPos, m_nPos,
338 }
339}
340
343 , m_RefName( pTextHt->GetRefMark().GetRefName() )
344 , m_nNodeIndex( nNodePos )
345 , m_nStart( pTextHt->GetStart() )
346 , m_nEnd( pTextHt->GetAnyEnd() )
347{
348}
349
351{
352 SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
353 OSL_ENSURE( pTextNd, "SwHistorySetRefMark: no TextNode" );
354 if ( !pTextNd )
355 return;
356
357 SwFormatRefMark aRefMark( m_RefName );
358
359 // if a reference mark without an end already exists here: must not insert!
360 if ( m_nStart != m_nEnd ||
362 {
363 pTextNd->InsertItem( aRefMark, m_nStart, m_nEnd,
365 }
366}
367
370 , m_TOXMark( pTextHt->GetTOXMark() )
371 , m_TOXName( m_TOXMark.GetTOXType()->GetTypeName() )
372 , m_eTOXTypes( m_TOXMark.GetTOXType()->GetType() )
373 , m_nNodeIndex( nNodePos )
374 , m_nStart( pTextHt->GetStart() )
375 , m_nEnd( pTextHt->GetAnyEnd() )
376{
377 static_cast<SvtListener*>(&m_TOXMark)->EndListeningAll();
378}
379
380SwTOXType* SwHistorySetTOXMark::GetSwTOXType(SwDoc& rDoc, TOXTypes eTOXTypes, const OUString& rTOXName)
381{
382 // search for respective TOX type
383 const sal_uInt16 nCnt = rDoc.GetTOXTypeCount(eTOXTypes);
384 SwTOXType* pToxType = nullptr;
385 for ( sal_uInt16 n = 0; n < nCnt; ++n )
386 {
387 pToxType = const_cast<SwTOXType*>(rDoc.GetTOXType(eTOXTypes, n));
388 if (pToxType->GetTypeName() == rTOXName)
389 break;
390 pToxType = nullptr;
391 }
392
393 if ( !pToxType ) // TOX type not found, create new
394 {
395 pToxType = const_cast<SwTOXType*>(
396 rDoc.InsertTOXType(SwTOXType(rDoc, eTOXTypes, rTOXName)));
397 }
398
399 return pToxType;
400}
401
403{
404 SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
405 OSL_ENSURE( pTextNd, "SwHistorySetTOXMark: no TextNode" );
406 if ( !pTextNd )
407 return;
408
409 SwTOXType* pToxType = GetSwTOXType(*pDoc, m_eTOXTypes, m_TOXName);
410
411 SwTOXMark aNew( m_TOXMark );
412 aNew.RegisterToTOXType( *pToxType );
413
414 pTextNd->InsertItem( aNew, m_nStart, m_nEnd,
416}
417
419{
420 return m_TOXName == rCmp.GetTOXType()->GetTypeName() &&
421 m_eTOXTypes == rCmp.GetTOXType()->GetType() &&
424 ? ( m_TOXMark.GetPrimaryKey() == rCmp.GetPrimaryKey() &&
426 : m_TOXMark.GetLevel() == rCmp.GetLevel()
427 );
428}
429
431 sal_Int32 nAttrStart, sal_Int32 nAttrEnd, SwNodeOffset nNodePos )
433 , m_nNodeIndex( nNodePos ), m_nStart( nAttrStart ), m_nEnd( nAttrEnd )
434 , m_nAttr( nWhich )
435{
436}
437
439{
440 SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
441 OSL_ENSURE( pTextNd, "SwHistoryResetText: no TextNode" );
442 if ( pTextNd )
443 {
445 }
446}
447
450 , m_pUndo( new SwUndoSaveSection )
451 , m_FootnoteNumber( pTextFootnote->GetFootnote().GetNumStr() )
452 , m_nNodeIndex( nNodePos )
453 , m_nStart( pTextFootnote->GetStart() )
454 , m_bEndNote( pTextFootnote->GetFootnote().IsEndNote() )
455{
456 OSL_ENSURE( pTextFootnote->GetStartNode(),
457 "SwHistorySetFootnote: Footnote without Section" );
458
459 // keep the old NodePos (because who knows what later will be saved/deleted
460 // in SaveSection)
461 SwDoc& rDoc = const_cast<SwDoc&>(pTextFootnote->GetTextNode().GetDoc());
462 SwNode* pSaveNd = rDoc.GetNodes()[ m_nNodeIndex ];
463
464 // keep pointer to StartNode of FootnoteSection and reset its attribute for now
465 // (as a result, its/all Frames will be deleted automatically)
466 SwNodeIndex aSttIdx( *pTextFootnote->GetStartNode() );
467 pTextFootnote->SetStartNode( nullptr, false );
468
469 m_pUndo->SaveSection( aSttIdx );
470 m_nNodeIndex = pSaveNd->GetIndex();
471}
472
475 , m_FootnoteNumber( rTextFootnote.GetFootnote().GetNumStr() )
476 , m_nNodeIndex( SwTextFootnote_GetIndex( (&rTextFootnote) ) )
477 , m_nStart( rTextFootnote.GetStart() )
478 , m_bEndNote( rTextFootnote.GetFootnote().IsEndNote() )
479{
480 OSL_ENSURE( rTextFootnote.GetStartNode(),
481 "SwHistorySetFootnote: Footnote without Section" );
482}
483
485{
486 return SwResId(STR_FOOTNOTE);
487}
488
490{
491}
492
494{
495 SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
496 OSL_ENSURE( pTextNd, "SwHistorySetFootnote: no TextNode" );
497 if ( !pTextNd )
498 return;
499
500 if (m_pUndo)
501 {
502 // set the footnote in the TextNode
504 SwFormatFootnote& rNew = const_cast<SwFormatFootnote&>(
505 pDoc->GetAttrPool().Put(aTemp) );
506 if ( !m_FootnoteNumber.isEmpty() )
507 {
509 }
510 SwTextFootnote* pTextFootnote = new SwTextFootnote( rNew, m_nStart );
511
512 // create the section of the Footnote
513 SwNodeIndex aIdx( *pTextNd );
514 m_pUndo->RestoreSection( pDoc, &aIdx, SwFootnoteStartNode );
515 pTextFootnote->SetStartNode( &aIdx );
516 if ( m_pUndo->GetHistory() )
517 {
518 // create frames only now
519 m_pUndo->GetHistory()->Rollback( pDoc );
520 }
521
522 pTextNd->InsertHint( pTextFootnote );
523 }
524 else
525 {
526 SwTextFootnote * const pFootnote =
527 static_cast<SwTextFootnote*>(
528 pTextNd->GetTextAttrForCharAt( m_nStart ));
529 assert(pFootnote);
530 SwFormatFootnote &rFootnote = const_cast<SwFormatFootnote&>(pFootnote->GetFootnote());
531 rFootnote.SetNumStr( m_FootnoteNumber );
532 if ( rFootnote.IsEndNote() != m_bEndNote )
533 {
534 rFootnote.SetEndNote( m_bEndNote );
535 pFootnote->CheckCondColl();
536 }
537 }
538}
539
541 SwNodeType nNodeWhich )
543 , m_pColl( pFormatColl )
544 , m_nNodeIndex( nNd )
545 , m_nNodeType( nNodeWhich )
546{
547}
548
550{
551 SwContentNode * pContentNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetContentNode();
552 OSL_ENSURE( pContentNd, "SwHistoryChangeFormatColl: no ContentNode" );
553
554 // before setting the format, check if it is still available in the
555 // document. if it has been deleted, there is no undo!
556 if ( !(pContentNd && m_nNodeType == pContentNd->GetNodeType()) )
557 return;
558
560 {
561 if (pDoc->GetTextFormatColls()->IsAlive(static_cast<SwTextFormatColl *>(m_pColl)))
562 {
563 pContentNd->ChgFormatColl( m_pColl );
564 }
565 }
566 else if (pDoc->GetGrfFormatColls()->IsAlive(static_cast<SwGrfFormatColl *>(m_pColl)))
567 {
568 pContentNd->ChgFormatColl( m_pColl );
569 }
570}
571
574 , m_pUndo( new SwUndoDelLayFormat( pFlyFormat ) )
575{
576 OSL_ENSURE( pFlyFormat, "SwHistoryTextFlyCnt: no Format" );
577 m_pUndo->ChgShowSel( false );
578}
579
581{
582}
583
585{
587 assert(pISCS);
588 ::sw::UndoRedoContext context(*pDoc, *pISCS);
589 m_pUndo->UndoImpl(context);
590}
591
593{
594 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHistoryTextFlyCnt"));
596
597 if (m_pUndo)
598 {
599 m_pUndo->dumpAsXml(pWriter);
600 }
601
602 (void)xmlTextWriterEndElement(pWriter);
603}
604
606 const ::sw::mark::IMark& rBkmk,
607 bool bSavePos,
608 bool bSaveOtherPos)
610 , m_aName(rBkmk.GetName())
611 , m_bHidden(false)
612 , m_nNode(bSavePos ?
613 rBkmk.GetMarkPos().GetNodeIndex() : SwNodeOffset(0))
614 , m_nOtherNode(bSaveOtherPos ?
615 rBkmk.GetOtherMarkPos().GetNodeIndex() : SwNodeOffset(0))
616 , m_nContent(bSavePos ?
617 rBkmk.GetMarkPos().GetContentIndex() : 0)
618 , m_nOtherContent(bSaveOtherPos ?
619 rBkmk.GetOtherMarkPos().GetContentIndex() :0)
620 , m_bSavePos(bSavePos)
621 , m_bSaveOtherPos(bSaveOtherPos)
622 , m_bHadOtherPos(rBkmk.IsExpanded())
623 , m_eBkmkType(IDocumentMarkAccess::GetType(rBkmk))
624{
625 const ::sw::mark::IBookmark* const pBookmark = dynamic_cast< const ::sw::mark::IBookmark* >(&rBkmk);
626 if(!pBookmark)
627 return;
628
629 m_aKeycode = pBookmark->GetKeyCode();
630 m_aShortName = pBookmark->GetShortName();
631 m_bHidden = pBookmark->IsHidden();
632 m_aHideCondition = pBookmark->GetHideCondition();
633
634 ::sfx2::Metadatable const*const pMetadatable(
635 dynamic_cast< ::sfx2::Metadatable const* >(pBookmark));
636 if (pMetadatable)
637 {
638 m_pMetadataUndo = pMetadatable->CreateUndo();
639 }
640}
641
643{
644 ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
645
646 SwNodes& rNds = pDoc->GetNodes();
647 IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
648 std::optional<SwPaM> pPam;
649 ::sw::mark::IMark* pMark = nullptr;
650
651 if(m_bSavePos)
652 {
653 SwContentNode* const pContentNd = rNds[m_nNode]->GetContentNode();
654 OSL_ENSURE(pContentNd,
655 "<SwHistoryBookmark::SetInDoc(..)>"
656 " - wrong node for a mark");
657
658 // #111660# don't crash when nNode1 doesn't point to content node.
659 if(pContentNd)
660 pPam.emplace(*pContentNd, m_nContent);
661 }
662 else
663 {
664 pMark = *pMarkAccess->findMark(m_aName);
665 pPam.emplace(pMark->GetMarkPos());
666 }
667
669 {
670 SwContentNode* const pContentNd = rNds[m_nOtherNode]->GetContentNode();
671 OSL_ENSURE(pContentNd,
672 "<SwHistoryBookmark::SetInDoc(..)>"
673 " - wrong node for a mark");
674
675 if (pPam && pContentNd)
676 {
677 pPam->SetMark();
678 pPam->GetMark()->Assign(*pContentNd, m_nOtherContent);
679 }
680 }
681 else if(m_bHadOtherPos)
682 {
683 if(!pMark)
684 pMark = *pMarkAccess->findMark(m_aName);
685 OSL_ENSURE(pMark->IsExpanded(),
686 "<SwHistoryBookmark::SetInDoc(..)>"
687 " - missing pos on old mark");
688 pPam->SetMark();
689 *pPam->GetMark() = pMark->GetOtherMarkPos();
690 }
691
692 if (!pPam)
693 return;
694
695 if ( pMark != nullptr )
696 {
697 pMarkAccess->deleteMark( pMark );
698 }
699 ::sw::mark::IBookmark* const pBookmark =
700 dynamic_cast<::sw::mark::IBookmark*>(
702 if ( pBookmark == nullptr )
703 return;
704
705 pBookmark->SetKeyCode(m_aKeycode);
706 pBookmark->SetShortName(m_aShortName);
707 pBookmark->Hide(m_bHidden);
709
710 if (m_pMetadataUndo)
711 {
712 ::sfx2::Metadatable * const pMeta(
713 dynamic_cast< ::sfx2::Metadatable* >(pBookmark));
714 OSL_ENSURE(pMeta, "metadata undo, but not metadatable?");
715 if (pMeta)
716 {
717 pMeta->RestoreMetadata(m_pMetadataUndo);
718 }
719 }
720}
721
722bool SwHistoryBookmark::IsEqualBookmark(const ::sw::mark::IMark& rBkmk)
723{
724 return m_nNode == rBkmk.GetMarkPos().GetNodeIndex()
725 && m_nContent == rBkmk.GetMarkPos().GetContentIndex()
726 && m_aName == rBkmk.GetName();
727}
728
729SwHistoryNoTextFieldmark::SwHistoryNoTextFieldmark(const ::sw::mark::IFieldmark& rFieldMark)
731 , m_sType(rFieldMark.GetFieldname())
732 , m_nNode(rFieldMark.GetMarkStart().GetNodeIndex())
733 , m_nContent(rFieldMark.GetMarkStart().GetContentIndex())
734{
735}
736
738{
739 ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
740
741 SwNodes& rNds = pDoc->GetNodes();
742 std::optional<SwPaM> pPam;
743
744 const SwContentNode* pContentNd = rNds[m_nNode]->GetContentNode();
745 if(pContentNd)
746 pPam.emplace(*pContentNd, m_nContent);
747
748 if (pPam)
749 {
750 IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
751 pMarkAccess->makeNoTextFieldBookmark(*pPam, OUString(), m_sType);
752 }
753}
754
756{
757 ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
758
759 SwNodes& rNds = rDoc.GetNodes();
760 std::optional<SwPaM> pPam;
761
762 const SwContentNode* pContentNd = rNds[m_nNode]->GetContentNode();
763 assert(pContentNd);
764 pPam.emplace(*pContentNd, m_nContent);
765
766 if (pPam)
767 {
768 IDocumentMarkAccess* pMarkAccess = rDoc.getIDocumentMarkAccess();
769 pMarkAccess->deleteFieldmarkAt(*pPam->GetPoint());
770 }
771}
772
773SwHistoryTextFieldmark::SwHistoryTextFieldmark(const ::sw::mark::IFieldmark& rFieldMark)
775 , m_sName(rFieldMark.GetName())
776 , m_sType(rFieldMark.GetFieldname())
777 , m_nStartNode(rFieldMark.GetMarkStart().GetNodeIndex())
778 , m_nStartContent(rFieldMark.GetMarkStart().GetContentIndex())
779 , m_nEndNode(rFieldMark.GetMarkEnd().GetNodeIndex())
780 , m_nEndContent(rFieldMark.GetMarkEnd().GetContentIndex())
781{
782 SwPosition const sepPos(sw::mark::FindFieldSep(rFieldMark));
783 m_nSepNode = sepPos.GetNodeIndex();
785}
786
788{
789 ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
790
791 SwNodes& rNds = pDoc->GetNodes();
792
793 assert(rNds[m_nStartNode]->IsContentNode());
794 assert(rNds[m_nEndNode]->IsContentNode());
795 assert(rNds[m_nSepNode]->IsContentNode());
796
798 *rNds[m_nEndNode]->GetContentNode(),
799 // subtract 1 for the CH_TXT_ATR_FIELDEND itself,
800 // plus more if same node as other CH_TXT_ATR
802 ? (m_nEndContent - 3)
804 ? (m_nEndContent - 2)
805 : (m_nEndContent - 1));
806 SwPosition const sepPos(*rNds[m_nSepNode]->GetContentNode(),
808
809 IDocumentMarkAccess & rMarksAccess(*pDoc->getIDocumentMarkAccess());
810 rMarksAccess.makeFieldBookmark(pam, m_sName, m_sType, &sepPos);
811}
812
814{
815 ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
816
817 SwNodes& rNds = rDoc.GetNodes();
818
819 assert(rNds[m_nStartNode]->IsContentNode());
820 assert(rNds[m_nEndNode]->IsContentNode());
821 assert(rNds[m_nSepNode]->IsContentNode());
822
824
825 IDocumentMarkAccess & rMarksAccess(*rDoc.getIDocumentMarkAccess());
826 rMarksAccess.deleteFieldmarkAt(pos);
827}
828
830 SwNodeOffset nNodePos, const o3tl::sorted_vector<sal_uInt16> &rSetArr )
832 , m_OldSet( rSet )
833 , m_ResetArray( 0, 4 )
834 , m_nNodeIndex( nNodePos )
835{
836 SfxItemIter aIter( m_OldSet ), aOrigIter( rSet );
837 const SfxPoolItem* pItem = aIter.GetCurItem(),
838 * pOrigItem = aOrigIter.GetCurItem();
839 while (pItem && pOrigItem)
840 {
841 if( !rSetArr.count( pOrigItem->Which() ))
842 {
843 m_ResetArray.push_back( pOrigItem->Which() );
844 m_OldSet.ClearItem( pOrigItem->Which() );
845 }
846 else
847 {
848 switch ( pItem->Which() )
849 {
850 case RES_PAGEDESC:
851 static_cast<SwFormatPageDesc*>(
852 const_cast<SfxPoolItem*>(pItem))->ChgDefinedIn( nullptr );
853 break;
854
855 case RES_PARATR_DROP:
856 static_cast<SwFormatDrop*>(
857 const_cast<SfxPoolItem*>(pItem))->ChgDefinedIn(nullptr);
858 break;
859
861 {
862 // When a formula is set, never save the value. It
863 // possibly must be recalculated!
864 // Save formulas always in plain text
866
867 SwTableBoxFormula& rNew =
868 *static_cast<SwTableBoxFormula*>(
869 const_cast<SfxPoolItem*>(pItem));
870 if ( rNew.IsIntrnlName() )
871 {
872 const SwTableBoxFormula& rOld =
874 const SwNode* pNd = rOld.GetNodeOfFormula();
875 if ( pNd )
876 {
877 const SwTableNode* pTableNode
878 = pNd->FindTableNode();
879 if(pTableNode)
880 {
881 auto pCpyTable = const_cast<SwTable*>(&pTableNode->GetTable());
883 rNew.ChgDefinedIn(rOld.GetDefinedIn());
884 rNew.PtrToBoxNm(pCpyTable);
885 }
886 }
887 }
888 rNew.ChgDefinedIn( nullptr );
889 }
890 break;
891 }
892 }
893
894 pItem = aIter.NextItem();
895 pOrigItem = aOrigIter.NextItem();
896 }
897}
898
900{
901 ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
902
903 SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ];
904 if ( pNode->IsContentNode() )
905 {
906 static_cast<SwContentNode*>(pNode)->SetAttr( m_OldSet );
907 if ( !m_ResetArray.empty() )
908 {
909 static_cast<SwContentNode*>(pNode)->ResetAttr( m_ResetArray );
910 }
911 }
912 else if ( pNode->IsTableNode() )
913 {
914 SwFormat& rFormat =
915 *static_cast<SwTableNode*>(pNode)->GetTable().GetFrameFormat();
916 rFormat.SetFormatAttr( m_OldSet );
917 if ( !m_ResetArray.empty() )
918 {
919 rFormat.ResetFormatAttr( m_ResetArray.front() );
920 }
921 }
922}
923
926 , m_rFormat(rFormat)
927 , m_nOldNodeIndex( rFormat.GetAnchor().GetAnchorNode()->GetIndex() )
928 , m_nOldContentIndex( (RndStdIds::FLY_AT_CHAR == rFormat.GetAnchor().GetAnchorId())
929 ? rFormat.GetAnchor().GetAnchorContentOffset()
931{
932}
933
935{
936 ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
937
938 // One would expect m_rFormat to only contain FlyFormats, given the name of
939 // this class, but apparently it is also used for DrawFormats.
940 if (!pDoc->GetSpzFrameFormats()->IsAlive(&m_rFormat)) // Format does still exist
941 return;
942
944
945 SwNode* pNd = pDoc->GetNodes()[ m_nOldNodeIndex ];
946 SwContentNode* pCNd = pNd->GetContentNode();
947 SwPosition aPos( *pNd );
950 aTmp.SetAnchor( &aPos );
951
952 // so the Layout does not get confused
953 if (!pCNd->getLayoutFrame(pDoc->getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, nullptr))
954 {
956 }
957
958 m_rFormat.SetFormatAttr( aTmp );
959}
960
962 const SwFormatChain& rAttr )
964 , m_pPrevFormat( rAttr.GetPrev() )
965 , m_pNextFormat( rAttr.GetNext() )
966 , m_pFlyFormat( &rFormat )
967{
968}
969
971{
972 if (!pDoc->GetSpzFrameFormats()->IsAlive(m_pFlyFormat))
973 return;
974
975 SwFormatChain aChain;
976
977 if (m_pPrevFormat &&
978 pDoc->GetSpzFrameFormats()->IsAlive(m_pPrevFormat))
979 {
980 aChain.SetPrev( m_pPrevFormat );
982 aTmp.SetNext( m_pFlyFormat );
984 }
985
986 if (m_pNextFormat &&
987 pDoc->GetSpzFrameFormats()->IsAlive(m_pNextFormat))
988 {
989 aChain.SetNext( m_pNextFormat );
991 aTmp.SetPrev( m_pFlyFormat );
993 }
994
995 if ( aChain.GetNext() || aChain.GetPrev() )
996 {
997 m_pFlyFormat->SetFormatAttr( aChain );
998 }
999}
1000
1001// -> #i27615#
1003 OUString sFormat)
1005 , m_OldSet(std::move(aSet)), m_Format(std::move(sFormat))
1006{
1007}
1008
1010{
1011 SwCharFormat * pCharFormat = pDoc->FindCharFormatByName(m_Format);
1012
1013 if (pCharFormat)
1014 {
1015 pCharFormat->SetFormatAttr(m_OldSet);
1016 }
1017}
1018// <- #i27615#
1019
1021 : m_nEndDiff( 0 )
1022{
1023}
1024
1026{
1027}
1028
1030 const SfxPoolItem* pOldValue,
1031 const SfxPoolItem* pNewValue,
1032 SwNodeOffset nNodeIdx)
1033{
1034 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1035 const sal_uInt16 nWhich(pNewValue->Which());
1036
1037 // excluded values
1038 if(nWhich == RES_TXTATR_FIELD || nWhich == RES_TXTATR_ANNOTATION)
1039 {
1040 return;
1041 }
1042
1043 // no default Attribute?
1044 std::unique_ptr<SwHistoryHint> pHt;
1045
1046 // To be able to include the DrawingLayer FillItems something more
1047 // general has to be done to check if an Item is default than to check
1048 // if its pointer equals that in Writer's global PoolDefaults (held in
1049 // aAttrTab and used to fill the pool defaults in Writer - looks as if
1050 // Writer is *older* than the SfxItemPool ?). I checked the possibility to
1051 // get the SfxItemPool here (works), but decided to use the SfxPoolItem's
1052 // global tooling aka IsDefaultItem(const SfxPoolItem*) for now
1053 if(pOldValue && !IsDefaultItem(pOldValue))
1054 {
1055 pHt.reset( new SwHistorySetFormat( pOldValue, nNodeIdx ) );
1056 }
1057 else
1058 {
1059 pHt.reset( new SwHistoryResetFormat( pNewValue, nNodeIdx ) );
1060 }
1061
1062 m_SwpHstry.push_back( std::move(pHt) );
1063}
1064
1065// FIXME: refactor the following "Add" methods (DRY)?
1066void SwHistory::Add( SwTextAttr* pHint, SwNodeOffset nNodeIdx, bool bNewAttr )
1067{
1068 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1069
1070 std::unique_ptr<SwHistoryHint> pHt;
1071 if( !bNewAttr )
1072 {
1073 switch ( pHint->Which() )
1074 {
1075 case RES_TXTATR_FTN:
1076 pHt.reset( new SwHistorySetFootnote(
1077 static_cast<SwTextFootnote*>(pHint), nNodeIdx ) );
1078 break;
1079 case RES_TXTATR_FLYCNT:
1080 pHt.reset( new SwHistoryTextFlyCnt( static_cast<SwTextFlyCnt*>(pHint)
1081 ->GetFlyCnt().GetFrameFormat() ) );
1082 break;
1083 case RES_TXTATR_FIELD:
1085 pHt.reset( new SwHistorySetTextField(
1086 static_txtattr_cast<SwTextField*>(pHint), nNodeIdx) );
1087 break;
1088 case RES_TXTATR_TOXMARK:
1089 pHt.reset( new SwHistorySetTOXMark(
1090 static_txtattr_cast<SwTextTOXMark*>(pHint), nNodeIdx) );
1091 break;
1092 case RES_TXTATR_REFMARK:
1093 pHt.reset( new SwHistorySetRefMark(
1094 static_txtattr_cast<SwTextRefMark*>(pHint), nNodeIdx) );
1095 break;
1096 default:
1097 pHt.reset( new SwHistorySetText( pHint, nNodeIdx ) );
1098 }
1099 }
1100 else
1101 {
1102 pHt.reset( new SwHistoryResetText( pHint->Which(), pHint->GetStart(),
1103 pHint->GetAnyEnd(), nNodeIdx ) );
1104 }
1105 m_SwpHstry.push_back( std::move(pHt) );
1106}
1107
1108void SwHistory::Add( SwFormatColl* pColl, SwNodeOffset nNodeIdx, SwNodeType nWhichNd )
1109{
1110 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1111
1112 std::unique_ptr<SwHistoryHint> pHt(
1113 new SwHistoryChangeFormatColl( pColl, nNodeIdx, nWhichNd ));
1114 m_SwpHstry.push_back( std::move(pHt) );
1115}
1116
1117void SwHistory::Add(const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOtherPos)
1118{
1119 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1120
1121 std::unique_ptr<SwHistoryHint> pHt;
1122
1123 switch (IDocumentMarkAccess::GetType(rBkmk))
1124 {
1127 assert(bSavePos && bSaveOtherPos); // must be deleted completely!
1128 pHt.reset(new SwHistoryTextFieldmark(dynamic_cast<sw::mark::IFieldmark const&>(rBkmk)));
1129 break;
1132 assert(bSavePos && bSaveOtherPos); // must be deleted completely!
1133 pHt.reset(new SwHistoryNoTextFieldmark(dynamic_cast<sw::mark::IFieldmark const&>(rBkmk)));
1134 break;
1135 default:
1136 pHt.reset(new SwHistoryBookmark(rBkmk, bSavePos, bSaveOtherPos));
1137 break;
1138 }
1139
1140 assert(pHt);
1141 m_SwpHstry.push_back( std::move(pHt) );
1142}
1143
1145{
1146 std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeFlyAnchor(rFormat));
1147 m_SwpHstry.push_back( std::move(pHt) );
1148}
1149
1150void SwHistory::AddDeleteFly(SwFrameFormat& rFormat, sal_uInt16& rSetPos)
1151{
1152 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1153
1154 const sal_uInt16 nWh = rFormat.Which();
1155 (void) nWh;
1156 // only Flys!
1157 assert((RES_FLYFRMFMT == nWh && dynamic_cast<SwFlyFrameFormat*>(&rFormat))
1158 || (RES_DRAWFRMFMT == nWh && dynamic_cast<SwDrawFrameFormat*>(&rFormat)));
1159 {
1160 std::unique_ptr<SwHistoryHint> pHint(new SwHistoryTextFlyCnt( &rFormat ));
1161 m_SwpHstry.push_back( std::move(pHint) );
1162
1163 if( const SwFormatChain* pChainItem = rFormat.GetItemIfSet( RES_CHAIN, false ) )
1164 {
1165 assert(RES_FLYFRMFMT == nWh); // not supported on SdrObjects
1166 if( pChainItem->GetNext() || pChainItem->GetPrev() )
1167 {
1168 std::unique_ptr<SwHistoryHint> pHt(
1169 new SwHistoryChangeFlyChain(static_cast<SwFlyFrameFormat&>(rFormat), *pChainItem));
1170 m_SwpHstry.insert( m_SwpHstry.begin() + rSetPos++, std::move(pHt) );
1171 if ( pChainItem->GetNext() )
1172 {
1173 SwFormatChain aTmp( pChainItem->GetNext()->GetChain() );
1174 aTmp.SetPrev( nullptr );
1175 pChainItem->GetNext()->SetFormatAttr( aTmp );
1176 }
1177 if ( pChainItem->GetPrev() )
1178 {
1179 SwFormatChain aTmp( pChainItem->GetPrev()->GetChain() );
1180 aTmp.SetNext( nullptr );
1181 pChainItem->GetPrev()->SetFormatAttr( aTmp );
1182 }
1183 }
1184 rFormat.ResetFormatAttr( RES_CHAIN );
1185 }
1186 }
1187}
1188
1189void SwHistory::Add( const SwTextFootnote& rFootnote )
1190{
1191 std::unique_ptr<SwHistoryHint> pHt(new SwHistorySetFootnote( rFootnote ));
1192 m_SwpHstry.push_back( std::move(pHt) );
1193}
1194
1195// #i27615#
1196void SwHistory::Add(const SfxItemSet & rSet, const SwCharFormat & rFormat)
1197{
1198 std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeCharFormat(rSet, rFormat.GetName()));
1199 m_SwpHstry.push_back( std::move(pHt) );
1200}
1201
1202bool SwHistory::Rollback( SwDoc* pDoc, sal_uInt16 nStart )
1203{
1204 if ( !Count() )
1205 return false;
1206
1207 for ( sal_uInt16 i = Count(); i > nStart ; )
1208 {
1209 SwHistoryHint * pHHt = m_SwpHstry[ --i ].get();
1210 pHHt->SetInDoc( pDoc, false );
1211 }
1212 m_SwpHstry.erase( m_SwpHstry.begin() + nStart, m_SwpHstry.end() );
1213 m_nEndDiff = 0;
1214 return true;
1215}
1216
1217bool SwHistory::TmpRollback( SwDoc* pDoc, sal_uInt16 nStart, bool bToFirst )
1218{
1219 sal_uInt16 nEnd = Count() - m_nEndDiff;
1220 if ( !Count() || !nEnd || nStart >= nEnd )
1221 return false;
1222
1223 if ( bToFirst )
1224 {
1225 for ( ; nEnd > nStart; ++m_nEndDiff )
1226 {
1227 SwHistoryHint* pHHt = m_SwpHstry[ --nEnd ].get();
1228 pHHt->SetInDoc( pDoc, true );
1229 }
1230 }
1231 else
1232 {
1233 for ( ; nStart < nEnd; ++m_nEndDiff, ++nStart )
1234 {
1235 SwHistoryHint* pHHt = m_SwpHstry[ nStart ].get();
1236 pHHt->SetInDoc( pDoc, true );
1237 }
1238 }
1239 return true;
1240}
1241
1242sal_uInt16 SwHistory::SetTmpEnd( sal_uInt16 nNewTmpEnd )
1243{
1244 OSL_ENSURE( nNewTmpEnd <= Count(), "SwHistory::SetTmpEnd: out of bounds" );
1245
1246 const sal_uInt16 nOld = Count() - m_nEndDiff;
1247 m_nEndDiff = Count() - nNewTmpEnd;
1248
1249 // for every SwHistoryFlyCnt, call the Redo of its UndoObject.
1250 // this saves the formats of the flys!
1251 for ( sal_uInt16 n = nOld; n < nNewTmpEnd; n++ )
1252 {
1253 if ( HSTRY_FLYCNT == (*this)[ n ]->Which() )
1254 {
1255 static_cast<SwHistoryTextFlyCnt*>((*this)[ n ])
1256 ->GetUDelLFormat()->RedoForRollback();
1257 }
1258 }
1259
1260 return nOld;
1261}
1262
1264 const SfxItemSet& rSet,
1265 SwNodeOffset nNodeIdx)
1266{
1267 if(!rSet.Count())
1268 return;
1269
1270 SfxItemIter aIter(rSet);
1271 const SfxPoolItem* pItem = aIter.GetCurItem();
1272 do
1273 {
1274 if(!IsInvalidItem(pItem))
1275 {
1276 Add(pItem, pItem, nNodeIdx);
1277 }
1278
1279 pItem = aIter.NextItem();
1280
1281 } while(pItem);
1282}
1283
1285{
1286 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHistory"));
1287 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1288
1289 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_SwpHstry"));
1290 for (const auto& pHistory : m_SwpHstry)
1291 {
1292 pHistory->dumpAsXml(pWriter);
1293 }
1294 (void)xmlTextWriterEndElement(pWriter);
1295
1296 (void)xmlTextWriterEndElement(pWriter);
1297}
1298
1300 SwpHints const * pHts,
1301 const SwNodeOffset nNodeIdx,
1302 const sal_Int32 nStart,
1303 const sal_Int32 nEnd,
1304 const bool bCopyFields )
1305{
1306 if( !pHts )
1307 return;
1308
1309 // copy all attributes of the TextNode in the area from nStart to nEnd
1310 SwTextAttr* pHt;
1311 for( size_t n = 0; n < pHts->Count(); ++n )
1312 {
1313 // nAttrStt must even be set when !pEndIdx
1314 pHt = pHts->Get(n);
1315 const sal_Int32 nAttrStt = pHt->GetStart();
1316 const sal_Int32 * pEndIdx = pHt->GetEnd();
1317 if( nullptr != pEndIdx && nAttrStt > nEnd )
1318 break;
1319
1320 // never copy Flys and Footnote !!
1321 bool bNextAttr = false;
1322 switch( pHt->Which() )
1323 {
1324 case RES_TXTATR_FIELD:
1327 if( !bCopyFields )
1328 bNextAttr = true;
1329 break;
1330 case RES_TXTATR_FLYCNT:
1331 case RES_TXTATR_FTN:
1332 bNextAttr = true;
1333 break;
1334 }
1335
1336 if( bNextAttr )
1337 continue;
1338
1339 // save all attributes that are somehow in this area
1340 if ( nStart <= nAttrStt )
1341 {
1342 if ( nEnd > nAttrStt )
1343 {
1344 Add( pHt, nNodeIdx, false );
1345 }
1346 }
1347 else if ( pEndIdx && nStart < *pEndIdx )
1348 {
1349 Add( pHt, nNodeIdx, false );
1350 }
1351 }
1352}
1353
1354// Class to register the history at a Node, Format, HintsArray, ...
1356 : SwClient( nullptr )
1357 , m_pHistory( pHst )
1358 , m_nNodeIndex( NODE_OFFSET_MAX )
1359{
1361}
1362
1363SwRegHistory::SwRegHistory( sw::BroadcastingModify* pRegIn, const SwNode& rNd,
1364 SwHistory* pHst )
1365 : SwClient( pRegIn )
1366 , m_pHistory( pHst )
1367 , m_nNodeIndex( rNd.GetIndex() )
1368{
1370}
1371
1373 : SwClient( nullptr )
1374 , m_pHistory( pHst )
1375 , m_nNodeIndex( rNd.GetIndex() )
1376{
1378}
1379
1381{
1382 if (rHint.GetId() != SfxHintId::SwLegacyModify)
1383 return;
1384 auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
1385 if ( !(m_pHistory && pLegacyHint->m_pNew && pLegacyHint->m_pOld != pLegacyHint->m_pNew) )
1386 return;
1387
1388 if ( pLegacyHint->m_pNew->Which() < POOLATTR_END )
1389 {
1390 if(RES_UPDATE_ATTR == pLegacyHint->m_pNew->Which())
1391 {
1392 m_pHistory->Add(pLegacyHint->m_pOld, pLegacyHint->m_pNew, m_nNodeIndex);
1393 }
1394 else
1395 {
1396 OSL_ENSURE(false, "Unexpected update attribute (!)");
1397 }
1398 }
1399 else if (pLegacyHint->m_pOld && RES_ATTRSET_CHG == pLegacyHint->m_pNew->Which())
1400 {
1401 std::unique_ptr<SwHistoryHint> pNewHstr;
1402 const SfxItemSet& rSet = *static_cast< const SwAttrSetChg* >(pLegacyHint->m_pOld)->GetChgSet();
1403
1404 if ( 1 < rSet.Count() )
1405 {
1406 pNewHstr.reset( new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet ) );
1407 }
1408 else if (const SfxPoolItem* pItem = SfxItemIter(rSet).GetCurItem())
1409 {
1410 if ( m_WhichIdSet.count( pItem->Which() ) )
1411 {
1412 pNewHstr.reset( new SwHistorySetFormat( pItem, m_nNodeIndex ) );
1413 }
1414 else
1415 {
1416 pNewHstr.reset( new SwHistoryResetFormat( pItem, m_nNodeIndex ) );
1417 }
1418 }
1419
1420 if (pNewHstr)
1421 m_pHistory->m_SwpHstry.push_back( std::move(pNewHstr) );
1422 }
1423}
1424
1425void SwRegHistory::AddHint( SwTextAttr* pHt, const bool bNew )
1426{
1427 m_pHistory->Add( pHt, m_nNodeIndex, bNew );
1428}
1429
1431 sal_Int32 const nStart, sal_Int32 const nEnd, SetAttrMode const nFlags,
1432 SwTextAttr **ppNewTextAttr )
1433{
1434 if( !rSet.Count() )
1435 return false;
1436
1437 SwTextNode * const pTextNode =
1438 dynamic_cast<SwTextNode *>(GetRegisteredIn());
1439
1440 OSL_ENSURE(pTextNode, "SwRegHistory not registered at text node?");
1441 if (!pTextNode)
1442 return false;
1443
1444 if (m_pHistory)
1445 {
1446 pTextNode->GetOrCreateSwpHints().Register(this);
1447 }
1448
1449 const bool bInserted = pTextNode->SetAttr( rSet, nStart, nEnd, nFlags, ppNewTextAttr );
1450
1451 // Caution: The array can be deleted when inserting an attribute!
1452 // This can happen when the value that should be added first deletes
1453 // an existing attribute but does not need to be added itself because
1454 // the paragraph attributes are identical
1455 // ( -> bForgetAttr in SwpHints::Insert )
1456 if ( pTextNode->GetpSwpHints() && m_pHistory )
1457 {
1458 pTextNode->GetpSwpHints()->DeRegister();
1459 }
1460
1461#ifndef NDEBUG
1462 if ( m_pHistory && bInserted )
1463 {
1464 SfxItemIter aIter(rSet);
1465 for (SfxPoolItem const* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1466 { // check that the history recorded a hint to reset every item
1467 sal_uInt16 const nWhich(pItem->Which());
1468 sal_uInt16 const nExpected(
1469 (isCHRATR(nWhich) || RES_TXTATR_UNKNOWN_CONTAINER == nWhich)
1471 : nWhich);
1472 if (RES_TXTATR_AUTOFMT == nExpected)
1473 continue; // special case, may get set on text node itself
1474 // tdf#105077 even worse, node's set could cause
1475 // nothing at all to be inserted
1476 assert(std::any_of(
1477 m_pHistory->m_SwpHstry.begin(), m_pHistory->m_SwpHstry.end(),
1478 [nExpected](std::unique_ptr<SwHistoryHint> const& pHint) -> bool {
1479 SwHistoryResetText const*const pReset(
1480 dynamic_cast<SwHistoryResetText const*>(pHint.get()));
1481 return pReset && (pReset->GetWhich() == nExpected);
1482 }));
1483 }
1484 }
1485#endif
1486
1487 return bInserted;
1488}
1489
1490void SwRegHistory::RegisterInModify( sw::BroadcastingModify* pRegIn, const SwNode& rNd )
1491{
1492 if ( m_pHistory && pRegIn )
1493 {
1494 pRegIn->Add( this );
1495 m_nNodeIndex = rNd.GetIndex();
1497 }
1498 else
1499 {
1501 }
1502}
1503
1505{
1506 if (!m_pHistory) return;
1507
1509
1510 if( !GetRegisteredIn() )
1511 return;
1512
1513 const SfxItemSet* pSet = nullptr;
1514 if( auto pContentNode = dynamic_cast< const SwContentNode *>( GetRegisteredIn() ) )
1515 {
1516 pSet = pContentNode->GetpSwAttrSet();
1517 }
1518 else if ( auto pSwFormat = dynamic_cast< const SwFormat *>( GetRegisteredIn() ) )
1519 {
1520 pSet = &pSwFormat->GetAttrSet();
1521 }
1522 if( pSet && pSet->Count() )
1523 {
1524 SfxItemIter aIter( *pSet );
1525 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1526 {
1527 sal_uInt16 nW = pItem->Which();
1528 m_WhichIdSet.insert( nW );
1529 }
1530 }
1531}
1532/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
virtual SwFieldType * InsertFieldType(const SwFieldType &)=0
virtual const SwRootFrame * GetCurrentLayout() const =0
Provides access to the marks of a document.
virtual sw::mark::IFieldmark * makeNoTextFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType)=0
virtual sw::mark::IFieldmark * makeFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType, SwPosition const *pSepPos=nullptr)=0
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
virtual ::sw::mark::IMark * makeMark(const SwPaM &rPaM, const OUString &rProposedName, MarkType eMark, ::sw::mark::InsertMode eMode, SwPosition const *pSepPos=nullptr)=0
Generates a new mark in the document for a certain selection.
virtual std::unique_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark, bool isMoveNodes)=0
Deletes a mark.
virtual void deleteFieldmarkAt(const SwPosition &rPos)=0
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:502
SfxHintId GetId() const
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
sal_uInt16 Count() const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 Which() const
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
SvxBreak GetBreak() const
Represents the style of a text portion.
Definition: charfmt.hxx:27
bool ContainsFormat(const SwCharFormat *pFormat) const
fast check if given format is contained here @precond pFormat must not have been deleted
Definition: chrfmt.cxx:127
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:166
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1223
virtual SwFormatColl * ChgFormatColl(SwFormatColl *)
Definition: node.cxx:1258
Definition: doc.hxx:197
const SwTOXType * InsertTOXType(const SwTOXType &rTyp)
Definition: doctxm.cxx:630
::sw::IShellCursorSupplier * GetIShellCursorSupplier()
Definition: doccorr.cxx:353
sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const
Manage table of content types.
Definition: doctxm.cxx:612
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: doc.hxx:786
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:755
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:158
SwNodes & GetNodes()
Definition: doc.hxx:422
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:371
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:419
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:793
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1890
const SwGrfFormatColls * GetGrfFormatColls() const
Definition: doc.hxx:821
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1337
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
Definition: doctxm.cxx:621
const sw::FrameFormats< sw::SpzFrameFormat * > * GetSpzFrameFormats() const
Definition: doc.hxx:759
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
FlyAnchors.
Definition: fmtanchr.hxx:37
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1593
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:32
SwFlyFrameFormat * GetPrev() const
Definition: fmtcnct.hxx:53
void SetNext(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2179
void SetPrev(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2171
SwFlyFrameFormat * GetNext() const
Definition: fmtcnct.hxx:54
SwCharFormat * GetCharFormat() const
Definition: fchrfmt.hxx:70
SwFormatColl is just an SwFormat subclass that defaults to m_bAutoFormat=false, expressing that this ...
Definition: fmtcol.hxx:38
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps.
Definition: paratr.hxx:72
void ChgDefinedIn(const sw::FormatDropDefiner *pDefiner)
Get and set Modify pointer.
Definition: paratr.hxx:129
SfxPoolItem subclass for footnotes and endnotes, stored in the anchor text node.
Definition: fmtftn.hxx:47
void SetEndNote(bool b)
Definition: atrftn.cxx:175
bool IsEndNote() const
Definition: fmtftn.hxx:75
void SetNumStr(const OUString &rStr)
Definition: fmtftn.hxx:77
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:36
void ChgDefinedIn(const sw::BroadcastingModify *pNew)
Definition: fmtpdsc.hxx:69
Base class for various Writer styles.
Definition: format.hxx:47
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:618
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
const OUString & GetName() const
Definition: format.hxx:131
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
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
Style of a layout element.
Definition: frmfmt.hxx:72
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2733
const bool m_bSaveOtherPos
Definition: rolbck.hxx:267
SwHistoryBookmark(const ::sw::mark::IMark &rBkmk, bool bSavePos, bool bSaveOtherPos)
Definition: rolbck.cxx:605
const SwNodeOffset m_nNode
Definition: rolbck.hxx:262
OUString m_aHideCondition
Definition: rolbck.hxx:260
const bool m_bHadOtherPos
Definition: rolbck.hxx:268
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo
Definition: rolbck.hxx:270
const sal_Int32 m_nOtherContent
Definition: rolbck.hxx:265
const OUString m_aName
Definition: rolbck.hxx:257
vcl::KeyCode m_aKeycode
Definition: rolbck.hxx:261
virtual void SetInDoc(SwDoc *pDoc, bool) override
Definition: rolbck.cxx:642
const bool m_bSavePos
Definition: rolbck.hxx:266
bool IsEqualBookmark(const ::sw::mark::IMark &rBkmk)
Definition: rolbck.cxx:722
const SwNodeOffset m_nOtherNode
Definition: rolbck.hxx:263
const IDocumentMarkAccess::MarkType m_eBkmkType
Definition: rolbck.hxx:269
OUString m_aShortName
Definition: rolbck.hxx:258
const sal_Int32 m_nContent
Definition: rolbck.hxx:264
SwHistoryChangeCharFormat(SfxItemSet aSet, OUString sFormat)
Definition: rolbck.cxx:1002
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:1009
const SfxItemSet m_OldSet
Definition: rolbck.hxx:345
const OUString m_Format
Definition: rolbck.hxx:346
const sal_Int32 m_nOldContentIndex
Definition: rolbck.hxx:325
sw::SpzFrameFormat & m_rFormat
Definition: rolbck.hxx:323
const SwNodeOffset m_nOldNodeIndex
Definition: rolbck.hxx:324
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:934
SwHistoryChangeFlyAnchor(sw::SpzFrameFormat &rFormat)
Definition: rolbck.cxx:924
SwHistoryChangeFlyChain(SwFlyFrameFormat &rFormat, const SwFormatChain &rAttr)
Definition: rolbck.cxx:961
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:970
SwFlyFrameFormat *const m_pPrevFormat
Definition: rolbck.hxx:334
SwFlyFrameFormat *const m_pFlyFormat
Definition: rolbck.hxx:336
SwFlyFrameFormat *const m_pNextFormat
Definition: rolbck.hxx:335
const SwNodeType m_nNodeType
Definition: rolbck.hxx:225
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:224
SwFormatColl *const m_pColl
Definition: rolbck.hxx:223
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:549
SwHistoryChangeFormatColl(SwFormatColl *pColl, SwNodeOffset nNode, SwNodeType nNodeWhich)
Definition: rolbck.cxx:540
const HISTORY_HINT m_eWhichId
Definition: rolbck.hxx:83
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: rolbck.cxx:68
virtual OUString GetDescription() const
Definition: rolbck.cxx:63
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet)=0
History object containing all information used during undo / redo of checkbox and drop-down form fiel...
Definition: rolbck.hxx:276
virtual void SetInDoc(SwDoc *pDoc, bool) override
Definition: rolbck.cxx:737
const OUString m_sType
Definition: rolbck.hxx:283
void ResetInDoc(SwDoc &rDoc)
Definition: rolbck.cxx:755
const SwNodeOffset m_nNode
Definition: rolbck.hxx:284
SwHistoryNoTextFieldmark(const ::sw::mark::IFieldmark &rFieldMark)
Definition: rolbck.cxx:729
const sal_Int32 m_nContent
Definition: rolbck.hxx:285
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:110
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:208
const sal_uInt16 m_nWhich
Definition: rolbck.hxx:111
SwHistoryResetFormat(const SfxPoolItem *pFormatHt, SwNodeOffset nNodeIdx)
Definition: rolbck.cxx:201
const sal_Int32 m_nEnd
Definition: rolbck.hxx:189
SwHistoryResetText(sal_uInt16 nWhich, sal_Int32 nStt, sal_Int32 nEnd, SwNodeOffset nNode)
Definition: rolbck.cxx:430
const sal_uInt16 m_nAttr
Definition: rolbck.hxx:190
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:187
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:438
const sal_Int32 m_nStart
Definition: rolbck.hxx:188
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:312
std::vector< sal_uInt16 > m_ResetArray
Definition: rolbck.hxx:311
SwHistorySetAttrSet(const SfxItemSet &rSet, SwNodeOffset nNode, const o3tl::sorted_vector< sal_uInt16 > &rSetArr)
Definition: rolbck.cxx:829
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:899
SfxItemSet m_OldSet
Definition: rolbck.hxx:310
virtual OUString GetDescription() const override
Definition: rolbck.cxx:484
const sal_Int32 m_nStart
Definition: rolbck.hxx:208
const std::unique_ptr< SwUndoSaveSection, o3tl::default_delete< SwUndoSaveSection > > m_pUndo
Definition: rolbck.hxx:205
SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:207
virtual ~SwHistorySetFootnote() override
Definition: rolbck.cxx:489
const bool m_bEndNote
Definition: rolbck.hxx:209
const OUString m_FootnoteNumber
Definition: rolbck.hxx:206
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:493
SwHistorySetFootnote(SwTextFootnote *pTextFootnote, SwNodeOffset nNode)
Definition: rolbck.cxx:448
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:97
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: rolbck.cxx:150
virtual ~SwHistorySetFormat() override
Definition: rolbck.cxx:197
virtual OUString GetDescription() const override
Definition: rolbck.cxx:118
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:165
std::unique_ptr< SfxPoolItem > m_pAttr
Definition: rolbck.hxx:96
SwHistorySetFormat(const SfxPoolItem *pFormatHt, SwNodeOffset nNode)
Definition: rolbck.cxx:78
const sal_Int32 m_nEnd
Definition: rolbck.hxx:160
SwHistorySetRefMark(const SwTextRefMark *pTextHt, SwNodeOffset nNode)
Definition: rolbck.cxx:341
const OUString m_RefName
Definition: rolbck.hxx:157
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:350
const sal_Int32 m_nStart
Definition: rolbck.hxx:159
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:158
const TOXTypes m_eTOXTypes
Definition: rolbck.hxx:172
bool IsEqual(const SwTOXMark &rCmp) const
Definition: rolbck.cxx:418
static SwTOXType * GetSwTOXType(SwDoc &rDoc, TOXTypes eTOXTypes, const OUString &rTOXName)
Definition: rolbck.cxx:380
const sal_Int32 m_nEnd
Definition: rolbck.hxx:175
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:402
const sal_Int32 m_nStart
Definition: rolbck.hxx:174
SwTOXMark m_TOXMark
Definition: rolbck.hxx:170
SwHistorySetTOXMark(const SwTextTOXMark *pTextHt, SwNodeOffset nNode)
Definition: rolbck.cxx:368
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:173
const OUString m_TOXName
Definition: rolbck.hxx:171
SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:142
SwFieldIds m_nFieldWhich
Definition: rolbck.hxx:144
virtual ~SwHistorySetTextField() override
Definition: rolbck.cxx:309
virtual OUString GetDescription() const override
Definition: rolbck.cxx:304
const std::unique_ptr< SwFormatField > m_pField
Definition: rolbck.hxx:140
std::unique_ptr< SwFieldType > m_pFieldType
! beware of the order for the declaration of the unique_ptrs.
Definition: rolbck.hxx:139
SwHistorySetTextField(const SwTextField *pTextField, SwNodeOffset nNode)
Definition: rolbck.cxx:283
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:313
std::unique_ptr< SfxPoolItem > m_pAttr
Definition: rolbck.hxx:121
const sal_Int32 m_nEnd
Definition: rolbck.hxx:124
bool m_bFormatIgnoreEnd
Definition: rolbck.hxx:126
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:122
virtual ~SwHistorySetText() override
Definition: rolbck.cxx:246
SwHistorySetText(SwTextAttr *pTextHt, SwNodeOffset nNode)
Definition: rolbck.cxx:222
const sal_Int32 m_nStart
Definition: rolbck.hxx:123
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:250
bool m_bFormatIgnoreStart
Definition: rolbck.hxx:125
History object containing all information used during undo / redo of text form field insertion.
Definition: rolbck.hxx:291
const sal_Int32 m_nStartContent
Definition: rolbck.hxx:301
const sal_Int32 m_nEndContent
Definition: rolbck.hxx:303
const OUString m_sType
Definition: rolbck.hxx:299
const SwNodeOffset m_nStartNode
Definition: rolbck.hxx:300
virtual void SetInDoc(SwDoc *pDoc, bool) override
Definition: rolbck.cxx:787
sal_Int32 m_nSepContent
Definition: rolbck.hxx:305
const SwNodeOffset m_nEndNode
Definition: rolbck.hxx:302
SwHistoryTextFieldmark(const ::sw::mark::IFieldmark &rFieldMark)
Definition: rolbck.cxx:773
void ResetInDoc(SwDoc &rDoc)
Definition: rolbck.cxx:813
SwNodeOffset m_nSepNode
Definition: rolbck.hxx:304
const OUString m_sName
Definition: rolbck.hxx:298
SwHistoryTextFlyCnt(SwFrameFormat *const pFlyFormat)
Definition: rolbck.cxx:572
virtual ~SwHistoryTextFlyCnt() override
Definition: rolbck.cxx:580
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:584
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: rolbck.cxx:592
std::unique_ptr< SwUndoDelLayFormat > m_pUndo
Definition: rolbck.hxx:235
void CopyFormatAttr(const SfxItemSet &rSet, SwNodeOffset nNodeIdx)
Definition: rolbck.cxx:1263
void CopyAttr(SwpHints const *pHts, const SwNodeOffset nNodeIdx, const sal_Int32 nStart, const sal_Int32 nEnd, const bool bCopyFields)
Definition: rolbck.cxx:1299
sal_uInt16 Count() const
Definition: rolbck.hxx:381
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: rolbck.cxx:1284
void AddDeleteFly(SwFrameFormat &, sal_uInt16 &rSetPos)
Definition: rolbck.cxx:1150
std::vector< std::unique_ptr< SwHistoryHint > > m_SwpHstry
Definition: rolbck.hxx:359
sal_uInt16 SetTmpEnd(sal_uInt16 nTmpEnd)
Definition: rolbck.cxx:1242
void Add(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, SwNodeOffset nNodeIdx)
Definition: rolbck.cxx:1029
~SwHistory()
Definition: rolbck.cxx:1025
sal_uInt16 m_nEndDiff
Definition: rolbck.hxx:360
bool TmpRollback(SwDoc *pDoc, sal_uInt16 nStart, bool ToFirst=true)
Definition: rolbck.cxx:1217
void AddChangeFlyAnchor(sw::SpzFrameFormat &rFormat)
Definition: rolbck.cxx:1144
bool Rollback(SwDoc *pDoc, sal_uInt16 nStart=0)
Definition: rolbck.cxx:1202
Marks a node in the document model.
Definition: ndindex.hxx:31
Base class of the Writer document model elements.
Definition: node.hxx:98
SwNodeOffset GetIndex() const
Definition: node.hxx:312
bool IsContentNode() const
Definition: node.hxx:188
SwDoc & GetDoc()
Definition: node.hxx:233
bool IsStartNode() const
Definition: node.hxx:187
bool IsTableNode() const
Definition: node.hxx:191
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:380
SwContentNode * GetContentNode()
Definition: node.hxx:666
SwNodeType GetNodeType() const
Definition: node.hxx:166
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: rolbck.cxx:1380
SwRegHistory(SwHistory *pHst)
Definition: rolbck.cxx:1355
SwHistory *const m_pHistory
Definition: rolbck.hxx:418
o3tl::sorted_vector< sal_uInt16 > m_WhichIdSet
Definition: rolbck.hxx:417
void MakeSetWhichIds()
Definition: rolbck.cxx:1504
SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:419
bool InsertItems(const SfxItemSet &rSet, sal_Int32 const nStart, sal_Int32 const nEnd, SetAttrMode const nFlags, SwTextAttr **ppNewTextAttr)
Definition: rolbck.cxx:1430
void AddHint(SwTextAttr *pHt, const bool bNew)
Definition: rolbck.cxx:1425
void RegisterInModify(sw::BroadcastingModify *pRegIn, const SwNode &rNd)
Definition: rolbck.cxx:1490
Starts a section of nodes in the document model.
Definition: node.hxx:348
void RegisterToTOXType(SwTOXType &rMark)
Definition: tox.cxx:141
const SwTOXType * GetTOXType() const
Definition: tox.hxx:576
sal_uInt16 GetLevel() const
Definition: tox.hxx:628
const OUString & GetAlternativeText() const
Definition: tox.hxx:570
OUString const & GetSecondaryKey() const
Definition: tox.hxx:640
OUString const & GetPrimaryKey() const
Definition: tox.hxx:634
const OUString & GetTypeName() const
Definition: tox.hxx:690
TOXTypes GetType() const
Definition: tox.hxx:693
virtual const SwNode * GetNodeOfFormula() const override
Get node type of the node containing this formula.
Definition: cellatr.cxx:85
void ChgDefinedIn(const sw::BroadcastingModify *pNew)
Definition: cellatr.hxx:68
const sw::BroadcastingModify * GetDefinedIn() const
Definition: cellatr.hxx:67
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:443
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:2094
bool IsIntrnlName() const
Definition: cellfml.hxx:131
void ToRelBoxNm(const SwTable *pTable)
create from the external/internal formula the relative formula
Definition: cellfml.cxx:630
void PtrToBoxNm(const SwTable *pTable)
create from the internal formula (for CORE) the external formula (for UI)
Definition: cellfml.cxx:580
const SwTable & GetTable() const
Definition: node.hxx:542
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
void SwitchFormulasToExternalRepresentation()
Definition: swtable.hxx:362
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
Definition: swtable.cxx:1344
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:167
void SetFormatIgnoreStart(bool bFlag)
Definition: txatbase.hxx:110
sal_Int32 GetAnyEnd() const
end (if available), else start
Definition: txatbase.hxx:161
virtual const sal_Int32 * GetEnd() const
end position
Definition: txatbase.cxx:48
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:208
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
const SwFormatCharFormat & GetCharFormat() const
Definition: txatbase.hxx:187
void SetFormatIgnoreEnd(bool bFlag)
Definition: txatbase.hxx:111
sal_uInt16 Which() const
Definition: txatbase.hxx:116
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
SwTextAttr subclass for footnotes and endnotes.
Definition: txtftn.hxx:34
void CheckCondColl()
Definition: atrftn.cxx:579
const SwNodeIndex * GetStartNode() const
Definition: txtftn.hxx:43
const SwTextNode & GetTextNode() const
Definition: txtftn.hxx:72
void SetStartNode(const SwNodeIndex *pNode, bool bDelNodes=true)
Definition: atrftn.cxx:309
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
void DeleteAttributes(const sal_uInt16 nWhich, const sal_Int32 nStart, const sal_Int32 nEnd=0)
delete all attributes of type nWhich at nStart (opt. end nEnd)
Definition: thints.cxx:1801
SwpHints & GetOrCreateSwpHints()
Definition: ndtxt.hxx:878
SwTextAttr * InsertItem(SfxPoolItem &rAttr, const sal_Int32 nStart, const sal_Int32 nEnd, const SetAttrMode nMode=SetAttrMode::DEFAULT)
create new text attribute from rAttr and insert it
Definition: thints.cxx:1305
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
Definition: ndtxt.cxx:5066
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:252
bool InsertHint(SwTextAttr *const pAttr, const SetAttrMode nMode=SetAttrMode::DEFAULT)
Insert pAttr into hints array.
Definition: thints.cxx:1340
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
Definition: ndtxt.cxx:3155
bool IsAlive(typename std::remove_pointer< Value >::type const *const p) const
check that given format is still alive (i.e. contained here)
Definition: docary.hxx:141
An SwTextAttr container, stores all directly formatted text portions for a text node.
Definition: ndhints.hxx:68
void DeRegister()
deregister the currently registered History
Definition: ndhints.hxx:197
SwTextAttr * Get(size_t nPos) const
Definition: ndhints.hxx:144
void Register(SwRegHistory *pHist)
register a History, which receives all attribute changes (for Undo)
Definition: ndhints.hxx:195
size_t Count() const
Definition: ndhints.hxx:142
size_type count(const Value &v) const
std::pair< const_iterator, bool > insert(Value &&x)
The Undo actions need to create new Shell cursors.
virtual void Hide(bool hide)=0
virtual void SetHideCondition(const OUString &)=0
virtual void SetShortName(const OUString &)=0
virtual void SetKeyCode(const vcl::KeyCode &)=0
virtual const SwPosition & GetOtherMarkPos() const =0
virtual bool IsExpanded() const =0
virtual const SwPosition & GetMarkPos() const =0
struct _xmlTextWriter * xmlTextWriterPtr
virtual OUString GetName() const override
OUString m_sName
@ Database
For old documents the Field-Which IDs must be preserved !!!
static SwContentNode * GetContentNode(SwDoc &rDoc, SwPosition &rPos, bool bNext)
Definition: fltshell.cxx:54
#define SwTextFootnote_GetIndex(pFIdx)
Definition: ftnidx.hxx:35
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(59)
bool isCHRATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:468
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(158)
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SwTableBoxFormula > RES_BOXATR_FORMULA(157)
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(169)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(60)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(162)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(165)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SwFormatDrop > RES_PARATR_DROP(70)
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(120)
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_TXTATR_UNKNOWN_CONTAINER(54)
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
constexpr TypedWhichId< SwUpdateAttr > RES_UPDATE_ATTR(170)
constexpr TypedWhichId< SwTOXMark > RES_TXTATR_TOXMARK(47)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
constexpr sal_uInt16 POOLATTR_END(RES_UNKNOWNATR_END)
sal_Int64 n
int i
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
SwPosition FindFieldSep(IFieldmark const &rMark)
return position of the CH_TXT_ATR_FIELDSEP for rMark
@ SwTableBoxStartNode
Definition: ndtyp.hxx:53
@ SwFootnoteStartNode
Definition: ndtyp.hxx:55
SwNodeType
Definition: ndtyp.hxx:28
constexpr SwNodeOffset NODE_OFFSET_MAX(SAL_MAX_INT32)
OUString m_aName
bool IsDefaultItem(const SfxPoolItem *pItem)
bool IsInvalidItem(const SfxPoolItem *pItem)
@ HSTRY_CHGFLYANCHOR
Definition: rolbck.hxx:74
@ HSTRY_BOOKMARK
Definition: rolbck.hxx:72
@ HSTRY_SETFTNHNT
Definition: rolbck.hxx:69
@ HSTRY_SETTOXMARKHNT
Definition: rolbck.hxx:67
@ HSTRY_CHGFLYCHAIN
Definition: rolbck.hxx:75
@ HSTRY_CHGFMTCOLL
Definition: rolbck.hxx:70
@ HSTRY_NOTEXTFIELDMARK
Definition: rolbck.hxx:77
@ HSTRY_SETTXTHNT
Definition: rolbck.hxx:64
@ HSTRY_RESETTXTHNT
Definition: rolbck.hxx:68
@ HSTRY_SETFMTHNT
Definition: rolbck.hxx:62
@ HSTRY_SETTXTFLDHNT
Definition: rolbck.hxx:65
@ HSTRY_SETREFMARKHNT
Definition: rolbck.hxx:66
@ HSTRY_RESETFMTHNT
Definition: rolbck.hxx:63
@ HSTRY_FLYCNT
Definition: rolbck.hxx:71
@ HSTRY_CHGCHARFMT
Definition: rolbck.hxx:76
@ HSTRY_SETATTRSET
Definition: rolbck.hxx:73
@ HSTRY_TEXTFIELDMARK
Definition: rolbck.hxx:78
static SfxItemSet & rSet
Marks a position in the document model.
Definition: pam.hxx:38
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
Definition: pam.cxx:267
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:78
sal_Int32 GetContentIndex() const
Definition: pam.hxx:85
RndStdIds
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
SetAttrMode
Definition: swtypes.hxx:133
@ NOHINTADJUST
attention: NOHINTADJUST prevents MergePortions! when using this need to pay attention to ignore start...
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:57
TOXTypes
Definition: toxe.hxx:40
@ TOX_INDEX
Definition: toxe.hxx:41
size_t pos