sw/source/ui/misc/pggrid.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
New commits: commit 8ac8a20ed15bb458e1ee5a8df2b97aef05ca4f7c Author: Mark Hung <mark...@gmail.com> AuthorDate: Thu Oct 7 20:36:17 2021 +0800 Commit: Mark Hung <mark...@gmail.com> CommitDate: Mon Oct 11 14:14:13 2021 +0200 tdf#141957 include the size of header and footer. Text grid dialog didn't include the size of header and footer, so if any of them are included, the resulted number of lines or chars per line was wrong. Change-Id: I09c1eed1552485adf75ad75cfaf25b99f8eec1e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123215 Tested-by: Jenkins Reviewed-by: Mark Hung <mark...@gmail.com> diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx index 5b1b69b05b37..875bee7ad331 100644 --- a/sw/source/ui/misc/pggrid.cxx +++ b/sw/source/ui/misc/pggrid.cxx @@ -29,6 +29,7 @@ #include <svx/ruler.hxx> #include <pggrid.hxx> #include <tgrditem.hxx> +#include <svx/pageitem.hxx> #include <wrtsh.hxx> #include <doc.hxx> @@ -274,6 +275,24 @@ void SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet) sal_Int32 nDistanceLR = rLRSpace.GetLeft() + rLRSpace.GetRight(); sal_Int32 nDistanceUL = rULSpace.GetUpper() + rULSpace.GetLower(); + for( sal_Int32 nId : { SID_ATTR_PAGE_HEADERSET, SID_ATTR_PAGE_FOOTERSET }) + { + const SfxPoolItem* pItem; + if( SfxItemState::SET == rSet.GetItemState( nId, false, &pItem ) ) + { + const SfxItemSet& rExtraSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet(); + const SfxBoolItem& rOn = + static_cast<const SfxBoolItem&>(rExtraSet.Get( rSet.GetPool()->GetWhich( SID_ATTR_PAGE_ON ) )); + + if ( rOn.GetValue() ) + { + const SvxSizeItem& rSizeItem = + static_cast<const SvxSizeItem&>(rExtraSet.Get(rSet.GetPool()->GetWhich(SID_ATTR_PAGE_SIZE))); + nDistanceUL += rSizeItem.GetSize().Height(); + } + } + } + sal_Int32 nValue1 = rSize.GetSize().Height() - nDistanceUL - rBox.GetDistance(SvxBoxItemLine::TOP) - rBox.GetDistance(SvxBoxItemLine::BOTTOM);