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

sushil_shinde sushil.shinde at synerzip.com
Thu Feb 13 10:50:19 CET 2014


 sw/qa/extras/ooxmlexport/data/Table_cell_auto_width_fdo69656.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx                          |   10 +++
 sw/source/filter/ww8/docxattributeoutput.cxx                      |   33 +++++++---
 3 files changed, 34 insertions(+), 9 deletions(-)

New commits:
commit 18044a60957e21222f642b41b03ca1f28716a6d7
Author: sushil_shinde <sushil.shinde at synerzip.com>
Date:   Wed Jan 22 17:11:58 2014 +0530

    fdo#69646 Export of table with auto-width, at least one column with auto-width
    
     - In case of auto width to table it should export as auto.
     - Added Unit Test to check it is properly exporting table.
    
    Conflicts:
    	sw/qa/extras/ooxmlexport/ooxmlexport.cxx
    Reviewed on:
    	https://gerrit.libreoffice.org/7594
    
    Change-Id: Id448111b81110bbc6c109f3da9195075b9b8a9fc

diff --git a/sw/qa/extras/ooxmlexport/data/Table_cell_auto_width_fdo69656.docx b/sw/qa/extras/ooxmlexport/data/Table_cell_auto_width_fdo69656.docx
new file mode 100644
index 0000000..10b8f9d
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/Table_cell_auto_width_fdo69656.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 94df3e8..b11f4ca 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2964,6 +2964,16 @@ DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillBitmapCrop, "dml-shape-fillbitmapcrop.d
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Bottom );
 
 }
+
+DECLARE_OOXMLEXPORT_TEST(fdo69656, "Table_cell_auto_width_fdo69656.docx")
+{
+    // Check for the width type of table and its cells.
+    xmlDocPtr pXmlDoc = parseExport();
+    if (!pXmlDoc)
+        return;
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblW","type","auto");
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1467692..97ec8b7 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2234,21 +2234,36 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
     m_pSerializer->mark( aSeqOrder );
 
     sal_uInt32 nPageSize = 0;
+    const char* widthType = "dxa";
     bool bRelBoxSize = false;
 
-    // Create the SwWriteTable instance to use col spans (and maybe other infos)
-    GetTablePageSize( pTableTextNodeInfoInner.get(), nPageSize, bRelBoxSize );
+    // If actual width of table is relative it shoud export is as "auto".
+    const SwTable *pTable = pTableTextNodeInfoInner->getTable();
+    SwFrmFmt *pTblFmt = pTable->GetFrmFmt( );
+    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";
+    }
+    else
+    {
+        // Create the SwWriteTable instance to use col spans (and maybe other infos)
+        GetTablePageSize( pTableTextNodeInfoInner.get(), nPageSize, bRelBoxSize );
+        if(nPageSize == 0)
+            widthType = "auto";
+    }
 
     // Output the table preferred width
-    if ( nPageSize != 0 )
-        m_pSerializer->singleElementNS( XML_w, XML_tblW,
-                FSNS( XML_w, XML_w ), OString::number( nPageSize ).getStr( ),
-                FSNS( XML_w, XML_type ), "dxa",
-                FSEND );
+    m_pSerializer->singleElementNS( XML_w, XML_tblW,
+            FSNS( XML_w, XML_w ), OString::number( nPageSize ).getStr( ),
+            FSNS( XML_w, XML_type ), widthType,
+            FSEND );
 
     // Output the table alignement
-    const SwTable *pTable = pTableTextNodeInfoInner->getTable();
-    SwFrmFmt *pTblFmt = pTable->GetFrmFmt( );
     const char* pJcVal;
     sal_Int32 nIndent = 0;
     switch ( pTblFmt->GetHoriOrient( ).GetHoriOrient( ) )


More information about the Libreoffice-commits mailing list