LibreOffice Module sw (master) 1
undobj1.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <libxml/xmlwriter.h>
21
22#include <svl/itemiter.hxx>
23#include <svx/svdundo.hxx>
24#include <osl/diagnose.h>
25#include <hintids.hxx>
26#include <hints.hxx>
27#include <fmtflcnt.hxx>
28#include <fmtanchr.hxx>
29#include <fmtcntnt.hxx>
30#include <txtflcnt.hxx>
31#include <frmfmt.hxx>
32#include <UndoCore.hxx>
33#include <rolbck.hxx>
34#include <doc.hxx>
36#include <rootfrm.hxx>
37#include <swundo.hxx>
38#include <pam.hxx>
39#include <mvsave.hxx>
40#include <ndtxt.hxx>
41#include <ndole.hxx>
42#include <frameformats.hxx>
43#include <svx/svdobj.hxx>
44
46 : SwUndo(nUndoId, pFormat->GetDoc())
47 , m_pFrameFormat(pFormat)
48 , m_nNodePagePos(0)
49 , m_nContentPos(0)
50 , m_nRndId(RndStdIds::FLY_AT_PARA)
51 , m_bDelFormat(false)
52{
53}
54
56{
57 if( m_bDelFormat ) // delete during an Undo?
58 {
59 if (const auto& pTextBoxes = m_pFrameFormat->GetOtherTextBoxFormats())
60 {
61 // Clear and unregister before release.
63 pTextBoxes->DelTextBox(m_pFrameFormat);
64
66 pTextBoxes->ClearAll();
67
68 // clear that before delete
70 }
71 delete m_pFrameFormat;
72 }
73}
74
76{
77 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwUndoFlyBase"));
78 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nNodePagePos"),
79 BAD_CAST(OString::number(sal_Int32(m_nNodePagePos)).getStr()));
80 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nContentPos"),
81 BAD_CAST(OString::number(m_nContentPos).getStr()));
82 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nRndId"),
83 BAD_CAST(OString::number(static_cast<int>(m_nRndId)).getStr()));
84 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_bDelFormat"),
85 BAD_CAST(OString::boolean(m_bDelFormat).getStr()));
86
87 SwUndo::dumpAsXml(pWriter);
89
91 {
92 m_pFrameFormat->dumpAsXml(pWriter);
93 }
94
95 (void)xmlTextWriterEndElement(pWriter);
96}
97
98void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrame)
99{
100 SwDoc *const pDoc = & rContext.GetDoc();
101
102 // add again into array
103 sw::SpzFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats();
104 rFlyFormats.push_back( static_cast<sw::SpzFrameFormat*>(m_pFrameFormat));
105
106 // OD 26.06.2003 #108784# - insert 'master' drawing object into drawing page
109
110 SwFormatAnchor aAnchor( m_nRndId );
111
112 if (RndStdIds::FLY_AT_PAGE == m_nRndId)
113 {
114 aAnchor.SetPageNum( o3tl::narrowing<sal_uInt16>(sal_Int32(m_nNodePagePos)) );
115 }
116 else
117 {
118 SwPosition aNewPos(*pDoc->GetNodes()[m_nNodePagePos]);
119 if ((RndStdIds::FLY_AS_CHAR == m_nRndId) || (RndStdIds::FLY_AT_CHAR == m_nRndId))
120 {
121 aNewPos.SetContent( m_nContentPos );
122 }
123 aAnchor.SetAnchor( &aNewPos );
124 }
125
126 m_pFrameFormat->SetFormatAttr( aAnchor ); // reset anchor
127
129 {
130 // get Content and reset ContentAttribute
131 SwNodeIndex aIdx( pDoc->GetNodes() );
132 RestoreSection( pDoc, &aIdx, SwFlyStartNode );
134 }
135
136 // Set InContentAttribute not until there is content!
137 // Otherwise the layout would format the Fly beforehand but would not find
138 // content; this happened with graphics from the internet.
139 if (RndStdIds::FLY_AS_CHAR == m_nRndId)
140 {
141 // there must be at least the attribute in a TextNode
142 SwContentNode* pCNd = aAnchor.GetAnchorNode()->GetContentNode();
143 OSL_ENSURE( pCNd->IsTextNode(), "no Text Node at position." );
146 }
147
149 {
150 // recklessly assume that this thing will live longer than the
151 // SwUndoFlyBase - not sure what could be done if that isn't the case...
152 m_pFrameFormat->GetOtherTextBoxFormats()->GetOwnerShape()->SetOtherTextBoxFormats(
154
155 SdrObject* pSdrObject
156 = m_pFrameFormat->GetOtherTextBoxFormats()->GetOwnerShape()->FindSdrObject();
157 if (pSdrObject && m_pFrameFormat->Which() == RES_FLYFRMFMT)
158 m_pFrameFormat->GetOtherTextBoxFormats()->AddTextBox(pSdrObject, m_pFrameFormat);
159
160 if (m_pFrameFormat->GetOtherTextBoxFormats()->GetOwnerShape()->Which() == RES_DRAWFRMFMT)
161 {
162
163 if (pSdrObject)
164 {
165 // Make sure the old UNO wrapper is no longer cached after changing the shape +
166 // textframe pair. Otherwise we would have a wrapper which doesn't know about its
167 // textframe, even if it's there.
168 pSdrObject->setUnoShape(nullptr);
169 }
170 }
172 {
173 SwFrameFormat* pShapeFormat = m_pFrameFormat->GetOtherTextBoxFormats()->GetOwnerShape();
174 pShapeFormat->SetFormatAttr(m_pFrameFormat->GetContent());
175 }
176 }
177
179
180 if( bShowSelFrame )
181 {
182 rContext.SetSelections(m_pFrameFormat, nullptr);
183 }
184
185 if( GetHistory() )
186 GetHistory()->Rollback( pDoc );
187
188 switch( m_nRndId )
189 {
190 case RndStdIds::FLY_AS_CHAR:
191 case RndStdIds::FLY_AT_CHAR:
192 {
193 const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
196 }
197 break;
198 case RndStdIds::FLY_AT_PARA:
199 case RndStdIds::FLY_AT_FLY:
200 {
201 const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
203 }
204 break;
205 case RndStdIds::FLY_AT_PAGE:
206 break;
207 default: break;
208 }
209 m_bDelFormat = false;
210}
211
213{
214 m_bDelFormat = true; // delete Format in DTOR
215 m_pFrameFormat->DelFrames(); // destroy Frames
216
218 { // tdf#108867 clear that pointer
219 m_pFrameFormat->GetOtherTextBoxFormats()->GetOwnerShape()->SetOtherTextBoxFormats(nullptr);
220 }
221
222 // all Uno objects should now log themselves off
224
226 {
227 // if there is content than save it
228 const SwFormatContent& rContent = m_pFrameFormat->GetContent();
229 OSL_ENSURE( rContent.GetContentIdx(), "Fly without content" );
230
231 SaveSection( *rContent.GetContentIdx() );
232 const_cast<SwFormatContent&>(rContent).SetNewContentIdx( nullptr );
233 }
234 // OD 02.07.2003 #108784# - remove 'master' drawing object from drawing page
235 else
237
238 const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
239 SwNode* pAnchorNode = rAnchor.GetAnchorNode();
240 // The positions in Nodes array got shifted.
241 m_nRndId = rAnchor.GetAnchorId();
242 if (RndStdIds::FLY_AS_CHAR == m_nRndId)
243 {
244 m_nNodePagePos = pAnchorNode->GetIndex();
246 SwTextNode *const pTextNd = pAnchorNode->GetTextNode();
247 OSL_ENSURE( pTextNd, "No Textnode found" );
248 SwTextFlyCnt* const pAttr = static_cast<SwTextFlyCnt*>(
250 // attribute is still in TextNode, delete
251 if( pAttr && pAttr->GetFlyCnt().GetFrameFormat() == m_pFrameFormat )
252 {
253 // Pointer to 0, do not delete
254 const_cast<SwFormatFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFormat();
255 pTextNd->EraseText( *rAnchor.GetContentAnchor(), 1 );
256 }
257 }
258 else if (RndStdIds::FLY_AT_CHAR == m_nRndId)
259 {
260 m_nNodePagePos = pAnchorNode->GetIndex();
262 }
263 else if ((RndStdIds::FLY_AT_PARA == m_nRndId) || (RndStdIds::FLY_AT_FLY == m_nRndId))
264 {
265 m_nNodePagePos = pAnchorNode->GetIndex();
266 }
267 else
268 {
270 }
271
272 m_pFrameFormat->ResetFormatAttr( RES_ANCHOR ); // delete anchor
273
274 // delete from array
275 sw::SpzFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats();
276 rFlyFormats.erase(static_cast<sw::SpzFrameFormat*>(m_pFrameFormat));
277}
278
280 : SwUndoFlyBase( pFormat, RES_DRAWFRMFMT == pFormat->Which() ?
282 mnCursorSaveIndexPara( nNodeIdx ), mnCursorSaveIndexPos( nCntIdx )
283{
284 const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
285 m_nRndId = rAnchor.GetAnchorId();
286 m_bDelFormat = false;
287 // note: SwUndoInsLayFormat is called with the content being fully inserted
288 // from most places but with only an empty content section from
289 // CopyLayoutFormat(); it's not necessary here to init m_nNodePagePos
290 // because Undo will do it.
291}
292
294{
295}
296
298{
299 SwDoc & rDoc(rContext.GetDoc());
300 const SwFormatContent& rContent = m_pFrameFormat->GetContent();
301 if( rContent.GetContentIdx() ) // no content
302 {
303 assert(&rContent.GetContentIdx()->GetNodes() == &rDoc.GetNodes());
305 {
306 SwTextNode *const pNode =
307 rDoc.GetNodes()[mnCursorSaveIndexPara]->GetTextNode();
308 if( pNode )
309 {
310 SwNodeIndex aIdx( rDoc.GetNodes(),
311 rContent.GetContentIdx()->GetIndex() );
312 SwNodeIndex aEndIdx( rDoc.GetNodes(),
313 aIdx.GetNode().EndOfSectionIndex() );
314 SwPosition aPos( *pNode, mnCursorSaveIndexPos );
315 // don't delete bookmarks here, DelFly() will save them in history
316 ::PaMCorrAbs(SwPaM(aIdx, aEndIdx), aPos);
317 // TODO: is aPos actually a sensible pos for e.g. SwXText* ?
318 }
319 }
320 }
321 DelFly(& rDoc);
322}
323
325{
326 InsFly(rContext);
327}
328
330{
331 SwDoc *const pDoc = & rContext.GetDoc();
332 // get anchor and reset it
334 if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
335 (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
336 (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
337 {
338 SwPosition aPos( *rContext.GetRepeatPaM().GetPoint() );
339 aAnchor.SetAnchor( &aPos );
340 }
341 else if( RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId() )
342 {
343 SwStartNode const*const pSttNd =
345 if( pSttNd )
346 {
347 SwPosition aPos( *pSttNd );
348 aAnchor.SetAnchor( &aPos );
349 }
350 else
351 {
352 return ;
353 }
354 }
355 else if (RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId())
356 {
358 }
359 else {
360 OSL_FAIL( "What kind of anchor is this?" );
361 }
362
363 (void) pDoc->getIDocumentLayoutAccess().CopyLayoutFormat( *m_pFrameFormat, aAnchor, true, true );
364}
365
367{
368 OUString aResult;
369
370 // HACK: disable caching:
371 // the SfxUndoManager calls GetComment() too early: the pFrameFormat does not
372 // have a SwDrawContact yet, so it will fall back to SwUndo::GetComment(),
373 // which sets pComment to a wrong value.
374// if (! pComment)
375 if ((true))
376 {
377 /*
378 If frame format is present and has an SdrObject use the undo
379 comment of the SdrObject. Otherwise use the default comment.
380 */
381 bool bDone = false;
382 if (m_pFrameFormat)
383 {
384 const SdrObject * pSdrObj = m_pFrameFormat->FindSdrObject();
385 if ( pSdrObj )
386 {
387 aResult = SdrUndoNewObj::GetComment( *pSdrObj );
388 bDone = true;
389 }
390 }
391
392 if (! bDone)
393 aResult = SwUndo::GetComment();
394 }
395 else
396 aResult = *maComment;
397
398 return aResult;
399}
400
401static SwUndoId
402lcl_GetSwUndoId(SwFrameFormat const *const pFrameFormat)
403{
404 if (RES_DRAWFRMFMT != pFrameFormat->Which())
405 {
406 const SwFormatContent& rContent = pFrameFormat->GetContent();
407 OSL_ENSURE( rContent.GetContentIdx(), "Fly without content" );
408
409 SwNodeIndex firstNode(*rContent.GetContentIdx(), 1);
410 SwNoTextNode *const pNoTextNode(firstNode.GetNode().GetNoTextNode());
411 if (pNoTextNode && pNoTextNode->IsGrfNode())
412 {
413 return SwUndoId::DELGRF;
414 }
415 else if (pNoTextNode && pNoTextNode->IsOLENode())
416 {
417 // surprisingly not SwUndoId::DELOLE, which does not seem to work
418 return SwUndoId::DELETE;
419 }
420 }
421 return SwUndoId::DELLAYFMT;
422}
423
425 : SwUndoFlyBase( pFormat, lcl_GetSwUndoId(pFormat) )
426 , m_bShowSelFrame( true )
427{
428 SwDoc* pDoc = pFormat->GetDoc();
429 DelFly( pDoc );
430}
431
433{
434 SwRewriter aRewriter;
435
436 SwDoc * pDoc = m_pFrameFormat->GetDoc();
437
438 if (pDoc)
439 {
440 const SwNodeIndex* pIdx = GetMvSttIdx();
441 if( SwNodeOffset(1) == GetMvNodeCnt() && pIdx)
442 {
443 SwNode *const pNd = & pIdx->GetNode();
444
445 if ( pNd->IsNoTextNode() && pNd->IsOLENode())
446 {
447 SwOLENode * pOLENd = pNd->GetOLENode();
448
449 aRewriter.AddRule(UndoArg1, pOLENd->GetDescription());
450 }
451 }
452 }
453
454 return aRewriter;
455}
456
458{
459 InsFly( rContext, m_bShowSelFrame );
460}
461
463{
464 SwDoc & rDoc(rContext.GetDoc());
465 const SwFormatContent& rContent = m_pFrameFormat->GetContent();
466 if( rContent.GetContentIdx() ) // no content
467 {
468 RemoveIdxFromSection(rDoc, rContent.GetContentIdx()->GetIndex());
469 }
470
471 DelFly(& rDoc);
472}
473
475{
476 const SwFormatContent& rContent = m_pFrameFormat->GetContent();
477 if( rContent.GetContentIdx() ) // no content
479 rContent.GetContentIdx()->GetIndex() );
480
482}
483
485 : SwUndo( SwUndoId::SETFLYFRMFMT, rFlyFormat.GetDoc() ), SwClient( &rFlyFormat ), m_pFrameFormat( &rFlyFormat ),
486 m_DerivedFromFormatName( rFlyFormat.IsDefault() ? "" : rFlyFormat.DerivedFrom()->GetName() ),
487 m_NewFormatName( rNewFrameFormat.GetName() ),
488 m_oItemSet( std::in_place, *rFlyFormat.GetAttrSet().GetPool(),
489 rFlyFormat.GetAttrSet().GetRanges() ),
490 m_nOldNode( 0 ), m_nNewNode( 0 ),
491 m_nOldContent( 0 ), m_nNewContent( 0 ),
492 m_nOldAnchorType( RndStdIds::FLY_AT_PARA ), m_nNewAnchorType( RndStdIds::FLY_AT_PARA ), m_bAnchorChanged( false )
493{
494}
495
497{
498 SwRewriter aRewriter;
499
500 aRewriter.AddRule(UndoArg1, m_NewFormatName);
501
502 return aRewriter;
503}
504
506{
507}
508
510 SwNodeOffset nNode, sal_Int32 nContent )
511{
512 RndStdIds nAnchorTyp = rAnchor.GetAnchorId();
513 if (RndStdIds::FLY_AT_PAGE != nAnchorTyp)
514 {
515 SwNode* pNd = m_pFrameFormat->GetDoc()->GetNodes()[ nNode ];
516
517 if( RndStdIds::FLY_AT_FLY == nAnchorTyp
518 ? ( !pNd->IsStartNode() || SwFlyStartNode !=
519 static_cast<SwStartNode*>(pNd)->GetStartNodeType() )
520 : !pNd->IsTextNode() )
521 {
522 pNd = nullptr; // invalid position
523 }
524 else
525 {
526 SwPosition aPos( *pNd );
527 if ((RndStdIds::FLY_AS_CHAR == nAnchorTyp) ||
528 (RndStdIds::FLY_AT_CHAR == nAnchorTyp))
529 {
530 if (nContent > pNd->GetTextNode()->GetText().getLength())
531 {
532 pNd = nullptr; // invalid position
533 }
534 else
535 {
536 aPos.SetContent(nContent);
537 }
538 }
539 if ( pNd )
540 {
541 rAnchor.SetAnchor( &aPos );
542 }
543 }
544
545 if( !pNd )
546 {
547 // invalid position - assign first page
548 rAnchor.SetType( RndStdIds::FLY_AT_PAGE );
549 rAnchor.SetPageNum( 1 );
550 }
551 }
552 else
553 rAnchor.SetPageNum( nContent );
554}
555
557{
558 SwDoc & rDoc = rContext.GetDoc();
559
560 // Is the new Format still existent?
561 SwFrameFormat* pDerivedFromFrameFormat = rDoc.FindFrameFormatByName(m_DerivedFromFormatName);
562 if (!pDerivedFromFrameFormat)
563 return;
564
565 if( m_bAnchorChanged )
567
568 if( m_pFrameFormat->DerivedFrom() != pDerivedFromFrameFormat)
569 m_pFrameFormat->SetDerivedFrom(pDerivedFromFrameFormat);
570
571 SfxItemIter aIter( *m_oItemSet );
572 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
573 {
574 if( IsInvalidItem( pItem ))
576 aIter.GetCurPos() ));
577 else
578 m_pFrameFormat->SetFormatAttr( *pItem );
579 }
580
581 if( m_bAnchorChanged )
582 {
583 const SwFormatAnchor& rOldAnch = m_pFrameFormat->GetAnchor();
584 if (RndStdIds::FLY_AS_CHAR == rOldAnch.GetAnchorId())
585 {
586 // With InContents it's tricky: the text attribute needs to be
587 // deleted. Unfortunately, this not only destroys the Frames but
588 // also the format. To prevent that, first detach the
589 // connection between attribute and format.
590 SwNode *pAnchorNode = rOldAnch.GetAnchorNode();
591 SwTextNode *pTextNode = pAnchorNode->GetTextNode();
592 OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
593 const sal_Int32 nIdx = rOldAnch.GetAnchorContentOffset();
594 SwTextAttr * pHint = pTextNode->GetTextAttrForCharAt(
595 nIdx, RES_TXTATR_FLYCNT );
596 assert(pHint && "Missing Hint.");
597 OSL_ENSURE( pHint->Which() == RES_TXTATR_FLYCNT,
598 "Missing FlyInCnt-Hint." );
599 OSL_ENSURE( pHint->GetFlyCnt().GetFrameFormat() == m_pFrameFormat,
600 "Wrong TextFlyCnt-Hint." );
601 const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
602
603 // Connection is now detached, therefore the attribute can be
604 // deleted
605 pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
606 }
607
608 // reposition anchor
609 SwFormatAnchor aNewAnchor( m_nOldAnchorType );
610 GetAnchor( aNewAnchor, m_nOldNode, m_nOldContent );
611 m_pFrameFormat->SetFormatAttr( aNewAnchor );
612
613 if (RndStdIds::FLY_AS_CHAR == aNewAnchor.GetAnchorId())
614 {
615 SwNode* pAnchorNode = aNewAnchor.GetAnchorNode();
617 pAnchorNode->GetTextNode()->InsertItem( aFormat,
618 m_nOldContent, 0 );
619 }
620
622 }
623 rContext.SetSelections(m_pFrameFormat, nullptr);
624}
625
627{
628 SwDoc & rDoc = rContext.GetDoc();
629
630 // Is the new Format still existent?
631 SwFrameFormat* pNewFrameFormat = rDoc.FindFrameFormatByName(m_NewFormatName);
632 if (!pNewFrameFormat)
633 return;
634
635 if( m_bAnchorChanged )
636 {
637 SwFormatAnchor aNewAnchor( m_nNewAnchorType );
638 GetAnchor( aNewAnchor, m_nNewNode, m_nNewContent );
640 aSet.Put( aNewAnchor );
641 rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat, &aSet );
642 }
643 else
644 rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat);
645
646 rContext.SetSelections(m_pFrameFormat, nullptr);
647}
648
649void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem )
650{
651 if( pItem && pItem != GetDfltAttr( nWhich ) )
652 {
653 // Special treatment for this anchor
654 if( RES_ANCHOR == nWhich )
655 {
656 // only keep the first change
657 OSL_ENSURE( !m_bAnchorChanged, "multiple changes of an anchor are not allowed!" );
658
659 m_bAnchorChanged = true;
660
661 const SwFormatAnchor* pAnchor = static_cast<const SwFormatAnchor*>(pItem);
662 m_nOldAnchorType = pAnchor->GetAnchorId();
663 switch( m_nOldAnchorType )
664 {
665 case RndStdIds::FLY_AS_CHAR:
666 case RndStdIds::FLY_AT_CHAR:
668 [[fallthrough]];
669 case RndStdIds::FLY_AT_PARA:
670 case RndStdIds::FLY_AT_FLY:
671 m_nOldNode = pAnchor->GetAnchorNode()->GetIndex();
672 break;
673
674 default:
675 m_nOldContent = pAnchor->GetPageNum();
676 }
677
678 pAnchor = &m_pFrameFormat->GetAnchor();
679 m_nNewAnchorType = pAnchor->GetAnchorId();
680 switch( m_nNewAnchorType )
681 {
682 case RndStdIds::FLY_AS_CHAR:
683 case RndStdIds::FLY_AT_CHAR:
685 [[fallthrough]];
686 case RndStdIds::FLY_AT_PARA:
687 case RndStdIds::FLY_AT_FLY:
688 m_nNewNode = pAnchor->GetAnchorNode()->GetIndex();
689 break;
690
691 default:
692 m_nNewContent = pAnchor->GetPageNum();
693 }
694 }
695 else
696 m_oItemSet->Put( *pItem );
697 }
698 else
699 m_oItemSet->InvalidateItem( nWhich );
700}
701
703{
704 if (rHint.GetId() != SfxHintId::SwLegacyModify)
705 return;
706 auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
707 if(!pLegacy->m_pOld)
708 return;
709 const sal_uInt16 nWhich = pLegacy->m_pOld->Which();
710 if(nWhich < POOLATTR_END)
711 PutAttr(nWhich, pLegacy->m_pOld);
712 else if(RES_ATTRSET_CHG == nWhich)
713 {
714 SfxItemIter aIter(*static_cast<const SwAttrSetChg*>(pLegacy->m_pOld)->GetChgSet());
715 for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
716 PutAttr(pItem->Which(), pItem);
717 }
718}
719
720/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ UndoArg1
Definition: SwRewriter.hxx:29
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual SwFrameFormat * CopyLayoutFormat(const SwFrameFormat &rSrc, const SwFormatAnchor &rNewAnchor, bool bSetTextFlyAtt, bool bMakeFrames)=0
virtual void setUnoShape(const css::uno::Reference< css::drawing::XShape > &_rxUnoShape)
virtual OUString GetComment() const override
SfxHintId GetId() const
const SfxPoolItem * GetCurItem() const
sal_uInt16 GetCurPos() const
const SfxPoolItem * NextItem()
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 Which() const
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
const SwAttrSet * GetChgSet() const
What has changed.
Definition: hints.hxx:347
Definition: doc.hxx:197
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
Definition: docfly.cxx:620
SwNodes & GetNodes()
Definition: doc.hxx:422
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:419
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1337
const sw::FrameFormats< sw::SpzFrameFormat * > * GetSpzFrameFormats() const
Definition: doc.hxx:759
SwFrameFormat * FindFrameFormatByName(const OUString &rName) const
Definition: docfmt.cxx:754
FlyAnchors.
Definition: fmtanchr.hxx:37
sal_Int32 GetAnchorContentOffset() const
Definition: atrfrm.cxx:1631
sal_uInt16 GetPageNum() const
Definition: fmtanchr.hxx:70
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:71
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1593
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:68
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:74
SwNode * GetAnchorNode() const
Definition: atrfrm.cxx:1614
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:32
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
Format of a fly content.
Definition: fmtflcnt.hxx:33
SwFrameFormat * GetFrameFormat() const
Definition: fmtflcnt.hxx:45
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:139
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:618
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:318
SwFormat * DerivedFrom() const
Definition: format.hxx:128
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:447
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
void RemoveAllUnos()
Definition: format.cxx:757
Style of a layout element.
Definition: frmfmt.hxx:72
void SetOtherTextBoxFormats(const std::shared_ptr< SwTextBoxNode > &rNew)
Definition: frmfmt.hxx:119
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2733
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2744
const std::shared_ptr< SwTextBoxNode > & GetOtherTextBoxFormats() const
Definition: frmfmt.hxx:118
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: atrfrm.cxx:2892
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:153
bool Rollback(SwDoc *pDoc, sal_uInt16 nStart=0)
Definition: rolbck.cxx:1202
Layout frame for SwNoTextNode, i.e. graphics and OLE nodes (including charts).
Definition: ndnotxt.hxx:30
Marks a node in the document model.
Definition: ndindex.hxx:31
const SwNodes & GetNodes() const
Definition: ndindex.hxx:119
SwNode & GetNode() const
Definition: ndindex.hxx:123
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:111
Base class of the Writer document model elements.
Definition: node.hxx:98
bool IsGrfNode() const
Definition: node.hxx:195
SwStartNode * GetStartNode()
Definition: node.hxx:642
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
SwNodeOffset GetIndex() const
Definition: node.hxx:312
bool IsNoTextNode() const
Definition: node.hxx:194
bool IsStartNode() const
Definition: node.hxx:187
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:220
bool IsTextNode() const
Definition: node.hxx:190
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:165
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:691
SwContentNode * GetContentNode()
Definition: node.hxx:666
SwNoTextNode * GetNoTextNode()
Definition: ndnotxt.hxx:95
bool IsOLENode() const
Definition: node.hxx:193
OUString GetDescription() const
Remove OLE-object from "memory".
Definition: ndole.hxx:145
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
SwNode & GetPointNode() const
Definition: pam.hxx:275
const SwPosition * GetPoint() const
Definition: pam.hxx:253
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:25
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:978
Starts a section of nodes in the document model.
Definition: node.hxx:348
SwStartNodeType GetStartNodeType() const
Definition: node.hxx:364
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
const SwFormatFlyCnt & GetFlyCnt() const
Definition: txatbase.hxx:226
sal_uInt16 Which() const
Definition: txatbase.hxx:116
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
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:1801
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:1305
void EraseText(const SwContentIndex &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:2777
bool HasHints() const
Definition: ndtxt.hxx:254
const OUString & GetText() const
Definition: ndtxt.hxx:244
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:3155
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:457
void RedoForRollback()
Definition: undobj1.cxx:474
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:462
SwUndoDelLayFormat(SwFrameFormat *pFormat)
Definition: undobj1.cxx:424
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: undobj1.cxx:432
void InsFly(::sw::UndoRedoContext &rContext, bool bShowSel=true)
Definition: undobj1.cxx:98
void DelFly(SwDoc *)
Definition: undobj1.cxx:212
RndStdIds m_nRndId
Definition: undobj.hxx:304
SwNodeOffset m_nNodePagePos
Definition: undobj.hxx:302
SwFrameFormat * m_pFrameFormat
Definition: undobj.hxx:301
bool m_bDelFormat
Definition: undobj.hxx:305
SwNodeOffset GetMvNodeCnt() const
Definition: undobj.hxx:313
virtual ~SwUndoFlyBase() override
Definition: undobj1.cxx:55
SwUndoFlyBase(SwFrameFormat *pFormat, SwUndoId nUndoId)
Definition: undobj1.cxx:45
sal_Int32 m_nContentPos
Definition: undobj.hxx:303
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: undobj1.cxx:75
const SwNodeIndex * GetMvSttIdx() const
Definition: undobj.hxx:312
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:297
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:324
SwNodeOffset mnCursorSaveIndexPara
Definition: undobj.hxx:323
SwUndoInsLayFormat(SwFrameFormat *pFormat, SwNodeOffset nNodeIdx, sal_Int32 nCntIdx)
Definition: undobj1.cxx:279
virtual ~SwUndoInsLayFormat() override
Definition: undobj1.cxx:293
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: undobj1.cxx:329
sal_Int32 mnCursorSaveIndexPos
Definition: undobj.hxx:324
virtual OUString GetComment() const override
Returns textual comment for this undo object.
Definition: undobj1.cxx:366
void SaveSection(const SwNodeIndex &rSttIdx)
Definition: undobj.cxx:1268
const SwHistory * GetHistory() const
Definition: undobj.hxx:221
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: undobj.cxx:1361
void RestoreSection(SwDoc *pDoc, SwNodeIndex *pIdx, sal_uInt16 nSectType)
Definition: undobj.cxx:1321
sal_Int32 m_nNewContent
Definition: UndoCore.hxx:200
std::optional< SfxItemSet > m_oItemSet
Definition: UndoCore.hxx:198
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:626
RndStdIds m_nOldAnchorType
Definition: UndoCore.hxx:201
sal_Int32 m_nOldContent
Definition: UndoCore.hxx:200
void GetAnchor(SwFormatAnchor &rAnhor, SwNodeOffset nNode, sal_Int32 nContent)
Definition: undobj1.cxx:509
virtual ~SwUndoSetFlyFormat() override
Definition: undobj1.cxx:505
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: undobj1.cxx:496
void PutAttr(sal_uInt16 nWhich, const SfxPoolItem *pItem)
Definition: undobj1.cxx:649
const OUString m_NewFormatName
Definition: UndoCore.hxx:197
SwFrameFormat * m_pFrameFormat
Definition: UndoCore.hxx:195
const OUString m_DerivedFromFormatName
Definition: UndoCore.hxx:196
SwUndoSetFlyFormat(SwFrameFormat &rFlyFormat, const SwFrameFormat &rNewFrameFormat)
Definition: undobj1.cxx:484
SwNodeOffset m_nNewNode
Definition: UndoCore.hxx:199
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:556
RndStdIds m_nNewAnchorType
Definition: UndoCore.hxx:201
SwNodeOffset m_nOldNode
Definition: UndoCore.hxx:199
void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: undobj1.cxx:702
std::optional< OUString > maComment
Definition: undobj.hxx:63
virtual OUString GetComment() const override
Returns textual comment for this undo object.
Definition: undobj.cxx:694
static void RemoveIdxFromSection(SwDoc &, SwNodeOffset nSttIdx, const SwNodeOffset *pEndIdx=nullptr)
Definition: undobj.cxx:108
std::pair< const_iterator, bool > push_back(const value_type &x)
bool erase(const value_type &x)
SwDoc & GetDoc() const
Definition: UndoCore.hxx:132
SwPaM & GetRepeatPaM()
Definition: UndoCore.hxx:134
SwDoc & GetDoc() const
Definition: UndoCore.hxx:95
void SetSelections(SwFrameFormat *const pSelFormat, SdrMarkList *const pMarkList)
Definition: UndoCore.hxx:99
struct _xmlTextWriter * xmlTextWriterPtr
virtual OUString GetName() const override
void PaMCorrAbs(const SwPaM &rRange, const SwPosition &rNewPos)
Function declarations so that everything below the CursorShell can move the Cursor once in a while.
Definition: doccorr.cxx:90
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(169)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(162)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(165)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(110)
constexpr sal_uInt16 POOLATTR_END(RES_UNKNOWNATR_END)
const SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
Definition: hints.cxx:147
WhichRangesContainer const aFrameFormatSetRange(svl::Items< RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, XATTR_FILL_FIRST, XATTR_FILL_LAST >)
bool GetRanges(std::vector< std::shared_ptr< SwUnoCursor > > &rRanges, SwDoc &rDoc, SwPaM const &rDelPam)
Definition: autofmt.cxx:1111
@ SwFlyStartNode
Definition: ndtyp.hxx:54
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
bool IsInvalidItem(const SfxPoolItem *pItem)
Marks a position in the document model.
Definition: pam.hxx:38
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
Definition: pam.cxx:267
const SfxPoolItem * m_pOld
Definition: calbck.hxx:77
RndStdIds
@ NOHINTEXPAND
for Undo, translated to SwInsertFlags::NOHINTEXPAND
SwUndoId
Definition: swundo.hxx:30
static SwUndoId lcl_GetSwUndoId(SwFrameFormat const *const pFrameFormat)
Definition: undobj1.cxx:402