From 2d9f739ccfead38cdaa13780f7bb5172553dbd77 Mon Sep 17 00:00:00 2001 From: Svante Schubert Date: Wed, 17 May 2023 17:44:39 +0200 Subject: [PATCH] tdf#155244 filter: XHTML export: Making ODF style IDs unique for ... ... HTML/CSS by adding a prefix (the @style:family with '-' as glue character) to their style name. Disabled debug output for style:family-name in XSL add text:a to text family ... and add a unit test. Change-Id: Ie846f5ea2a872872f38036aff59d29c8f530ed32 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152749 Tested-by: Jenkins Reviewed-by: Michael Stahl --- .../export/common/table/table_rows.xsl | 5 +- .../export/common/table_of_content.xsl | 25 +- .../xslt/odf2xhtml/export/xhtml/body.xsl | 345 ++++++++++++++++-- .../xslt/odf2xhtml/export/xhtml/header.xsl | 7 +- .../xslt/odf2xhtml/export/xhtml/table.xsl | 6 +- sc/CppunitTest_sc_html_export_test.mk | 5 + sc/qa/extras/htmlexporttest.cxx | 18 + sc/qa/extras/testdocuments/default-styles.ods | Bin 0 -> 8881 bytes sw/qa/extras/htmlexport/xhtmlexport.cxx | 23 +- 9 files changed, 394 insertions(+), 40 deletions(-) create mode 100644 sc/qa/extras/testdocuments/default-styles.ods diff --git a/filter/source/xslt/odf2xhtml/export/common/table/table_rows.xsl b/filter/source/xslt/odf2xhtml/export/common/table/table_rows.xsl index 2d6cd7285037..60b47be753ca 100644 --- a/filter/source/xslt/odf2xhtml/export/common/table/table_rows.xsl +++ b/filter/source/xslt/odf2xhtml/export/common/table/table_rows.xsl @@ -196,7 +196,10 @@ - + + + + diff --git a/filter/source/xslt/odf2xhtml/export/common/table_of_content.xsl b/filter/source/xslt/odf2xhtml/export/common/table_of_content.xsl index 7a04bee074a8..0f36b36486de 100644 --- a/filter/source/xslt/odf2xhtml/export/common/table_of_content.xsl +++ b/filter/source/xslt/odf2xhtml/export/common/table_of_content.xsl @@ -93,7 +93,10 @@ - + + + + @@ -317,7 +320,10 @@ Scenarios unmatched: - + + + + @@ -341,7 +347,10 @@ Scenarios unmatched: - + + + + @@ -358,7 +367,10 @@ Scenarios unmatched: - + + + + @@ -382,7 +394,10 @@ Scenarios unmatched: - + + + + diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl index 9706c1df0615..7b3c7e4d3b17 100644 --- a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl +++ b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl @@ -19,7 +19,7 @@ - + @@ -1207,7 +1207,10 @@ NOTE: Should be handled as CSS style in style header --> - + + + + @@ -2847,29 +2850,329 @@ - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + chart + + + + page + + + + graphic + + + + paragraph + + + + presentation + + + + ruby + + + + section + + + + table + + + + cell + + + + col + + + + row + + + + text + + + WARNING: No style family found for + unknown-family + + + + + + + + + + + + + + chart + + + + drawing-page + + + + graphic + + + + paragraph + + + + presentation + + + + ruby + + + + section + + + + table + + + + table-cell + + + + table-column + + + + table-row + + + + text + + + WARNING: No style family found for parent element + unknown-family-parent + + + + diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/header.xsl b/filter/source/xslt/odf2xhtml/export/xhtml/header.xsl index 8ee38796ebdf..bdd2d05b0925 100644 --- a/filter/source/xslt/odf2xhtml/export/xhtml/header.xsl +++ b/filter/source/xslt/odf2xhtml/export/xhtml/header.xsl @@ -129,7 +129,12 @@ - . { } + . + + + + + { } diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/table.xsl b/filter/source/xslt/odf2xhtml/export/xhtml/table.xsl index 8448665d20b3..0788b2bf52a9 100644 --- a/filter/source/xslt/odf2xhtml/export/xhtml/table.xsl +++ b/filter/source/xslt/odf2xhtml/export/xhtml/table.xsl @@ -206,8 +206,10 @@ - + + + + - diff --git a/sc/CppunitTest_sc_html_export_test.mk b/sc/CppunitTest_sc_html_export_test.mk index f9da77710a29..bc64eb5b7803 100644 --- a/sc/CppunitTest_sc_html_export_test.mk +++ b/sc/CppunitTest_sc_html_export_test.mk @@ -67,6 +67,11 @@ $(eval $(call gb_CppunitTest_use_api,sc_html_export_test,\ oovbaapi \ )) +$(eval $(call gb_CppunitTest_use_packages,sc_html_export_test, \ + filter_xhtml \ + filter_xslt \ +)) + $(eval $(call gb_CppunitTest_use_ure,sc_html_export_test)) $(eval $(call gb_CppunitTest_use_vcl,sc_html_export_test)) diff --git a/sc/qa/extras/htmlexporttest.cxx b/sc/qa/extras/htmlexporttest.cxx index f65e027ae62e..6e28d791fbb3 100644 --- a/sc/qa/extras/htmlexporttest.cxx +++ b/sc/qa/extras/htmlexporttest.cxx @@ -50,8 +50,26 @@ public: assertXPath(pDoc, "/html/body/table/tr/td/img", 0); } + void testTdf155244() + { + loadFromURL(u"default-styles.ods"); + save("XHTML Calc File"); + + xmlDocUniquePtr pXmlDoc = parseXml(maTempFile); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/xhtml:html", 1); + // the problem was that there were 2 CSS styles named "Default" + assertXPath(pXmlDoc, "/xhtml:html/xhtml:body/xhtml:table/xhtml:tr/xhtml:td", "class", "cell-Default"); + OUString const styles = getXPathContent(pXmlDoc, "/xhtml:html/xhtml:head/xhtml:style"); + CPPUNIT_ASSERT(styles.indexOf(".graphic-Default{ background-color:#729fcf;") != -1); + CPPUNIT_ASSERT(styles.indexOf(".cell-Default{ font-size:10pt; font-family:'Liberation Sans'; }") != -1); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), styles.indexOf(".Default")); + } + CPPUNIT_TEST_SUITE(ScHTMLExportTest); CPPUNIT_TEST(testHtmlSkipImage); + CPPUNIT_TEST(testTdf155244); CPPUNIT_TEST_SUITE_END(); }; diff --git a/sc/qa/extras/testdocuments/default-styles.ods b/sc/qa/extras/testdocuments/default-styles.ods new file mode 100644 index 0000000000000000000000000000000000000000..d2167ed2023b4d1348b86d96e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X@3SXV>5+o}}tH(@sM_!YV~B(8+MfwmpO zU_+j}v-Tn%a2ExH7)|@0@ojJrd)a=1+c6WA!`7mRmjOWbaTDrvG7H(`ashXzX1tr7 z3N=J+80E0ANv1WnA)My$WqDQ3Mk6ENUeR~`t>X@83AKcKj0XhU$=20ow?`)(Y78bgvqedMwUl5x;2i zESs+v<7mzs*Rto&fOHqEN|lXS>eC*(7wYW5Ti!BxuHWFU={U1)Wy5XNiM^&~hP5S* z%M=QXqsCc|w7|NLA3xHUpPfL~TLN^;?@?ZBp504G}yx8-BTt^w=9cvb;C$JVztiU#vB! zU)VHB;dg%v6O%Xn|o6irylbi4+Za6fd6$w zrkNWBYtvH$hg-u^Q$*U$MnYuwC6RLgL${>5Wo%wpi}s^sf@<@@EJW++tV`SOH}y*) z4$4sTgzDsV9^^rdQRuC~2lzf^n?%xND!X>5?lS^PR6g%l0V49u!8@x%m zviVQ2A9>{8+cWo zcg-KUy(^OTTEZ_ESeJjF_=~drr`C_B_*cB&wb)%2H=}D7@Slo5Ze6dIbk|aUxuLy2 z^8csakL$>v2Z(Uz=WXtH&EKsvuPqi5{(jZ@9p&#Z{ZKuw>hiTTU(StRR%vB96x6HR Pa4$b5mqmw%;;Q#wzMt$s literal 0 HcmV?d00001 diff --git a/sw/qa/extras/htmlexport/xhtmlexport.cxx b/sw/qa/extras/htmlexport/xhtmlexport.cxx index 923c3fecda8a..299b5ff6b5c8 100644 --- a/sw/qa/extras/htmlexport/xhtmlexport.cxx +++ b/sw/qa/extras/htmlexport/xhtmlexport.cxx @@ -49,7 +49,7 @@ DECLARE_HTMLEXPORT_TEST(testTdf131812, "tdf131812.odt") sal_uInt64 nLength = pStream->TellEnd(); OString aStream(read_uInt8s_ToOString(*pStream, nLength)); CPPUNIT_ASSERT( - aStream.indexOf(".P1 { font-size:12pt; font-family:\'Liberation Serif\'; " + aStream.indexOf(".paragraph-P1{ font-size:12pt; font-family:\'Liberation Serif\'; " "writing-mode:horizontal-tb; direction:rtl; text-align:right ! important;}") != -1); } @@ -138,18 +138,20 @@ DECLARE_HTMLEXPORT_TEST(testTdf107696, "tdf107696.odt") CPPUNIT_ASSERT(aStream.indexOf("span.heading_numbering { margin-right: 0.8rem; }* { margin:0;}") != -1); CPPUNIT_ASSERT( - aStream.indexOf("

Level 2 without number

") != -1); CPPUNIT_ASSERT( - aStream.indexOf("

3.1Level 2, number 3.1

") + aStream.indexOf( + "

3.1Level 2, number 3.1

") != -1); CPPUNIT_ASSERT( - aStream.indexOf("

3.2Level 2, number 3.2

") + aStream.indexOf( + "

3.2Level 2, number 3.2

") != -1); } @@ -160,8 +162,9 @@ DECLARE_HTMLEXPORT_TEST(testTdf66305, "tdf66305.odt") sal_uInt64 nLength = pStream->TellEnd(); OString aStream(read_uInt8s_ToOString(*pStream, nLength)); CPPUNIT_ASSERT( - aStream.indexOf("

Introduction

 

") + aStream.indexOf("

Introduction

 

") != -1); }