sc/qa/filter/html/data/tdf132770_inserted_text.html | 1 sc/qa/filter/html/html.cxx | 24 ++++++++++++++ sc/source/filter/html/htmlpars.cxx | 2 + sw/qa/extras/htmlimport/data/tdf132770-inserted-text.html | 1 sw/qa/extras/htmlimport/htmlimport.cxx | 12 +++++++ sw/source/filter/html/swhtml.cxx | 2 - 6 files changed, 41 insertions(+), 1 deletion(-)
New commits: commit 7112bc2a98b06217302fb18e52fcbd03f8744f79 Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Sat Jan 4 11:44:39 2025 +0100 Commit: Andreas Heinisch <andreas.heini...@yahoo.de> CommitDate: Mon Jan 6 11:10:38 2025 +0100 tdf#132770 - FORMATTING: Import inserted text tag <ins> (underlined) Change-Id: I5819ce4d4551bbd781921d847131f15cf2b94a38 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179771 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> diff --git a/sc/qa/filter/html/data/tdf132770_inserted_text.html b/sc/qa/filter/html/data/tdf132770_inserted_text.html new file mode 100644 index 000000000000..d07966ffef47 --- /dev/null +++ b/sc/qa/filter/html/data/tdf132770_inserted_text.html @@ -0,0 +1 @@ +<p><ins>ins</ins></p> \ No newline at end of file diff --git a/sc/qa/filter/html/html.cxx b/sc/qa/filter/html/html.cxx index 2f6b9cb249b8..2c1d02aab0b5 100644 --- a/sc/qa/filter/html/html.cxx +++ b/sc/qa/filter/html/html.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/table/XCellRange.hpp> #include <editeng/crossedoutitem.hxx> +#include <editeng/udlnitem.hxx> #include <comphelper/propertyvalue.hxx> #include <svl/numformat.hxx> @@ -231,6 +232,29 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf79298_strikeout_variants) } } +CPPUNIT_TEST_FIXTURE(Test, testTdf132770_inserted_text) +{ + // Given a document with an inserted text tag <ins> + OUString aURL = createFileURL(u"tdf132770_inserted_text.html"); + + // When loading that document to Calc: + uno::Sequence<beans::PropertyValue> aParams = { + comphelper::makePropertyValue(u"DocumentService"_ustr, + u"com.sun.star.sheet.SpreadsheetDocument"_ustr), + }; + loadWithParams(aURL, aParams); + + // Verify HTML inserted text tag <ins> + ScDocument* pDoc = getScDoc(); + const ScPatternAttr* pAttr = pDoc->GetPattern(ScAddress(0, 0, 0)); + CPPUNIT_ASSERT_MESSAGE("Failed to get cell attribute.", pAttr); + const SvxUnderlineItem& rUnderlineItem = pAttr->GetItem(ATTR_FONT_UNDERLINE); + // Without the accompanying fix in place, this tests would have failed with: + // - Expected: 1 (FontLineStyle::LINESTYLE_SINGLE) + // - Actual : 0 (FontLineStyle::NONE) + CPPUNIT_ASSERT_EQUAL(FontLineStyle::LINESTYLE_SINGLE, rUnderlineItem.GetLineStyle()); +} + CPPUNIT_TEST_FIXTURE(Test, testCopyText) { // Given a document with 01 in A1: diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 6c225c3020c8..a4e0f7069a1f 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -1804,6 +1804,7 @@ void ScHTMLLayoutParser::ProcToken( HtmlImportInfo* pInfo ) } break; case HtmlTokenId::UNDERLINE_ON : + case HtmlTokenId::INSERTEDTEXT_ON: { if ( IsAtBeginningOfText( pInfo ) ) mxActEntry->aItemSet.Put( SvxUnderlineItem( LINESTYLE_SINGLE, @@ -3099,6 +3100,7 @@ void ScHTMLQueryParser::ProcessToken( const HtmlImportInfo& rInfo ) break; case HtmlTokenId::UNDERLINE_ON: // <u> + case HtmlTokenId::INSERTEDTEXT_ON: // <ins> mpCurrTable->PutItem( SvxUnderlineItem( LINESTYLE_SINGLE, ATTR_FONT_UNDERLINE ) ); break; default: break; diff --git a/sw/qa/extras/htmlimport/data/tdf132770-inserted-text.html b/sw/qa/extras/htmlimport/data/tdf132770-inserted-text.html new file mode 100644 index 000000000000..d07966ffef47 --- /dev/null +++ b/sw/qa/extras/htmlimport/data/tdf132770-inserted-text.html @@ -0,0 +1 @@ +<p><ins>ins</ins></p> \ No newline at end of file diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 746379b6f7b1..c118872158cb 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -395,6 +395,18 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf79298StrikeoutVariants) getProperty<sal_Int16>(getRun(getParagraph(3), 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: + // - Expected: 1 (FontLineStyle::LINESTYLE_SINGLE) + // - Actual : 0 (FontLineStyle::NONE) + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Underline for <ins> missing", sal_Int16(awt::FontUnderline::SINGLE), + getProperty<sal_Int16>(getRun(getParagraph(1), 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 diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 9488fb0dafff..01b0bdd31fbe 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -1897,6 +1897,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken ) break; case HtmlTokenId::UNDERLINE_ON: + case HtmlTokenId::INSERTEDTEXT_ON: { NewStdAttr( HtmlTokenId::UNDERLINE_ON, &m_xAttrTab->pUnderline, SvxUnderlineItem(LINESTYLE_SINGLE, RES_CHRATR_UNDERLINE) ); @@ -1974,7 +1975,6 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken ) case HtmlTokenId::PERSON_ON: case HtmlTokenId::ACRONYM_ON: case HtmlTokenId::ABBREVIATION_ON: - case HtmlTokenId::INSERTEDTEXT_ON: case HtmlTokenId::TELETYPE_ON: NewCharFormat( nToken );