From e21bc1b3e587c2bd90168b24f3774d98a3837f8e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 5 May 2020 18:03:51 +0200 Subject: sw from-bottom relative orientation: fix calculation of position limits Create a new Writer doc, insert a rectangle with height = 10cm, try to position it 2cm above the bottom of the page, so that would be -12cm, but we limited the metric field to -2cm because 2cm was the page margin. Teach SwFEShell::CalcBoundRect() about text::RelOrientation::PAGE_PRINT_AREA_BOTTOM, then this will work without problems. Change-Id: Ib6ddccc1512d39fff5bff2e989973b156a6c2bf7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93501 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/source/core/frmedt/fews.cxx | 16 +++++++++++++++- sw/source/uibase/shells/drwbassh.cxx | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx index 87fb9075644f..4f545ed22649 100644 --- a/sw/source/core/frmedt/fews.cxx +++ b/sw/source/core/frmedt/fews.cxx @@ -967,7 +967,9 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, // #i18732# - adjustment vertical 'virtual' anchor position // ( respectively ), if object is vertical aligned // to page areas. - if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA ) + if (_eVertRelOrient == text::RelOrientation::PAGE_FRAME + || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA + || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM) { if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() ) { @@ -998,6 +1000,18 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, aPos.setY(aPos.getY() + pTmpFrame->getFrameArea().Height()); } } + else if (_eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM) + { + if (rVertEnvironLayFrame.IsPageFrame()) + { + auto& rPageFrame = static_cast(rVertEnvironLayFrame); + aPos.setY(rPageFrame.PrtWithoutHeaderAndFooter().Bottom()); + } + else + { + aPos.AdjustY(rVertEnvironLayFrame.getFramePrintArea().Bottom()); + } + } } } } diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx index 18fce24f2c94..bccbe313bdf9 100644 --- a/sw/source/uibase/shells/drwbassh.cxx +++ b/sw/source/uibase/shells/drwbassh.cxx @@ -958,7 +958,8 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation&, rValidation, // and alignment at page areas. const bool bMaxVPosAtBottom = !rValidation.bFollowTextFlow || rValidation.nVRelOrient == text::RelOrientation::PAGE_FRAME || - rValidation.nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA; + rValidation.nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA || + rValidation.nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM; { SwTwips nTmpMaxVPos = ( bMaxVPosAtBottom ? aBoundRect.Bottom() -- cgit v1.2.3