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 
63 {
64  return OUString();
65 }
66 
68 {
69  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHistoryHint"));
70  (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
71  (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"), BAD_CAST(typeid(*this).name()));
72  (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_eWhichId"),
73  BAD_CAST(OString::number(m_eWhichId).getStr()));
74  (void)xmlTextWriterEndElement(pWriter);
75 }
76 
79  , m_pAttr( pFormatHt->Clone() )
80  , m_nNodeIndex( nNd )
81 {
82  switch ( m_pAttr->Which() )
83  {
84  case RES_PAGEDESC:
85  static_cast<SwFormatPageDesc&>(*m_pAttr).ChgDefinedIn( nullptr );
86  break;
87  case RES_PARATR_DROP:
88  static_cast<SwFormatDrop&>(*m_pAttr).ChgDefinedIn(nullptr);
89  break;
90  case RES_BOXATR_FORMULA:
91  {
92  // save formulas always in plain text
93  SwTableBoxFormula& rNew = static_cast<SwTableBoxFormula&>(*m_pAttr);
94  if ( rNew.IsIntrnlName() )
95  {
96  const SwTableBoxFormula& rOld =
97  *static_cast<const SwTableBoxFormula*>(pFormatHt);
98  const SwNode* pNd = rOld.GetNodeOfFormula();
99  if ( pNd )
100  {
101  const SwTableNode* pTableNode = pNd->FindTableNode();
102  if (pTableNode)
103  {
104  SwTableFormulaUpdate aMsgHint( &pTableNode->GetTable() );
105  aMsgHint.m_eFlags = TBL_BOXNAME;
106  rNew.ChgDefinedIn( rOld.GetDefinedIn() );
107  rNew.ChangeState( &aMsgHint );
108  }
109  }
110  }
111  rNew.ChgDefinedIn( nullptr );
112  }
113  break;
114  }
115 }
116 
118 {
119  OUString aResult;
120 
121  switch (m_pAttr->Which())
122  {
123  case RES_BREAK:
124  switch (static_cast<SvxFormatBreakItem &>(*m_pAttr).GetBreak())
125  {
126  case SvxBreak::PageBefore:
127  case SvxBreak::PageAfter:
128  case SvxBreak::PageBoth:
129  aResult = SwResId(STR_UNDO_PAGEBREAKS);
130 
131  break;
132  case SvxBreak::ColumnBefore:
133  case SvxBreak::ColumnAfter:
134  case SvxBreak::ColumnBoth:
135  aResult = SwResId(STR_UNDO_COLBRKS);
136 
137  break;
138  default:
139  break;
140  }
141  break;
142  default:
143  break;
144  }
145 
146  return aResult;
147 }
148 
150 {
151  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHistorySetFormat"));
152  (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nNodeIndex"),
153  BAD_CAST(OString::number(sal_Int32(m_nNodeIndex)).getStr()));
154  SwHistoryHint::dumpAsXml(pWriter);
155 
156  if (m_pAttr)
157  {
158  m_pAttr->dumpAsXml(pWriter);
159  }
160 
161  (void)xmlTextWriterEndElement(pWriter);
162 }
163 
164 void SwHistorySetFormat::SetInDoc( SwDoc* pDoc, bool bTmpSet )
165 {
166  SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ];
167  if ( pNode->IsContentNode() )
168  {
169  static_cast<SwContentNode*>(pNode)->SetAttr( *m_pAttr );
170  }
171  else if ( pNode->IsTableNode() )
172  {
173  static_cast<SwTableNode*>(pNode)->GetTable().GetFrameFormat()->SetFormatAttr(
174  *m_pAttr );
175  }
176  else if ( pNode->IsStartNode() && (SwTableBoxStartNode ==
177  static_cast<SwStartNode*>(pNode)->GetStartNodeType()) )
178  {
179  SwTableNode* pTNd = pNode->FindTableNode();
180  if ( pTNd )
181  {
182  SwTableBox* pBox = pTNd->GetTable().GetTableBox( m_nNodeIndex );
183  if (pBox)
184  {
186  }
187  }
188  }
189 
190  if ( !bTmpSet )
191  {
192  m_pAttr.reset();
193  }
194 }
195 
197 {
198 }
199 
202  , m_nNodeIndex( nNodeIdx )
203  , m_nWhich( pFormatHt->Which() )
204 {
205 }
206 
208 {
209  SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ];
210  if ( pNode->IsContentNode() )
211  {
212  static_cast<SwContentNode*>(pNode)->ResetAttr( m_nWhich );
213  }
214  else if ( pNode->IsTableNode() )
215  {
216  static_cast<SwTableNode*>(pNode)->GetTable().GetFrameFormat()->
217  ResetFormatAttr( m_nWhich );
218  }
219 }
220 
223  , m_nNodeIndex( nNodePos )
224  , m_nStart( pTextHt->GetStart() )
225  , m_nEnd( pTextHt->GetAnyEnd() )
226  , m_bFormatIgnoreStart(pTextHt->IsFormatIgnoreStart())
227  , m_bFormatIgnoreEnd (pTextHt->IsFormatIgnoreEnd ())
228 {
229  // Caution: the following attributes generate no format attributes:
230  // - NoLineBreak, NoHyphen, Inserted, Deleted
231  // These cases must be handled separately !!!
232 
233  // a little bit complicated but works: first assign a copy of the
234  // default value and afterwards the values from text attribute
235  if ( RES_TXTATR_CHARFMT == pTextHt->Which() )
236  {
237  m_pAttr.reset( new SwFormatCharFormat( pTextHt->GetCharFormat().GetCharFormat() ) );
238  }
239  else
240  {
241  m_pAttr.reset( pTextHt->GetAttr().Clone() );
242  }
243 }
244 
246 {
247 }
248 
250 {
251  if (!m_pAttr)
252  return;
253 
254  if ( RES_TXTATR_CHARFMT == m_pAttr->Which() )
255  {
256  // ask the Doc if the CharFormat still exists
257  if (!pDoc->GetCharFormats()->ContainsFormat(static_cast<SwFormatCharFormat&>(*m_pAttr).GetCharFormat()))
258  return; // do not set, format does not exist
259  }
260 
261  SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
262  OSL_ENSURE( pTextNd, "SwHistorySetText::SetInDoc: not a TextNode" );
263 
264  if ( !pTextNd )
265  return;
266 
267  SwTextAttr *const pAttr = pTextNd->InsertItem(*m_pAttr, m_nStart, m_nEnd,
270  // shouldn't be possible to hit any error/merging path from here
271  assert(pAttr);
273  {
274  pAttr->SetFormatIgnoreStart(true);
275  }
276  if (m_bFormatIgnoreEnd)
277  {
278  pAttr->SetFormatIgnoreEnd(true);
279  }
280 }
281 
284  , m_pField( new SwFormatField( *pTextField->GetFormatField().GetField() ) )
285 {
286  // only copy if not Sys-FieldType
287  SwDoc& rDoc = pTextField->GetTextNode().GetDoc();
288 
289  m_nFieldWhich = m_pField->GetField()->GetTyp()->Which();
295  {
296  m_pFieldType = m_pField->GetField()->GetTyp()->Copy();
297  m_pField->GetField()->ChgTyp( m_pFieldType.get() ); // change field type
298  }
299  m_nNodeIndex = nNodePos;
300  m_nPos = pTextField->GetStart();
301 }
302 
304 {
305  return m_pField->GetField()->GetDescription();
306 }
307 
309 {
310 }
311 
313 {
314  if (!m_pField)
315  return;
316 
317  SwFieldType* pNewFieldType = m_pFieldType.get();
318  if ( !pNewFieldType )
319  {
320  pNewFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType( m_nFieldWhich );
321  }
322  else
323  {
324  // register type with the document
325  pNewFieldType = pDoc->getIDocumentFieldsAccess().InsertFieldType( *m_pFieldType );
326  }
327 
328  m_pField->GetField()->ChgTyp( pNewFieldType ); // change field type
329 
330  SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
331  OSL_ENSURE( pTextNd, "SwHistorySetTextField: no TextNode" );
332 
333  if ( pTextNd )
334  {
335  pTextNd->InsertItem( *m_pField, m_nPos, m_nPos,
337  }
338 }
339 
342  , m_RefName( pTextHt->GetRefMark().GetRefName() )
343  , m_nNodeIndex( nNodePos )
344  , m_nStart( pTextHt->GetStart() )
345  , m_nEnd( pTextHt->GetAnyEnd() )
346 {
347 }
348 
350 {
351  SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
352  OSL_ENSURE( pTextNd, "SwHistorySetRefMark: no TextNode" );
353  if ( !pTextNd )
354  return;
355 
356  SwFormatRefMark aRefMark( m_RefName );
357 
358  // if a reference mark without an end already exists here: must not insert!
359  if ( m_nStart != m_nEnd ||
361  {
362  pTextNd->InsertItem( aRefMark, m_nStart, m_nEnd,
364  }
365 }
366 
369  , m_TOXMark( pTextHt->GetTOXMark() )
370  , m_TOXName( m_TOXMark.GetTOXType()->GetTypeName() )
371  , m_eTOXTypes( m_TOXMark.GetTOXType()->GetType() )
372  , m_nNodeIndex( nNodePos )
373  , m_nStart( pTextHt->GetStart() )
374  , m_nEnd( pTextHt->GetAnyEnd() )
375 {
376  static_cast<SvtListener*>(&m_TOXMark)->EndListeningAll();
377 }
378 
379 SwTOXType* SwHistorySetTOXMark::GetSwTOXType(SwDoc& rDoc, TOXTypes eTOXTypes, const OUString& rTOXName)
380 {
381  // search for respective TOX type
382  const sal_uInt16 nCnt = rDoc.GetTOXTypeCount(eTOXTypes);
383  SwTOXType* pToxType = nullptr;
384  for ( sal_uInt16 n = 0; n < nCnt; ++n )
385  {
386  pToxType = const_cast<SwTOXType*>(rDoc.GetTOXType(eTOXTypes, n));
387  if (pToxType->GetTypeName() == rTOXName)
388  break;
389  pToxType = nullptr;
390  }
391 
392  if ( !pToxType ) // TOX type not found, create new
393  {
394  pToxType = const_cast<SwTOXType*>(
395  rDoc.InsertTOXType(SwTOXType(rDoc, eTOXTypes, rTOXName)));
396  }
397 
398  return pToxType;
399 }
400 
402 {
403  SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
404  OSL_ENSURE( pTextNd, "SwHistorySetTOXMark: no TextNode" );
405  if ( !pTextNd )
406  return;
407 
408  SwTOXType* pToxType = GetSwTOXType(*pDoc, m_eTOXTypes, m_TOXName);
409 
410  SwTOXMark aNew( m_TOXMark );
411  aNew.RegisterToTOXType( *pToxType );
412 
413  pTextNd->InsertItem( aNew, m_nStart, m_nEnd,
415 }
416 
417 bool SwHistorySetTOXMark::IsEqual( const SwTOXMark& rCmp ) const
418 {
419  return m_TOXName == rCmp.GetTOXType()->GetTypeName() &&
420  m_eTOXTypes == rCmp.GetTOXType()->GetType() &&
422  ( (TOX_INDEX == m_eTOXTypes)
423  ? ( m_TOXMark.GetPrimaryKey() == rCmp.GetPrimaryKey() &&
425  : m_TOXMark.GetLevel() == rCmp.GetLevel()
426  );
427 }
428 
430  sal_Int32 nAttrStart, sal_Int32 nAttrEnd, SwNodeOffset nNodePos )
432  , m_nNodeIndex( nNodePos ), m_nStart( nAttrStart ), m_nEnd( nAttrEnd )
433  , m_nAttr( nWhich )
434 {
435 }
436 
438 {
439  SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
440  OSL_ENSURE( pTextNd, "SwHistoryResetText: no TextNode" );
441  if ( pTextNd )
442  {
443  pTextNd->DeleteAttributes( m_nAttr, m_nStart, m_nEnd );
444  }
445 }
446 
449  , m_pUndo( new SwUndoSaveSection )
450  , m_FootnoteNumber( pTextFootnote->GetFootnote().GetNumStr() )
451  , m_nNodeIndex( nNodePos )
452  , m_nStart( pTextFootnote->GetStart() )
453  , m_bEndNote( pTextFootnote->GetFootnote().IsEndNote() )
454 {
455  OSL_ENSURE( pTextFootnote->GetStartNode(),
456  "SwHistorySetFootnote: Footnote without Section" );
457 
458  // keep the old NodePos (because who knows what later will be saved/deleted
459  // in SaveSection)
460  SwDoc& rDoc = const_cast<SwDoc&>(pTextFootnote->GetTextNode().GetDoc());
461  SwNode* pSaveNd = rDoc.GetNodes()[ m_nNodeIndex ];
462 
463  // keep pointer to StartNode of FootnoteSection and reset its attribute for now
464  // (as a result, its/all Frames will be deleted automatically)
465  SwNodeIndex aSttIdx( *pTextFootnote->GetStartNode() );
466  pTextFootnote->SetStartNode( nullptr, false );
467 
468  m_pUndo->SaveSection( aSttIdx );
469  m_nNodeIndex = pSaveNd->GetIndex();
470 }
471 
474  , m_FootnoteNumber( rTextFootnote.GetFootnote().GetNumStr() )
475  , m_nNodeIndex( SwTextFootnote_GetIndex( (&rTextFootnote) ) )
476  , m_nStart( rTextFootnote.GetStart() )
477  , m_bEndNote( rTextFootnote.GetFootnote().IsEndNote() )
478 {
479  OSL_ENSURE( rTextFootnote.GetStartNode(),
480  "SwHistorySetFootnote: Footnote without Section" );
481 }
482 
484 {
485  return SwResId(STR_FOOTNOTE);
486 }
487 
489 {
490 }
491 
493 {
494  SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
495  OSL_ENSURE( pTextNd, "SwHistorySetFootnote: no TextNode" );
496  if ( !pTextNd )
497  return;
498 
499  if (m_pUndo)
500  {
501  // set the footnote in the TextNode
502  SwFormatFootnote aTemp( m_bEndNote );
503  SwFormatFootnote& rNew = const_cast<SwFormatFootnote&>(
504  pDoc->GetAttrPool().Put(aTemp) );
505  if ( !m_FootnoteNumber.isEmpty() )
506  {
507  rNew.SetNumStr( m_FootnoteNumber );
508  }
509  SwTextFootnote* pTextFootnote = new SwTextFootnote( rNew, m_nStart );
510 
511  // create the section of the Footnote
512  SwNodeIndex aIdx( *pTextNd );
513  m_pUndo->RestoreSection( pDoc, &aIdx, SwFootnoteStartNode );
514  pTextFootnote->SetStartNode( &aIdx );
515  if ( m_pUndo->GetHistory() )
516  {
517  // create frames only now
518  m_pUndo->GetHistory()->Rollback( pDoc );
519  }
520 
521  pTextNd->InsertHint( pTextFootnote );
522  }
523  else
524  {
525  SwTextFootnote * const pFootnote =
526  static_cast<SwTextFootnote*>(
527  pTextNd->GetTextAttrForCharAt( m_nStart ));
528  assert(pFootnote);
529  SwFormatFootnote &rFootnote = const_cast<SwFormatFootnote&>(pFootnote->GetFootnote());
530  rFootnote.SetNumStr( m_FootnoteNumber );
531  if ( rFootnote.IsEndNote() != m_bEndNote )
532  {
533  rFootnote.SetEndNote( m_bEndNote );
534  pFootnote->CheckCondColl();
535  }
536  }
537 }
538 
540  SwNodeType nNodeWhich )
542  , m_pColl( pFormatColl )
543  , m_nNodeIndex( nNd )
544  , m_nNodeType( nNodeWhich )
545 {
546 }
547 
549 {
550  SwContentNode * pContentNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetContentNode();
551  OSL_ENSURE( pContentNd, "SwHistoryChangeFormatColl: no ContentNode" );
552 
553  // before setting the format, check if it is still available in the
554  // document. if it has been deleted, there is no undo!
555  if ( !(pContentNd && m_nNodeType == pContentNd->GetNodeType()) )
556  return;
557 
558  if ( SwNodeType::Text == m_nNodeType )
559  {
560  if (pDoc->GetTextFormatColls()->IsAlive(static_cast<SwTextFormatColl *>(m_pColl)))
561  {
562  pContentNd->ChgFormatColl( m_pColl );
563  }
564  }
565  else if (pDoc->GetGrfFormatColls()->IsAlive(static_cast<SwGrfFormatColl *>(m_pColl)))
566  {
567  pContentNd->ChgFormatColl( m_pColl );
568  }
569 }
570 
573  , m_pUndo( new SwUndoDelLayFormat( pFlyFormat ) )
574 {
575  OSL_ENSURE( pFlyFormat, "SwHistoryTextFlyCnt: no Format" );
576  m_pUndo->ChgShowSel( false );
577 }
578 
580 {
581 }
582 
584 {
586  assert(pISCS);
587  ::sw::UndoRedoContext context(*pDoc, *pISCS);
588  m_pUndo->UndoImpl(context);
589 }
590 
592 {
593  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHistoryTextFlyCnt"));
594  SwHistoryHint::dumpAsXml(pWriter);
595 
596  if (m_pUndo)
597  {
598  m_pUndo->dumpAsXml(pWriter);
599  }
600 
601  (void)xmlTextWriterEndElement(pWriter);
602 }
603 
605  const ::sw::mark::IMark& rBkmk,
606  bool bSavePos,
607  bool bSaveOtherPos)
609  , m_aName(rBkmk.GetName())
610  , m_bHidden(false)
611  , m_nNode(bSavePos ?
612  rBkmk.GetMarkPos().nNode.GetIndex() : SwNodeOffset(0))
613  , m_nOtherNode(bSaveOtherPos ?
614  rBkmk.GetOtherMarkPos().nNode.GetIndex() : SwNodeOffset(0))
615  , m_nContent(bSavePos ?
616  rBkmk.GetMarkPos().nContent.GetIndex() : 0)
617  , m_nOtherContent(bSaveOtherPos ?
618  rBkmk.GetOtherMarkPos().nContent.GetIndex() :0)
619  , m_bSavePos(bSavePos)
620  , m_bSaveOtherPos(bSaveOtherPos)
621  , m_bHadOtherPos(rBkmk.IsExpanded())
622  , m_eBkmkType(IDocumentMarkAccess::GetType(rBkmk))
623 {
624  const ::sw::mark::IBookmark* const pBookmark = dynamic_cast< const ::sw::mark::IBookmark* >(&rBkmk);
625  if(!pBookmark)
626  return;
627 
628  m_aKeycode = pBookmark->GetKeyCode();
629  m_aShortName = pBookmark->GetShortName();
630  m_bHidden = pBookmark->IsHidden();
631  m_aHideCondition = pBookmark->GetHideCondition();
632 
633  ::sfx2::Metadatable const*const pMetadatable(
634  dynamic_cast< ::sfx2::Metadatable const* >(pBookmark));
635  if (pMetadatable)
636  {
637  m_pMetadataUndo = pMetadatable->CreateUndo();
638  }
639 }
640 
642 {
643  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
644 
645  SwNodes& rNds = pDoc->GetNodes();
646  IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
647  std::optional<SwPaM> pPam;
648  ::sw::mark::IMark* pMark = nullptr;
649 
650  if(m_bSavePos)
651  {
652  SwContentNode* const pContentNd = rNds[m_nNode]->GetContentNode();
653  OSL_ENSURE(pContentNd,
654  "<SwHistoryBookmark::SetInDoc(..)>"
655  " - wrong node for a mark");
656 
657  // #111660# don't crash when nNode1 doesn't point to content node.
658  if(pContentNd)
659  pPam.emplace(*pContentNd, m_nContent);
660  }
661  else
662  {
663  pMark = *pMarkAccess->findMark(m_aName);
664  pPam.emplace(pMark->GetMarkPos());
665  }
666 
667  if(m_bSaveOtherPos)
668  {
669  SwContentNode* const pContentNd = rNds[m_nOtherNode]->GetContentNode();
670  OSL_ENSURE(pContentNd,
671  "<SwHistoryBookmark::SetInDoc(..)>"
672  " - wrong node for a mark");
673 
674  if (pPam && pContentNd)
675  {
676  pPam->SetMark();
677  pPam->GetMark()->nNode = m_nOtherNode;
678  pPam->GetMark()->nContent.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*>(
701  pMarkAccess->makeMark(*pPam, m_aName, m_eBkmkType, sw::mark::InsertMode::New));
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 
722 bool SwHistoryBookmark::IsEqualBookmark(const ::sw::mark::IMark& rBkmk)
723 {
724  return m_nNode == rBkmk.GetMarkPos().nNode.GetIndex()
725  && m_nContent == rBkmk.GetMarkPos().nContent.GetIndex()
726  && m_aName == rBkmk.GetName();
727 }
728 
729 SwHistoryNoTextFieldmark::SwHistoryNoTextFieldmark(const ::sw::mark::IFieldmark& rFieldMark)
731  , m_sType(rFieldMark.GetFieldname())
732  , m_nNode(rFieldMark.GetMarkPos().nNode.GetIndex())
733  , m_nContent(rFieldMark.GetMarkPos().nContent.GetIndex())
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  if(pContentNd)
764  pPam.emplace(*pContentNd, m_nContent-1);
765 
766  if (pPam)
767  {
768  IDocumentMarkAccess* pMarkAccess = rDoc.getIDocumentMarkAccess();
769  pMarkAccess->deleteFieldmarkAt(*pPam->GetPoint());
770  }
771 }
772 
773 SwHistoryTextFieldmark::SwHistoryTextFieldmark(const ::sw::mark::IFieldmark& rFieldMark)
775  , m_sName(rFieldMark.GetName())
776  , m_sType(rFieldMark.GetFieldname())
777  , m_nStartNode(rFieldMark.GetMarkStart().nNode.GetIndex())
778  , m_nStartContent(rFieldMark.GetMarkStart().nContent.GetIndex())
779  , m_nEndNode(rFieldMark.GetMarkEnd().nNode.GetIndex())
780  , m_nEndContent(rFieldMark.GetMarkEnd().nContent.GetIndex())
781 {
782  SwPosition const sepPos(sw::mark::FindFieldSep(rFieldMark));
783  m_nSepNode = sepPos.nNode.GetIndex();
784  m_nSepContent = sepPos.nContent.GetIndex();
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 
797  SwPaM const pam(*rNds[m_nStartNode]->GetContentNode(), m_nStartContent,
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 
860  case RES_BOXATR_FORMULA:
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 =
873  rSet.Get( RES_BOXATR_FORMULA );
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()->nNode.GetIndex() )
929  , m_nOldContentIndex( (RndStdIds::FLY_AT_CHAR == rFormat.GetAnchor().GetAnchorId())
930  ? rFormat.GetAnchor().GetContentAnchor()->nContent.GetIndex()
931  : COMPLETE_STRING )
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 {
977  if (!pDoc->GetSpzFrameFormats()->IsAlive(m_pFlyFormat))
978  return;
979 
980  SwFormatChain aChain;
981 
982  if (m_pPrevFormat &&
984  {
985  aChain.SetPrev( m_pPrevFormat );
987  aTmp.SetNext( m_pFlyFormat );
988  m_pPrevFormat->SetFormatAttr( aTmp );
989  }
990 
991  if (m_pNextFormat &&
993  {
994  aChain.SetNext( m_pNextFormat );
996  aTmp.SetPrev( m_pFlyFormat );
997  m_pNextFormat->SetFormatAttr( aTmp );
998  }
999 
1000  if ( aChain.GetNext() || aChain.GetPrev() )
1001  {
1002  m_pFlyFormat->SetFormatAttr( aChain );
1003  }
1004 }
1005 
1006 // -> #i27615#
1008  const OUString & sFormat)
1010  , m_OldSet(rSet), m_Format(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)?
1071 void 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:
1089  case RES_TXTATR_ANNOTATION:
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 
1113 void 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 
1122 void 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 
1155 void 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  const SwFormatChain* pChainItem;
1169  if( SfxItemState::SET == rFormat.GetItemState( RES_CHAIN, false,
1170  reinterpret_cast<const SfxPoolItem**>(&pChainItem) ))
1171  {
1172  assert(RES_FLYFRMFMT == nWh); // not supported on SdrObjects
1173  if( pChainItem->GetNext() || pChainItem->GetPrev() )
1174  {
1175  std::unique_ptr<SwHistoryHint> pHt(
1176  new SwHistoryChangeFlyChain(static_cast<SwFlyFrameFormat&>(rFormat), *pChainItem));
1177  m_SwpHstry.insert( m_SwpHstry.begin() + rSetPos++, std::move(pHt) );
1178  if ( pChainItem->GetNext() )
1179  {
1180  SwFormatChain aTmp( pChainItem->GetNext()->GetChain() );
1181  aTmp.SetPrev( nullptr );
1182  pChainItem->GetNext()->SetFormatAttr( aTmp );
1183  }
1184  if ( pChainItem->GetPrev() )
1185  {
1186  SwFormatChain aTmp( pChainItem->GetPrev()->GetChain() );
1187  aTmp.SetNext( nullptr );
1188  pChainItem->GetPrev()->SetFormatAttr( aTmp );
1189  }
1190  }
1191  rFormat.ResetFormatAttr( RES_CHAIN );
1192  }
1193  }
1194 }
1195 
1196 void SwHistory::Add( const SwTextFootnote& rFootnote )
1197 {
1198  std::unique_ptr<SwHistoryHint> pHt(new SwHistorySetFootnote( rFootnote ));
1199  m_SwpHstry.push_back( std::move(pHt) );
1200 }
1201 
1202 // #i27615#
1203 void SwHistory::Add(const SfxItemSet & rSet, const SwCharFormat & rFormat)
1204 {
1205  std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeCharFormat(rSet, rFormat.GetName()));
1206  m_SwpHstry.push_back( std::move(pHt) );
1207 }
1208 
1209 bool SwHistory::Rollback( SwDoc* pDoc, sal_uInt16 nStart )
1210 {
1211  if ( !Count() )
1212  return false;
1213 
1214  for ( sal_uInt16 i = Count(); i > nStart ; )
1215  {
1216  SwHistoryHint * pHHt = m_SwpHstry[ --i ].get();
1217  pHHt->SetInDoc( pDoc, false );
1218  }
1219  m_SwpHstry.erase( m_SwpHstry.begin() + nStart, m_SwpHstry.end() );
1220  m_nEndDiff = 0;
1221  return true;
1222 }
1223 
1224 bool SwHistory::TmpRollback( SwDoc* pDoc, sal_uInt16 nStart, bool bToFirst )
1225 {
1226  sal_uInt16 nEnd = Count() - m_nEndDiff;
1227  if ( !Count() || !nEnd || nStart >= nEnd )
1228  return false;
1229 
1230  if ( bToFirst )
1231  {
1232  for ( ; nEnd > nStart; ++m_nEndDiff )
1233  {
1234  SwHistoryHint* pHHt = m_SwpHstry[ --nEnd ].get();
1235  pHHt->SetInDoc( pDoc, true );
1236  }
1237  }
1238  else
1239  {
1240  for ( ; nStart < nEnd; ++m_nEndDiff, ++nStart )
1241  {
1242  SwHistoryHint* pHHt = m_SwpHstry[ nStart ].get();
1243  pHHt->SetInDoc( pDoc, true );
1244  }
1245  }
1246  return true;
1247 }
1248 
1249 sal_uInt16 SwHistory::SetTmpEnd( sal_uInt16 nNewTmpEnd )
1250 {
1251  OSL_ENSURE( nNewTmpEnd <= Count(), "SwHistory::SetTmpEnd: out of bounds" );
1252 
1253  const sal_uInt16 nOld = Count() - m_nEndDiff;
1254  m_nEndDiff = Count() - nNewTmpEnd;
1255 
1256  // for every SwHistoryFlyCnt, call the Redo of its UndoObject.
1257  // this saves the formats of the flys!
1258  for ( sal_uInt16 n = nOld; n < nNewTmpEnd; n++ )
1259  {
1260  if ( HSTRY_FLYCNT == (*this)[ n ]->Which() )
1261  {
1262  static_cast<SwHistoryTextFlyCnt*>((*this)[ n ])
1263  ->GetUDelLFormat()->RedoForRollback();
1264  }
1265  }
1266 
1267  return nOld;
1268 }
1269 
1271  const SfxItemSet& rSet,
1272  SwNodeOffset nNodeIdx)
1273 {
1274  if(!rSet.Count())
1275  return;
1276 
1277  SfxItemIter aIter(rSet);
1278  const SfxPoolItem* pItem = aIter.GetCurItem();
1279  do
1280  {
1281  if(!IsInvalidItem(pItem))
1282  {
1283  Add(pItem, pItem, nNodeIdx);
1284  }
1285 
1286  pItem = aIter.NextItem();
1287 
1288  } while(pItem);
1289 }
1290 
1292 {
1293  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHistory"));
1294  (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1295 
1296  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_SwpHstry"));
1297  for (const auto& pHistory : m_SwpHstry)
1298  {
1299  pHistory->dumpAsXml(pWriter);
1300  }
1301  (void)xmlTextWriterEndElement(pWriter);
1302 
1303  (void)xmlTextWriterEndElement(pWriter);
1304 }
1305 
1307  SwpHints const * pHts,
1308  const SwNodeOffset nNodeIdx,
1309  const sal_Int32 nStart,
1310  const sal_Int32 nEnd,
1311  const bool bCopyFields )
1312 {
1313  if( !pHts )
1314  return;
1315 
1316  // copy all attributes of the TextNode in the area from nStart to nEnd
1317  SwTextAttr* pHt;
1318  for( size_t n = 0; n < pHts->Count(); ++n )
1319  {
1320  // nAttrStt must even be set when !pEndIdx
1321  pHt = pHts->Get(n);
1322  const sal_Int32 nAttrStt = pHt->GetStart();
1323  const sal_Int32 * pEndIdx = pHt->GetEnd();
1324  if( nullptr != pEndIdx && nAttrStt > nEnd )
1325  break;
1326 
1327  // never copy Flys and Footnote !!
1328  bool bNextAttr = false;
1329  switch( pHt->Which() )
1330  {
1331  case RES_TXTATR_FIELD:
1332  case RES_TXTATR_ANNOTATION:
1333  case RES_TXTATR_INPUTFIELD:
1334  if( !bCopyFields )
1335  bNextAttr = true;
1336  break;
1337  case RES_TXTATR_FLYCNT:
1338  case RES_TXTATR_FTN:
1339  bNextAttr = true;
1340  break;
1341  }
1342 
1343  if( bNextAttr )
1344  continue;
1345 
1346  // save all attributes that are somehow in this area
1347  if ( nStart <= nAttrStt )
1348  {
1349  if ( nEnd > nAttrStt )
1350  {
1351  Add( pHt, nNodeIdx, false );
1352  }
1353  }
1354  else if ( pEndIdx && nStart < *pEndIdx )
1355  {
1356  Add( pHt, nNodeIdx, false );
1357  }
1358  }
1359 }
1360 
1361 // Class to register the history at a Node, Format, HintsArray, ...
1363  : SwClient( nullptr )
1364  , m_pHistory( pHst )
1365  , m_nNodeIndex( NODE_OFFSET_MAX )
1366 {
1367  MakeSetWhichIds();
1368 }
1369 
1371  SwHistory* pHst )
1372  : SwClient( pRegIn )
1373  , m_pHistory( pHst )
1374  , m_nNodeIndex( rNd.GetIndex() )
1375 {
1376  MakeSetWhichIds();
1377 }
1378 
1380  : SwClient( nullptr )
1381  , m_pHistory( pHst )
1382  , m_nNodeIndex( rNd.GetIndex() )
1383 {
1384  MakeSetWhichIds();
1385 }
1386 
1388 {
1389  if (rHint.GetId() != SfxHintId::SwLegacyModify)
1390  return;
1391  auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
1392  if ( !(m_pHistory && pLegacyHint->m_pNew && pLegacyHint->m_pOld != pLegacyHint->m_pNew) )
1393  return;
1394 
1395  if ( pLegacyHint->m_pNew->Which() < POOLATTR_END )
1396  {
1397  if(RES_UPDATE_ATTR == pLegacyHint->m_pNew->Which())
1398  {
1399  m_pHistory->Add(pLegacyHint->m_pOld, pLegacyHint->m_pNew, m_nNodeIndex);
1400  }
1401  else
1402  {
1403  OSL_ENSURE(false, "Unexpected update attribute (!)");
1404  }
1405  }
1406  else if (pLegacyHint->m_pOld && RES_ATTRSET_CHG == pLegacyHint->m_pNew->Which())
1407  {
1408  std::unique_ptr<SwHistoryHint> pNewHstr;
1409  const SfxItemSet& rSet = *static_cast< const SwAttrSetChg* >(pLegacyHint->m_pOld)->GetChgSet();
1410 
1411  if ( 1 < rSet.Count() )
1412  {
1413  pNewHstr.reset( new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet ) );
1414  }
1415  else if (const SfxPoolItem* pItem = SfxItemIter(rSet).GetCurItem())
1416  {
1417  if ( m_WhichIdSet.count( pItem->Which() ) )
1418  {
1419  pNewHstr.reset( new SwHistorySetFormat( pItem, m_nNodeIndex ) );
1420  }
1421  else
1422  {
1423  pNewHstr.reset( new SwHistoryResetFormat( pItem, m_nNodeIndex ) );
1424  }
1425  }
1426 
1427  if (pNewHstr)
1428  m_pHistory->m_SwpHstry.push_back( std::move(pNewHstr) );
1429  }
1430 }
1431 
1432 void SwRegHistory::AddHint( SwTextAttr* pHt, const bool bNew )
1433 {
1434  m_pHistory->Add( pHt, m_nNodeIndex, bNew );
1435 }
1436 
1438  sal_Int32 const nStart, sal_Int32 const nEnd, SetAttrMode const nFlags,
1439  SwTextAttr **ppNewTextAttr )
1440 {
1441  if( !rSet.Count() )
1442  return false;
1443 
1444  SwTextNode * const pTextNode =
1445  dynamic_cast<SwTextNode *>(GetRegisteredIn());
1446 
1447  OSL_ENSURE(pTextNode, "SwRegHistory not registered at text node?");
1448  if (!pTextNode)
1449  return false;
1450 
1451  if (m_pHistory)
1452  {
1453  pTextNode->GetOrCreateSwpHints().Register(this);
1454  }
1455 
1456  const bool bInserted = pTextNode->SetAttr( rSet, nStart, nEnd, nFlags, ppNewTextAttr );
1457 
1458  // Caution: The array can be deleted when inserting an attribute!
1459  // This can happen when the value that should be added first deletes
1460  // an existing attribute but does not need to be added itself because
1461  // the paragraph attributes are identical
1462  // ( -> bForgetAttr in SwpHints::Insert )
1463  if ( pTextNode->GetpSwpHints() && m_pHistory )
1464  {
1465  pTextNode->GetpSwpHints()->DeRegister();
1466  }
1467 
1468 #ifndef NDEBUG
1469  if ( m_pHistory && bInserted )
1470  {
1471  SfxItemIter aIter(rSet);
1472  for (SfxPoolItem const* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1473  { // check that the history recorded a hint to reset every item
1474  sal_uInt16 const nWhich(pItem->Which());
1475  sal_uInt16 const nExpected(
1476  (isCHRATR(nWhich) || RES_TXTATR_UNKNOWN_CONTAINER == nWhich)
1478  : nWhich);
1479  if (RES_TXTATR_AUTOFMT == nExpected)
1480  continue; // special case, may get set on text node itself
1481  // tdf#105077 even worse, node's set could cause
1482  // nothing at all to be inserted
1483  assert(std::any_of(
1484  m_pHistory->m_SwpHstry.begin(), m_pHistory->m_SwpHstry.end(),
1485  [nExpected](std::unique_ptr<SwHistoryHint> const& pHint) -> bool {
1486  SwHistoryResetText const*const pReset(
1487  dynamic_cast<SwHistoryResetText const*>(pHint.get()));
1488  return pReset && (pReset->GetWhich() == nExpected);
1489  }));
1490  }
1491  }
1492 #endif
1493 
1494  return bInserted;
1495 }
1496 
1498 {
1499  if ( m_pHistory && pRegIn )
1500  {
1501  pRegIn->Add( this );
1502  m_nNodeIndex = rNd.GetIndex();
1503  MakeSetWhichIds();
1504  }
1505  else
1506  {
1507  m_WhichIdSet.clear();
1508  }
1509 }
1510 
1512 {
1513  if (!m_pHistory) return;
1514 
1515  m_WhichIdSet.clear();
1516 
1517  if( !GetRegisteredIn() )
1518  return;
1519 
1520  const SfxItemSet* pSet = nullptr;
1521  if( auto pContentNode = dynamic_cast< const SwContentNode *>( GetRegisteredIn() ) )
1522  {
1523  pSet = pContentNode->GetpSwAttrSet();
1524  }
1525  else if ( auto pSwFormat = dynamic_cast< const SwFormat *>( GetRegisteredIn() ) )
1526  {
1527  pSet = &pSwFormat->GetAttrSet();
1528  }
1529  if( pSet && pSet->Count() )
1530  {
1531  SfxItemIter aIter( *pSet );
1532  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1533  {
1534  sal_uInt16 nW = pItem->Which();
1535  m_WhichIdSet.insert( nW );
1536  }
1537  }
1538 }
1539 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const std::unique_ptr< SwFormatField > m_pField
Definition: rolbck.hxx:138
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:241
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:207
Starts a section of nodes in the document model.
Definition: node.hxx:313
History object containing all information used during undo / redo of text form field insertion...
Definition: rolbck.hxx:288
const OUString m_sType
Definition: rolbck.hxx:281
const SwGrfFormatColls * GetGrfFormatColls() const
Definition: doc.hxx:806
TOXTypes
Definition: toxe.hxx:39
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
const TOXTypes m_eTOXTypes
Definition: rolbck.hxx:170
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: rolbck.cxx:149
void SetEndNote(bool b)
Definition: atrftn.cxx:173
SwHistoryNoTextFieldmark(const ::sw::mark::IFieldmark &rFieldMark)
Definition: rolbck.cxx:729
SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:417
void Add(SwClient *pDepend)
Definition: calbck.cxx:173
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:222
const std::unique_ptr< SwUndoSaveSection, o3tl::default_delete< SwUndoSaveSection > > m_pUndo
Definition: rolbck.hxx:203
sal_uInt16 GetWhich() const
Definition: rolbck.hxx:195
Marks a position in the document model.
Definition: pam.hxx:36
std::vector< std::unique_ptr< SwHistoryHint > > m_SwpHstry
Definition: rolbck.hxx:357
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
Definition: swtable.cxx:1336
SwHistoryChangeFormatColl(SwFormatColl *pColl, SwNodeOffset nNode, SwNodeType nNodeWhich)
Definition: rolbck.cxx:539
bool isCHRATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:476
OUString m_aName
const sal_Int32 m_nStart
Definition: rolbck.hxx:186
const sal_uInt16 m_nWhich
Definition: rolbck.hxx:109
virtual const SwRootFrame * GetCurrentLayout() const =0
OUString const & GetPrimaryKey() const
Definition: tox.hxx:634
constexpr SwNodeOffset NODE_OFFSET_MAX(SAL_MAX_INT32)
const sal_uInt16 m_nAttr
Definition: rolbck.hxx:188
const bool m_bHadOtherPos
Definition: rolbck.hxx:266
size_type count(const Value &v) const
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
Definition: ndtxt.cxx:4832
void SetStartNode(const SwNodeIndex *pNode, bool bDelNodes=true)
Definition: atrftn.cxx:295
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:226
SwHistoryChangeCharFormat(const SfxItemSet &rSet, const OUString &sFormat)
Definition: rolbck.cxx:1007
static SwContentNode * GetContentNode(SwDoc &rDoc, SwNodeIndex &rIdx, bool bNext)
Definition: fltshell.cxx:53
const sal_Int32 m_nEndContent
Definition: rolbck.hxx:301
bool Rollback(SwDoc *pDoc, sal_uInt16 nStart=0)
Definition: rolbck.cxx:1209
const bool m_bSavePos
Definition: rolbck.hxx:264
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
SwHistorySetFootnote(SwTextFootnote *pTextFootnote, SwNodeOffset nNode)
Definition: rolbck.cxx:447
SwNodeIndex nNode
Definition: pam.hxx:38
const SwTOXType * InsertTOXType(const SwTOXType &rTyp)
Definition: doctxm.cxx:628
const SfxItemSet m_OldSet
Definition: rolbck.hxx:343
virtual const sal_Int32 * GetEnd() const
end position
Definition: txatbase.cxx:48
SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:205
void CheckCondColl()
Definition: atrftn.cxx:573
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:108
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:478
virtual ~SwHistorySetFormat() override
Definition: rolbck.cxx:196
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1213
sal_Int64 n
Provides access to the marks of a document.
SwNodeOffset m_nSepNode
Definition: rolbck.hxx:302
Definition: doc.hxx:188
void SetNumStr(const OUString &rStr)
Definition: fmtftn.hxx:73
SwHistorySetText(SwTextAttr *pTextHt, SwNodeOffset nNode)
Definition: rolbck.cxx:221
const SwNodeOffset m_nStartNode
Definition: rolbck.hxx:298
void SetFormatIgnoreStart(bool bFlag)
Definition: txatbase.hxx:108
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(57)
virtual const SwPosition & GetMarkPos() const =0
SwPosition FindFieldSep(IFieldmark const &rMark)
return position of the CH_TXT_ATR_FIELDSEP for rMark
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
virtual void SetInDoc(SwDoc *pDoc, bool) override
Definition: rolbck.cxx:737
bool IsEqual(const SwTOXMark &rCmp) const
Definition: rolbck.cxx:417
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:312
virtual OUString GetDescription() const
Definition: rolbck.cxx:62
SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:140
bool TmpRollback(SwDoc *pDoc, sal_uInt16 nStart, bool ToFirst=true)
Definition: rolbck.cxx:1224
bool IsEndNote() const
Definition: fmtftn.hxx:71
const sw::BroadcastingModify * GetDefinedIn() const
Definition: cellatr.hxx:64
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1790
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: rolbck.cxx:1291
bool ContainsFormat(const SwCharFormat *pFormat) const
fast check if given format is contained here pFormat must not have been deleted
Definition: chrfmt.cxx:109
const SwTOXType * GetTOXType() const
Definition: tox.hxx:576
void SetFormatIgnoreEnd(bool bFlag)
Definition: txatbase.hxx:109
sal_Int32 m_nSepContent
Definition: rolbck.hxx:303
sal_uInt16 Which() const
Definition: txatbase.hxx:114
void SetPrev(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2131
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:171
const sal_Int32 m_nEnd
Definition: rolbck.hxx:122
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(152)
sal_Int32 GetAnyEnd() const
end (if available), else start
Definition: txatbase.hxx:157
void ChangeState(const SfxPoolItem *pItem)
Definition: cellatr.cxx:97
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(59)
For old documents the Field-Which IDs must be preserved !!!
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:744
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:401
SfxHintId GetId() const
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet)=0
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:437
virtual ~SwHistorySetText() override
Definition: rolbck.cxx:245
void AddDeleteFly(SwFrameFormat &, sal_uInt16 &rSetPos)
Definition: rolbck.cxx:1155
bool IsAlive(SwFrameFormat const *) const
not so fast check that given format is still alive (i.e. contained here)
Definition: docfmt.cxx:2159
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:3012
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
const SfxPoolItem * NextItem()
const sal_Int32 m_nStart
Definition: rolbck.hxx:172
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:156
const SwNodeOffset m_nNode
Definition: rolbck.hxx:282
OUString m_sName
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:349
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: rolbck.cxx:67
SwNodeType GetNodeType() const
Definition: node.hxx:146
void RegisterInModify(sw::BroadcastingModify *pRegIn, const SwNode &rNd)
Definition: rolbck.cxx:1497
SwIndex nContent
Definition: pam.hxx:39
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo
Definition: rolbck.hxx:268
void CopyAttr(SwpHints const *pHts, const SwNodeOffset nNodeIdx, const sal_Int32 nStart, const sal_Int32 nEnd, const bool bCopyFields)
Definition: rolbck.cxx:1306
size_t pos
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
const IDocumentMarkAccess::MarkType m_eBkmkType
Definition: rolbck.hxx:267
History object containing all information used during undo / redo of checkbox and drop-down form fiel...
Definition: rolbck.hxx:273
SwFlyFrameFormat *const m_pPrevFormat
Definition: rolbck.hxx:332
const OUString & GetName() const
Definition: format.hxx:115
constexpr TypedWhichId< SwFormatDrop > RES_PARATR_DROP(70)
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.
std::unique_ptr< SwFieldType > m_pFieldType
! beware of the order for the declaration of the unique_ptrs.
Definition: rolbck.hxx:137
bool IsEqualBookmark(const ::sw::mark::IMark &rBkmk)
Definition: rolbck.cxx:722
sal_Int32 GetStart() const
Definition: txatbase.hxx:86
bool IsStartNode() const
Definition: node.hxx:626
const OUString m_FootnoteNumber
Definition: rolbck.hxx:204
OUString m_aHideCondition
Definition: rolbck.hxx:258
SwHistoryChangeFlyChain(SwFlyFrameFormat &rFormat, const SwFormatChain &rAttr)
Definition: rolbck.cxx:966
virtual OUString GetDescription() const override
Definition: rolbck.cxx:483
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:1272
const SwTable & GetTable() const
Definition: node.hxx:500
sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const
Manage table of content types.
Definition: doctxm.cxx:610
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
virtual OUString GetDescription() const override
Definition: rolbck.cxx:117
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:154
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
const sal_Int32 m_nContent
Definition: rolbck.hxx:283
const OUString m_sName
Definition: rolbck.hxx:296
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(58)
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:583
virtual void SetKeyCode(const vcl::KeyCode &)=0
const SwNodeOffset m_nOldNodeIndex
Definition: rolbck.hxx:322
const sal_Int32 m_nEnd
Definition: rolbck.hxx:158
SwHistorySetTOXMark(const SwTextTOXMark *pTextHt, SwNodeOffset nNode)
Definition: rolbck.cxx:367
SwHistoryTextFieldmark(const ::sw::mark::IFieldmark &rFieldMark)
Definition: rolbck.cxx:773
virtual void SetShortName(const OUString &)=0
SwHistory *const m_pHistory
Definition: rolbck.hxx:416
std::unique_ptr< SfxPoolItem > m_pAttr
Definition: rolbck.hxx:94
const SwNodeOffset m_nNode
Definition: rolbck.hxx:260
Base class for various Writer styles.
Definition: format.hxx:46
bool IsAlive(typename std::remove_pointer< Value >::type const *const p) const
check that given format is still alive (i.e. contained here)
Definition: docary.hxx:141
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: rolbck.cxx:1387
virtual std::unique_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark)=0
Deletes a mark.
const OUString & GetAlternativeText() const
Definition: tox.hxx:570
OUString m_aShortName
Definition: rolbck.hxx:256
SwHistoryTextFlyCnt(SwFrameFormat *const pFlyFormat)
Definition: rolbck.cxx:571
bool IsContentNode() const
Definition: node.hxx:630
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
struct _xmlTextWriter * xmlTextWriterPtr
virtual void Hide(bool hide)=0
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:935
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:59
size_t Count() const
Definition: ndhints.hxx:142
void DeRegister()
deregister the currently registered History
Definition: ndhints.hxx:197
SwNodeType
Definition: ndtyp.hxx:28
constexpr TypedWhichId< SwUpdateAttr > RES_UPDATE_ATTR(167)
SwTextAttr * Get(size_t nPos) const
Definition: ndhints.hxx:144
const OUString m_TOXName
Definition: rolbck.hxx:169
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
const SwNodeOffset m_nOtherNode
Definition: rolbck.hxx:261
SwFieldIds m_nFieldWhich
Definition: rolbck.hxx:142
SwDoc & GetDoc()
Definition: node.hxx:213
o3tl::sorted_vector< sal_uInt16 > m_WhichIdSet
Definition: rolbck.hxx:415
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
const OUString m_aName
Definition: rolbck.hxx:255
virtual ~SwHistorySetTextField() override
Definition: rolbck.cxx:308
bool IsIntrnlName() const
Definition: cellfml.hxx:132
SwHistoryResetFormat(const SfxPoolItem *pFormatHt, SwNodeOffset nNodeIdx)
Definition: rolbck.cxx:200
SetAttrMode
Definition: swtypes.hxx:133
void ChgDefinedIn(const sw::BroadcastingModify *pNew)
Definition: fmtpdsc.hxx:69
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:310
SwContentNode * GetContentNode()
Definition: node.hxx:617
SwNodeOffset GetIndex() const
Definition: node.hxx:292
const bool m_bEndNote
Definition: rolbck.hxx:207
sal_uInt16 Count() const
FlyAnchors.
Definition: fmtanchr.hxx:34
sal_uInt16 GetLevel() const
Definition: tox.hxx:628
const SwNodeOffset m_nEndNode
Definition: rolbck.hxx:300
SwHistorySetRefMark(const SwTextRefMark *pTextHt, SwNodeOffset nNode)
Definition: rolbck.cxx:340
void RegisterToTOXType(SwTOXType &rMark)
Definition: tox.cxx:136
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2704
virtual void SetInDoc(SwDoc *pDoc, bool) override
Definition: rolbck.cxx:787
const OUString & GetTypeName() const
Definition: tox.hxx:690
std::shared_ptr< MetadatableUndo > CreateUndo() const
const sal_Int32 m_nStart
Definition: rolbck.hxx:121
std::unique_ptr< SwUndoDelLayFormat > m_pUndo
Definition: rolbck.hxx:233
const sal_Int32 m_nStart
Definition: rolbck.hxx:157
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:388
virtual ~SwHistorySetFootnote() override
Definition: rolbck.cxx:488
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:31
SwHistorySetTextField(const SwTextField *pTextField, SwNodeOffset nNode)
Definition: rolbck.cxx:282
Marks a node in the document model.
Definition: ndindex.hxx:32
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:695
#define SwTextFootnote_GetIndex(pFIdx)
Definition: ftnidx.hxx:34
virtual sw::mark::IFieldmark * makeFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType, SwPosition const *pSepPos=nullptr)=0
SwHistorySetFormat(const SfxPoolItem *pFormatHt, SwNodeOffset nNode)
Definition: rolbck.cxx:77
void Register(SwRegHistory *pHist)
register a History, which receives all attribute changes (for Undo)
Definition: ndhints.hxx:195
virtual void SetHideCondition(const OUString &)=0
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:492
virtual SwFormatColl * ChgFormatColl(SwFormatColl *)
Definition: node.cxx:1248
SwFrameFormat & m_rFormat
Definition: rolbck.hxx:321
virtual void deleteFieldmarkAt(const SwPosition &rPos)=0
Represents the style of a text portion.
Definition: charfmt.hxx:26
attention: NOHINTADJUST prevents MergePortions! when using this need to pay attention to ignore start...
void AddChangeFlyAnchor(SwFrameFormat &rFormat)
Definition: rolbck.cxx:1149
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:204
virtual sw::mark::IFieldmark * makeNoTextFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType)=0
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
const sal_Int32 m_nStart
Definition: rolbck.hxx:206
SwFlyFrameFormat * GetNext() const
Definition: fmtcnct.hxx:54
constexpr sal_uInt16 POOLATTR_END(RES_UNKNOWNATR_END)
The Undo actions need to create new Shell cursors.
sal_uInt16 Count() const
Definition: rolbck.hxx:379
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
void Add(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, SwNodeOffset nNodeIdx)
Definition: rolbck.cxx:1034
void ChgDefinedIn(const sw::BroadcastingModify *pNew)
Definition: cellatr.hxx:65
void ResetInDoc(SwDoc &rDoc)
Definition: rolbck.cxx:813
const OUString m_RefName
Definition: rolbck.hxx:155
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: doc.hxx:771
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:95
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
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:1721
void AddHint(SwTextAttr *pHt, const bool bNew)
Definition: rolbck.cxx:1432
const sal_Int32 m_nOldContentIndex
Definition: rolbck.hxx:323
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:624
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(114)
SwCharFormat * GetCharFormat() const
Definition: fchrfmt.hxx:70
An SwTextAttr container, stores all directly formatted text portions for a text node.
Definition: ndhints.hxx:67
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:740
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
OUString const & GetSecondaryKey() const
Definition: tox.hxx:640
virtual const SwNode * GetNodeOfFormula() const override
Get node type of the node containing this formula.
Definition: cellatr.cxx:85
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:185
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:778
virtual SwFieldType * InsertFieldType(const SwFieldType &)=0
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:975
const sal_Int32 m_nContent
Definition: rolbck.hxx:262
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: rolbck.cxx:591
const sal_Int32 m_nEnd
Definition: rolbck.hxx:187
sal_Int32 GetIndex() const
Definition: index.hxx:91
virtual ~SwHistoryTextFlyCnt() override
Definition: rolbck.cxx:579
void MakeSetWhichIds()
Definition: rolbck.cxx:1511
SwNodes & GetNodes()
Definition: doc.hxx:409
constexpr TypedWhichId< SwTableBoxFormula > RES_BOXATR_FORMULA(151)
SfxItemSet m_OldSet
Definition: rolbck.hxx:308
SwTOXMark m_TOXMark
Definition: rolbck.hxx:168
void ChgDefinedIn(const sw::FormatDropDefiner *pDefiner)
Get and set Modify pointer.
Definition: paratr.hxx:120
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:249
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
sal_uInt16 SetTmpEnd(sal_uInt16 nTmpEnd)
Definition: rolbck.cxx:1249
SwFlyFrameFormat *const m_pFlyFormat
Definition: rolbck.hxx:334
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:165
SwHistoryResetText(sal_uInt16 nWhich, sal_Int32 nStt, sal_Int32 nEnd, SwNodeOffset nNode)
Definition: rolbck.cxx:429
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:406
const OUString m_Format
Definition: rolbck.hxx:344
SwFlyFrameFormat *const m_pNextFormat
Definition: rolbck.hxx:333
constexpr TypedWhichId< SwTOXMark > RES_TXTATR_TOXMARK(47)
const OUString m_sType
Definition: rolbck.hxx:297
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:548
const sal_Int32 m_nStartContent
Definition: rolbck.hxx:299
void ResetInDoc(SwDoc &rDoc)
Definition: rolbck.cxx:755
~SwHistory()
Definition: rolbck.cxx:1030
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:164
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1763
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
TOXTypes GetType() const
Definition: tox.hxx:693
virtual void SetInDoc(SwDoc *pDoc, bool) override
Definition: rolbck.cxx:641
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:357
bool InsertHint(SwTextAttr *const pAttr, const SetAttrMode nMode=SetAttrMode::DEFAULT)
Insert pAttr into hints array.
Definition: thints.cxx:1307
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:58
const bool m_bSaveOtherPos
Definition: rolbck.hxx:265
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:163
SwNodeIndex * GetStartNode() const
Definition: txtftn.hxx:41
const HISTORY_HINT m_eWhichId
Definition: rolbck.hxx:81
vcl::KeyCode m_aKeycode
Definition: rolbck.hxx:259
void SetNext(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2139
RndStdIds
bool IsTableNode() const
Definition: node.hxx:642
const sal_Int32 m_nEnd
Definition: rolbck.hxx:173
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:900
std::unique_ptr< SfxPoolItem > m_pAttr
Definition: rolbck.hxx:119
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
Definition: doctxm.cxx:619
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps...
Definition: paratr.hxx:62
TableFormulaUpdateFlags m_eFlags
Definition: hints.hxx:268
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
const SwFormatCharFormat & GetCharFormat() const
Definition: txatbase.hxx:183
bool InsertItems(const SfxItemSet &rSet, sal_Int32 const nStart, sal_Int32 const nEnd, SetAttrMode const nFlags, SwTextAttr **ppNewTextAttr)
Definition: rolbck.cxx:1437
std::pair< const_iterator, bool > insert(Value &&x)
bool IsInvalidItem(const SfxPoolItem *pItem)
SwHistoryBookmark(const ::sw::mark::IMark &rBkmk, bool bSavePos, bool bSaveOtherPos)
Definition: rolbck.cxx:604
const SwNodeOffset m_nNodeIndex
Definition: rolbck.hxx:120
SwFlyFrameFormat * GetPrev() const
Definition: fmtcnct.hxx:53
SwFormatColl *const m_pColl
Definition: rolbck.hxx:221
void CopyFormatAttr(const SfxItemSet &rSet, SwNodeOffset nNodeIdx)
Definition: rolbck.cxx:1270
virtual bool IsExpanded() const =0
const SwNodeType m_nNodeType
Definition: rolbck.hxx:223
sal_uInt16 m_nEndDiff
Definition: rolbck.hxx:358
std::vector< sal_uInt16 > m_ResetArray
Definition: rolbck.hxx:309
::sw::IShellCursorSupplier * GetIShellCursorSupplier()
Definition: doccorr.cxx:351
bool m_bFormatIgnoreStart
Definition: rolbck.hxx:123
const SwTextNode & GetTextNode() const
Definition: txtftn.hxx:70
void RestoreMetadata(std::shared_ptr< MetadatableUndo > const &i_pUndo)
static SwTOXType * GetSwTOXType(SwDoc &rDoc, TOXTypes eTOXTypes, const OUString &rTOXName)
Definition: rolbck.cxx:379
SwHistoryChangeFlyAnchor(SwFrameFormat &rFormat)
Definition: rolbck.cxx:925
sal_uInt16 Which() const
virtual void SetInDoc(SwDoc *pDoc, bool bTmpSet) override
Definition: rolbck.cxx:1014
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_TXTATR_UNKNOWN_CONTAINER(54)
const SfxPoolItem * GetCurItem() const
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1319
SwRegHistory(SwHistory *pHst)
Definition: rolbck.cxx:1362
const sal_Int32 m_nOtherContent
Definition: rolbck.hxx:263
SwpHints & GetOrCreateSwpHints()
Definition: ndtxt.hxx:833
virtual const SwPosition & GetOtherMarkPos() const =0
bool m_bFormatIgnoreEnd
Definition: rolbck.hxx:124
bool IsDefaultItem(const SfxPoolItem *pItem)
Base class of the Writer document model elements.
Definition: node.hxx:81
virtual OUString GetDescription() const override
Definition: rolbck.cxx:303
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo