summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-03-27 16:01:51 +0500
committerXisco Fauli <xiscofauli@libreoffice.org>2024-03-27 22:03:48 +0100
commit832fb1ab9abf94f4074e0cc20d846c1536931cf3 (patch)
tree33023403db8dc82dfb031f010c48091ed6e15438
parent15c04b923b7b86b3f63b9ea62b0005ea101f9217 (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
-rw-r--r--sw/qa/extras/htmlexport/data/tdf160390.fodt17
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx7
-rw-r--r--sw/source/filter/html/htmlatr.cxx40
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);
}
}
}