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 no position attributes are coming in, we correct the position in a way
367 // such that the fly's document coordinates are preserved.
368 // If only the alignment changes in the position attributes (text::RelOrientation::FRAME
369 // vs. text::RelOrientation::PRTAREA), we also correct the 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 aOldH.GetPos() == pHoriOrientItem->GetPos() ))
377 {
378 SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldH.GetPos();
379 nPos += aOldAnchorPos.getX() - aNewAnchorPos.getX();
380
381 if( pHoriOrientItem )
382 {
383 aOldH.SetHoriOrient( pHoriOrientItem->GetHoriOrient() );
384 aOldH.SetRelationOrient( pHoriOrientItem->GetRelationOrient() );
385 }
386 aOldH.SetPos( nPos );
387 bPutOldH = true;
388 }
389 if (nNew == RndStdIds::FLY_AT_PAGE)
390 {
391 sal_Int16 nRelOrient(pHoriOrientItem
392 ? pHoriOrientItem->GetRelationOrient()
393 : aOldH.GetRelationOrient());
394 if (sw::GetAtPageRelOrientation(nRelOrient, false))
395 {
396 SAL_INFO("sw.ui", "fixing horizontal RelOrientation for at-page anchor");
397 aOldH.SetRelationOrient(nRelOrient);
398 bPutOldH = true;
399 }
400 }
401 if (bPutOldH)
402 {
403 rSet.Put( aOldH );
404 }
405
406 const SwFormatVertOrient* pVertOrientItem = rSet.GetItemIfSet( RES_VERT_ORIENT, false );
407 SwFormatVertOrient aOldV( rFormat.GetVertOrient() );
408
409 // #i28922# - correction: compare <aOldV.GetVertOrient() with
410 // <text::VertOrientation::NONE>
411 if( text::VertOrientation::NONE == aOldV.GetVertOrient() && (!pVertOrientItem ||
412 aOldV.GetPos() == pVertOrientItem->GetPos() ) )
413 {
414 SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldV.GetPos();
415 nPos += aOldAnchorPos.getY() - aNewAnchorPos.getY();
416 if( pVertOrientItem )
417 {
418 SwFormatVertOrient& rV = const_cast<SwFormatVertOrient&>(*pVertOrientItem);
419 aOldV.SetVertOrient( rV.GetVertOrient() );
421 }
422 aOldV.SetPos( nPos );
423 rSet.Put( aOldV );
424 }
425 }
426 break;
427 default:
428 break;
429 }
430
431 if( bNewFrames )
432 rFormat.MakeFrames();
433
434 return MAKEFRMS;
435}
436
437static bool
439 sal_Int8 (SwDoc::*pSetFlyFrameAnchor)(SwFrameFormat &, SfxItemSet &, bool),
440 SwFrameFormat & rFlyFormat, SfxItemSet & rSet)
441{
442 // #i32968# Inserting columns in the frame causes MakeFrameFormat to put two
443 // objects of type SwUndoFrameFormat on the undo stack. We don't want them.
444 ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
445
446 // Is the anchor attribute included?
447 // If so, we pass it to a special method, which returns true
448 // if the Fly needs to be created anew, because we e.g change the FlyType.
449 sal_Int8 const nMakeFrames =
450 (SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false ))
451 ? (rDoc.*pSetFlyFrameAnchor)( rFlyFormat, rSet, false )
452 : DONTMAKEFRMS;
453
454 const SfxPoolItem* pItem;
455 SfxItemIter aIter( rSet );
457 const SfxPoolItem* pItemIter = aIter.GetCurItem();
458 do {
459 switch(pItemIter->Which())
460 {
461 case RES_FILL_ORDER:
462 case RES_BREAK:
463 case RES_PAGEDESC:
464 case RES_CNTNT:
465 case RES_FOOTER:
466 OSL_FAIL( "Unknown Fly attribute." );
467 [[fallthrough]];
468 case RES_CHAIN:
469 rSet.ClearItem(pItemIter->Which());
470 break;
471 case RES_ANCHOR:
472 if( DONTMAKEFRMS != nMakeFrames )
473 break;
474 [[fallthrough]];
475 default:
476 if( !IsInvalidItem(pItemIter) && ( SfxItemState::SET !=
477 rFlyFormat.GetAttrSet().GetItemState(pItemIter->Which(), true, &pItem ) ||
478 *pItem != *pItemIter))
479 aTmpSet.Put(*pItemIter);
480 break;
481 }
482
483 pItemIter = aIter.NextItem();
484
485 } while (pItemIter && (0 != pItemIter->Which()));
486
487 if( aTmpSet.Count() )
488 rFlyFormat.SetFormatAttr( aTmpSet );
489
490 if( MAKEFRMS == nMakeFrames )
491 rFlyFormat.MakeFrames();
492
493 return aTmpSet.Count() || MAKEFRMS == nMakeFrames;
494}
495
497{
499 SfxItemIter aIter(rSet);
500
501 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
502 {
503 if (IsInvalidItem(pItem))
504 continue;
505 std::unique_ptr<SfxPoolItem> pResult;
506
507 switch(pItem->Which())
508 {
509 case XATTR_FILLBITMAP:
510 {
511 pResult = pItem->StaticWhichCast(XATTR_FILLBITMAP).checkForUniqueItem(pDrawModel);
512 break;
513 }
514 case XATTR_LINEDASH:
515 {
516 pResult = pItem->StaticWhichCast(XATTR_LINEDASH).checkForUniqueItem(pDrawModel);
517 break;
518 }
519 case XATTR_LINESTART:
520 {
521 pResult = pItem->StaticWhichCast(XATTR_LINESTART).checkForUniqueItem(pDrawModel);
522 break;
523 }
524 case XATTR_LINEEND:
525 {
526 pResult = pItem->StaticWhichCast(XATTR_LINEEND).checkForUniqueItem(pDrawModel);
527 break;
528 }
530 {
531 pResult = pItem->StaticWhichCast(XATTR_FILLGRADIENT).checkForUniqueItem(pDrawModel);
532 break;
533 }
535 {
536 pResult = pItem->StaticWhichCast(XATTR_FILLFLOATTRANSPARENCE).checkForUniqueItem(pDrawModel);
537 break;
538 }
539 case XATTR_FILLHATCH:
540 {
541 pResult = pItem->StaticWhichCast(XATTR_FILLHATCH).checkForUniqueItem(pDrawModel);
542 break;
543 }
544 }
545
546 if(pResult)
547 {
548 rSet.Put(std::move(pResult));
549 }
550 }
551}
552
554{
555 if( !rSet.Count() )
556 return false;
557
558 std::unique_ptr<SwUndoFormatAttrHelper> pSaveUndo;
559
560 if (GetIDocumentUndoRedo().DoesUndo())
561 {
562 GetIDocumentUndoRedo().ClearRedo(); // AppendUndo far below, so leave it
563 pSaveUndo.reset( new SwUndoFormatAttrHelper( rFlyFormat ) );
564 }
565
566 bool const bRet = lcl_SetFlyFrameAttr(*this, &SwDoc::SetFlyFrameAnchor, rFlyFormat, rSet);
567
568 if (pSaveUndo && pSaveUndo->GetUndo() )
569 {
570 GetIDocumentUndoRedo().AppendUndo( pSaveUndo->ReleaseUndo() );
571 }
572
574
575 //SwTextBoxHelper::syncFlyFrameAttr(rFlyFormat, rSet);
576
577 return bRet;
578}
579
580// #i73249#
582 const OUString& sNewTitle )
583{
584 if ( rFlyFrameFormat.GetObjTitle() == sNewTitle )
585 {
586 return;
587 }
588
589 ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo());
590
591 if (GetIDocumentUndoRedo().DoesUndo())
592 {
593 GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoFlyStrAttr>( rFlyFrameFormat,
595 rFlyFrameFormat.GetObjTitle(),
596 sNewTitle ) );
597 }
598
599 rFlyFrameFormat.SetObjTitle( sNewTitle, true );
600
602}
603
605 const OUString& sNewDescription )
606{
607 if ( rFlyFrameFormat.GetObjDescription() == sNewDescription )
608 {
609 return;
610 }
611
612 ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo());
613
614 if (GetIDocumentUndoRedo().DoesUndo())
615 {
616 GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoFlyStrAttr>( rFlyFrameFormat,
618 rFlyFrameFormat.GetObjDescription(),
619 sNewDescription ) );
620 }
621
622 rFlyFrameFormat.SetObjDescription( sNewDescription, true );
623
625}
626
628 SfxItemSet* pSet, bool bKeepOrient )
629{
630 bool bChgAnchor = false, bFrameSz = false;
631
632 const SwFormatFrameSize aFrameSz( rFormat.GetFrameSize() );
633
634 SwUndoSetFlyFormat* pUndo = nullptr;
635 bool const bUndo = GetIDocumentUndoRedo().DoesUndo();
636 if (bUndo)
637 {
638 pUndo = new SwUndoSetFlyFormat( rFormat, rNewFormat );
639 GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
640 }
641
642 // #i32968# Inserting columns in the section causes MakeFrameFormat to put
643 // 2 objects of type SwUndoFrameFormat on the undo stack. We don't want them.
644 ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
645
646 // Set the column first, or we'll have trouble with
647 //Set/Reset/Synch. and so on
648 if( SfxItemState::SET != rNewFormat.GetAttrSet().GetItemState( RES_COL ))
649 rFormat.ResetFormatAttr( RES_COL );
650
651 if( rFormat.DerivedFrom() != &rNewFormat )
652 {
653 rFormat.SetDerivedFrom( &rNewFormat );
654
655 // 1. If not automatic = ignore; else = dispose
656 // 2. Dispose of it!
657 if( SfxItemState::SET == rNewFormat.GetAttrSet().GetItemState( RES_FRM_SIZE, false ))
658 {
659 rFormat.ResetFormatAttr( RES_FRM_SIZE );
660 bFrameSz = true;
661 }
662
663 const SfxItemSet* pAsk = pSet;
664 if( !pAsk ) pAsk = &rNewFormat.GetAttrSet();
665 const SwFormatAnchor* pFormatAnchor = pAsk->GetItemIfSet( RES_ANCHOR, false );
666 if( pFormatAnchor
667 && pFormatAnchor->GetAnchorId() !=
668 rFormat.GetAnchor().GetAnchorId() )
669 {
670 if( pSet )
671 bChgAnchor = MAKEFRMS == SetFlyFrameAnchor( rFormat, *pSet, false );
672 else
673 {
674 // Needs to have the FlyFormat range, because we set attributes in it,
675 // in SetFlyFrameAnchor.
676 SfxItemSet aFlySet( *rNewFormat.GetAttrSet().GetPool(),
677 rNewFormat.GetAttrSet().GetRanges() );
678 aFlySet.Put( *pFormatAnchor );
679 bChgAnchor = MAKEFRMS == SetFlyFrameAnchor( rFormat, aFlySet, false);
680 }
681 }
682 }
683
684 // Only reset vertical and horizontal orientation, if we have automatic alignment
685 // set in the template. Otherwise use the old value.
686 // If we update the frame template the Fly should NOT lose its orientation (which
687 // is not being updated!).
688 // text::HoriOrientation::NONE and text::VertOrientation::NONE are allowed now
689 if (!bKeepOrient)
690 {
693 }
694
699
700 if( !bFrameSz )
701 rFormat.SetFormatAttr( aFrameSz );
702
703 if( bChgAnchor )
704 rFormat.MakeFrames();
705
706 if( pUndo )
707 pUndo->EndListeningAll();
708
710
711 return bChgAnchor;
712}
713
714void SwDoc::GetGrfNms( const SwFlyFrameFormat& rFormat, OUString* pGrfName,
715 OUString* pFltName )
716{
717 SwNodeIndex aIdx( *rFormat.GetContent().GetContentIdx(), 1 );
718 const SwGrfNode* pGrfNd = aIdx.GetNode().GetGrfNode();
719 if( pGrfNd && pGrfNd->IsLinkedFile() )
720 pGrfNd->GetFileFilterNms( pGrfName, pFltName );
721}
722
723bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
724 RndStdIds _eAnchorType,
725 const bool _bSameOnly,
726 const bool _bPosCorr )
727{
728 OSL_ENSURE( getIDocumentLayoutAccess().GetCurrentLayout(), "No layout!" );
729
730 if ( !_rMrkList.GetMarkCount() ||
732 {
733 return false;
734 }
735
736 GetIDocumentUndoRedo().StartUndo( SwUndoId::INSATTR, nullptr );
737
738 bool bUnmark = false;
739 for ( size_t i = 0; i < _rMrkList.GetMarkCount(); ++i )
740 {
741 SdrObject* pObj = _rMrkList.GetMark( i )->GetMarkedSdrObj();
742 if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
743 {
744 SwDrawContact* pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
745
746 // consider, that drawing object has
747 // no user call. E.g.: a 'virtual' drawing object is disconnected by
748 // the anchor type change of the 'master' drawing object.
749 // Continue with next selected object and assert, if this isn't excepted.
750 if ( !pContact )
751 {
752#if OSL_DEBUG_LEVEL > 0
753 auto pSwDrawVirtObj = dynamic_cast<SwDrawVirtObj*>( pObj);
754 bool bNoUserCallExcepted = pSwDrawVirtObj && !pSwDrawVirtObj->IsConnected();
755 OSL_ENSURE( bNoUserCallExcepted, "SwDoc::ChgAnchor(..) - no contact at selected drawing object" );
756#endif
757 continue;
758 }
759
760 // #i26791#
761 const SwFrame* pOldAnchorFrame = pContact->GetAnchorFrame( pObj );
762 const SwFrame* pNewAnchorFrame = pOldAnchorFrame;
763
764 // #i54336#
765 // Instead of only keeping the index position for an as-character
766 // anchored object the complete <SwPosition> is kept, because the
767 // anchor index position could be moved, if the object again is
768 // anchored as character.
769 std::optional<SwPosition> oOldAsCharAnchorPos;
770 const RndStdIds eOldAnchorType = pContact->GetAnchorId();
771 if ( !_bSameOnly && eOldAnchorType == RndStdIds::FLY_AS_CHAR )
772 {
773 oOldAsCharAnchorPos.emplace(*pContact->GetAnchorFormat().GetContentAnchor());
774 }
775
776 if ( _bSameOnly )
777 _eAnchorType = eOldAnchorType;
778
779 SwFormatAnchor aNewAnch( _eAnchorType );
780 SwAnchoredObject *pAnchoredObj = pContact->GetAnchoredObj(pObj);
781 tools::Rectangle aObjRect(pAnchoredObj->GetObjRect().SVRect());
782 const Point aPt( aObjRect.TopLeft() );
783
784 switch ( _eAnchorType )
785 {
786 case RndStdIds::FLY_AT_PARA:
787 case RndStdIds::FLY_AT_CHAR:
788 {
789 const Point aNewPoint = ( pOldAnchorFrame->IsVertical() ||
790 pOldAnchorFrame->IsRightToLeft() )
791 ? aObjRect.TopRight()
792 : aPt;
793
794 // allow drawing objects in header/footer
795 pNewAnchorFrame = ::FindAnchor( pOldAnchorFrame, aNewPoint );
796 if ( pNewAnchorFrame->IsTextFrame() && static_cast<const SwTextFrame*>(pNewAnchorFrame)->IsFollow() )
797 {
798 pNewAnchorFrame = static_cast<const SwTextFrame*>(pNewAnchorFrame)->FindMaster();
799 }
800 if ( pNewAnchorFrame->IsProtected() )
801 {
802 pNewAnchorFrame = nullptr;
803 }
804 else
805 {
806 SwPosition aPos( pNewAnchorFrame->IsTextFrame()
807 ? *static_cast<SwTextFrame const*>(pNewAnchorFrame)->GetTextNodeForParaProps()
808 : *static_cast<SwNoTextFrame const*>(pNewAnchorFrame)->GetNode() );
809
810 aNewAnch.SetType( _eAnchorType );
811 aNewAnch.SetAnchor( &aPos );
812 }
813 }
814 break;
815
816 case RndStdIds::FLY_AT_FLY: // LAYER_IMPL
817 {
818 // Search the closest SwFlyFrame starting from the upper left corner.
819 SwFrame *pTextFrame;
820 {
822 SwPosition aPos( GetNodes() );
823 Point aPoint( aPt );
824 aPoint.setX(aPoint.getX() - 1);
826 // consider that drawing objects can be in
827 // header/footer. Thus, <GetFrame()> by left-top-corner
828 std::pair<Point, bool> const tmp(aPt, false);
829 pTextFrame = aPos.GetNode().
831 getIDocumentLayoutAccess().GetCurrentLayout(),
832 nullptr, &tmp);
833 }
834 const SwFrame *pTmp = ::FindAnchor( pTextFrame, aPt );
835 pNewAnchorFrame = pTmp->FindFlyFrame();
836 if( pNewAnchorFrame && !pNewAnchorFrame->IsProtected() )
837 {
838 const SwFrameFormat *pTmpFormat = static_cast<const SwFlyFrame*>(pNewAnchorFrame)->GetFormat();
839 const SwFormatContent& rContent = pTmpFormat->GetContent();
840 SwPosition aPos( *rContent.GetContentIdx() );
841 aNewAnch.SetAnchor( &aPos );
842 break;
843 }
844
845 aNewAnch.SetType( RndStdIds::FLY_AT_PAGE );
846 [[fallthrough]];
847 }
848 case RndStdIds::FLY_AT_PAGE:
849 {
850 pNewAnchorFrame = getIDocumentLayoutAccess().GetCurrentLayout()->Lower();
851 while ( pNewAnchorFrame && !pNewAnchorFrame->getFrameArea().Contains( aPt ) )
852 pNewAnchorFrame = pNewAnchorFrame->GetNext();
853 if ( !pNewAnchorFrame )
854 continue;
855
856 aNewAnch.SetPageNum( static_cast<const SwPageFrame*>(pNewAnchorFrame)->GetPhyPageNum());
857 }
858 break;
859 case RndStdIds::FLY_AS_CHAR:
860 if( _bSameOnly ) // Change of position/size
861 {
862 if( !pOldAnchorFrame )
863 {
864 pContact->ConnectToLayout();
865 pOldAnchorFrame = pContact->GetAnchorFrame();
866 }
867 const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pOldAnchorFrame))->Prepare();
868 }
869 else // Change of anchors
870 {
871 // allow drawing objects in header/footer
872 pNewAnchorFrame = ::FindAnchor( pOldAnchorFrame, aPt );
873 if( pNewAnchorFrame->IsProtected() )
874 {
875 pNewAnchorFrame = nullptr;
876 break;
877 }
878
879 bUnmark = ( 0 != i );
880 Point aPoint( aPt );
881 aPoint.setX(aPoint.getX() - 1); // Do not load in the DrawObj!
882 aNewAnch.SetType( RndStdIds::FLY_AS_CHAR );
883 assert(pNewAnchorFrame->IsTextFrame()); // because AS_CHAR
884 SwTextFrame const*const pFrame(
885 static_cast<SwTextFrame const*>(pNewAnchorFrame));
886 SwPosition aPos( *pFrame->GetTextNodeForParaProps() );
887 if ( pNewAnchorFrame->getFrameArea().Contains( aPoint ) )
888 {
889 // We need to find a TextNode, because only there we can anchor a
890 // content-bound DrawObject.
893 }
894 else
895 {
896 if ( pNewAnchorFrame->getFrameArea().Bottom() < aPt.Y() )
897 {
898 aPos = pFrame->MapViewToModelPos(TextFrameIndex(0));
899 }
900 else
901 {
902 aPos = pFrame->MapViewToModelPos(
903 TextFrameIndex(pFrame->GetText().getLength()));
904 }
905 }
906 aNewAnch.SetAnchor( &aPos );
907 SetAttr( aNewAnch, *pContact->GetFormat() );
908 // #i26791# - adjust vertical positioning to 'center to
909 // baseline'
910 SetAttr( SwFormatVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME ), *pContact->GetFormat() );
911 SwTextNode *pNd = aPos.GetNode().GetTextNode();
912 OSL_ENSURE( pNd, "Cursor not positioned at TextNode." );
913
914 SwFormatFlyCnt aFormat( pContact->GetFormat() );
915 pNd->InsertItem( aFormat, aPos.GetContentIndex(), 0 );
916
917 // Has a textbox attached to the format? Sync it as well!
918 if (pContact->GetFormat() && pContact->GetFormat()->GetOtherTextBoxFormats())
919 {
921 SwTextBoxHelper::changeAnchor, pContact->GetFormat(), pObj);
922 }
923 }
924 break;
925 default:
926 OSL_ENSURE( false, "unexpected AnchorId." );
927 }
928
929 if ( (RndStdIds::FLY_AS_CHAR != _eAnchorType) &&
930 pNewAnchorFrame &&
931 ( !_bSameOnly || pNewAnchorFrame != pOldAnchorFrame ) )
932 {
933 // #i26791# - Direct object positioning no longer needed. Apply
934 // of attributes (method call <SetAttr(..)>) takes care of the
935 // invalidation of the object position.
936 if ( _bPosCorr )
937 {
938 // #i33313# - consider not connected 'virtual' drawing
939 // objects
940 auto pSwDrawVirtObj = dynamic_cast<SwDrawVirtObj*>( pObj);
941 if ( pSwDrawVirtObj && !pSwDrawVirtObj->IsConnected() )
942 {
943 SwRect aNewObjRect( aObjRect );
944 static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( nullptr ))
945 ->AdjustPositioningAttr( pNewAnchorFrame,
946 &aNewObjRect );
947 }
948 else
949 {
950 static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( pObj ))
951 ->AdjustPositioningAttr( pNewAnchorFrame );
952 }
953 }
954 if (aNewAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
955 {
956 SwFormatHoriOrient item(pContact->GetFormat()->GetHoriOrient());
957 sal_Int16 nRelOrient(item.GetRelationOrient());
958 if (sw::GetAtPageRelOrientation(nRelOrient, false))
959 {
960 SAL_INFO("sw.ui", "fixing horizontal RelOrientation for at-page anchor");
961 item.SetRelationOrient(nRelOrient);
962 SetAttr(item, *pContact->GetFormat());
963 }
964 }
965 // tdf#136385 set the anchor last - otherwise it messes up the
966 // position in SwDrawContact::Changed_() callback
967 SetAttr(aNewAnch, *pContact->GetFormat());
968 }
969
970 // we have changed the anchoring attributes, and those are used to
971 // order the object in its sorted list, so update its position
972 pAnchoredObj->UpdateObjInSortedList();
973
974 // #i54336#
975 if (oOldAsCharAnchorPos)
976 {
977 if ( pNewAnchorFrame)
978 {
979 // We need to handle InContents in a special way:
980 // The TextAttribut needs to be destroyed which, unfortunately, also
981 // destroys the format. To avoid that, we disconnect the format from
982 // the attribute.
983 const sal_Int32 nIndx( oOldAsCharAnchorPos->GetContentIndex() );
984 SwTextNode* pTextNode( oOldAsCharAnchorPos->GetNode().GetTextNode() );
985 assert(pTextNode && "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object");
986 SwTextAttr * const pHint =
987 pTextNode->GetTextAttrForCharAt( nIndx, RES_TXTATR_FLYCNT );
988 assert(pHint && "Missing FlyInCnt-Hint.");
989 const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
990
991 // They are disconnected. We now have to destroy the attribute.
992 pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx );
993 }
994 }
995 }
996 }
997
998 GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
1000
1001 return bUnmark;
1002}
1003
1005{
1006 // The Source must not yet have a Follow.
1007 const SwFormatChain &rOldChain = rSource.GetChain();
1008 if ( rOldChain.GetNext() )
1010
1011 // Target must not be equal to Source and we also must not have a closed chain.
1012 const SwFrameFormat *pFormat = &rDest;
1013 do {
1014 if( pFormat == &rSource )
1015 return SwChainRet::SELF;
1016 pFormat = pFormat->GetChain().GetNext();
1017 } while ( pFormat );
1018
1019 // There must not be a chaining from outside to inside or the other way around.
1020 if( rDest.IsLowerOf( rSource ) || rSource .IsLowerOf( rDest ) )
1021 return SwChainRet::SELF;
1022
1023 // The Target must not yet have a Master.
1024 const SwFormatChain &rChain = rDest.GetChain();
1025 if( rChain.GetPrev() )
1027
1028 // Target must be empty.
1029 const SwNodeIndex* pCntIdx = rDest.GetContent().GetContentIdx();
1030 if( !pCntIdx )
1031 return SwChainRet::NOT_FOUND;
1032
1033 SwNodeIndex aNxtIdx( *pCntIdx, 1 );
1034 const SwTextNode* pTextNd = aNxtIdx.GetNode().GetTextNode();
1035 if( !pTextNd )
1036 return SwChainRet::NOT_FOUND;
1037
1038 const SwNodeOffset nFlySttNd = pCntIdx->GetIndex();
1039 if( SwNodeOffset(2) != ( pCntIdx->GetNode().EndOfSectionIndex() - nFlySttNd ) ||
1040 pTextNd->GetText().getLength() )
1041 {
1042 return SwChainRet::NOT_EMPTY;
1043 }
1044
1045 for( auto pSpzFrameFm : *GetSpzFrameFormats() )
1046 {
1047 const SwFormatAnchor& rAnchor = pSpzFrameFm->GetAnchor();
1048 // #i20622# - to-frame anchored objects are allowed.
1049 if ( (rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PARA) &&
1050 (rAnchor.GetAnchorId() != RndStdIds::FLY_AT_CHAR) )
1051 continue;
1052 if ( nullptr == rAnchor.GetAnchorNode() )
1053 continue;
1054 SwNodeOffset nTstSttNd = rAnchor.GetAnchorNode()->GetIndex();
1055 if( nFlySttNd <= nTstSttNd && nTstSttNd < nFlySttNd + SwNodeOffset(2) )
1056 {
1057 return SwChainRet::NOT_EMPTY;
1058 }
1059 }
1060
1061 // We also need to consider the right area.
1062 // Both Flys need to be located in the same area (Body, Header/Footer, Fly).
1063 // If the Source is not the selected frame, it's enough to find a suitable
1064 // one. e.g. if it's requested by the API.
1065
1066 // both in the same fly, header, footer or on the page?
1067 const SwFormatAnchor &rSrcAnchor = rSource.GetAnchor(),
1068 &rDstAnchor = rDest.GetAnchor();
1069 SwNodeOffset nEndOfExtras = GetNodes().GetEndOfExtras().GetIndex();
1070 bool bAllowed = false;
1071 if ( RndStdIds::FLY_AT_PAGE == rSrcAnchor.GetAnchorId() )
1072 {
1073 if ( (RndStdIds::FLY_AT_PAGE == rDstAnchor.GetAnchorId()) ||
1074 ( rDstAnchor.GetAnchorNode() &&
1075 rDstAnchor.GetAnchorNode()->GetIndex() > nEndOfExtras ))
1076 bAllowed = true;
1077 }
1078 else if( rSrcAnchor.GetAnchorNode() && rDstAnchor.GetAnchorNode() )
1079 {
1080 const SwNode &rSrcNd = *rSrcAnchor.GetAnchorNode(),
1081 &rDstNd = *rDstAnchor.GetAnchorNode();
1082 const SwStartNode* pSttNd = nullptr;
1083 if( rSrcNd == rDstNd ||
1084 ( !pSttNd &&
1085 nullptr != ( pSttNd = rSrcNd.FindFlyStartNode() ) &&
1086 pSttNd == rDstNd.FindFlyStartNode() ) ||
1087 ( !pSttNd &&
1088 nullptr != ( pSttNd = rSrcNd.FindFooterStartNode() ) &&
1089 pSttNd == rDstNd.FindFooterStartNode() ) ||
1090 ( !pSttNd &&
1091 nullptr != ( pSttNd = rSrcNd.FindHeaderStartNode() ) &&
1092 pSttNd == rDstNd.FindHeaderStartNode() ) ||
1093 ( !pSttNd && rDstNd.GetIndex() > nEndOfExtras &&
1094 rSrcNd.GetIndex() > nEndOfExtras ))
1095 bAllowed = true;
1096 }
1097
1098 return bAllowed ? SwChainRet::OK : SwChainRet::WRONG_AREA;
1099}
1100
1102{
1103 SwChainRet nErr = Chainable( rSource, rDest );
1104 if ( nErr == SwChainRet::OK )
1105 {
1106 GetIDocumentUndoRedo().StartUndo( SwUndoId::CHAINE, nullptr );
1107
1108 SwFlyFrameFormat& rDestFormat = const_cast<SwFlyFrameFormat&>(static_cast<const SwFlyFrameFormat&>(rDest));
1109
1110 // Attach Follow to the Master.
1111 SwFormatChain aChain = rDestFormat.GetChain();
1112 aChain.SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1113 SetAttr( aChain, rDestFormat );
1114
1116 RES_CHAIN, RES_CHAIN> aSet( GetAttrPool() );
1117
1118 // Attach Follow to the Master.
1119 aChain.SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1120 SetAttr( aChain, rDestFormat );
1121
1122 // Attach Master to the Follow.
1123 // Make sure that the Master has a fixed height.
1124 aChain = rSource.GetChain();
1125 aChain.SetNext( &rDestFormat );
1126 aSet.Put( aChain );
1127
1128 SwFormatFrameSize aSize( rSource.GetFrameSize() );
1129 if ( aSize.GetHeightSizeType() != SwFrameSize::Fixed )
1130 {
1132 if ( pFly )
1133 aSize.SetHeight( pFly->getFrameArea().Height() );
1135 aSet.Put( aSize );
1136 }
1137 SetAttr( aSet, rSource );
1138
1139 GetIDocumentUndoRedo().EndUndo( SwUndoId::CHAINE, nullptr );
1140 }
1141 return nErr;
1142}
1143
1145{
1146 SwFormatChain aChain( rFormat.GetChain() );
1147 if ( aChain.GetNext() )
1148 {
1149 GetIDocumentUndoRedo().StartUndo( SwUndoId::UNCHAIN, nullptr );
1150 SwFrameFormat *pFollow = aChain.GetNext();
1151 aChain.SetNext( nullptr );
1152 SetAttr( aChain, rFormat );
1153 aChain = pFollow->GetChain();
1154 aChain.SetPrev( nullptr );
1155 SetAttr( aChain, *pFollow );
1156 GetIDocumentUndoRedo().EndUndo( SwUndoId::UNCHAIN, nullptr );
1157 }
1158}
1159
1160/* 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:183
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:1230
Definition: doc.hxx:194
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
Definition: docfly.cxx:627
void SetFlyFrameTitle(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewTitle)
Definition: docfly.cxx:581
SwChainRet Chainable(const SwFrameFormat &rSource, const SwFrameFormat &rDest)
Definition: docfly.cxx:1004
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:400
SwChainRet Chain(SwFrameFormat &rSource, const SwFrameFormat &rDest)
Definition: docfly.cxx:1101
void SetFlyFrameDescription(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewDescription)
Definition: docfly.cxx:604
SwFrameFormat * GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes=false)
Definition: docfly.cxx:115
void Unchain(SwFrameFormat &rFormat)
Definition: docfly.cxx:1144
void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet &rSet)
Definition: docfly.cxx:496
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:150
SwNodes & GetNodes()
Definition: doc.hxx:417
size_t GetFlyCount(FlyCntType eType, bool bIgnoreTextBoxes=false) const
Access to frames.
Definition: docfly.cxx:68
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:411
static void GetGrfNms(const SwFlyFrameFormat &rFormat, OUString *pGrfName, OUString *pFltName)
Definition: docfly.cxx:714
bool ChgAnchor(const SdrMarkList &_rMrkList, RndStdIds _eAnchorType, const bool _bSameOnly, const bool _bPosCorr)
Definition: docfly.cxx:723
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1326
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:161
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:752
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Definition: docfly.cxx:553
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:2413
void SetObjDescription(const OUString &rDescription, bool bBroadcast=false)
Definition: atrfrm.cxx:3233
OUString GetObjDescription() const
Definition: atrfrm.cxx:3252
SwFlyFrame * GetFrame(const Point *pDocPos=nullptr) const
Definition: atrfrm.cxx:3145
OUString GetObjTitle() const
Definition: atrfrm.cxx:3209
void SetObjTitle(const OUString &rTitle, bool bBroadcast=false)
Definition: atrfrm.cxx:3190
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
void SetHoriOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:96
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:2808
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:1234
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1111
SwFrame * GetNext()
Definition: frame.hxx:676
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:987
bool IsVertical() const
Definition: frame.hxx:973
bool IsLinkedFile() const
Definition: ndgrf.hxx:164
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
Definition: ndgrf.cxx:494
TElementType * First()
Definition: calbck.hxx:365
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:175
SwNode & GetNode() const
Definition: ndindex.hxx:136
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:171
Base class of the Writer document model elements.
Definition: node.hxx:98
bool IsGrfNode() const
Definition: node.hxx:705
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:154
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:897
SwNodeOffset GetIndex() const
Definition: node.hxx:312
const SwStartNode * FindFooterStartNode() const
Definition: node.hxx:226
bool IsNoTextNode() const
Definition: node.hxx:697
const SwStartNode * FindHeaderStartNode() const
Definition: node.hxx:224
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:220
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:726
SwContentNode * GetContentNode()
Definition: node.hxx:664
bool IsOLENode() const
Definition: node.hxx:701
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:2522
A page of the document layout.
Definition: pagefrm.hxx:58
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:165
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:2748
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:111
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:252
const OUString & GetText() const
Definition: ndtxt.hxx:242
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:3141
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:438
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:1069
DocumentType eType
@ Fixed
Frame cannot be moved in Var-direction.
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
constexpr TypedWhichId< SwFormatCol > RES_COL(109)
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
constexpr TypedWhichId< SwFormatFooter > RES_FOOTER(97)
constexpr TypedWhichId< SwFormatFillOrder > RES_FILL_ORDER(RES_FRMATR_BEGIN)
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(95)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(98)
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(114)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
constexpr TypedWhichId< SwFormatEditInReadonly > RES_EDIT_IN_READONLY(112)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
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)