diff --git a/sw/qa/extras/htmlimport/data/tdf121049-subscript-class.html b/sw/qa/extras/htmlimport/data/tdf121049-subscript-class.html new file mode 100644 index 000000000000..aa248232079f --- /dev/null +++ b/sw/qa/extras/htmlimport/data/tdf121049-subscript-class.html @@ -0,0 +1 @@ +

sub

diff --git a/sw/qa/extras/htmlimport/data/tdf121049-superscript-class.html b/sw/qa/extras/htmlimport/data/tdf121049-superscript-class.html new file mode 100644 index 000000000000..fce537d0fd0f --- /dev/null +++ b/sw/qa/extras/htmlimport/data/tdf121049-superscript-class.html @@ -0,0 +1 @@ +

sup

diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index c624ef8a1970..dcf6aea64efd 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -9,6 +9,8 @@ #include +#include + #include #include #include @@ -342,6 +344,30 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf80194_subscript) CPPUNIT_ASSERT( 70 < getProperty(xRun, u"CharEscapementHeight"_ustr)); } +CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf121049Superscript) +{ + createSwWebDoc("tdf121049-superscript-class.html"); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 33 (DFLT_ESC_SUPER) + // - Actual : 0 (SvxEscapement::Off) + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Superscript for missing", sal_Int32(DFLT_ESC_SUPER), + getProperty(getRun(getParagraph(1), 1), u"CharEscapement"_ustr)); +} + +CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf121049Subscript) +{ + createSwWebDoc("tdf121049-subscript-class.html"); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: -8 (DFLT_ESC_SUB) + // - Actual : 0 (SvxEscapement::Off) + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Subscript for missing", sal_Int32(DFLT_ESC_SUB), + getProperty(getRun(getParagraph(1), 1), u"CharEscapement"_ustr)); +} + CPPUNIT_TEST_FIXTURE(HtmlImportTest, testReqIfTable) { setImportFilterName(TestFilter::HTML_WRITER); diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx index b96a8b119ca7..52b43bac388e 100644 --- a/sw/source/filter/html/htmlcss1.cxx +++ b/sw/source/filter/html/htmlcss1.cxx @@ -77,6 +77,8 @@ const sal_uInt16 aItemIds[] = RES_BREAK, RES_PAGEDESC, RES_KEEP, + // tdf#121049 - preserve superscript/subscript when pasting HTML with class definition + RES_CHRATR_ESCAPEMENT, }; void SwCSS1Parser::ChgPageDesc( const SwPageDesc *pPageDesc,