[Libreoffice-commits] core.git: sw/qa sw/source

YogeshBharate yogesh.bharate at synerzip.com
Mon May 12 00:24:25 PDT 2014


 sw/qa/extras/ooxmlexport/data/tablePreferredWidth.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx               |   13 +++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx           |   19 ++++++++++++++---
 3 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit 533e435acd116615b4c6d4872f51b467d623ddd6
Author: YogeshBharate <yogesh.bharate at synerzip.com>
Date:   Thu May 8 13:04:08 2014 +0530

    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 at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/tablePreferredWidth.docx b/sw/qa/extras/ooxmlexport/data/tablePreferredWidth.docx
new file mode 100644
index 0000000..6546be9
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tablePreferredWidth.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 6564776..e2c7e58 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 4f29904..e969c0c 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
     {


More information about the Libreoffice-commits mailing list