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