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 {
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 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().GetAnchorNode()->GetIndex() )
929 , m_nOldContentIndex( (RndStdIds::FLY_AT_CHAR == rFormat.GetAnchor().GetAnchorId())
930 ? rFormat.GetAnchor().GetAnchorContentOffset()
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 );
949 aTmp.SetAnchor( &aPos );
950
951 // so the Layout does not get confused
952 if (!pCNd->getLayoutFrame(pDoc->getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, nullptr))
953 {
955 }
956
957 m_rFormat.SetFormatAttr( aTmp );
958}
959
961 const SwFormatChain& rAttr )
963 , m_pPrevFormat( rAttr.GetPrev() )
964 , m_pNextFormat( rAttr.GetNext() )
965 , m_pFlyFormat( &rFormat )
966{
967}
968
970{
972 return;
973
974 SwFormatChain aChain;
975
976 if (m_pPrevFormat &&
978 {
979 aChain.SetPrev( m_pPrevFormat );
981 aTmp.SetNext( m_pFlyFormat );
983 }
984
985 if (m_pNextFormat &&
987 {
988 aChain.SetNext( m_pNextFormat );
990 aTmp.SetPrev( m_pFlyFormat );
992 }
993
994 if ( aChain.GetNext() || aChain.GetPrev() )
995 {
996 m_pFlyFormat->SetFormatAttr( aChain );
997 }
998}
999
1000// -> #i27615#
1002 OUString sFormat)
1004 , m_OldSet(std::move(aSet)), m_Format(std::move(sFormat))
1005{
1006}
1007
1009{
1010 SwCharFormat * pCharFormat = pDoc->FindCharFormatByName(m_Format);
1011
1012 if (pCharFormat)
1013 {
1014 pCharFormat->SetFormatAttr(m_OldSet);
1015 }
1016}
1017// <- #i27615#
1018
1020 : m_nEndDiff( 0 )
1021{
1022}
1023
1025{
1026}
1027
1029 const SfxPoolItem* pOldValue,
1030 const SfxPoolItem* pNewValue,
1031 SwNodeOffset nNodeIdx)
1032{
1033 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1034 const sal_uInt16 nWhich(pNewValue->Which());
1035
1036 // excluded values
1037 if(nWhich == RES_TXTATR_FIELD || nWhich == RES_TXTATR_ANNOTATION)
1038 {
1039 return;
1040 }
1041
1042 // no default Attribute?
1043 std::unique_ptr<SwHistoryHint> pHt;
1044
1045 // To be able to include the DrawingLayer FillItems something more
1046 // general has to be done to check if an Item is default than to check
1047 // if its pointer equals that in Writer's global PoolDefaults (held in
1048 // aAttrTab and used to fill the pool defaults in Writer - looks as if
1049 // Writer is *older* than the SfxItemPool ?). I checked the possibility to
1050 // get the SfxItemPool here (works), but decided to use the SfxPoolItem's
1051 // global tooling aka IsDefaultItem(const SfxPoolItem*) for now
1052 if(pOldValue && !IsDefaultItem(pOldValue))
1053 {
1054 pHt.reset( new SwHistorySetFormat( pOldValue, nNodeIdx ) );
1055 }
1056 else
1057 {
1058 pHt.reset( new SwHistoryResetFormat( pNewValue, nNodeIdx ) );
1059 }
1060
1061 m_SwpHstry.push_back( std::move(pHt) );
1062}
1063
1064// FIXME: refactor the following "Add" methods (DRY)?
1065void SwHistory::Add( SwTextAttr* pHint, SwNodeOffset nNodeIdx, bool bNewAttr )
1066{
1067 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1068
1069 std::unique_ptr<SwHistoryHint> pHt;
1070 if( !bNewAttr )
1071 {
1072 switch ( pHint->Which() )
1073 {
1074 case RES_TXTATR_FTN:
1075 pHt.reset( new SwHistorySetFootnote(
1076 static_cast<SwTextFootnote*>(pHint), nNodeIdx ) );
1077 break;
1078 case RES_TXTATR_FLYCNT:
1079 pHt.reset( new SwHistoryTextFlyCnt( static_cast<SwTextFlyCnt*>(pHint)
1080 ->GetFlyCnt().GetFrameFormat() ) );
1081 break;
1082 case RES_TXTATR_FIELD:
1084 pHt.reset( new SwHistorySetTextField(
1085 static_txtattr_cast<SwTextField*>(pHint), nNodeIdx) );
1086 break;
1087 case RES_TXTATR_TOXMARK:
1088 pHt.reset( new SwHistorySetTOXMark(
1089 static_txtattr_cast<SwTextTOXMark*>(pHint), nNodeIdx) );
1090 break;
1091 case RES_TXTATR_REFMARK:
1092 pHt.reset( new SwHistorySetRefMark(
1093 static_txtattr_cast<SwTextRefMark*>(pHint), nNodeIdx) );
1094 break;
1095 default:
1096 pHt.reset( new SwHistorySetText( pHint, nNodeIdx ) );
1097 }
1098 }
1099 else
1100 {
1101 pHt.reset( new SwHistoryResetText( pHint->Which(), pHint->GetStart(),
1102 pHint->GetAnyEnd(), nNodeIdx ) );
1103 }
1104 m_SwpHstry.push_back( std::move(pHt) );
1105}
1106
1107void SwHistory::Add( SwFormatColl* pColl, SwNodeOffset nNodeIdx, SwNodeType nWhichNd )
1108{
1109 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1110
1111 std::unique_ptr<SwHistoryHint> pHt(
1112 new SwHistoryChangeFormatColl( pColl, nNodeIdx, nWhichNd ));
1113 m_SwpHstry.push_back( std::move(pHt) );
1114}
1115
1116void SwHistory::Add(const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOtherPos)
1117{
1118 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1119
1120 std::unique_ptr<SwHistoryHint> pHt;
1121
1122 switch (IDocumentMarkAccess::GetType(rBkmk))
1123 {
1126 assert(bSavePos && bSaveOtherPos); // must be deleted completely!
1127 pHt.reset(new SwHistoryTextFieldmark(dynamic_cast<sw::mark::IFieldmark const&>(rBkmk)));
1128 break;
1131 assert(bSavePos && bSaveOtherPos); // must be deleted completely!
1132 pHt.reset(new SwHistoryNoTextFieldmark(dynamic_cast<sw::mark::IFieldmark const&>(rBkmk)));
1133 break;
1134 default:
1135 pHt.reset(new SwHistoryBookmark(rBkmk, bSavePos, bSaveOtherPos));
1136 break;
1137 }
1138
1139 assert(pHt);
1140 m_SwpHstry.push_back( std::move(pHt) );
1141}
1142
1144{
1145 std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeFlyAnchor( rFormat ));
1146 m_SwpHstry.push_back( std::move(pHt) );
1147}
1148
1149void SwHistory::AddDeleteFly(SwFrameFormat& rFormat, sal_uInt16& rSetPos)
1150{
1151 OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1152
1153 const sal_uInt16 nWh = rFormat.Which();
1154 (void) nWh;
1155 // only Flys!
1156 assert((RES_FLYFRMFMT == nWh && dynamic_cast<SwFlyFrameFormat*>(&rFormat))
1157 || (RES_DRAWFRMFMT == nWh && dynamic_cast<SwDrawFrameFormat*>(&rFormat)));
1158 {
1159 std::unique_ptr<SwHistoryHint> pHint(new SwHistoryTextFlyCnt( &rFormat ));
1160 m_SwpHstry.push_back( std::move(pHint) );
1161
1162 if( const SwFormatChain* pChainItem = rFormat.GetItemIfSet( RES_CHAIN, false ) )
1163 {
1164 assert(RES_FLYFRMFMT == nWh); // not supported on SdrObjects
1165 if( pChainItem->GetNext() || pChainItem->GetPrev() )
1166 {
1167 std::unique_ptr<SwHistoryHint> pHt(
1168 new SwHistoryChangeFlyChain(static_cast<SwFlyFrameFormat&>(rFormat), *pChainItem));
1169 m_SwpHstry.insert( m_SwpHstry.begin() + rSetPos++, std::move(pHt) );
1170 if ( pChainItem->GetNext() )
1171 {
1172 SwFormatChain aTmp( pChainItem->GetNext()->GetChain() );
1173 aTmp.SetPrev( nullptr );
1174 pChainItem->GetNext()->SetFormatAttr( aTmp );
1175 }
1176 if ( pChainItem->GetPrev() )
1177 {
1178 SwFormatChain aTmp( pChainItem->GetPrev()->GetChain() );
1179 aTmp.SetNext( nullptr );
1180 pChainItem->GetPrev()->SetFormatAttr( aTmp );
1181 }
1182 }
1183 rFormat.ResetFormatAttr( RES_CHAIN );
1184 }
1185 }
1186}
1187
1188void SwHistory::Add( const SwTextFootnote& rFootnote )
1189{
1190 std::unique_ptr<SwHistoryHint> pHt(new SwHistorySetFootnote( rFootnote ));
1191 m_SwpHstry.push_back( std::move(pHt) );
1192}
1193
1194// #i27615#
1195void SwHistory::Add(const SfxItemSet & rSet, const SwCharFormat & rFormat)
1196{
1197 std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeCharFormat(rSet, rFormat.GetName()));
1198 m_SwpHstry.push_back( std::move(pHt) );
1199}
1200
1201bool SwHistory::Rollback( SwDoc* pDoc, sal_uInt16 nStart )
1202{
1203 if ( !Count() )
1204 return false;
1205
1206 for ( sal_uInt16 i = Count(); i > nStart ; )
1207 {
1208 SwHistoryHint * pHHt = m_SwpHstry[ --i ].get();
1209 pHHt->SetInDoc( pDoc, false );
1210 }
1211 m_SwpHstry.erase( m_SwpHstry.begin() + nStart, m_SwpHstry.end() );
1212 m_nEndDiff = 0;
1213 return true;
1214}
1215
1216bool SwHistory::TmpRollback( SwDoc* pDoc, sal_uInt16 nStart, bool bToFirst )
1217{
1218 sal_uInt16 nEnd = Count() - m_nEndDiff;
1219 if ( !Count() || !nEnd || nStart >= nEnd )
1220 return false;
1221
1222 if ( bToFirst )
1223 {
1224 for ( ; nEnd > nStart; ++m_nEndDiff )
1225 {
1226 SwHistoryHint* pHHt = m_SwpHstry[ --nEnd ].get();
1227 pHHt->SetInDoc( pDoc, true );
1228 }
1229 }
1230 else
1231 {
1232 for ( ; nStart < nEnd; ++m_nEndDiff, ++nStart )
1233 {
1234 SwHistoryHint* pHHt = m_SwpHstry[ nStart ].get();
1235 pHHt->SetInDoc( pDoc, true );
1236 }
1237 }
1238 return true;
1239}
1240
1241sal_uInt16 SwHistory::SetTmpEnd( sal_uInt16 nNewTmpEnd )
1242{
1243 OSL_ENSURE( nNewTmpEnd <= Count(), "SwHistory::SetTmpEnd: out of bounds" );
1244
1245 const sal_uInt16 nOld = Count() - m_nEndDiff;
1246 m_nEndDiff = Count() - nNewTmpEnd;
1247
1248 // for every SwHistoryFlyCnt, call the Redo of its UndoObject.
1249 // this saves the formats of the flys!
1250 for ( sal_uInt16 n = nOld; n < nNewTmpEnd; n++ )
1251 {
1252 if ( HSTRY_FLYCNT == (*this)[ n ]->Which() )
1253 {
1254 static_cast<SwHistoryTextFlyCnt*>((*this)[ n ])
1255 ->GetUDelLFormat()->RedoForRollback();
1256 }
1257 }
1258
1259 return nOld;
1260}
1261
1263 const SfxItemSet& rSet,
1264 SwNodeOffset nNodeIdx)
1265{
1266 if(!rSet.Count())
1267 return;
1268
1269 SfxItemIter aIter(rSet);
1270 const SfxPoolItem* pItem = aIter.GetCurItem();
1271 do
1272 {
1273 if(!IsInvalidItem(pItem))
1274 {
1275 Add(pItem, pItem, nNodeIdx);
1276 }
1277
1278 pItem = aIter.NextItem();
1279
1280 } while(pItem);
1281}
1282
1284{
1285 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHistory"));
1286 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1287
1288 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_SwpHstry"));
1289 for (const auto& pHistory : m_SwpHstry)
1290 {
1291 pHistory->dumpAsXml(pWriter);
1292 }
1293 (void)xmlTextWriterEndElement(pWriter);
1294
1295 (void)xmlTextWriterEndElement(pWriter);
1296}
1297
1299 SwpHints const * pHts,
1300 const SwNodeOffset nNodeIdx,
1301 const sal_Int32 nStart,
1302 const sal_Int32 nEnd,
1303 const bool bCopyFields )
1304{
1305 if( !pHts )
1306 return;
1307
1308 // copy all attributes of the TextNode in the area from nStart to nEnd
1309 SwTextAttr* pHt;
1310 for( size_t n = 0; n < pHts->Count(); ++n )
1311 {
1312 // nAttrStt must even be set when !pEndIdx
1313 pHt = pHts->Get(n);
1314 const sal_Int32 nAttrStt = pHt->GetStart();
1315 const sal_Int32 * pEndIdx = pHt->GetEnd();
1316 if( nullptr != pEndIdx && nAttrStt > nEnd )
1317 break;
1318
1319 // never copy Flys and Footnote !!
1320 bool bNextAttr = false;
1321 switch( pHt->Which() )
1322 {
1323 case RES_TXTATR_FIELD:
1326 if( !bCopyFields )
1327 bNextAttr = true;
1328 break;
1329 case RES_TXTATR_FLYCNT:
1330 case RES_TXTATR_FTN:
1331 bNextAttr = true;
1332 break;
1333 }
1334
1335 if( bNextAttr )
1336 continue;
1337
1338 // save all attributes that are somehow in this area
1339 if ( nStart <= nAttrStt )
1340 {
1341 if ( nEnd > nAttrStt )
1342 {
1343 Add( pHt, nNodeIdx, false );
1344 }
1345 }
1346 else if ( pEndIdx && nStart < *pEndIdx )
1347 {
1348 Add( pHt, nNodeIdx, false );
1349 }
1350 }
1351}
1352
1353// Class to register the history at a Node, Format, HintsArray, ...
1355 : SwClient( nullptr )
1356 , m_pHistory( pHst )
1357 , m_nNodeIndex( NODE_OFFSET_MAX )
1358{
1360}
1361
1362SwRegHistory::SwRegHistory( sw::BroadcastingModify* pRegIn, const SwNode& rNd,
1363 SwHistory* pHst )
1364 : SwClient( pRegIn )
1365 , m_pHistory( pHst )
1366 , m_nNodeIndex( rNd.GetIndex() )
1367{
1369}
1370
1372 : SwClient( nullptr )
1373 , m_pHistory( pHst )
1374 , m_nNodeIndex( rNd.GetIndex() )
1375{
1377}
1378
1380{
1381 if (rHint.GetId() != SfxHintId::SwLegacyModify)
1382 return;
1383 auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
1384 if ( !(m_pHistory && pLegacyHint->m_pNew && pLegacyHint->m_pOld != pLegacyHint->m_pNew) )
1385 return;
1386
1387 if ( pLegacyHint->m_pNew->Which() < POOLATTR_END )
1388 {
1389 if(RES_UPDATE_ATTR == pLegacyHint->m_pNew->Which())
1390 {
1391 m_pHistory->Add(pLegacyHint->m_pOld, pLegacyHint->m_pNew, m_nNodeIndex);
1392 }
1393 else
1394 {
1395 OSL_ENSURE(false, "Unexpected update attribute (!)");
1396 }
1397 }
1398 else if (pLegacyHint->m_pOld && RES_ATTRSET_CHG == pLegacyHint->m_pNew->Which())
1399 {
1400 std::unique_ptr<SwHistoryHint> pNewHstr;
1401 const SfxItemSet& rSet = *static_cast< const SwAttrSetChg* >(pLegacyHint->m_pOld)->GetChgSet();
1402
1403 if ( 1 < rSet.Count() )
1404 {
1405 pNewHstr.reset( new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet ) );
1406 }
1407 else if (const SfxPoolItem* pItem = SfxItemIter(rSet).GetCurItem())
1408 {
1409 if ( m_WhichIdSet.count( pItem->Which() ) )
1410 {
1411 pNewHstr.reset( new SwHistorySetFormat( pItem, m_nNodeIndex ) );
1412 }
1413 else
1414 {
1415 pNewHstr.reset( new SwHistoryResetFormat( pItem, m_nNodeIndex ) );
1416 }
1417 }
1418
1419 if (pNewHstr)
1420 m_pHistory->m_SwpHstry.push_back( std::move(pNewHstr) );
1421 }
1422}
1423
1424void SwRegHistory::AddHint( SwTextAttr* pHt, const bool bNew )
1425{
1426 m_pHistory->Add( pHt, m_nNodeIndex, bNew );
1427}
1428
1430 sal_Int32 const nStart, sal_Int32 const nEnd, SetAttrMode const nFlags,
1431 SwTextAttr **ppNewTextAttr )
1432{
1433 if( !rSet.Count() )
1434 return false;
1435
1436 SwTextNode * const pTextNode =
1437 dynamic_cast<SwTextNode *>(GetRegisteredIn());
1438
1439 OSL_ENSURE(pTextNode, "SwRegHistory not registered at text node?");
1440 if (!pTextNode)
1441 return false;
1442
1443 if (m_pHistory)
1444 {
1445 pTextNode->GetOrCreateSwpHints().Register(this);
1446 }
1447
1448 const bool bInserted = pTextNode->SetAttr( rSet, nStart, nEnd, nFlags, ppNewTextAttr );
1449
1450 // Caution: The array can be deleted when inserting an attribute!
1451 // This can happen when the value that should be added first deletes
1452 // an existing attribute but does not need to be added itself because
1453 // the paragraph attributes are identical
1454 // ( -> bForgetAttr in SwpHints::Insert )
1455 if ( pTextNode->GetpSwpHints() && m_pHistory )
1456 {
1457 pTextNode->GetpSwpHints()->DeRegister();
1458 }
1459
1460#ifndef NDEBUG
1461 if ( m_pHistory && bInserted )
1462 {
1463 SfxItemIter aIter(rSet);
1464 for (SfxPoolItem const* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1465 { // check that the history recorded a hint to reset every item
1466 sal_uInt16 const nWhich(pItem->Which());
1467 sal_uInt16 const nExpected(
1468 (isCHRATR(nWhich) || RES_TXTATR_UNKNOWN_CONTAINER == nWhich)
1470 : nWhich);
1471 if (RES_TXTATR_AUTOFMT == nExpected)
1472 continue; // special case, may get set on text node itself
1473 // tdf#105077 even worse, node's set could cause
1474 // nothing at all to be inserted
1475 assert(std::any_of(
1476 m_pHistory->m_SwpHstry.begin(), m_pHistory->m_SwpHstry.end(),
1477 [nExpected](std::unique_ptr<SwHistoryHint> const& pHint) -> bool {
1478 SwHistoryResetText const*const pReset(
1479 dynamic_cast<SwHistoryResetText const*>(pHint.get()));
1480 return pReset && (pReset->GetWhich() == nExpected);
1481 }));
1482 }
1483 }
1484#endif
1485
1486 return bInserted;
1487}
1488
1489void SwRegHistory::RegisterInModify( sw::BroadcastingModify* pRegIn, const SwNode& rNd )
1490{
1491 if ( m_pHistory && pRegIn )
1492 {
1493 pRegIn->Add( this );
1494 m_nNodeIndex = rNd.GetIndex();
1496 }
1497 else
1498 {
1500 }
1501}
1502
1504{
1505 if (!m_pHistory) return;
1506
1508
1509 if( !GetRegisteredIn() )
1510 return;
1511
1512 const SfxItemSet* pSet = nullptr;
1513 if( auto pContentNode = dynamic_cast< const SwContentNode *>( GetRegisteredIn() ) )
1514 {
1515 pSet = pContentNode->GetpSwAttrSet();
1516 }
1517 else if ( auto pSwFormat = dynamic_cast< const SwFormat *>( GetRegisteredIn() ) )
1518 {
1519 pSet = &pSwFormat->GetAttrSet();
1520 }
1521 if( pSet && pSet->Count() )
1522 {
1523 SfxItemIter aIter( *pSet );
1524 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1525 {
1526 sal_uInt16 nW = pItem->Which();
1527 m_WhichIdSet.insert( nW );
1528 }
1529 }
1530}
1531/* 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:489
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:1230
virtual SwFormatColl * ChgFormatColl(SwFormatColl *)
Definition: node.cxx:1265
Definition: doc.hxx:195
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:780
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:749
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:152
SwNodes & GetNodes()
Definition: doc.hxx:418
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:365
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:413
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:787
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1874
const SwGrfFormatColls * GetGrfFormatColls() const
Definition: doc.hxx:815
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1329
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:753
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
Definition: doctxm.cxx:621
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:243
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:2164
void SetPrev(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2156
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:63
void ChgDefinedIn(const sw::FormatDropDefiner *pDefiner)
Get and set Modify pointer.
Definition: paratr.hxx:120
void SetEndNote(bool b)
Definition: atrftn.cxx:175
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: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:62
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2726
bool IsAlive(SwFrameFormat const *) const
not so fast check that given format is still alive (i.e. contained here)
Definition: docfmt.cxx:2148
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:1001
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:1008
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:960
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:969
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:1262
void CopyAttr(SwpHints const *pHts, const SwNodeOffset nNodeIdx, const sal_Int32 nStart, const sal_Int32 nEnd, const bool bCopyFields)
Definition: rolbck.cxx:1298
sal_uInt16 Count() const
Definition: rolbck.hxx:378
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: rolbck.cxx:1283
void AddDeleteFly(SwFrameFormat &, sal_uInt16 &rSetPos)
Definition: rolbck.cxx:1149
std::vector< std::unique_ptr< SwHistoryHint > > m_SwpHstry
Definition: rolbck.hxx:356
void AddChangeFlyAnchor(SwFrameFormat &rFormat)
Definition: rolbck.cxx:1143
sal_uInt16 SetTmpEnd(sal_uInt16 nTmpEnd)
Definition: rolbck.cxx:1241
void Add(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, SwNodeOffset nNodeIdx)
Definition: rolbck.cxx:1028
~SwHistory()
Definition: rolbck.cxx:1024
sal_uInt16 m_nEndDiff
Definition: rolbck.hxx:357
bool TmpRollback(SwDoc *pDoc, sal_uInt16 nStart, bool ToFirst=true)
Definition: rolbck.cxx:1216
bool Rollback(SwDoc *pDoc, sal_uInt16 nStart=0)
Definition: rolbck.cxx:1201
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:679
SwDoc & GetDoc()
Definition: node.hxx:233
bool IsStartNode() const
Definition: node.hxx:675
bool IsTableNode() const
Definition: node.hxx:691
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:187
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: rolbck.cxx:1379
SwRegHistory(SwHistory *pHst)
Definition: rolbck.cxx:1354
SwHistory *const m_pHistory
Definition: rolbck.hxx:415
o3tl::sorted_vector< sal_uInt16 > m_WhichIdSet
Definition: rolbck.hxx:414
void MakeSetWhichIds()
Definition: rolbck.cxx:1503
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:1429
void AddHint(SwTextAttr *pHt, const bool bNew)
Definition: rolbck.cxx:1424
void RegisterInModify(sw::BroadcastingModify *pRegIn, const SwNode &rNd)
Definition: rolbck.cxx:1489
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 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:426
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1917
TableFormulaUpdateFlags m_eFlags
Definition: hints.hxx:286
bool IsIntrnlName() const
Definition: cellfml.hxx:132
const SwTable & GetTable() const
Definition: node.hxx:542
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
SwTextAttr subclass for footnotes and endnotes.
Definition: txtftn.hxx:34
void CheckCondColl()
Definition: atrftn.cxx:580
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:310
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
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:874
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:5044
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:250
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:3153
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)
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< SvxFormatBreakItem > RES_BREAK(94)
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(59)
bool isCHRATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:470
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:270
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
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
Definition: pam.cxx:266
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:77
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
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