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