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