sw/qa/extras/ooxmlimport/data/rhbz1075124.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 16 ++++++++++ writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 24 +++++++-------- writerfilter/source/dmapper/TablePropertiesHandler.cxx | 4 +- 4 files changed, 30 insertions(+), 14 deletions(-)
New commits: commit 76aa23c59b4c81ea7b9d974a1a0a9e39c6bf8741 Author: Michael Stahl <mst...@redhat.com> Date: Tue Mar 11 22:36:35 2014 +0100 rhbz#1075124: writerfilter: fix tables with negative left margin SvxBoxItem::nLeftDist is unsigned; the bugdoc sets a very large value due to wrap-around which causes the table content not to be displayed. DomainMapperTableHandler::endTableGetTableStyle() tweaks the rInfo.nLeftBorderDistance by adding half the border line width to it, which makes it positive; at that point the value has already been used to init table::TableBorderDistances, so move that downward so it gets the positive value too. Change-Id: Ied2331b93f2e95845d7e8b2cc06e89e1ab24296e diff --git a/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx b/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx new file mode 100644 index 0000000..3b31701 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index bfc8af0..e67796e 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -47,6 +47,7 @@ #include <com/sun/star/view/XFormLayerAccess.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/TableBorder2.hpp> +#include <com/sun/star/table/TableBorderDistances.hpp> #include <com/sun/star/text/SizeType.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/text/XDocumentIndex.hpp> @@ -210,6 +211,21 @@ DECLARE_OOXMLIMPORT_TEST(testRhbz988516, "rhbz988516.docx") getProperty<OUString>(getParagraph(3), "NumberingStyleName")); } +DECLARE_OOXMLIMPORT_TEST(testRhbz1075124, "rhbz1075124.docx") +{ + // negative left margin on table wrapped around to 64k unsigned + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, + uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables( + xTablesSupplier->getTextTables(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-243), + getProperty<sal_Int32>(xTables->getByIndex(0), "LeftMargin")); + table::TableBorderDistances dists( + getProperty<table::TableBorderDistances>(xTables->getByIndex(0), + "TableBorderDistances")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(26), dists.LeftDistance); +} + DECLARE_OOXMLIMPORT_TEST(testFdo49940, "fdo49940.docx") { uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index a9a4221..a6ade15 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -406,18 +406,6 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo m_aTableProperties->getValue( TablePropertyMap::CELL_MAR_BOTTOM, rInfo.nBottomBorderDistance ); - table::TableBorderDistances aDistances; - aDistances.IsTopDistanceValid = - aDistances.IsBottomDistanceValid = - aDistances.IsLeftDistanceValid = - aDistances.IsRightDistanceValid = sal_True; - aDistances.TopDistance = static_cast<sal_Int16>( rInfo.nTopBorderDistance ); - aDistances.BottomDistance = static_cast<sal_Int16>( rInfo.nBottomBorderDistance ); - aDistances.LeftDistance = static_cast<sal_Int16>( rInfo.nLeftBorderDistance ); - aDistances.RightDistance = static_cast<sal_Int16>( rInfo.nRightBorderDistance ); - - m_aTableProperties->Insert( PROP_TABLE_BORDER_DISTANCES, uno::makeAny( aDistances ) ); - if (rFrameProperties.hasElements()) lcl_DecrementHoriOrientPosition(rFrameProperties, rInfo.nLeftBorderDistance); @@ -477,6 +465,18 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo lcl_debug_TableBorder(aTableBorder); #endif + table::TableBorderDistances aDistances; + aDistances.IsTopDistanceValid = + aDistances.IsBottomDistanceValid = + aDistances.IsLeftDistanceValid = + aDistances.IsRightDistanceValid = sal_True; + aDistances.TopDistance = static_cast<sal_Int16>( rInfo.nTopBorderDistance ); + aDistances.BottomDistance = static_cast<sal_Int16>( rInfo.nBottomBorderDistance ); + aDistances.LeftDistance = static_cast<sal_Int16>( rInfo.nLeftBorderDistance ); + aDistances.RightDistance = static_cast<sal_Int16>( rInfo.nRightBorderDistance ); + + m_aTableProperties->Insert( PROP_TABLE_BORDER_DISTANCES, uno::makeAny( aDistances ) ); + // Table position in Office is computed in 2 different ways : // - top level tables: the goal is to have in-cell text starting at table indent pos (tblInd), // so table's position depends on table's cells margin diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx index 3bd1768..b9b456b 100644 --- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx +++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx @@ -366,8 +366,8 @@ namespace dmapper { if (m_pCurrentInteropGrabBag) m_pCurrentInteropGrabBag->push_back(pHandler->getInteropGrabBag()); TablePropertyMapPtr pTblIndMap(new TablePropertyMap); - sal_uInt32 nTblInd = pHandler->getMeasureValue(); - pTblIndMap->setValue( TablePropertyMap::LEFT_MARGIN, nTblInd); + sal_Int32 nTblInd = pHandler->getMeasureValue(); + pTblIndMap->setValue(TablePropertyMap::LEFT_MARGIN, nTblInd); insertTableProps(pTblIndMap); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits