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 <fmtfsize.hxx>
25 #include <fmtornt.hxx>
26 #include <dcontact.hxx>
27 #include <ndgrf.hxx>
28 #include <doc.hxx>
29 #include <IDocumentUndoRedo.hxx>
31 #include <IDocumentState.hxx>
33 #include <ndindex.hxx>
34 #include <docary.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  && nullptr != ( pIdx = pFlyFormat->GetContent().GetContentIdx() )
84  && pIdx->GetNodes().IsDocNodes()
85  )
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  && nullptr != ( pIdx = pFlyFormat->GetContent().GetContentIdx() )
132  && pIdx->GetNodes().IsDocNodes()
133  )
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  const SfxPoolItem* pItem;
331  switch( nNew )
332  {
333  case RndStdIds::FLY_AS_CHAR:
334  // If no position attributes are received, we have to make sure
335  // that no forbidden automatic alignment is left.
336  {
337  const SwPosition *pPos = aNewAnch.GetContentAnchor();
338  SwTextNode *pNd = pPos->nNode.GetNode().GetTextNode();
339  OSL_ENSURE( pNd, "Cursor does not point to TextNode." );
340 
341  SwFormatFlyCnt aFormat( static_cast<SwFlyFrameFormat*>(&rFormat) );
342  pNd->InsertItem( aFormat, pPos->nContent.GetIndex(), 0 );
343  }
344 
345  if( SfxItemState::SET != rSet.GetItemState( RES_VERT_ORIENT, false, &pItem ))
346  {
347  SwFormatVertOrient aOldV( rFormat.GetVertOrient() );
348  bool bSet = true;
349  switch( aOldV.GetVertOrient() )
350  {
351  case text::VertOrientation::LINE_TOP: aOldV.SetVertOrient( text::VertOrientation::TOP ); break;
352  case text::VertOrientation::LINE_CENTER: aOldV.SetVertOrient( text::VertOrientation::CENTER); break;
353  case text::VertOrientation::LINE_BOTTOM: aOldV.SetVertOrient( text::VertOrientation::BOTTOM); break;
354  case text::VertOrientation::NONE: aOldV.SetVertOrient( text::VertOrientation::CENTER); break;
355  default:
356  bSet = false;
357  }
358  if( bSet )
359  rSet.Put( aOldV );
360  }
361  break;
362 
363  case RndStdIds::FLY_AT_PARA:
364  case RndStdIds::FLY_AT_CHAR: // LAYER_IMPL
365  case RndStdIds::FLY_AT_FLY: // LAYER_IMPL
366  case RndStdIds::FLY_AT_PAGE:
367  {
368  // If no position attributes are coming in, we correct the position in a way
369  // such that the fly's document coordinates are preserved.
370  // If only the alignment changes in the position attributes (text::RelOrientation::FRAME
371  // vs. text::RelOrientation::PRTAREA), we also correct the position.
372  if( SfxItemState::SET != rSet.GetItemState( RES_HORI_ORIENT, false, &pItem ))
373  pItem = nullptr;
374 
375  SwFormatHoriOrient aOldH( rFormat.GetHoriOrient() );
376 
377  if( text::HoriOrientation::NONE == aOldH.GetHoriOrient() && ( !pItem ||
378  aOldH.GetPos() == static_cast<const SwFormatHoriOrient*>(pItem)->GetPos() ))
379  {
380  SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldH.GetPos();
381  nPos += aOldAnchorPos.getX() - aNewAnchorPos.getX();
382 
383  if( pItem )
384  {
385  SwFormatHoriOrient* pH = const_cast<SwFormatHoriOrient*>(static_cast<const SwFormatHoriOrient*>(pItem));
386  aOldH.SetHoriOrient( pH->GetHoriOrient() );
387  aOldH.SetRelationOrient( pH->GetRelationOrient() );
388  }
389  aOldH.SetPos( nPos );
390  rSet.Put( aOldH );
391  }
392 
393  if( SfxItemState::SET != rSet.GetItemState( RES_VERT_ORIENT, false, &pItem ))
394  pItem = nullptr;
395  SwFormatVertOrient aOldV( rFormat.GetVertOrient() );
396 
397  // #i28922# - correction: compare <aOldV.GetVertOrient() with
398  // <text::VertOrientation::NONE>
399  if( text::VertOrientation::NONE == aOldV.GetVertOrient() && (!pItem ||
400  aOldV.GetPos() == static_cast<const SwFormatVertOrient*>(pItem)->GetPos() ) )
401  {
402  SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldV.GetPos();
403  nPos += aOldAnchorPos.getY() - aNewAnchorPos.getY();
404  if( pItem )
405  {
406  SwFormatVertOrient* pV = const_cast<SwFormatVertOrient*>(static_cast<const SwFormatVertOrient*>(pItem));
407  aOldV.SetVertOrient( pV->GetVertOrient() );
408  aOldV.SetRelationOrient( pV->GetRelationOrient() );
409  }
410  aOldV.SetPos( nPos );
411  rSet.Put( aOldV );
412  }
413  }
414  break;
415  default:
416  break;
417  }
418 
419  if( bNewFrames )
420  rFormat.MakeFrames();
421 
422  return MAKEFRMS;
423 }
424 
425 static bool
427  sal_Int8 (SwDoc::*pSetFlyFrameAnchor)(SwFrameFormat &, SfxItemSet &, bool),
428  SwFrameFormat & rFlyFormat, SfxItemSet & rSet)
429 {
430  // #i32968# Inserting columns in the frame causes MakeFrameFormat to put two
431  // objects of type SwUndoFrameFormat on the undo stack. We don't want them.
432  ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
433 
434  // Is the anchor attribute included?
435  // If so, we pass it to a special method, which returns true
436  // if the Fly needs to be created anew, because we e.g change the FlyType.
437  sal_Int8 const nMakeFrames =
438  (SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false ))
439  ? (rDoc.*pSetFlyFrameAnchor)( rFlyFormat, rSet, false )
440  : DONTMAKEFRMS;
441 
442  const SfxPoolItem* pItem;
443  SfxItemIter aIter( rSet );
444  SfxItemSet aTmpSet( rDoc.GetAttrPool(), aFrameFormatSetRange );
445  const SfxPoolItem* pItemIter = aIter.GetCurItem();
446  do {
447  switch(pItemIter->Which())
448  {
449  case RES_FILL_ORDER:
450  case RES_BREAK:
451  case RES_PAGEDESC:
452  case RES_CNTNT:
453  case RES_FOOTER:
454  OSL_FAIL( "Unknown Fly attribute." );
455  [[fallthrough]];
456  case RES_CHAIN:
457  rSet.ClearItem(pItemIter->Which());
458  break;
459  case RES_ANCHOR:
460  if( DONTMAKEFRMS != nMakeFrames )
461  break;
462  [[fallthrough]];
463  default:
464  if( !IsInvalidItem(pItemIter) && ( SfxItemState::SET !=
465  rFlyFormat.GetAttrSet().GetItemState(pItemIter->Which(), true, &pItem ) ||
466  *pItem != *pItemIter))
467  aTmpSet.Put(*pItemIter);
468  break;
469  }
470 
471  pItemIter = aIter.NextItem();
472 
473  } while (pItemIter && (0 != pItemIter->Which()));
474 
475  if( aTmpSet.Count() )
476  rFlyFormat.SetFormatAttr( aTmpSet );
477 
478  if( MAKEFRMS == nMakeFrames )
479  rFlyFormat.MakeFrames();
480 
481  return aTmpSet.Count() || MAKEFRMS == nMakeFrames;
482 }
483 
485 {
487  SfxItemIter aIter(rSet);
488 
489  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
490  {
491  if (IsInvalidItem(pItem))
492  continue;
493  std::unique_ptr<SfxPoolItem> pResult;
494 
495  switch(pItem->Which())
496  {
497  case XATTR_FILLBITMAP:
498  {
499  pResult = static_cast< const XFillBitmapItem* >(pItem)->checkForUniqueItem(pDrawModel);
500  break;
501  }
502  case XATTR_LINEDASH:
503  {
504  pResult = static_cast< const XLineDashItem* >(pItem)->checkForUniqueItem(pDrawModel);
505  break;
506  }
507  case XATTR_LINESTART:
508  {
509  pResult = static_cast< const XLineStartItem* >(pItem)->checkForUniqueItem(pDrawModel);
510  break;
511  }
512  case XATTR_LINEEND:
513  {
514  pResult = static_cast< const XLineEndItem* >(pItem)->checkForUniqueItem(pDrawModel);
515  break;
516  }
517  case XATTR_FILLGRADIENT:
518  {
519  pResult = static_cast< const XFillGradientItem* >(pItem)->checkForUniqueItem(pDrawModel);
520  break;
521  }
523  {
524  pResult = static_cast< const XFillFloatTransparenceItem* >(pItem)->checkForUniqueItem(pDrawModel);
525  break;
526  }
527  case XATTR_FILLHATCH:
528  {
529  pResult = static_cast< const XFillHatchItem* >(pItem)->checkForUniqueItem(pDrawModel);
530  break;
531  }
532  }
533 
534  if(pResult)
535  {
536  rSet.Put(*pResult);
537  }
538  }
539 }
540 
542 {
543  if( !rSet.Count() )
544  return false;
545 
546  std::unique_ptr<SwUndoFormatAttrHelper> pSaveUndo;
547 
549  {
550  GetIDocumentUndoRedo().ClearRedo(); // AppendUndo far below, so leave it
551  pSaveUndo.reset( new SwUndoFormatAttrHelper( rFlyFormat ) );
552  }
553 
554  bool const bRet = lcl_SetFlyFrameAttr(*this, &SwDoc::SetFlyFrameAnchor, rFlyFormat, rSet);
555 
556  if (pSaveUndo && pSaveUndo->GetUndo() )
557  {
558  GetIDocumentUndoRedo().AppendUndo( pSaveUndo->ReleaseUndo() );
559  }
560 
562 
563  SwTextBoxHelper::syncFlyFrameAttr(rFlyFormat, rSet);
564 
565  return bRet;
566 }
567 
568 // #i73249#
570  const OUString& sNewTitle )
571 {
572  if ( rFlyFrameFormat.GetObjTitle() == sNewTitle )
573  {
574  return;
575  }
576 
577  ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo());
578 
579  if (GetIDocumentUndoRedo().DoesUndo())
580  {
581  GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoFlyStrAttr>( rFlyFrameFormat,
583  rFlyFrameFormat.GetObjTitle(),
584  sNewTitle ) );
585  }
586 
587  rFlyFrameFormat.SetObjTitle( sNewTitle, true );
588 
590 }
591 
593  const OUString& sNewDescription )
594 {
595  if ( rFlyFrameFormat.GetObjDescription() == sNewDescription )
596  {
597  return;
598  }
599 
600  ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo());
601 
602  if (GetIDocumentUndoRedo().DoesUndo())
603  {
604  GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoFlyStrAttr>( rFlyFrameFormat,
606  rFlyFrameFormat.GetObjDescription(),
607  sNewDescription ) );
608  }
609 
610  rFlyFrameFormat.SetObjDescription( sNewDescription, true );
611 
613 }
614 
616  SfxItemSet* pSet, bool bKeepOrient )
617 {
618  bool bChgAnchor = false, bFrameSz = false;
619 
620  const SwFormatFrameSize aFrameSz( rFormat.GetFrameSize() );
621 
622  SwUndoSetFlyFormat* pUndo = nullptr;
623  bool const bUndo = GetIDocumentUndoRedo().DoesUndo();
624  if (bUndo)
625  {
626  pUndo = new SwUndoSetFlyFormat( rFormat, rNewFormat );
627  GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
628  }
629 
630  // #i32968# Inserting columns in the section causes MakeFrameFormat to put
631  // 2 objects of type SwUndoFrameFormat on the undo stack. We don't want them.
632  ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
633 
634  // Set the column first, or we'll have trouble with
635  //Set/Reset/Synch. and so on
636  const SfxPoolItem* pItem;
637  if( SfxItemState::SET != rNewFormat.GetAttrSet().GetItemState( RES_COL ))
638  rFormat.ResetFormatAttr( RES_COL );
639 
640  if( rFormat.DerivedFrom() != &rNewFormat )
641  {
642  rFormat.SetDerivedFrom( &rNewFormat );
643 
644  // 1. If not automatic = ignore; else = dispose
645  // 2. Dispose of it!
646  if( SfxItemState::SET == rNewFormat.GetAttrSet().GetItemState( RES_FRM_SIZE, false ))
647  {
648  rFormat.ResetFormatAttr( RES_FRM_SIZE );
649  bFrameSz = true;
650  }
651 
652  const SfxItemSet* pAsk = pSet;
653  if( !pAsk ) pAsk = &rNewFormat.GetAttrSet();
654  if( SfxItemState::SET == pAsk->GetItemState( RES_ANCHOR, false, &pItem )
655  && static_cast<const SwFormatAnchor*>(pItem)->GetAnchorId() !=
656  rFormat.GetAnchor().GetAnchorId() )
657  {
658  if( pSet )
659  bChgAnchor = MAKEFRMS == SetFlyFrameAnchor( rFormat, *pSet, false );
660  else
661  {
662  // Needs to have the FlyFormat range, because we set attributes in it,
663  // in SetFlyFrameAnchor.
664  SfxItemSet aFlySet( *rNewFormat.GetAttrSet().GetPool(),
665  rNewFormat.GetAttrSet().GetRanges() );
666  aFlySet.Put( *pItem );
667  bChgAnchor = MAKEFRMS == SetFlyFrameAnchor( rFormat, aFlySet, false);
668  }
669  }
670  }
671 
672  // Only reset vertical and horizontal orientation, if we have automatic alignment
673  // set in the template. Otherwise use the old value.
674  // If we update the frame template the Fly should NOT lose its orientation (which
675  // is not being updated!).
676  // text::HoriOrientation::NONE and text::VertOrientation::NONE are allowed now
677  if (!bKeepOrient)
678  {
681  }
682 
687 
688  if( !bFrameSz )
689  rFormat.SetFormatAttr( aFrameSz );
690 
691  if( bChgAnchor )
692  rFormat.MakeFrames();
693 
694  if( pUndo )
695  pUndo->EndListeningAll();
696 
698 
699  return bChgAnchor;
700 }
701 
702 void SwDoc::GetGrfNms( const SwFlyFrameFormat& rFormat, OUString* pGrfName,
703  OUString* pFltName )
704 {
705  SwNodeIndex aIdx( *rFormat.GetContent().GetContentIdx(), 1 );
706  const SwGrfNode* pGrfNd = aIdx.GetNode().GetGrfNode();
707  if( pGrfNd && pGrfNd->IsLinkedFile() )
708  pGrfNd->GetFileFilterNms( pGrfName, pFltName );
709 }
710 
711 bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
712  RndStdIds _eAnchorType,
713  const bool _bSameOnly,
714  const bool _bPosCorr )
715 {
716  OSL_ENSURE( getIDocumentLayoutAccess().GetCurrentLayout(), "No layout!" );
717 
718  if ( !_rMrkList.GetMarkCount() ||
720  {
721  return false;
722  }
723 
725 
726  bool bUnmark = false;
727  for ( size_t i = 0; i < _rMrkList.GetMarkCount(); ++i )
728  {
729  SdrObject* pObj = _rMrkList.GetMark( i )->GetMarkedSdrObj();
730  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
731  {
732  SwDrawContact* pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
733 
734  // consider, that drawing object has
735  // no user call. E.g.: a 'virtual' drawing object is disconnected by
736  // the anchor type change of the 'master' drawing object.
737  // Continue with next selected object and assert, if this isn't excepted.
738  if ( !pContact )
739  {
740 #if OSL_DEBUG_LEVEL > 0
741  bool bNoUserCallExcepted =
742  dynamic_cast<const SwDrawVirtObj*>( pObj) != nullptr &&
743  !static_cast<SwDrawVirtObj*>(pObj)->IsConnected();
744  OSL_ENSURE( bNoUserCallExcepted, "SwDoc::ChgAnchor(..) - no contact at selected drawing object" );
745 #endif
746  continue;
747  }
748 
749  // #i26791#
750  const SwFrame* pOldAnchorFrame = pContact->GetAnchorFrame( pObj );
751  const SwFrame* pNewAnchorFrame = pOldAnchorFrame;
752 
753  // #i54336#
754  // Instead of only keeping the index position for an as-character
755  // anchored object the complete <SwPosition> is kept, because the
756  // anchor index position could be moved, if the object again is
757  // anchored as character.
758  std::unique_ptr<const SwPosition> xOldAsCharAnchorPos;
759  const RndStdIds eOldAnchorType = pContact->GetAnchorId();
760  if ( !_bSameOnly && eOldAnchorType == RndStdIds::FLY_AS_CHAR )
761  {
762  xOldAsCharAnchorPos.reset(new SwPosition(pContact->GetContentAnchor()));
763  }
764 
765  if ( _bSameOnly )
766  _eAnchorType = eOldAnchorType;
767 
768  SwFormatAnchor aNewAnch( _eAnchorType );
769  SwAnchoredObject *pAnchoredObj = pContact->GetAnchoredObj(pObj);
770  tools::Rectangle aObjRect(pAnchoredObj->GetObjRect().SVRect());
771  const Point aPt( aObjRect.TopLeft() );
772 
773  switch ( _eAnchorType )
774  {
775  case RndStdIds::FLY_AT_PARA:
776  case RndStdIds::FLY_AT_CHAR:
777  {
778  const Point aNewPoint = ( pOldAnchorFrame->IsVertical() ||
779  pOldAnchorFrame->IsRightToLeft() )
780  ? aObjRect.TopRight()
781  : aPt;
782 
783  // allow drawing objects in header/footer
784  pNewAnchorFrame = ::FindAnchor( pOldAnchorFrame, aNewPoint );
785  if ( pNewAnchorFrame->IsTextFrame() && static_cast<const SwTextFrame*>(pNewAnchorFrame)->IsFollow() )
786  {
787  pNewAnchorFrame = static_cast<const SwTextFrame*>(pNewAnchorFrame)->FindMaster();
788  }
789  if ( pNewAnchorFrame->IsProtected() )
790  {
791  pNewAnchorFrame = nullptr;
792  }
793  else
794  {
795  SwPosition aPos( pNewAnchorFrame->IsTextFrame()
796  ? *static_cast<SwTextFrame const*>(pNewAnchorFrame)->GetTextNodeForParaProps()
797  : *static_cast<SwNoTextFrame const*>(pNewAnchorFrame)->GetNode() );
798 
799  aNewAnch.SetType( _eAnchorType );
800  aNewAnch.SetAnchor( &aPos );
801  }
802  }
803  break;
804 
805  case RndStdIds::FLY_AT_FLY: // LAYER_IMPL
806  {
807  // Search the closest SwFlyFrame starting from the upper left corner.
808  SwFrame *pTextFrame;
809  {
811  SwPosition aPos( GetNodes() );
812  Point aPoint( aPt );
813  aPoint.setX(aPoint.getX() - 1);
815  // consider that drawing objects can be in
816  // header/footer. Thus, <GetFrame()> by left-top-corner
817  std::pair<Point, bool> const tmp(aPt, false);
818  pTextFrame = aPos.nNode.GetNode().
820  getIDocumentLayoutAccess().GetCurrentLayout(),
821  nullptr, &tmp);
822  }
823  const SwFrame *pTmp = ::FindAnchor( pTextFrame, aPt );
824  pNewAnchorFrame = pTmp->FindFlyFrame();
825  if( pNewAnchorFrame && !pNewAnchorFrame->IsProtected() )
826  {
827  const SwFrameFormat *pTmpFormat = static_cast<const SwFlyFrame*>(pNewAnchorFrame)->GetFormat();
828  const SwFormatContent& rContent = pTmpFormat->GetContent();
829  SwPosition aPos( *rContent.GetContentIdx() );
830  aNewAnch.SetAnchor( &aPos );
831  break;
832  }
833 
834  aNewAnch.SetType( RndStdIds::FLY_AT_PAGE );
835  [[fallthrough]];
836  }
837  case RndStdIds::FLY_AT_PAGE:
838  {
839  pNewAnchorFrame = getIDocumentLayoutAccess().GetCurrentLayout()->Lower();
840  while ( pNewAnchorFrame && !pNewAnchorFrame->getFrameArea().IsInside( aPt ) )
841  pNewAnchorFrame = pNewAnchorFrame->GetNext();
842  if ( !pNewAnchorFrame )
843  continue;
844 
845  aNewAnch.SetPageNum( static_cast<const SwPageFrame*>(pNewAnchorFrame)->GetPhyPageNum());
846  }
847  break;
848  case RndStdIds::FLY_AS_CHAR:
849  if( _bSameOnly ) // Change of position/size
850  {
851  if( !pOldAnchorFrame )
852  {
853  pContact->ConnectToLayout();
854  pOldAnchorFrame = pContact->GetAnchorFrame();
855  }
856  const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pOldAnchorFrame))->Prepare();
857  }
858  else // Change of anchors
859  {
860  // allow drawing objects in header/footer
861  pNewAnchorFrame = ::FindAnchor( pOldAnchorFrame, aPt );
862  if( pNewAnchorFrame->IsProtected() )
863  {
864  pNewAnchorFrame = nullptr;
865  break;
866  }
867 
868  bUnmark = ( 0 != i );
869  Point aPoint( aPt );
870  aPoint.setX(aPoint.getX() - 1); // Do not load in the DrawObj!
871  aNewAnch.SetType( RndStdIds::FLY_AS_CHAR );
872  assert(pNewAnchorFrame->IsTextFrame()); // because AS_CHAR
873  SwTextFrame const*const pFrame(
874  static_cast<SwTextFrame const*>(pNewAnchorFrame));
875  SwPosition aPos( *pFrame->GetTextNodeForParaProps() );
876  if ( pNewAnchorFrame->getFrameArea().IsInside( aPoint ) )
877  {
878  // We need to find a TextNode, because only there we can anchor a
879  // content-bound DrawObject.
882  }
883  else
884  {
885  if ( pNewAnchorFrame->getFrameArea().Bottom() < aPt.Y() )
886  {
887  aPos = pFrame->MapViewToModelPos(TextFrameIndex(0));
888  }
889  else
890  {
891  aPos = pFrame->MapViewToModelPos(
892  TextFrameIndex(pFrame->GetText().getLength()));
893  }
894  }
895  aNewAnch.SetAnchor( &aPos );
896  SetAttr( aNewAnch, *pContact->GetFormat() );
897  // #i26791# - adjust vertical positioning to 'center to
898  // baseline'
899  SetAttr( SwFormatVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME ), *pContact->GetFormat() );
900  SwTextNode *pNd = aPos.nNode.GetNode().GetTextNode();
901  OSL_ENSURE( pNd, "Cursor not positioned at TextNode." );
902 
903  SwFormatFlyCnt aFormat( pContact->GetFormat() );
904  pNd->InsertItem( aFormat, aPos.nContent.GetIndex(), 0 );
905  }
906  break;
907  default:
908  OSL_ENSURE( false, "unexpected AnchorId." );
909  }
910 
911  if ( (RndStdIds::FLY_AS_CHAR != _eAnchorType) &&
912  pNewAnchorFrame &&
913  ( !_bSameOnly || pNewAnchorFrame != pOldAnchorFrame ) )
914  {
915  // #i26791# - Direct object positioning no longer needed. Apply
916  // of attributes (method call <SetAttr(..)>) takes care of the
917  // invalidation of the object position.
918  SetAttr( aNewAnch, *pContact->GetFormat() );
919  if ( _bPosCorr )
920  {
921  // #i33313# - consider not connected 'virtual' drawing
922  // objects
923  if ( dynamic_cast<const SwDrawVirtObj*>( pObj) != nullptr &&
924  !static_cast<SwDrawVirtObj*>(pObj)->IsConnected() )
925  {
926  SwRect aNewObjRect( aObjRect );
927  static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( nullptr ))
928  ->AdjustPositioningAttr( pNewAnchorFrame,
929  &aNewObjRect );
930  }
931  else
932  {
933  static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( pObj ))
934  ->AdjustPositioningAttr( pNewAnchorFrame );
935  }
936  }
937  }
938 
939  // we have changed the anchoring attributes, and those are used to
940  // order the object in its sorted list, so update its position
941  pAnchoredObj->UpdateObjInSortedList();
942 
943  // #i54336#
944  if (xOldAsCharAnchorPos)
945  {
946  if ( pNewAnchorFrame)
947  {
948  // We need to handle InContents in a special way:
949  // The TextAttribut needs to be destroyed which, unfortunately, also
950  // destroys the format. To avoid that, we disconnect the format from
951  // the attribute.
952  const sal_Int32 nIndx( xOldAsCharAnchorPos->nContent.GetIndex() );
953  SwTextNode* pTextNode( xOldAsCharAnchorPos->nNode.GetNode().GetTextNode() );
954  assert(pTextNode && "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object");
955  SwTextAttr * const pHint =
956  pTextNode->GetTextAttrForCharAt( nIndx, RES_TXTATR_FLYCNT );
957  assert(pHint && "Missing FlyInCnt-Hint.");
958  const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()).SetFlyFormat();
959 
960  // They are disconnected. We now have to destroy the attribute.
961  pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx );
962  }
963  }
964  }
965  }
966 
969 
970  return bUnmark;
971 }
972 
974 {
975  // The Source must not yet have a Follow.
976  const SwFormatChain &rOldChain = rSource.GetChain();
977  if ( rOldChain.GetNext() )
979 
980  // Target must not be equal to Source and we also must not have a closed chain.
981  const SwFrameFormat *pFormat = &rDest;
982  do {
983  if( pFormat == &rSource )
984  return SwChainRet::SELF;
985  pFormat = pFormat->GetChain().GetNext();
986  } while ( pFormat );
987 
988  // There must not be a chaining from outside to inside or the other way around.
989  if( rDest.IsLowerOf( rSource ) || rSource .IsLowerOf( rDest ) )
990  return SwChainRet::SELF;
991 
992  // The Target must not yet have a Master.
993  const SwFormatChain &rChain = rDest.GetChain();
994  if( rChain.GetPrev() )
996 
997  // Target must be empty.
998  const SwNodeIndex* pCntIdx = rDest.GetContent().GetContentIdx();
999  if( !pCntIdx )
1000  return SwChainRet::NOT_FOUND;
1001 
1002  SwNodeIndex aNxtIdx( *pCntIdx, 1 );
1003  const SwTextNode* pTextNd = aNxtIdx.GetNode().GetTextNode();
1004  if( !pTextNd )
1005  return SwChainRet::NOT_FOUND;
1006 
1007  const sal_uLong nFlySttNd = pCntIdx->GetIndex();
1008  if( 2 != ( pCntIdx->GetNode().EndOfSectionIndex() - nFlySttNd ) ||
1009  pTextNd->GetText().getLength() )
1010  {
1011  return SwChainRet::NOT_EMPTY;
1012  }
1013 
1014  for( auto pSpzFrameFm : *GetSpzFrameFormats() )
1015  {
1016  const SwFormatAnchor& rAnchor = pSpzFrameFm->GetAnchor();
1017  sal_uLong nTstSttNd;
1018  // #i20622# - to-frame anchored objects are allowed.
1019  if ( ((rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA) ||
1020  (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR)) &&
1021  nullptr != rAnchor.GetContentAnchor() &&
1022  nFlySttNd <= ( nTstSttNd =
1023  rAnchor.GetContentAnchor()->nNode.GetIndex() ) &&
1024  nTstSttNd < nFlySttNd + 2 )
1025  {
1026  return SwChainRet::NOT_EMPTY;
1027  }
1028  }
1029 
1030  // We also need to consider the right area.
1031  // Both Flys need to be located in the same area (Body, Header/Footer, Fly).
1032  // If the Source is not the selected frame, it's enough to find a suitable
1033  // one. e.g. if it's requested by the API.
1034 
1035  // both in the same fly, header, footer or on the page?
1036  const SwFormatAnchor &rSrcAnchor = rSource.GetAnchor(),
1037  &rDstAnchor = rDest.GetAnchor();
1038  sal_uLong nEndOfExtras = GetNodes().GetEndOfExtras().GetIndex();
1039  bool bAllowed = false;
1040  if ( RndStdIds::FLY_AT_PAGE == rSrcAnchor.GetAnchorId() )
1041  {
1042  if ( (RndStdIds::FLY_AT_PAGE == rDstAnchor.GetAnchorId()) ||
1043  ( rDstAnchor.GetContentAnchor() &&
1044  rDstAnchor.GetContentAnchor()->nNode.GetIndex() > nEndOfExtras ))
1045  bAllowed = true;
1046  }
1047  else if( rSrcAnchor.GetContentAnchor() && rDstAnchor.GetContentAnchor() )
1048  {
1049  const SwNodeIndex &rSrcIdx = rSrcAnchor.GetContentAnchor()->nNode,
1050  &rDstIdx = rDstAnchor.GetContentAnchor()->nNode;
1051  const SwStartNode* pSttNd = nullptr;
1052  if( rSrcIdx == rDstIdx ||
1053  ( !pSttNd &&
1054  nullptr != ( pSttNd = rSrcIdx.GetNode().FindFlyStartNode() ) &&
1055  pSttNd == rDstIdx.GetNode().FindFlyStartNode() ) ||
1056  ( !pSttNd &&
1057  nullptr != ( pSttNd = rSrcIdx.GetNode().FindFooterStartNode() ) &&
1058  pSttNd == rDstIdx.GetNode().FindFooterStartNode() ) ||
1059  ( !pSttNd &&
1060  nullptr != ( pSttNd = rSrcIdx.GetNode().FindHeaderStartNode() ) &&
1061  pSttNd == rDstIdx.GetNode().FindHeaderStartNode() ) ||
1062  ( !pSttNd && rDstIdx.GetIndex() > nEndOfExtras &&
1063  rSrcIdx.GetIndex() > nEndOfExtras ))
1064  bAllowed = true;
1065  }
1066 
1067  return bAllowed ? SwChainRet::OK : SwChainRet::WRONG_AREA;
1068 }
1069 
1071 {
1072  SwChainRet nErr = Chainable( rSource, rDest );
1073  if ( nErr == SwChainRet::OK )
1074  {
1076 
1077  SwFlyFrameFormat& rDestFormat = const_cast<SwFlyFrameFormat&>(static_cast<const SwFlyFrameFormat&>(rDest));
1078 
1079  // Attach Follow to the Master.
1080  SwFormatChain aChain = rDestFormat.GetChain();
1081  aChain.SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1082  SetAttr( aChain, rDestFormat );
1083 
1085  RES_CHAIN, RES_CHAIN>{} );
1086 
1087  // Attach Follow to the Master.
1088  aChain.SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1089  SetAttr( aChain, rDestFormat );
1090 
1091  // Attach Master to the Follow.
1092  // Make sure that the Master has a fixed height.
1093  aChain = rSource.GetChain();
1094  aChain.SetNext( &rDestFormat );
1095  aSet.Put( aChain );
1096 
1097  SwFormatFrameSize aSize( rSource.GetFrameSize() );
1098  if ( aSize.GetHeightSizeType() != SwFrameSize::Fixed )
1099  {
1100  SwFlyFrame *pFly = SwIterator<SwFlyFrame,SwFormat>( rSource ).First();
1101  if ( pFly )
1102  aSize.SetHeight( pFly->getFrameArea().Height() );
1103  aSize.SetHeightSizeType( SwFrameSize::Fixed );
1104  aSet.Put( aSize );
1105  }
1106  SetAttr( aSet, rSource );
1107 
1109  }
1110  return nErr;
1111 }
1112 
1114 {
1115  SwFormatChain aChain( rFormat.GetChain() );
1116  if ( aChain.GetNext() )
1117  {
1119  SwFrameFormat *pFollow = aChain.GetNext();
1120  aChain.SetNext( nullptr );
1121  SetAttr( aChain, rFormat );
1122  aChain = pFollow->GetChain();
1123  aChain.SetPrev( nullptr );
1124  SetAttr( aChain, *pFollow );
1126  }
1127 }
1128 
1129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Starts a section of nodes in the document model.
Definition: node.hxx:303
Base class of the Writer layout elements.
Definition: frame.hxx:297
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
virtual SwRect GetObjRect() const =0
sal_uLong GetIndex() const
Definition: node.hxx:282
#define RES_FRM_SIZE
Definition: hintids.hxx:289
#define RES_COL
Definition: hintids.hxx:309
#define XATTR_FILLHATCH
#define RES_URL
Definition: hintids.hxx:311
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:312
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:811
bool IsGrfNode() const
Definition: node.hxx:656
OUString GetObjDescription() const
Definition: atrfrm.cxx:3158
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:303
stay with the cursor inside text
Definition: crstate.hxx:127
#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: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
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:2709
#define RES_SURROUND
Definition: hintids.hxx:301
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1148
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
#define XATTR_FILLGRADIENT
Definition: doc.hxx:186
static SwContentNode * GetContentNode(SwDoc *pDoc, SwNodeIndex &rIdx, bool bNext)
Definition: fltshell.cxx:54
void Height(long nNew)
Definition: swrect.hxx:190
#define XATTR_FILLFLOATTRANSPARENCE
#define MAKEFRMS
Definition: docfly.cxx:268
SwNode & GetNode() const
Definition: ndindex.hxx:119
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:168
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:143
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
sal_uInt16 Which() const
Definition: txatbase.hxx:110
Only empty frames may be connected.
void SetPrev(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2025
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:55
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
#define RES_CNTNT
Definition: hintids.hxx:295
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:171
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:741
Destination in section where it shouldn't be (header, footer).
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:154
SwChainRet Chain(SwFrameFormat &rSource, const SwFrameFormat &rDest)
Definition: docfly.cxx:1070
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:3051
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Definition: trvlfrm.cxx:423
#define RES_CHAIN
Definition: hintids.hxx:314
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:426
const SfxPoolItem * NextItem()
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:782
Destination and/or source not found.
const SwRect & getFrameArea() const
Definition: frame.hxx:177
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:450
int nCount
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
bool IsTextFrame() const
Definition: frame.hxx:1212
#define RES_UL_SPACE
Definition: hintids.hxx:292
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:1255
OUString GetObjTitle() const
Definition: atrfrm.cxx:3121
SwFrameFormat * GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes=false)
Definition: docfly.cxx:115
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1089
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
Definition: ndgrf.cxx:483
void Unchain(SwFrameFormat &rFormat)
Definition: docfly.cxx:1113
#define RES_PRINT
Definition: hintids.hxx:298
virtual bool DoesUndo() const =0
Is Undo enabled?
SwAttrPool * GetPool() const
Definition: swatrset.hxx:190
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:326
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:652
#define RES_BACKGROUND
Definition: hintids.hxx:305
#define RES_FLYFRMFMT
Definition: hintids.hxx:369
SdrObject * GetMarkedSdrObj() const
#define RES_FILL_ORDER
Definition: hintids.hxx:288
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:304
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
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:302
RndStdIds GetAnchorId() const
Definition: dcontact.hxx:145
void SetFlyFrameDescription(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewDescription)
Definition: docfly.cxx:592
const SwFrame * Lower() const
Definition: layfrm.hxx:101
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
Definition: docfly.cxx:615
SwContentNode * GetContentNode()
Definition: node.hxx:615
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:2632
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:393
sal_Int8 SetFlyFrameAnchor(SwFrameFormat &rFlyFormat, SfxItemSet &rSet, bool bNewFrames)
Definition: docfly.cxx:272
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:541
static void GetGrfNms(const SwFlyFrameFormat &rFormat, OUString *pGrfName, OUString *pFltName)
Definition: docfly.cxx:702
#define XATTR_LINEDASH
Frame cannot be moved in Var-direction.
static sal_uInt16 nPgNum
Definition: viewport.cxx:49
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:404
SwFlyFrameFormat * GetNext() const
Definition: fmtcnct.hxx:54
#define RES_LR_SPACE
Definition: hintids.hxx:291
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
#define RES_FOOTER
Definition: hintids.hxx:297
sal_uInt16 const aFrameFormatSetRange[]
Definition: init.cxx:234
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
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:80
void Bottom(const long nBottom)
Definition: swrect.hxx:208
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:1704
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:650
tools::Rectangle SVRect() const
Definition: swrect.hxx:283
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:2714
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
#define IGNOREANCHOR
Definition: docfly.cxx:269
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const override
Definition: dcontact.cxx:740
#define XATTR_LINEEND
sal_Int32 GetIndex() const
Definition: index.hxx:95
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:109
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2643
void ConnectToLayout(const SwFormatAnchor *pAnch=nullptr)
Inserts SdrObject in the arrays of the layout ((SwPageFrame and SwFrame).
Definition: dcontact.cxx:1715
virtual SwDrawModel * GetOrCreateDrawModel()=0
SwNodes & GetNodes()
Definition: doc.hxx:405
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:210
bool IsRightToLeft() const
Definition: frame.hxx:965
void SetFlyFrameTitle(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewTitle)
Definition: docfly.cxx:569
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
#define RES_TXTATR_FLYCNT
Definition: hintids.hxx:245
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:1022
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:951
#define XATTR_FILLBITMAP
SwChainRet Chainable(const SwFrameFormat &rSource, const SwFrameFormat &rDest)
Definition: docfly.cxx:973
void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet &rSet)
Definition: docfly.cxx:484
SwFrameFormat * GetFrameFormat() const
Definition: fmtflcnt.hxx:45
void SetNext(SwFlyFrameFormat *pFormat)
Definition: atrfrm.cxx:2033
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
Definition: nodes.cxx:2313
RndStdIds
size_t size() const
void SetObjTitle(const OUString &rTitle, bool bBroadcast=false)
Definition: atrfrm.cxx:3098
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:153
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
bool IsInvalidItem(const SfxPoolItem *pItem)
#define RES_PAGEDESC
Definition: hintids.hxx:293
#define RES_BREAK
Definition: hintids.hxx:294
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:161
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 SetObjDescription(const OUString &rDescription, bool bBroadcast=false)
Definition: atrfrm.cxx:3135
const SwPosition & GetContentAnchor() const
Definition: dcontact.hxx:152
SwChainRet
Definition: flyenum.hxx:33
bool ChgAnchor(const SdrMarkList &_rMrkList, RndStdIds _eAnchorType, const bool _bSameOnly, const bool _bPosCorr)
Definition: docfly.cxx:711
sal_uInt16 nPos
const SfxPoolItem * GetCurItem() const
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1317
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:836
bool HasHints() const
Definition: ndtxt.hxx:221
#define XATTR_LINESTART
SwFlyFrame * GetFrame(const Point *pDocPos=nullptr) const
Definition: atrfrm.cxx:3053
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1478
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1625
bool IsConnected() const
is 'virtual' drawing object connected to writer layout and / to drawing layer.
Definition: dcontact.cxx:2258
const SwFormatFlyCnt & GetFlyCnt() const
Definition: txatbase.hxx:206
SwFrame * GetNext()
Definition: frame.hxx:656
Base class of the Writer document model elements.
Definition: node.hxx:79