Kaydet (Commit) 76aa23c5 authored tarafından Michael Stahl's avatar Michael Stahl

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
üst de660901
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <com/sun/star/view/XFormLayerAccess.hpp> #include <com/sun/star/view/XFormLayerAccess.hpp>
#include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/table/TableBorder2.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/text/SizeType.hpp>
#include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/xml/dom/XDocument.hpp>
#include <com/sun/star/text/XDocumentIndex.hpp> #include <com/sun/star/text/XDocumentIndex.hpp>
...@@ -210,6 +211,21 @@ DECLARE_OOXMLIMPORT_TEST(testRhbz988516, "rhbz988516.docx") ...@@ -210,6 +211,21 @@ DECLARE_OOXMLIMPORT_TEST(testRhbz988516, "rhbz988516.docx")
getProperty<OUString>(getParagraph(3), "NumberingStyleName")); 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") DECLARE_OOXMLIMPORT_TEST(testFdo49940, "fdo49940.docx")
{ {
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
......
...@@ -406,18 +406,6 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -406,18 +406,6 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
m_aTableProperties->getValue( TablePropertyMap::CELL_MAR_BOTTOM, m_aTableProperties->getValue( TablePropertyMap::CELL_MAR_BOTTOM,
rInfo.nBottomBorderDistance ); 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()) if (rFrameProperties.hasElements())
lcl_DecrementHoriOrientPosition(rFrameProperties, rInfo.nLeftBorderDistance); lcl_DecrementHoriOrientPosition(rFrameProperties, rInfo.nLeftBorderDistance);
...@@ -477,6 +465,18 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -477,6 +465,18 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
lcl_debug_TableBorder(aTableBorder); lcl_debug_TableBorder(aTableBorder);
#endif #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 : // 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), // - 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 // so table's position depends on table's cells margin
......
...@@ -366,8 +366,8 @@ namespace dmapper { ...@@ -366,8 +366,8 @@ namespace dmapper {
if (m_pCurrentInteropGrabBag) if (m_pCurrentInteropGrabBag)
m_pCurrentInteropGrabBag->push_back(pHandler->getInteropGrabBag()); m_pCurrentInteropGrabBag->push_back(pHandler->getInteropGrabBag());
TablePropertyMapPtr pTblIndMap(new TablePropertyMap); TablePropertyMapPtr pTblIndMap(new TablePropertyMap);
sal_uInt32 nTblInd = pHandler->getMeasureValue(); sal_Int32 nTblInd = pHandler->getMeasureValue();
pTblIndMap->setValue( TablePropertyMap::LEFT_MARGIN, nTblInd); pTblIndMap->setValue(TablePropertyMap::LEFT_MARGIN, nTblInd);
insertTableProps(pTblIndMap); insertTableProps(pTblIndMap);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment