LibreOffice Module sw (master)  1
undobj1.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <libxml/xmlwriter.h>
21 
22 #include <svl/itemiter.hxx>
23 #include <svx/svdundo.hxx>
24 #include <osl/diagnose.h>
25 #include <hintids.hxx>
26 #include <hints.hxx>
27 #include <fmtflcnt.hxx>
28 #include <fmtanchr.hxx>
29 #include <fmtcntnt.hxx>
30 #include <txtflcnt.hxx>
31 #include <frmfmt.hxx>
32 #include <UndoCore.hxx>
33 #include <rolbck.hxx>
34 #include <doc.hxx>
36 #include <rootfrm.hxx>
37 #include <swundo.hxx>
38 #include <pam.hxx>
39 #include <ndtxt.hxx>
40 #include <ndole.hxx>
41 #include <frameformats.hxx>
42 #include <svx/svdobj.hxx>
43 
45  : SwUndo(nUndoId, pFormat->GetDoc())
46  , m_pFrameFormat(pFormat)
47  , m_nNodePagePos(0)
48  , m_nContentPos(0)
49  , m_nRndId(RndStdIds::FLY_AT_PARA)
50  , m_bDelFormat(false)
51 {
52 }
53 
55 {
56  if( m_bDelFormat ) // delete during an Undo?
57  {
59  { // clear that before delete
61  }
62  delete m_pFrameFormat;
63  }
64 }
65 
67 {
68  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwUndoFlyBase"));
69  (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nNodePagePos"),
70  BAD_CAST(OString::number(m_nNodePagePos).getStr()));
71  (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nContentPos"),
72  BAD_CAST(OString::number(m_nContentPos).getStr()));
73  (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nRndId"),
74  BAD_CAST(OString::number(static_cast<int>(m_nRndId)).getStr()));
75  (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_bDelFormat"),
76  BAD_CAST(OString::boolean(m_bDelFormat).getStr()));
77 
78  SwUndo::dumpAsXml(pWriter);
80 
81  if (m_pFrameFormat)
82  {
83  m_pFrameFormat->dumpAsXml(pWriter);
84  }
85 
86  (void)xmlTextWriterEndElement(pWriter);
87 }
88 
89 void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrame)
90 {
91  SwDoc *const pDoc = & rContext.GetDoc();
92 
93  // add again into array
94  SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats();
95  rFlyFormats.push_back( m_pFrameFormat );
96 
97  // OD 26.06.2003 #108784# - insert 'master' drawing object into drawing page
100 
101  SwFormatAnchor aAnchor( m_nRndId );
102 
103  if (RndStdIds::FLY_AT_PAGE == m_nRndId)
104  {
105  aAnchor.SetPageNum( static_cast<sal_uInt16>(m_nNodePagePos) );
106  }
107  else
108  {
109  SwPosition aNewPos(pDoc->GetNodes().GetEndOfContent());
110  aNewPos.nNode = m_nNodePagePos;
111  if ((RndStdIds::FLY_AS_CHAR == m_nRndId) || (RndStdIds::FLY_AT_CHAR == m_nRndId))
112  {
113  aNewPos.nContent.Assign( aNewPos.nNode.GetNode().GetContentNode(),
114  m_nContentPos );
115  }
116  aAnchor.SetAnchor( &aNewPos );
117  }
118 
119  m_pFrameFormat->SetFormatAttr( aAnchor ); // reset anchor
120 
122  {
123  // get Content and reset ContentAttribute
124  SwNodeIndex aIdx( pDoc->GetNodes() );
125  RestoreSection( pDoc, &aIdx, SwFlyStartNode );
126  m_pFrameFormat->SetFormatAttr( SwFormatContent( aIdx.GetNode().GetStartNode() ));
127  }
128 
129  // Set InContentAttribute not until there is content!
130  // Otherwise the layout would format the Fly beforehand but would not find
131  // content; this happened with graphics from the internet.
132  if (RndStdIds::FLY_AS_CHAR == m_nRndId)
133  {
134  // there must be at least the attribute in a TextNode
136  OSL_ENSURE( pCNd->IsTextNode(), "no Text Node at position." );
137  SwFormatFlyCnt aFormat( m_pFrameFormat );
139  }
140 
142  {
143  // recklessly assume that this thing will live longer than the
144  // SwUndoFlyBase - not sure what could be done if that isn't the case...
146 
148  {
150  if (pSdrObject)
151  {
152  // Make sure the old UNO wrapper is no longer cached after changing the shape +
153  // textframe pair. Otherwise we would have a wrapper which doesn't know about its
154  // textframe, even if it's there.
155  pSdrObject->setUnoShape(nullptr);
156  }
157  }
159  {
160  // This is a draw format and we just set the fly format's textbox pointer to this draw
161  // format. Sync the draw format's content with the fly format's content.
163  m_pFrameFormat->SetFormatAttr(pFlyFormat->GetContent());
164  }
165  }
166 
168 
169  if( bShowSelFrame )
170  {
171  rContext.SetSelections(m_pFrameFormat, nullptr);
172  }
173 
174  if( GetHistory() )
175  GetHistory()->Rollback( pDoc );
176 
177  switch( m_nRndId )
178  {
179  case RndStdIds::FLY_AS_CHAR:
180  case RndStdIds::FLY_AT_CHAR:
181  {
182  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
185  }
186  break;
187  case RndStdIds::FLY_AT_PARA:
188  case RndStdIds::FLY_AT_FLY:
189  {
190  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
192  }
193  break;
194  case RndStdIds::FLY_AT_PAGE:
195  break;
196  default: break;
197  }
198  m_bDelFormat = false;
199 }
200 
202 {
203  m_bDelFormat = true; // delete Format in DTOR
204  m_pFrameFormat->DelFrames(); // destroy Frames
205 
207  { // tdf#108867 clear that pointer
209  }
210 
211  // all Uno objects should now log themselves off
213 
214  if ( RES_DRAWFRMFMT != m_pFrameFormat->Which() )
215  {
216  // if there is content than save it
217  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
218  OSL_ENSURE( rContent.GetContentIdx(), "Fly without content" );
219 
220  SaveSection( *rContent.GetContentIdx() );
221  const_cast<SwFormatContent&>(rContent).SetNewContentIdx( nullptr );
222  }
223  // OD 02.07.2003 #108784# - remove 'master' drawing object from drawing page
224  else
226 
227  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
228  const SwPosition* pPos = rAnchor.GetContentAnchor();
229  // The positions in Nodes array got shifted.
230  m_nRndId = rAnchor.GetAnchorId();
231  if (RndStdIds::FLY_AS_CHAR == m_nRndId)
232  {
233  m_nNodePagePos = pPos->nNode.GetIndex();
234  m_nContentPos = pPos->nContent.GetIndex();
235  SwTextNode *const pTextNd = pPos->nNode.GetNode().GetTextNode();
236  OSL_ENSURE( pTextNd, "No Textnode found" );
237  SwTextFlyCnt* const pAttr = static_cast<SwTextFlyCnt*>(
239  // attribute is still in TextNode, delete
240  if( pAttr && pAttr->GetFlyCnt().GetFrameFormat() == m_pFrameFormat )
241  {
242  // Pointer to 0, do not delete
243  const_cast<SwFormatFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFormat();
244  SwIndex aIdx( pPos->nContent );
245  pTextNd->EraseText( aIdx, 1 );
246  }
247  }
248  else if (RndStdIds::FLY_AT_CHAR == m_nRndId)
249  {
250  m_nNodePagePos = pPos->nNode.GetIndex();
251  m_nContentPos = pPos->nContent.GetIndex();
252  }
253  else if ((RndStdIds::FLY_AT_PARA == m_nRndId) || (RndStdIds::FLY_AT_FLY == m_nRndId))
254  {
255  m_nNodePagePos = pPos->nNode.GetIndex();
256  }
257  else
258  {
259  m_nNodePagePos = rAnchor.GetPageNum();
260  }
261 
262  m_pFrameFormat->ResetFormatAttr( RES_ANCHOR ); // delete anchor
263 
264  // delete from array
265  SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats();
266  rFlyFormats.erase( m_pFrameFormat );
267 }
268 
269 SwUndoInsLayFormat::SwUndoInsLayFormat( SwFrameFormat* pFormat, sal_uLong nNodeIdx, sal_Int32 nCntIdx )
270  : SwUndoFlyBase( pFormat, RES_DRAWFRMFMT == pFormat->Which() ?
272  mnCursorSaveIndexPara( nNodeIdx ), mnCursorSaveIndexPos( nCntIdx )
273 {
274  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
275  m_nRndId = rAnchor.GetAnchorId();
276  m_bDelFormat = false;
277  // note: SwUndoInsLayFormat is called with the content being fully inserted
278  // from most places but with only an empty content section from
279  // CopyLayoutFormat(); it's not necessary here to init m_nNodePagePos
280  // because Undo will do it.
281 }
282 
284 {
285 }
286 
288 {
289  SwDoc & rDoc(rContext.GetDoc());
290  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
291  if( rContent.GetContentIdx() ) // no content
292  {
293  assert(&rContent.GetContentIdx()->GetNodes() == &rDoc.GetNodes());
294  bool bRemoveIdx = true;
295  if( mnCursorSaveIndexPara > 0 )
296  {
297  SwTextNode *const pNode =
298  rDoc.GetNodes()[mnCursorSaveIndexPara]->GetTextNode();
299  if( pNode )
300  {
301  SwNodeIndex aIdx( rDoc.GetNodes(),
302  rContent.GetContentIdx()->GetIndex() );
303  SwNodeIndex aEndIdx( rDoc.GetNodes(),
304  aIdx.GetNode().EndOfSectionIndex() );
306  SwPosition aPos( *pNode, aIndex );
307  SwDoc::CorrAbs( aIdx, aEndIdx, aPos, true );
308  bRemoveIdx = false;
309  }
310  }
311  if( bRemoveIdx )
312  {
313  RemoveIdxFromSection( rDoc, rContent.GetContentIdx()->GetIndex() );
314  }
315  }
316  DelFly(& rDoc);
317 }
318 
320 {
321  InsFly(rContext);
322 }
323 
325 {
326  SwDoc *const pDoc = & rContext.GetDoc();
327  // get anchor and reset it
329  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
330  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
331  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
332  {
333  SwPosition aPos( *rContext.GetRepeatPaM().GetPoint() );
334  if (RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId())
335  {
336  aPos.nContent.Assign( nullptr, 0 );
337  }
338  aAnchor.SetAnchor( &aPos );
339  }
340  else if( RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId() )
341  {
342  SwStartNode const*const pSttNd =
343  rContext.GetRepeatPaM().GetNode().FindFlyStartNode();
344  if( pSttNd )
345  {
346  SwPosition aPos( *pSttNd );
347  aAnchor.SetAnchor( &aPos );
348  }
349  else
350  {
351  return ;
352  }
353  }
354  else if (RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId())
355  {
356  aAnchor.SetPageNum( pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetCurrPage( &rContext.GetRepeatPaM() ));
357  }
358  else {
359  OSL_FAIL( "What kind of anchor is this?" );
360  }
361 
362  (void) pDoc->getIDocumentLayoutAccess().CopyLayoutFormat( *m_pFrameFormat, aAnchor, true, true );
363 }
364 
366 {
367  OUString aResult;
368 
369  // HACK: disable caching:
370  // the SfxUndoManager calls GetComment() too early: the pFrameFormat does not
371  // have a SwDrawContact yet, so it will fall back to SwUndo::GetComment(),
372  // which sets pComment to a wrong value.
373 // if (! pComment)
374  if ((true))
375  {
376  /*
377  If frame format is present and has an SdrObject use the undo
378  comment of the SdrObject. Otherwise use the default comment.
379  */
380  bool bDone = false;
381  if (m_pFrameFormat)
382  {
383  const SdrObject * pSdrObj = m_pFrameFormat->FindSdrObject();
384  if ( pSdrObj )
385  {
386  aResult = SdrUndoNewObj::GetComment( *pSdrObj );
387  bDone = true;
388  }
389  }
390 
391  if (! bDone)
392  aResult = SwUndo::GetComment();
393  }
394  else
395  aResult = *maComment;
396 
397  return aResult;
398 }
399 
400 static SwUndoId
401 lcl_GetSwUndoId(SwFrameFormat const *const pFrameFormat)
402 {
403  if (RES_DRAWFRMFMT != pFrameFormat->Which())
404  {
405  const SwFormatContent& rContent = pFrameFormat->GetContent();
406  OSL_ENSURE( rContent.GetContentIdx(), "Fly without content" );
407 
408  SwNodeIndex firstNode(*rContent.GetContentIdx(), 1);
409  SwNoTextNode *const pNoTextNode(firstNode.GetNode().GetNoTextNode());
410  if (pNoTextNode && pNoTextNode->IsGrfNode())
411  {
412  return SwUndoId::DELGRF;
413  }
414  else if (pNoTextNode && pNoTextNode->IsOLENode())
415  {
416  // surprisingly not SwUndoId::DELOLE, which does not seem to work
417  return SwUndoId::DELETE;
418  }
419  }
420  return SwUndoId::DELLAYFMT;
421 }
422 
424  : SwUndoFlyBase( pFormat, lcl_GetSwUndoId(pFormat) )
425  , m_bShowSelFrame( true )
426 {
427  SwDoc* pDoc = pFormat->GetDoc();
428  DelFly( pDoc );
429 }
430 
432 {
433  SwRewriter aRewriter;
434 
435  SwDoc * pDoc = m_pFrameFormat->GetDoc();
436 
437  if (pDoc)
438  {
439  SwNodeIndex* pIdx = GetMvSttIdx();
440  if( 1 == GetMvNodeCnt() && pIdx)
441  {
442  SwNode *const pNd = & pIdx->GetNode();
443 
444  if ( pNd->IsNoTextNode() && pNd->IsOLENode())
445  {
446  SwOLENode * pOLENd = pNd->GetOLENode();
447 
448  aRewriter.AddRule(UndoArg1, pOLENd->GetDescription());
449  }
450  }
451  }
452 
453  return aRewriter;
454 }
455 
457 {
458  InsFly( rContext, m_bShowSelFrame );
459 }
460 
462 {
463  SwDoc & rDoc(rContext.GetDoc());
464  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
465  if( rContent.GetContentIdx() ) // no content
466  {
467  RemoveIdxFromSection(rDoc, rContent.GetContentIdx()->GetIndex());
468  }
469 
470  DelFly(& rDoc);
471 }
472 
474 {
475  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
476  if( rContent.GetContentIdx() ) // no content
478  rContent.GetContentIdx()->GetIndex() );
479 
481 }
482 
484  : SwUndo( SwUndoId::SETFLYFRMFMT, rFlyFormat.GetDoc() ), SwClient( &rFlyFormat ), m_pFrameFormat( &rFlyFormat ),
485  m_DerivedFromFormatName( rFlyFormat.IsDefault() ? "" : rFlyFormat.DerivedFrom()->GetName() ),
486  m_NewFormatName( rNewFrameFormat.GetName() ),
487  m_pItemSet( new SfxItemSet( *rFlyFormat.GetAttrSet().GetPool(),
488  rFlyFormat.GetAttrSet().GetRanges() )),
489  m_nOldNode( 0 ), m_nNewNode( 0 ),
490  m_nOldContent( 0 ), m_nNewContent( 0 ),
491  m_nOldAnchorType( RndStdIds::FLY_AT_PARA ), m_nNewAnchorType( RndStdIds::FLY_AT_PARA ), m_bAnchorChanged( false )
492 {
493 }
494 
496 {
497  SwRewriter aRewriter;
498 
499  aRewriter.AddRule(UndoArg1, m_NewFormatName);
500 
501  return aRewriter;
502 }
503 
505 {
506 }
507 
509  sal_uLong nNode, sal_Int32 nContent )
510 {
511  RndStdIds nAnchorTyp = rAnchor.GetAnchorId();
512  if (RndStdIds::FLY_AT_PAGE != nAnchorTyp)
513  {
514  SwNode* pNd = m_pFrameFormat->GetDoc()->GetNodes()[ nNode ];
515 
516  if( RndStdIds::FLY_AT_FLY == nAnchorTyp
517  ? ( !pNd->IsStartNode() || SwFlyStartNode !=
518  static_cast<SwStartNode*>(pNd)->GetStartNodeType() )
519  : !pNd->IsTextNode() )
520  {
521  pNd = nullptr; // invalid position
522  }
523  else
524  {
525  SwPosition aPos( *pNd );
526  if ((RndStdIds::FLY_AS_CHAR == nAnchorTyp) ||
527  (RndStdIds::FLY_AT_CHAR == nAnchorTyp))
528  {
529  if (nContent > pNd->GetTextNode()->GetText().getLength())
530  {
531  pNd = nullptr; // invalid position
532  }
533  else
534  {
535  aPos.nContent.Assign(pNd->GetTextNode(), nContent);
536  }
537  }
538  if ( pNd )
539  {
540  rAnchor.SetAnchor( &aPos );
541  }
542  }
543 
544  if( !pNd )
545  {
546  // invalid position - assign first page
547  rAnchor.SetType( RndStdIds::FLY_AT_PAGE );
548  rAnchor.SetPageNum( 1 );
549  }
550  }
551  else
552  rAnchor.SetPageNum( nContent );
553 }
554 
556 {
557  SwDoc & rDoc = rContext.GetDoc();
558 
559  // Is the new Format still existent?
560  SwFrameFormat* pDerivedFromFrameFormat = rDoc.FindFrameFormatByName(m_DerivedFromFormatName);
561  if (!pDerivedFromFrameFormat)
562  return;
563 
564  if( m_bAnchorChanged )
566 
567  if( m_pFrameFormat->DerivedFrom() != pDerivedFromFrameFormat)
568  m_pFrameFormat->SetDerivedFrom(pDerivedFromFrameFormat);
569 
570  SfxItemIter aIter( *m_pItemSet );
571  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
572  {
573  if( IsInvalidItem( pItem ))
574  m_pFrameFormat->ResetFormatAttr( m_pItemSet->GetWhichByPos(
575  aIter.GetCurPos() ));
576  else
577  m_pFrameFormat->SetFormatAttr( *pItem );
578  }
579 
580  if( m_bAnchorChanged )
581  {
582  const SwFormatAnchor& rOldAnch = m_pFrameFormat->GetAnchor();
583  if (RndStdIds::FLY_AS_CHAR == rOldAnch.GetAnchorId())
584  {
585  // With InContents it's tricky: the text attribute needs to be
586  // deleted. Unfortunately, this not only destroys the Frames but
587  // also the format. To prevent that, first detach the
588  // connection between attribute and format.
589  const SwPosition *pPos = rOldAnch.GetContentAnchor();
590  SwTextNode *pTextNode = pPos->nNode.GetNode().GetTextNode();
591  OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
592  const sal_Int32 nIdx = pPos->nContent.GetIndex();
593  SwTextAttr * pHint = pTextNode->GetTextAttrForCharAt(
594  nIdx, RES_TXTATR_FLYCNT );
595  assert(pHint && "Missing Hint.");
596  OSL_ENSURE( pHint->Which() == RES_TXTATR_FLYCNT,
597  "Missing FlyInCnt-Hint." );
598  OSL_ENSURE( pHint->GetFlyCnt().GetFrameFormat() == m_pFrameFormat,
599  "Wrong TextFlyCnt-Hint." );
600  const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
601 
602  // Connection is now detached, therefore the attribute can be
603  // deleted
604  pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
605  }
606 
607  // reposition anchor
608  SwFormatAnchor aNewAnchor( m_nOldAnchorType );
609  GetAnchor( aNewAnchor, m_nOldNode, m_nOldContent );
610  m_pFrameFormat->SetFormatAttr( aNewAnchor );
611 
612  if (RndStdIds::FLY_AS_CHAR == aNewAnchor.GetAnchorId())
613  {
614  const SwPosition* pPos = aNewAnchor.GetContentAnchor();
615  SwFormatFlyCnt aFormat( m_pFrameFormat );
616  pPos->nNode.GetNode().GetTextNode()->InsertItem( aFormat,
617  m_nOldContent, 0 );
618  }
619 
621  }
622  rContext.SetSelections(m_pFrameFormat, nullptr);
623 }
624 
626 {
627  SwDoc & rDoc = rContext.GetDoc();
628 
629  // Is the new Format still existent?
630  SwFrameFormat* pNewFrameFormat = rDoc.FindFrameFormatByName(m_NewFormatName);
631  if (!pNewFrameFormat)
632  return;
633 
634  if( m_bAnchorChanged )
635  {
636  SwFormatAnchor aNewAnchor( m_nNewAnchorType );
637  GetAnchor( aNewAnchor, m_nNewNode, m_nNewContent );
639  aSet.Put( aNewAnchor );
640  rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat, &aSet );
641  }
642  else
643  rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat);
644 
645  rContext.SetSelections(m_pFrameFormat, nullptr);
646 }
647 
648 void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem )
649 {
650  if( pItem && pItem != GetDfltAttr( nWhich ) )
651  {
652  // Special treatment for this anchor
653  if( RES_ANCHOR == nWhich )
654  {
655  // only keep the first change
656  OSL_ENSURE( !m_bAnchorChanged, "multiple changes of an anchor are not allowed!" );
657 
658  m_bAnchorChanged = true;
659 
660  const SwFormatAnchor* pAnchor = static_cast<const SwFormatAnchor*>(pItem);
661  m_nOldAnchorType = pAnchor->GetAnchorId();
662  switch( m_nOldAnchorType )
663  {
664  case RndStdIds::FLY_AS_CHAR:
665  case RndStdIds::FLY_AT_CHAR:
667  [[fallthrough]];
668  case RndStdIds::FLY_AT_PARA:
669  case RndStdIds::FLY_AT_FLY:
670  m_nOldNode = pAnchor->GetContentAnchor()->nNode.GetIndex();
671  break;
672 
673  default:
674  m_nOldContent = pAnchor->GetPageNum();
675  }
676 
677  pAnchor = &m_pFrameFormat->GetAnchor();
678  m_nNewAnchorType = pAnchor->GetAnchorId();
679  switch( m_nNewAnchorType )
680  {
681  case RndStdIds::FLY_AS_CHAR:
682  case RndStdIds::FLY_AT_CHAR:
684  [[fallthrough]];
685  case RndStdIds::FLY_AT_PARA:
686  case RndStdIds::FLY_AT_FLY:
687  m_nNewNode = pAnchor->GetContentAnchor()->nNode.GetIndex();
688  break;
689 
690  default:
691  m_nNewContent = pAnchor->GetPageNum();
692  }
693  }
694  else
695  m_pItemSet->Put( *pItem );
696  }
697  else
698  m_pItemSet->InvalidateItem( nWhich );
699 }
700 
702 {
703  auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint);
704  if(!pLegacy || !pLegacy->m_pOld)
705  return;
706  const sal_uInt16 nWhich = pLegacy->m_pOld->Which();
707  if(nWhich < POOLATTR_END)
708  PutAttr(nWhich, pLegacy->m_pOld);
709  else if(RES_ATTRSET_CHG == nWhich)
710  {
711  SfxItemIter aIter(*static_cast<const SwAttrSetChg*>(pLegacy->m_pOld)->GetChgSet());
712  for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
713  PutAttr(pItem->Which(), pItem);
714  }
715 }
716 
717 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Starts a section of nodes in the document model.
Definition: node.hxx:312
bool erase(const value_type &x)
Definition: docfmt.cxx:2121
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
void SetSelections(SwFrameFormat *const pSelFormat, SdrMarkList *const pMarkList)
Definition: UndoCore.hxx:98
bool GetRanges(std::vector< std::shared_ptr< SwUnoCursor >> &rRanges, SwDoc &rDoc, SwPaM const &rDelPam)
Definition: autofmt.cxx:1118
Marks a position in the document model.
Definition: pam.hxx:35
RndStdIds m_nOldAnchorType
Definition: UndoCore.hxx:195
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
std::pair< const_iterator, bool > push_back(const value_type &x)
Definition: docfmt.cxx:2113
const OUString & GetText() const
Definition: ndtxt.hxx:210
virtual const SwRootFrame * GetCurrentLayout() const =0
SwUndoId
Definition: swundo.hxx:29
sal_uInt16 GetCurrPage(const SwPaM *) const
Query/set the current Page and the collective Page count We'll format as much as necessary.
Definition: trvlfrm.cxx:981
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: undobj1.cxx:66
bool Rollback(SwDoc *pDoc, sal_uInt16 nStart=0)
Definition: rolbck.cxx:1210
SwNodeIndex nNode
Definition: pam.hxx:37
sal_uInt16 GetPageNum() const
Definition: fmtanchr.hxx:66
sal_Int32 m_nNewContent
Definition: UndoCore.hxx:194
sal_uIntPtr sal_uLong
SwPaM & GetRepeatPaM()
Definition: UndoCore.hxx:128
Definition: doc.hxx:187
virtual SwFrameFormat * CopyLayoutFormat(const SwFrameFormat &rSrc, const SwFormatAnchor &rNewAnchor, bool bSetTextFlyAtt, bool bMakeFrames)=0
void setUnoShape(const css::uno::Reference< css::uno::XInterface > &_rxUnoShape)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(57)
SwNode & GetNode() const
Definition: ndindex.hxx:119
sal_Int32 m_nContentPos
Definition: undobj.hxx:302
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
SwUndoDelLayFormat(SwFrameFormat *pFormat)
Definition: undobj1.cxx:423
const SwHistory * GetHistory() const
Definition: undobj.hxx:220
sal_uInt16 Which() const
Definition: txatbase.hxx:114
static void RemoveIdxFromSection(SwDoc &, sal_uLong nSttIdx, const sal_uLong *pEndIdx=nullptr)
Definition: undobj.cxx:116
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
SwFrameFormat * FindFrameFormatByName(std::u16string_view rName) const
Definition: docfmt.cxx:734
void InsFly(::sw::UndoRedoContext &rContext, bool bShowSel=true)
Definition: undobj1.cxx:89
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:743
sal_Int32 m_nOldContent
Definition: UndoCore.hxx:194
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:3050
const OUString m_DerivedFromFormatName
Definition: UndoCore.hxx:190
void DelFly(SwDoc *)
Definition: undobj1.cxx:201
const SfxPoolItem * NextItem()
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
SwIndex nContent
Definition: pam.hxx:38
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
void SetOtherTextBoxFormat(SwFrameFormat *pFormat)
Definition: atrfrm.cxx:2494
SwDoc & GetDoc() const
Definition: UndoCore.hxx:126
for Undo, translated to SwInsertFlags::NOHINTEXPAND
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
bool IsStartNode() const
Definition: node.hxx:628
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:1271
const SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
Definition: hints.cxx:153
SwDoc & GetDoc() const
Definition: UndoCore.hxx:94
SwUndoInsLayFormat(SwFrameFormat *pFormat, sal_uLong nNodeIdx, sal_Int32 nCntIdx)
Definition: undobj1.cxx:269
sal_uLong m_nNodePagePos
Definition: undobj.hxx:301
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:321
Specific frame formats (frames, DrawObjects).
bool IsOLENode() const
Definition: node.hxx:656
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:625
sal_uLong m_nOldNode
Definition: UndoCore.hxx:193
SwNodeIndex * GetMvSttIdx() const
Definition: undobj.hxx:311
struct _xmlTextWriter * xmlTextWriterPtr
Style of a layout element.
Definition: frmfmt.hxx:58
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:461
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: undobj1.cxx:495
SwFrameFormat * m_pFrameFormat
Definition: undobj.hxx:300
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
const SwPosition * GetPoint() const
Definition: pam.hxx:207
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: undobj.cxx:1311
SwFrameFormat * GetOtherTextBoxFormat() const
Definition: frmfmt.hxx:102
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
sal_uLong m_nNewNode
Definition: UndoCore.hxx:193
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
static SwUndoId lcl_GetSwUndoId(SwFrameFormat const *const pFrameFormat)
Definition: undobj1.cxx:401
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:287
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
Definition: docfly.cxx:632
SwContentNode * GetContentNode()
Definition: node.hxx:619
FlyAnchors.
Definition: fmtanchr.hxx:34
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:319
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2644
sal_Int32 mnCursorSaveIndexPos
Definition: undobj.hxx:323
Marks a character position inside a document model node.
Definition: index.hxx:33
bool m_bDelFormat
Definition: undobj.hxx:304
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:27
RndStdIds m_nRndId
Definition: undobj.hxx:303
std::optional< OUString > maComment
Definition: undobj.hxx:62
bool IsNoTextNode() const
Definition: node.hxx:652
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:697
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: undobj1.cxx:431
virtual OUString GetComment() const override
Returns textual comment for this undo object.
Definition: undobj.cxx:659
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: atrfrm.cxx:2806
sal_uLong GetMvNodeCnt() const
Definition: undobj.hxx:312
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
virtual ~SwUndoFlyBase() override
Definition: undobj1.cxx:54
void GetAnchor(SwFormatAnchor &rAnhor, sal_uLong nNode, sal_Int32 nContent)
Definition: undobj1.cxx:508
constexpr sal_uInt16 POOLATTR_END(RES_UNKNOWNATR_END)
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
void PutAttr(sal_uInt16 nWhich, const SfxPoolItem *pItem)
Definition: undobj1.cxx:648
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
sal_uInt16 const aFrameFormatSetRange[]
Definition: init.cxx:233
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
sal_uInt16 GetCurPos() const
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
void EraseText(const SwIndex &rIdx, const sal_Int32 nCount=SAL_MAX_INT32, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
delete text content ATTENTION: must not be called with a range that overlaps the start of an attribut...
Definition: ndtxt.cxx:2668
SwFormat * DerivedFrom() const
Definition: format.hxx:112
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:1720
void RestoreSection(SwDoc *pDoc, SwNodeIndex *pIdx, sal_uInt16 nSectType)
Definition: undobj.cxx:1271
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:624
SwFrameFormat * m_pFrameFormat
Definition: UndoCore.hxx:189
virtual ~SwUndoSetFlyFormat() override
Definition: undobj1.cxx:504
std::deque< AttacherIndex_Impl > aIndex
void CorrAbs(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset=0, bool bMoveCursor=false)
Definition: doccorr.cxx:168
const SfxPoolItem * m_pOld
Definition: calbck.hxx:73
virtual ~SwUndoInsLayFormat() override
Definition: undobj1.cxx:283
sal_Int32 GetIndex() const
Definition: index.hxx:91
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2655
SwNodes & GetNodes()
Definition: doc.hxx:408
void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: undobj1.cxx:701
RndStdIds m_nNewAnchorType
Definition: UndoCore.hxx:195
SwUndoFlyBase(SwFrameFormat *pFormat, SwUndoId nUndoId)
Definition: undobj1.cxx:44
Format of a fly content.
Definition: fmtflcnt.hxx:32
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:324
void RemoveAllUnos()
Definition: format.cxx:763
SwUndoSetFlyFormat(SwFrameFormat &rFlyFormat, const SwFrameFormat &rNewFrameFormat)
Definition: undobj1.cxx:483
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:199
SwFrameFormat * GetFrameFormat() const
Definition: fmtflcnt.hxx:45
RndStdIds
virtual OUString GetComment() const override
void RedoForRollback()
Definition: undobj1.cxx:473
bool IsInvalidItem(const SfxPoolItem *pItem)
std::unique_ptr< SfxItemSet > m_pItemSet
Definition: UndoCore.hxx:192
virtual OUString GetComment() const override
Returns textual comment for this undo object.
Definition: undobj1.cxx:365
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:456
bool IsTextNode() const
Definition: node.hxx:640
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:555
void SaveSection(const SwNodeIndex &rSttIdx)
Definition: undobj.cxx:1218
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:138
sal_uInt16 Which() const
sal_uLong mnCursorSaveIndexPara
Definition: undobj.hxx:322
const SfxPoolItem * GetCurItem() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1320
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:845
bool HasHints() const
Definition: ndtxt.hxx:220
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1494
const OUString m_NewFormatName
Definition: UndoCore.hxx:191
const SwFormatFlyCnt & GetFlyCnt() const
Definition: txatbase.hxx:210
Base class of the Writer document model elements.
Definition: node.hxx:80
OUString GetDescription() const
Remove OLE-object from "memory".
Definition: ndole.hxx:141
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: undobj1.cxx:324
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo