sw/qa/filter/html/html.cxx | 37 +++++++++++++++++++++++++++++++++++++ sw/source/filter/html/htmltabw.cxx | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-)
New commits: commit 90441a276d14441f3f0c325f89338c535f6bdfbe Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Jan 5 13:56:23 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Jan 6 10:04:14 2023 +0100 sw XHTML export: avoid sdnum and sdval attributes on table cells These are not valid in XHTML, as the reqif validator points it out: ERROR at 239: [XSD] cvc-complex-type.3.2.2: Attribute 'sdval' is not allowed to appear in element 'td'. ERROR at 239: [XSD] cvc-complex-type.3.2.2: Attribute 'sdnum' is not allowed to appear in element 'td'. The actual cell contents is already there, so just omit this unwanted metadata in the XHTML case. (cherry picked from commit b4c3291630610d38270d7d8ccda5f810b3e05d63) Change-Id: I68804dd2ce45b0579287aeccbb550b174859f7ba diff --git a/sw/qa/filter/html/html.cxx b/sw/qa/filter/html/html.cxx index 5fb02c46e2c4..f3b31efa7fe6 100644 --- a/sw/qa/filter/html/html.cxx +++ b/sw/qa/filter/html/html.cxx @@ -16,6 +16,9 @@ #include <fmtfsize.hxx> #include <frameformats.hxx> #include <unotxdoc.hxx> +#include <itabenum.hxx> +#include <wrtsh.hxx> +#include <cellatr.hxx> namespace { @@ -144,6 +147,40 @@ CPPUNIT_TEST_FIXTURE(Test, testSvmImageExport) // i.e. we wrote both GIF and PNG, not just PNG for SVM images. assertXPath(pXmlDoc, "//reqif-xhtml:object", "type", "image/png"); } + +CPPUNIT_TEST_FIXTURE(Test, testTableCellFloatValueType) +{ + // Given a document with a single table cell, its cell value is set to double: + loadURL("private:factory/swriter", nullptr); + auto pTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDoc* pDoc = pTextDocument->GetDocShell()->GetDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0); + pWrtShell->InsertTable(aTableOptions, 1, 1); + pWrtShell->MoveTable(GotoPrevTable, fnTableStart); + SwTableNode* pTableNode = pWrtShell->GetCursor()->GetNode().FindTableNode(); + SwTable& rTable = pTableNode->GetTable(); + auto pBox = const_cast<SwTableBox*>(rTable.GetTableBox("A1")); + SwFrameFormat* pBoxFormat = pBox->ClaimFrameFormat(); + SwAttrSet aSet(pBoxFormat->GetAttrSet()); + SwTableBoxValue aBoxValue(42.0); + aSet.Put(aBoxValue); + pBoxFormat->GetDoc()->SetAttr(aSet, *pBoxFormat); + + // When exporting to XHTML: + setFilterOptions("xhtmlns=reqif-xhtml"); + save("HTML (StarWriter)", maTempFile); + + // Then make sure that the sdval attribute is omitted, which is not in the XHTML spec: + SvMemoryStream aStream; + WrapReqifFromTempFile(aStream); + xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + // Without the accompanying fix in place, this test would have failed with: + // - XPath '//reqif-xhtml:td' unexpected 'sdval' attribute + // i.e. sdval was written in XHTML mode. + assertXPathNoAttribute(pXmlDoc, "//reqif-xhtml:td", "sdval"); + assertXPathNoAttribute(pXmlDoc, "//reqif-xhtml:td", "sdnum"); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index 81a7daf570a0..73c1e1336e98 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -455,7 +455,7 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt, nNumFormat = pBox->GetFrameFormat()->GetTableBoxNumFormat().GetValue(); } - if( bNumFormat || bValue ) + if ((bNumFormat || bValue) && !rWrt.mbXHTML) { sOut.append(HTMLOutFuncs::CreateTableDataOptionsValNum(bValue, nValue, nNumFormat, *rWrt.m_pDoc->GetNumberFormatter(), rWrt.m_eDestEnc,