diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-03-11 22:36:35 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-03-11 23:34:09 +0100 |
commit | 76aa23c59b4c81ea7b9d974a1a0a9e39c6bf8741 (patch) | |
tree | 0a8826943dfd03d9900be92954897470fa5a6d04 | |
parent | de660901e1805f33467d425018d6bf5d5326e376 (diff) |
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
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/rhbz1075124.docx | bin | 0 -> 4216 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 16 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 24 | ||||
-rw-r--r-- | writerfilter/source/dmapper/TablePropertiesHandler.cxx | 4 |
4 files changed, 30 insertions, 14 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx b/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx Binary files differnew file mode 100644 index 000000000000..3b3170101718 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index bfc8af08bea6..e67796ec7ead 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 a9a4221cf408..a6ade15be9b3 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 3bd176830d73..b9b456b751b0 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); } } |