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