sw/qa/extras/uiwriter/data/tdf153636.odt |binary sw/qa/extras/uiwriter/uiwriter8.cxx | 31 ++++++++++++++++++++++++++++++- sw/source/core/doc/doctxm.cxx | 19 +++++++++++-------- 3 files changed, 41 insertions(+), 9 deletions(-)
New commits: commit 5b864851f6c1c88674b6c2ad07215d62249f47ac Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Tue Oct 29 12:11:41 2024 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Nov 11 17:30:27 2024 +0100 tdf#153636 - Search for outline node only if index is for the current chapter Otherwise, "Use level from source chapter" does not work for Graphics and Frames in user-defined indices. Change-Id: I148a097276cf8a60d69a208266ceb9def0444654 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175783 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176094 diff --git a/sw/qa/extras/uiwriter/data/tdf153636.odt b/sw/qa/extras/uiwriter/data/tdf153636.odt new file mode 100644 index 000000000000..d2380120d39e Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf153636.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index 215fc719ad66..a6ba1e38d359 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -2918,7 +2918,36 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf151462) "portion"_ostr, u"another sub three"_ustr); } -CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf151801) +CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf153636) +{ + createSwDoc("tdf153636.odt"); + dispatchCommand(mxComponent, u".uno:UpdateAllIndexes"_ustr, {}); + saveAndReload(u"writer8"_ustr); + + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + for (int i = 1; i <= 3; i += 2) + { + const OUString frameStyleName + = getXPath(pXmlDoc, + "/office:document-content/office:body/office:text/" + "text:user-index[@text:name='User-Defined1']/text:index-body/text:p[" + + OString::number(i) + "]"_ostr, + "style-name"_ostr); + const OUString tableStyleName + = getXPath(pXmlDoc, + "/office:document-content/office:body/office:text/" + "text:user-index[@text:name='User-Defined1']/text:index-body/text:p[" + + OString::number(i + 1) + "]"_ostr, + "style-name"_ostr); + + // Without the fix in place, the frame and table indentation would differ + CPPUNIT_ASSERT_EQUAL(frameStyleName, tableStyleName); + } +} + +CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf157129) { Resetter resetter([]() { std::shared_ptr<comphelper::ConfigurationChanges> pBatch( diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 9bd9d9678eab..75a3cbb26822 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -719,8 +719,9 @@ bool SwDoc::SetTOXBaseName(const SwTOXBase& rTOXBase, const OUString& rName) return false; } -static const SwTextNode* lcl_FindChapterNode( const SwNode& rNd, - SwRootFrame const*const pLayout, sal_uInt8 const nLvl = 0 ) +static const SwTextNode* lcl_FindChapterNode(const SwNode& rNd, SwRootFrame const* const pLayout, + sal_uInt8 const nLvl = 0, + const bool bIsFromChapter = true) { const SwNode* pNd = &rNd; if( pNd->GetNodes().GetEndOfExtras().GetIndex() > pNd->GetIndex() ) @@ -735,8 +736,10 @@ static const SwTextNode* lcl_FindChapterNode( const SwNode& rNd, SwPosition aPos( *pNd ); pNd = GetBodyTextNode( pNd->GetDoc(), aPos, *pFrame ); OSL_ENSURE( pNd, "Where's the paragraph?" ); - // tdf#151462 - search for outline node containing the current node - return pNd ? pNd->FindOutlineNodeOfLevel(pNd->GetSectionLevel() - 1, pLayout) : nullptr; + // tdf#153636 - search for outline node only if the index is for the current chapter + if (bIsFromChapter) + // tdf#151462 - search for outline node containing the current node + return pNd->FindOutlineNodeOfLevel(pNd->GetSectionLevel() - 1, pLayout); } } return pNd->FindOutlineNodeOfLevel(nLvl, pLayout); @@ -1613,8 +1616,8 @@ void SwTOXBaseSection::UpdateContent( SwTOXElement eMyType, TOX_ILLUSTRATIONS != SwTOXBase::GetType() && TOX_OBJECTS != SwTOXBase::GetType() ) { - const SwTextNode* pOutlNd = ::lcl_FindChapterNode( *pCNd, - pLayout, MAXLEVEL - 1); + const SwTextNode* pOutlNd + = ::lcl_FindChapterNode(*pCNd, pLayout, MAXLEVEL - 1, IsFromChapter()); if( pOutlNd ) { if( pOutlNd->GetTextColl()->IsAssignedToListLevelOfOutlineStyle()) @@ -1672,8 +1675,8 @@ void SwTOXBaseSection::UpdateTable(const SwTextNode* pOwnChapterNode, std::unique_ptr<SwTOXTable> pNew(new SwTOXTable( *pCNd )); if( IsLevelFromChapter() && TOX_TABLES != SwTOXBase::GetType()) { - const SwTextNode* pOutlNd = - ::lcl_FindChapterNode(*pCNd, pLayout, MAXLEVEL - 1); + const SwTextNode* pOutlNd + = ::lcl_FindChapterNode(*pCNd, pLayout, MAXLEVEL - 1, IsFromChapter()); if( pOutlNd ) { if( pOutlNd->GetTextColl()->IsAssignedToListLevelOfOutlineStyle())