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 <hintids.hxx>
25 #include <hints.hxx>
26 #include <fmtflcnt.hxx>
27 #include <fmtanchr.hxx>
28 #include <fmtcntnt.hxx>
29 #include <txtflcnt.hxx>
30 #include <frmfmt.hxx>
31 #include <UndoCore.hxx>
32 #include <rolbck.hxx>
33 #include <doc.hxx>
35 #include <docary.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  xmlTextWriterStartElement(pWriter, BAD_CAST("SwUndoFlyBase"));
69  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nNodePagePos"),
70  BAD_CAST(OString::number(m_nNodePagePos).getStr()));
71  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nContentPos"),
72  BAD_CAST(OString::number(m_nContentPos).getStr()));
73  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nRndId"),
74  BAD_CAST(OString::number(static_cast<int>(m_nRndId)).getStr()));
75  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  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  }
158  }
159 
161 
162  if( bShowSelFrame )
163  {
164  rContext.SetSelections(m_pFrameFormat, nullptr);
165  }
166 
167  if( GetHistory() )
168  GetHistory()->Rollback( pDoc );
169 
170  switch( m_nRndId )
171  {
172  case RndStdIds::FLY_AS_CHAR:
173  case RndStdIds::FLY_AT_CHAR:
174  {
175  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
178  }
179  break;
180  case RndStdIds::FLY_AT_PARA:
181  case RndStdIds::FLY_AT_FLY:
182  {
183  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
185  }
186  break;
187  case RndStdIds::FLY_AT_PAGE:
188  break;
189  default: break;
190  }
191  m_bDelFormat = false;
192 }
193 
195 {
196  m_bDelFormat = true; // delete Format in DTOR
197  m_pFrameFormat->DelFrames(); // destroy Frames
198 
200  { // tdf#108867 clear that pointer
202  }
203 
204  // all Uno objects should now log themselves off
206 
207  if ( RES_DRAWFRMFMT != m_pFrameFormat->Which() )
208  {
209  // if there is content than save it
210  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
211  OSL_ENSURE( rContent.GetContentIdx(), "Fly without content" );
212 
213  SaveSection( *rContent.GetContentIdx() );
214  const_cast<SwFormatContent&>(rContent).SetNewContentIdx( nullptr );
215  }
216  // OD 02.07.2003 #108784# - remove 'master' drawing object from drawing page
217  else
219 
220  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
221  const SwPosition* pPos = rAnchor.GetContentAnchor();
222  // The positions in Nodes array got shifted.
223  m_nRndId = rAnchor.GetAnchorId();
224  if (RndStdIds::FLY_AS_CHAR == m_nRndId)
225  {
226  m_nNodePagePos = pPos->nNode.GetIndex();
227  m_nContentPos = pPos->nContent.GetIndex();
228  SwTextNode *const pTextNd = pPos->nNode.GetNode().GetTextNode();
229  OSL_ENSURE( pTextNd, "No Textnode found" );
230  SwTextFlyCnt* const pAttr = static_cast<SwTextFlyCnt*>(
232  // attribute is still in TextNode, delete
233  if( pAttr && pAttr->GetFlyCnt().GetFrameFormat() == m_pFrameFormat )
234  {
235  // Pointer to 0, do not delete
236  const_cast<SwFormatFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFormat();
237  SwIndex aIdx( pPos->nContent );
238  pTextNd->EraseText( aIdx, 1 );
239  }
240  }
241  else if (RndStdIds::FLY_AT_CHAR == m_nRndId)
242  {
243  m_nNodePagePos = pPos->nNode.GetIndex();
244  m_nContentPos = pPos->nContent.GetIndex();
245  }
246  else if ((RndStdIds::FLY_AT_PARA == m_nRndId) || (RndStdIds::FLY_AT_FLY == m_nRndId))
247  {
248  m_nNodePagePos = pPos->nNode.GetIndex();
249  }
250  else
251  {
252  m_nNodePagePos = rAnchor.GetPageNum();
253  }
254 
255  m_pFrameFormat->ResetFormatAttr( RES_ANCHOR ); // delete anchor
256 
257  // delete from array
258  SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats();
259  rFlyFormats.erase( m_pFrameFormat );
260 }
261 
262 SwUndoInsLayFormat::SwUndoInsLayFormat( SwFrameFormat* pFormat, sal_uLong nNodeIdx, sal_Int32 nCntIdx )
263  : SwUndoFlyBase( pFormat, RES_DRAWFRMFMT == pFormat->Which() ?
265  mnCursorSaveIndexPara( nNodeIdx ), mnCursorSaveIndexPos( nCntIdx )
266 {
267  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
268  m_nRndId = rAnchor.GetAnchorId();
269  m_bDelFormat = false;
270  // note: SwUndoInsLayFormat is called with the content being fully inserted
271  // from most places but with only an empty content section from
272  // CopyLayoutFormat(); it's not necessary here to init m_nNodePagePos
273  // because Undo will do it.
274 }
275 
277 {
278 }
279 
281 {
282  SwDoc & rDoc(rContext.GetDoc());
283  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
284  if( rContent.GetContentIdx() ) // no content
285  {
286  assert(&rContent.GetContentIdx()->GetNodes() == &rDoc.GetNodes());
287  bool bRemoveIdx = true;
288  if( mnCursorSaveIndexPara > 0 )
289  {
290  SwTextNode *const pNode =
291  rDoc.GetNodes()[mnCursorSaveIndexPara]->GetTextNode();
292  if( pNode )
293  {
294  SwNodeIndex aIdx( rDoc.GetNodes(),
295  rContent.GetContentIdx()->GetIndex() );
296  SwNodeIndex aEndIdx( rDoc.GetNodes(),
297  aIdx.GetNode().EndOfSectionIndex() );
299  SwPosition aPos( *pNode, aIndex );
300  SwDoc::CorrAbs( aIdx, aEndIdx, aPos, true );
301  bRemoveIdx = false;
302  }
303  }
304  if( bRemoveIdx )
305  {
306  RemoveIdxFromSection( rDoc, rContent.GetContentIdx()->GetIndex() );
307  }
308  }
309  DelFly(& rDoc);
310 }
311 
313 {
314  InsFly(rContext);
315 }
316 
318 {
319  SwDoc *const pDoc = & rContext.GetDoc();
320  // get anchor and reset it
322  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
323  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
324  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
325  {
326  SwPosition aPos( *rContext.GetRepeatPaM().GetPoint() );
327  if (RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId())
328  {
329  aPos.nContent.Assign( nullptr, 0 );
330  }
331  aAnchor.SetAnchor( &aPos );
332  }
333  else if( RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId() )
334  {
335  SwStartNode const*const pSttNd =
336  rContext.GetRepeatPaM().GetNode().FindFlyStartNode();
337  if( pSttNd )
338  {
339  SwPosition aPos( *pSttNd );
340  aAnchor.SetAnchor( &aPos );
341  }
342  else
343  {
344  return ;
345  }
346  }
347  else if (RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId())
348  {
349  aAnchor.SetPageNum( pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetCurrPage( &rContext.GetRepeatPaM() ));
350  }
351  else {
352  OSL_FAIL( "What kind of anchor is this?" );
353  }
354 
355  (void) pDoc->getIDocumentLayoutAccess().CopyLayoutFormat( *m_pFrameFormat, aAnchor, true, true );
356 }
357 
359 {
360  OUString aResult;
361 
362  // HACK: disable caching:
363  // the SfxUndoManager calls GetComment() too early: the pFrameFormat does not
364  // have a SwDrawContact yet, so it will fall back to SwUndo::GetComment(),
365  // which sets pComment to a wrong value.
366 // if (! pComment)
367  if ((true))
368  {
369  /*
370  If frame format is present and has an SdrObject use the undo
371  comment of the SdrObject. Otherwise use the default comment.
372  */
373  bool bDone = false;
374  if (m_pFrameFormat)
375  {
376  const SdrObject * pSdrObj = m_pFrameFormat->FindSdrObject();
377  if ( pSdrObj )
378  {
379  aResult = SdrUndoNewObj::GetComment( *pSdrObj );
380  bDone = true;
381  }
382  }
383 
384  if (! bDone)
385  aResult = SwUndo::GetComment();
386  }
387  else
388  aResult = *maComment;
389 
390  return aResult;
391 }
392 
393 static SwUndoId
394 lcl_GetSwUndoId(SwFrameFormat const *const pFrameFormat)
395 {
396  if (RES_DRAWFRMFMT != pFrameFormat->Which())
397  {
398  const SwFormatContent& rContent = pFrameFormat->GetContent();
399  OSL_ENSURE( rContent.GetContentIdx(), "Fly without content" );
400 
401  SwNodeIndex firstNode(*rContent.GetContentIdx(), 1);
402  SwNoTextNode *const pNoTextNode(firstNode.GetNode().GetNoTextNode());
403  if (pNoTextNode && pNoTextNode->IsGrfNode())
404  {
405  return SwUndoId::DELGRF;
406  }
407  else if (pNoTextNode && pNoTextNode->IsOLENode())
408  {
409  // surprisingly not SwUndoId::DELOLE, which does not seem to work
410  return SwUndoId::DELETE;
411  }
412  }
413  return SwUndoId::DELLAYFMT;
414 }
415 
417  : SwUndoFlyBase( pFormat, lcl_GetSwUndoId(pFormat) )
418  , m_bShowSelFrame( true )
419 {
420  SwDoc* pDoc = pFormat->GetDoc();
421  DelFly( pDoc );
422 }
423 
425 {
426  SwRewriter aRewriter;
427 
428  SwDoc * pDoc = m_pFrameFormat->GetDoc();
429 
430  if (pDoc)
431  {
432  SwNodeIndex* pIdx = GetMvSttIdx();
433  if( 1 == GetMvNodeCnt() && pIdx)
434  {
435  SwNode *const pNd = & pIdx->GetNode();
436 
437  if ( pNd->IsNoTextNode() && pNd->IsOLENode())
438  {
439  SwOLENode * pOLENd = pNd->GetOLENode();
440 
441  aRewriter.AddRule(UndoArg1, pOLENd->GetDescription());
442  }
443  }
444  }
445 
446  return aRewriter;
447 }
448 
450 {
451  InsFly( rContext, m_bShowSelFrame );
452 }
453 
455 {
456  SwDoc & rDoc(rContext.GetDoc());
457  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
458  if( rContent.GetContentIdx() ) // no content
459  {
460  RemoveIdxFromSection(rDoc, rContent.GetContentIdx()->GetIndex());
461  }
462 
463  DelFly(& rDoc);
464 }
465 
467 {
468  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
469  if( rContent.GetContentIdx() ) // no content
471  rContent.GetContentIdx()->GetIndex() );
472 
474 }
475 
477  : SwUndo( SwUndoId::SETFLYFRMFMT, rFlyFormat.GetDoc() ), SwClient( &rFlyFormat ), m_pFrameFormat( &rFlyFormat ),
478  m_DerivedFromFormatName( rFlyFormat.IsDefault() ? "" : rFlyFormat.DerivedFrom()->GetName() ),
479  m_NewFormatName( rNewFrameFormat.GetName() ),
480  m_pItemSet( new SfxItemSet( *rFlyFormat.GetAttrSet().GetPool(),
481  rFlyFormat.GetAttrSet().GetRanges() )),
482  m_nOldNode( 0 ), m_nNewNode( 0 ),
483  m_nOldContent( 0 ), m_nNewContent( 0 ),
484  m_nOldAnchorType( RndStdIds::FLY_AT_PARA ), m_nNewAnchorType( RndStdIds::FLY_AT_PARA ), m_bAnchorChanged( false )
485 {
486 }
487 
489 {
490  SwRewriter aRewriter;
491 
492  aRewriter.AddRule(UndoArg1, m_NewFormatName);
493 
494  return aRewriter;
495 }
496 
498 {
499 }
500 
502  sal_uLong nNode, sal_Int32 nContent )
503 {
504  RndStdIds nAnchorTyp = rAnchor.GetAnchorId();
505  if (RndStdIds::FLY_AT_PAGE != nAnchorTyp)
506  {
507  SwNode* pNd = m_pFrameFormat->GetDoc()->GetNodes()[ nNode ];
508 
509  if( RndStdIds::FLY_AT_FLY == nAnchorTyp
510  ? ( !pNd->IsStartNode() || SwFlyStartNode !=
511  static_cast<SwStartNode*>(pNd)->GetStartNodeType() )
512  : !pNd->IsTextNode() )
513  {
514  pNd = nullptr; // invalid position
515  }
516  else
517  {
518  SwPosition aPos( *pNd );
519  if ((RndStdIds::FLY_AS_CHAR == nAnchorTyp) ||
520  (RndStdIds::FLY_AT_CHAR == nAnchorTyp))
521  {
522  if (nContent > pNd->GetTextNode()->GetText().getLength())
523  {
524  pNd = nullptr; // invalid position
525  }
526  else
527  {
528  aPos.nContent.Assign(pNd->GetTextNode(), nContent);
529  }
530  }
531  if ( pNd )
532  {
533  rAnchor.SetAnchor( &aPos );
534  }
535  }
536 
537  if( !pNd )
538  {
539  // invalid position - assign first page
540  rAnchor.SetType( RndStdIds::FLY_AT_PAGE );
541  rAnchor.SetPageNum( 1 );
542  }
543  }
544  else
545  rAnchor.SetPageNum( nContent );
546 }
547 
549 {
550  SwDoc & rDoc = rContext.GetDoc();
551 
552  // Is the new Format still existent?
553  SwFrameFormat* pDerivedFromFrameFormat = rDoc.FindFrameFormatByName(m_DerivedFromFormatName);
554  if (!pDerivedFromFrameFormat)
555  return;
556 
557  if( m_bAnchorChanged )
559 
560  if( m_pFrameFormat->DerivedFrom() != pDerivedFromFrameFormat)
561  m_pFrameFormat->SetDerivedFrom(pDerivedFromFrameFormat);
562 
563  SfxItemIter aIter( *m_pItemSet );
564  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
565  {
566  if( IsInvalidItem( pItem ))
567  m_pFrameFormat->ResetFormatAttr( m_pItemSet->GetWhichByPos(
568  aIter.GetCurPos() ));
569  else
570  m_pFrameFormat->SetFormatAttr( *pItem );
571  }
572 
573  if( m_bAnchorChanged )
574  {
575  const SwFormatAnchor& rOldAnch = m_pFrameFormat->GetAnchor();
576  if (RndStdIds::FLY_AS_CHAR == rOldAnch.GetAnchorId())
577  {
578  // With InContents it's tricky: the text attribute needs to be
579  // deleted. Unfortunately, this not only destroys the Frames but
580  // also the format. To prevent that, first detach the
581  // connection between attribute and format.
582  const SwPosition *pPos = rOldAnch.GetContentAnchor();
583  SwTextNode *pTextNode = pPos->nNode.GetNode().GetTextNode();
584  OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
585  const sal_Int32 nIdx = pPos->nContent.GetIndex();
586  SwTextAttr * pHint = pTextNode->GetTextAttrForCharAt(
587  nIdx, RES_TXTATR_FLYCNT );
588  assert(pHint && "Missing Hint.");
589  OSL_ENSURE( pHint->Which() == RES_TXTATR_FLYCNT,
590  "Missing FlyInCnt-Hint." );
591  OSL_ENSURE( pHint->GetFlyCnt().GetFrameFormat() == m_pFrameFormat,
592  "Wrong TextFlyCnt-Hint." );
593  const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
594 
595  // Connection is now detached, therefore the attribute can be
596  // deleted
597  pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
598  }
599 
600  // reposition anchor
601  SwFormatAnchor aNewAnchor( m_nOldAnchorType );
602  GetAnchor( aNewAnchor, m_nOldNode, m_nOldContent );
603  m_pFrameFormat->SetFormatAttr( aNewAnchor );
604 
605  if (RndStdIds::FLY_AS_CHAR == aNewAnchor.GetAnchorId())
606  {
607  const SwPosition* pPos = aNewAnchor.GetContentAnchor();
608  SwFormatFlyCnt aFormat( m_pFrameFormat );
609  pPos->nNode.GetNode().GetTextNode()->InsertItem( aFormat,
610  m_nOldContent, 0 );
611  }
612 
614  }
615  rContext.SetSelections(m_pFrameFormat, nullptr);
616 }
617 
619 {
620  SwDoc & rDoc = rContext.GetDoc();
621 
622  // Is the new Format still existent?
623  SwFrameFormat* pNewFrameFormat = rDoc.FindFrameFormatByName(m_NewFormatName);
624  if (!pNewFrameFormat)
625  return;
626 
627  if( m_bAnchorChanged )
628  {
629  SwFormatAnchor aNewAnchor( m_nNewAnchorType );
630  GetAnchor( aNewAnchor, m_nNewNode, m_nNewContent );
632  aSet.Put( aNewAnchor );
633  rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat, &aSet );
634  }
635  else
636  rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat);
637 
638  rContext.SetSelections(m_pFrameFormat, nullptr);
639 }
640 
641 void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem )
642 {
643  if( pItem && pItem != GetDfltAttr( nWhich ) )
644  {
645  // Special treatment for this anchor
646  if( RES_ANCHOR == nWhich )
647  {
648  // only keep the first change
649  OSL_ENSURE( !m_bAnchorChanged, "multiple changes of an anchor are not allowed!" );
650 
651  m_bAnchorChanged = true;
652 
653  const SwFormatAnchor* pAnchor = static_cast<const SwFormatAnchor*>(pItem);
654  m_nOldAnchorType = pAnchor->GetAnchorId();
655  switch( m_nOldAnchorType )
656  {
657  case RndStdIds::FLY_AS_CHAR:
658  case RndStdIds::FLY_AT_CHAR:
660  [[fallthrough]];
661  case RndStdIds::FLY_AT_PARA:
662  case RndStdIds::FLY_AT_FLY:
663  m_nOldNode = pAnchor->GetContentAnchor()->nNode.GetIndex();
664  break;
665 
666  default:
667  m_nOldContent = pAnchor->GetPageNum();
668  }
669 
670  pAnchor = &m_pFrameFormat->GetAnchor();
671  m_nNewAnchorType = pAnchor->GetAnchorId();
672  switch( m_nNewAnchorType )
673  {
674  case RndStdIds::FLY_AS_CHAR:
675  case RndStdIds::FLY_AT_CHAR:
677  [[fallthrough]];
678  case RndStdIds::FLY_AT_PARA:
679  case RndStdIds::FLY_AT_FLY:
680  m_nNewNode = pAnchor->GetContentAnchor()->nNode.GetIndex();
681  break;
682 
683  default:
684  m_nNewContent = pAnchor->GetPageNum();
685  }
686  }
687  else
688  m_pItemSet->Put( *pItem );
689  }
690  else
691  m_pItemSet->InvalidateItem( nWhich );
692 }
693 
695 {
696  auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint);
697  if(!pLegacy || !pLegacy->m_pOld)
698  return;
699  const sal_uInt16 nWhich = pLegacy->m_pOld->Which();
700  if(nWhich < POOLATTR_END)
701  PutAttr(nWhich, pLegacy->m_pOld);
702  else if(RES_ATTRSET_CHG == nWhich)
703  {
704  SfxItemIter aIter(*static_cast<const SwAttrSetChg*>(pLegacy->m_pOld)->GetChgSet());
705  for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
706  PutAttr(pItem->Which(), pItem);
707  }
708 }
709 
710 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Starts a section of nodes in the document model.
Definition: node.hxx:311
bool erase(const value_type &x)
Definition: docfmt.cxx:2102
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:1117
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:2094
const OUString & GetText() const
Definition: ndtxt.hxx:212
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:980
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:186
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:416
const SwHistory * GetHistory() const
Definition: undobj.hxx:220
sal_uInt16 Which() const
Definition: txatbase.hxx:110
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
void InsFly(::sw::UndoRedoContext &rContext, bool bShowSel=true)
Definition: undobj1.cxx:89
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:741
sal_Int32 m_nOldContent
Definition: UndoCore.hxx:194
SwFrameFormat * FindFrameFormatByName(const OUString &rName) const
Definition: docfmt.cxx:734
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:3022
const OUString m_DerivedFromFormatName
Definition: UndoCore.hxx:190
void DelFly(SwDoc *)
Definition: undobj1.cxx:194
const SfxPoolItem * NextItem()
SwIndex nContent
Definition: pam.hxx:38
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void SetOtherTextBoxFormat(SwFrameFormat *pFormat)
Definition: atrfrm.cxx:2516
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:627
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(161)
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:1270
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:262
sal_uLong m_nNodePagePos
Definition: undobj.hxx:301
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:328
Specific frame formats (frames, DrawObjects).
bool IsOLENode() const
Definition: node.hxx:655
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:618
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:454
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: undobj1.cxx:488
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:394
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:280
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
Definition: docfly.cxx:632
SwContentNode * GetContentNode()
Definition: node.hxx:618
FlyAnchors.
Definition: fmtanchr.hxx:34
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:312
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2670
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:651
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:696
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: undobj1.cxx:424
virtual OUString GetComment() const override
Returns textual comment for this undo object.
Definition: undobj.cxx:659
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: atrfrm.cxx:2832
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:501
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:641
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:461
sal_uInt16 GetCurPos() const
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:78
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:2631
SwFormat * DerivedFrom() const
Definition: format.hxx:108
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
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:1719
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:641
SwFrameFormat * m_pFrameFormat
Definition: UndoCore.hxx:189
virtual ~SwUndoSetFlyFormat() override
Definition: undobj1.cxx:497
std::deque< AttacherIndex_Impl > aIndex
void CorrAbs(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset=0, bool bMoveCursor=false)
Definition: doccorr.cxx:167
const SfxPoolItem * m_pOld
Definition: calbck.hxx:70
virtual ~SwUndoInsLayFormat() override
Definition: undobj1.cxx:276
sal_Int32 GetIndex() const
Definition: index.hxx:91
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2681
SwNodes & GetNodes()
Definition: doc.hxx:405
void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: undobj1.cxx:694
RndStdIds m_nNewAnchorType
Definition: UndoCore.hxx:195
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
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:370
void RemoveAllUnos()
Definition: format.cxx:782
SwUndoSetFlyFormat(SwFrameFormat &rFlyFormat, const SwFrameFormat &rNewFrameFormat)
Definition: undobj1.cxx:476
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:198
SwFrameFormat * GetFrameFormat() const
Definition: fmtflcnt.hxx:45
RndStdIds
virtual OUString GetComment() const override
void RedoForRollback()
Definition: undobj1.cxx:466
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:358
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:449
bool IsTextNode() const
Definition: node.hxx:639
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:548
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:1317
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:845
bool HasHints() const
Definition: ndtxt.hxx:222
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1516
const OUString m_NewFormatName
Definition: UndoCore.hxx:191
const SwFormatFlyCnt & GetFlyCnt() const
Definition: txatbase.hxx:206
Base class of the Writer document model elements.
Definition: node.hxx:79
OUString GetDescription() const
Remove OLE-object from "memory".
Definition: ndole.hxx:141
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: undobj1.cxx:317
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo