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 SwTableFormulaUpdate aMsgHint( &pTableNode->GetTable() );
106 aMsgHint.m_eFlags = TBL_BOXNAME;
107 rNew.ChgDefinedIn( rOld.GetDefinedIn() );
108 rNew.ChangeState( &aMsgHint );
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 {
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 SwTableFormulaUpdate aMsgHint(
882 &pTableNode->GetTable() );
883 aMsgHint.m_eFlags = TBL_BOXNAME;
884 rNew.ChgDefinedIn( rOld.GetDefinedIn() );
885 rNew.ChangeState( &aMsgHint );
886 }
887 }
888 }
889 rNew.ChgDefinedIn( nullptr );
890 }
891 break;
892 }
893 }
894
895 pItem = aIter.NextItem();
896 pOrigItem = aOrigIter.NextItem();
897 }
898}
899
901{
902 ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
903
904 SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ];
905 if ( pNode->IsContentNode() )
906 {
907 static_cast<SwContentNode*>(pNode)->SetAttr( m_OldSet );
908 if ( !m_ResetArray.empty() )
909 {
910 static_cast<SwContentNode*>(pNode)->ResetAttr( m_ResetArray );
911 }
912 }
913 else if ( pNode->IsTableNode() )
914 {
915 SwFormat& rFormat =
916 *static_cast<SwTableNode*>(pNode)->GetTable().GetFrameFormat();
917 rFormat.SetFormatAttr( m_OldSet );
918 if ( !m_ResetArray.empty() )
919 {
920 rFormat.ResetFormatAttr( m_ResetArray.front() );
921 }
922 }
923}
924
927 , m_rFormat( rFormat )
928 , m_nOldNodeIndex( rFormat.GetAnchor().GetContentAnchor()->GetNodeIndex() )
929 , m_nOldContentIndex( (RndStdIds::FLY_AT_CHAR == rFormat.GetAnchor().GetAnchorId())
930 ? rFormat.GetAnchor().GetContentAnchor()->GetContentIndex()
932{
933}
934
936{
937 ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
938
939 if (!pDoc->GetSpzFrameFormats()->IsAlive(&m_rFormat)) // Format does still exist
940 return;
941
943
944 SwNode* pNd = pDoc->GetNodes()[ m_nOldNodeIndex ];
945 SwContentNode* pCNd = pNd->GetContentNode();
946 SwPosition aPos( *pNd );
948 {
949 OSL_ENSURE(pCNd, "SwHistoryChangeFlyAnchor: no ContentNode");
950 if (pCNd)
951 {
952 aPos.nContent.Assign( pCNd, m_nOldContentIndex );
953 }
954 }
955 aTmp.SetAnchor( &aPos );
956
957 // so the Layout does not get confused
958 if (!pCNd || !pCNd->getLayoutFrame(pDoc->getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, nullptr))
959 {
961 }
962
963 m_rFormat.SetFormatAttr( aTmp );
964}
965
967 const SwFormatChain& rAttr )
969 , m_pPrevFormat( rAttr.GetPrev() )
970 , m_pNextFormat( rAttr.GetNext() )
971 , m_pFlyFormat( &rFormat )
972{
973}
974
976{
978 return;
979
980 SwFormatChain aChain;
981
982 if (m_pPrevFormat &&
984 {
985 aChain.SetPrev( m_pPrevFormat );
987 aTmp.SetNext( m_pFlyFormat );
989 }
990
991 if (m_pNextFormat &&
993 {
994 aChain.SetNext( m_pNextFormat );
996 aTmp.SetPrev( m_pFlyFormat );
998 }
999
1000 if ( aChain.GetNext() || aChain.GetPrev() )
1001 {
1002 m_pFlyFormat->SetFormatAttr( aChain );
1003 }
1004}
1005
1006// -> #i27615#
1008 OUString sFormat)
1010 , m_OldSet(std::move(aSet)), m_Format(std::move(sFormat))
1011{
1012}
1013
1015{
1016 SwCharFormat * pCharFormat = pDoc->FindCharFormatByName(m_Format);
1017
1018 if (pCharFormat)
1019 {
1020 pCharFormat->SetFormatAttr(m_OldSet);
1021 }
1022}
1023// <- #i27615#
1024
1026 : m_nEndDiff( 0 )
1027{
1028}
1029
1031{
1032}
1033
1035 const SfxPoolItem* pOldValue,
1036 const SfxPoolItem* pNewValue,
1037 SwNodeOffset nNodeIdx)
1038{
1039 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1040 const sal_uInt16 nWhich(pNewValue->Which());
1041
1042 // excluded values
1043 if(nWhich == RES_TXTATR_FIELD || nWhich == RES_TXTATR_ANNOTATION)
1044 {
1045 return;
1046 }
1047
1048 // no default Attribute?
1049 std::unique_ptr<SwHistoryHint> pHt;
1050
1051 // To be able to include the DrawingLayer FillItems something more
1052 // general has to be done to check if an Item is default than to check
1053 // if its pointer equals that in Writer's global PoolDefaults (held in
1054 // aAttrTab and used to fill the pool defaults in Writer - looks as if
1055 // Writer is *older* than the SfxItemPool ?). I checked the possibility to
1056 // get the SfxItemPool here (works), but decided to use the SfxPoolItem's
1057 // global tooling aka IsDefaultItem(const SfxPoolItem*) for now
1058 if(pOldValue && !IsDefaultItem(pOldValue))
1059 {
1060 pHt.reset( new SwHistorySetFormat( pOldValue, nNodeIdx ) );
1061 }
1062 else
1063 {
1064 pHt.reset( new SwHistoryResetFormat( pNewValue, nNodeIdx ) );
1065 }
1066
1067 m_SwpHstry.push_back( std::move(pHt) );
1068}
1069
1070// FIXME: refactor the following "Add" methods (DRY)?
1071void SwHistory::Add( SwTextAttr* pHint, SwNodeOffset nNodeIdx, bool bNewAttr )
1072{
1073 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1074
1075 std::unique_ptr<SwHistoryHint> pHt;
1076 if( !bNewAttr )
1077 {
1078 switch ( pHint->Which() )
1079 {
1080 case RES_TXTATR_FTN:
1081 pHt.reset( new SwHistorySetFootnote(
1082 static_cast<SwTextFootnote*>(pHint), nNodeIdx ) );
1083 break;
1084 case RES_TXTATR_FLYCNT:
1085 pHt.reset( new SwHistoryTextFlyCnt( static_cast<SwTextFlyCnt*>(pHint)
1086 ->GetFlyCnt().GetFrameFormat() ) );
1087 break;
1088 case RES_TXTATR_FIELD:
1090 pHt.reset( new SwHistorySetTextField(
1091 static_txtattr_cast<SwTextField*>(pHint), nNodeIdx) );
1092 break;
1093 case RES_TXTATR_TOXMARK:
1094 pHt.reset( new SwHistorySetTOXMark(
1095 static_txtattr_cast<SwTextTOXMark*>(pHint), nNodeIdx) );
1096 break;
1097 case RES_TXTATR_REFMARK:
1098 pHt.reset( new SwHistorySetRefMark(
1099 static_txtattr_cast<SwTextRefMark*>(pHint), nNodeIdx) );
1100 break;
1101 default:
1102 pHt.reset( new SwHistorySetText( pHint, nNodeIdx ) );
1103 }
1104 }
1105 else
1106 {
1107 pHt.reset( new SwHistoryResetText( pHint->Which(), pHint->GetStart(),
1108 pHint->GetAnyEnd(), nNodeIdx ) );
1109 }
1110 m_SwpHstry.push_back( std::move(pHt) );
1111}
1112
1113void SwHistory::Add( SwFormatColl* pColl, SwNodeOffset nNodeIdx, SwNodeType nWhichNd )
1114{
1115 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1116
1117 std::unique_ptr<SwHistoryHint> pHt(
1118 new SwHistoryChangeFormatColl( pColl, nNodeIdx, nWhichNd ));
1119 m_SwpHstry.push_back( std::move(pHt) );
1120}
1121
1122void SwHistory::Add(const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOtherPos)
1123{
1124 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1125
1126 std::unique_ptr<SwHistoryHint> pHt;
1127
1128 switch (IDocumentMarkAccess::GetType(rBkmk))
1129 {
1132 assert(bSavePos && bSaveOtherPos); // must be deleted completely!
1133 pHt.reset(new SwHistoryTextFieldmark(dynamic_cast<sw::mark::IFieldmark const&>(rBkmk)));
1134 break;
1137 assert(bSavePos && bSaveOtherPos); // must be deleted completely!
1138 pHt.reset(new SwHistoryNoTextFieldmark(dynamic_cast<sw::mark::IFieldmark const&>(rBkmk)));
1139 break;
1140 default:
1141 pHt.reset(new SwHistoryBookmark(rBkmk, bSavePos, bSaveOtherPos));
1142 break;
1143 }
1144
1145 assert(pHt);
1146 m_SwpHstry.push_back( std::move(pHt) );
1147}
1148
1150{
1151 std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeFlyAnchor( rFormat ));
1152 m_SwpHstry.push_back( std::move(pHt) );
1153}
1154
1155void SwHistory::AddDeleteFly(SwFrameFormat& rFormat, sal_uInt16& rSetPos)
1156{
1157 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1158
1159 const sal_uInt16 nWh = rFormat.Which();
1160 (void) nWh;
1161 // only Flys!
1162 assert((RES_FLYFRMFMT == nWh && dynamic_cast<SwFlyFrameFormat*>(&rFormat))
1163 || (RES_DRAWFRMFMT == nWh && dynamic_cast<SwDrawFrameFormat*>(&rFormat)));
1164 {
1165 std::unique_ptr<SwHistoryHint> pHint(new SwHistoryTextFlyCnt( &rFormat ));
1166 m_SwpHstry.push_back( std::move(pHint) );
1167
1168 if( const SwFormatChain* pChainItem = rFormat.GetItemIfSet( RES_CHAIN, false ) )
1169 {
1170 assert(RES_FLYFRMFMT == nWh); // not supported on SdrObjects
1171 if( pChainItem->GetNext() || pChainItem->GetPrev() )
1172 {
1173 std::unique_ptr<SwHistoryHint> pHt(
1174 new SwHistoryChangeFlyChain(static_cast<SwFlyFrameFormat&>(rFormat), *pChainItem));
1175 m_SwpHstry.insert( m_SwpHstry.begin() + rSetPos++, std::move(pHt) );
1176 if ( pChainItem->GetNext() )
1177 {
1178 SwFormatChain aTmp( pChainItem->GetNext()->GetChain() );
1179 aTmp.SetPrev( nullptr );
1180 pChainItem->GetNext()->SetFormatAttr( aTmp );
1181 }
1182 if ( pChainItem->GetPrev() )
1183 {
1184 SwFormatChain aTmp( pChainItem->GetPrev()->GetChain() );
1185 aTmp.SetNext( nullptr );
1186 pChainItem->GetPrev()->SetFormatAttr( aTmp );
1187 }
1188 }
1189 rFormat.ResetFormatAttr( RES_CHAIN );
1190 }
1191 }
1192}
1193
1194void SwHistory::Add( const SwTextFootnote& rFootnote )
1195{
1196 std::unique_ptr<SwHistoryHint> pHt(new SwHistorySetFootnote( rFootnote ));
1197 m_SwpHstry.push_back( std::move(pHt) );
1198}
1199
1200// #i27615#
1201void SwHistory::Add(const SfxItemSet & rSet, const SwCharFormat & rFormat)
1202{
1203 std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeCharFormat(rSet, rFormat.GetName()));
1204 m_SwpHstry.push_back( std::move(pHt) );
1205}
1206
1207bool SwHistory::Rollback( SwDoc* pDoc, sal_uInt16 nStart )
1208{
1209 if ( !Count() )
1210 return false;
1211
1212 for ( sal_uInt16 i = Count(); i > nStart ; )
1213 {
1214 SwHistoryHint * pHHt = m_SwpHstry[ --i ].get();
1215 pHHt->SetInDoc( pDoc, false );
1216 }
1217 m_SwpHstry.erase( m_SwpHstry.begin() + nStart, m_SwpHstry.end() );
1218 m_nEndDiff = 0;
1219 return true;
1220}
1221
1222bool SwHistory::TmpRollback( SwDoc* pDoc, sal_uInt16 nStart, bool bToFirst )
1223{
1224 sal_uInt16 nEnd = Count() - m_nEndDiff;
1225 if ( !Count() || !nEnd || nStart >= nEnd )
1226 return false;
1227
1228 if ( bToFirst )
1229 {
1230 for ( ; nEnd > nStart; ++m_nEndDiff )
1231 {
1232 SwHistoryHint* pHHt = m_SwpHstry[ --nEnd ].get();
1233 pHHt->SetInDoc( pDoc, true );
1234 }
1235 }
1236 else
1237 {
1238 for ( ; nStart < nEnd; ++m_nEndDiff, ++nStart )
1239 {
1240 SwHistoryHint* pHHt = m_SwpHstry[ nStart ].get();
1241 pHHt->SetInDoc( pDoc, true );
1242 }
1243 }
1244 return true;
1245}
1246
1247sal_uInt16 SwHistory::SetTmpEnd( sal_uInt16 nNewTmpEnd )
1248{
1249 OSL_ENSURE( nNewTmpEnd <= Count(), "SwHistory::SetTmpEnd: out of bounds" );
1250
1251 const sal_uInt16 nOld = Count() - m_nEndDiff;
1252 m_nEndDiff = Count() - nNewTmpEnd;
1253
1254 // for every SwHistoryFlyCnt, call the Redo of its UndoObject.
1255 // this saves the formats of the flys!
1256 for ( sal_uInt16 n = nOld; n < nNewTmpEnd; n++ )
1257 {
1258 if ( HSTRY_FLYCNT == (*this)[ n ]->Which() )
1259 {
1260 static_cast<SwHistoryTextFlyCnt*>((*this)[ n ])
1261 ->GetUDelLFormat()->RedoForRollback();
1262 }
1263 }
1264
1265 return nOld;
1266}
1267
1269 const SfxItemSet& rSet,
1270 SwNodeOffset nNodeIdx)
1271{
1272 if(!rSet.Count())
1273 return;
1274
1275 SfxItemIter aIter(rSet);
1276 const SfxPoolItem* pItem = aIter.GetCurItem();
1277 do
1278 {
1279 if(!IsInvalidItem(pItem))
1280 {
1281 Add(pItem, pItem, nNodeIdx);
1282 }
1283
1284 pItem = aIter.NextItem();
1285
1286 } while(pItem);
1287}
1288
1290{
1291 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHistory"));
1292 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1293
1294 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_SwpHstry"));
1295 for (const auto& pHistory : m_SwpHstry)
1296 {
1297 pHistory->dumpAsXml(pWriter);
1298 }
1299 (void)xmlTextWriterEndElement(pWriter);
1300
1301 (void)xmlTextWriterEndElement(pWriter);
1302}
1303
1305 SwpHints const * pHts,
1306 const SwNodeOffset nNodeIdx,
1307 const sal_Int32 nStart,
1308 const sal_Int32 nEnd,
1309 const bool bCopyFields )
1310{
1311 if( !pHts )
1312 return;
1313
1314 // copy all attributes of the TextNode in the area from nStart to nEnd
1315 SwTextAttr* pHt;
1316 for( size_t n = 0; n < pHts->Count(); ++n )
1317 {
1318 // nAttrStt must even be set when !pEndIdx
1319 pHt = pHts->Get(n);
1320 const sal_Int32 nAttrStt = pHt->GetStart();
1321 const sal_Int32 * pEndIdx = pHt->GetEnd();
1322 if( nullptr != pEndIdx && nAttrStt > nEnd )
1323 break;
1324
1325 // never copy Flys and Footnote !!
1326 bool bNextAttr = false;
1327 switch( pHt->Which() )
1328 {
1329 case RES_TXTATR_FIELD:
1332 if( !bCopyFields )
1333 bNextAttr = true;
1334 break;
1335 case RES_TXTATR_FLYCNT:
1336 case RES_TXTATR_FTN:
1337 bNextAttr = true;
1338 break;
1339 }
1340
1341 if( bNextAttr )
1342 continue;
1343
1344 // save all attributes that are somehow in this area
1345 if ( nStart <= nAttrStt )
1346 {
1347 if ( nEnd > nAttrStt )
1348 {
1349 Add( pHt, nNodeIdx, false );
1350 }
1351 }
1352 else if ( pEndIdx && nStart < *pEndIdx )
1353 {
1354 Add( pHt, nNodeIdx, false );
1355 }
1356 }
1357}
1358
1359// Class to register the history at a Node, Format, HintsArray, ...
1361 : SwClient( nullptr )
1362 , m_pHistory( pHst )
1363 , m_nNodeIndex( NODE_OFFSET_MAX )
1364{
1366}
1367
1369 SwHistory* pHst )
1370 : SwClient( pRegIn )
1371 , m_pHistory( pHst )
1372 , m_nNodeIndex( rNd.GetIndex() )
1373{
1375}
1376
1378 : SwClient( nullptr )
1379 , m_pHistory( pHst )
1380 , m_nNodeIndex( rNd.GetIndex() )
1381{
1383}
1384
1386{
1387 if (rHint.GetId() != SfxHintId::SwLegacyModify)
1388 return;
1389 auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
1390 if ( !(m_pHistory && pLegacyHint->m_pNew && pLegacyHint->m_pOld != pLegacyHint->m_pNew) )
1391 return;
1392
1393 if ( pLegacyHint->m_pNew->Which() < POOLATTR_END )
1394 {
1395 if(RES_UPDATE_ATTR == pLegacyHint->m_pNew->Which())
1396 {
1397 m_pHistory->Add(pLegacyHint->m_pOld, pLegacyHint->m_pNew, m_nNodeIndex);
1398 }
1399 else
1400 {
1401 OSL_ENSURE(false, "Unexpected update attribute (!)");
1402 }
1403 }
1404 else if (pLegacyHint->m_pOld && RES_ATTRSET_CHG == pLegacyHint->m_pNew->Which())
1405 {
1406 std::unique_ptr<SwHistoryHint> pNewHstr;
1407 const SfxItemSet& rSet = *static_cast< const SwAttrSetChg* >(pLegacyHint->m_pOld)->GetChgSet();
1408
1409 if ( 1 < rSet.Count() )
1410 {
1411 pNewHstr.reset( new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet ) );
1412 }
1413 else if (const SfxPoolItem* pItem = SfxItemIter(rSet).GetCurItem())
1414 {
1415 if ( m_WhichIdSet.count( pItem->Which() ) )
1416 {
1417 pNewHstr.reset( new SwHistorySetFormat( pItem, m_nNodeIndex ) );
1418 }
1419 else
1420 {
1421 pNewHstr.reset( new SwHistoryResetFormat( pItem, m_nNodeIndex ) );
1422 }
1423 }
1424
1425 if (pNewHstr)
1426 m_pHistory->m_SwpHstry.push_back( std::move(pNewHstr) );
1427 }
1428}
1429
1430void SwRegHistory::AddHint( SwTextAttr* pHt, const bool bNew )
1431{
1432 m_pHistory->Add( pHt, m_nNodeIndex, bNew );
1433}
1434
1436 sal_Int32 const nStart, sal_Int32 const nEnd, SetAttrMode const nFlags,
1437 SwTextAttr **ppNewTextAttr )
1438{
1439 if( !rSet.Count() )
1440 return false;
1441
1442 SwTextNode * const pTextNode =
1443 dynamic_cast<SwTextNode *>(GetRegisteredIn());
1444
1445 OSL_ENSURE(pTextNode, "SwRegHistory not registered at text node?");
1446 if (!pTextNode)
1447 return false;
1448
1449 if (m_pHistory)
1450 {
1451 pTextNode->GetOrCreateSwpHints().Register(this);
1452 }
1453
1454 const bool bInserted = pTextNode->SetAttr( rSet, nStart, nEnd, nFlags, ppNewTextAttr );
1455
1456 // Caution: The array can be deleted when inserting an attribute!
1457 // This can happen when the value that should be added first deletes
1458 // an existing attribute but does not need to be added itself because
1459 // the paragraph attributes are identical
1460 // ( -> bForgetAttr in SwpHints::Insert )
1461 if ( pTextNode->GetpSwpHints() && m_pHistory )
1462 {
1463 pTextNode->GetpSwpHints()->DeRegister();
1464 }
1465
1466#ifndef NDEBUG
1467 if ( m_pHistory && bInserted )
1468 {
1469 SfxItemIter aIter(rSet);
1470 for (SfxPoolItem const* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1471 { // check that the history recorded a hint to reset every item
1472 sal_uInt16 const nWhich(pItem->Which());
1473 sal_uInt16 const nExpected(
1474 (isCHRATR(nWhich) || RES_TXTATR_UNKNOWN_CONTAINER == nWhich)
1476 : nWhich);
1477 if (RES_TXTATR_AUTOFMT == nExpected)
1478 continue; // special case, may get set on text node itself
1479 // tdf#105077 even worse, node's set could cause
1480 // nothing at all to be inserted
1481 assert(std::any_of(
1482 m_pHistory->m_SwpHstry.begin(), m_pHistory->m_SwpHstry.end(),
1483 [nExpected](std::unique_ptr<SwHistoryHint> const& pHint) -> bool {
1484 SwHistoryResetText const*const pReset(
1485 dynamic_cast<SwHistoryResetText const*>(pHint.get()));
1486 return pReset && (pReset->GetWhich() == nExpected);
1487 }));
1488 }
1489 }
1490#endif
1491
1492 return bInserted;
1493}
1494
1496{
1497 if ( m_pHistory && pRegIn )
1498 {
1499 pRegIn->Add( this );
1500 m_nNodeIndex = rNd.GetIndex();
1502 }
1503 else
1504 {
1506 }
1507}
1508
1510{
1511 if (!m_pHistory) return;
1512
1514
1515 if( !GetRegisteredIn() )
1516 return;
1517
1518 const SfxItemSet* pSet = nullptr;
1519 if( auto pContentNode = dynamic_cast< const SwContentNode *>( GetRegisteredIn() ) )
1520 {
1521 pSet = pContentNode->GetpSwAttrSet();
1522 }
1523 else if ( auto pSwFormat = dynamic_cast< const SwFormat *>( GetRegisteredIn() ) )
1524 {
1525 pSet = &pSwFormat->GetAttrSet();
1526 }
1527 if( pSet && pSet->Count() )
1528 {
1529 SfxItemIter aIter( *pSet );
1530 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1531 {
1532 sal_uInt16 nW = pItem->Which();
1533 m_WhichIdSet.insert( nW );
1534 }
1535 }
1536}
1537/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
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:475
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:109
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:164
SwContentIndex & Assign(const SwContentNode *, sal_Int32)
Definition: index.cxx:206
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1224
virtual SwFormatColl * ChgFormatColl(SwFormatColl *)
Definition: node.cxx:1259
Definition: doc.hxx:192
const SwTOXType * InsertTOXType(const SwTOXType &rTyp)
Definition: doctxm.cxx:629
::sw::IShellCursorSupplier * GetIShellCursorSupplier()
Definition: doccorr.cxx:353
sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const
Manage table of content types.
Definition: doctxm.cxx:611
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: doc.hxx:775
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:744
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:145
SwNodes & GetNodes()
Definition: doc.hxx:413
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:358
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:406
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:782
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1793
const SwGrfFormatColls * GetGrfFormatColls() const
Definition: doc.hxx:810
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1322
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:748
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
Definition: doctxm.cxx:620
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
FlyAnchors.
Definition: fmtanchr.hxx:37
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1586
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:32
SwFlyFrameFormat * GetPrev() const
Definition: fmtcnct.hxx:53
void SetNext(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2139
void SetPrev(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2131
SwFlyFrameFormat * GetNext() const
Definition: fmtcnct.hxx:54
SwCharFormat * GetCharFormat() const
Definition: fchrfmt.hxx:70
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps.
Definition: paratr.hxx:63
void ChgDefinedIn(const sw::FormatDropDefiner *pDefiner)
Get and set Modify pointer.
Definition: paratr.hxx:120
void SetEndNote(bool b)
Definition: atrftn.cxx:177
bool IsEndNote() const
Definition: fmtftn.hxx:73
void SetNumStr(const OUString &rStr)
Definition: fmtftn.hxx:75
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:620
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:83
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:449
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:62
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2702
bool IsAlive(SwFrameFormat const *) const
not so fast check that given format is still alive (i.e. contained here)
Definition: docfmt.cxx:2152
const bool m_bSaveOtherPos
Definition: rolbck.hxx:264
SwHistoryBookmark(const ::sw::mark::IMark &rBkmk, bool bSavePos, bool bSaveOtherPos)
Definition: rolbck.cxx:605
const SwNodeOffset m_nNode
Definition: rolbck.hxx:259
OUString m_aHideCondition
Definition: rolbck.hxx:257
const bool m_bHadOtherPos
Definition: rolbck.hxx:265
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo
Definition: rolbck.hxx:267
const sal_Int32 m_nOtherContent
Definition: rolbck.hxx:262
const OUString m_aName
Definition: rolbck.hxx:254
vcl::KeyCode m_aKeycode
Definition: rolbck.hxx:258
virtual void SetInDoc(SwDoc *pDoc, bool) override
Definition: rolbck.cxx:642
const bool m_bSavePos
Definition: rolbck.hxx:263
bool IsEqualBookmark(const ::sw::mark::IMark &rBkmk)
Definition: rolbck.cxx:722
const SwNodeOffset m_nOtherNode
Definition: rolbck.hxx:260
const IDocumentMarkAccess::MarkType m_eBkmkType
Definition: rolbck.hxx:266
OUString m_aShortName
Definition: rolbck.hxx:255
const sal_Int32 m_nContent
Definition: rolbck.hxx:261
SwHistoryChangeCharFormat(SfxItemSet aSet, OUString sFormat)
Definition: rolbck.cxx:1007
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:1014
const SfxItemSet m_OldSet
Definition: rolbck.hxx:342
const OUString m_Format
Definition: rolbck.hxx:343
const sal_Int32 m_nOldContentIndex
Definition: rolbck.hxx:322
SwFrameFormat & m_rFormat
Definition: rolbck.hxx:320
SwHistoryChangeFlyAnchor(SwFrameFormat &rFormat)
Definition: rolbck.cxx:925
const SwNodeOffset m_nOldNodeIndex
Definition: rolbck.hxx:321
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:935
SwHistoryChangeFlyChain(SwFlyFrameFormat &rFormat, const SwFormatChain &rAttr)
Definition: rolbck.cxx:966
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:975
SwFlyFrameFormat *const m_pPrevFormat
Definition: rolbck.hxx:331
SwFlyFrameFormat *const m_pFlyFormat
Definition: rolbck.hxx:333
SwFlyFrameFormat *const m_pNextFormat
Definition: rolbck.hxx:332
const SwNodeType m_nNodeType
Definition: rolbck.hxx:222
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:221
SwFormatColl *const m_pColl
Definition: rolbck.hxx:220
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:80
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:273
virtual void SetInDoc(SwDoc *pDoc, bool) override
Definition: rolbck.cxx:737
const OUString m_sType
Definition: rolbck.hxx:280
void ResetInDoc(SwDoc &rDoc)
Definition: rolbck.cxx:755
const SwNodeOffset m_nNode
Definition: rolbck.hxx:281
SwHistoryNoTextFieldmark(const ::sw::mark::IFieldmark &rFieldMark)
Definition: rolbck.cxx:729
const sal_Int32 m_nContent
Definition: rolbck.hxx:282
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:107
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:208
const sal_uInt16 m_nWhich
Definition: rolbck.hxx:108
SwHistoryResetFormat(const SfxPoolItem *pFormatHt, SwNodeOffset nNodeIdx)
Definition: rolbck.cxx:201
const sal_Int32 m_nEnd
Definition: rolbck.hxx:186
SwHistoryResetText(sal_uInt16 nWhich, sal_Int32 nStt, sal_Int32 nEnd, SwNodeOffset nNode)
Definition: rolbck.cxx:430
const sal_uInt16 m_nAttr
Definition: rolbck.hxx:187
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:184
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:438
const sal_Int32 m_nStart
Definition: rolbck.hxx:185
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:309
std::vector< sal_uInt16 > m_ResetArray
Definition: rolbck.hxx:308
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:900
SfxItemSet m_OldSet
Definition: rolbck.hxx:307
virtual OUString GetDescription() const override
Definition: rolbck.cxx:484
const sal_Int32 m_nStart
Definition: rolbck.hxx:205
const std::unique_ptr< SwUndoSaveSection, o3tl::default_delete< SwUndoSaveSection > > m_pUndo
Definition: rolbck.hxx:202
SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:204
virtual ~SwHistorySetFootnote() override
Definition: rolbck.cxx:489
const bool m_bEndNote
Definition: rolbck.hxx:206
const OUString m_FootnoteNumber
Definition: rolbck.hxx:203
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:94
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:93
SwHistorySetFormat(const SfxPoolItem *pFormatHt, SwNodeOffset nNode)
Definition: rolbck.cxx:78
const sal_Int32 m_nEnd
Definition: rolbck.hxx:157
SwHistorySetRefMark(const SwTextRefMark *pTextHt, SwNodeOffset nNode)
Definition: rolbck.cxx:341
const OUString m_RefName
Definition: rolbck.hxx:154
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:350
const sal_Int32 m_nStart
Definition: rolbck.hxx:156
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:155
const TOXTypes m_eTOXTypes
Definition: rolbck.hxx:169
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:172
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:402
const sal_Int32 m_nStart
Definition: rolbck.hxx:171
SwTOXMark m_TOXMark
Definition: rolbck.hxx:167
SwHistorySetTOXMark(const SwTextTOXMark *pTextHt, SwNodeOffset nNode)
Definition: rolbck.cxx:368
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:170
const OUString m_TOXName
Definition: rolbck.hxx:168
SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:139
SwFieldIds m_nFieldWhich
Definition: rolbck.hxx:141
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:137
std::unique_ptr< SwFieldType > m_pFieldType
! beware of the order for the declaration of the unique_ptrs.
Definition: rolbck.hxx:136
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:118
const sal_Int32 m_nEnd
Definition: rolbck.hxx:121
bool m_bFormatIgnoreEnd
Definition: rolbck.hxx:123
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:119
virtual ~SwHistorySetText() override
Definition: rolbck.cxx:246
SwHistorySetText(SwTextAttr *pTextHt, SwNodeOffset nNode)
Definition: rolbck.cxx:222
const sal_Int32 m_nStart
Definition: rolbck.hxx:120
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:250
bool m_bFormatIgnoreStart
Definition: rolbck.hxx:122
History object containing all information used during undo / redo of text form field insertion.
Definition: rolbck.hxx:288
const sal_Int32 m_nStartContent
Definition: rolbck.hxx:298
const sal_Int32 m_nEndContent
Definition: rolbck.hxx:300
const OUString m_sType
Definition: rolbck.hxx:296
const SwNodeOffset m_nStartNode
Definition: rolbck.hxx:297
virtual void SetInDoc(SwDoc *pDoc, bool) override
Definition: rolbck.cxx:787
sal_Int32 m_nSepContent
Definition: rolbck.hxx:302
const SwNodeOffset m_nEndNode
Definition: rolbck.hxx:299
SwHistoryTextFieldmark(const ::sw::mark::IFieldmark &rFieldMark)
Definition: rolbck.cxx:773
void ResetInDoc(SwDoc &rDoc)
Definition: rolbck.cxx:813
SwNodeOffset m_nSepNode
Definition: rolbck.hxx:301
const OUString m_sName
Definition: rolbck.hxx:295
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:232
void CopyFormatAttr(const SfxItemSet &rSet, SwNodeOffset nNodeIdx)
Definition: rolbck.cxx:1268
void CopyAttr(SwpHints const *pHts, const SwNodeOffset nNodeIdx, const sal_Int32 nStart, const sal_Int32 nEnd, const bool bCopyFields)
Definition: rolbck.cxx:1304
sal_uInt16 Count() const
Definition: rolbck.hxx:378
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: rolbck.cxx:1289
void AddDeleteFly(SwFrameFormat &, sal_uInt16 &rSetPos)
Definition: rolbck.cxx:1155
std::vector< std::unique_ptr< SwHistoryHint > > m_SwpHstry
Definition: rolbck.hxx:356
void AddChangeFlyAnchor(SwFrameFormat &rFormat)
Definition: rolbck.cxx:1149
sal_uInt16 SetTmpEnd(sal_uInt16 nTmpEnd)
Definition: rolbck.cxx:1247
void Add(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, SwNodeOffset nNodeIdx)
Definition: rolbck.cxx:1034
~SwHistory()
Definition: rolbck.cxx:1030
sal_uInt16 m_nEndDiff
Definition: rolbck.hxx:357
bool TmpRollback(SwDoc *pDoc, sal_uInt16 nStart, bool ToFirst=true)
Definition: rolbck.cxx:1222
bool Rollback(SwDoc *pDoc, sal_uInt16 nStart=0)
Definition: rolbck.cxx:1207
void Add(SwClient *pDepend)
Definition: calbck.cxx:172
Marks a node in the document model.
Definition: ndindex.hxx:31
Base class of the Writer document model elements.
Definition: node.hxx:84
SwNodeOffset GetIndex() const
Definition: node.hxx:296
bool IsContentNode() const
Definition: node.hxx:656
SwDoc & GetDoc()
Definition: node.hxx:217
bool IsStartNode() const
Definition: node.hxx:652
bool IsTableNode() const
Definition: node.hxx:668
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:370
SwContentNode * GetContentNode()
Definition: node.hxx:643
SwNodeType GetNodeType() const
Definition: node.hxx:150
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: rolbck.cxx:1385
SwRegHistory(SwHistory *pHst)
Definition: rolbck.cxx:1360
SwHistory *const m_pHistory
Definition: rolbck.hxx:415
o3tl::sorted_vector< sal_uInt16 > m_WhichIdSet
Definition: rolbck.hxx:414
void MakeSetWhichIds()
Definition: rolbck.cxx:1509
SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:416
bool InsertItems(const SfxItemSet &rSet, sal_Int32 const nStart, sal_Int32 const nEnd, SetAttrMode const nFlags, SwTextAttr **ppNewTextAttr)
Definition: rolbck.cxx:1435
void AddHint(SwTextAttr *pHt, const bool bNew)
Definition: rolbck.cxx:1430
void RegisterInModify(sw::BroadcastingModify *pRegIn, const SwNode &rNd)
Definition: rolbck.cxx:1495
Starts a section of nodes in the document model.
Definition: node.hxx:325
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 ChangeState(const SfxPoolItem *pItem)
Definition: cellatr.cxx:97
void ChgDefinedIn(const sw::BroadcastingModify *pNew)
Definition: cellatr.hxx:65
const sw::BroadcastingModify * GetDefinedIn() const
Definition: cellatr.hxx:64
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:419
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1901
TableFormulaUpdateFlags m_eFlags
Definition: hints.hxx:271
bool IsIntrnlName() const
Definition: cellfml.hxx:132
const SwTable & GetTable() const
Definition: node.hxx:521
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
Definition: swtable.cxx:1340
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
void CheckCondColl()
Definition: atrftn.cxx:569
const SwNodeIndex * GetStartNode() const
Definition: txtftn.hxx:41
const SwTextNode & GetTextNode() const
Definition: txtftn.hxx:70
void SetStartNode(const SwNodeIndex *pNode, bool bDelNodes=true)
Definition: atrftn.cxx:299
Represents the style of a paragraph.
Definition: fmtcol.hxx:59
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:86
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:1802
SwpHints & GetOrCreateSwpHints()
Definition: ndtxt.hxx:853
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:4990
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:230
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:3105
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:140
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)
void RestoreMetadata(std::shared_ptr< MetadatableUndo > const &i_pUndo)
std::shared_ptr< MetadatableUndo > CreateUndo() const
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
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< SvxFormatBreakItem > RES_BREAK(94)
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(59)
bool isCHRATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:479
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(152)
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
constexpr TypedWhichId< SwTableBoxFormula > RES_BOXATR_FORMULA(151)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(60)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
constexpr TypedWhichId< SwUpdateAttr > RES_UPDATE_ATTR(167)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
constexpr TypedWhichId< SwFormatDrop > RES_PARATR_DROP(70)
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_TXTATR_UNKNOWN_CONTAINER(54)
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(114)
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
constexpr TypedWhichId< SwTOXMark > RES_TXTATR_TOXMARK(47)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
constexpr sal_uInt16 POOLATTR_END(RES_UNKNOWNATR_END)
@ TBL_BOXNAME
Definition: hints.hxx:255
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:71
@ HSTRY_BOOKMARK
Definition: rolbck.hxx:69
@ HSTRY_SETFTNHNT
Definition: rolbck.hxx:66
@ HSTRY_SETTOXMARKHNT
Definition: rolbck.hxx:64
@ HSTRY_CHGFLYCHAIN
Definition: rolbck.hxx:72
@ HSTRY_CHGFMTCOLL
Definition: rolbck.hxx:67
@ HSTRY_NOTEXTFIELDMARK
Definition: rolbck.hxx:74
@ HSTRY_SETTXTHNT
Definition: rolbck.hxx:61
@ HSTRY_RESETTXTHNT
Definition: rolbck.hxx:65
@ HSTRY_SETFMTHNT
Definition: rolbck.hxx:59
@ HSTRY_SETTXTFLDHNT
Definition: rolbck.hxx:62
@ HSTRY_SETREFMARKHNT
Definition: rolbck.hxx:63
@ HSTRY_RESETFMTHNT
Definition: rolbck.hxx:60
@ HSTRY_FLYCNT
Definition: rolbck.hxx:68
@ HSTRY_CHGCHARFMT
Definition: rolbck.hxx:73
@ HSTRY_SETATTRSET
Definition: rolbck.hxx:70
@ HSTRY_TEXTFIELDMARK
Definition: rolbck.hxx:75
static SfxItemSet & rSet
Marks a position in the document model.
Definition: pam.hxx:37
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:77
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
SwContentIndex nContent
Definition: pam.hxx:39
RndStdIds
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
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