sw/qa/extras/uiwriter/data/tdf151462.odt |binary
 sw/qa/extras/uiwriter/data/tdf40142.odt  |binary
 sw/qa/extras/uiwriter/uiwriter8.cxx      |   16 ++++++++++++++--
 sw/source/core/doc/doctxm.cxx            |    2 ++
 4 files changed, 16 insertions(+), 2 deletions(-)

New commits:
commit 5c04c4474236cc50009aea6d89f7c443c861af19
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Tue Mar 14 15:34:16 2023 +0100
Commit:     Andreas Heinisch <andreas.heini...@yahoo.de>
CommitDate: Wed Mar 15 11:00:03 2023 +0000

    tdf#40142 - Consider level settings of the various text nodes
    
    Consider level settings of the various text nodes when creating a TOC
    from custom styles.
    
    Change-Id: I70759f9bcf63e8591ce89bc71afabb1da0c2f29c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148886
    Tested-by: Jenkins
    Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de>

diff --git a/sw/qa/extras/uiwriter/data/tdf151462.odt 
b/sw/qa/extras/uiwriter/data/tdf151462.odt
index cdd250232e18..648cb7619582 100644
Binary files a/sw/qa/extras/uiwriter/data/tdf151462.odt and 
b/sw/qa/extras/uiwriter/data/tdf151462.odt differ
diff --git a/sw/qa/extras/uiwriter/data/tdf40142.odt 
b/sw/qa/extras/uiwriter/data/tdf40142.odt
new file mode 100755
index 000000000000..7f87c867ee29
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf40142.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 498a9f9e7408..45d76fd76771 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -2484,13 +2484,25 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf97899)
     CPPUNIT_ASSERT(!sCharStyleName.isEmpty());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf40142)
+{
+    createSwDoc("tdf40142.odt");
+    dispatchCommand(mxComponent, ".uno:UpdateAllIndexes", {});
+
+    xmlDocUniquePtr pLayout = parseLayoutDump();
+    // Without the fix in place, this test would have failed with
+    // - Expected: 2
+    // - Actual  : 4
+    assertXPath(pLayout, "/root/page[1]/body/section[2]/txt", 2);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf151462)
 {
     createSwDoc("tdf151462.odt");
     dispatchCommand(mxComponent, ".uno:UpdateAllIndexes", {});
 
     xmlDocUniquePtr pLayout = parseLayoutDump();
-    // tdf#151462 - without the fix in place, there would be just the first 
index entry
+    // Without the fix in place, there would be just the first index entry
     assertXPath(pLayout,
                 
"/root/page[1]/body/txt[2]/anchored/fly/section/txt[1]/SwParaPortion/"
                 "SwLineLayout[1]/SwLinePortion[1]",
@@ -2504,7 +2516,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf151462)
                 "SwLineLayout[1]/SwLinePortion[1]",
                 "portion", "sub three");
 
-    // tdf#151462 - without the fix in place, there would be just the first 
index entry
+    // Without the fix in place, there would be just the first index entry
     assertXPath(pLayout,
                 
"/root/page[1]/body/txt[6]/anchored/fly/section/txt[1]/SwParaPortion/"
                 "SwLineLayout[1]/SwLinePortion[1]",
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index 5f54e5313f70..0a80b25d2f6b 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -1373,6 +1373,8 @@ void SwTOXBaseSection::UpdateTemplate(const SwTextNode* 
pOwnChapterNode,
                 if (pTextNd->GetText().getLength() &&
                     pTextNd->getLayoutFrame(pLayout) &&
                     pTextNd->GetNodes().IsDocNodes() &&
+                    // tdf#40142 - consider level settings of the various text 
nodes
+                    o3tl::make_unsigned(pTextNd->GetAttrOutlineLevel()) <= 
GetLevel() &&
                     (!pLayout || !pLayout->HasMergedParas()
                         || 
static_cast<SwTextFrame*>(pTextNd->getLayoutFrame(pLayout))->GetTextNodeForParaProps()
 == pTextNd) &&
                     (!IsFromChapter() || IsHeadingContained(pOwnChapterNode, 
*pTextNd)))

Reply via email to