diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-03-27 16:01:51 +0500 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-04-07 13:58:03 +0200 |
commit | 153040b2eaa8efe399ba7bc4c0a4c43603b89e40 (patch) | |
tree | 775d00cef16172403e2941e53c8e49e6cdddc2bb /sw | |
parent | 4977f8bc199e1c7ce03c146fdcffa147f6c869e7 (diff) |
tdf#160390: make sure to forward the iterator
Change-Id: I302cc4303f083a1024175ce4ba00ce8021c6d4c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165390
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165404
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/htmlexport/data/tdf160390.fodt | 17 | ||||
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/html/htmlatr.cxx | 40 |
3 files changed, 43 insertions, 21 deletions
diff --git a/sw/qa/extras/htmlexport/data/tdf160390.fodt b/sw/qa/extras/htmlexport/data/tdf160390.fodt new file mode 100644 index 000000000000..53d6144ff19b --- /dev/null +++ b/sw/qa/extras/htmlexport/data/tdf160390.fodt @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph"> + <style:text-properties style:text-underline-style="solid" fo:font-weight="bold"/> + </style:style> + <style:style style:name="T1" style:family="text"> + <style:text-properties style:text-underline-style="none" fo:font-weight="normal"/> + </style:style> + </office:automatic-styles> + <office:body> + <office:text> + <text:p text:style-name="P1">foo<text:span text:style-name="T1"> </text:span></text:p> + </office:text> + </office:body> +</office:document>
\ No newline at end of file diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index de2e9da4c678..42099f3bc44f 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -3053,6 +3053,13 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_Tdf160017_spanClosingOrder) CPPUNIT_ASSERT(parseXml(maTempFile)); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_Tdf160390) +{ + // This document must not hang infinitely on HTML export + createSwDoc("tdf160390.fodt"); + ExportToHTML(); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index c880082018f1..f298f93dc5b2 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -1524,8 +1524,9 @@ void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart, for (auto it = items.begin(); it != items.end();) { - HTMLStartEndPos* pTest = *it; - sal_Int32 nTestEnd = pTest->GetEnd(); + auto itTest = it++; // forward early, allow 'continue', and keep a copy for 'erase' + HTMLStartEndPos* pTest = *itTest; + const sal_Int32 nTestEnd = pTest->GetEnd(); if (nTestEnd <= nStart) continue; @@ -1533,28 +1534,25 @@ void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart, const SfxPoolItem& rTestItem = pTest->GetItem(); // only the corresponding OnTag attributes have to be considered - if (rTestItem.Which() == nWhich && HTML_ON_VALUE == GetHTMLItemState(rTestItem)) - { - // if necessary, insert the second part of the split - // attribute - if (nTestEnd > nEnd) - InsertItem(pTest->GetItem(), nEnd, nTestEnd); + if (rTestItem.Which() != nWhich || HTML_ON_VALUE != GetHTMLItemState(rTestItem)) + continue; - if (nTestStart >= nStart) - { - // the Test item only starts after the new end of the - // attribute. Therefore, it can be completely erased. - it = items.erase(it); - std::erase(m_aEndLst[pTest->GetEnd()], pTest); - delete pTest; - continue; - } + // if necessary, insert the second part of the split attribute + if (nTestEnd > nEnd) + InsertItem(rTestItem, nEnd, nTestEnd); - // the start of the new attribute corresponds to the new - // end of the attribute - FixSplittedItem(pTest, nStart); + if (nTestStart >= nStart) + { + // the Test item only starts after the new end of the + // attribute. Therefore, it can be completely erased. + it = items.erase(itTest); + std::erase(m_aEndLst[nTestEnd], pTest); + delete pTest; + continue; } - ++it; + + // the start of the new attribute corresponds to the new end of the attribute + FixSplittedItem(pTest, nStart); } } } |