sw/qa/filter/html/html.cxx | 36 ++++++++++++++++++++++++++++++++++++ sw/source/filter/html/htmltabw.cxx | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-)
New commits: commit b4c3291630610d38270d7d8ccda5f810b3e05d63 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Jan 5 13:56:23 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Jan 5 14:48:32 2023 +0000 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. Change-Id: I68804dd2ce45b0579287aeccbb550b174859f7ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145081 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/filter/html/html.cxx b/sw/qa/filter/html/html.cxx index 6cb4a91cd393..4ec815da0c56 100644 --- a/sw/qa/filter/html/html.cxx +++ b/sw/qa/filter/html/html.cxx @@ -15,6 +15,9 @@ #include <fmtfsize.hxx> #include <frameformats.hxx> #include <unotxdoc.hxx> +#include <itabenum.hxx> +#include <wrtsh.hxx> +#include <cellatr.hxx> namespace { @@ -126,6 +129,39 @@ 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: + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0); + pWrtShell->InsertTable(aTableOptions, 1, 1); + pWrtShell->MoveTable(GotoPrevTable, fnTableStart); + SwTableNode* pTableNode = pWrtShell->GetCursor()->GetPointNode().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)"); + + // 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 b6aeb137e4bb..43e9ebf97328 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -450,7 +450,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()));