sw/source/ui/misc/pggrid.cxx |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

New commits:
commit b21880ab06e85fdb688c8e5d11453a9fb9d52896
Author:     Mark Hung <mark...@gmail.com>
AuthorDate: Thu Oct 7 20:36:17 2021 +0800
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Oct 14 16:43:46 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>
    (cherry picked from commit 8ac8a20ed15bb458e1ee5a8df2b97aef05ca4f7c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123397
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx
index 20a964eceaf7..73657c9573aa 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>
@@ -272,6 +273,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);

Reply via email to