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 <fmtfollowtextflow.hxx>
34 #include <editeng/lrspitem.hxx>
35 #include <editeng/ulspitem.hxx>
36 #include <ndtxt.hxx>
38 #include <textboxhelper.hxx>
39 #include <fmtsrnd.hxx>
40 #include <osl/diagnose.h>
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#
92  assert(mpAnchoredObj &&
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#
108  assert(mpFrameFormat &&
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  case text::RelOrientation::PAGE_PRINT_AREA_TOP:
253  {
254  nHeight = aRectFnSet.GetHeight(_rPageAlignLayFrame.getFrameArea());
255  nOffset = aRectFnSet.YDiff(
256  aRectFnSet.GetTop(_rPageAlignLayFrame.getFrameArea()),
257  nVertOrientTop );
258  }
259  break;
260  case text::RelOrientation::PAGE_PRINT_AREA:
261  {
262  nHeight = aRectFnSet.GetHeight(_rPageAlignLayFrame.getFramePrintArea());
263  nOffset = aRectFnSet.GetTopMargin(_rPageAlignLayFrame) +
264  aRectFnSet.YDiff(
265  aRectFnSet.GetTop(_rPageAlignLayFrame.getFrameArea()),
266  nVertOrientTop );
267  // if aligned to page in horizontal layout, consider header and
268  // footer frame height appropriately.
269  if( _rPageAlignLayFrame.IsPageFrame() && !aRectFnSet.IsVert() )
270  {
271  const SwFrame* pPrtFrame =
272  static_cast<const SwPageFrame&>(_rPageAlignLayFrame).Lower();
273  while( pPrtFrame )
274  {
275  if( pPrtFrame->IsHeaderFrame() )
276  {
277  nHeight -= pPrtFrame->getFrameArea().Height();
278  nOffset += pPrtFrame->getFrameArea().Height();
279  }
280  else if( pPrtFrame->IsFooterFrame() )
281  {
282  nHeight -= pPrtFrame->getFrameArea().Height();
283  }
284  pPrtFrame = pPrtFrame->GetNext();
285  }
286  }
287  }
288  break;
289  case text::RelOrientation::PAGE_PRINT_AREA_BOTTOM:
290  {
291  nHeight = aRectFnSet.GetBottomMargin(_rPageAlignLayFrame);
292  nOffset = aRectFnSet.YDiff(
293  aRectFnSet.GetPrtBottom(_rPageAlignLayFrame),
294  nVertOrientTop);
295 
296  if (_rPageAlignLayFrame.IsPageFrame() && !aRectFnSet.IsVert())
297  {
298  const SwFrame* pPrtFrame =
299  static_cast<const SwPageFrame&>(_rPageAlignLayFrame).Lower();
300 
301  while (pPrtFrame)
302  {
303  if (pPrtFrame->IsFooterFrame())
304  {
305  nHeight += pPrtFrame->getFrameArea().Height();
306  nOffset -= pPrtFrame->getFrameArea().Height();
307  }
308  pPrtFrame = pPrtFrame->GetNext();
309  }
310  }
311 
312  }
313  break;
314  // #i22341# - vertical alignment at top of line
315  case text::RelOrientation::TEXT_LINE:
316  {
317  if ( IsAnchoredToChar() )
318  {
319  nHeight = 0;
320  nOffset = aRectFnSet.YDiff( ToCharTopOfLine(), nVertOrientTop );
321  }
322  else
323  {
324  OSL_FAIL( "<SwAnchoredObjectPosition::GetVertAlignmentValues(..)> - invalid relative alignment" );
325  }
326  }
327  break;
328  case text::RelOrientation::CHAR:
329  {
330  if ( IsAnchoredToChar() )
331  {
332  nHeight = aRectFnSet.GetHeight(*ToCharRect());
333  nOffset = aRectFnSet.YDiff( aRectFnSet.GetTop(*ToCharRect()),
334  nVertOrientTop );
335  }
336  else
337  {
338  OSL_FAIL( "<SwAnchoredObjectPosition::GetVertAlignmentValues(..)> - invalid relative alignment" );
339  }
340  }
341  break;
342  // no break here, because text::RelOrientation::CHAR is invalid, if !mbAnchorToChar
343  default:
344  {
345  OSL_FAIL( "<SwAnchoredObjectPosition::GetVertAlignmentValues(..)> - invalid relative alignment" );
346  }
347  }
348 
349  _orAlignAreaHeight = nHeight;
350  _orAlignAreaOffset = nOffset;
351 }
352 
353 // #i26791# - add output parameter <_roVertOffsetToFrameAnchorPos>
355  const SwFrame& _rVertOrientFrame,
356  const SwFrame& _rPageAlignLayFrame,
357  const sal_Int16 _eVertOrient,
358  const sal_Int16 _eRelOrient,
359  const SwTwips _nVertPos,
360  const SvxLRSpaceItem& _rLRSpacing,
361  const SvxULSpaceItem& _rULSpacing,
362  SwTwips& _roVertOffsetToFrameAnchorPos ) const
363 {
364  SwTwips nRelPosY = 0;
365  SwRectFnSet aRectFnSet(&_rVertOrientFrame);
366 
367  SwTwips nAlignAreaHeight;
368  SwTwips nAlignAreaOffset;
369  GetVertAlignmentValues( _rVertOrientFrame, _rPageAlignLayFrame,
370  _eRelOrient, nAlignAreaHeight, nAlignAreaOffset );
371 
372  nRelPosY = nAlignAreaOffset;
373  const SwRect aObjBoundRect( GetAnchoredObj().GetObjRect() );
374  const SwTwips nObjHeight = aRectFnSet.GetHeight(aObjBoundRect);
375 
376  switch ( _eVertOrient )
377  {
379  {
380  // 'manual' vertical position
381  nRelPosY += _nVertPos;
382  }
383  break;
384  case text::VertOrientation::TOP:
385  {
386  nRelPosY += aRectFnSet.IsVert()
387  ? ( aRectFnSet.IsVertL2R()
388  ? _rLRSpacing.GetLeft()
389  : _rLRSpacing.GetRight() )
390  : _rULSpacing.GetUpper();
391  }
392  break;
393  case text::VertOrientation::CENTER:
394  {
395  nRelPosY += (nAlignAreaHeight / 2) - (nObjHeight / 2);
396  }
397  break;
398  case text::VertOrientation::BOTTOM:
399  {
400  nRelPosY += nAlignAreaHeight -
401  ( nObjHeight + ( aRectFnSet.IsVert()
402  ? ( aRectFnSet.IsVertL2R()
403  ? _rLRSpacing.GetRight()
404  : _rLRSpacing.GetLeft() )
405  : _rULSpacing.GetLower() ) );
406  }
407  break;
408  default:
409  {
410  OSL_FAIL( "<SwAnchoredObjectPosition::GetVertRelPos(..) - invalid vertical positioning" );
411  }
412  }
413 
414  // #i26791#
415  _roVertOffsetToFrameAnchorPos = nAlignAreaOffset;
416 
417  return nRelPosY;
418 }
419 
430  const bool bVert,
431  const bool bVertL2R,
432  const SwFrame& rPageAlignLayFrame,
433  const SwTwips nProposedRelPosY,
434  const bool bFollowTextFlow,
435  const bool bCheckBottom ) const
436 {
437  SwTwips nAdjustedRelPosY = nProposedRelPosY;
438  // TODO: Replace the following condition with the correction
439  // of the implementation of option FollowTextFlow.
441  !(GetAnchorFrame().IsInTab() && DoesObjFollowsTextFlow()) )
442  {
443  return nAdjustedRelPosY;
444  }
445 
446  const Size aObjSize(GetAnchoredObj().GetObjRect().SSize());
447  // determine the area of 'page' alignment frame, to which the vertical
448  // position is restricted.
449  // #i28701# - Extend restricted area for the vertical
450  // position to area of the page frame, if wrapping style influence is
451  // considered on object positioning. Needed to avoid layout loops in the
452  // object positioning algorithm considering the wrapping style influence
453  // caused by objects, which follow the text flow and thus are restricted
454  // to its environment (e.g. page header/footer).
455  SwRect aPgAlignArea;
456  {
457  // #i26945# - no extension of restricted area, if
458  // object's attribute follow text flow is set and its inside a table
459  if ( GetFrameFormat().getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) &&
460  ( !bFollowTextFlow ||
461  !GetAnchoredObj().GetAnchorFrame()->IsInTab() ) )
462  {
463  aPgAlignArea = rPageAlignLayFrame.FindPageFrame()->getFrameArea();
464  }
465  else
466  {
467  aPgAlignArea = rPageAlignLayFrame.getFrameArea();
468  }
469  }
470 
471  if ( bVert )
472  {
473  // #i31805# - consider value of <_bCheckBottom>
474  if ( !bVertL2R )
475  {
476  if ( bCheckBottom &&
477  nTopOfAnch - nAdjustedRelPosY - aObjSize.Width() <
478  aPgAlignArea.Left() )
479  {
480  nAdjustedRelPosY = aPgAlignArea.Left() +
481  nTopOfAnch -
482  aObjSize.Width();
483  }
484  // #i32964# - correction
485  if ( nTopOfAnch - nAdjustedRelPosY > aPgAlignArea.Right() )
486  {
487  nAdjustedRelPosY = nTopOfAnch - aPgAlignArea.Right();
488  }
489  }
490  else
491  {
492  // tdf#112443 if position is completely off-page
493  // return the proposed position and do not adjust it...
494  // tdf#120839 .. unless anchored to char (anchor can jump on other page)
496  if ( bDisablePositioning && !IsAnchoredToChar() && nTopOfAnch + nAdjustedRelPosY > aPgAlignArea.Right() )
497  {
498  return nProposedRelPosY;
499  }
500 
501  if ( bCheckBottom &&
502  nTopOfAnch + nAdjustedRelPosY + aObjSize.Width() >
503  aPgAlignArea.Right() )
504  {
505  nAdjustedRelPosY = aPgAlignArea.Right() -
506  nTopOfAnch -
507  aObjSize.Width();
508  }
509  if ( nTopOfAnch + nAdjustedRelPosY < aPgAlignArea.Left() )
510  {
511  nAdjustedRelPosY = aPgAlignArea.Left() - nTopOfAnch;
512  }
513  }
514  }
515  else
516  {
517  // tdf#112443 if position is completely off-page
518  // return the proposed position and do not adjust it...
520 
521  // tdf#123002 disable the positioning in header and footer only
522  // we should limit this since anchors of body frames may appear on other pages
523  const bool bIsFooterOrHeader = GetAnchorFrame().GetUpper()
525 
526  if ( bDisablePositioning && bIsFooterOrHeader && nTopOfAnch + nAdjustedRelPosY > aPgAlignArea.Bottom() )
527  {
528  return nProposedRelPosY;
529  }
530 
531  // #i31805# - consider value of <bCheckBottom>
532  if ( bCheckBottom &&
533  nTopOfAnch + nAdjustedRelPosY + aObjSize.Height() >
534  aPgAlignArea.Top() + aPgAlignArea.Height() )
535  {
536  nAdjustedRelPosY = aPgAlignArea.Top() + aPgAlignArea.Height() -
537  nTopOfAnch -
538  aObjSize.Height();
539  }
540  if ( nTopOfAnch + nAdjustedRelPosY < aPgAlignArea.Top() )
541  {
542  nAdjustedRelPosY = aPgAlignArea.Top() - nTopOfAnch;
543  }
544  }
545  return nAdjustedRelPosY;
546 }
547 
554  const SwFrame& _rPageAlignLayFrame,
555  const SwTwips _nProposedRelPosX ) const
556 {
557  SwTwips nAdjustedRelPosX = _nProposedRelPosX;
558 
560  return nAdjustedRelPosX;
561 
562  const SwFrame& rAnchorFrame = GetAnchorFrame();
563  const bool bVert = rAnchorFrame.IsVertical();
564 
565  const Size aObjSize( GetAnchoredObj().GetObjRect().SSize() );
566 
567  if( bVert )
568  {
569  if ( rAnchorFrame.getFrameArea().Top() + nAdjustedRelPosX + aObjSize.Height() >
570  _rPageAlignLayFrame.getFrameArea().Bottom() )
571  {
572  nAdjustedRelPosX = _rPageAlignLayFrame.getFrameArea().Bottom() -
573  rAnchorFrame.getFrameArea().Top() -
574  aObjSize.Height();
575  }
576  if ( rAnchorFrame.getFrameArea().Top() + nAdjustedRelPosX <
577  _rPageAlignLayFrame.getFrameArea().Top() )
578  {
579  nAdjustedRelPosX = _rPageAlignLayFrame.getFrameArea().Top() -
580  rAnchorFrame.getFrameArea().Top();
581  }
582  }
583  else
584  {
585  if ( rAnchorFrame.getFrameArea().Left() + nAdjustedRelPosX + aObjSize.Width() >
586  _rPageAlignLayFrame.getFrameArea().Right() )
587  {
588  nAdjustedRelPosX = _rPageAlignLayFrame.getFrameArea().Right() -
589  rAnchorFrame.getFrameArea().Left() -
590  aObjSize.Width();
591  }
592  if ( rAnchorFrame.getFrameArea().Left() + nAdjustedRelPosX <
593  _rPageAlignLayFrame.getFrameArea().Left() )
594  {
595  nAdjustedRelPosX = _rPageAlignLayFrame.getFrameArea().Left() -
596  rAnchorFrame.getFrameArea().Left();
597  }
598  }
599 
600  return nAdjustedRelPosX;
601 }
602 
605  const SwFrame& _rPageAlignLayFrame,
606  const sal_Int16 _eRelOrient,
607  const bool _bObjWrapThrough,
608  SwTwips& _orAlignAreaWidth,
609  SwTwips& _orAlignAreaOffset,
610  bool& _obAlignedRelToPage ) const
611 {
612  SwTwips nWidth = 0;
613  SwTwips nOffset = 0;
614  SwRectFnSet aRectFnSet(&_rHoriOrientFrame);
615  switch ( _eRelOrient )
616  {
617  case text::RelOrientation::PRINT_AREA:
618  {
619  nWidth = aRectFnSet.GetWidth(_rHoriOrientFrame.getFramePrintArea());
620  nOffset = aRectFnSet.GetLeftMargin(_rHoriOrientFrame);
621  if ( _rHoriOrientFrame.IsTextFrame() )
622  {
623  // consider movement of text frame left
624  nOffset += static_cast<const SwTextFrame&>(_rHoriOrientFrame).GetBaseOffsetForFly( !_bObjWrapThrough );
625  }
626  else if ( _rHoriOrientFrame.IsPageFrame() && aRectFnSet.IsVert() )
627  {
628  // for to-page anchored objects, consider header/footer frame
629  // in vertical layout
630  const SwFrame* pPrtFrame =
631  static_cast<const SwPageFrame&>(_rHoriOrientFrame).Lower();
632  while( pPrtFrame )
633  {
634  if( pPrtFrame->IsHeaderFrame() )
635  {
636  nWidth -= pPrtFrame->getFrameArea().Height();
637  nOffset += pPrtFrame->getFrameArea().Height();
638  }
639  else if( pPrtFrame->IsFooterFrame() )
640  {
641  nWidth -= pPrtFrame->getFrameArea().Height();
642  }
643  pPrtFrame = pPrtFrame->GetNext();
644  }
645  }
646  break;
647  }
648  case text::RelOrientation::PAGE_LEFT:
649  {
650  // align at left border of page frame/fly frame/cell frame
651  nWidth = aRectFnSet.GetLeftMargin(_rPageAlignLayFrame);
652  nOffset = aRectFnSet.XDiff(
653  aRectFnSet.GetLeft(_rPageAlignLayFrame.getFrameArea()),
654  aRectFnSet.GetLeft(_rHoriOrientFrame.getFrameArea()) );
655  _obAlignedRelToPage = true;
656  }
657  break;
658  case text::RelOrientation::PAGE_RIGHT:
659  {
660  // align at right border of page frame/fly frame/cell frame
661  nWidth = aRectFnSet.GetRightMargin(_rPageAlignLayFrame);
662  nOffset = aRectFnSet.XDiff(
663  aRectFnSet.GetPrtRight(_rPageAlignLayFrame),
664  aRectFnSet.GetLeft(_rHoriOrientFrame.getFrameArea()) );
665  _obAlignedRelToPage = true;
666  }
667  break;
668  case text::RelOrientation::FRAME_LEFT:
669  {
670  // align at left border of anchor frame
671  nWidth = aRectFnSet.GetLeftMargin(_rHoriOrientFrame);
672  nOffset = 0;
673  }
674  break;
675  case text::RelOrientation::FRAME_RIGHT:
676  {
677  // align at right border of anchor frame
678  // Unify and simplify
679  nWidth = aRectFnSet.GetRightMargin(_rHoriOrientFrame);
680  nOffset = aRectFnSet.GetRight(_rHoriOrientFrame.getFramePrintArea());
681  }
682  break;
683  case text::RelOrientation::CHAR:
684  {
685  // alignment relative to character - assure, that corresponding
686  // character rectangle is set.
687  if ( IsAnchoredToChar() )
688  {
689  nWidth = 0;
690  nOffset = aRectFnSet.XDiff(
691  aRectFnSet.GetLeft(*ToCharRect()),
692  aRectFnSet.GetLeft(ToCharOrientFrame()->getFrameArea()) );
693  break;
694  }
695  [[fallthrough]];
696  }
697  case text::RelOrientation::PAGE_PRINT_AREA:
698  {
699  nWidth = aRectFnSet.GetWidth(_rPageAlignLayFrame.getFramePrintArea());
700  nOffset = aRectFnSet.XDiff(
701  aRectFnSet.GetPrtLeft(_rPageAlignLayFrame),
702  aRectFnSet.GetLeft(_rHoriOrientFrame.getFrameArea()) );
703  if ( _rHoriOrientFrame.IsPageFrame() && aRectFnSet.IsVert() )
704  {
705  // for to-page anchored objects, consider header/footer frame
706  // in vertical layout
707  const SwFrame* pPrtFrame =
708  static_cast<const SwPageFrame&>(_rHoriOrientFrame).Lower();
709  while( pPrtFrame )
710  {
711  if( pPrtFrame->IsHeaderFrame() )
712  {
713  nWidth -= pPrtFrame->getFrameArea().Height();
714  nOffset += pPrtFrame->getFrameArea().Height();
715  }
716  else if( pPrtFrame->IsFooterFrame() )
717  {
718  nWidth -= pPrtFrame->getFrameArea().Height();
719  }
720  pPrtFrame = pPrtFrame->GetNext();
721  }
722  }
723  _obAlignedRelToPage = true;
724  break;
725  }
726  case text::RelOrientation::PAGE_FRAME:
727  {
728  nWidth = aRectFnSet.GetWidth(_rPageAlignLayFrame.getFrameArea());
729  nOffset = aRectFnSet.XDiff(
730  aRectFnSet.GetLeft(_rPageAlignLayFrame.getFrameArea()),
731  aRectFnSet.GetLeft(_rHoriOrientFrame.getFrameArea()) );
732  _obAlignedRelToPage = true;
733  break;
734  }
735  default:
736  {
737  nWidth = aRectFnSet.GetWidth(_rHoriOrientFrame.getFrameArea());
738 
739  bool bWrapThrough = _bObjWrapThrough;
740  // If the frame format is a TextBox of a draw shape, then use the
741  // surround of the original shape.
743 
744  bool bIgnoreFlysAnchoredAtFrame = !bWrapThrough;
745  nOffset = _rHoriOrientFrame.IsTextFrame() ?
746  static_cast<const SwTextFrame&>(_rHoriOrientFrame).GetBaseOffsetForFly( bIgnoreFlysAnchoredAtFrame ) :
747  0;
748  break;
749  }
750  }
751 
752  _orAlignAreaWidth = nWidth;
753  _orAlignAreaOffset = nOffset;
754 }
755 
758  const bool _bToggleLeftRight,
759  sal_Int16& _ioeHoriOrient,
760  sal_Int16& _iopeRelOrient
761  )
762 {
763  if( !_bToggleLeftRight )
764  return;
765 
766  // toggle orientation
767  switch ( _ioeHoriOrient )
768  {
769  case text::HoriOrientation::RIGHT :
770  {
771  _ioeHoriOrient = text::HoriOrientation::LEFT;
772  }
773  break;
774  case text::HoriOrientation::LEFT :
775  {
776  _ioeHoriOrient = text::HoriOrientation::RIGHT;
777  }
778  break;
779  default:
780  break;
781  }
782 
783  // toggle relative alignment
784  switch ( _iopeRelOrient )
785  {
786  case text::RelOrientation::PAGE_RIGHT :
787  {
788  _iopeRelOrient = text::RelOrientation::PAGE_LEFT;
789  }
790  break;
791  case text::RelOrientation::PAGE_LEFT :
792  {
793  _iopeRelOrient = text::RelOrientation::PAGE_RIGHT;
794  }
795  break;
796  case text::RelOrientation::FRAME_RIGHT :
797  {
798  _iopeRelOrient = text::RelOrientation::FRAME_LEFT;
799  }
800  break;
801  case text::RelOrientation::FRAME_LEFT :
802  {
803  _iopeRelOrient = text::RelOrientation::FRAME_RIGHT;
804  }
805  break;
806  default:
807  break;
808  }
809 }
810 
813  const SwFrame& _rHoriOrientFrame,
814  const SwEnvironmentOfAnchoredObject& _rEnvOfObj,
815  const SwFormatHoriOrient& _rHoriOrient,
816  const SvxLRSpaceItem& _rLRSpacing,
817  const SvxULSpaceItem& _rULSpacing,
818  const bool _bObjWrapThrough,
819  const SwTwips _nRelPosY,
820  SwTwips& _roHoriOffsetToFrameAnchorPos
821  ) const
822 {
823  // determine 'page' alignment layout frame
824  const SwFrame& rPageAlignLayFrame =
825  _rEnvOfObj.GetHoriEnvironmentLayoutFrame( _rHoriOrientFrame );
826 
827  const bool bEvenPage = !rPageAlignLayFrame.OnRightPage();
828  const bool bToggle = _rHoriOrient.IsPosToggle() && bEvenPage;
829 
830  // determine orientation and relative alignment
831  sal_Int16 eHoriOrient = _rHoriOrient.GetHoriOrient();
832  sal_Int16 eRelOrient = _rHoriOrient.GetRelationOrient();
833  // toggle orientation and relative alignment
834  ToggleHoriOrientAndAlign( bToggle, eHoriOrient, eRelOrient );
835 
836  // determine alignment parameter
837  // <nWidth>: 'width' of alignment area
838  // <nOffset>: offset of alignment area, relative to 'left' of anchor frame
839  SwTwips nWidth = 0;
840  SwTwips nOffset = 0;
841  bool bAlignedRelToPage = false;
842  GetHoriAlignmentValues( _rHoriOrientFrame, rPageAlignLayFrame,
843  eRelOrient, _bObjWrapThrough,
844  nWidth, nOffset, bAlignedRelToPage );
845 
846  const SwFrame& rAnchorFrame = GetAnchorFrame();
847  SwRectFnSet aRectFnSet(&_rHoriOrientFrame);
848  SwTwips nObjWidth = aRectFnSet.GetWidth(GetAnchoredObj().GetObjRect());
849  SwTwips nRelPosX = nOffset;
850  if ( _rHoriOrient.GetHoriOrient() == text::HoriOrientation::NONE )
851  {
852  // 'manual' horizontal position
853  const bool bR2L = rAnchorFrame.IsRightToLeft();
854  if( IsAnchoredToChar() && text::RelOrientation::CHAR == eRelOrient )
855  {
856  if( bR2L )
857  nRelPosX -= _rHoriOrient.GetPos();
858  else
859  nRelPosX += _rHoriOrient.GetPos();
860  }
861  else if ( bToggle || ( !_rHoriOrient.IsPosToggle() && bR2L ) )
862  {
863  // Correction: consider <nOffset> also for
864  // toggling from left to right.
865  nRelPosX += nWidth - nObjWidth - _rHoriOrient.GetPos();
866  }
867  else
868  {
869  nRelPosX += _rHoriOrient.GetPos();
870  }
871  }
872  else if ( text::HoriOrientation::CENTER == eHoriOrient )
873  nRelPosX += (nWidth / 2) - (nObjWidth / 2);
874  else if ( text::HoriOrientation::RIGHT == eHoriOrient )
875  nRelPosX += nWidth -
876  ( nObjWidth +
877  ( aRectFnSet.IsVert() ? _rULSpacing.GetLower() : _rLRSpacing.GetRight() ) );
878  else
879  nRelPosX += aRectFnSet.IsVert() ? _rULSpacing.GetUpper() : _rLRSpacing.GetLeft();
880 
881  // adjust relative position by distance between anchor frame and
882  // the frame, the object is oriented at.
883  if ( &rAnchorFrame != &_rHoriOrientFrame )
884  {
885  SwTwips nLeftOrient = aRectFnSet.GetLeft(_rHoriOrientFrame.getFrameArea());
886  SwTwips nLeftAnchor = aRectFnSet.GetLeft(rAnchorFrame.getFrameArea());
887  nRelPosX += aRectFnSet.XDiff( nLeftOrient, nLeftAnchor );
888  }
889 
890  // adjust calculated relative horizontal position, in order to
891  // keep object inside 'page' alignment layout frame
892  const SwFrame& rEnvironmentLayFrame =
893  _rEnvOfObj.GetHoriEnvironmentLayoutFrame( _rHoriOrientFrame );
894  bool bFollowTextFlow = GetFrameFormat().GetFollowTextFlow().GetValue();
895  bool bWrapThrough = GetFrameFormat().GetSurround().GetSurround() != text::WrapTextMode_THROUGH;
896  // Don't try to keep wrap-though objects inside the cell, even if they are following text flow.
897  if (!rEnvironmentLayFrame.IsInTab() || !bFollowTextFlow || bWrapThrough)
898  {
899  nRelPosX = AdjustHoriRelPos( rEnvironmentLayFrame, nRelPosX );
900  }
901 
902  // if object is a Writer fly frame and it's anchored to a content and
903  // it is horizontal positioned left or right, but not relative to character,
904  // it has to be drawn aside another object, which have the same horizontal
905  // position and lay below it.
906  if ( dynamic_cast<const SwFlyFrame*>( &GetAnchoredObj() ) != nullptr &&
908  ( eHoriOrient == text::HoriOrientation::LEFT || eHoriOrient == text::HoriOrientation::RIGHT ) &&
909  eRelOrient != text::RelOrientation::CHAR )
910  {
911  nRelPosX = AdjustHoriRelPosForDrawAside( _rHoriOrientFrame,
912  nRelPosX, _nRelPosY,
913  eHoriOrient, eRelOrient,
914  _rLRSpacing, _rULSpacing,
915  bEvenPage );
916  }
917 
918  // #i26791#
919  _roHoriOffsetToFrameAnchorPos = nOffset;
920 
921  return nRelPosX;
922 }
923 
924 // method incl. helper methods for adjusting proposed horizontal position,
925 // if object has to draw aside another object.
930  const SwFrame& _rHoriOrientFrame,
931  const SwTwips _nProposedRelPosX,
932  const SwTwips _nRelPosY,
933  const sal_Int16 _eHoriOrient,
934  const sal_Int16 _eRelOrient,
935  const SvxLRSpaceItem& _rLRSpacing,
936  const SvxULSpaceItem& _rULSpacing,
937  const bool _bEvenPage
938  ) const
939 {
940  // #i26791#
941  if ( dynamic_cast<const SwTextFrame*>( &GetAnchorFrame() ) == nullptr ||
942  dynamic_cast<const SwFlyAtContentFrame*>( &GetAnchoredObj() ) == nullptr )
943  {
944  OSL_FAIL( "<SwAnchoredObjectPosition::AdjustHoriRelPosForDrawAside(..) - usage for wrong anchor type" );
945  return _nProposedRelPosX;
946  }
947 
948  const SwTextFrame& rAnchorTextFrame = static_cast<const SwTextFrame&>(GetAnchorFrame());
949  // #i26791#
950  const SwFlyAtContentFrame& rFlyAtContentFrame =
951  static_cast<const SwFlyAtContentFrame&>(GetAnchoredObj());
952  const SwRect aObjBoundRect( GetAnchoredObj().GetObjRect() );
953  SwRectFnSet aRectFnSet(&_rHoriOrientFrame);
954 
955  SwTwips nAdjustedRelPosX = _nProposedRelPosX;
956 
957  // determine proposed object bound rectangle
958  Point aTmpPos = aRectFnSet.GetPos(rAnchorTextFrame.getFrameArea());
959  if( aRectFnSet.IsVert() )
960  {
961  aTmpPos.AdjustX( -(_nRelPosY + aObjBoundRect.Width()) );
962  aTmpPos.AdjustY(nAdjustedRelPosX );
963  }
964  else
965  {
966  aTmpPos.AdjustX(nAdjustedRelPosX );
967  aTmpPos.AdjustY(_nRelPosY );
968  }
969  SwRect aTmpObjRect( aTmpPos, aObjBoundRect.SSize() );
970 
971  const sal_uInt32 nObjOrdNum = GetObject().GetOrdNum();
972  const SwPageFrame* pObjPage = rFlyAtContentFrame.FindPageFrame();
973  const SwFrame* pObjContext = ::FindContext( &rAnchorTextFrame, SwFrameType::Column );
974  sal_uLong nObjIndex = rAnchorTextFrame.GetTextNodeFirst()->GetIndex();
975  SwOrderIter aIter( pObjPage );
976  const SwFlyFrame* pFly = static_cast<const SwVirtFlyDrawObj*>(aIter.Bottom())->GetFlyFrame();
977  while ( pFly && nObjOrdNum > pFly->GetVirtDrawObj()->GetOrdNumDirect() )
978  {
979  if ( DrawAsideFly( pFly, aTmpObjRect, pObjContext, nObjIndex,
980  _bEvenPage, _eHoriOrient, _eRelOrient ) )
981  {
982  if( aRectFnSet.IsVert() )
983  {
984  const SvxULSpaceItem& rOtherUL = pFly->GetFormat()->GetULSpace();
985  const SwTwips nOtherTop = pFly->getFrameArea().Top() - rOtherUL.GetUpper();
986  const SwTwips nOtherBot = pFly->getFrameArea().Bottom() + rOtherUL.GetLower();
987  if ( nOtherTop <= aTmpObjRect.Bottom() + _rULSpacing.GetLower() &&
988  nOtherBot >= aTmpObjRect.Top() - _rULSpacing.GetUpper() )
989  {
990  if ( _eHoriOrient == text::HoriOrientation::LEFT )
991  {
992  SwTwips nTmp = nOtherBot + 1 + _rULSpacing.GetUpper() -
993  rAnchorTextFrame.getFrameArea().Top();
994  if ( nTmp > nAdjustedRelPosX &&
995  rAnchorTextFrame.getFrameArea().Top() + nTmp +
996  aObjBoundRect.Height() + _rULSpacing.GetLower()
997  <= pObjPage->getFrameArea().Height() + pObjPage->getFrameArea().Top() )
998  {
999  nAdjustedRelPosX = nTmp;
1000  }
1001  }
1002  else if ( _eHoriOrient == text::HoriOrientation::RIGHT )
1003  {
1004  SwTwips nTmp = nOtherTop - 1 - _rULSpacing.GetLower() -
1005  aObjBoundRect.Height() -
1006  rAnchorTextFrame.getFrameArea().Top();
1007  if ( nTmp < nAdjustedRelPosX &&
1008  rAnchorTextFrame.getFrameArea().Top() + nTmp - _rULSpacing.GetUpper()
1009  >= pObjPage->getFrameArea().Top() )
1010  {
1011  nAdjustedRelPosX = nTmp;
1012  }
1013  }
1014  aTmpObjRect.Pos().setY( rAnchorTextFrame.getFrameArea().Top() +
1015  nAdjustedRelPosX );
1016  }
1017  }
1018  else
1019  {
1020  const SvxLRSpaceItem& rOtherLR = pFly->GetFormat()->GetLRSpace();
1021  const SwTwips nOtherLeft = pFly->getFrameArea().Left() - rOtherLR.GetLeft();
1022  const SwTwips nOtherRight = pFly->getFrameArea().Right() + rOtherLR.GetRight();
1023  if( nOtherLeft <= aTmpObjRect.Right() + _rLRSpacing.GetRight() &&
1024  nOtherRight >= aTmpObjRect.Left() - _rLRSpacing.GetLeft() )
1025  {
1026  if ( _eHoriOrient == text::HoriOrientation::LEFT )
1027  {
1028  SwTwips nTmp = nOtherRight + 1 + _rLRSpacing.GetLeft() -
1029  rAnchorTextFrame.getFrameArea().Left();
1030  if ( nTmp > nAdjustedRelPosX &&
1031  rAnchorTextFrame.getFrameArea().Left() + nTmp +
1032  aObjBoundRect.Width() + _rLRSpacing.GetRight()
1033  <= pObjPage->getFrameArea().Width() + pObjPage->getFrameArea().Left() )
1034  {
1035  nAdjustedRelPosX = nTmp;
1036  }
1037  }
1038  else if ( _eHoriOrient == text::HoriOrientation::RIGHT )
1039  {
1040  SwTwips nTmp = nOtherLeft - 1 - _rLRSpacing.GetRight() -
1041  aObjBoundRect.Width() -
1042  rAnchorTextFrame.getFrameArea().Left();
1043  if ( nTmp < nAdjustedRelPosX &&
1044  rAnchorTextFrame.getFrameArea().Left() + nTmp - _rLRSpacing.GetLeft()
1045  >= pObjPage->getFrameArea().Left() )
1046  {
1047  nAdjustedRelPosX = nTmp;
1048  }
1049  }
1050  aTmpObjRect.Pos().setX( rAnchorTextFrame.getFrameArea().Left() +
1051  nAdjustedRelPosX );
1052  }
1053  } // end of <if (bVert)>
1054  } // end of <if DrawAsideFly(..)>
1055 
1056  pFly = static_cast<const SwVirtFlyDrawObj*>(aIter.Next())->GetFlyFrame();
1057  } // end of <loop on fly frames
1058 
1059  return nAdjustedRelPosX;
1060 }
1061 
1067  const SwRect& _rObjRect,
1068  const SwFrame* _pObjContext,
1069  const sal_uLong _nObjIndex,
1070  const bool _bEvenPage,
1071  const sal_Int16 _eHoriOrient,
1072  const sal_Int16 _eRelOrient
1073  ) const
1074 {
1075  bool bRetVal = false;
1076 
1077  SwRectFnSet aRectFnSet(&GetAnchorFrame());
1078 
1079  if ( _pFly->IsFlyAtContentFrame() &&
1080  aRectFnSet.BottomDist( _pFly->getFrameArea(), aRectFnSet.GetTop(_rObjRect) ) < 0 &&
1081  aRectFnSet.BottomDist( _rObjRect, aRectFnSet.GetTop(_pFly->getFrameArea()) ) < 0 &&
1082  ::FindContext( _pFly->GetAnchorFrame(), SwFrameType::Column ) == _pObjContext )
1083  {
1084  sal_uLong nOtherIndex =
1085  static_cast<const SwTextFrame*>(_pFly->GetAnchorFrame())->GetTextNodeFirst()->GetIndex();
1086  if (sw::FrameContainsNode(static_cast<SwTextFrame const&>(*_pFly->GetAnchorFrame()), _nObjIndex)
1087  || nOtherIndex < _nObjIndex)
1088  {
1089  const SwFormatHoriOrient& rHori = _pFly->GetFormat()->GetHoriOrient();
1090  sal_Int16 eOtherRelOrient = rHori.GetRelationOrient();
1091  if( text::RelOrientation::CHAR != eOtherRelOrient )
1092  {
1093  sal_Int16 eOtherHoriOrient = rHori.GetHoriOrient();
1094  ToggleHoriOrientAndAlign( _bEvenPage && rHori.IsPosToggle(),
1095  eOtherHoriOrient,
1096  eOtherRelOrient );
1097  if ( eOtherHoriOrient == _eHoriOrient &&
1098  Minor_( _eRelOrient, eOtherRelOrient, text::HoriOrientation::LEFT == _eHoriOrient ) )
1099  {
1100  bRetVal = true;
1101  }
1102  }
1103  }
1104  }
1105 
1106  return bRetVal;
1107 }
1108 
1118 bool SwAnchoredObjectPosition::Minor_( sal_Int16 _eRelOrient1,
1119  sal_Int16 _eRelOrient2,
1120  bool _bLeft )
1121 {
1122  bool bRetVal;
1123 
1124  // draw aside order for left horizontal position
1126  static sal_uInt16 const aLeft[ 10 ] =
1127  { 5, 6, 0, 1, 8, 4, 7, 2, 3, 9 };
1128  // draw aside order for right horizontal position
1130  static sal_uInt16 const aRight[ 10 ] =
1131  { 5, 6, 0, 8, 1, 7, 4, 2, 3, 9 };
1132 
1133  // decide depending on given order, which frame has to draw aside another frame
1134  if( _bLeft )
1135  bRetVal = aLeft[ _eRelOrient1 ] >= aLeft[ _eRelOrient2 ];
1136  else
1137  bRetVal = aRight[ _eRelOrient1 ] >= aRight[ _eRelOrient2 ];
1138 
1139  return bRetVal;
1140 }
1141 
1142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetValue() 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:2783
Base class of the Writer layout elements.
Definition: frame.hxx:313
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:158
void GetInfoAboutObj()
determine information about object
tools::Long GetRight(const SwRect &rRect) const
Definition: frame.hxx:1377
const SdrObject * Next()
Definition: frmtool.cxx:2694
SwTwips GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const
Definition: txtfrm.cxx:4017
sal_uLong GetIndex() const
Definition: node.hxx:291
void Right(const tools::Long nRight)
Definition: swrect.hxx:200
Point GetPos(const SwRect &rRect) const
Definition: frame.hxx:1380
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2877
tools::Long GetPrtRight(const SwFrame &rFrame) const
Definition: frame.hxx:1409
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:3580
sal_uInt16 GetLower() const
tools::Long BottomDist(const SwRect &rRect, tools::Long nPos) const
Definition: frame.hxx:1411
tools::Long GetLeftMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1402
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...
void Left(const tools::Long nLeft)
Definition: swrect.hxx:195
SwRectFn FnRect() const
Definition: frame.hxx:1366
SwTwips GetPos() const
Definition: fmtornt.hxx:92
sal_uIntPtr sal_uLong
tools::Long GetRight() const
const SwRect & getFramePrintArea() const
Definition: frame.hxx:179
bool IsVert() const
Definition: frame.hxx:1364
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
tools::Long GetWidth(const SwRect &rRect) const
Definition: frame.hxx:1378
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:171
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
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:218
tools::Long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1374
constexpr tools::Long Width() const
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:178
bool IsInTab() const
Definition: frame.hxx:952
const SwLayoutFrame & GetHoriEnvironmentLayoutFrame(const SwFrame &_rHoriOrientFrame) const
determine environment layout frame for possible horizontal object positions respectively for alignmen...
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:1231
tools::Long GetPrtLeft(const SwFrame &rFrame) const
Definition: frame.hxx:1408
void Width(tools::Long nNew)
Definition: swrect.hxx:187
bool OnRightPage() const
Definition: frame.hxx:732
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The Get reverse way: seeks the format to the specified object.
Definition: dcontact.cxx:120
tools::Long GetLeft(const SwRect &rRect) const
Definition: frame.hxx:1376
static bool IsDraggingOffPageAllowed(const SwFrameFormat *)
method to determine if dragging objects off page is allowed
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
tools::Long XDiff(tools::Long n1, tools::Long n2) const
Definition: frame.hxx:1419
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:457
bool FrameContainsNode(SwContentFrame const &rFrame, sal_uLong nNodeIndex)
Definition: txtfrm.cxx:288
const SwFormatFollowTextFlow & GetFollowTextFlow(bool=true) const
static bool Minor_(sal_Int16 _eRelOrient1, sal_Int16 _eRelOrient2, bool _bLeft)
determine, if object has to draw aside another object
tools::Long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1407
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
SwPageFrame * FindPageFrame()
Definition: frame.hxx:679
tools::Long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1379
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
tools::Long GetLeft() const
const SwFrame * mpAnchorFrame
SwLayoutFrame * GetUpper()
Definition: frame.hxx:677
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
SwTwips GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() const
method to determine the upper space amount, which is considered for the previous frame and the page g...
Definition: flowfrm.cxx:1725
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
tools::Long GetTopMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1400
tools::Long YDiff(tools::Long n1, tools::Long n2) const
Definition: frame.hxx:1420
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:717
tools::Long GetRightMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1403
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:57
tools::Long SwTwips
Definition: swtypes.hxx:49
virtual const SwFrame * ToCharOrientFrame() const
void Bottom(const tools::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 ...
tools::Long GetBottomMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1401
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
virtual SwFrameFormat & GetFrameFormat()=0
constexpr tools::Long Height() const
bool IsRightToLeft() const
Definition: frame.hxx:984
void Top(const tools::Long nTop)
Definition: swrect.hxx:204
bool IsVertL2R() const
Definition: frame.hxx:1365
bool IsPageFrame() const
Definition: frame.hxx:1175
void GetVertAlignmentValues(const SwFrame &_rVertOrientFrame, const SwFrame &_rPageAlignLayFrame, const sal_Int16 _eRelOrient, SwTwips &_orAlignAreaHeight, SwTwips &_orAlignAreaOffset) const
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
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:970
const SwFrame * GetAnchorFrame() const
void Height(tools::Long nNew)
Definition: swrect.hxx:191
bool ObjAnchoredAtPara() const
Definition: dcontact.hxx:148
bool IsFooterFrame() const
Definition: frame.hxx:1191
bool ObjAnchoredAtChar() const
Definition: dcontact.hxx:149
const SdrObject * Bottom()
Definition: frmtool.cxx:2667
sal_uInt16 GetUpper() const
bool IsHeaderFrame() const
Definition: frame.hxx:1187
SwRectGet fnGetTop
Definition: frame.hxx:1288
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:675
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74