sw/qa/extras/ooxmlexport/data/fdo77887.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 17 +++ sw/source/filter/ww8/docxattributeoutput.cxx | 57 +++++++++++++ writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 65 ++++++++++++--- writerfilter/source/dmapper/DomainMapperTableManager.cxx | 8 + writerfilter/source/dmapper/DomainMapperTableManager.hxx | 1 writerfilter/source/dmapper/TablePositionHandler.hxx | 42 +++++++++ 7 files changed, 179 insertions(+), 11 deletions(-)
New commits: commit cbcc6189e300b6aa5e9e8e6883598a4d28b770c0 Author: Ravindra Vidhate <ravindra.vidh...@synerzip.com> Date: Mon Apr 28 15:05:54 2014 +0530 fdo#77887 : Floating Table positions are not preserved when doing Export The margin of the floating table from top of the page is not being preserved correctly and it also get increased. The w:tblpPr tag is also not preserved. Reviewed on: https://gerrit.libreoffice.org/9185 Change-Id: I8a27a4bab94a1afd27a7ba49ca55ff014918fffc diff --git a/sw/qa/extras/ooxmlexport/data/fdo77887.docx b/sw/qa/extras/ooxmlexport/data/fdo77887.docx new file mode 100644 index 0000000..cb3f453 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo77887.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 44b9aa7..55b08e7 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3174,6 +3174,23 @@ DECLARE_OOXMLEXPORT_TEST(testFDO77117, "fdo77117.docx") CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight")); } +DECLARE_OOXMLEXPORT_TEST(testFloatingTable, "fdo77887.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "horzAnchor", "margin"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "leftFromText", "141"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "rightFromText", "141"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpXSpec", "center"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpY", "2266"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "vertAnchor", "page"); + +} + + 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 7fd9a37..66b1b26 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2728,6 +2728,63 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t m_aTableStyleConf[ BOX_LINE_LEFT ] = aGrabBagElement->second.get<table::BorderLine2>(); else if( aGrabBagElement->first == "TableStyleRightBorder" ) m_aTableStyleConf[ BOX_LINE_RIGHT ] = aGrabBagElement->second.get<table::BorderLine2>(); + else if (aGrabBagElement->first == "TablePosition" ) + { + FastAttributeList *attrListTablePos = m_pSerializer->createAttrList( ); + uno::Sequence<beans::PropertyValue> aTablePosition = aGrabBagElement->second.get<uno::Sequence<beans::PropertyValue> >(); + for (sal_Int32 i = 0; i < aTablePosition.getLength(); ++i) + { + if (aTablePosition[i].Name == "vertAnchor") + { + OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8); + attrListTablePos->add( FSNS( XML_w, XML_vertAnchor ), strTemp.getStr() ); + } + else if (aTablePosition[i].Name == "tblpYSpec") + { + OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8); + attrListTablePos->add( FSNS( XML_w, XML_tblpYSpec ), strTemp.getStr() ); + } + else if (aTablePosition[i].Name == "horzAnchor") + { + OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8); + attrListTablePos->add( FSNS( XML_w, XML_horzAnchor ), strTemp.getStr() ); + } + else if (aTablePosition[i].Name == "tblpXSpec") + { + OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8); + attrListTablePos->add( FSNS( XML_w, XML_tblpXSpec ), strTemp.getStr() ); + } + else if (aTablePosition[i].Name == "bottomFromText") + { + attrListTablePos->add( FSNS( XML_w, XML_bottomFromText ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) ); + } + else if (aTablePosition[i].Name == "leftFromText") + { + attrListTablePos->add( FSNS( XML_w, XML_leftFromText ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) ); + } + else if (aTablePosition[i].Name == "rightFromText") + { + attrListTablePos->add( FSNS( XML_w, XML_rightFromText ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) ); + } + else if (aTablePosition[i].Name == "topFromText") + { + attrListTablePos->add( FSNS( XML_w, XML_topFromText ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) ); + } + else if (aTablePosition[i].Name == "tblpX") + { + attrListTablePos->add( FSNS( XML_w, XML_tblpX ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) ); + } + else if (aTablePosition[i].Name == "tblpY") + { + attrListTablePos->add( FSNS( XML_w, XML_tblpY ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) ); + } + } + + XFastAttributeListRef xAttrListTablePosRef( attrListTablePos ); + + m_pSerializer->singleElementNS( XML_w, XML_tblpPr, xAttrListTablePosRef); + attrListTablePos = NULL; + } } // Output the table alignement diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index a167dd1..49ea9ac 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -29,6 +29,7 @@ #include <com/sun/star/text/RelOrientation.hpp> #include <com/sun/star/text/SizeType.hpp> #include <dmapperLoggers.hxx> +#include <TablePositionHandler.hxx> #ifdef DEBUG_DMAPPER_TABLE_HANDLER #include <PropertyMapHelper.hxx> @@ -354,8 +355,50 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo PropertyMap::iterator aTableStyleIter = m_aTableProperties->find(META_PROP_TABLE_STYLE_NAME); - uno::Sequence< beans::PropertyValue > aGrabBag( 5 ); + uno::Sequence< beans::PropertyValue > aGrabBag( 6 ); sal_Int32 nGrabBagSize = 0; + + if (0 != m_rDMapper_Impl.getTableManager().getCurrentTableRealPosition()) + { + TablePositionHandler *pTablePositions = m_rDMapper_Impl.getTableManager().getCurrentTableRealPosition(); + + uno::Sequence< beans::PropertyValue > aGrabBagTS( 10 ); + + aGrabBagTS[0].Name = "bottomFromText"; + aGrabBagTS[0].Value = uno::makeAny(pTablePositions->getBottomFromText() ); + + aGrabBagTS[1].Name = "horzAnchor"; + aGrabBagTS[1].Value = uno::makeAny( pTablePositions->getHorzAnchor() ); + + aGrabBagTS[2].Name = "leftFromText"; + aGrabBagTS[2].Value = uno::makeAny( pTablePositions->getLeftFromText() ); + + aGrabBagTS[3].Name = "rightFromText"; + aGrabBagTS[3].Value = uno::makeAny( pTablePositions->getRightFromText() ); + + aGrabBagTS[4].Name = "tblpX"; + aGrabBagTS[4].Value = uno::makeAny( pTablePositions->getX() ); + + aGrabBagTS[5].Name = "tblpXSpec"; + aGrabBagTS[5].Value = uno::makeAny( pTablePositions->getXSpec() ); + + aGrabBagTS[6].Name = "tblpY"; + aGrabBagTS[6].Value = uno::makeAny( pTablePositions->getY() ); + + aGrabBagTS[7].Name = "tblpYSpec"; + aGrabBagTS[7].Value = uno::makeAny( pTablePositions->getYSpec() ); + + aGrabBagTS[8].Name = "topFromText"; + aGrabBagTS[8].Value = uno::makeAny( pTablePositions->getTopFromText() ); + + aGrabBagTS[9].Name = "vertAnchor"; + aGrabBagTS[9].Value = uno::makeAny( pTablePositions->getVertAnchor() ); + + aGrabBag[nGrabBagSize].Name = "TablePosition"; + aGrabBag[nGrabBagSize].Value = uno::makeAny( aGrabBagTS ); + nGrabBagSize++; + } + if(aTableStyleIter != m_aTableProperties->end()) { // Apply table style properties recursively @@ -366,8 +409,8 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo pTableStyle = dynamic_cast<TableStyleSheetEntry*>( pStyleSheet.get( ) ); m_aTableProperties->erase( aTableStyleIter ); - aGrabBag[0].Name = "TableStyleName"; - aGrabBag[0].Value = uno::makeAny( sTableStyleName ); + aGrabBag[nGrabBagSize].Name = "TableStyleName"; + aGrabBag[nGrabBagSize].Value = uno::makeAny( sTableStyleName ); nGrabBagSize++; if( pStyleSheet ) @@ -384,26 +427,26 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo TableInfo rStyleInfo; if (lcl_extractTableBorderProperty(pMergedProperties, PROP_TOP_BORDER, rStyleInfo, aBorderLine)) { - aGrabBag[1].Name = "TableStyleTopBorder"; - aGrabBag[1].Value = uno::makeAny( aBorderLine ); + aGrabBag[nGrabBagSize].Name = "TableStyleTopBorder"; + aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine ); nGrabBagSize++; } if (lcl_extractTableBorderProperty(pMergedProperties, PROP_BOTTOM_BORDER, rStyleInfo, aBorderLine)) { - aGrabBag[2].Name = "TableStyleBottomBorder"; - aGrabBag[2].Value = uno::makeAny( aBorderLine ); + aGrabBag[nGrabBagSize].Name = "TableStyleBottomBorder"; + aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine ); nGrabBagSize++; } if (lcl_extractTableBorderProperty(pMergedProperties, PROP_LEFT_BORDER, rStyleInfo, aBorderLine)) { - aGrabBag[3].Name = "TableStyleLeftBorder"; - aGrabBag[3].Value = uno::makeAny( aBorderLine ); + aGrabBag[nGrabBagSize].Name = "TableStyleLeftBorder"; + aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine ); nGrabBagSize++; } if (lcl_extractTableBorderProperty(pMergedProperties, PROP_RIGHT_BORDER, rStyleInfo, aBorderLine)) { - aGrabBag[4].Name = "TableStyleRightBorder"; - aGrabBag[4].Value = uno::makeAny( aBorderLine ); + aGrabBag[nGrabBagSize].Name = "TableStyleRightBorder"; + aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine ); nGrabBagSize++; } diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index 126cec0..3bf3ce3 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -457,6 +457,14 @@ const uno::Sequence<beans::PropertyValue> DomainMapperTableManager::getCurrentTa return uno::Sequence< beans::PropertyValue >( 0 ); } +TablePositionHandler* DomainMapperTableManager::getCurrentTableRealPosition() +{ + if ( !m_aTablePositions.empty( ) && m_aTablePositions.back() ) + return (m_aTablePositions.back( )).get(); + else + return 0; +} + void DomainMapperTableManager::startLevel( ) { DomainMapperTableManager_Base_t::startLevel( ); diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx index b229b4d..29896ae 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx @@ -94,6 +94,7 @@ public: const OUString& getTableStyleName() const { return m_sTableStyleName; } const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getCurrentTablePosition(); + TablePositionHandler* getCurrentTableRealPosition(); virtual void cellProps(TablePropertyMapPtr pProps) SAL_OVERRIDE { diff --git a/writerfilter/source/dmapper/TablePositionHandler.hxx b/writerfilter/source/dmapper/TablePositionHandler.hxx index 592b134..6fd28b4 100644 --- a/writerfilter/source/dmapper/TablePositionHandler.hxx +++ b/writerfilter/source/dmapper/TablePositionHandler.hxx @@ -38,6 +38,48 @@ class TablePositionHandler virtual void lcl_sprm(Sprm& sprm) SAL_OVERRIDE; public: + int getY() + { + return m_nY; + } + int getX() + { + return m_nX; + } + int getLeftFromText() + { + return m_nLeftFromText; + } + int getRightFromText() + { + return m_nRightFromText; + } + int getTopFromText() + { + return m_nTopFromText; + } + int getBottomFromText() + { + return m_nBottomFromText; + } + + OUString getVertAnchor() + { + return m_aVertAnchor; + } + OUString getYSpec() + { + return m_aYSpec; + } + OUString getHorzAnchor() + { + return m_aHorzAnchor; + } + OUString getXSpec() + { + return m_aXSpec; + } + TablePositionHandler(); virtual ~TablePositionHandler(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits