diff --git a/sc/qa/filter/html/data/tdf79298_strikeout_variants.html b/sc/qa/filter/html/data/tdf79298_strikeout_variants.html new file mode 100644 index 000000000000..391ddf095c2b --- /dev/null +++ b/sc/qa/filter/html/data/tdf79298_strikeout_variants.html @@ -0,0 +1,3 @@ +

s

+

strike

+

del

\ No newline at end of file diff --git a/sc/qa/filter/html/html.cxx b/sc/qa/filter/html/html.cxx index c243dea350b0..2f6b9cb249b8 100644 --- a/sc/qa/filter/html/html.cxx +++ b/sc/qa/filter/html/html.cxx @@ -13,6 +13,8 @@ #include #include +#include + #include #include #include @@ -205,6 +207,30 @@ CPPUNIT_TEST_FIXTURE(Test, testPasteSingleCell) CPPUNIT_ASSERT_EQUAL(static_cast(3), pDoc->GetValue(/*col=*/2, /*row=*/0, /*tab=*/0)); } +CPPUNIT_TEST_FIXTURE(Test, testTdf79298_strikeout_variants) +{ + createScDoc(); + + // Paste different strikeout variants into the first cell + ScDocument* pDoc = getScDoc(); + ScAddress aCellPos(/*nColP=*/0, /*nRowP=*/0, /*nTabP=*/0); + ScImportExport aImporter(*pDoc, aCellPos); + SvFileStream aFile(createFileURL(u"tdf79298_strikeout_variants.html"), StreamMode::READ); + SvMemoryStream aMemory; + aMemory.WriteStream(aFile); + aMemory.Seek(0); + CPPUNIT_ASSERT(aImporter.ImportStream(aMemory, OUString(), SotClipboardFormatId::HTML)); + + // Verify HTML strikeout tags (, , and ) + for (size_t nCol = 0; nCol < 3; ++nCol) + { + const ScPatternAttr* pAttr = pDoc->GetPattern(ScAddress(0, nCol, 0)); + CPPUNIT_ASSERT_MESSAGE("Failed to get cell attribute.", pAttr); + const SvxCrossedOutItem& rCrossedOutItem = pAttr->GetItem(ATTR_FONT_CROSSEDOUT); + CPPUNIT_ASSERT_EQUAL(FontStrikeout::STRIKEOUT_SINGLE, rCrossedOutItem.GetStrikeout()); + } +} + 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 125d6e98ec80..6c225c3020c8 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -1794,6 +1795,14 @@ void ScHTMLLayoutParser::ProcToken( HtmlImportInfo* pInfo ) } } break; + case HtmlTokenId::STRIKE_ON: + case HtmlTokenId::STRIKETHROUGH_ON: + case HtmlTokenId::DELETEDTEXT_ON: + { + if (IsAtBeginningOfText(pInfo)) + mxActEntry->aItemSet.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE, ATTR_FONT_CROSSEDOUT)); + } + break; case HtmlTokenId::UNDERLINE_ON : { if ( IsAtBeginningOfText( pInfo ) ) diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index 5b6ad74377f9..8b5b5b58dfb9 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -246,6 +246,8 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu pAttrItemSet->Put( *pItem ); if ( rESet.GetItemState( ATTR_FONT_UNDERLINE, false, &pItem) == SfxItemState::SET ) pAttrItemSet->Put( *pItem ); + if ( rESet.GetItemState( ATTR_FONT_CROSSEDOUT, false, &pItem) == SfxItemState::SET ) + pAttrItemSet->Put( *pItem ); // HTML LATIN/CJK/CTL script type dependent const SfxPoolItem* pFont; if ( rESet.GetItemState( ATTR_FONT, false, &pFont) != SfxItemState::SET ) diff --git a/sw/qa/extras/htmlimport/data/tdf79298-strikeout-variants.html b/sw/qa/extras/htmlimport/data/tdf79298-strikeout-variants.html new file mode 100644 index 000000000000..391ddf095c2b --- /dev/null +++ b/sw/qa/extras/htmlimport/data/tdf79298-strikeout-variants.html @@ -0,0 +1,3 @@ +

s

+

strike

+

del

\ No newline at end of file diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 43163ce5a39a..746379b6f7b1 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -376,6 +377,24 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testImageSize) CPPUNIT_ASSERT_EQUAL(static_cast(aExpected.getHeight()), aSize.Height); } +CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf79298StrikeoutVariants) +{ + createSwWebDoc("tdf79298-strikeout-variants.html"); + + // Without the accompanying fix in place, this tests would have failed with: + // - Expected: 1 (FontStrikeout::SINGLE) + // - Actual : 0 (FontStrikeout::NONE) + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Strikeout for missing", sal_Int16(awt::FontStrikeout::SINGLE), + getProperty(getRun(getParagraph(1), 1), u"CharStrikeout"_ustr)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Strikeout for missing", sal_Int16(awt::FontStrikeout::SINGLE), + getProperty(getRun(getParagraph(2), 1), u"CharStrikeout"_ustr)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Strikeout for missing", sal_Int16(awt::FontStrikeout::SINGLE), + getProperty(getRun(getParagraph(3), 1), u"CharStrikeout"_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 fb0ed452336f..9488fb0dafff 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -1889,6 +1889,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken ) case HtmlTokenId::STRIKE_ON: case HtmlTokenId::STRIKETHROUGH_ON: + case HtmlTokenId::DELETEDTEXT_ON: { NewStdAttr( HtmlTokenId::STRIKE_ON, &m_xAttrTab->pStrike, SvxCrossedOutItem(STRIKEOUT_SINGLE, RES_CHRATR_CROSSEDOUT) ); @@ -1974,7 +1975,6 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken ) case HtmlTokenId::ACRONYM_ON: case HtmlTokenId::ABBREVIATION_ON: case HtmlTokenId::INSERTEDTEXT_ON: - case HtmlTokenId::DELETEDTEXT_ON: case HtmlTokenId::TELETYPE_ON: NewCharFormat( nToken );