diff options
author | YogeshBharate <yogesh.bharate@synerzip.com> | 2014-05-08 13:04:08 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-05-12 07:23:58 +0000 |
commit | 533e435acd116615b4c6d4872f51b467d623ddd6 (patch) | |
tree | 8d7a5e352174059b6834a5bdefd6723e934f6042 /sw | |
parent | 30d6bf6f25c1531e10454739b791ee572b59b251 (diff) |
fdo#78325: Table Preferred width in percent is not preserved after RT.
Problem Description :
- After RT, table preferred width in percent is change to '0'.
- After RT, width type change to 'auto' instead of 'pct'.
XML Difference:
In Original : <w:tblW w:w="3000" w:type="pct" />
In Roundtrip : <w:tblW w:w="0" w:type="auto" />
Change-Id: I20f4011520715b7c1555e82dd1ca590c4b1b9b3a
Reviewed-on: https://gerrit.libreoffice.org/9277
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tablePreferredWidth.docx | bin | 0 -> 13130 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 19 |
3 files changed, 29 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tablePreferredWidth.docx b/sw/qa/extras/ooxmlexport/data/tablePreferredWidth.docx Binary files differnew file mode 100644 index 000000000000..6546be9b63ed --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tablePreferredWidth.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 65647768a5b1..e2c7e5867b13 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3217,6 +3217,19 @@ DECLARE_OOXMLEXPORT_TEST(testFloatingTable, "fdo77887.docx") } +DECLARE_OOXMLEXPORT_TEST(testTablePreferredWidth, "tablePreferredWidth.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if(!pXmlDoc) + return; + + // Problem :If the table preferred width is in percent, then after RT it changes to 0 & width type changes + // to 'auto' instead of 'pct'. + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "w", "3000"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "type","pct"); +} + DECLARE_OOXMLEXPORT_TEST(testFDO75431, "fdo75431.docx") { xmlDocPtr pXmlDoc = parseExport("word/document.xml"); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 4f299049c235..e969c0c8f07d 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2679,17 +2679,30 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t const char* widthType = "dxa"; bool bRelBoxSize = false; - // If actual width of table is relative it shoud export is as "auto". + // If actual width of table is relative it shoud export is as "pct".` const SwTable *pTable = pTableTextNodeInfoInner->getTable(); SwFrmFmt *pTblFmt = pTable->GetFrmFmt( ); + const SwFmtFrmSize &rSize = pTblFmt->GetFrmSize(); + int nWidthPercent = rSize.GetWidthPercent(); uno::Reference<beans::XPropertySet> xPropertySet(SwXTextTables::GetObject(const_cast<SwFrmFmt&>(*pTable->GetFrmFmt( ))),uno::UNO_QUERY); bool isWidthRelative = false; xPropertySet->getPropertyValue("IsWidthRelative") >>= isWidthRelative; if(isWidthRelative) { - nPageSize = 0; - widthType = "auto"; + /** + * As per ECMA Specification : ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference [ 17.18.90 ST_TblWidth (Table Width Units)] + * http://www.schemacentral.com/sc/ooxml/a-w_type-7.html + * + * Fiftieths of a Percent : + * http://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/ + * pct Width is in Fiftieths of a Percent + * + * ex. If the Table width is 50% then + * Width in Fiftieths of a percent is (50 * 50) % or 0.5 * 5000 = 2500pct + **/ + nPageSize = nWidthPercent * 50 ; + widthType = "pct" ; } else { |