From 8be3ae254f5b2ff76d9861ad4b9b5b5de5d14bb4 Mon Sep 17 00:00:00 2001 From: Louis Meyrat Date: Sun, 12 Jan 2020 17:26:09 +0100 Subject: tdf#128290 add tblLayout element to docx export This will disable the automatic table width feature of MS Word, which does not exist in LO. Now, tables in LO-generated docx have the same column width in MS Word Change-Id: I955c8e5667376475e7c41e3b74d88e3513fec561 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86671 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sw/qa/extras/ooxmlexport/data/tdf128290.odt | Bin 0 -> 9782 bytes sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 7 +++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 4 ++++ 3 files changed, 11 insertions(+) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf128290.odt (limited to 'sw') diff --git a/sw/qa/extras/ooxmlexport/data/tdf128290.odt b/sw/qa/extras/ooxmlexport/data/tdf128290.odt new file mode 100644 index 000000000000..81ea0c6773aa Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf128290.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 1835b92bec49..922cb9183adc 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -307,6 +307,13 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf77796, "tdf77796.docx") assertXPath(pXml, "/w:document/w:body/w:tbl/w:tblPr/w:tblCellMar/w:end", "w", "108"); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf128290, "tdf128290.odt") +{ + xmlDocPtr pXml = parseExport("word/document.xml"); + CPPUNIT_ASSERT(pXml); + assertXPath(pXml, "/w:document/w:body/w:tbl/w:tblPr/w:tblLayout", "type", "fixed"); +} + DECLARE_OOXMLIMPORT_TEST(testContSectBreakHeaderFooter, "cont-sect-break-header-footer.docx") { // Load a document with a continuous section break on page 2. diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 25b22b8df5ed..172205b11b50 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3771,6 +3771,10 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t FSNS( XML_w, XML_w ), OString::number(nPageSize), FSNS( XML_w, XML_type ), widthType ); + // Disable layout autofit, as it does not exist in LibreOffice yet + m_pSerializer->singleElementNS( XML_w, XML_tblLayout, + FSNS( XML_w, XML_type ), "fixed" ); + // Look for the table style property in the table grab bag std::map aGrabBag = pTableFormat->GetAttrSet().GetItem(RES_FRMATR_GRABBAG)->GetGrabBag(); -- cgit