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 
66 using namespace ::com::sun::star;
67 
68 size_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 
115 SwFrameFormat* 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 
159 std::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 
209 static 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.GetContentAnchor() )
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.GetContentAnchor() )
228  {
229  const SwPosition *pPos = rAnch.GetContentAnchor();
230  const SwContentNode* pNd = pPos->nNode.GetNode().GetContentNode();
231  std::pair<Point, bool> const tmp(aRet, false);
232  const SwFrame* pOld = pNd ? pNd->getLayoutFrame(rDoc.getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, &tmp) : nullptr;
233  if( pOld )
234  aRet = pOld->getFrameArea().Pos();
235  }
236  break;
237 
238  case RndStdIds::FLY_AT_FLY: // LAYER_IMPL
239  if( rAnch.GetContentAnchor() )
240  {
241  const SwFlyFrameFormat* pFormat = static_cast<SwFlyFrameFormat*>(rAnch.GetContentAnchor()->
242  nNode.GetNode().GetFlyFormat());
243  const SwFrame* pOld = pFormat ? pFormat->GetFrame( &aRet ) : nullptr;
244  if( pOld )
245  aRet = pOld->getFrameArea().Pos();
246  }
247  break;
248 
249  case RndStdIds::FLY_AT_PAGE:
250  {
251  sal_uInt16 nPgNum = rAnch.GetPageNum();
252  const SwPageFrame *pPage = static_cast<SwPageFrame*>(rDoc.getIDocumentLayoutAccess().GetCurrentLayout()->Lower());
253  for( sal_uInt16 i = 1; (i <= nPgNum) && pPage; ++i,
254  pPage =static_cast<const SwPageFrame*>(pPage->GetNext()) )
255  if( i == nPgNum )
256  {
257  aRet = pPage->getFrameArea().Pos();
258  break;
259  }
260  }
261  break;
262  default:
263  break;
264  }
265  return aRet;
266 }
267 
268 #define MAKEFRMS 0
269 #define IGNOREANCHOR 1
270 #define DONTMAKEFRMS 2
271 
272 sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, bool bNewFrames )
273 {
274  // Changing anchors is almost always allowed.
275  // Exception: Paragraph and character bound frames must not become
276  // page bound, if they are located in the header or footer.
277  const SwFormatAnchor &rOldAnch = rFormat.GetAnchor();
278  const RndStdIds nOld = rOldAnch.GetAnchorId();
279 
280  SwFormatAnchor aNewAnch( rSet.Get( RES_ANCHOR ) );
281  RndStdIds nNew = aNewAnch.GetAnchorId();
282 
283  // Is the new anchor valid?
284  if( !aNewAnch.GetContentAnchor() && (RndStdIds::FLY_AT_FLY == nNew ||
285  (RndStdIds::FLY_AT_PARA == nNew) || (RndStdIds::FLY_AS_CHAR == nNew) ||
286  (RndStdIds::FLY_AT_CHAR == nNew) ))
287  {
288  return IGNOREANCHOR;
289  }
290 
291  if( nOld == nNew )
292  return DONTMAKEFRMS;
293 
294  Point aOldAnchorPos( ::lcl_FindAnchorLayPos( *this, rOldAnch, &rFormat ));
295  Point aNewAnchorPos( ::lcl_FindAnchorLayPos( *this, aNewAnch, nullptr ));
296 
297  // Destroy the old Frames.
298  // The Views are hidden implicitly, so hiding them another time would be
299  // kind of a show!
300  rFormat.DelFrames();
301 
302  if ( RndStdIds::FLY_AS_CHAR == nOld )
303  {
304  // We need to handle InContents in a special way:
305  // The TextAttribut needs to be destroyed which, unfortunately, also
306  // destroys the format. To avoid that, we disconnect the format from
307  // the attribute.
308  const SwPosition *pPos = rOldAnch.GetContentAnchor();
309  SwTextNode *pTextNode = pPos->nNode.GetNode().GetTextNode();
310  OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
311  const sal_Int32 nIdx = pPos->nContent.GetIndex();
312  SwTextAttr * const pHint =
313  pTextNode->GetTextAttrForCharAt( nIdx, RES_TXTATR_FLYCNT );
314  OSL_ENSURE( pHint && pHint->Which() == RES_TXTATR_FLYCNT,
315  "Missing FlyInCnt-Hint." );
316  OSL_ENSURE( pHint && pHint->GetFlyCnt().GetFrameFormat() == &rFormat,
317  "Wrong TextFlyCnt-Hint." );
318  if (pHint)
319  const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
320 
321  // They are disconnected. We now have to destroy the attribute.
322  pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
323  }
324 
325  // We can finally set the attribute. It needs to be the first one!
326  // Undo depends on it!
327  rFormat.SetFormatAttr( aNewAnch );
328 
329  // Correct the position
330  switch( nNew )
331  {
332  case RndStdIds::FLY_AS_CHAR:
333  // If no position attributes are received, we have to make sure
334  // that no forbidden automatic alignment is left.
335  {
336  const SwPosition *pPos = aNewAnch.GetContentAnchor();
337  SwTextNode *pNd = pPos->nNode.GetNode().GetTextNode();
338  OSL_ENSURE( pNd, "Cursor does not point to TextNode." );
339 
340  SwFormatFlyCnt aFormat( static_cast<SwFlyFrameFormat*>(&rFormat) );
341  pNd->InsertItem( aFormat, pPos->nContent.GetIndex(), 0 );
342  }
343 
344  if( SfxItemState::SET != rSet.GetItemState( RES_VERT_ORIENT, false ))
345  {
346  SwFormatVertOrient aOldV( rFormat.GetVertOrient() );
347  bool bSet = true;
348  switch( aOldV.GetVertOrient() )
349  {
350  case text::VertOrientation::LINE_TOP: aOldV.SetVertOrient( text::VertOrientation::TOP ); break;
351  case text::VertOrientation::LINE_CENTER: aOldV.SetVertOrient( text::VertOrientation::CENTER); break;
352  case text::VertOrientation::LINE_BOTTOM: aOldV.SetVertOrient( text::VertOrientation::BOTTOM); break;
353  case text::VertOrientation::NONE: aOldV.SetVertOrient( text::VertOrientation::CENTER); break;
354  default:
355  bSet = false;
356  }
357  if( bSet )
358  rSet.Put( aOldV );
359  }
360  break;
361 
362  case RndStdIds::FLY_AT_PARA:
363  case RndStdIds::FLY_AT_CHAR: // LAYER_IMPL
364  case RndStdIds::FLY_AT_FLY: // LAYER_IMPL
365  case RndStdIds::FLY_AT_PAGE:
366  {
367  // If no position attributes are coming in, we correct the position in a way
368  // such that the fly's document coordinates are preserved.
369  // If only the alignment changes in the position attributes (text::RelOrientation::FRAME
370  // vs. text::RelOrientation::PRTAREA), we also correct the position.
371  const SwFormatHoriOrient* pHoriOrientItem = rSet.GetItemIfSet( RES_HORI_ORIENT, false );
372 
373  SwFormatHoriOrient aOldH( rFormat.GetHoriOrient() );
374  bool bPutOldH(false);
375 
376  if( text::HoriOrientation::NONE == aOldH.GetHoriOrient() && ( !pHoriOrientItem ||
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  if( pHoriOrientItem )
383  {
384  aOldH.SetHoriOrient( pHoriOrientItem->GetHoriOrient() );
385  aOldH.SetRelationOrient( pHoriOrientItem->GetRelationOrient() );
386  }
387  aOldH.SetPos( nPos );
388  bPutOldH = true;
389  }
390  if (nNew == RndStdIds::FLY_AT_PAGE)
391  {
392  sal_Int16 nRelOrient(pHoriOrientItem
393  ? pHoriOrientItem->GetRelationOrient()
394  : aOldH.GetRelationOrient());
395  if (sw::GetAtPageRelOrientation(nRelOrient, false))
396  {
397  SAL_INFO("sw.ui", "fixing horizontal RelOrientation for at-page anchor");
398  aOldH.SetRelationOrient(nRelOrient);
399  bPutOldH = true;
400  }
401  }
402  if (bPutOldH)
403  {
404  rSet.Put( aOldH );
405  }
406 
407  const SwFormatVertOrient* pVertOrientItem = rSet.GetItemIfSet( RES_VERT_ORIENT, false );
408  SwFormatVertOrient aOldV( rFormat.GetVertOrient() );
409 
410  // #i28922# - correction: compare <aOldV.GetVertOrient() with
411  // <text::VertOrientation::NONE>
412  if( text::VertOrientation::NONE == aOldV.GetVertOrient() && (!pVertOrientItem ||
413  aOldV.GetPos() == pVertOrientItem->GetPos() ) )
414  {
415  SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldV.GetPos();
416  nPos += aOldAnchorPos.getY() - aNewAnchorPos.getY();
417  if( pVertOrientItem )
418  {
419  SwFormatVertOrient& rV = const_cast<SwFormatVertOrient&>(*pVertOrientItem);
420  aOldV.SetVertOrient( rV.GetVertOrient() );
421  aOldV.SetRelationOrient( rV.GetRelationOrient() );
422  }
423  aOldV.SetPos( nPos );
424  rSet.Put( aOldV );
425  }
426  }
427  break;
428  default:
429  break;
430  }
431 
432  if( bNewFrames )
433  rFormat.MakeFrames();
434 
435  return MAKEFRMS;
436 }
437 
438 static bool
440  sal_Int8 (SwDoc::*pSetFlyFrameAnchor)(SwFrameFormat &, SfxItemSet &, bool),
441  SwFrameFormat & rFlyFormat, SfxItemSet & rSet)
442 {
443  // #i32968# Inserting columns in the frame causes MakeFrameFormat to put two
444  // objects of type SwUndoFrameFormat on the undo stack. We don't want them.
445  ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
446 
447  // Is the anchor attribute included?
448  // If so, we pass it to a special method, which returns true
449  // if the Fly needs to be created anew, because we e.g change the FlyType.
450  sal_Int8 const nMakeFrames =
451  (SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false ))
452  ? (rDoc.*pSetFlyFrameAnchor)( rFlyFormat, rSet, false )
453  : DONTMAKEFRMS;
454 
455  const SfxPoolItem* pItem;
456  SfxItemIter aIter( rSet );
457  SfxItemSet aTmpSet( rDoc.GetAttrPool(), aFrameFormatSetRange );
458  const SfxPoolItem* pItemIter = aIter.GetCurItem();
459  do {
460  switch(pItemIter->Which())
461  {
462  case RES_FILL_ORDER:
463  case RES_BREAK:
464  case RES_PAGEDESC:
465  case RES_CNTNT:
466  case RES_FOOTER:
467  OSL_FAIL( "Unknown Fly attribute." );
468  [[fallthrough]];
469  case RES_CHAIN:
470  rSet.ClearItem(pItemIter->Which());
471  break;
472  case RES_ANCHOR:
473  if( DONTMAKEFRMS != nMakeFrames )
474  break;
475  [[fallthrough]];
476  default:
477  if( !IsInvalidItem(pItemIter) && ( SfxItemState::SET !=
478  rFlyFormat.GetAttrSet().GetItemState(pItemIter->Which(), true, &pItem ) ||
479  *pItem != *pItemIter))
480  aTmpSet.Put(*pItemIter);
481  break;
482  }
483 
484  pItemIter = aIter.NextItem();
485 
486  } while (pItemIter && (0 != pItemIter->Which()));
487 
488  if( aTmpSet.Count() )
489  rFlyFormat.SetFormatAttr( aTmpSet );
490 
491  if( MAKEFRMS == nMakeFrames )
492  rFlyFormat.MakeFrames();
493 
494  return aTmpSet.Count() || MAKEFRMS == nMakeFrames;
495 }
496 
498 {
500  SfxItemIter aIter(rSet);
501 
502  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
503  {
504  if (IsInvalidItem(pItem))
505  continue;
506  std::unique_ptr<SfxPoolItem> pResult;
507 
508  switch(pItem->Which())
509  {
510  case XATTR_FILLBITMAP:
511  {
512  pResult = pItem->StaticWhichCast(XATTR_FILLBITMAP).checkForUniqueItem(pDrawModel);
513  break;
514  }
515  case XATTR_LINEDASH:
516  {
517  pResult = pItem->StaticWhichCast(XATTR_LINEDASH).checkForUniqueItem(pDrawModel);
518  break;
519  }
520  case XATTR_LINESTART:
521  {
522  pResult = pItem->StaticWhichCast(XATTR_LINESTART).checkForUniqueItem(pDrawModel);
523  break;
524  }
525  case XATTR_LINEEND:
526  {
527  pResult = pItem->StaticWhichCast(XATTR_LINEEND).checkForUniqueItem(pDrawModel);
528  break;
529  }
530  case XATTR_FILLGRADIENT:
531  {
532  pResult = pItem->StaticWhichCast(XATTR_FILLGRADIENT).checkForUniqueItem(pDrawModel);
533  break;
534  }
536  {
537  pResult = pItem->StaticWhichCast(XATTR_FILLFLOATTRANSPARENCE).checkForUniqueItem(pDrawModel);
538  break;
539  }
540  case XATTR_FILLHATCH:
541  {
542  pResult = pItem->StaticWhichCast(XATTR_FILLHATCH).checkForUniqueItem(pDrawModel);
543  break;
544  }
545  }
546 
547  if(pResult)
548  {
549  rSet.Put(*pResult);
550  }
551  }
552 }
553 
555 {
556  if( !rSet.Count() )
557  return false;
558 
559  std::unique_ptr<SwUndoFormatAttrHelper> pSaveUndo;
560 
562  {
563  GetIDocumentUndoRedo().ClearRedo(); // AppendUndo far below, so leave it
564  pSaveUndo.reset( new SwUndoFormatAttrHelper( rFlyFormat ) );
565  }
566 
567  bool const bRet = lcl_SetFlyFrameAttr(*this, &SwDoc::SetFlyFrameAnchor, rFlyFormat, rSet);
568 
569  if (pSaveUndo && pSaveUndo->GetUndo() )
570  {
571  GetIDocumentUndoRedo().AppendUndo( pSaveUndo->ReleaseUndo() );
572  }
573 
575 
576  //SwTextBoxHelper::syncFlyFrameAttr(rFlyFormat, rSet);
577 
578  return bRet;
579 }
580 
581 // #i73249#
583  const OUString& sNewTitle )
584 {
585  if ( rFlyFrameFormat.GetObjTitle() == sNewTitle )
586  {
587  return;
588  }
589 
590  ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo());
591 
592  if (GetIDocumentUndoRedo().DoesUndo())
593  {
594  GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoFlyStrAttr>( rFlyFrameFormat,
596  rFlyFrameFormat.GetObjTitle(),
597  sNewTitle ) );
598  }
599 
600  rFlyFrameFormat.SetObjTitle( sNewTitle, true );
601 
603 }
604 
606  const OUString& sNewDescription )
607 {
608  if ( rFlyFrameFormat.GetObjDescription() == sNewDescription )
609  {
610  return;
611  }
612 
613  ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo());
614 
615  if (GetIDocumentUndoRedo().DoesUndo())
616  {
617  GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoFlyStrAttr>( rFlyFrameFormat,
619  rFlyFrameFormat.GetObjDescription(),
620  sNewDescription ) );
621  }
622 
623  rFlyFrameFormat.SetObjDescription( sNewDescription, true );
624 
626 }
627 
629  SfxItemSet* pSet, bool bKeepOrient )
630 {
631  bool bChgAnchor = false, bFrameSz = false;
632 
633  const SwFormatFrameSize aFrameSz( rFormat.GetFrameSize() );
634 
635  SwUndoSetFlyFormat* pUndo = nullptr;
636  bool const bUndo = GetIDocumentUndoRedo().DoesUndo();
637  if (bUndo)
638  {
639  pUndo = new SwUndoSetFlyFormat( rFormat, rNewFormat );
640  GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
641  }
642 
643  // #i32968# Inserting columns in the section causes MakeFrameFormat to put
644  // 2 objects of type SwUndoFrameFormat on the undo stack. We don't want them.
645  ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
646 
647  // Set the column first, or we'll have trouble with
648  //Set/Reset/Synch. and so on
649  if( SfxItemState::SET != rNewFormat.GetAttrSet().GetItemState( RES_COL ))
650  rFormat.ResetFormatAttr( RES_COL );
651 
652  if( rFormat.DerivedFrom() != &rNewFormat )
653  {
654  rFormat.SetDerivedFrom( &rNewFormat );
655 
656  // 1. If not automatic = ignore; else = dispose
657  // 2. Dispose of it!
658  if( SfxItemState::SET == rNewFormat.GetAttrSet().GetItemState( RES_FRM_SIZE, false ))
659  {
660  rFormat.ResetFormatAttr( RES_FRM_SIZE );
661  bFrameSz = true;
662  }
663 
664  const SfxItemSet* pAsk = pSet;
665  if( !pAsk ) pAsk = &rNewFormat.GetAttrSet();
666  const SwFormatAnchor* pFormatAnchor = pAsk->GetItemIfSet( RES_ANCHOR, false );
667  if( pFormatAnchor
668  && pFormatAnchor->GetAnchorId() !=
669  rFormat.GetAnchor().GetAnchorId() )
670  {
671  if( pSet )
672  bChgAnchor = MAKEFRMS == SetFlyFrameAnchor( rFormat, *pSet, false );
673  else
674  {
675  // Needs to have the FlyFormat range, because we set attributes in it,
676  // in SetFlyFrameAnchor.
677  SfxItemSet aFlySet( *rNewFormat.GetAttrSet().GetPool(),
678  rNewFormat.GetAttrSet().GetRanges() );
679  aFlySet.Put( *pFormatAnchor );
680  bChgAnchor = MAKEFRMS == SetFlyFrameAnchor( rFormat, aFlySet, false);
681  }
682  }
683  }
684 
685  // Only reset vertical and horizontal orientation, if we have automatic alignment
686  // set in the template. Otherwise use the old value.
687  // If we update the frame template the Fly should NOT lose its orientation (which
688  // is not being updated!).
689  // text::HoriOrientation::NONE and text::VertOrientation::NONE are allowed now
690  if (!bKeepOrient)
691  {
694  }
695 
700 
701  if( !bFrameSz )
702  rFormat.SetFormatAttr( aFrameSz );
703 
704  if( bChgAnchor )
705  rFormat.MakeFrames();
706 
707  if( pUndo )
708  pUndo->EndListeningAll();
709 
711 
712  return bChgAnchor;
713 }
714 
715 void SwDoc::GetGrfNms( const SwFlyFrameFormat& rFormat, OUString* pGrfName,
716  OUString* pFltName )
717 {
718  SwNodeIndex aIdx( *rFormat.GetContent().GetContentIdx(), 1 );
719  const SwGrfNode* pGrfNd = aIdx.GetNode().GetGrfNode();
720  if( pGrfNd && pGrfNd->IsLinkedFile() )
721  pGrfNd->GetFileFilterNms( pGrfName, pFltName );
722 }
723 
724 bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
725  RndStdIds _eAnchorType,
726  const bool _bSameOnly,
727  const bool _bPosCorr )
728 {
729  OSL_ENSURE( getIDocumentLayoutAccess().GetCurrentLayout(), "No layout!" );
730 
731  if ( !_rMrkList.GetMarkCount() ||
733  {
734  return false;
735  }
736 
738 
739  bool bUnmark = false;
740  for ( size_t i = 0; i < _rMrkList.GetMarkCount(); ++i )
741  {
742  SdrObject* pObj = _rMrkList.GetMark( i )->GetMarkedSdrObj();
743  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
744  {
745  SwDrawContact* pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
746 
747  // consider, that drawing object has
748  // no user call. E.g.: a 'virtual' drawing object is disconnected by
749  // the anchor type change of the 'master' drawing object.
750  // Continue with next selected object and assert, if this isn't excepted.
751  if ( !pContact )
752  {
753 #if OSL_DEBUG_LEVEL > 0
754  auto pSwDrawVirtObj = dynamic_cast<SwDrawVirtObj*>( pObj);
755  bool bNoUserCallExcepted = pSwDrawVirtObj && !pSwDrawVirtObj->IsConnected();
756  OSL_ENSURE( bNoUserCallExcepted, "SwDoc::ChgAnchor(..) - no contact at selected drawing object" );
757 #endif
758  continue;
759  }
760 
761  // #i26791#
762  const SwFrame* pOldAnchorFrame = pContact->GetAnchorFrame( pObj );
763  const SwFrame* pNewAnchorFrame = pOldAnchorFrame;
764 
765  // #i54336#
766  // Instead of only keeping the index position for an as-character
767  // anchored object the complete <SwPosition> is kept, because the
768  // anchor index position could be moved, if the object again is
769  // anchored as character.
770  std::unique_ptr<const SwPosition> xOldAsCharAnchorPos;
771  const RndStdIds eOldAnchorType = pContact->GetAnchorId();
772  if ( !_bSameOnly && eOldAnchorType == RndStdIds::FLY_AS_CHAR )
773  {
774  xOldAsCharAnchorPos.reset(new SwPosition(pContact->GetContentAnchor()));
775  }
776 
777  if ( _bSameOnly )
778  _eAnchorType = eOldAnchorType;
779 
780  SwFormatAnchor aNewAnch( _eAnchorType );
781  SwAnchoredObject *pAnchoredObj = pContact->GetAnchoredObj(pObj);
782  tools::Rectangle aObjRect(pAnchoredObj->GetObjRect().SVRect());
783  const Point aPt( aObjRect.TopLeft() );
784 
785  switch ( _eAnchorType )
786  {
787  case RndStdIds::FLY_AT_PARA:
788  case RndStdIds::FLY_AT_CHAR:
789  {
790  const Point aNewPoint = ( pOldAnchorFrame->IsVertical() ||
791  pOldAnchorFrame->IsRightToLeft() )
792  ? aObjRect.TopRight()
793  : aPt;
794 
795  // allow drawing objects in header/footer
796  pNewAnchorFrame = ::FindAnchor( pOldAnchorFrame, aNewPoint );
797  if ( pNewAnchorFrame->IsTextFrame() && static_cast<const SwTextFrame*>(pNewAnchorFrame)->IsFollow() )
798  {
799  pNewAnchorFrame = static_cast<const SwTextFrame*>(pNewAnchorFrame)->FindMaster();
800  }
801  if ( pNewAnchorFrame->IsProtected() )
802  {
803  pNewAnchorFrame = nullptr;
804  }
805  else
806  {
807  SwPosition aPos( pNewAnchorFrame->IsTextFrame()
808  ? *static_cast<SwTextFrame const*>(pNewAnchorFrame)->GetTextNodeForParaProps()
809  : *static_cast<SwNoTextFrame const*>(pNewAnchorFrame)->GetNode() );
810 
811  aNewAnch.SetType( _eAnchorType );
812  aNewAnch.SetAnchor( &aPos );
813  }
814  }
815  break;
816 
817  case RndStdIds::FLY_AT_FLY: // LAYER_IMPL
818  {
819  // Search the closest SwFlyFrame starting from the upper left corner.
820  SwFrame *pTextFrame;
821  {
823  SwPosition aPos( GetNodes() );
824  Point aPoint( aPt );
825  aPoint.setX(aPoint.getX() - 1);
827  // consider that drawing objects can be in
828  // header/footer. Thus, <GetFrame()> by left-top-corner
829  std::pair<Point, bool> const tmp(aPt, false);
830  pTextFrame = aPos.nNode.GetNode().
832  getIDocumentLayoutAccess().GetCurrentLayout(),
833  nullptr, &tmp);
834  }
835  const SwFrame *pTmp = ::FindAnchor( pTextFrame, aPt );
836  pNewAnchorFrame = pTmp->FindFlyFrame();
837  if( pNewAnchorFrame && !pNewAnchorFrame->IsProtected() )
838  {
839  const SwFrameFormat *pTmpFormat = static_cast<const SwFlyFrame*>(pNewAnchorFrame)->GetFormat();
840  const SwFormatContent& rContent = pTmpFormat->GetContent();
841  SwPosition aPos( *rContent.GetContentIdx() );
842  aNewAnch.SetAnchor( &aPos );
843  break;
844  }
845 
846  aNewAnch.SetType( RndStdIds::FLY_AT_PAGE );
847  [[fallthrough]];
848  }
849  case RndStdIds::FLY_AT_PAGE:
850  {
851  pNewAnchorFrame = getIDocumentLayoutAccess().GetCurrentLayout()->Lower();
852  while ( pNewAnchorFrame && !pNewAnchorFrame->getFrameArea().Contains( aPt ) )
853  pNewAnchorFrame = pNewAnchorFrame->GetNext();
854  if ( !pNewAnchorFrame )
855  continue;
856 
857  aNewAnch.SetPageNum( static_cast<const SwPageFrame*>(pNewAnchorFrame)->GetPhyPageNum());
858  }
859  break;
860  case RndStdIds::FLY_AS_CHAR:
861  if( _bSameOnly ) // Change of position/size
862  {
863  if( !pOldAnchorFrame )
864  {
865  pContact->ConnectToLayout();
866  pOldAnchorFrame = pContact->GetAnchorFrame();
867  }
868  const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pOldAnchorFrame))->Prepare();
869  }
870  else // Change of anchors
871  {
872  // allow drawing objects in header/footer
873  pNewAnchorFrame = ::FindAnchor( pOldAnchorFrame, aPt );
874  if( pNewAnchorFrame->IsProtected() )
875  {
876  pNewAnchorFrame = nullptr;
877  break;
878  }
879 
880  bUnmark = ( 0 != i );
881  Point aPoint( aPt );
882  aPoint.setX(aPoint.getX() - 1); // Do not load in the DrawObj!
883  aNewAnch.SetType( RndStdIds::FLY_AS_CHAR );
884  assert(pNewAnchorFrame->IsTextFrame()); // because AS_CHAR
885  SwTextFrame const*const pFrame(
886  static_cast<SwTextFrame const*>(pNewAnchorFrame));
887  SwPosition aPos( *pFrame->GetTextNodeForParaProps() );
888  if ( pNewAnchorFrame->getFrameArea().Contains( aPoint ) )
889  {
890  // We need to find a TextNode, because only there we can anchor a
891  // content-bound DrawObject.
894  }
895  else
896  {
897  if ( pNewAnchorFrame->getFrameArea().Bottom() < aPt.Y() )
898  {
899  aPos = pFrame->MapViewToModelPos(TextFrameIndex(0));
900  }
901  else
902  {
903  aPos = pFrame->MapViewToModelPos(
904  TextFrameIndex(pFrame->GetText().getLength()));
905  }
906  }
907  aNewAnch.SetAnchor( &aPos );
908  SetAttr( aNewAnch, *pContact->GetFormat() );
909  // #i26791# - adjust vertical positioning to 'center to
910  // baseline'
911  SetAttr( SwFormatVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME ), *pContact->GetFormat() );
912  SwTextNode *pNd = aPos.nNode.GetNode().GetTextNode();
913  OSL_ENSURE( pNd, "Cursor not positioned at TextNode." );
914 
915  SwFormatFlyCnt aFormat( pContact->GetFormat() );
916  pNd->InsertItem( aFormat, aPos.nContent.GetIndex(), 0 );
917 
918  // Has a textbox attached to the format? Sync it as well!
921  {
923  pContact->GetFormat()->GetAttrSet(), pObj);
924  }
925  }
926  break;
927  default:
928  OSL_ENSURE( false, "unexpected AnchorId." );
929  }
930 
931  if ( (RndStdIds::FLY_AS_CHAR != _eAnchorType) &&
932  pNewAnchorFrame &&
933  ( !_bSameOnly || pNewAnchorFrame != pOldAnchorFrame ) )
934  {
935  // #i26791# - Direct object positioning no longer needed. Apply
936  // of attributes (method call <SetAttr(..)>) takes care of the
937  // invalidation of the object position.
938  if ( _bPosCorr )
939  {
940  // #i33313# - consider not connected 'virtual' drawing
941  // objects
942  auto pSwDrawVirtObj = dynamic_cast<SwDrawVirtObj*>( pObj);
943  if ( pSwDrawVirtObj && !pSwDrawVirtObj->IsConnected() )
944  {
945  SwRect aNewObjRect( aObjRect );
946  static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( nullptr ))
947  ->AdjustPositioningAttr( pNewAnchorFrame,
948  &aNewObjRect );
949  }
950  else
951  {
952  static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( pObj ))
953  ->AdjustPositioningAttr( pNewAnchorFrame );
954  }
955  }
956  if (aNewAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
957  {
958  SwFormatHoriOrient item(pContact->GetFormat()->GetHoriOrient());
959  sal_Int16 nRelOrient(item.GetRelationOrient());
960  if (sw::GetAtPageRelOrientation(nRelOrient, false))
961  {
962  SAL_INFO("sw.ui", "fixing horizontal RelOrientation for at-page anchor");
963  item.SetRelationOrient(nRelOrient);
964  SetAttr(item, *pContact->GetFormat());
965  }
966  }
967  // tdf#136385 set the anchor last - otherwise it messes up the
968  // position in SwDrawContact::Changed_() callback
969  SetAttr(aNewAnch, *pContact->GetFormat());
970  }
971 
972  // we have changed the anchoring attributes, and those are used to
973  // order the object in its sorted list, so update its position
974  pAnchoredObj->UpdateObjInSortedList();
975 
976  // #i54336#
977  if (xOldAsCharAnchorPos)
978  {
979  if ( pNewAnchorFrame)
980  {
981  // We need to handle InContents in a special way:
982  // The TextAttribut needs to be destroyed which, unfortunately, also
983  // destroys the format. To avoid that, we disconnect the format from
984  // the attribute.
985  const sal_Int32 nIndx( xOldAsCharAnchorPos->nContent.GetIndex() );
986  SwTextNode* pTextNode( xOldAsCharAnchorPos->nNode.GetNode().GetTextNode() );
987  assert(pTextNode && "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object");
988  SwTextAttr * const pHint =
989  pTextNode->GetTextAttrForCharAt( nIndx, RES_TXTATR_FLYCNT );
990  assert(pHint && "Missing FlyInCnt-Hint.");
991  const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
992 
993  // They are disconnected. We now have to destroy the attribute.
994  pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx );
995  }
996  }
997  }
998  }
999 
1002 
1003  return bUnmark;
1004 }
1005 
1007 {
1008  // The Source must not yet have a Follow.
1009  const SwFormatChain &rOldChain = rSource.GetChain();
1010  if ( rOldChain.GetNext() )
1012 
1013  // Target must not be equal to Source and we also must not have a closed chain.
1014  const SwFrameFormat *pFormat = &rDest;
1015  do {
1016  if( pFormat == &rSource )
1017  return SwChainRet::SELF;
1018  pFormat = pFormat->GetChain().GetNext();
1019  } while ( pFormat );
1020 
1021  // There must not be a chaining from outside to inside or the other way around.
1022  if( rDest.IsLowerOf( rSource ) || rSource .IsLowerOf( rDest ) )
1023  return SwChainRet::SELF;
1024 
1025  // The Target must not yet have a Master.
1026  const SwFormatChain &rChain = rDest.GetChain();
1027  if( rChain.GetPrev() )
1028  return SwChainRet::IS_IN_CHAIN;
1029 
1030  // Target must be empty.
1031  const SwNodeIndex* pCntIdx = rDest.GetContent().GetContentIdx();
1032  if( !pCntIdx )
1033  return SwChainRet::NOT_FOUND;
1034 
1035  SwNodeIndex aNxtIdx( *pCntIdx, 1 );
1036  const SwTextNode* pTextNd = aNxtIdx.GetNode().GetTextNode();
1037  if( !pTextNd )
1038  return SwChainRet::NOT_FOUND;
1039 
1040  const SwNodeOffset nFlySttNd = pCntIdx->GetIndex();
1041  if( SwNodeOffset(2) != ( pCntIdx->GetNode().EndOfSectionIndex() - nFlySttNd ) ||
1042  pTextNd->GetText().getLength() )
1043  {
1044  return SwChainRet::NOT_EMPTY;
1045  }
1046 
1047  for( auto pSpzFrameFm : *GetSpzFrameFormats() )
1048  {
1049  const SwFormatAnchor& rAnchor = pSpzFrameFm->GetAnchor();
1050  // #i20622# - to-frame anchored objects are allowed.
1051  if ( (rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PARA) &&
1052  (rAnchor.GetAnchorId() != RndStdIds::FLY_AT_CHAR) )
1053  continue;
1054  if ( nullptr == rAnchor.GetContentAnchor() )
1055  continue;
1056  SwNodeOffset nTstSttNd = rAnchor.GetContentAnchor()->nNode.GetIndex();
1057  if( nFlySttNd <= nTstSttNd && nTstSttNd < nFlySttNd + SwNodeOffset(2) )
1058  {
1059  return SwChainRet::NOT_EMPTY;
1060  }
1061  }
1062 
1063  // We also need to consider the right area.
1064  // Both Flys need to be located in the same area (Body, Header/Footer, Fly).
1065  // If the Source is not the selected frame, it's enough to find a suitable
1066  // one. e.g. if it's requested by the API.
1067 
1068  // both in the same fly, header, footer or on the page?
1069  const SwFormatAnchor &rSrcAnchor = rSource.GetAnchor(),
1070  &rDstAnchor = rDest.GetAnchor();
1071  SwNodeOffset nEndOfExtras = GetNodes().GetEndOfExtras().GetIndex();
1072  bool bAllowed = false;
1073  if ( RndStdIds::FLY_AT_PAGE == rSrcAnchor.GetAnchorId() )
1074  {
1075  if ( (RndStdIds::FLY_AT_PAGE == rDstAnchor.GetAnchorId()) ||
1076  ( rDstAnchor.GetContentAnchor() &&
1077  rDstAnchor.GetContentAnchor()->nNode.GetIndex() > nEndOfExtras ))
1078  bAllowed = true;
1079  }
1080  else if( rSrcAnchor.GetContentAnchor() && rDstAnchor.GetContentAnchor() )
1081  {
1082  const SwNodeIndex &rSrcIdx = rSrcAnchor.GetContentAnchor()->nNode,
1083  &rDstIdx = rDstAnchor.GetContentAnchor()->nNode;
1084  const SwStartNode* pSttNd = nullptr;
1085  if( rSrcIdx == rDstIdx ||
1086  ( !pSttNd &&
1087  nullptr != ( pSttNd = rSrcIdx.GetNode().FindFlyStartNode() ) &&
1088  pSttNd == rDstIdx.GetNode().FindFlyStartNode() ) ||
1089  ( !pSttNd &&
1090  nullptr != ( pSttNd = rSrcIdx.GetNode().FindFooterStartNode() ) &&
1091  pSttNd == rDstIdx.GetNode().FindFooterStartNode() ) ||
1092  ( !pSttNd &&
1093  nullptr != ( pSttNd = rSrcIdx.GetNode().FindHeaderStartNode() ) &&
1094  pSttNd == rDstIdx.GetNode().FindHeaderStartNode() ) ||
1095  ( !pSttNd && rDstIdx.GetIndex() > nEndOfExtras &&
1096  rSrcIdx.GetIndex() > nEndOfExtras ))
1097  bAllowed = true;
1098  }
1099 
1100  return bAllowed ? SwChainRet::OK : SwChainRet::WRONG_AREA;
1101 }
1102 
1104 {
1105  SwChainRet nErr = Chainable( rSource, rDest );
1106  if ( nErr == SwChainRet::OK )
1107  {
1109 
1110  SwFlyFrameFormat& rDestFormat = const_cast<SwFlyFrameFormat&>(static_cast<const SwFlyFrameFormat&>(rDest));
1111 
1112  // Attach Follow to the Master.
1113  SwFormatChain aChain = rDestFormat.GetChain();
1114  aChain.SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1115  SetAttr( aChain, rDestFormat );
1116 
1118  RES_CHAIN, RES_CHAIN> aSet( GetAttrPool() );
1119 
1120  // Attach Follow to the Master.
1121  aChain.SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1122  SetAttr( aChain, rDestFormat );
1123 
1124  // Attach Master to the Follow.
1125  // Make sure that the Master has a fixed height.
1126  aChain = rSource.GetChain();
1127  aChain.SetNext( &rDestFormat );
1128  aSet.Put( aChain );
1129 
1130  SwFormatFrameSize aSize( rSource.GetFrameSize() );
1131  if ( aSize.GetHeightSizeType() != SwFrameSize::Fixed )
1132  {
1133  SwFlyFrame *pFly = SwIterator<SwFlyFrame,SwFormat>( rSource ).First();
1134  if ( pFly )
1135  aSize.SetHeight( pFly->getFrameArea().Height() );
1136  aSize.SetHeightSizeType( SwFrameSize::Fixed );
1137  aSet.Put( aSize );
1138  }
1139  SetAttr( aSet, rSource );
1140 
1142  }
1143  return nErr;
1144 }
1145 
1147 {
1148  SwFormatChain aChain( rFormat.GetChain() );
1149  if ( aChain.GetNext() )
1150  {
1152  SwFrameFormat *pFollow = aChain.GetNext();
1153  aChain.SetNext( nullptr );
1154  SetAttr( aChain, rFormat );
1155  aChain = pFollow->GetChain();
1156  aChain.SetPrev( nullptr );
1157  SetAttr( aChain, *pFollow );
1159  }
1160 }
1161 
1162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
Starts a section of nodes in the document model.
Definition: node.hxx:313
Base class of the Writer layout elements.
Definition: frame.hxx:314
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:159
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
virtual SwRect GetObjRect() const =0
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
constexpr TypedWhichId< SwFormatFillOrder > RES_FILL_ORDER(RES_FRMATR_BEGIN)
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:687
const SwStartNode * FindHeaderStartNode() const
Definition: node.hxx:204
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
size_t GetMarkCount() const
Self-chaining is not allowed.
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
Destination already in chain.
Marks a position in the document model.
Definition: pam.hxx:36
class for the positioning of drawing objects
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:821
constexpr TypedWhichId< XLineStartItem > XATTR_LINESTART(XATTR_LINE_FIRST+4)
bool IsGrfNode() const
Definition: node.hxx:666
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(98)
OUString GetObjDescription() const
Definition: atrfrm.cxx:3222
const OUString & GetText() const
Definition: ndtxt.hxx:218
const SwStartNode * FindFooterStartNode() const
Definition: node.hxx:206
virtual const SwRootFrame * GetCurrentLayout() const =0
constexpr TypedWhichId< SwFormatEditInReadonly > RES_EDIT_IN_READONLY(112)
static SwContentNode * GetContentNode(SwDoc &rDoc, SwNodeIndex &rIdx, bool bNext)
Definition: fltshell.cxx:53
constexpr TypedWhichId< SwFormatCol > RES_COL(109)
#define DONTMAKEFRMS
Definition: docfly.cxx:270
signed char sal_Int8
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
SwNodeIndex nNode
Definition: pam.hxx:38
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
sal_uInt16 GetPageNum() const
Definition: fmtanchr.hxx:66
virtual void SetModified()=0
Must be called manually at changes of format.
SwTwips GetPos() const
Definition: fmtornt.hxx:92
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! The void*...
Definition: txtfrm.cxx:2728
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1210
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
const WhichRangesContainer & GetRanges() const
Definition: doc.hxx:187
#define MAKEFRMS
Definition: docfly.cxx:268
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
SwNode & GetNode() const
Definition: ndindex.hxx:119
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
SdrMark * GetMark(size_t nNum) const
void Pos(const Point &rNew)
Definition: swrect.hxx:171
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
sal_uInt16 Which() const
Definition: txatbase.hxx:116
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
Only empty frames may be connected.
void SetPrev(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2132
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:55
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:172
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 >)
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:743
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
Destination in section where it shouldn't be (header, footer).
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:155
SwChainRet Chain(SwFrameFormat &rSource, const SwFrameFormat &rDest)
Definition: docfly.cxx:1103
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:3068
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Definition: trvlfrm.cxx:425
std::vector< SwFrameFormat const * > GetFlyFrameFormats(FlyCntType eType, bool bIgnoreTextBoxes)
Definition: docfly.cxx:159
static bool lcl_SetFlyFrameAttr(SwDoc &rDoc, sal_Int8(SwDoc::*pSetFlyFrameAnchor)(SwFrameFormat &, SfxItemSet &, bool), SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Definition: docfly.cxx:439
const SfxPoolItem * NextItem()
wrapper class for the positioning of Writer fly frames and drawing objects
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
SwIndex nContent
Definition: pam.hxx:39
const SwFrame * GetAnchorFrame(const SdrObject *_pDrawObj=nullptr) const
Definition: dcontact.cxx:804
Destination and/or source not found.
const SwRect & getFrameArea() const
Definition: frame.hxx:179
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:43
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
int nCount
bool IsTextFrame() const
Definition: frame.hxx:1234
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:1300
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
OUString GetObjTitle() const
Definition: atrfrm.cxx:3179
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:152
SwFrameFormat * GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes=false)
Definition: docfly.cxx:115
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1111
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
Definition: ndgrf.cxx:494
void Unchain(SwFrameFormat &rFormat)
Definition: docfly.cxx:1146
virtual bool DoesUndo() const =0
Is Undo enabled?
SwAttrPool * GetPool() const
Definition: swatrset.hxx:183
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:319
Specific frame formats (frames, DrawObjects).
static Point lcl_FindAnchorLayPos(SwDoc &rDoc, const SwFormatAnchor &rAnch, const SwFrameFormat *pFlyFormat)
Definition: docfly.cxx:209
bool IsOLENode() const
Definition: node.hxx:662
bool GetAtPageRelOrientation(sal_Int16 &rOrientation, bool const isIgnorePrintArea)
Definition: atrfrm.cxx:108
SdrObject * GetMarkedSdrObj() const
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo)=0
Add new Undo action.
virtual void ClearRedo()=0
Delete all Redo actions.
Style of a layout element.
Definition: frmfmt.hxx:59
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
void SetVertOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:56
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
FlyCntType
Definition: flyenum.hxx:23
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
RndStdIds GetAnchorId() const
Definition: dcontact.hxx:145
void SetFlyFrameDescription(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewDescription)
Definition: docfly.cxx:605
const SwFrame * Lower() const
Definition: layfrm.hxx:101
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
Definition: docfly.cxx:628
SwContentNode * GetContentNode()
Definition: node.hxx:625
SwNodeOffset GetIndex() const
Definition: node.hxx:292
sal_uInt16 Count() const
FlyAnchors.
Definition: fmtanchr.hxx:34
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2694
void UpdateObjInSortedList()
method to update anchored object in the lists
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
sal_Int8 SetFlyFrameAnchor(SwFrameFormat &rFlyFormat, SfxItemSet &rSet, bool bNewFrames)
Definition: docfly.cxx:272
bool IsNoTextNode() const
Definition: node.hxx:658
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:31
Marks a node in the document model.
Definition: ndindex.hxx:30
A page of the document layout.
Definition: pagefrm.hxx:57
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Definition: docfly.cxx:554
static void GetGrfNms(const SwFlyFrameFormat &rFormat, OUString *pGrfName, OUString *pFltName)
Definition: docfly.cxx:715
stay with the cursor inside text
Frame cannot be moved in Var-direction.
tools::Long SwTwips
Definition: swtypes.hxx:51
static sal_uInt16 nPgNum
Definition: viewport.cxx:52
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(95)
SwFlyFrameFormat * GetNext() const
Definition: fmtcnct.hxx:54
bool Contains(const Point &rPOINT) const
Definition: swrect.hxx:356
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:448
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
SwFormat * DerivedFrom() const
Definition: format.hxx:128
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void DeleteAttributes(const sal_uInt16 nWhich, const sal_Int32 nStart, const sal_Int32 nEnd=0)
delete all attributes of type nWhich at nStart (opt. end nEnd)
Definition: thints.cxx:1772
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:619
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(114)
constexpr TypedWhichId< XFillFloatTransparenceItem > XATTR_FILLFLOATTRANSPARENCE(XATTR_FILL_FIRST+11)
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
bool IsLowerOf(const SwFrameFormat &rFormat) const
Definition: atrfrm.cxx:2776
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
const SwNodes & GetNodes() const
Definition: ndindex.hxx:156
SwTwips GetPos() const
Definition: fmtornt.hxx:59
#define IGNOREANCHOR
Definition: docfly.cxx:269
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const override
Definition: dcontact.cxx:762
#define SAL_INFO(area, stream)
sal_Int32 GetIndex() const
Definition: index.hxx:91
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2705
void ConnectToLayout(const SwFormatAnchor *pAnch=nullptr)
Inserts SdrObject in the arrays of the layout ((SwPageFrame and SwFrame).
Definition: dcontact.cxx:1787
virtual SwDrawModel * GetOrCreateDrawModel()=0
SwNodes & GetNodes()
Definition: doc.hxx:408
size_t GetFlyCount(FlyCntType eType, bool bIgnoreTextBoxes=false) const
Access to frames.
Definition: docfly.cxx:68
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object...
Definition: dcontact.hxx:212
bool IsRightToLeft() const
Definition: frame.hxx:987
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
void SetFlyFrameTitle(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewTitle)
Definition: docfly.cxx:582
static void syncFlyFrameAttr(SwFrameFormat &rShape, SfxItemSet const &rSet, SdrObject *pObj)
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
Format of a fly content.
Definition: fmtflcnt.hxx:32
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
SdrObject * getParentSdrObjectFromSdrObject() const
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
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:1063
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:200
bool IsVertical() const
Definition: frame.hxx:973
SwChainRet Chainable(const SwFrameFormat &rSource, const SwFrameFormat &rDest)
Definition: docfly.cxx:1006
constexpr TypedWhichId< SwFormatFooter > RES_FOOTER(97)
void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet &rSet)
Definition: docfly.cxx:497
SwFrameFormat * GetFrameFormat() const
Definition: fmtflcnt.hxx:45
void SetNext(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2140
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
Definition: nodes.cxx:2380
RndStdIds
size_t size() const
void SetObjTitle(const OUString &rTitle, bool bBroadcast=false)
Definition: atrfrm.cxx:3160
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:154
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
bool IsInvalidItem(const SfxPoolItem *pItem)
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:160
Source already has a follow.
SwFlyFrameFormat * GetPrev() const
Definition: fmtcnct.hxx:53
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...
void Height(tools::Long nNew)
Definition: swrect.hxx:193
void SetObjDescription(const OUString &rDescription, bool bBroadcast=false)
Definition: atrfrm.cxx:3203
const SwPosition & GetContentAnchor() const
Definition: dcontact.hxx:152
SwChainRet
Definition: flyenum.hxx:33
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
bool ChgAnchor(const SdrMarkList &_rMrkList, RndStdIds _eAnchorType, const bool _bSameOnly, const bool _bPosCorr)
Definition: docfly.cxx:724
sal_uInt16 nPos
const SfxPoolItem * GetCurItem() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1318
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:864
bool HasHints() const
Definition: ndtxt.hxx:228
SwFlyFrame * GetFrame(const Point *pDocPos=nullptr) const
Definition: atrfrm.cxx:3115
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1585
bool m_bDetectedRangeSegmentation false
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1628
bool IsConnected() const
is 'virtual' drawing object connected to writer layout and / to drawing layer.
Definition: dcontact.cxx:2363
const SwFormatFlyCnt & GetFlyCnt() const
Definition: txatbase.hxx:226
SwFrame * GetNext()
Definition: frame.hxx:676
Base class of the Writer document model elements.
Definition: node.hxx:81