sw/qa/extras/layout/data/tdf167202_footnote.docx |binary
 sw/qa/extras/layout/layout5.cxx                  |   24 +++++++++++++++++++++++
 sw/source/core/text/frmpaint.cxx                 |   14 +++++++++++++
 3 files changed, 38 insertions(+)

New commits:
commit c5971987a1684c81ab6359ecc9a640f31f39bbbc
Author:     Bayram Çiçek <[email protected]>
AuthorDate: Thu Sep 25 11:14:39 2025 +0300
Commit:     Caolán McNamara <[email protected]>
CommitDate: Tue Sep 30 12:22:52 2025 +0200

    tdf#167202: sw: do not show line numbering in footnote
    
    if compatibility options are enabled.
    - add a unit test.
    
    Change-Id: I87ae611b5917c2b11b3f131dfa66e7f9b19a24cb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191493
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 4afbcee5f13f63a49bbd957664daf7e37ea7472e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191653
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Bayram Çiçek <[email protected]>

diff --git a/sw/qa/extras/layout/data/tdf167202_footnote.docx 
b/sw/qa/extras/layout/data/tdf167202_footnote.docx
new file mode 100644
index 000000000000..68ca669d9d12
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf167202_footnote.docx 
differ
diff --git a/sw/qa/extras/layout/layout5.cxx b/sw/qa/extras/layout/layout5.cxx
index 1b6addbfd638..3869a52b448a 100644
--- a/sw/qa/extras/layout/layout5.cxx
+++ b/sw/qa/extras/layout/layout5.cxx
@@ -546,6 +546,30 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf122014)
     CPPUNIT_ASSERT_GREATER(nX1 + 100, nX2);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf167202_footnote)
+{
+    createSwDoc("tdf167202_footnote.docx");
+    SwDocShell* pShell = getSwDocShell();
+    CPPUNIT_ASSERT(pShell);
+
+    // Dump the rendering of the first page as an XML file.
+    std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+    MetafileXmlDump dumper;
+    xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    // Check if footnote is there.
+    assertXPathContent(pXmlDoc, "(//textarray)[7]/text", u"FOOTNOTE #1");
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // equality assertion failed
+    // - Expected: 10
+    // - Actual  : 11
+    // - In <>, XPath '//textarray' number of nodes is incorrect
+    // i.e. if there are 11 textarray node, it means there is an extra 
numbering in the footnote.
+    assertXPath(pXmlDoc, "//textarray", 10);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf134659)
 {
     createSwDoc("tdf134659.docx");
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index f768d212a62f..f42cca628061 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -47,6 +47,7 @@
 #include <EnhancedPDFExportHelper.hxx>
 
 #include <IDocumentRedlineAccess.hxx>
+#include <IDocumentSettingAccess.hxx>
 #include <IDocumentStylePoolAccess.hxx>
 
 #define REDLINE_DISTANCE 567/4
@@ -320,6 +321,19 @@ void SwTextFrame::PaintExtraData( const SwRect &rRect ) 
const
     const SwFormatLineNumber &rLineNum = GetAttrSet()->GetLineNumber();
     bool bLineNum = !IsInTab() && rLineInf.IsPaintLineNumbers() &&
                ( !IsInFly() || rLineInf.IsCountInFlys() ) && 
rLineNum.IsCount();
+
+    // Do not show line numbering in footnote.
+    // if compatibility options are enabled.
+    if (IsInFootnote())
+    {
+        const IDocumentSettingAccess& rIDSA = rDoc.getIDocumentSettingAccess();
+        const bool bCompatMso13 = 
rIDSA.get(DocumentSettingId::TAB_OVER_SPACING); // MSO 2013+
+        const bool bCompatMso10 = 
rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN); // <= MSO 2010
+
+        if (bCompatMso13 || bCompatMso10)
+            bLineNum = false;
+    }
+
     sal_Int16 eHor = 
static_cast<sal_Int16>(SwModule::get()->GetRedlineMarkPos());
     if (eHor != text::HoriOrientation::NONE
         && (!IDocumentRedlineAccess::IsShowChanges(rIDRA.GetRedlineFlags())

Reply via email to