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