LibreOffice Module sw (master) 1
docfly.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 <hintids.hxx>
21#include <svl/itemiter.hxx>
22#include <svx/svdobj.hxx>
23#include <svx/svdmark.hxx>
24#include <osl/diagnose.h>
25#include <fmtfsize.hxx>
26#include <fmtornt.hxx>
27#include <dcontact.hxx>
28#include <ndgrf.hxx>
29#include <doc.hxx>
30#include <IDocumentUndoRedo.hxx>
32#include <IDocumentState.hxx>
34#include <ndindex.hxx>
35#include <drawdoc.hxx>
36#include <fmtcntnt.hxx>
37#include <fmtanchr.hxx>
38#include <fmtflcnt.hxx>
39#include <txtfrm.hxx>
40#include <notxtfrm.hxx>
41#include <pagefrm.hxx>
42#include <rootfrm.hxx>
43#include <flyfrm.hxx>
44#include <textboxhelper.hxx>
45#include <txatbase.hxx>
46#include <frmfmt.hxx>
47#include <ndtxt.hxx>
48#include <pam.hxx>
49#include <swundo.hxx>
50#include <crstate.hxx>
51#include <UndoCore.hxx>
52#include <UndoAttribute.hxx>
53#include <fmtcnct.hxx>
54#include <dflyobj.hxx>
55#include <undoflystrattr.hxx>
56#include <calbck.hxx>
57#include <frameformats.hxx>
58#include <memory>
59#include <svx/xbtmpit.hxx>
60#include <svx/xflftrit.hxx>
61#include <svx/xlndsit.hxx>
62#include <svx/xlnstit.hxx>
63#include <svx/xlnedit.hxx>
64#include <svx/xflhtit.hxx>
65#include <formatflysplit.hxx>
66
67using namespace ::com::sun::star;
68
69size_t SwDoc::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const
70{
71 size_t nCount = 0;
72 const SwNodeIndex* pIdx;
73
74 for(sw::SpzFrameFormat* pFlyFormat: *GetSpzFrameFormats())
75 {
76 if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT))
77 continue;
78
79 if( RES_FLYFRMFMT != pFlyFormat->Which() )
80 continue;
81 pIdx = pFlyFormat->GetContent().GetContentIdx();
82 if( pIdx && pIdx->GetNodes().IsDocNodes() )
83 {
84 const SwNode* pNd = GetNodes()[ pIdx->GetIndex() + 1 ];
85
86 switch( eType )
87 {
88 case FLYCNTTYPE_FRM:
89 if(!pNd->IsNoTextNode())
90 nCount++;
91 break;
92
93 case FLYCNTTYPE_GRF:
94 if( pNd->IsGrfNode() )
95 nCount++;
96 break;
97
98 case FLYCNTTYPE_OLE:
99 if(pNd->IsOLENode())
100 nCount++;
101 break;
102
103 default:
104 nCount++;
105 }
106 }
107 }
108 return nCount;
109}
110
112SwFrameFormat* SwDoc::GetFlyNum( size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes )
113{
114 SwFrameFormat* pRetFormat = nullptr;
115 const SwNodeIndex* pIdx;
116 size_t nCount = 0;
117
118 for(sw::SpzFrameFormat* pFlyFormat: *GetSpzFrameFormats())
119 {
120 if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT))
121 continue;
122
123 if( RES_FLYFRMFMT != pFlyFormat->Which() )
124 continue;
125 pIdx = pFlyFormat->GetContent().GetContentIdx();
126 if( pIdx && pIdx->GetNodes().IsDocNodes() )
127 {
128 const SwNode* pNd = GetNodes()[ pIdx->GetIndex() + 1 ];
129 switch( eType )
130 {
131 case FLYCNTTYPE_FRM:
132 if( !pNd->IsNoTextNode() && nIdx == nCount++)
133 pRetFormat = pFlyFormat;
134 break;
135 case FLYCNTTYPE_GRF:
136 if(pNd->IsGrfNode() && nIdx == nCount++ )
137 pRetFormat = pFlyFormat;
138 break;
139 case FLYCNTTYPE_OLE:
140 if(pNd->IsOLENode() && nIdx == nCount++)
141 pRetFormat = pFlyFormat;
142 break;
143 default:
144 if(nIdx == nCount++)
145 pRetFormat = pFlyFormat;
146 }
147 }
148 }
149 return pRetFormat;
150}
151
152std::vector<SwFrameFormat const*> SwDoc::GetFlyFrameFormats(
153 FlyCntType const eType, bool const bIgnoreTextBoxes)
154{
155 std::vector<SwFrameFormat const*> ret;
156 ret.reserve(GetSpzFrameFormats()->size());
157
158 for(sw::SpzFrameFormat* pFlyFormat: *GetSpzFrameFormats())
159 {
160 if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT))
161 {
162 continue;
163 }
164
165 if (RES_FLYFRMFMT != pFlyFormat->Which())
166 {
167 continue;
168 }
169
170 SwNodeIndex const*const pIdx(pFlyFormat->GetContent().GetContentIdx());
171 if (pIdx && pIdx->GetNodes().IsDocNodes())
172 {
173 SwNode const*const pNd = GetNodes()[ pIdx->GetIndex() + 1 ];
174 switch (eType)
175 {
176 case FLYCNTTYPE_FRM:
177 if (!pNd->IsNoTextNode())
178 ret.push_back(pFlyFormat);
179 break;
180 case FLYCNTTYPE_GRF:
181 if (pNd->IsGrfNode())
182 ret.push_back(pFlyFormat);
183 break;
184 case FLYCNTTYPE_OLE:
185 if (pNd->IsOLENode())
186 ret.push_back(pFlyFormat);
187 break;
188 default:
189 ret.push_back(pFlyFormat);
190 }
191 }
192 }
193
194 return ret;
195}
196
197static Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFormatAnchor& rAnch,
198 const SwFrameFormat* pFlyFormat )
199{
200 Point aRet;
202 switch( rAnch.GetAnchorId() )
203 {
204 case RndStdIds::FLY_AS_CHAR:
205 if( pFlyFormat && rAnch.GetAnchorNode() )
206 {
207 const SwFrame* pOld = static_cast<const SwFlyFrameFormat*>(pFlyFormat)->GetFrame( &aRet );
208 if( pOld )
209 aRet = pOld->getFrameArea().Pos();
210 }
211 break;
212
213 case RndStdIds::FLY_AT_PARA:
214 case RndStdIds::FLY_AT_CHAR: // LAYER_IMPL
215 if( rAnch.GetAnchorNode() )
216 {
217 const SwContentNode* pNd = rAnch.GetAnchorNode()->GetContentNode();
218 std::pair<Point, bool> const tmp(aRet, false);
219 const SwFrame* pOld = pNd ? pNd->getLayoutFrame(rDoc.getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, &tmp) : nullptr;
220 if( pOld )
221 aRet = pOld->getFrameArea().Pos();
222 }
223 break;
224
225 case RndStdIds::FLY_AT_FLY: // LAYER_IMPL
226 if( rAnch.GetAnchorNode() )
227 {
228 const SwFlyFrameFormat* pFormat = static_cast<SwFlyFrameFormat*>(rAnch.GetAnchorNode()->
229 GetFlyFormat());
230 const SwFrame* pOld = pFormat ? pFormat->GetFrame( &aRet ) : nullptr;
231 if( pOld )
232 aRet = pOld->getFrameArea().Pos();
233 }
234 break;
235
236 case RndStdIds::FLY_AT_PAGE:
237 {
238 sal_uInt16 nPgNum = rAnch.GetPageNum();
239 const SwPageFrame *pPage = static_cast<SwPageFrame*>(rDoc.getIDocumentLayoutAccess().GetCurrentLayout()->Lower());
240 for( sal_uInt16 i = 1; (i <= nPgNum) && pPage; ++i,
241 pPage =static_cast<const SwPageFrame*>(pPage->GetNext()) )
242 if( i == nPgNum )
243 {
244 aRet = pPage->getFrameArea().Pos();
245 break;
246 }
247 }
248 break;
249 default:
250 break;
251 }
252 return aRet;
253}
254
255#define MAKEFRMS 0
256#define IGNOREANCHOR 1
257#define DONTMAKEFRMS 2
258
260{
261 // Changing anchors is almost always allowed.
262 // Exception: Paragraph and character bound frames must not become
263 // page bound, if they are located in the header or footer.
264 const SwFormatAnchor &rOldAnch = rFormat.GetAnchor();
265 const RndStdIds nOld = rOldAnch.GetAnchorId();
266
267 SwFormatAnchor aNewAnch( rSet.Get( RES_ANCHOR ) );
268 RndStdIds nNew = aNewAnch.GetAnchorId();
269
270 // Is the new anchor valid?
271 if( !aNewAnch.GetAnchorNode() && (RndStdIds::FLY_AT_FLY == nNew ||
272 (RndStdIds::FLY_AT_PARA == nNew) || (RndStdIds::FLY_AS_CHAR == nNew) ||
273 (RndStdIds::FLY_AT_CHAR == nNew) ))
274 {
275 return IGNOREANCHOR;
276 }
277
278 if( nOld == nNew )
279 return DONTMAKEFRMS;
280
281 Point aOldAnchorPos( ::lcl_FindAnchorLayPos( *this, rOldAnch, &rFormat ));
282 Point aNewAnchorPos( ::lcl_FindAnchorLayPos( *this, aNewAnch, nullptr ));
283
284 // Destroy the old Frames.
285 // The Views are hidden implicitly, so hiding them another time would be
286 // kind of a show!
287 rFormat.DelFrames();
288
289 if ( RndStdIds::FLY_AS_CHAR == nOld )
290 {
291 // We need to handle InContents in a special way:
292 // The TextAttribut needs to be destroyed which, unfortunately, also
293 // destroys the format. To avoid that, we disconnect the format from
294 // the attribute.
295 SwNode *pAnchorNode = rOldAnch.GetAnchorNode();
296 SwTextNode *pTextNode = pAnchorNode->GetTextNode();
297 OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
298 const sal_Int32 nIdx = rOldAnch.GetAnchorContentOffset();
299 SwTextAttr * const pHint =
300 pTextNode->GetTextAttrForCharAt( nIdx, RES_TXTATR_FLYCNT );
301 OSL_ENSURE( pHint && pHint->Which() == RES_TXTATR_FLYCNT,
302 "Missing FlyInCnt-Hint." );
303 OSL_ENSURE( pHint && pHint->GetFlyCnt().GetFrameFormat() == &rFormat,
304 "Wrong TextFlyCnt-Hint." );
305 if (pHint)
306 const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
307
308 // They are disconnected. We now have to destroy the attribute.
309 pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
310 }
311
312 // We can finally set the attribute. It needs to be the first one!
313 // Undo depends on it!
314 rFormat.SetFormatAttr( aNewAnch );
315
316 // Correct the position
317 switch( nNew )
318 {
319 case RndStdIds::FLY_AS_CHAR:
320 // If no position attributes are received, we have to make sure
321 // that no forbidden automatic alignment is left.
322 {
323 SwNode *pAnchorNode = aNewAnch.GetAnchorNode();
324 SwTextNode *pNd = pAnchorNode->GetTextNode();
325 OSL_ENSURE( pNd, "Cursor does not point to TextNode." );
326
327 SwFormatFlyCnt aFormat( static_cast<SwFlyFrameFormat*>(&rFormat) );
328 pNd->InsertItem( aFormat, aNewAnch.GetAnchorContentOffset(), 0 );
329 }
330
331 if( SfxItemState::SET != rSet.GetItemState( RES_VERT_ORIENT, false ))
332 {
333 SwFormatVertOrient aOldV( rFormat.GetVertOrient() );
334 bool bSet = true;
335 switch( aOldV.GetVertOrient() )
336 {
337 case text::VertOrientation::LINE_TOP: aOldV.SetVertOrient( text::VertOrientation::TOP ); break;
338 case text::VertOrientation::LINE_CENTER: aOldV.SetVertOrient( text::VertOrientation::CENTER); break;
339 case text::VertOrientation::LINE_BOTTOM: aOldV.SetVertOrient( text::VertOrientation::BOTTOM); break;
340 case text::VertOrientation::NONE: aOldV.SetVertOrient( text::VertOrientation::CENTER); break;
341 default:
342 bSet = false;
343 }
344 if( bSet )
345 rSet.Put( aOldV );
346 }
347 break;
348
349 case RndStdIds::FLY_AT_PARA:
350 case RndStdIds::FLY_AT_CHAR: // LAYER_IMPL
351 case RndStdIds::FLY_AT_FLY: // LAYER_IMPL
352 case RndStdIds::FLY_AT_PAGE:
353 {
354 // If only the anchor type has changed (char -> para -> page) and the absolute position
355 // is unchanged even though there is a new relative orientation
356 // (likely because the old orientation was not valid for the new anchor type),
357 // then adjust the position to account for the moved anchor position.
358 const SwFormatHoriOrient* pHoriOrientItem = rSet.GetItemIfSet( RES_HORI_ORIENT, false );
359
360 SwFormatHoriOrient aOldH( rFormat.GetHoriOrient() );
361 bool bPutOldH(false);
362
363 if (text::HoriOrientation::NONE == aOldH.GetHoriOrient() && pHoriOrientItem
364 && text::HoriOrientation::NONE == pHoriOrientItem->GetHoriOrient()
365 && aOldH.GetPos() == pHoriOrientItem->GetPos())
366 {
367 SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldH.GetPos();
368 nPos += aOldAnchorPos.getX() - aNewAnchorPos.getX();
369
370 assert(aOldH.GetRelationOrient() != pHoriOrientItem->GetRelationOrient());
371 aOldH.SetRelationOrient(pHoriOrientItem->GetRelationOrient());
372
373 aOldH.SetPos( nPos );
374 bPutOldH = true;
375 }
376 if (nNew == RndStdIds::FLY_AT_PAGE)
377 {
378 sal_Int16 nRelOrient(pHoriOrientItem
379 ? pHoriOrientItem->GetRelationOrient()
380 : aOldH.GetRelationOrient());
381 if (sw::GetAtPageRelOrientation(nRelOrient, false))
382 {
383 SAL_INFO("sw.ui", "fixing horizontal RelOrientation for at-page anchor");
384 aOldH.SetRelationOrient(nRelOrient);
385 bPutOldH = true;
386 }
387 }
388 if (bPutOldH)
389 {
390 rSet.Put( aOldH );
391 }
392
393 const SwFormatVertOrient* pVertOrientItem = rSet.GetItemIfSet( RES_VERT_ORIENT, false );
394 SwFormatVertOrient aOldV( rFormat.GetVertOrient() );
395
396 if (text::VertOrientation::NONE == aOldV.GetVertOrient() && pVertOrientItem
397 && text::VertOrientation::NONE == pVertOrientItem->GetVertOrient()
398 && aOldV.GetPos() == pVertOrientItem->GetPos())
399 {
400 SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldV.GetPos();
401 nPos += aOldAnchorPos.getY() - aNewAnchorPos.getY();
402
403 assert(aOldV.GetRelationOrient() != pVertOrientItem->GetRelationOrient());
404 aOldV.SetRelationOrient(pVertOrientItem->GetRelationOrient());
405
406 aOldV.SetPos( nPos );
407 rSet.Put( aOldV );
408 }
409 }
410 break;
411 default:
412 break;
413 }
414
415 if( bNewFrames )
416 rFormat.MakeFrames();
417
418 return MAKEFRMS;
419}
420
421static bool
423 sal_Int8 (SwDoc::*pSetFlyFrameAnchor)(SwFrameFormat &, SfxItemSet &, bool),
424 SwFrameFormat & rFlyFormat, SfxItemSet & rSet)
425{
426 // #i32968# Inserting columns in the frame causes MakeFrameFormat to put two
427 // objects of type SwUndoFrameFormat on the undo stack. We don't want them.
428 ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
429
430 // Is the anchor attribute included?
431 // If so, we pass it to a special method, which returns true
432 // if the Fly needs to be created anew, because we e.g change the FlyType.
433 sal_Int8 const nMakeFrames =
434 (SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false ))
435 ? (rDoc.*pSetFlyFrameAnchor)( rFlyFormat, rSet, false )
436 : DONTMAKEFRMS;
437
438 const SfxPoolItem* pItem;
439 SfxItemIter aIter( rSet );
441 const SfxPoolItem* pItemIter = aIter.GetCurItem();
442 do {
443 switch(pItemIter->Which())
444 {
445 case RES_FILL_ORDER:
446 case RES_BREAK:
447 case RES_PAGEDESC:
448 case RES_CNTNT:
449 case RES_FOOTER:
450 OSL_FAIL( "Unknown Fly attribute." );
451 [[fallthrough]];
452 case RES_CHAIN:
453 rSet.ClearItem(pItemIter->Which());
454 break;
455 case RES_ANCHOR:
456 if( DONTMAKEFRMS != nMakeFrames )
457 break;
458 [[fallthrough]];
459 default:
460 if( !IsInvalidItem(pItemIter) && ( SfxItemState::SET !=
461 rFlyFormat.GetAttrSet().GetItemState(pItemIter->Which(), true, &pItem ) ||
462 *pItem != *pItemIter))
463 aTmpSet.Put(*pItemIter);
464 break;
465 }
466
467 pItemIter = aIter.NextItem();
468
469 } while (pItemIter && (0 != pItemIter->Which()));
470
471 if( aTmpSet.Count() )
472 rFlyFormat.SetFormatAttr( aTmpSet );
473
474 if( MAKEFRMS == nMakeFrames )
475 rFlyFormat.MakeFrames();
476
477 return aTmpSet.Count() || MAKEFRMS == nMakeFrames;
478}
479
481{
483 SfxItemIter aIter(rSet);
484
485 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
486 {
487 if (IsInvalidItem(pItem))
488 continue;
489 std::unique_ptr<SfxPoolItem> pResult;
490
491 switch(pItem->Which())
492 {
493 case XATTR_FILLBITMAP:
494 {
495 pResult = pItem->StaticWhichCast(XATTR_FILLBITMAP).checkForUniqueItem(pDrawModel);
496 break;
497 }
498 case XATTR_LINEDASH:
499 {
500 pResult = pItem->StaticWhichCast(XATTR_LINEDASH).checkForUniqueItem(pDrawModel);
501 break;
502 }
503 case XATTR_LINESTART:
504 {
505 pResult = pItem->StaticWhichCast(XATTR_LINESTART).checkForUniqueItem(pDrawModel);
506 break;
507 }
508 case XATTR_LINEEND:
509 {
510 pResult = pItem->StaticWhichCast(XATTR_LINEEND).checkForUniqueItem(pDrawModel);
511 break;
512 }
514 {
515 pResult = pItem->StaticWhichCast(XATTR_FILLGRADIENT).checkForUniqueItem(pDrawModel);
516 break;
517 }
519 {
520 pResult = pItem->StaticWhichCast(XATTR_FILLFLOATTRANSPARENCE).checkForUniqueItem(pDrawModel);
521 break;
522 }
523 case XATTR_FILLHATCH:
524 {
525 pResult = pItem->StaticWhichCast(XATTR_FILLHATCH).checkForUniqueItem(pDrawModel);
526 break;
527 }
528 }
529
530 if(pResult)
531 {
532 rSet.Put(std::move(pResult));
533 }
534 }
535}
536
538{
539 if( !rSet.Count() )
540 return false;
541
542 SwDocModifyAndUndoGuard guard(rFlyFormat);
543
544 bool const bRet = lcl_SetFlyFrameAttr(*this, &SwDoc::SetFlyFrameAnchor, rFlyFormat, rSet);
545
546 //SwTextBoxHelper::syncFlyFrameAttr(rFlyFormat, rSet);
547
548 return bRet;
549}
550
551// #i73249#
553 const OUString& sNewTitle )
554{
555 if ( rFlyFrameFormat.GetObjTitle() == sNewTitle )
556 {
557 return;
558 }
559
560 ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo());
561
562 if (GetIDocumentUndoRedo().DoesUndo())
563 {
564 GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoFlyStrAttr>( rFlyFrameFormat,
566 rFlyFrameFormat.GetObjTitle(),
567 sNewTitle ) );
568 }
569
570 rFlyFrameFormat.SetObjTitle( sNewTitle, true );
571
573}
574
576 const OUString& sNewDescription )
577{
578 if ( rFlyFrameFormat.GetObjDescription() == sNewDescription )
579 {
580 return;
581 }
582
583 ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo());
584
585 if (GetIDocumentUndoRedo().DoesUndo())
586 {
587 GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoFlyStrAttr>( rFlyFrameFormat,
589 rFlyFrameFormat.GetObjDescription(),
590 sNewDescription ) );
591 }
592
593 rFlyFrameFormat.SetObjDescription( sNewDescription, true );
594
596}
597
599 bool const isDecorative)
600{
601 if (rFlyFrameFormat.GetAttrSet().Get(RES_DECORATIVE).GetValue() == isDecorative)
602 {
603 return;
604 }
605
606 ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo());
607
608 if (GetIDocumentUndoRedo().DoesUndo())
609 {
610 GetIDocumentUndoRedo().AppendUndo(
611 std::make_unique<SwUndoFlyDecorative>(rFlyFrameFormat, isDecorative));
612 }
613
614 rFlyFrameFormat.SetObjDecorative(isDecorative);
615
617}
618
619
621 SfxItemSet* pSet, bool bKeepOrient )
622{
623 bool bChgAnchor = false, bFrameSz = false;
624
625 const SwFormatFrameSize aFrameSz( rFormat.GetFrameSize() );
626
627 SwUndoSetFlyFormat* pUndo = nullptr;
628 bool const bUndo = GetIDocumentUndoRedo().DoesUndo();
629 if (bUndo)
630 {
631 pUndo = new SwUndoSetFlyFormat( rFormat, rNewFormat );
632 GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
633 }
634
635 // #i32968# Inserting columns in the section causes MakeFrameFormat to put
636 // 2 objects of type SwUndoFrameFormat on the undo stack. We don't want them.
637 ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
638
639 // Set the column first, or we'll have trouble with
640 //Set/Reset/Synch. and so on
641 if( SfxItemState::SET != rNewFormat.GetAttrSet().GetItemState( RES_COL ))
642 rFormat.ResetFormatAttr( RES_COL );
643
644 if( rFormat.DerivedFrom() != &rNewFormat )
645 {
646 rFormat.SetDerivedFrom( &rNewFormat );
647
648 // 1. If not automatic = ignore; else = dispose
649 // 2. Dispose of it!
650 if( SfxItemState::SET == rNewFormat.GetAttrSet().GetItemState( RES_FRM_SIZE, false ))
651 {
652 rFormat.ResetFormatAttr( RES_FRM_SIZE );
653 bFrameSz = true;
654 }
655
656 const SfxItemSet* pAsk = pSet;
657 if( !pAsk ) pAsk = &rNewFormat.GetAttrSet();
658 const SwFormatAnchor* pFormatAnchor = pAsk->GetItemIfSet( RES_ANCHOR, false );
659 if( pFormatAnchor
660 && pFormatAnchor->GetAnchorId() !=
661 rFormat.GetAnchor().GetAnchorId() )
662 {
663 if( pSet )
664 bChgAnchor = MAKEFRMS == SetFlyFrameAnchor( rFormat, *pSet, false );
665 else
666 {
667 // Needs to have the FlyFormat range, because we set attributes in it,
668 // in SetFlyFrameAnchor.
669 SfxItemSet aFlySet( *rNewFormat.GetAttrSet().GetPool(),
670 rNewFormat.GetAttrSet().GetRanges() );
671 aFlySet.Put( *pFormatAnchor );
672 bChgAnchor = MAKEFRMS == SetFlyFrameAnchor( rFormat, aFlySet, false);
673 }
674 }
675 }
676
677 // Only reset vertical and horizontal orientation, if we have automatic alignment
678 // set in the template. Otherwise use the old value.
679 // If we update the frame template the Fly should NOT lose its orientation (which
680 // is not being updated!).
681 // text::HoriOrientation::NONE and text::VertOrientation::NONE are allowed now
682 if (!bKeepOrient)
683 {
686 }
687
692
693 if( !bFrameSz )
694 rFormat.SetFormatAttr( aFrameSz );
695
696 if( bChgAnchor )
697 rFormat.MakeFrames();
698
699 if( pUndo )
700 pUndo->EndListeningAll();
701
703
704 return bChgAnchor;
705}
706
707void SwDoc::GetGrfNms( const SwFlyFrameFormat& rFormat, OUString* pGrfName,
708 OUString* pFltName )
709{
710 SwNodeIndex aIdx( *rFormat.GetContent().GetContentIdx(), 1 );
711 const SwGrfNode* pGrfNd = aIdx.GetNode().GetGrfNode();
712 if( pGrfNd && pGrfNd->IsLinkedFile() )
713 pGrfNd->GetFileFilterNms( pGrfName, pFltName );
714}
715
716bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
717 RndStdIds _eAnchorType,
718 const bool _bSameOnly,
719 const bool _bPosCorr )
720{
721 OSL_ENSURE( getIDocumentLayoutAccess().GetCurrentLayout(), "No layout!" );
722
723 if ( !_rMrkList.GetMarkCount() ||
725 {
726 return false;
727 }
728
729 GetIDocumentUndoRedo().StartUndo( SwUndoId::INSATTR, nullptr );
730
731 bool bUnmark = false;
732 for ( size_t i = 0; i < _rMrkList.GetMarkCount(); ++i )
733 {
734 SdrObject* pObj = _rMrkList.GetMark( i )->GetMarkedSdrObj();
735 if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
736 {
737 SwDrawContact* pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
738
739 // consider, that drawing object has
740 // no user call. E.g.: a 'virtual' drawing object is disconnected by
741 // the anchor type change of the 'master' drawing object.
742 // Continue with next selected object and assert, if this isn't excepted.
743 if ( !pContact )
744 {
745#if OSL_DEBUG_LEVEL > 0
746 auto pSwDrawVirtObj = dynamic_cast<SwDrawVirtObj*>( pObj);
747 bool bNoUserCallExcepted = pSwDrawVirtObj && !pSwDrawVirtObj->IsConnected();
748 OSL_ENSURE( bNoUserCallExcepted, "SwDoc::ChgAnchor(..) - no contact at selected drawing object" );
749#endif
750 continue;
751 }
752
753 // #i26791#
754 const SwFrame* pOldAnchorFrame = pContact->GetAnchorFrame( pObj );
755 const SwFrame* pNewAnchorFrame = pOldAnchorFrame;
756
757 // #i54336#
758 // Instead of only keeping the index position for an as-character
759 // anchored object the complete <SwPosition> is kept, because the
760 // anchor index position could be moved, if the object again is
761 // anchored as character.
762 std::optional<SwPosition> oOldAsCharAnchorPos;
763 const RndStdIds eOldAnchorType = pContact->GetAnchorId();
764 if ( !_bSameOnly && eOldAnchorType == RndStdIds::FLY_AS_CHAR )
765 {
766 oOldAsCharAnchorPos.emplace(*pContact->GetAnchorFormat().GetContentAnchor());
767 }
768
769 if ( _bSameOnly )
770 _eAnchorType = eOldAnchorType;
771
772 SwFormatAnchor aNewAnch( _eAnchorType );
773 SwAnchoredObject *pAnchoredObj = pContact->GetAnchoredObj(pObj);
774 tools::Rectangle aObjRect(pAnchoredObj->GetObjRect().SVRect());
775 const Point aPt( aObjRect.TopLeft() );
776
777 switch ( _eAnchorType )
778 {
779 case RndStdIds::FLY_AT_PARA:
780 case RndStdIds::FLY_AT_CHAR:
781 {
782 const Point aNewPoint = ( pOldAnchorFrame->IsVertical() ||
783 pOldAnchorFrame->IsRightToLeft() )
784 ? aObjRect.TopRight()
785 : aPt;
786
787 // allow drawing objects in header/footer
788 pNewAnchorFrame = ::FindAnchor( pOldAnchorFrame, aNewPoint );
789 if ( pNewAnchorFrame->IsTextFrame() && static_cast<const SwTextFrame*>(pNewAnchorFrame)->IsFollow() )
790 {
791 pNewAnchorFrame = static_cast<const SwTextFrame*>(pNewAnchorFrame)->FindMaster();
792 }
793 if ( pNewAnchorFrame->IsProtected() )
794 {
795 pNewAnchorFrame = nullptr;
796 }
797 else
798 {
799 SwPosition aPos( pNewAnchorFrame->IsTextFrame()
800 ? *static_cast<SwTextFrame const*>(pNewAnchorFrame)->GetTextNodeForParaProps()
801 : *static_cast<SwNoTextFrame const*>(pNewAnchorFrame)->GetNode() );
802
803 aNewAnch.SetType( _eAnchorType );
804 aNewAnch.SetAnchor( &aPos );
805 }
806 }
807 break;
808
809 case RndStdIds::FLY_AT_FLY: // LAYER_IMPL
810 {
811 // Search the closest SwFlyFrame starting from the upper left corner.
812 SwFrame *pTextFrame;
813 {
815 SwPosition aPos( GetNodes() );
816 Point aPoint( aPt );
817 aPoint.setX(aPoint.getX() - 1);
819 // consider that drawing objects can be in
820 // header/footer. Thus, <GetFrame()> by left-top-corner
821 std::pair<Point, bool> const tmp(aPt, false);
822 pTextFrame = aPos.GetNode().
824 getIDocumentLayoutAccess().GetCurrentLayout(),
825 nullptr, &tmp);
826 }
827 const SwFrame *pTmp = ::FindAnchor( pTextFrame, aPt );
828 pNewAnchorFrame = pTmp->FindFlyFrame();
829 if( pNewAnchorFrame && !pNewAnchorFrame->IsProtected() )
830 {
831 const SwFrameFormat *pTmpFormat = static_cast<const SwFlyFrame*>(pNewAnchorFrame)->GetFormat();
832 const SwFormatContent& rContent = pTmpFormat->GetContent();
833 SwPosition aPos( *rContent.GetContentIdx() );
834 aNewAnch.SetAnchor( &aPos );
835 break;
836 }
837
838 aNewAnch.SetType( RndStdIds::FLY_AT_PAGE );
839 [[fallthrough]];
840 }
841 case RndStdIds::FLY_AT_PAGE:
842 {
843 pNewAnchorFrame = getIDocumentLayoutAccess().GetCurrentLayout()->Lower();
844 while ( pNewAnchorFrame && !pNewAnchorFrame->getFrameArea().Contains( aPt ) )
845 pNewAnchorFrame = pNewAnchorFrame->GetNext();
846 if ( !pNewAnchorFrame )
847 continue;
848
849 aNewAnch.SetPageNum( static_cast<const SwPageFrame*>(pNewAnchorFrame)->GetPhyPageNum());
850 }
851 break;
852 case RndStdIds::FLY_AS_CHAR:
853 if( _bSameOnly ) // Change of position/size
854 {
855 if( !pOldAnchorFrame )
856 {
857 pContact->ConnectToLayout();
858 pOldAnchorFrame = pContact->GetAnchorFrame();
859 }
860 const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pOldAnchorFrame))->Prepare();
861 }
862 else // Change of anchors
863 {
864 // allow drawing objects in header/footer
865 pNewAnchorFrame = ::FindAnchor( pOldAnchorFrame, aPt );
866 if( pNewAnchorFrame->IsProtected() )
867 {
868 pNewAnchorFrame = nullptr;
869 break;
870 }
871
872 bUnmark = ( 0 != i );
873 Point aPoint( aPt );
874 aPoint.setX(aPoint.getX() - 1); // Do not load in the DrawObj!
875 aNewAnch.SetType( RndStdIds::FLY_AS_CHAR );
876 assert(pNewAnchorFrame->IsTextFrame()); // because AS_CHAR
877 SwTextFrame const*const pFrame(
878 static_cast<SwTextFrame const*>(pNewAnchorFrame));
879 SwPosition aPos( *pFrame->GetTextNodeForParaProps() );
880 if ( pNewAnchorFrame->getFrameArea().Contains( aPoint ) )
881 {
882 // We need to find a TextNode, because only there we can anchor a
883 // content-bound DrawObject.
886 }
887 else
888 {
889 if ( pNewAnchorFrame->getFrameArea().Bottom() < aPt.Y() )
890 {
891 aPos = pFrame->MapViewToModelPos(TextFrameIndex(0));
892 }
893 else
894 {
895 aPos = pFrame->MapViewToModelPos(
896 TextFrameIndex(pFrame->GetText().getLength()));
897 }
898 }
899 aNewAnch.SetAnchor( &aPos );
900 SetAttr( aNewAnch, *pContact->GetFormat() );
901 // #i26791# - adjust vertical positioning to 'center to
902 // baseline'
903 SetAttr( SwFormatVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME ), *pContact->GetFormat() );
904 SwTextNode *pNd = aPos.GetNode().GetTextNode();
905 OSL_ENSURE( pNd, "Cursor not positioned at TextNode." );
906
907 SwFormatFlyCnt aFormat( pContact->GetFormat() );
908 pNd->InsertItem( aFormat, aPos.GetContentIndex(), 0 );
909
910 // Has a textbox attached to the format? Sync it as well!
911 if (pContact->GetFormat() && pContact->GetFormat()->GetOtherTextBoxFormats())
912 {
914 SwTextBoxHelper::changeAnchor, pContact->GetFormat(), pObj);
915 }
916 }
917 break;
918 default:
919 OSL_ENSURE( false, "unexpected AnchorId." );
920 }
921
922 if ( (RndStdIds::FLY_AS_CHAR != _eAnchorType) &&
923 pNewAnchorFrame &&
924 ( !_bSameOnly || pNewAnchorFrame != pOldAnchorFrame ) )
925 {
926 // #i26791# - Direct object positioning no longer needed. Apply
927 // of attributes (method call <SetAttr(..)>) takes care of the
928 // invalidation of the object position.
929 if ( _bPosCorr )
930 {
931 // #i33313# - consider not connected 'virtual' drawing
932 // objects
933 auto pSwDrawVirtObj = dynamic_cast<SwDrawVirtObj*>( pObj);
934 if ( pSwDrawVirtObj && !pSwDrawVirtObj->IsConnected() )
935 {
936 SwRect aNewObjRect( aObjRect );
937 static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( nullptr ))
938 ->AdjustPositioningAttr( pNewAnchorFrame,
939 &aNewObjRect );
940 }
941 else
942 {
943 static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( pObj ))
944 ->AdjustPositioningAttr( pNewAnchorFrame );
945 }
946 }
947 if (aNewAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
948 {
949 SwFormatHoriOrient item(pContact->GetFormat()->GetHoriOrient());
950 sal_Int16 nRelOrient(item.GetRelationOrient());
951 if (sw::GetAtPageRelOrientation(nRelOrient, false))
952 {
953 SAL_INFO("sw.ui", "fixing horizontal RelOrientation for at-page anchor");
954 item.SetRelationOrient(nRelOrient);
955 SetAttr(item, *pContact->GetFormat());
956 }
957 }
958 // tdf#136385 set the anchor last - otherwise it messes up the
959 // position in SwDrawContact::Changed_() callback
960 SetAttr(aNewAnch, *pContact->GetFormat());
961 }
962
963 // we have changed the anchoring attributes, and those are used to
964 // order the object in its sorted list, so update its position
965 pAnchoredObj->UpdateObjInSortedList();
966
967 // #i54336#
968 if (oOldAsCharAnchorPos)
969 {
970 if ( pNewAnchorFrame)
971 {
972 // We need to handle InContents in a special way:
973 // The TextAttribut needs to be destroyed which, unfortunately, also
974 // destroys the format. To avoid that, we disconnect the format from
975 // the attribute.
976 const sal_Int32 nIndx( oOldAsCharAnchorPos->GetContentIndex() );
977 SwTextNode* pTextNode( oOldAsCharAnchorPos->GetNode().GetTextNode() );
978 assert(pTextNode && "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object");
979 SwTextAttr * const pHint =
980 pTextNode->GetTextAttrForCharAt( nIndx, RES_TXTATR_FLYCNT );
981 assert(pHint && "Missing FlyInCnt-Hint.");
982 const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
983
984 // They are disconnected. We now have to destroy the attribute.
985 pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx );
986 }
987 }
988 }
989 }
990
991 GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
993
994 return bUnmark;
995}
996
998{
999 // The Source must not yet have a Follow.
1000 const SwFormatChain &rOldChain = rSource.GetChain();
1001 if ( rOldChain.GetNext() )
1003
1004 // Target must not be equal to Source and we also must not have a closed chain.
1005 const SwFrameFormat *pFormat = &rDest;
1006 do {
1007 if( pFormat == &rSource )
1008 return SwChainRet::SELF;
1009 pFormat = pFormat->GetChain().GetNext();
1010 } while ( pFormat );
1011
1012 // There must not be a chaining from outside to inside or the other way around.
1013 if( rDest.IsLowerOf( rSource ) || rSource .IsLowerOf( rDest ) )
1014 return SwChainRet::SELF;
1015
1016 // The Target must not yet have a Master.
1017 const SwFormatChain &rChain = rDest.GetChain();
1018 if( rChain.GetPrev() )
1020
1021 // Split flys are incompatible with chaining.
1022 const SwFormatFlySplit& rOldSplit = rSource.GetFlySplit();
1023 if (rOldSplit.GetValue())
1024 {
1026 }
1027 const SwFormatFlySplit& rNewSplit = rDest.GetFlySplit();
1028 if (rNewSplit.GetValue())
1029 {
1031 }
1032
1033 // Target must be empty.
1034 const SwNodeIndex* pCntIdx = rDest.GetContent().GetContentIdx();
1035 if( !pCntIdx )
1036 return SwChainRet::NOT_FOUND;
1037
1038 SwNodeIndex aNxtIdx( *pCntIdx, 1 );
1039 const SwTextNode* pTextNd = aNxtIdx.GetNode().GetTextNode();
1040 if( !pTextNd )
1041 return SwChainRet::NOT_FOUND;
1042
1043 const SwNodeOffset nFlySttNd = pCntIdx->GetIndex();
1044 if( SwNodeOffset(2) != ( pCntIdx->GetNode().EndOfSectionIndex() - nFlySttNd ) ||
1045 pTextNd->GetText().getLength() )
1046 {
1047 return SwChainRet::NOT_EMPTY;
1048 }
1049
1050 for(sw::SpzFrameFormat* pSpzFrameFm: *GetSpzFrameFormats())
1051 {
1052 const SwFormatAnchor& rAnchor = pSpzFrameFm->GetAnchor();
1053 // #i20622# - to-frame anchored objects are allowed.
1054 if ( (rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PARA) &&
1055 (rAnchor.GetAnchorId() != RndStdIds::FLY_AT_CHAR) )
1056 continue;
1057 if ( nullptr == rAnchor.GetAnchorNode() )
1058 continue;
1059 SwNodeOffset nTstSttNd = rAnchor.GetAnchorNode()->GetIndex();
1060 if( nFlySttNd <= nTstSttNd && nTstSttNd < nFlySttNd + SwNodeOffset(2) )
1061 {
1062 return SwChainRet::NOT_EMPTY;
1063 }
1064 }
1065
1066 // We also need to consider the right area.
1067 // Both Flys need to be located in the same area (Body, Header/Footer, Fly).
1068 // If the Source is not the selected frame, it's enough to find a suitable
1069 // one. e.g. if it's requested by the API.
1070
1071 // both in the same fly, header, footer or on the page?
1072 const SwFormatAnchor &rSrcAnchor = rSource.GetAnchor(),
1073 &rDstAnchor = rDest.GetAnchor();
1074 SwNodeOffset nEndOfExtras = GetNodes().GetEndOfExtras().GetIndex();
1075 bool bAllowed = false;
1076 if ( RndStdIds::FLY_AT_PAGE == rSrcAnchor.GetAnchorId() )
1077 {
1078 if ( (RndStdIds::FLY_AT_PAGE == rDstAnchor.GetAnchorId()) ||
1079 ( rDstAnchor.GetAnchorNode() &&
1080 rDstAnchor.GetAnchorNode()->GetIndex() > nEndOfExtras ))
1081 bAllowed = true;
1082 }
1083 else if( rSrcAnchor.GetAnchorNode() && rDstAnchor.GetAnchorNode() )
1084 {
1085 const SwNode &rSrcNd = *rSrcAnchor.GetAnchorNode(),
1086 &rDstNd = *rDstAnchor.GetAnchorNode();
1087 const SwStartNode* pSttNd = nullptr;
1088 if( rSrcNd == rDstNd ||
1089 ( !pSttNd &&
1090 nullptr != ( pSttNd = rSrcNd.FindFlyStartNode() ) &&
1091 pSttNd == rDstNd.FindFlyStartNode() ) ||
1092 ( !pSttNd &&
1093 nullptr != ( pSttNd = rSrcNd.FindFooterStartNode() ) &&
1094 pSttNd == rDstNd.FindFooterStartNode() ) ||
1095 ( !pSttNd &&
1096 nullptr != ( pSttNd = rSrcNd.FindHeaderStartNode() ) &&
1097 pSttNd == rDstNd.FindHeaderStartNode() ) ||
1098 ( !pSttNd && rDstNd.GetIndex() > nEndOfExtras &&
1099 rSrcNd.GetIndex() > nEndOfExtras ))
1100 bAllowed = true;
1101 }
1102
1103 return bAllowed ? SwChainRet::OK : SwChainRet::WRONG_AREA;
1104}
1105
1107{
1108 SwChainRet nErr = Chainable( rSource, rDest );
1109 if ( nErr == SwChainRet::OK )
1110 {
1111 GetIDocumentUndoRedo().StartUndo( SwUndoId::CHAINE, nullptr );
1112
1113 SwFlyFrameFormat& rDestFormat = const_cast<SwFlyFrameFormat&>(static_cast<const SwFlyFrameFormat&>(rDest));
1114
1115 // Attach Follow to the Master.
1116 SwFormatChain aChain = rDestFormat.GetChain();
1117 aChain.SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1118 SetAttr( aChain, rDestFormat );
1119
1121 RES_CHAIN, RES_CHAIN> aSet( GetAttrPool() );
1122
1123 // Attach Follow to the Master.
1124 aChain.SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1125 SetAttr( aChain, rDestFormat );
1126
1127 // Attach Master to the Follow.
1128 // Make sure that the Master has a fixed height.
1129 aChain = rSource.GetChain();
1130 aChain.SetNext( &rDestFormat );
1131 aSet.Put( aChain );
1132
1133 SwFormatFrameSize aSize( rSource.GetFrameSize() );
1134 if ( aSize.GetHeightSizeType() != SwFrameSize::Fixed )
1135 {
1137 if ( pFly )
1138 aSize.SetHeight( pFly->getFrameArea().Height() );
1140 aSet.Put( aSize );
1141 }
1142 SetAttr( aSet, rSource );
1143
1144 GetIDocumentUndoRedo().EndUndo( SwUndoId::CHAINE, nullptr );
1145 }
1146 return nErr;
1147}
1148
1150{
1151 SwFormatChain aChain( rFormat.GetChain() );
1152 if ( aChain.GetNext() )
1153 {
1154 GetIDocumentUndoRedo().StartUndo( SwUndoId::UNCHAIN, nullptr );
1155 SwFrameFormat *pFollow = aChain.GetNext();
1156 aChain.SetNext( nullptr );
1157 SetAttr( aChain, rFormat );
1158 aChain = pFollow->GetChain();
1159 aChain.SetPrev( nullptr );
1160 SetAttr( aChain, *pFollow );
1161 GetIDocumentUndoRedo().EndUndo( SwUndoId::UNCHAIN, nullptr );
1162 }
1163}
1164
1165/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
virtual SwDrawModel * GetOrCreateDrawModel()=0
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
virtual void SetModified()=0
Must be called manually at changes of format.
constexpr tools::Long Y() const
void setX(tools::Long nX)
constexpr tools::Long getX() const
constexpr tools::Long getY() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
SdrObject * GetMarkedSdrObj() const
SdrObject * getParentSdrObjectFromSdrObject() const
bool GetValue() const
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
const WhichRangesContainer & GetRanges() const
sal_uInt16 Count() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 Which() const
void SetHeight(tools::Long n)
class for the positioning of drawing objects
wrapper class for the positioning of Writer fly frames and drawing objects
virtual SwRect GetObjRect() const =0
void UpdateObjInSortedList()
method to update anchored object in the <SwSortedObjs> lists
SwAttrPool * GetPool() const
Definition: swatrset.hxx:190
void EndListeningAll()
Definition: calbck.cxx:136
const SwFormatAnchor & GetAnchorFormat() const
some virtual helper methods for information about the object (Writer fly frame resp.
Definition: dcontact.hxx:138
RndStdIds GetAnchorId() const
Definition: dcontact.hxx:145
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1223
Definition: doc.hxx:197
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
Definition: docfly.cxx:620
void SetFlyFrameTitle(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewTitle)
Definition: docfly.cxx:552
SwChainRet Chainable(const SwFrameFormat &rSource, const SwFrameFormat &rDest)
Definition: docfly.cxx:997
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:408
void SetFlyFrameDecorative(SwFlyFrameFormat &rFlyFrameFormat, bool isDecorative)
Definition: docfly.cxx:598
SwChainRet Chain(SwFrameFormat &rSource, const SwFrameFormat &rDest)
Definition: docfly.cxx:1106
void SetFlyFrameDescription(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewDescription)
Definition: docfly.cxx:575
SwFrameFormat * GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes=false)
Definition: docfly.cxx:112
void Unchain(SwFrameFormat &rFormat)
Definition: docfly.cxx:1149
void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet &rSet)
Definition: docfly.cxx:480
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history.
Definition: docfmt.cxx:458
std::vector< SwFrameFormat const * > GetFlyFrameFormats(FlyCntType eType, bool bIgnoreTextBoxes)
Definition: docfly.cxx:152
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:158
SwNodes & GetNodes()
Definition: doc.hxx:422
size_t GetFlyCount(FlyCntType eType, bool bIgnoreTextBoxes=false) const
Access to frames.
Definition: docfly.cxx:69
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:419
static void GetGrfNms(const SwFlyFrameFormat &rFormat, OUString *pGrfName, OUString *pFltName)
Definition: docfly.cxx:707
bool ChgAnchor(const SdrMarkList &_rMrkList, RndStdIds _eAnchorType, const bool _bSameOnly, const bool _bPosCorr)
Definition: docfly.cxx:716
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1337
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:169
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Definition: docfly.cxx:537
const sw::FrameFormats< sw::SpzFrameFormat * > * GetSpzFrameFormats() const
Definition: doc.hxx:759
sal_Int8 SetFlyFrameAnchor(SwFrameFormat &rFlyFormat, SfxItemSet &rSet, bool bNewFrames)
Definition: docfly.cxx:259
ContactObject for connection of formats as representatives of draw objects in SwClient and the object...
Definition: dcontact.hxx:305
const SwFrame * GetAnchorFrame(const SdrObject *_pDrawObj=nullptr) const
Definition: dcontact.cxx:804
void ConnectToLayout(const SwFormatAnchor *pAnch=nullptr)
Inserts SdrObject in the arrays of the layout ((SwPageFrame and SwFrame).
Definition: dcontact.cxx:1796
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const override
Definition: dcontact.cxx:762
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object.
Definition: dcontact.hxx:212
bool IsConnected() const
is 'virtual' drawing object connected to writer layout and / to drawing layer.
Definition: dcontact.cxx:2419
void SetObjDescription(const OUString &rDescription, bool bBroadcast=false)
Definition: atrfrm.cxx:3208
OUString GetObjDescription() const
Definition: atrfrm.cxx:3226
SwFlyFrame * GetFrame(const Point *pDocPos=nullptr) const
Definition: atrfrm.cxx:3140
void SetObjDecorative(bool isDecorative)
Definition: atrfrm.cxx:3240
OUString GetObjTitle() const
Definition: atrfrm.cxx:3184
void SetObjTitle(const OUString &rTitle, bool bBroadcast=false)
Definition: atrfrm.cxx:3166
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
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
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:32
SwFlyFrameFormat * GetPrev() const
Definition: fmtcnct.hxx:53
void SetNext(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2179
void SetPrev(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2171
SwFlyFrameFormat * GetNext() const
Definition: fmtcnct.hxx:54
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
Determines if a fly frame can be split across multiple pages.
void SetHeightSizeType(SwFrameSize eSize)
Definition: fmtfsize.hxx:81
SwFrameSize GetHeightSizeType() const
Definition: fmtfsize.hxx:80
Defines the horizontal position of a fly frame.
Definition: fmtornt.hxx:73
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:100
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:94
void SetRelationOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:97
SwTwips GetPos() const
Definition: fmtornt.hxx:99
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:95
Defines the vertical position of a fly frame.
Definition: fmtornt.hxx:37
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:58
SwTwips GetPos() const
Definition: fmtornt.hxx:62
void SetVertOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:59
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:63
void SetRelationOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:60
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:57
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:618
const SwFormatFlySplit & GetFlySplit(bool=true) const
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:113
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:318
SwFormat * DerivedFrom() const
Definition: format.hxx:128
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:115
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:447
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
const SwRect & getFrameArea() const
Definition: frame.hxx:179
Style of a layout element.
Definition: frmfmt.hxx:72
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
bool IsLowerOf(const SwFrameFormat &rFormat) const
Definition: atrfrm.cxx:2822
const std::shared_ptr< SwTextBoxNode > & GetOtherTextBoxFormats() const
Definition: frmfmt.hxx:118
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsTextFrame() const
Definition: frame.hxx:1240
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1117
SwFrame * GetNext()
Definition: frame.hxx:682
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1639
bool IsRightToLeft() const
Definition: frame.hxx:993
bool IsVertical() const
Definition: frame.hxx:979
bool IsLinkedFile() const
Definition: ndgrf.hxx:160
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
Definition: ndgrf.cxx:470
TElementType * First()
Definition: calbck.hxx:372
const SwFrame * Lower() const
Definition: layfrm.hxx:101
const SwContentNode * GetNode() const
Definition: notxtfrm.hxx:77
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
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:150
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
SwNodeOffset GetIndex() const
Definition: node.hxx:312
const SwStartNode * FindFooterStartNode() const
Definition: node.hxx:226
bool IsNoTextNode() const
Definition: node.hxx:194
const SwStartNode * FindHeaderStartNode() const
Definition: node.hxx:224
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:220
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:691
SwContentNode * GetContentNode()
Definition: node.hxx:666
bool IsOLENode() const
Definition: node.hxx:193
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:163
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
Definition: nodes.cxx:2555
A page of the document layout.
Definition: pagefrm.hxx:60
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Height(tools::Long nNew)
Definition: swrect.hxx:193
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
void Pos(const Point &rNew)
Definition: swrect.hxx:171
bool Contains(const Point &rPOINT) const
Definition: swrect.hxx:356
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Definition: trvlfrm.cxx:425
Starts a section of nodes in the document model.
Definition: node.hxx:348
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
static bool changeAnchor(SwFrameFormat *pShape, SdrObject *pObj)
Sets the anchor of the associated textframe of the given shape, and returns true on success.
static void synchronizeGroupTextBoxProperty(bool pFunc(SwFrameFormat *, SdrObject *), SwFrameFormat *pFormat, SdrObject *pObj)
Calls the method given by pFunc with every textboxes of the group given by pFormat.
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1333
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true) override
SwContentFrame: the shortcut for the Frames If the void* casts wrongly, it's its own fault!...
Definition: txtfrm.cxx:2840
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1380
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1390
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
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
constexpr Point TopLeft() const
constexpr Point TopRight() const
@ SetOnlyText
stay with the cursor inside text
int nCount
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:172
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
static Point lcl_FindAnchorLayPos(SwDoc &rDoc, const SwFormatAnchor &rAnch, const SwFrameFormat *pFlyFormat)
Definition: docfly.cxx:197
#define DONTMAKEFRMS
Definition: docfly.cxx:257
#define IGNOREANCHOR
Definition: docfly.cxx:256
#define MAKEFRMS
Definition: docfly.cxx:255
static bool lcl_SetFlyFrameAttr(SwDoc &rDoc, sal_Int8(SwDoc::*pSetFlyFrameAnchor)(SwFrameFormat &, SfxItemSet &, bool), SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Definition: docfly.cxx:422
static SwContentNode * GetContentNode(SwDoc &rDoc, SwPosition &rPos, bool bNext)
Definition: fltshell.cxx:54
SwChainRet
Definition: flyenum.hxx:34
@ NOT_EMPTY
Only empty frames may be connected.
@ IS_IN_CHAIN
Destination already in chain.
@ SOURCE_CHAINED
Source already has a follow.
@ NOT_FOUND
Destination and/or source not found.
@ SELF
Self-chaining is not allowed.
@ WRONG_AREA
Destination in section where it shouldn't be (header, footer).
FlyCntType
Definition: flyenum.hxx:24
@ FLYCNTTYPE_GRF
Definition: flyenum.hxx:27
@ FLYCNTTYPE_OLE
Definition: flyenum.hxx:28
@ FLYCNTTYPE_FRM
Definition: flyenum.hxx:26
const SwContentFrame * FindAnchor(const SwFrame *pOldAnch, const Point &rNew, const bool bBody=false)
search an anchor for paragraph bound frames starting from pOldAnch
Definition: flycnt.cxx:1084
DocumentType eType
@ Fixed
Frame cannot be moved in Var-direction.
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr TypedWhichId< SwFormatCol > RES_COL(115)
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(109)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(108)
constexpr TypedWhichId< SwFormatEditInReadonly > RES_EDIT_IN_READONLY(118)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
constexpr TypedWhichId< SwFormatFillOrder > RES_FILL_ORDER(RES_FRMATR_BEGIN)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(162)
constexpr TypedWhichId< SwFormatFooter > RES_FOOTER(103)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(110)
constexpr TypedWhichId< SfxBoolItem > RES_DECORATIVE(140)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(120)
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(107)
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(101)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(97)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(104)
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 >)
sal_uInt16 nPos
#define SAL_INFO(area, stream)
size
int i
bool GetAtPageRelOrientation(sal_Int16 &rOrientation, bool const isIgnorePrintArea)
Definition: atrfrm.cxx:108
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
bool IsInvalidItem(const SfxPoolItem *pItem)
static SfxItemSet & rSet
Marks a position in the document model.
Definition: pam.hxx:38
SwNode & GetNode() const
Definition: pam.hxx:81
sal_Int32 GetContentIndex() const
Definition: pam.hxx:85
RndStdIds
tools::Long SwTwips
Definition: swtypes.hxx:51
@ FLYFRMFMT_TITLE
@ FLYFRMFMT_DESCRIPTION
signed char sal_Int8
static sal_uInt16 nPgNum
Definition: viewport.cxx:52
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
constexpr TypedWhichId< XLineStartItem > XATTR_LINESTART(XATTR_LINE_FIRST+4)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< XFillFloatTransparenceItem > XATTR_FILLFLOATTRANSPARENCE(XATTR_FILL_FIRST+11)
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)