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(sal_Int32(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( o3tl::narrowing<sal_uInt16>(sal_Int32(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...
147 
148  SdrObject* pSdrObject
150  if (pSdrObject && m_pFrameFormat->Which() == RES_FLYFRMFMT)
152 
154  {
155 
156  if (pSdrObject)
157  {
158  // Make sure the old UNO wrapper is no longer cached after changing the shape +
159  // textframe pair. Otherwise we would have a wrapper which doesn't know about its
160  // textframe, even if it's there.
161  pSdrObject->setUnoShape(nullptr);
162  }
163  }
165  {
167  pShapeFormat->SetFormatAttr(m_pFrameFormat->GetContent());
168  }
169  }
170 
172 
173  if( bShowSelFrame )
174  {
175  rContext.SetSelections(m_pFrameFormat, nullptr);
176  }
177 
178  if( GetHistory() )
179  GetHistory()->Rollback( pDoc );
180 
181  switch( m_nRndId )
182  {
183  case RndStdIds::FLY_AS_CHAR:
184  case RndStdIds::FLY_AT_CHAR:
185  {
186  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
189  }
190  break;
191  case RndStdIds::FLY_AT_PARA:
192  case RndStdIds::FLY_AT_FLY:
193  {
194  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
196  }
197  break;
198  case RndStdIds::FLY_AT_PAGE:
199  break;
200  default: break;
201  }
202  m_bDelFormat = false;
203 }
204 
206 {
207  m_bDelFormat = true; // delete Format in DTOR
208  m_pFrameFormat->DelFrames(); // destroy Frames
209 
211  { // tdf#108867 clear that pointer
213  }
214 
215  // all Uno objects should now log themselves off
217 
218  if ( RES_DRAWFRMFMT != m_pFrameFormat->Which() )
219  {
220  // if there is content than save it
221  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
222  OSL_ENSURE( rContent.GetContentIdx(), "Fly without content" );
223 
224  SaveSection( *rContent.GetContentIdx() );
225  const_cast<SwFormatContent&>(rContent).SetNewContentIdx( nullptr );
226  }
227  // OD 02.07.2003 #108784# - remove 'master' drawing object from drawing page
228  else
230 
231  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
232  const SwPosition* pPos = rAnchor.GetContentAnchor();
233  // The positions in Nodes array got shifted.
234  m_nRndId = rAnchor.GetAnchorId();
235  if (RndStdIds::FLY_AS_CHAR == m_nRndId)
236  {
237  m_nNodePagePos = pPos->nNode.GetIndex();
238  m_nContentPos = pPos->nContent.GetIndex();
239  SwTextNode *const pTextNd = pPos->nNode.GetNode().GetTextNode();
240  OSL_ENSURE( pTextNd, "No Textnode found" );
241  SwTextFlyCnt* const pAttr = static_cast<SwTextFlyCnt*>(
243  // attribute is still in TextNode, delete
244  if( pAttr && pAttr->GetFlyCnt().GetFrameFormat() == m_pFrameFormat )
245  {
246  // Pointer to 0, do not delete
247  const_cast<SwFormatFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFormat();
248  SwIndex aIdx( pPos->nContent );
249  pTextNd->EraseText( aIdx, 1 );
250  }
251  }
252  else if (RndStdIds::FLY_AT_CHAR == m_nRndId)
253  {
254  m_nNodePagePos = pPos->nNode.GetIndex();
255  m_nContentPos = pPos->nContent.GetIndex();
256  }
257  else if ((RndStdIds::FLY_AT_PARA == m_nRndId) || (RndStdIds::FLY_AT_FLY == m_nRndId))
258  {
259  m_nNodePagePos = pPos->nNode.GetIndex();
260  }
261  else
262  {
264  }
265 
266  m_pFrameFormat->ResetFormatAttr( RES_ANCHOR ); // delete anchor
267 
268  // delete from array
269  SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats();
270  rFlyFormats.erase( m_pFrameFormat );
271 }
272 
273 SwUndoInsLayFormat::SwUndoInsLayFormat( SwFrameFormat* pFormat, SwNodeOffset nNodeIdx, sal_Int32 nCntIdx )
274  : SwUndoFlyBase( pFormat, RES_DRAWFRMFMT == pFormat->Which() ?
276  mnCursorSaveIndexPara( nNodeIdx ), mnCursorSaveIndexPos( nCntIdx )
277 {
278  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
279  m_nRndId = rAnchor.GetAnchorId();
280  m_bDelFormat = false;
281  // note: SwUndoInsLayFormat is called with the content being fully inserted
282  // from most places but with only an empty content section from
283  // CopyLayoutFormat(); it's not necessary here to init m_nNodePagePos
284  // because Undo will do it.
285 }
286 
288 {
289 }
290 
292 {
293  SwDoc & rDoc(rContext.GetDoc());
294  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
295  if( rContent.GetContentIdx() ) // no content
296  {
297  assert(&rContent.GetContentIdx()->GetNodes() == &rDoc.GetNodes());
298  bool bRemoveIdx = true;
300  {
301  SwTextNode *const pNode =
302  rDoc.GetNodes()[mnCursorSaveIndexPara]->GetTextNode();
303  if( pNode )
304  {
305  SwNodeIndex aIdx( rDoc.GetNodes(),
306  rContent.GetContentIdx()->GetIndex() );
307  SwNodeIndex aEndIdx( rDoc.GetNodes(),
308  aIdx.GetNode().EndOfSectionIndex() );
310  SwPosition aPos( *pNode, aIndex );
311  SwDoc::CorrAbs( aIdx, aEndIdx, aPos, true );
312  bRemoveIdx = false;
313  }
314  }
315  if( bRemoveIdx )
316  {
317  RemoveIdxFromSection( rDoc, rContent.GetContentIdx()->GetIndex() );
318  }
319  }
320  DelFly(& rDoc);
321 }
322 
324 {
325  InsFly(rContext);
326 }
327 
329 {
330  SwDoc *const pDoc = & rContext.GetDoc();
331  // get anchor and reset it
333  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
334  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
335  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
336  {
337  SwPosition aPos( *rContext.GetRepeatPaM().GetPoint() );
338  if (RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId())
339  {
340  aPos.nContent.Assign( nullptr, 0 );
341  }
342  aAnchor.SetAnchor( &aPos );
343  }
344  else if( RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId() )
345  {
346  SwStartNode const*const pSttNd =
347  rContext.GetRepeatPaM().GetNode().FindFlyStartNode();
348  if( pSttNd )
349  {
350  SwPosition aPos( *pSttNd );
351  aAnchor.SetAnchor( &aPos );
352  }
353  else
354  {
355  return ;
356  }
357  }
358  else if (RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId())
359  {
360  aAnchor.SetPageNum( pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetCurrPage( &rContext.GetRepeatPaM() ));
361  }
362  else {
363  OSL_FAIL( "What kind of anchor is this?" );
364  }
365 
366  (void) pDoc->getIDocumentLayoutAccess().CopyLayoutFormat( *m_pFrameFormat, aAnchor, true, true );
367 }
368 
370 {
371  OUString aResult;
372 
373  // HACK: disable caching:
374  // the SfxUndoManager calls GetComment() too early: the pFrameFormat does not
375  // have a SwDrawContact yet, so it will fall back to SwUndo::GetComment(),
376  // which sets pComment to a wrong value.
377 // if (! pComment)
378  if ((true))
379  {
380  /*
381  If frame format is present and has an SdrObject use the undo
382  comment of the SdrObject. Otherwise use the default comment.
383  */
384  bool bDone = false;
385  if (m_pFrameFormat)
386  {
387  const SdrObject * pSdrObj = m_pFrameFormat->FindSdrObject();
388  if ( pSdrObj )
389  {
390  aResult = SdrUndoNewObj::GetComment( *pSdrObj );
391  bDone = true;
392  }
393  }
394 
395  if (! bDone)
396  aResult = SwUndo::GetComment();
397  }
398  else
399  aResult = *maComment;
400 
401  return aResult;
402 }
403 
404 static SwUndoId
405 lcl_GetSwUndoId(SwFrameFormat const *const pFrameFormat)
406 {
407  if (RES_DRAWFRMFMT != pFrameFormat->Which())
408  {
409  const SwFormatContent& rContent = pFrameFormat->GetContent();
410  OSL_ENSURE( rContent.GetContentIdx(), "Fly without content" );
411 
412  SwNodeIndex firstNode(*rContent.GetContentIdx(), 1);
413  SwNoTextNode *const pNoTextNode(firstNode.GetNode().GetNoTextNode());
414  if (pNoTextNode && pNoTextNode->IsGrfNode())
415  {
416  return SwUndoId::DELGRF;
417  }
418  else if (pNoTextNode && pNoTextNode->IsOLENode())
419  {
420  // surprisingly not SwUndoId::DELOLE, which does not seem to work
421  return SwUndoId::DELETE;
422  }
423  }
424  return SwUndoId::DELLAYFMT;
425 }
426 
428  : SwUndoFlyBase( pFormat, lcl_GetSwUndoId(pFormat) )
429  , m_bShowSelFrame( true )
430 {
431  SwDoc* pDoc = pFormat->GetDoc();
432  DelFly( pDoc );
433 }
434 
436 {
437  SwRewriter aRewriter;
438 
439  SwDoc * pDoc = m_pFrameFormat->GetDoc();
440 
441  if (pDoc)
442  {
443  SwNodeIndex* pIdx = GetMvSttIdx();
444  if( SwNodeOffset(1) == GetMvNodeCnt() && pIdx)
445  {
446  SwNode *const pNd = & pIdx->GetNode();
447 
448  if ( pNd->IsNoTextNode() && pNd->IsOLENode())
449  {
450  SwOLENode * pOLENd = pNd->GetOLENode();
451 
452  aRewriter.AddRule(UndoArg1, pOLENd->GetDescription());
453  }
454  }
455  }
456 
457  return aRewriter;
458 }
459 
461 {
462  InsFly( rContext, m_bShowSelFrame );
463 }
464 
466 {
467  SwDoc & rDoc(rContext.GetDoc());
468  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
469  if( rContent.GetContentIdx() ) // no content
470  {
471  RemoveIdxFromSection(rDoc, rContent.GetContentIdx()->GetIndex());
472  }
473 
474  DelFly(& rDoc);
475 }
476 
478 {
479  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
480  if( rContent.GetContentIdx() ) // no content
482  rContent.GetContentIdx()->GetIndex() );
483 
485 }
486 
488  : SwUndo( SwUndoId::SETFLYFRMFMT, rFlyFormat.GetDoc() ), SwClient( &rFlyFormat ), m_pFrameFormat( &rFlyFormat ),
489  m_DerivedFromFormatName( rFlyFormat.IsDefault() ? "" : rFlyFormat.DerivedFrom()->GetName() ),
490  m_NewFormatName( rNewFrameFormat.GetName() ),
491  m_oItemSet( std::in_place, *rFlyFormat.GetAttrSet().GetPool(),
492  rFlyFormat.GetAttrSet().GetRanges() ),
493  m_nOldNode( 0 ), m_nNewNode( 0 ),
494  m_nOldContent( 0 ), m_nNewContent( 0 ),
495  m_nOldAnchorType( RndStdIds::FLY_AT_PARA ), m_nNewAnchorType( RndStdIds::FLY_AT_PARA ), m_bAnchorChanged( false )
496 {
497 }
498 
500 {
501  SwRewriter aRewriter;
502 
503  aRewriter.AddRule(UndoArg1, m_NewFormatName);
504 
505  return aRewriter;
506 }
507 
509 {
510 }
511 
513  SwNodeOffset nNode, sal_Int32 nContent )
514 {
515  RndStdIds nAnchorTyp = rAnchor.GetAnchorId();
516  if (RndStdIds::FLY_AT_PAGE != nAnchorTyp)
517  {
518  SwNode* pNd = m_pFrameFormat->GetDoc()->GetNodes()[ nNode ];
519 
520  if( RndStdIds::FLY_AT_FLY == nAnchorTyp
521  ? ( !pNd->IsStartNode() || SwFlyStartNode !=
522  static_cast<SwStartNode*>(pNd)->GetStartNodeType() )
523  : !pNd->IsTextNode() )
524  {
525  pNd = nullptr; // invalid position
526  }
527  else
528  {
529  SwPosition aPos( *pNd );
530  if ((RndStdIds::FLY_AS_CHAR == nAnchorTyp) ||
531  (RndStdIds::FLY_AT_CHAR == nAnchorTyp))
532  {
533  if (nContent > pNd->GetTextNode()->GetText().getLength())
534  {
535  pNd = nullptr; // invalid position
536  }
537  else
538  {
539  aPos.nContent.Assign(pNd->GetTextNode(), nContent);
540  }
541  }
542  if ( pNd )
543  {
544  rAnchor.SetAnchor( &aPos );
545  }
546  }
547 
548  if( !pNd )
549  {
550  // invalid position - assign first page
551  rAnchor.SetType( RndStdIds::FLY_AT_PAGE );
552  rAnchor.SetPageNum( 1 );
553  }
554  }
555  else
556  rAnchor.SetPageNum( nContent );
557 }
558 
560 {
561  SwDoc & rDoc = rContext.GetDoc();
562 
563  // Is the new Format still existent?
564  SwFrameFormat* pDerivedFromFrameFormat = rDoc.FindFrameFormatByName(m_DerivedFromFormatName);
565  if (!pDerivedFromFrameFormat)
566  return;
567 
568  if( m_bAnchorChanged )
570 
571  if( m_pFrameFormat->DerivedFrom() != pDerivedFromFrameFormat)
572  m_pFrameFormat->SetDerivedFrom(pDerivedFromFrameFormat);
573 
574  SfxItemIter aIter( *m_oItemSet );
575  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
576  {
577  if( IsInvalidItem( pItem ))
578  m_pFrameFormat->ResetFormatAttr( m_oItemSet->GetWhichByPos(
579  aIter.GetCurPos() ));
580  else
581  m_pFrameFormat->SetFormatAttr( *pItem );
582  }
583 
584  if( m_bAnchorChanged )
585  {
586  const SwFormatAnchor& rOldAnch = m_pFrameFormat->GetAnchor();
587  if (RndStdIds::FLY_AS_CHAR == rOldAnch.GetAnchorId())
588  {
589  // With InContents it's tricky: the text attribute needs to be
590  // deleted. Unfortunately, this not only destroys the Frames but
591  // also the format. To prevent that, first detach the
592  // connection between attribute and format.
593  const SwPosition *pPos = rOldAnch.GetContentAnchor();
594  SwTextNode *pTextNode = pPos->nNode.GetNode().GetTextNode();
595  OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
596  const sal_Int32 nIdx = pPos->nContent.GetIndex();
597  SwTextAttr * pHint = pTextNode->GetTextAttrForCharAt(
598  nIdx, RES_TXTATR_FLYCNT );
599  assert(pHint && "Missing Hint.");
600  OSL_ENSURE( pHint->Which() == RES_TXTATR_FLYCNT,
601  "Missing FlyInCnt-Hint." );
602  OSL_ENSURE( pHint->GetFlyCnt().GetFrameFormat() == m_pFrameFormat,
603  "Wrong TextFlyCnt-Hint." );
604  const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
605 
606  // Connection is now detached, therefore the attribute can be
607  // deleted
608  pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
609  }
610 
611  // reposition anchor
612  SwFormatAnchor aNewAnchor( m_nOldAnchorType );
613  GetAnchor( aNewAnchor, m_nOldNode, m_nOldContent );
614  m_pFrameFormat->SetFormatAttr( aNewAnchor );
615 
616  if (RndStdIds::FLY_AS_CHAR == aNewAnchor.GetAnchorId())
617  {
618  const SwPosition* pPos = aNewAnchor.GetContentAnchor();
619  SwFormatFlyCnt aFormat( m_pFrameFormat );
620  pPos->nNode.GetNode().GetTextNode()->InsertItem( aFormat,
621  m_nOldContent, 0 );
622  }
623 
625  }
626  rContext.SetSelections(m_pFrameFormat, nullptr);
627 }
628 
630 {
631  SwDoc & rDoc = rContext.GetDoc();
632 
633  // Is the new Format still existent?
634  SwFrameFormat* pNewFrameFormat = rDoc.FindFrameFormatByName(m_NewFormatName);
635  if (!pNewFrameFormat)
636  return;
637 
638  if( m_bAnchorChanged )
639  {
640  SwFormatAnchor aNewAnchor( m_nNewAnchorType );
641  GetAnchor( aNewAnchor, m_nNewNode, m_nNewContent );
643  aSet.Put( aNewAnchor );
644  rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat, &aSet );
645  }
646  else
647  rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat);
648 
649  rContext.SetSelections(m_pFrameFormat, nullptr);
650 }
651 
652 void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem )
653 {
654  if( pItem && pItem != GetDfltAttr( nWhich ) )
655  {
656  // Special treatment for this anchor
657  if( RES_ANCHOR == nWhich )
658  {
659  // only keep the first change
660  OSL_ENSURE( !m_bAnchorChanged, "multiple changes of an anchor are not allowed!" );
661 
662  m_bAnchorChanged = true;
663 
664  const SwFormatAnchor* pAnchor = static_cast<const SwFormatAnchor*>(pItem);
665  m_nOldAnchorType = pAnchor->GetAnchorId();
666  switch( m_nOldAnchorType )
667  {
668  case RndStdIds::FLY_AS_CHAR:
669  case RndStdIds::FLY_AT_CHAR:
671  [[fallthrough]];
672  case RndStdIds::FLY_AT_PARA:
673  case RndStdIds::FLY_AT_FLY:
674  m_nOldNode = pAnchor->GetContentAnchor()->nNode.GetIndex();
675  break;
676 
677  default:
678  m_nOldContent = pAnchor->GetPageNum();
679  }
680 
681  pAnchor = &m_pFrameFormat->GetAnchor();
682  m_nNewAnchorType = pAnchor->GetAnchorId();
683  switch( m_nNewAnchorType )
684  {
685  case RndStdIds::FLY_AS_CHAR:
686  case RndStdIds::FLY_AT_CHAR:
688  [[fallthrough]];
689  case RndStdIds::FLY_AT_PARA:
690  case RndStdIds::FLY_AT_FLY:
691  m_nNewNode = pAnchor->GetContentAnchor()->nNode.GetIndex();
692  break;
693 
694  default:
695  m_nNewContent = pAnchor->GetPageNum();
696  }
697  }
698  else
699  m_oItemSet->Put( *pItem );
700  }
701  else
702  m_oItemSet->InvalidateItem( nWhich );
703 }
704 
706 {
707  if (rHint.GetId() != SfxHintId::SwLegacyModify)
708  return;
709  auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
710  if(!pLegacy->m_pOld)
711  return;
712  const sal_uInt16 nWhich = pLegacy->m_pOld->Which();
713  if(nWhich < POOLATTR_END)
714  PutAttr(nWhich, pLegacy->m_pOld);
715  else if(RES_ATTRSET_CHG == nWhich)
716  {
717  SfxItemIter aIter(*static_cast<const SwAttrSetChg*>(pLegacy->m_pOld)->GetChgSet());
718  for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
719  PutAttr(pItem->Which(), pItem);
720  }
721 }
722 
723 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Starts a section of nodes in the document model.
Definition: node.hxx:313
bool erase(const value_type &x)
Definition: docfmt.cxx:2130
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:224
void SetSelections(SwFrameFormat *const pSelFormat, SdrMarkList *const pMarkList)
Definition: UndoCore.hxx:99
bool GetRanges(std::vector< std::shared_ptr< SwUnoCursor >> &rRanges, SwDoc &rDoc, SwPaM const &rDelPam)
Definition: autofmt.cxx:1114
Marks a position in the document model.
Definition: pam.hxx:36
RndStdIds m_nOldAnchorType
Definition: UndoCore.hxx:196
SwNodeOffset GetMvNodeCnt() const
Definition: undobj.hxx:313
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:2122
const OUString & GetText() const
Definition: ndtxt.hxx:218
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:1209
SwNodeIndex nNode
Definition: pam.hxx:38
static void RemoveIdxFromSection(SwDoc &, SwNodeOffset nSttIdx, const SwNodeOffset *pEndIdx=nullptr)
Definition: undobj.cxx:116
sal_uInt16 GetPageNum() const
Definition: fmtanchr.hxx:66
sal_Int32 m_nNewContent
Definition: UndoCore.hxx:195
SwPaM & GetRepeatPaM()
Definition: UndoCore.hxx:129
Definition: doc.hxx:188
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:121
void SetOtherTextBoxFormat(SwTextBoxNode *pNew)
Definition: frmfmt.hxx:106
sal_Int32 m_nContentPos
Definition: undobj.hxx:303
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
SwUndoDelLayFormat(SwFrameFormat *pFormat)
Definition: undobj1.cxx:427
const SwHistory * GetHistory() const
Definition: undobj.hxx:221
sal_uInt16 Which() const
Definition: txatbase.hxx:114
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
WhichRangesContainer const aFrameFormatSetRange(svl::Items< RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, XATTR_FILL_FIRST, XATTR_FILL_LAST >)
void InsFly(::sw::UndoRedoContext &rContext, bool bShowSel=true)
Definition: undobj1.cxx:89
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:744
SfxHintId GetId() const
sal_Int32 m_nOldContent
Definition: UndoCore.hxx:195
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
SwFrameFormat * FindFrameFormatByName(const OUString &rName) const
Definition: docfmt.cxx:747
void AddTextBox(SdrObject *pDrawObject, SwFrameFormat *pNewTextBox)
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
const OUString m_DerivedFromFormatName
Definition: UndoCore.hxx:191
void DelFly(SwDoc *)
Definition: undobj1.cxx:205
const SfxPoolItem * NextItem()
SwNodeOffset m_nNodePagePos
Definition: undobj.hxx:302
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
SwIndex nContent
Definition: pam.hxx:39
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
SwDoc & GetDoc() const
Definition: UndoCore.hxx:127
for Undo, translated to SwInsertFlags::NOHINTEXPAND
bool IsStartNode() const
Definition: node.hxx:626
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 SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
Definition: hints.cxx:153
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:154
SwDoc & GetDoc() const
Definition: UndoCore.hxx:95
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:321
Specific frame formats (frames, DrawObjects).
bool IsOLENode() const
Definition: node.hxx:654
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:161
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:629
SwNodeIndex * GetMvSttIdx() const
Definition: undobj.hxx:312
SwFrameFormat * GetOwnerShape()
struct _xmlTextWriter * xmlTextWriterPtr
Style of a layout element.
Definition: frmfmt.hxx:59
std::optional< SfxItemSet > m_oItemSet
Definition: UndoCore.hxx:193
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:465
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: undobj1.cxx:499
SwFrameFormat * m_pFrameFormat
Definition: undobj.hxx:301
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
const SwPosition * GetPoint() const
Definition: pam.hxx:208
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: undobj.cxx:1315
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
static SwUndoId lcl_GetSwUndoId(SwFrameFormat const *const pFrameFormat)
Definition: undobj1.cxx:405
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:291
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
Definition: docfly.cxx:632
SwContentNode * GetContentNode()
Definition: node.hxx:617
FlyAnchors.
Definition: fmtanchr.hxx:34
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:323
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
sal_Int32 mnCursorSaveIndexPos
Definition: undobj.hxx:324
Marks a character position inside a document model node.
Definition: index.hxx:33
bool m_bDelFormat
Definition: undobj.hxx:305
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:25
RndStdIds m_nRndId
Definition: undobj.hxx:304
std::optional< OUString > maComment
Definition: undobj.hxx:63
bool IsNoTextNode() const
Definition: node.hxx:650
Marks a node in the document model.
Definition: ndindex.hxx:32
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:695
SwNodeOffset m_nNewNode
Definition: UndoCore.hxx:194
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:435
virtual OUString GetComment() const override
Returns textual comment for this undo object.
Definition: undobj.cxx:662
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: atrfrm.cxx:2866
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
virtual ~SwUndoFlyBase() override
Definition: undobj1.cxx:54
constexpr sal_uInt16 POOLATTR_END(RES_UNKNOWNATR_END)
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
SwUndoInsLayFormat(SwFrameFormat *pFormat, SwNodeOffset nNodeIdx, sal_Int32 nCntIdx)
Definition: undobj1.cxx:273
void PutAttr(sal_uInt16 nWhich, const SfxPoolItem *pItem)
Definition: undobj1.cxx:652
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
void GetAnchor(SwFormatAnchor &rAnhor, SwNodeOffset nNode, sal_Int32 nContent)
Definition: undobj1.cxx:512
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:2632
SwFormat * DerivedFrom() const
Definition: format.hxx:112
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
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 RestoreSection(SwDoc *pDoc, SwNodeIndex *pIdx, sal_uInt16 nSectType)
Definition: undobj.cxx:1275
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:624
SwFrameFormat * m_pFrameFormat
Definition: UndoCore.hxx:190
virtual ~SwUndoSetFlyFormat() override
Definition: undobj1.cxx:508
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:77
virtual ~SwUndoInsLayFormat() override
Definition: undobj1.cxx:287
sal_Int32 GetIndex() const
Definition: index.hxx:91
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2715
SwNodes & GetNodes()
Definition: doc.hxx:409
void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: undobj1.cxx:705
RndStdIds m_nNewAnchorType
Definition: UndoCore.hxx:196
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
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:326
void RemoveAllUnos()
Definition: format.cxx:763
SwUndoSetFlyFormat(SwFrameFormat &rFlyFormat, const SwFrameFormat &rNewFrameFormat)
Definition: undobj1.cxx:487
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:200
SwFrameFormat * GetFrameFormat() const
Definition: fmtflcnt.hxx:45
RndStdIds
virtual OUString GetComment() const override
void RedoForRollback()
Definition: undobj1.cxx:477
SwNodeOffset m_nOldNode
Definition: UndoCore.hxx:194
bool IsInvalidItem(const SfxPoolItem *pItem)
virtual OUString GetComment() const override
Returns textual comment for this undo object.
Definition: undobj1.cxx:369
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:460
bool IsTextNode() const
Definition: node.hxx:638
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:559
void SaveSection(const SwNodeIndex &rSttIdx)
Definition: undobj.cxx:1222
SwTextBoxNode * GetOtherTextBoxFormat() const
Definition: frmfmt.hxx:105
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:140
sal_uInt16 Which() const
const SfxPoolItem * GetCurItem() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1319
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:856
bool HasHints() const
Definition: ndtxt.hxx:228
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1584
SwNodeOffset mnCursorSaveIndexPara
Definition: undobj.hxx:323
const OUString m_NewFormatName
Definition: UndoCore.hxx:192
const SwFormatFlyCnt & GetFlyCnt() const
Definition: txatbase.hxx:210
Base class of the Writer document model elements.
Definition: node.hxx:81
OUString GetDescription() const
Remove OLE-object from "memory".
Definition: ndole.hxx:141
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: undobj1.cxx:328
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo