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);
79 
80  if (m_pFrameFormat)
81  {
82  m_pFrameFormat->dumpAsXml(pWriter);
83  }
84 
85  xmlTextWriterEndElement(pWriter);
86 }
87 
88 void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrame)
89 {
90  SwDoc *const pDoc = & rContext.GetDoc();
91 
92  // add again into array
93  SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats();
94  rFlyFormats.push_back( m_pFrameFormat );
95 
96  // OD 26.06.2003 #108784# - insert 'master' drawing object into drawing page
99 
100  SwFormatAnchor aAnchor( m_nRndId );
101 
102  if (RndStdIds::FLY_AT_PAGE == m_nRndId)
103  {
104  aAnchor.SetPageNum( static_cast<sal_uInt16>(m_nNodePagePos) );
105  }
106  else
107  {
108  SwPosition aNewPos(pDoc->GetNodes().GetEndOfContent());
109  aNewPos.nNode = m_nNodePagePos;
110  if ((RndStdIds::FLY_AS_CHAR == m_nRndId) || (RndStdIds::FLY_AT_CHAR == m_nRndId))
111  {
112  aNewPos.nContent.Assign( aNewPos.nNode.GetNode().GetContentNode(),
113  m_nContentPos );
114  }
115  aAnchor.SetAnchor( &aNewPos );
116  }
117 
118  m_pFrameFormat->SetFormatAttr( aAnchor ); // reset anchor
119 
121  {
122  // get Content and reset ContentAttribute
123  SwNodeIndex aIdx( pDoc->GetNodes() );
124  RestoreSection( pDoc, &aIdx, SwFlyStartNode );
125  m_pFrameFormat->SetFormatAttr( SwFormatContent( aIdx.GetNode().GetStartNode() ));
126  }
127 
128  // Set InContentAttribute not until there is content!
129  // Otherwise the layout would format the Fly beforehand but would not find
130  // content; this happened with graphics from the internet.
131  if (RndStdIds::FLY_AS_CHAR == m_nRndId)
132  {
133  // there must be at least the attribute in a TextNode
135  OSL_ENSURE( pCNd->IsTextNode(), "no Text Node at position." );
136  SwFormatFlyCnt aFormat( m_pFrameFormat );
138  }
139 
141  {
142  // recklessly assume that this thing will live longer than the
143  // SwUndoFlyBase - not sure what could be done if that isn't the case...
145 
147  {
149  if (pSdrObject)
150  {
151  // Make sure the old UNO wrapper is no longer cached after changing the shape +
152  // textframe pair. Otherwise we would have a wrapper which doesn't know about its
153  // textframe, even if it's there.
154  pSdrObject->setUnoShape(nullptr);
155  }
156  }
157  }
158 
160 
161  if( bShowSelFrame )
162  {
163  rContext.SetSelections(m_pFrameFormat, nullptr);
164  }
165 
166  if( GetHistory() )
167  GetHistory()->Rollback( pDoc );
168 
169  switch( m_nRndId )
170  {
171  case RndStdIds::FLY_AS_CHAR:
172  case RndStdIds::FLY_AT_CHAR:
173  {
174  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
177  }
178  break;
179  case RndStdIds::FLY_AT_PARA:
180  case RndStdIds::FLY_AT_FLY:
181  {
182  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
184  }
185  break;
186  case RndStdIds::FLY_AT_PAGE:
187  break;
188  default: break;
189  }
190  m_bDelFormat = false;
191 }
192 
194 {
195  m_bDelFormat = true; // delete Format in DTOR
196  m_pFrameFormat->DelFrames(); // destroy Frames
197 
199  { // tdf#108867 clear that pointer
201  }
202 
203  // all Uno objects should now log themselves off
204  {
206  m_pFrameFormat->ModifyNotification( &aMsgHint, &aMsgHint );
207  }
208 
209  if ( RES_DRAWFRMFMT != m_pFrameFormat->Which() )
210  {
211  // if there is content than save it
212  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
213  OSL_ENSURE( rContent.GetContentIdx(), "Fly without content" );
214 
215  SaveSection( *rContent.GetContentIdx() );
216  const_cast<SwFormatContent&>(rContent).SetNewContentIdx( nullptr );
217  }
218  // OD 02.07.2003 #108784# - remove 'master' drawing object from drawing page
219  else
221 
222  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
223  const SwPosition* pPos = rAnchor.GetContentAnchor();
224  // The positions in Nodes array got shifted.
225  m_nRndId = rAnchor.GetAnchorId();
226  if (RndStdIds::FLY_AS_CHAR == m_nRndId)
227  {
228  m_nNodePagePos = pPos->nNode.GetIndex();
229  m_nContentPos = pPos->nContent.GetIndex();
230  SwTextNode *const pTextNd = pPos->nNode.GetNode().GetTextNode();
231  OSL_ENSURE( pTextNd, "No Textnode found" );
232  SwTextFlyCnt* const pAttr = static_cast<SwTextFlyCnt*>(
234  // attribute is still in TextNode, delete
235  if( pAttr && pAttr->GetFlyCnt().GetFrameFormat() == m_pFrameFormat )
236  {
237  // Pointer to 0, do not delete
238  const_cast<SwFormatFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFormat();
239  SwIndex aIdx( pPos->nContent );
240  pTextNd->EraseText( aIdx, 1 );
241  }
242  }
243  else if (RndStdIds::FLY_AT_CHAR == m_nRndId)
244  {
245  m_nNodePagePos = pPos->nNode.GetIndex();
246  m_nContentPos = pPos->nContent.GetIndex();
247  }
248  else if ((RndStdIds::FLY_AT_PARA == m_nRndId) || (RndStdIds::FLY_AT_FLY == m_nRndId))
249  {
250  m_nNodePagePos = pPos->nNode.GetIndex();
251  }
252  else
253  {
254  m_nNodePagePos = rAnchor.GetPageNum();
255  }
256 
257  m_pFrameFormat->ResetFormatAttr( RES_ANCHOR ); // delete anchor
258 
259  // delete from array
260  SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats();
261  rFlyFormats.erase( m_pFrameFormat );
262 }
263 
264 SwUndoInsLayFormat::SwUndoInsLayFormat( SwFrameFormat* pFormat, sal_uLong nNodeIdx, sal_Int32 nCntIdx )
265  : SwUndoFlyBase( pFormat, RES_DRAWFRMFMT == pFormat->Which() ?
267  mnCursorSaveIndexPara( nNodeIdx ), mnCursorSaveIndexPos( nCntIdx )
268 {
269  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
270  m_nRndId = rAnchor.GetAnchorId();
271  m_bDelFormat = false;
272  // note: SwUndoInsLayFormat is called with the content being fully inserted
273  // from most places but with only an empty content section from
274  // CopyLayoutFormat(); it's not necessary here to init m_nNodePagePos
275  // because Undo will do it.
276 }
277 
279 {
280 }
281 
283 {
284  SwDoc & rDoc(rContext.GetDoc());
285  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
286  if( rContent.GetContentIdx() ) // no content
287  {
288  assert(&rContent.GetContentIdx()->GetNodes() == &rDoc.GetNodes());
289  bool bRemoveIdx = true;
290  if( mnCursorSaveIndexPara > 0 )
291  {
292  SwTextNode *const pNode =
293  rDoc.GetNodes()[mnCursorSaveIndexPara]->GetTextNode();
294  if( pNode )
295  {
296  SwNodeIndex aIdx( rDoc.GetNodes(),
297  rContent.GetContentIdx()->GetIndex() );
298  SwNodeIndex aEndIdx( rDoc.GetNodes(),
299  aIdx.GetNode().EndOfSectionIndex() );
301  SwPosition aPos( *pNode, aIndex );
302  SwDoc::CorrAbs( aIdx, aEndIdx, aPos, true );
303  bRemoveIdx = false;
304  }
305  }
306  if( bRemoveIdx )
307  {
308  RemoveIdxFromSection( rDoc, rContent.GetContentIdx()->GetIndex() );
309  }
310  }
311  DelFly(& rDoc);
312 }
313 
315 {
316  InsFly(rContext);
317 }
318 
320 {
321  SwDoc *const pDoc = & rContext.GetDoc();
322  // get anchor and reset it
324  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
325  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
326  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
327  {
328  SwPosition aPos( *rContext.GetRepeatPaM().GetPoint() );
329  if (RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId())
330  {
331  aPos.nContent.Assign( nullptr, 0 );
332  }
333  aAnchor.SetAnchor( &aPos );
334  }
335  else if( RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId() )
336  {
337  SwStartNode const*const pSttNd =
338  rContext.GetRepeatPaM().GetNode().FindFlyStartNode();
339  if( pSttNd )
340  {
341  SwPosition aPos( *pSttNd );
342  aAnchor.SetAnchor( &aPos );
343  }
344  else
345  {
346  return ;
347  }
348  }
349  else if (RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId())
350  {
351  aAnchor.SetPageNum( pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetCurrPage( &rContext.GetRepeatPaM() ));
352  }
353  else {
354  OSL_FAIL( "What kind of anchor is this?" );
355  }
356 
357  (void) pDoc->getIDocumentLayoutAccess().CopyLayoutFormat( *m_pFrameFormat, aAnchor, true, true );
358 }
359 
361 {
362  OUString aResult;
363 
364  // HACK: disable caching:
365  // the SfxUndoManager calls GetComment() too early: the pFrameFormat does not
366  // have a SwDrawContact yet, so it will fall back to SwUndo::GetComment(),
367  // which sets pComment to a wrong value.
368 // if (! pComment)
369  if ((true))
370  {
371  /*
372  If frame format is present and has an SdrObject use the undo
373  comment of the SdrObject. Otherwise use the default comment.
374  */
375  bool bDone = false;
376  if (m_pFrameFormat)
377  {
378  const SdrObject * pSdrObj = m_pFrameFormat->FindSdrObject();
379  if ( pSdrObj )
380  {
381  aResult = SdrUndoNewObj::GetComment( *pSdrObj );
382  bDone = true;
383  }
384  }
385 
386  if (! bDone)
387  aResult = SwUndo::GetComment();
388  }
389  else
390  aResult = *maComment;
391 
392  return aResult;
393 }
394 
395 static SwUndoId
396 lcl_GetSwUndoId(SwFrameFormat const *const pFrameFormat)
397 {
398  if (RES_DRAWFRMFMT != pFrameFormat->Which())
399  {
400  const SwFormatContent& rContent = pFrameFormat->GetContent();
401  OSL_ENSURE( rContent.GetContentIdx(), "Fly without content" );
402 
403  SwNodeIndex firstNode(*rContent.GetContentIdx(), 1);
404  SwNoTextNode *const pNoTextNode(firstNode.GetNode().GetNoTextNode());
405  if (pNoTextNode && pNoTextNode->IsGrfNode())
406  {
407  return SwUndoId::DELGRF;
408  }
409  else if (pNoTextNode && pNoTextNode->IsOLENode())
410  {
411  // surprisingly not SwUndoId::DELOLE, which does not seem to work
412  return SwUndoId::DELETE;
413  }
414  }
415  return SwUndoId::DELLAYFMT;
416 }
417 
419  : SwUndoFlyBase( pFormat, lcl_GetSwUndoId(pFormat) )
420  , m_bShowSelFrame( true )
421 {
422  SwDoc* pDoc = pFormat->GetDoc();
423  DelFly( pDoc );
424 }
425 
427 {
428  SwRewriter aRewriter;
429 
430  SwDoc * pDoc = m_pFrameFormat->GetDoc();
431 
432  if (pDoc)
433  {
434  SwNodeIndex* pIdx = GetMvSttIdx();
435  if( 1 == GetMvNodeCnt() && pIdx)
436  {
437  SwNode *const pNd = & pIdx->GetNode();
438 
439  if ( pNd->IsNoTextNode() && pNd->IsOLENode())
440  {
441  SwOLENode * pOLENd = pNd->GetOLENode();
442 
443  aRewriter.AddRule(UndoArg1, pOLENd->GetDescription());
444  }
445  }
446  }
447 
448  return aRewriter;
449 }
450 
452 {
453  InsFly( rContext, m_bShowSelFrame );
454 }
455 
457 {
458  SwDoc & rDoc(rContext.GetDoc());
459  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
460  if( rContent.GetContentIdx() ) // no content
461  {
462  RemoveIdxFromSection(rDoc, rContent.GetContentIdx()->GetIndex());
463  }
464 
465  DelFly(& rDoc);
466 }
467 
469 {
470  const SwFormatContent& rContent = m_pFrameFormat->GetContent();
471  if( rContent.GetContentIdx() ) // no content
473  rContent.GetContentIdx()->GetIndex() );
474 
476 }
477 
479  : SwUndo( SwUndoId::SETFLYFRMFMT, rFlyFormat.GetDoc() ), SwClient( &rFlyFormat ), m_pFrameFormat( &rFlyFormat ),
480  m_DerivedFromFormatName( rFlyFormat.IsDefault() ? "" : rFlyFormat.DerivedFrom()->GetName() ),
481  m_NewFormatName( rNewFrameFormat.GetName() ),
482  m_pItemSet( new SfxItemSet( *rFlyFormat.GetAttrSet().GetPool(),
483  rFlyFormat.GetAttrSet().GetRanges() )),
484  m_nOldNode( 0 ), m_nNewNode( 0 ),
485  m_nOldContent( 0 ), m_nNewContent( 0 ),
486  m_nOldAnchorType( RndStdIds::FLY_AT_PARA ), m_nNewAnchorType( RndStdIds::FLY_AT_PARA ), m_bAnchorChanged( false )
487 {
488 }
489 
491 {
492  SwRewriter aRewriter;
493 
494  aRewriter.AddRule(UndoArg1, m_NewFormatName);
495 
496  return aRewriter;
497 }
498 
500 {
501 }
502 
504  sal_uLong nNode, sal_Int32 nContent )
505 {
506  RndStdIds nAnchorTyp = rAnchor.GetAnchorId();
507  if (RndStdIds::FLY_AT_PAGE != nAnchorTyp)
508  {
509  SwNode* pNd = m_pFrameFormat->GetDoc()->GetNodes()[ nNode ];
510 
511  if( RndStdIds::FLY_AT_FLY == nAnchorTyp
512  ? ( !pNd->IsStartNode() || SwFlyStartNode !=
513  static_cast<SwStartNode*>(pNd)->GetStartNodeType() )
514  : !pNd->IsTextNode() )
515  {
516  pNd = nullptr; // invalid position
517  }
518  else
519  {
520  SwPosition aPos( *pNd );
521  if ((RndStdIds::FLY_AS_CHAR == nAnchorTyp) ||
522  (RndStdIds::FLY_AT_CHAR == nAnchorTyp))
523  {
524  if (nContent > pNd->GetTextNode()->GetText().getLength())
525  {
526  pNd = nullptr; // invalid position
527  }
528  else
529  {
530  aPos.nContent.Assign(pNd->GetTextNode(), nContent);
531  }
532  }
533  if ( pNd )
534  {
535  rAnchor.SetAnchor( &aPos );
536  }
537  }
538 
539  if( !pNd )
540  {
541  // invalid position - assign first page
542  rAnchor.SetType( RndStdIds::FLY_AT_PAGE );
543  rAnchor.SetPageNum( 1 );
544  }
545  }
546  else
547  rAnchor.SetPageNum( nContent );
548 }
549 
551 {
552  SwDoc & rDoc = rContext.GetDoc();
553 
554  // Is the new Format still existent?
555  SwFrameFormat* pDerivedFromFrameFormat = rDoc.FindFrameFormatByName(m_DerivedFromFormatName);
556  if (!pDerivedFromFrameFormat)
557  return;
558 
559  if( m_bAnchorChanged )
561 
562  if( m_pFrameFormat->DerivedFrom() != pDerivedFromFrameFormat)
563  m_pFrameFormat->SetDerivedFrom(pDerivedFromFrameFormat);
564 
565  SfxItemIter aIter( *m_pItemSet );
566  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
567  {
568  if( IsInvalidItem( pItem ))
569  m_pFrameFormat->ResetFormatAttr( m_pItemSet->GetWhichByPos(
570  aIter.GetCurPos() ));
571  else
572  m_pFrameFormat->SetFormatAttr( *pItem );
573  }
574 
575  if( m_bAnchorChanged )
576  {
577  const SwFormatAnchor& rOldAnch = m_pFrameFormat->GetAnchor();
578  if (RndStdIds::FLY_AS_CHAR == rOldAnch.GetAnchorId())
579  {
580  // With InContents it's tricky: the text attribute needs to be
581  // deleted. Unfortunately, this not only destroys the Frames but
582  // also the format. To prevent that, first detach the
583  // connection between attribute and format.
584  const SwPosition *pPos = rOldAnch.GetContentAnchor();
585  SwTextNode *pTextNode = pPos->nNode.GetNode().GetTextNode();
586  OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
587  const sal_Int32 nIdx = pPos->nContent.GetIndex();
588  SwTextAttr * pHint = pTextNode->GetTextAttrForCharAt(
589  nIdx, RES_TXTATR_FLYCNT );
590  assert(pHint && "Missing Hint.");
591  OSL_ENSURE( pHint->Which() == RES_TXTATR_FLYCNT,
592  "Missing FlyInCnt-Hint." );
593  OSL_ENSURE( pHint->GetFlyCnt().GetFrameFormat() == m_pFrameFormat,
594  "Wrong TextFlyCnt-Hint." );
595  const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
596 
597  // Connection is now detached, therefore the attribute can be
598  // deleted
599  pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
600  }
601 
602  // reposition anchor
603  SwFormatAnchor aNewAnchor( m_nOldAnchorType );
604  GetAnchor( aNewAnchor, m_nOldNode, m_nOldContent );
605  m_pFrameFormat->SetFormatAttr( aNewAnchor );
606 
607  if (RndStdIds::FLY_AS_CHAR == aNewAnchor.GetAnchorId())
608  {
609  const SwPosition* pPos = aNewAnchor.GetContentAnchor();
610  SwFormatFlyCnt aFormat( m_pFrameFormat );
611  pPos->nNode.GetNode().GetTextNode()->InsertItem( aFormat,
612  m_nOldContent, 0 );
613  }
614 
616  }
617  rContext.SetSelections(m_pFrameFormat, nullptr);
618 }
619 
621 {
622  SwDoc & rDoc = rContext.GetDoc();
623 
624  // Is the new Format still existent?
625  SwFrameFormat* pNewFrameFormat = rDoc.FindFrameFormatByName(m_NewFormatName);
626  if (!pNewFrameFormat)
627  return;
628 
629  if( m_bAnchorChanged )
630  {
631  SwFormatAnchor aNewAnchor( m_nNewAnchorType );
632  GetAnchor( aNewAnchor, m_nNewNode, m_nNewContent );
634  aSet.Put( aNewAnchor );
635  rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat, &aSet );
636  }
637  else
638  rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat);
639 
640  rContext.SetSelections(m_pFrameFormat, nullptr);
641 }
642 
643 void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem )
644 {
645  if( pItem && pItem != GetDfltAttr( nWhich ) )
646  {
647  // Special treatment for this anchor
648  if( RES_ANCHOR == nWhich )
649  {
650  // only keep the first change
651  OSL_ENSURE( !m_bAnchorChanged, "multiple changes of an anchor are not allowed!" );
652 
653  m_bAnchorChanged = true;
654 
655  const SwFormatAnchor* pAnchor = static_cast<const SwFormatAnchor*>(pItem);
656  m_nOldAnchorType = pAnchor->GetAnchorId();
657  switch( m_nOldAnchorType )
658  {
659  case RndStdIds::FLY_AS_CHAR:
660  case RndStdIds::FLY_AT_CHAR:
662  [[fallthrough]];
663  case RndStdIds::FLY_AT_PARA:
664  case RndStdIds::FLY_AT_FLY:
665  m_nOldNode = pAnchor->GetContentAnchor()->nNode.GetIndex();
666  break;
667 
668  default:
669  m_nOldContent = pAnchor->GetPageNum();
670  }
671 
672  pAnchor = &m_pFrameFormat->GetAnchor();
673  m_nNewAnchorType = pAnchor->GetAnchorId();
674  switch( m_nNewAnchorType )
675  {
676  case RndStdIds::FLY_AS_CHAR:
677  case RndStdIds::FLY_AT_CHAR:
679  [[fallthrough]];
680  case RndStdIds::FLY_AT_PARA:
681  case RndStdIds::FLY_AT_FLY:
682  m_nNewNode = pAnchor->GetContentAnchor()->nNode.GetIndex();
683  break;
684 
685  default:
686  m_nNewContent = pAnchor->GetPageNum();
687  }
688  }
689  else
690  m_pItemSet->Put( *pItem );
691  }
692  else
693  m_pItemSet->InvalidateItem( nWhich );
694 }
695 
697 {
698  if( !pOld )
699  return;
700 
701  sal_uInt16 nWhich = pOld->Which();
702 
703  if( nWhich < POOLATTR_END )
704  PutAttr( nWhich, pOld );
705  else if( RES_ATTRSET_CHG == nWhich )
706  {
707  SfxItemIter aIter( *static_cast<const SwAttrSetChg*>(pOld)->GetChgSet() );
708  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
709  {
710  PutAttr( pItem->Which(), pItem );
711  }
712  }
713 }
714 
715 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Starts a section of nodes in the document model.
Definition: node.hxx:303
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:211
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:1203
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:184
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:301
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
SwUndoDelLayFormat(SwFrameFormat *pFormat)
Definition: undobj1.cxx:418
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:88
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:739
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:3054
const OUString m_DerivedFromFormatName
Definition: UndoCore.hxx:190
void DelFly(SwDoc *)
Definition: undobj1.cxx:193
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:624
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:1255
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:264
sal_uLong m_nNodePagePos
Definition: undobj.hxx:300
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:326
virtual void ModifyNotification(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.hxx:154
Specific frame formats (frames, DrawObjects).
bool IsOLENode() const
Definition: node.hxx:652
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:620
sal_uLong m_nOldNode
Definition: UndoCore.hxx:193
SwNodeIndex * GetMvSttIdx() const
Definition: undobj.hxx:310
struct _xmlTextWriter * xmlTextWriterPtr
Style of a layout element.
Definition: frmfmt.hxx:57
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:456
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: undobj1.cxx:490
SwFrameFormat * m_pFrameFormat
Definition: undobj.hxx:299
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
const SwPosition * GetPoint() const
Definition: pam.hxx:207
SwFrameFormat * GetOtherTextBoxFormat() const
Definition: frmfmt.hxx:101
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:396
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:282
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
Definition: docfly.cxx:632
SwContentNode * GetContentNode()
Definition: node.hxx:615
FlyAnchors.
Definition: fmtanchr.hxx:34
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:314
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2670
sal_Int32 mnCursorSaveIndexPos
Definition: undobj.hxx:322
Marks a character position inside a document model node.
Definition: index.hxx:33
bool m_bDelFormat
Definition: undobj.hxx:303
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:29
RndStdIds m_nRndId
Definition: undobj.hxx:302
std::optional< OUString > maComment
Definition: undobj.hxx:62
bool IsNoTextNode() const
Definition: node.hxx:648
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
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:426
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:311
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:503
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(179)
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:643
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:458
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:2663
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:1704
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:650
SwFrameFormat * m_pFrameFormat
Definition: UndoCore.hxx:189
virtual ~SwUndoSetFlyFormat() override
Definition: undobj1.cxx:499
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
virtual ~SwUndoInsLayFormat() override
Definition: undobj1.cxx:278
sal_Int32 GetIndex() const
Definition: index.hxx:91
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2681
SwNodes & GetNodes()
Definition: doc.hxx:403
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:376
SwUndoSetFlyFormat(SwFrameFormat &rFlyFormat, const SwFrameFormat &rNewFrameFormat)
Definition: undobj1.cxx:478
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:468
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:360
void Modify(const SfxPoolItem *, const SfxPoolItem *) override
Definition: undobj1.cxx:696
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:451
bool IsTextNode() const
Definition: node.hxx:636
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:550
void SaveSection(const SwNodeIndex &rSttIdx)
Definition: undobj.cxx:1218
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:137
sal_uInt16 Which() const
sal_uLong mnCursorSaveIndexPara
Definition: undobj.hxx:321
const SfxPoolItem * GetCurItem() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1315
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:844
bool HasHints() const
Definition: ndtxt.hxx:221
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:319
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo