summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-01-05 13:56:23 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2023-01-10 11:19:10 +0000
commit957dd409411ea490958f3c014a71b7361c00b8c4 (patch)
tree54d32c4549f447d630436780a38553477f7e9f59
parentRevert "Resolves tdf#143100 - Disable cell style commands when sheet is prote... (diff)
downloadcore-957dd409411ea490958f3c014a71b7361c00b8c4.tar.gz
core-957dd409411ea490958f3c014a71b7361c00b8c4.zip
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 <vmiklos@collabora.com> Tested-by: Jenkins (cherry picked from commit b4c3291630610d38270d7d8ccda5f810b3e05d63) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145215 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r--sw/qa/filter/html/html.cxx36
-rw-r--r--sw/source/filter/html/htmltabw.cxx2
2 files changed, 37 insertions, 1 deletions
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()));