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