diff options
author | sushil_shinde <sushil.shinde@synerzip.com> | 2014-01-22 17:11:58 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-13 10:49:56 +0100 |
commit | 18044a60957e21222f642b41b03ca1f28716a6d7 (patch) | |
tree | f966b97f1e70502ee3581fd777f4ab5aa7bdc205 | |
parent | d19598b56c8bec688d1944cd167f32a369344100 (diff) |
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
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/Table_cell_auto_width_fdo69656.docx | bin | 0 -> 18939 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 33 |
3 files changed, 34 insertions, 9 deletions
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 Binary files differnew file mode 100644 index 000000000000..10b8f9de21d8 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/Table_cell_auto_width_fdo69656.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 94df3e8c0c28..b11f4ca2d34d 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 1467692bac2a..97ec8b7b5007 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( ) ) |