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