tdf#171772 - Properly close ins/del tag to prevent persistent formatting

Change-Id: I99a8dbed6075e05a70852d1165df4f6b30e56e39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203720
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
This commit is contained in:
Andreas Heinisch
2026-04-16 17:49:41 +02:00
parent 9d6c75db62
commit d8b8dd009b
4 changed files with 46 additions and 3 deletions
@@ -0,0 +1,2 @@
<p><ins>ins</ins></p>
<p>auto</p>
@@ -0,0 +1,6 @@
<p><s>s</s></p>
<p>auto</p>
<p><strike>strike</strike></p>
<p>auto</p>
<p><del>del</del></p>
<p>auto</p>
+31 -1
View File
@@ -417,11 +417,29 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf79298StrikeoutVariants)
getProperty<sal_Int16>(getRun(getParagraph(3), 1), u"CharStrikeout"_ustr));
}
CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf171772StrikeoutVariants)
{
createSwWebDoc("tdf171772-strikeout-variants.html");
// Without the accompanying fix in place, this tests would have failed with:
// - Expected: 0 (FontStrikeout::NONE)
// - Actual : 1 (FontStrikeout::SINGLE)
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Strikeout for <del> not properly closed", sal_Int16(awt::FontStrikeout::NONE),
getProperty<sal_Int16>(getRun(getParagraph(2), 1), u"CharStrikeout"_ustr));
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Strikeout for <s> not properly closed", sal_Int16(awt::FontStrikeout::NONE),
getProperty<sal_Int16>(getRun(getParagraph(4), 1), u"CharStrikeout"_ustr));
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Strikeout for <strike> not properly closed", sal_Int16(awt::FontStrikeout::NONE),
getProperty<sal_Int16>(getRun(getParagraph(6), 1), u"CharStrikeout"_ustr));
}
CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf132770InsertedText)
{
createSwWebDoc("tdf132770-inserted-text.html");
// Without the accompanying fix in place, this tests would have failed with:
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1 (FontLineStyle::LINESTYLE_SINGLE)
// - Actual : 0 (FontLineStyle::NONE)
CPPUNIT_ASSERT_EQUAL_MESSAGE(
@@ -429,6 +447,18 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf132770InsertedText)
getProperty<sal_Int16>(getRun(getParagraph(1), 1), u"CharUnderline"_ustr));
}
CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf171772InsertedText)
{
createSwWebDoc("tdf171772-inserted-text.html");
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 0 (FontLineStyle::NONE)
// - Actual : 1 (FontLineStyle::LINESTYLE_SINGLE)
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Underline for <ins> not properly closed", sal_Int16(awt::FontUnderline::NONE),
getProperty<sal_Int16>(getRun(getParagraph(2), 1), u"CharUnderline"_ustr));
}
CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf142781)
{
// FIXME: the DPI check should be removed when either (1) the test is fixed to work with
+7 -2
View File
@@ -1948,6 +1948,13 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
EndTag( nToken );
break;
// tdf#171772 - properly close inserted tag to prevent persistent underline
case HtmlTokenId::INSERTEDTEXT_OFF:
EndTag(HtmlTokenId::UNDERLINE_OFF);
break;
// tdf#171772 - properly close deleted tag to prevent persistent strikethrough
case HtmlTokenId::DELETEDTEXT_OFF:
case HtmlTokenId::STRIKETHROUGH_OFF:
EndTag( HtmlTokenId::STRIKE_OFF );
break;
@@ -2007,8 +2014,6 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
case HtmlTokenId::PERSON_OFF:
case HtmlTokenId::ACRONYM_OFF:
case HtmlTokenId::ABBREVIATION_OFF:
case HtmlTokenId::INSERTEDTEXT_OFF:
case HtmlTokenId::DELETEDTEXT_OFF:
case HtmlTokenId::TELETYPE_OFF:
EndTag( nToken );