LibreOffice Module sw (master)  1
anchoredobjectposition.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 
22 #include <flyfrm.hxx>
23 #include <flyfrms.hxx>
24 #include <txtfrm.hxx>
25 #include <pagefrm.hxx>
26 #include <frmatr.hxx>
27 #include <frmtool.hxx>
28 #include <svx/svdobj.hxx>
29 #include <dflyobj.hxx>
30 #include <dcontact.hxx>
31 #include <frmfmt.hxx>
32 #include <fmtornt.hxx>
33 #include <fmtfsize.hxx>
34 #include <fmtfollowtextflow.hxx>
35 #include <editeng/lrspitem.hxx>
36 #include <editeng/ulspitem.hxx>
37 #include <ndtxt.hxx>
39 #include <textboxhelper.hxx>
40 #include <fmtsrnd.hxx>
41 
42 using namespace ::com::sun::star;
43 using namespace objectpositioning;
44 
46  : mrDrawObj( _rDrawObj ),
47  mpAnchoredObj( nullptr ),
48  mpAnchorFrame( nullptr ),
49  mpContact( nullptr ),
50  mbIsObjFly( false ),
51  // #i62875#
52  mbFollowTextFlow( false ),
53  mbDoNotCaptureAnchoredObj( false )
54 {
55 #if OSL_DEBUG_LEVEL > 0
56  // assert, if object isn't of expected type
57  const bool bObjOfExceptedType =
58  dynamic_cast<const SwVirtFlyDrawObj*>( &mrDrawObj) != nullptr || // object representing fly frame
59  dynamic_cast<const SwDrawVirtObj*>( &mrDrawObj) != nullptr || // 'virtual' drawing object
60  ( dynamic_cast<const SdrVirtObj*>( &mrDrawObj) == nullptr && // 'master' drawing object
61  dynamic_cast<const SwFlyDrawObj*>( &mrDrawObj) == nullptr ); // - indirectly checked
62  OSL_ENSURE( bObjOfExceptedType,
63  "SwAnchoredObjectPosition(..) - object of unexpected type!" );
64 #endif
65 
67 }
68 
75 {
76  // determine, if object represents a fly frame
77  {
78  mbIsObjFly = dynamic_cast<const SwVirtFlyDrawObj*>( &mrDrawObj) != nullptr;
79  }
80 
81  // determine contact object
82  {
84  assert(mpContact &&
85  "SwAnchoredObjectPosition::GetInfoAboutObj() - missing SwContact-object.");
86  }
87 
88  // determine anchored object, the object belongs to
89  {
90  // #i26791#
93  "SwAnchoredObjectPosition::GetInfoAboutObj() - missing anchored object.");
94  }
95 
96  // determine frame, the object is anchored at
97  {
98  // #i26791#
100  OSL_ENSURE( mpAnchorFrame,
101  "SwAnchoredObjectPosition::GetInfoAboutObj() - missing anchor frame." );
102  }
103 
104  // determine format the object belongs to
105  {
106  // #i28701#
109  "<SwAnchoredObjectPosition::GetInfoAboutObj() - missing frame format.");
110  }
111 
112  // #i62875# - determine attribute value of <Follow-Text-Flow>
113  {
115  }
116 
117  // determine, if anchored object has not to be captured on the page.
118  // the following conditions must be hold to *not* capture it:
119  // - corresponding document compatibility flag is set
120  // - it's a drawing object or it's a non-textbox wrap-though fly frame
121  // - it doesn't follow the text flow
122  {
124  bool bWrapThrough = mpFrameFormat->GetSurround().GetSurround() == css::text::WrapTextMode_THROUGH;
125  mbDoNotCaptureAnchoredObj = (!mbIsObjFly || (!bTextBox && bWrapThrough)) && !mbFollowTextFlow &&
127  }
128 }
129 
131 {}
132 
134 {
135  return false;
136 }
137 
139 {
140  return nullptr;
141 }
142 
144 {
145  return nullptr;
146 }
147 
148 // #i22341#
150 {
151  return 0;
152 }
153 
160  const SwRectFn& _fnRect,
161  const bool _bVert ) const
162 {
163  SwTwips nTopOfFrameForObjPos = (_rFrame.getFrameArea().*_fnRect->fnGetTop)();
164 
165  if ( _rFrame.IsTextFrame() )
166  {
167  const SwTextFrame& rTextFrame = static_cast<const SwTextFrame&>(_rFrame);
168  if ( _bVert )
169  {
170  nTopOfFrameForObjPos -=
172  }
173  else
174  {
175  nTopOfFrameForObjPos +=
177 
178  const SwFormatSurround& rSurround = mpFrameFormat->GetSurround();
179  bool bWrapThrough = rSurround.GetSurround() == css::text::WrapTextMode_THROUGH;
180  // If the frame format is a TextBox of a draw shape, then use the
181  // surround of the original shape.
183 
184  // Get the offset between the top of the text frame and the top of
185  // the first line inside the frame that has more than just fly
186  // portions.
187  nTopOfFrameForObjPos += rTextFrame.GetBaseVertOffsetForFly(!bWrapThrough);
188  }
189  }
190 
191  return nTopOfFrameForObjPos;
192 }
193 
195  const SwFrame& _rVertOrientFrame,
196  const SwFrame& _rPageAlignLayFrame,
197  const sal_Int16 _eRelOrient,
198  SwTwips& _orAlignAreaHeight,
199  SwTwips& _orAlignAreaOffset ) const
200 {
201  SwTwips nHeight = 0;
202  SwTwips nOffset = 0;
203  SwRectFnSet aRectFnSet(&_rVertOrientFrame);
204  // #i11860# - top of <_rVertOrientFrame> for object positioning
205  const SwTwips nVertOrientTop = GetTopForObjPos( _rVertOrientFrame, aRectFnSet.FnRect(), aRectFnSet.IsVert() );
206  // #i11860# - upper space amount of <_rVertOrientFrame> considered
207  // for previous frame
208  const SwTwips nVertOrientUpperSpaceForPrevFrameAndPageGrid =
209  _rVertOrientFrame.IsTextFrame()
210  ? static_cast<const SwTextFrame&>(_rVertOrientFrame).
211  GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid()
212  : 0;
213  switch ( _eRelOrient )
214  {
215  case text::RelOrientation::FRAME:
216  {
217  // #i11860# - consider upper space of previous frame
218  nHeight = aRectFnSet.GetHeight(_rVertOrientFrame.getFrameArea()) -
219  nVertOrientUpperSpaceForPrevFrameAndPageGrid;
220  nOffset = 0;
221  }
222  break;
223  case text::RelOrientation::PRINT_AREA:
224  {
225  nHeight = aRectFnSet.GetHeight(_rVertOrientFrame.getFramePrintArea());
226  // #i11860# - consider upper space of previous frame
227  nOffset = aRectFnSet.GetTopMargin(_rVertOrientFrame) -
228  nVertOrientUpperSpaceForPrevFrameAndPageGrid;
229  // if aligned to page in horizontal layout, consider header and
230  // footer frame height appropriately.
231  if( _rVertOrientFrame.IsPageFrame() && !aRectFnSet.IsVert() )
232  {
233  const SwFrame* pPrtFrame =
234  static_cast<const SwPageFrame&>(_rVertOrientFrame).Lower();
235  while( pPrtFrame )
236  {
237  if( pPrtFrame->IsHeaderFrame() )
238  {
239  nHeight -= pPrtFrame->getFrameArea().Height();
240  nOffset += pPrtFrame->getFrameArea().Height();
241  }
242  else if( pPrtFrame->IsFooterFrame() )
243  {
244  nHeight -= pPrtFrame->getFrameArea().Height();
245  }
246  pPrtFrame = pPrtFrame->GetNext();
247  }
248  }
249  }
250  break;
251  case text::RelOrientation::PAGE_FRAME:
252  {
253  nHeight = aRectFnSet.GetHeight(_rPageAlignLayFrame.getFrameArea());
254  nOffset = aRectFnSet.YDiff(
255  aRectFnSet.GetTop(_rPageAlignLayFrame.getFrameArea()),
256  nVertOrientTop );
257  }
258  break;
259  case text::RelOrientation::PAGE_PRINT_AREA:
260  {
261  nHeight = aRectFnSet.GetHeight(_rPageAlignLayFrame.getFramePrintArea());
262  nOffset = aRectFnSet.GetTopMargin(_rPageAlignLayFrame) +
263  aRectFnSet.YDiff(
264  aRectFnSet.GetTop(_rPageAlignLayFrame.getFrameArea()),
265  nVertOrientTop );
266  // if aligned to page in horizontal layout, consider header and
267  // footer frame height appropriately.
268  if( _rPageAlignLayFrame.IsPageFrame() && !aRectFnSet.IsVert() )
269  {
270  const SwFrame* pPrtFrame =
271  static_cast<const SwPageFrame&>(_rPageAlignLayFrame).Lower();
272  while( pPrtFrame )
273  {
274  if( pPrtFrame->IsHeaderFrame() )
275  {
276  nHeight -= pPrtFrame->getFrameArea().Height();
277  nOffset += pPrtFrame->getFrameArea().Height();
278  }
279  else if( pPrtFrame->IsFooterFrame() )
280  {
281  nHeight -= pPrtFrame->getFrameArea().Height();
282  }
283  pPrtFrame = pPrtFrame->GetNext();
284  }
285  }
286  }
287  break;
288  case text::RelOrientation::PAGE_PRINT_AREA_BOTTOM:
289  {
290  nHeight = aRectFnSet.GetBottomMargin(_rPageAlignLayFrame);
291  nOffset = aRectFnSet.YDiff(
292  aRectFnSet.GetPrtBottom(_rPageAlignLayFrame),
293  nVertOrientTop);
294  }
295  break;
296  // #i22341# - vertical alignment at top of line
297  case text::RelOrientation::TEXT_LINE:
298  {
299  if ( IsAnchoredToChar() )
300  {
301  nHeight = 0;
302  nOffset = aRectFnSet.YDiff( ToCharTopOfLine(), nVertOrientTop );
303  }
304  else
305  {
306  OSL_FAIL( "<SwAnchoredObjectPosition::GetVertAlignmentValues(..)> - invalid relative alignment" );
307  }
308  }
309  break;
310  case text::RelOrientation::CHAR:
311  {
312  if ( IsAnchoredToChar() )
313  {
314  nHeight = aRectFnSet.GetHeight(*ToCharRect());
315  nOffset = aRectFnSet.YDiff( aRectFnSet.GetTop(*ToCharRect()),
316  nVertOrientTop );
317  }
318  else
319  {
320  OSL_FAIL( "<SwAnchoredObjectPosition::GetVertAlignmentValues(..)> - invalid relative alignment" );
321  }
322  }
323  break;
324  // no break here, because text::RelOrientation::CHAR is invalid, if !mbAnchorToChar
325  default:
326  {
327  OSL_FAIL( "<SwAnchoredObjectPosition::GetVertAlignmentValues(..)> - invalid relative alignment" );
328  }
329  }
330 
331  _orAlignAreaHeight = nHeight;
332  _orAlignAreaOffset = nOffset;
333 }
334 
335 // #i26791# - add output parameter <_roVertOffsetToFrameAnchorPos>
337  const SwFrame& _rVertOrientFrame,
338  const SwFrame& _rPageAlignLayFrame,
339  const sal_Int16 _eVertOrient,
340  const sal_Int16 _eRelOrient,
341  const SwTwips _nVertPos,
342  const SvxLRSpaceItem& _rLRSpacing,
343  const SvxULSpaceItem& _rULSpacing,
344  SwTwips& _roVertOffsetToFrameAnchorPos ) const
345 {
346  SwTwips nRelPosY = 0;
347  SwRectFnSet aRectFnSet(&_rVertOrientFrame);
348 
349  SwTwips nAlignAreaHeight;
350  SwTwips nAlignAreaOffset;
351  GetVertAlignmentValues( _rVertOrientFrame, _rPageAlignLayFrame,
352  _eRelOrient, nAlignAreaHeight, nAlignAreaOffset );
353 
354  nRelPosY = nAlignAreaOffset;
355  const SwRect aObjBoundRect( GetAnchoredObj().GetObjRect() );
356  const SwTwips nObjHeight = aRectFnSet.GetHeight(aObjBoundRect);
357 
358  switch ( _eVertOrient )
359  {
361  {
362  // 'manual' vertical position
363  nRelPosY += _nVertPos;
364  }
365  break;
366  case text::VertOrientation::TOP:
367  {
368  nRelPosY += aRectFnSet.IsVert()
369  ? ( aRectFnSet.IsVertL2R()
370  ? _rLRSpacing.GetLeft()
371  : _rLRSpacing.GetRight() )
372  : _rULSpacing.GetUpper();
373  }
374  break;
375  case text::VertOrientation::CENTER:
376  {
377  nRelPosY += (nAlignAreaHeight / 2) - (nObjHeight / 2);
378  }
379  break;
380  case text::VertOrientation::BOTTOM:
381  {
382  nRelPosY += nAlignAreaHeight -
383  ( nObjHeight + ( aRectFnSet.IsVert()
384  ? ( aRectFnSet.IsVertL2R()
385  ? _rLRSpacing.GetRight()
386  : _rLRSpacing.GetLeft() )
387  : _rULSpacing.GetLower() ) );
388  }
389  break;
390  default:
391  {
392  OSL_FAIL( "<SwAnchoredObjectPosition::GetVertRelPos(..) - invalid vertical positioning" );
393  }
394  }
395 
396  // #i26791#
397  _roVertOffsetToFrameAnchorPos = nAlignAreaOffset;
398 
399  return nRelPosY;
400 }
401 
412  const bool bVert,
413  const bool bVertL2R,
414  const SwFrame& rPageAlignLayFrame,
415  const SwTwips nProposedRelPosY,
416  const bool bFollowTextFlow,
417  const bool bCheckBottom ) const
418 {
419  SwTwips nAdjustedRelPosY = nProposedRelPosY;
420 
421  const Size aObjSize( GetAnchoredObj().GetObjRect().SSize() );
422 
423  // determine the area of 'page' alignment frame, to which the vertical
424  // position is restricted.
425  // #i28701# - Extend restricted area for the vertical
426  // position to area of the page frame, if wrapping style influence is
427  // considered on object positioning. Needed to avoid layout loops in the
428  // object positioning algorithm considering the wrapping style influence
429  // caused by objects, which follow the text flow and thus are restricted
430  // to its environment (e.g. page header/footer).
431  SwRect aPgAlignArea;
432  {
433  // #i26945# - no extension of restricted area, if
434  // object's attribute follow text flow is set and its inside a table
435  if ( GetFrameFormat().getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) &&
436  ( !bFollowTextFlow ||
437  !GetAnchoredObj().GetAnchorFrame()->IsInTab() ) )
438  {
439  aPgAlignArea = rPageAlignLayFrame.FindPageFrame()->getFrameArea();
440  }
441  else
442  {
443  aPgAlignArea = rPageAlignLayFrame.getFrameArea();
444  }
445  }
446 
447  if ( bVert )
448  {
449  // #i31805# - consider value of <_bCheckBottom>
450  if ( !bVertL2R )
451  {
452  if ( bCheckBottom &&
453  nTopOfAnch - nAdjustedRelPosY - aObjSize.Width() <
454  aPgAlignArea.Left() )
455  {
456  nAdjustedRelPosY = aPgAlignArea.Left() +
457  nTopOfAnch -
458  aObjSize.Width();
459  }
460  // #i32964# - correction
461  if ( nTopOfAnch - nAdjustedRelPosY > aPgAlignArea.Right() )
462  {
463  nAdjustedRelPosY = nTopOfAnch - aPgAlignArea.Right();
464  }
465  }
466  else
467  {
468  // tdf#112443 if position is completely off-page
469  // return the proposed position and do not adjust it...
470  // tdf#120839 .. unless anchored to char (anchor can jump on other page)
472 
473  if ( bDisablePositioning && !IsAnchoredToChar() && nTopOfAnch + nAdjustedRelPosY > aPgAlignArea.Right() )
474  {
475  return nProposedRelPosY;
476  }
477 
478  if ( bCheckBottom &&
479  nTopOfAnch + nAdjustedRelPosY + aObjSize.Width() >
480  aPgAlignArea.Right() )
481  {
482  nAdjustedRelPosY = aPgAlignArea.Right() -
483  nTopOfAnch -
484  aObjSize.Width();
485  }
486  if ( nTopOfAnch + nAdjustedRelPosY < aPgAlignArea.Left() )
487  {
488  nAdjustedRelPosY = aPgAlignArea.Left() - nTopOfAnch;
489  }
490  }
491  }
492  else
493  {
494  // tdf#112443 if position is completely off-page
495  // return the proposed position and do not adjust it...
497 
498  // tdf#123002 disable the positioning in header and footer only
499  // we should limit this since anchors of body frames may appear on other pages
500  const bool bIsFooterOrHeader = GetAnchorFrame().GetUpper()
502 
503  if ( bDisablePositioning && bIsFooterOrHeader && nTopOfAnch + nAdjustedRelPosY > aPgAlignArea.Bottom() )
504  {
505  return nProposedRelPosY;
506  }
507 
508  // #i31805# - consider value of <bCheckBottom>
509  if ( bCheckBottom &&
510  nTopOfAnch + nAdjustedRelPosY + aObjSize.Height() >
511  aPgAlignArea.Top() + aPgAlignArea.Height() )
512  {
513  nAdjustedRelPosY = aPgAlignArea.Top() + aPgAlignArea.Height() -
514  nTopOfAnch -
515  aObjSize.Height();
516  }
517  if ( nTopOfAnch + nAdjustedRelPosY < aPgAlignArea.Top() )
518  {
519  nAdjustedRelPosY = aPgAlignArea.Top() - nTopOfAnch;
520  }
521 
522  // tdf#91260 - allow textboxes extending beyond the page bottom
523  // tdf#101627 - the patch a4dee94afed9ade6ac50237c8d99a6e49d3bebc1
524  // for tdf#91260 causes problems if the textbox
525  // is anchored in the footer, so exclude this case
526  if ( !( GetAnchorFrame().GetUpper() && GetAnchorFrame().GetUpper()->IsFooterFrame() )
527  && nAdjustedRelPosY < nProposedRelPosY )
528  {
529  const SwFrameFormat* pFormat = &(GetFrameFormat());
530  if ( GetObject().IsTextBox() )
531  {
532  // shrink textboxes to extend beyond the page bottom
533  SwFrameFormat* pFrameFormat = ::FindFrameFormat(&GetObject());
534  SwFormatFrameSize aSize(pFormat->GetFrameSize());
535  SwTwips nShrinked = aSize.GetHeight() - (nProposedRelPosY - nAdjustedRelPosY);
536  if (nShrinked >= 0) {
537  aSize.SetHeight( nShrinked );
538  pFrameFormat->SetFormatAttr(aSize);
539  }
540  nAdjustedRelPosY = nProposedRelPosY;
541  } else if ( SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT) )
542  // when the shape has a textbox, use only the proposed vertical position
543  nAdjustedRelPosY = nProposedRelPosY;
544  }
545  }
546  return nAdjustedRelPosY;
547 }
548 
555  const SwFrame& _rPageAlignLayFrame,
556  const SwTwips _nProposedRelPosX ) const
557 {
558  SwTwips nAdjustedRelPosX = _nProposedRelPosX;
559 
560  const SwFrame& rAnchorFrame = GetAnchorFrame();
561  const bool bVert = rAnchorFrame.IsVertical();
562 
563  const Size aObjSize( GetAnchoredObj().GetObjRect().SSize() );
564 
565  if( bVert )
566  {
567  if ( rAnchorFrame.getFrameArea().Top() + nAdjustedRelPosX + aObjSize.Height() >
568  _rPageAlignLayFrame.getFrameArea().Bottom() )
569  {
570  nAdjustedRelPosX = _rPageAlignLayFrame.getFrameArea().Bottom() -
571  rAnchorFrame.getFrameArea().Top() -
572  aObjSize.Height();
573  }
574  if ( rAnchorFrame.getFrameArea().Top() + nAdjustedRelPosX <
575  _rPageAlignLayFrame.getFrameArea().Top() )
576  {
577  nAdjustedRelPosX = _rPageAlignLayFrame.getFrameArea().Top() -
578  rAnchorFrame.getFrameArea().Top();
579  }
580  }
581  else
582  {
583  if ( rAnchorFrame.getFrameArea().Left() + nAdjustedRelPosX + aObjSize.Width() >
584  _rPageAlignLayFrame.getFrameArea().Right() )
585  {
586  nAdjustedRelPosX = _rPageAlignLayFrame.getFrameArea().Right() -
587  rAnchorFrame.getFrameArea().Left() -
588  aObjSize.Width();
589  }
590  if ( rAnchorFrame.getFrameArea().Left() + nAdjustedRelPosX <
591  _rPageAlignLayFrame.getFrameArea().Left() )
592  {
593  nAdjustedRelPosX = _rPageAlignLayFrame.getFrameArea().Left() -
594  rAnchorFrame.getFrameArea().Left();
595  }
596  }
597 
598  return nAdjustedRelPosX;
599 }
600 
603  const SwFrame& _rPageAlignLayFrame,
604  const sal_Int16 _eRelOrient,
605  const bool _bObjWrapThrough,
606  SwTwips& _orAlignAreaWidth,
607  SwTwips& _orAlignAreaOffset,
608  bool& _obAlignedRelToPage ) const
609 {
610  SwTwips nWidth = 0;
611  SwTwips nOffset = 0;
612  SwRectFnSet aRectFnSet(&_rHoriOrientFrame);
613  switch ( _eRelOrient )
614  {
615  case text::RelOrientation::PRINT_AREA:
616  {
617  nWidth = aRectFnSet.GetWidth(_rHoriOrientFrame.getFramePrintArea());
618  nOffset = aRectFnSet.GetLeftMargin(_rHoriOrientFrame);
619  if ( _rHoriOrientFrame.IsTextFrame() )
620  {
621  // consider movement of text frame left
622  nOffset += static_cast<const SwTextFrame&>(_rHoriOrientFrame).GetBaseOffsetForFly( !_bObjWrapThrough );
623  }
624  else if ( _rHoriOrientFrame.IsPageFrame() && aRectFnSet.IsVert() )
625  {
626  // for to-page anchored objects, consider header/footer frame
627  // in vertical layout
628  const SwFrame* pPrtFrame =
629  static_cast<const SwPageFrame&>(_rHoriOrientFrame).Lower();
630  while( pPrtFrame )
631  {
632  if( pPrtFrame->IsHeaderFrame() )
633  {
634  nWidth -= pPrtFrame->getFrameArea().Height();
635  nOffset += pPrtFrame->getFrameArea().Height();
636  }
637  else if( pPrtFrame->IsFooterFrame() )
638  {
639  nWidth -= pPrtFrame->getFrameArea().Height();
640  }
641  pPrtFrame = pPrtFrame->GetNext();
642  }
643  }
644  break;
645  }
646  case text::RelOrientation::PAGE_LEFT:
647  {
648  // align at left border of page frame/fly frame/cell frame
649  nWidth = aRectFnSet.GetLeftMargin(_rPageAlignLayFrame);
650  nOffset = aRectFnSet.XDiff(
651  aRectFnSet.GetLeft(_rPageAlignLayFrame.getFrameArea()),
652  aRectFnSet.GetLeft(_rHoriOrientFrame.getFrameArea()) );
653  _obAlignedRelToPage = true;
654  }
655  break;
656  case text::RelOrientation::PAGE_RIGHT:
657  {
658  // align at right border of page frame/fly frame/cell frame
659  nWidth = aRectFnSet.GetRightMargin(_rPageAlignLayFrame);
660  nOffset = aRectFnSet.XDiff(
661  aRectFnSet.GetPrtRight(_rPageAlignLayFrame),
662  aRectFnSet.GetLeft(_rHoriOrientFrame.getFrameArea()) );
663  _obAlignedRelToPage = true;
664  }
665  break;
666  case text::RelOrientation::FRAME_LEFT:
667  {
668  // align at left border of anchor frame
669  nWidth = aRectFnSet.GetLeftMargin(_rHoriOrientFrame);
670  nOffset = 0;
671  }
672  break;
673  case text::RelOrientation::FRAME_RIGHT:
674  {
675  // align at right border of anchor frame
676  // Unify and simplify
677  nWidth = aRectFnSet.GetRightMargin(_rHoriOrientFrame);
678  nOffset = aRectFnSet.GetRight(_rHoriOrientFrame.getFramePrintArea());
679  }
680  break;
681  case text::RelOrientation::CHAR:
682  {
683  // alignment relative to character - assure, that corresponding
684  // character rectangle is set.
685  if ( IsAnchoredToChar() )
686  {
687  nWidth = 0;
688  nOffset = aRectFnSet.XDiff(
689  aRectFnSet.GetLeft(*ToCharRect()),
690  aRectFnSet.GetLeft(ToCharOrientFrame()->getFrameArea()) );
691  break;
692  }
693  [[fallthrough]];
694  }
695  case text::RelOrientation::PAGE_PRINT_AREA:
696  {
697  nWidth = aRectFnSet.GetWidth(_rPageAlignLayFrame.getFramePrintArea());
698  nOffset = aRectFnSet.XDiff(
699  aRectFnSet.GetPrtLeft(_rPageAlignLayFrame),
700  aRectFnSet.GetLeft(_rHoriOrientFrame.getFrameArea()) );
701  if ( _rHoriOrientFrame.IsPageFrame() && aRectFnSet.IsVert() )
702  {
703  // for to-page anchored objects, consider header/footer frame
704  // in vertical layout
705  const SwFrame* pPrtFrame =
706  static_cast<const SwPageFrame&>(_rHoriOrientFrame).Lower();
707  while( pPrtFrame )
708  {
709  if( pPrtFrame->IsHeaderFrame() )
710  {
711  nWidth -= pPrtFrame->getFrameArea().Height();
712  nOffset += pPrtFrame->getFrameArea().Height();
713  }
714  else if( pPrtFrame->IsFooterFrame() )
715  {
716  nWidth -= pPrtFrame->getFrameArea().Height();
717  }
718  pPrtFrame = pPrtFrame->GetNext();
719  }
720  }
721  _obAlignedRelToPage = true;
722  break;
723  }
724  case text::RelOrientation::PAGE_FRAME:
725  {
726  nWidth = aRectFnSet.GetWidth(_rPageAlignLayFrame.getFrameArea());
727  nOffset = aRectFnSet.XDiff(
728  aRectFnSet.GetLeft(_rPageAlignLayFrame.getFrameArea()),
729  aRectFnSet.GetLeft(_rHoriOrientFrame.getFrameArea()) );
730  _obAlignedRelToPage = true;
731  break;
732  }
733  default:
734  {
735  nWidth = aRectFnSet.GetWidth(_rHoriOrientFrame.getFrameArea());
736 
737  bool bWrapThrough = _bObjWrapThrough;
738  // If the frame format is a TextBox of a draw shape, then use the
739  // surround of the original shape.
741 
742  bool bIgnoreFlysAnchoredAtFrame = !bWrapThrough;
743  nOffset = _rHoriOrientFrame.IsTextFrame() ?
744  static_cast<const SwTextFrame&>(_rHoriOrientFrame).GetBaseOffsetForFly( bIgnoreFlysAnchoredAtFrame ) :
745  0;
746  break;
747  }
748  }
749 
750  _orAlignAreaWidth = nWidth;
751  _orAlignAreaOffset = nOffset;
752 }
753 
756  const bool _bToggleLeftRight,
757  sal_Int16& _ioeHoriOrient,
758  sal_Int16& _iopeRelOrient
759  )
760 {
761  if( !_bToggleLeftRight )
762  return;
763 
764  // toggle orientation
765  switch ( _ioeHoriOrient )
766  {
767  case text::HoriOrientation::RIGHT :
768  {
769  _ioeHoriOrient = text::HoriOrientation::LEFT;
770  }
771  break;
772  case text::HoriOrientation::LEFT :
773  {
774  _ioeHoriOrient = text::HoriOrientation::RIGHT;
775  }
776  break;
777  default:
778  break;
779  }
780 
781  // toggle relative alignment
782  switch ( _iopeRelOrient )
783  {
784  case text::RelOrientation::PAGE_RIGHT :
785  {
786  _iopeRelOrient = text::RelOrientation::PAGE_LEFT;
787  }
788  break;
789  case text::RelOrientation::PAGE_LEFT :
790  {
791  _iopeRelOrient = text::RelOrientation::PAGE_RIGHT;
792  }
793  break;
794  case text::RelOrientation::FRAME_RIGHT :
795  {
796  _iopeRelOrient = text::RelOrientation::FRAME_LEFT;
797  }
798  break;
799  case text::RelOrientation::FRAME_LEFT :
800  {
801  _iopeRelOrient = text::RelOrientation::FRAME_RIGHT;
802  }
803  break;
804  default:
805  break;
806  }
807 }
808 
811  const SwFrame& _rHoriOrientFrame,
812  const SwEnvironmentOfAnchoredObject& _rEnvOfObj,
813  const SwFormatHoriOrient& _rHoriOrient,
814  const SvxLRSpaceItem& _rLRSpacing,
815  const SvxULSpaceItem& _rULSpacing,
816  const bool _bObjWrapThrough,
817  const SwTwips _nRelPosY,
818  SwTwips& _roHoriOffsetToFrameAnchorPos
819  ) const
820 {
821  // determine 'page' alignment layout frame
822  const SwFrame& rPageAlignLayFrame =
823  _rEnvOfObj.GetHoriEnvironmentLayoutFrame( _rHoriOrientFrame );
824 
825  const bool bEvenPage = !rPageAlignLayFrame.OnRightPage();
826  const bool bToggle = _rHoriOrient.IsPosToggle() && bEvenPage;
827 
828  // determine orientation and relative alignment
829  sal_Int16 eHoriOrient = _rHoriOrient.GetHoriOrient();
830  sal_Int16 eRelOrient = _rHoriOrient.GetRelationOrient();
831  // toggle orientation and relative alignment
832  ToggleHoriOrientAndAlign( bToggle, eHoriOrient, eRelOrient );
833 
834  // determine alignment parameter
835  // <nWidth>: 'width' of alignment area
836  // <nOffset>: offset of alignment area, relative to 'left' of anchor frame
837  SwTwips nWidth = 0;
838  SwTwips nOffset = 0;
839  bool bAlignedRelToPage = false;
840  GetHoriAlignmentValues( _rHoriOrientFrame, rPageAlignLayFrame,
841  eRelOrient, _bObjWrapThrough,
842  nWidth, nOffset, bAlignedRelToPage );
843 
844  const SwFrame& rAnchorFrame = GetAnchorFrame();
845  SwRectFnSet aRectFnSet(&_rHoriOrientFrame);
846  SwTwips nObjWidth = aRectFnSet.GetWidth(GetAnchoredObj().GetObjRect());
847  SwTwips nRelPosX = nOffset;
848  if ( _rHoriOrient.GetHoriOrient() == text::HoriOrientation::NONE )
849  {
850  // 'manual' horizontal position
851  const bool bR2L = rAnchorFrame.IsRightToLeft();
852  if( IsAnchoredToChar() && text::RelOrientation::CHAR == eRelOrient )
853  {
854  if( bR2L )
855  nRelPosX -= _rHoriOrient.GetPos();
856  else
857  nRelPosX += _rHoriOrient.GetPos();
858  }
859  else if ( bToggle || ( !_rHoriOrient.IsPosToggle() && bR2L ) )
860  {
861  // Correction: consider <nOffset> also for
862  // toggling from left to right.
863  nRelPosX += nWidth - nObjWidth - _rHoriOrient.GetPos();
864  }
865  else
866  {
867  nRelPosX += _rHoriOrient.GetPos();
868  }
869  }
870  else if ( text::HoriOrientation::CENTER == eHoriOrient )
871  nRelPosX += (nWidth / 2) - (nObjWidth / 2);
872  else if ( text::HoriOrientation::RIGHT == eHoriOrient )
873  nRelPosX += nWidth -
874  ( nObjWidth +
875  ( aRectFnSet.IsVert() ? _rULSpacing.GetLower() : _rLRSpacing.GetRight() ) );
876  else
877  nRelPosX += aRectFnSet.IsVert() ? _rULSpacing.GetUpper() : _rLRSpacing.GetLeft();
878 
879  // adjust relative position by distance between anchor frame and
880  // the frame, the object is oriented at.
881  if ( &rAnchorFrame != &_rHoriOrientFrame )
882  {
883  SwTwips nLeftOrient = aRectFnSet.GetLeft(_rHoriOrientFrame.getFrameArea());
884  SwTwips nLeftAnchor = aRectFnSet.GetLeft(rAnchorFrame.getFrameArea());
885  nRelPosX += aRectFnSet.XDiff( nLeftOrient, nLeftAnchor );
886  }
887 
888  // adjust calculated relative horizontal position, in order to
889  // keep object inside 'page' alignment layout frame
890  const SwFrame& rEnvironmentLayFrame =
891  _rEnvOfObj.GetHoriEnvironmentLayoutFrame( _rHoriOrientFrame );
892  bool bFollowTextFlow = GetFrameFormat().GetFollowTextFlow().GetValue();
893  bool bWrapThrough = GetFrameFormat().GetSurround().GetSurround() != text::WrapTextMode_THROUGH;
894  // Don't try to keep wrap-though objects inside the cell, even if they are following text flow.
895  if (!rEnvironmentLayFrame.IsInTab() || !bFollowTextFlow || bWrapThrough)
896  {
897  nRelPosX = AdjustHoriRelPos( rEnvironmentLayFrame, nRelPosX );
898  }
899 
900  // if object is a Writer fly frame and it's anchored to a content and
901  // it is horizontal positioned left or right, but not relative to character,
902  // it has to be drawn aside another object, which have the same horizontal
903  // position and lay below it.
904  if ( dynamic_cast<const SwFlyFrame*>( &GetAnchoredObj() ) != nullptr &&
906  ( eHoriOrient == text::HoriOrientation::LEFT || eHoriOrient == text::HoriOrientation::RIGHT ) &&
907  eRelOrient != text::RelOrientation::CHAR )
908  {
909  nRelPosX = AdjustHoriRelPosForDrawAside( _rHoriOrientFrame,
910  nRelPosX, _nRelPosY,
911  eHoriOrient, eRelOrient,
912  _rLRSpacing, _rULSpacing,
913  bEvenPage );
914  }
915 
916  // #i26791#
917  _roHoriOffsetToFrameAnchorPos = nOffset;
918 
919  return nRelPosX;
920 }
921 
922 // method incl. helper methods for adjusting proposed horizontal position,
923 // if object has to draw aside another object.
928  const SwFrame& _rHoriOrientFrame,
929  const SwTwips _nProposedRelPosX,
930  const SwTwips _nRelPosY,
931  const sal_Int16 _eHoriOrient,
932  const sal_Int16 _eRelOrient,
933  const SvxLRSpaceItem& _rLRSpacing,
934  const SvxULSpaceItem& _rULSpacing,
935  const bool _bEvenPage
936  ) const
937 {
938  // #i26791#
939  if ( dynamic_cast<const SwTextFrame*>( &GetAnchorFrame() ) == nullptr ||
940  dynamic_cast<const SwFlyAtContentFrame*>( &GetAnchoredObj() ) == nullptr )
941  {
942  OSL_FAIL( "<SwAnchoredObjectPosition::AdjustHoriRelPosForDrawAside(..) - usage for wrong anchor type" );
943  return _nProposedRelPosX;
944  }
945 
946  const SwTextFrame& rAnchorTextFrame = static_cast<const SwTextFrame&>(GetAnchorFrame());
947  // #i26791#
948  const SwFlyAtContentFrame& rFlyAtContentFrame =
949  static_cast<const SwFlyAtContentFrame&>(GetAnchoredObj());
950  const SwRect aObjBoundRect( GetAnchoredObj().GetObjRect() );
951  SwRectFnSet aRectFnSet(&_rHoriOrientFrame);
952 
953  SwTwips nAdjustedRelPosX = _nProposedRelPosX;
954 
955  // determine proposed object bound rectangle
956  Point aTmpPos = aRectFnSet.GetPos(rAnchorTextFrame.getFrameArea());
957  if( aRectFnSet.IsVert() )
958  {
959  aTmpPos.AdjustX( -(_nRelPosY + aObjBoundRect.Width()) );
960  aTmpPos.AdjustY(nAdjustedRelPosX );
961  }
962  else
963  {
964  aTmpPos.AdjustX(nAdjustedRelPosX );
965  aTmpPos.AdjustY(_nRelPosY );
966  }
967  SwRect aTmpObjRect( aTmpPos, aObjBoundRect.SSize() );
968 
969  const sal_uInt32 nObjOrdNum = GetObject().GetOrdNum();
970  const SwPageFrame* pObjPage = rFlyAtContentFrame.FindPageFrame();
971  const SwFrame* pObjContext = ::FindContext( &rAnchorTextFrame, SwFrameType::Column );
972  sal_uLong nObjIndex = rAnchorTextFrame.GetTextNodeFirst()->GetIndex();
973  SwOrderIter aIter( pObjPage );
974  const SwFlyFrame* pFly = static_cast<const SwVirtFlyDrawObj*>(aIter.Bottom())->GetFlyFrame();
975  while ( pFly && nObjOrdNum > pFly->GetVirtDrawObj()->GetOrdNumDirect() )
976  {
977  if ( DrawAsideFly( pFly, aTmpObjRect, pObjContext, nObjIndex,
978  _bEvenPage, _eHoriOrient, _eRelOrient ) )
979  {
980  if( aRectFnSet.IsVert() )
981  {
982  const SvxULSpaceItem& rOtherUL = pFly->GetFormat()->GetULSpace();
983  const SwTwips nOtherTop = pFly->getFrameArea().Top() - rOtherUL.GetUpper();
984  const SwTwips nOtherBot = pFly->getFrameArea().Bottom() + rOtherUL.GetLower();
985  if ( nOtherTop <= aTmpObjRect.Bottom() + _rULSpacing.GetLower() &&
986  nOtherBot >= aTmpObjRect.Top() - _rULSpacing.GetUpper() )
987  {
988  if ( _eHoriOrient == text::HoriOrientation::LEFT )
989  {
990  SwTwips nTmp = nOtherBot + 1 + _rULSpacing.GetUpper() -
991  rAnchorTextFrame.getFrameArea().Top();
992  if ( nTmp > nAdjustedRelPosX &&
993  rAnchorTextFrame.getFrameArea().Top() + nTmp +
994  aObjBoundRect.Height() + _rULSpacing.GetLower()
995  <= pObjPage->getFrameArea().Height() + pObjPage->getFrameArea().Top() )
996  {
997  nAdjustedRelPosX = nTmp;
998  }
999  }
1000  else if ( _eHoriOrient == text::HoriOrientation::RIGHT )
1001  {
1002  SwTwips nTmp = nOtherTop - 1 - _rULSpacing.GetLower() -
1003  aObjBoundRect.Height() -
1004  rAnchorTextFrame.getFrameArea().Top();
1005  if ( nTmp < nAdjustedRelPosX &&
1006  rAnchorTextFrame.getFrameArea().Top() + nTmp - _rULSpacing.GetUpper()
1007  >= pObjPage->getFrameArea().Top() )
1008  {
1009  nAdjustedRelPosX = nTmp;
1010  }
1011  }
1012  aTmpObjRect.Pos().setY( rAnchorTextFrame.getFrameArea().Top() +
1013  nAdjustedRelPosX );
1014  }
1015  }
1016  else
1017  {
1018  const SvxLRSpaceItem& rOtherLR = pFly->GetFormat()->GetLRSpace();
1019  const SwTwips nOtherLeft = pFly->getFrameArea().Left() - rOtherLR.GetLeft();
1020  const SwTwips nOtherRight = pFly->getFrameArea().Right() + rOtherLR.GetRight();
1021  if( nOtherLeft <= aTmpObjRect.Right() + _rLRSpacing.GetRight() &&
1022  nOtherRight >= aTmpObjRect.Left() - _rLRSpacing.GetLeft() )
1023  {
1024  if ( _eHoriOrient == text::HoriOrientation::LEFT )
1025  {
1026  SwTwips nTmp = nOtherRight + 1 + _rLRSpacing.GetLeft() -
1027  rAnchorTextFrame.getFrameArea().Left();
1028  if ( nTmp > nAdjustedRelPosX &&
1029  rAnchorTextFrame.getFrameArea().Left() + nTmp +
1030  aObjBoundRect.Width() + _rLRSpacing.GetRight()
1031  <= pObjPage->getFrameArea().Width() + pObjPage->getFrameArea().Left() )
1032  {
1033  nAdjustedRelPosX = nTmp;
1034  }
1035  }
1036  else if ( _eHoriOrient == text::HoriOrientation::RIGHT )
1037  {
1038  SwTwips nTmp = nOtherLeft - 1 - _rLRSpacing.GetRight() -
1039  aObjBoundRect.Width() -
1040  rAnchorTextFrame.getFrameArea().Left();
1041  if ( nTmp < nAdjustedRelPosX &&
1042  rAnchorTextFrame.getFrameArea().Left() + nTmp - _rLRSpacing.GetLeft()
1043  >= pObjPage->getFrameArea().Left() )
1044  {
1045  nAdjustedRelPosX = nTmp;
1046  }
1047  }
1048  aTmpObjRect.Pos().setX( rAnchorTextFrame.getFrameArea().Left() +
1049  nAdjustedRelPosX );
1050  }
1051  } // end of <if (bVert)>
1052  } // end of <if DrawAsideFly(..)>
1053 
1054  pFly = static_cast<const SwVirtFlyDrawObj*>(aIter.Next())->GetFlyFrame();
1055  } // end of <loop on fly frames
1056 
1057  return nAdjustedRelPosX;
1058 }
1059 
1065  const SwRect& _rObjRect,
1066  const SwFrame* _pObjContext,
1067  const sal_uLong _nObjIndex,
1068  const bool _bEvenPage,
1069  const sal_Int16 _eHoriOrient,
1070  const sal_Int16 _eRelOrient
1071  ) const
1072 {
1073  bool bRetVal = false;
1074 
1075  SwRectFnSet aRectFnSet(&GetAnchorFrame());
1076 
1077  if ( _pFly->IsFlyAtContentFrame() &&
1078  aRectFnSet.BottomDist( _pFly->getFrameArea(), aRectFnSet.GetTop(_rObjRect) ) < 0 &&
1079  aRectFnSet.BottomDist( _rObjRect, aRectFnSet.GetTop(_pFly->getFrameArea()) ) < 0 &&
1080  ::FindContext( _pFly->GetAnchorFrame(), SwFrameType::Column ) == _pObjContext )
1081  {
1082  sal_uLong nOtherIndex =
1083  static_cast<const SwTextFrame*>(_pFly->GetAnchorFrame())->GetTextNodeFirst()->GetIndex();
1084  if (sw::FrameContainsNode(static_cast<SwTextFrame const&>(*_pFly->GetAnchorFrame()), _nObjIndex)
1085  || nOtherIndex < _nObjIndex)
1086  {
1087  const SwFormatHoriOrient& rHori = _pFly->GetFormat()->GetHoriOrient();
1088  sal_Int16 eOtherRelOrient = rHori.GetRelationOrient();
1089  if( text::RelOrientation::CHAR != eOtherRelOrient )
1090  {
1091  sal_Int16 eOtherHoriOrient = rHori.GetHoriOrient();
1092  ToggleHoriOrientAndAlign( _bEvenPage && rHori.IsPosToggle(),
1093  eOtherHoriOrient,
1094  eOtherRelOrient );
1095  if ( eOtherHoriOrient == _eHoriOrient &&
1096  Minor_( _eRelOrient, eOtherRelOrient, text::HoriOrientation::LEFT == _eHoriOrient ) )
1097  {
1098  bRetVal = true;
1099  }
1100  }
1101  }
1102  }
1103 
1104  return bRetVal;
1105 }
1106 
1116 bool SwAnchoredObjectPosition::Minor_( sal_Int16 _eRelOrient1,
1117  sal_Int16 _eRelOrient2,
1118  bool _bLeft )
1119 {
1120  bool bRetVal;
1121 
1122  // draw aside order for left horizontal position
1124  static sal_uInt16 const aLeft[ 10 ] =
1125  { 5, 6, 0, 1, 8, 4, 7, 2, 3, 9 };
1126  // draw aside order for right horizontal position
1128  static sal_uInt16 const aRight[ 10 ] =
1129  { 5, 6, 0, 8, 1, 7, 4, 2, 3, 9 };
1130 
1131  // decide depending on given order, which frame has to draw aside another frame
1132  if( _bLeft )
1133  bRetVal = aLeft[ _eRelOrient1 ] >= aLeft[ _eRelOrient2 ];
1134  else
1135  bRetVal = aRight[ _eRelOrient1 ] >= aRight[ _eRelOrient2 ];
1136 
1137  return bRetVal;
1138 }
1139 
1140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetLeft() const
bool GetValue() const
long Width() const
SwTwips ImplAdjustHoriRelPos(const SwFrame &_rPageAlignLayFrame, const SwTwips _nProposedRelPosX) const
adjust calculated horizontal in order to keep object inside 'page' alignment layout frame...
const SwVirtFlyDrawObj * GetVirtDrawObj() const
Definition: fly.cxx:2718
Base class of the Writer layout elements.
Definition: frame.hxx:297
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:151
void GetInfoAboutObj()
determine information about object
long BottomDist(const SwRect &rRect, long nPos) const
Definition: frame.hxx:1392
const SdrObject * Next()
Definition: frmtool.cxx:2607
SwTwips GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const
Definition: txtfrm.cxx:4005
sal_uLong GetIndex() const
Definition: node.hxx:282
Point GetPos(const SwRect &rRect) const
Definition: frame.hxx:1361
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2807
const SwFrame * FindContext(const SwFrame *pFrame, SwFrameType nAdditionalContextTyp)
provides the area of a frame in that no Fly from another area can overlap
Definition: frmtool.cxx:3497
sal_uInt16 GetLower() const
long Height() const
SwTwips AdjustHoriRelPosForDrawAside(const SwFrame &_rHoriOrientFrame, const SwTwips _nProposedRelPosX, const SwTwips _nRelPosY, const sal_Int16 _eHoriOrient, const sal_Int16 _eRelOrient, const SvxLRSpaceItem &_rLRSpacing, const SvxULSpaceItem &_rULSpacing, const bool _bEvenPage) const
adjust calculated horizontal position in order to draw object aside other objects with same positioni...
SwRectFn FnRect() const
Definition: frame.hxx:1347
SwTwips GetPos() const
Definition: fmtornt.hxx:92
sal_uIntPtr sal_uLong
const SwRect & getFramePrintArea() const
Definition: frame.hxx:178
virtual bool IsTextBox() const
void Height(long nNew)
Definition: swrect.hxx:191
long SwTwips
Definition: swtypes.hxx:49
bool IsVert() const
Definition: frame.hxx:1345
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:171
static void ToggleHoriOrientAndAlign(const bool _bToggleLeftRight, sal_Int16 &_ioeHoriOrient, sal_Int16 &_iopeRelOrient)
toggle given horizontal orientation and relative alignment
bool IsFlyAtContentFrame() const
Definition: flyfrm.hxx:196
long YDiff(long n1, long n2) const
Definition: frame.hxx:1401
long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1388
void Top(const long nTop)
Definition: swrect.hxx:204
SwTwips ImplAdjustVertRelPos(const SwTwips nTopOfAnch, const bool bVert, const bool bVertL2R, const SwFrame &rPageAlignLayFrame, const SwTwips nProposedRelPosY, const bool bFollowTextFlow, const bool bCheckBottom) const
adjust calculated vertical in order to keep object inside 'page' alignment layout frame...
const SwRect & getFrameArea() const
Definition: frame.hxx:177
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
bool IsInTab() const
Definition: frame.hxx:933
const SwLayoutFrame & GetHoriEnvironmentLayoutFrame(const SwFrame &_rHoriOrientFrame) const
determine environment layout frame for possible horizontal object positions respectively for alignmen...
long GetBottomMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1382
bool DrawAsideFly(const SwFlyFrame *_pFly, const SwRect &_rObjRect, const SwFrame *_pObjContext, const sal_uLong _nObjIndex, const bool _bEvenPage, const sal_Int16 _eHoriOrient, const sal_Int16 _eRelOrient) const
determine, if object has to draw aside given fly frame
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
bool IsTextFrame() const
Definition: frame.hxx:1212
bool OnRightPage() const
Definition: frame.hxx:713
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
long GetLeftMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1383
long GetLeft(const SwRect &rRect) const
Definition: frame.hxx:1357
long GetRight(const SwRect &rRect) const
Definition: frame.hxx:1358
SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The Get reverse way: seeks the format to the specified object.
Definition: dcontact.cxx:120
void Right(const long nRight)
Definition: swrect.hxx:200
SwTwips GetVertRelPos(const SwFrame &_rVertOrientFrame, const SwFrame &_rPageAlignLayFrame, const sal_Int16 _eVertOrient, const sal_Int16 _eRelOrient, const SwTwips _nVertPos, const SvxLRSpaceItem &_rLRSpacing, const SvxULSpaceItem &_rULSpacing, SwTwips &_roVertOffsetToFrameAnchorPos) const
SwFrame * AnchorFrame()
sal_uInt32 GetOrdNumDirect() const
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:448
bool FrameContainsNode(SwContentFrame const &rFrame, sal_uLong nNodeIndex)
Definition: txtfrm.cxx:284
const SwFormatFollowTextFlow & GetFollowTextFlow(bool=true) const
Style of a layout element.
Definition: frmfmt.hxx:57
static bool Minor_(sal_Int16 _eRelOrient1, sal_Int16 _eRelOrient2, bool _bLeft)
determine, if object has to draw aside another object
long XDiff(long n1, long n2) const
Definition: frame.hxx:1400
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
SwPageFrame * FindPageFrame()
Definition: frame.hxx:660
SwTwips CalcRelPosX(const SwFrame &_rHoriOrientFrame, const SwEnvironmentOfAnchoredObject &_rEnvOfObj, const SwFormatHoriOrient &_rHoriOrient, const SvxLRSpaceItem &_rLRSpacing, const SvxULSpaceItem &_rULSpacing, const bool _bObjWrapThrough, const SwTwips _nRelPosY, SwTwips &_roHoriOffsetToFrameAnchorPos) const
calculate relative horizontal position
const SwFrame * mpAnchorFrame
SwLayoutFrame * GetUpper()
Definition: frame.hxx:658
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
long GetTopMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1381
SwTwips GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() const
method to determine the upper space amount, which is considered for the previous frame and the page g...
Definition: flowfrm.cxx:1668
sal_uInt32 GetOrdNum() const
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
void GetHoriAlignmentValues(const SwFrame &_rHoriOrientFrame, const SwFrame &_rPageAlignLayFrame, const sal_Int16 _eRelOrient, const bool _bObjWrapThrough, SwTwips &_orAlignAreaWidth, SwTwips &_orAlignAreaOffset, bool &_obAlignedRelToPage) const
determine alignment values for horizontal position of object
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:757
void SSize(const Size &rNew)
Definition: swrect.hxx:178
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
A page of the document layout.
Definition: pagefrm.hxx:41
long GetPrtRight(const SwFrame &rFrame) const
Definition: frame.hxx:1390
virtual const SwFrame * ToCharOrientFrame() const
long GetPrtLeft(const SwFrame &rFrame) const
Definition: frame.hxx:1389
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
long GetWidth(const SwRect &rRect) const
Definition: frame.hxx:1359
void Left(const long nLeft)
Definition: swrect.hxx:195
void Bottom(const long nBottom)
Definition: swrect.hxx:209
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:76
bool IsPosToggle() const
Definition: fmtornt.hxx:95
SwTwips AdjustHoriRelPos(const SwFrame &_rPageAlignLayFrame, const SwTwips _nProposedRelPosX) const
adjust calculated horizontal in order to keep object inside 'page' alignment layout frame for object ...
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
virtual SwFrameFormat & GetFrameFormat()=0
void Width(long nNew)
Definition: swrect.hxx:187
bool IsRightToLeft() const
Definition: frame.hxx:965
bool IsVertL2R() const
Definition: frame.hxx:1346
bool IsPageFrame() const
Definition: frame.hxx:1156
void GetVertAlignmentValues(const SwFrame &_rVertOrientFrame, const SwFrame &_rPageAlignLayFrame, const sal_Int16 _eRelOrient, SwTwips &_orAlignAreaHeight, SwTwips &_orAlignAreaOffset) const
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1360
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(154)
long GetRight() const
SwTwips GetTopForObjPos(const SwFrame &_rFrame, const SwRectFn &_fnRect, const bool _bVert) const
helper method to determine top of a frame for the vertical object positioning
bool IsVertical() const
Definition: frame.hxx:951
long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1355
const SwFrame * GetAnchorFrame() const
long GetRightMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1384
long GetHeight() const
bool ObjAnchoredAtPara() const
Definition: dcontact.hxx:148
bool IsFooterFrame() const
Definition: frame.hxx:1172
bool ObjAnchoredAtChar() const
Definition: dcontact.hxx:149
const SdrObject * Bottom()
Definition: frmtool.cxx:2580
sal_uInt16 GetUpper() const
bool IsHeaderFrame() const
Definition: frame.hxx:1168
SwRectGet fnGetTop
Definition: frame.hxx:1269
static void getShapeWrapThrough(const SwFrameFormat *pTextBox, bool &rWrapThrough)
If pTextBox is a textbox, then set rWrapThrough to the surround of its shape.
SwFrame * GetNext()
Definition: frame.hxx:656
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74