[Libreoffice-commits] core.git: 3 commits - sw/qa writerfilter/source
LuboÅ¡ LuÅák
l.lunak at collabora.com
Wed Mar 26 09:37:14 PDT 2014
dev/null |binary
sw/qa/extras/ooxmlimport/data/negative_table_cell_twips.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 24 +++--------
writerfilter/source/dmapper/CellMarginHandler.cxx | 2
writerfilter/source/dmapper/ConversionHelper.cxx | 10 +++-
writerfilter/source/dmapper/ConversionHelper.hxx | 1
writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 24 +++++------
writerfilter/source/dmapper/TablePropertiesHandler.cxx | 4 -
8 files changed, 32 insertions(+), 33 deletions(-)
New commits:
commit 0d1abac3a3131a9419cedb4385edf6ab8ccb58de
Author: LuboÅ¡ LuÅák <l.lunak at collabora.com>
Date: Wed Mar 26 17:31:03 2014 +0100
test for ignoring negative cell margin values
Change-Id: I7e56762a7097dd7369f9d8d71b499888ee5c081d
diff --git a/sw/qa/extras/ooxmlimport/data/negative_table_cell_twips.docx b/sw/qa/extras/ooxmlimport/data/negative_table_cell_twips.docx
new file mode 100644
index 0000000..3ae73db
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/negative_table_cell_twips.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index b86d26d..da5472d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1981,6 +1981,14 @@ DECLARE_OOXMLIMPORT_TEST(testLargeTwips, "large-twips.docx" )
CPPUNIT_ASSERT( width.toInt32() > 0 );
}
+DECLARE_OOXMLIMPORT_TEST(testNegativeCellMarginTwips, "negative-cell-margin-twips.docx" )
+{
+ // Sligtly related to cp#1000043, the twips value was negative, which wrapped around somewhere,
+ // while MSO seems to ignore that as well.
+ OUString width = parseDump( "/root/page/body/tab/row[1]/cell[1]/txt/infos/bounds", "width" );
+ CPPUNIT_ASSERT( width.toInt32() > 0 );
+}
+
DECLARE_OOXMLIMPORT_TEST(testFdo38414, "fdo38414.docx" )
{
// The cells in the last (4th) column were merged properly and so the result didn't have the same height.
commit 1e47614cdb84b018a22a334dad0cdd9f0f53892c
Author: LuboÅ¡ LuÅák <l.lunak at collabora.com>
Date: Wed Mar 26 17:28:51 2014 +0100
apparently some table .docx properties shouldn't be < 0
Somewhat related to 10b4da63e3143108ba75891e9e98fdaa2f7953ab , a similar
doc has negative value inside w:tblCellMar, which MSO seems to ignore
(altering the value has no visible effect), so ignore it as well.
Change-Id: I846e9b55fea0d4e66f03ce615584516360b8b7dd
diff --git a/writerfilter/source/dmapper/CellMarginHandler.cxx b/writerfilter/source/dmapper/CellMarginHandler.cxx
index 380a8d9..6bbb525 100644
--- a/writerfilter/source/dmapper/CellMarginHandler.cxx
+++ b/writerfilter/source/dmapper/CellMarginHandler.cxx
@@ -57,7 +57,7 @@ void CellMarginHandler::lcl_attribute(Id rName, Value & rVal)
{
case NS_ooxml::LN_CT_TblWidth_w:
m_nWidth = nIntValue;
- m_nValue = ConversionHelper::convertTwipToMM100( nIntValue );
+ m_nValue = ConversionHelper::convertTwipToMM100Unsigned( nIntValue );
break;
case NS_ooxml::LN_CT_TblWidth_type:
OSL_ENSURE( NS_ooxml::LN_Value_ST_TblWidth_dxa == sal::static_int_cast<Id>(nIntValue), "cell margins work for absolute values, only");
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx
index cba58b7..9de86ee 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -226,18 +226,24 @@ OUString ConvertMSFormatStringToSO(
}
+#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
sal_Int32 convertTwipToMM100(sal_Int32 _t)
{
+ return TWIP_TO_MM100( _t );
+}
+
+sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t)
+{
+ if( _t < 0 )
+ return 0;
// It appears that MSO handles large twip values specially, probably legacy 16bit handling,
// anything that's bigger than 32767 appears to be simply ignored.
if( _t >= 0x8000 )
return 0;
-#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
return TWIP_TO_MM100( _t );
}
-
sal_Int32 convertEMUToMM100(sal_Int32 _t)
{
return _t / 360;
diff --git a/writerfilter/source/dmapper/ConversionHelper.hxx b/writerfilter/source/dmapper/ConversionHelper.hxx
index 5b3b4fd..247da5c 100644
--- a/writerfilter/source/dmapper/ConversionHelper.hxx
+++ b/writerfilter/source/dmapper/ConversionHelper.hxx
@@ -44,6 +44,7 @@ namespace ConversionHelper{
OUString ConvertMSFormatStringToSO(
const OUString& rFormat, ::com::sun::star::lang::Locale& rLocale, bool bHijri);
sal_Int32 convertTwipToMM100(sal_Int32 _t);
+ sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t);
// probably the most useless unit in the world - English Metric Units (EMU) 360 000 EMU == 1cm
sal_Int32 convertEMUToMM100(sal_Int32 _t);
sal_Int16 convertTableJustification( sal_Int32 nIntValue );
commit 77f4c4b8db2671921dd378ac4e255b700c7cf332
Author: LuboÅ¡ LuÅák <l.lunak at collabora.com>
Date: Wed Mar 26 17:01:27 2014 +0100
Revert "rhbz#1075124: writerfilter: fix tables with negative left margin"
It appears that this was just a workaround that incidentally worked.
Making the negative value even larger (in abs value) doesn't seem to make
a difference for MSO, but LO fails again. A proper fix (better workaround?)
will follow.
This reverts commit 76aa23c59b4c81ea7b9d974a1a0a9e39c6bf8741.
diff --git a/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx b/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx
deleted file mode 100644
index 3b31701..0000000
Binary files a/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx and /dev/null differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 6943c4b..b86d26d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -47,7 +47,6 @@
#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>
@@ -211,21 +210,6 @@ 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 a6ade15..a9a4221 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -406,6 +406,18 @@ 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);
@@ -465,18 +477,6 @@ 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 d71e9ae..7777ed9 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -370,8 +370,8 @@ namespace dmapper {
if (m_pCurrentInteropGrabBag)
m_pCurrentInteropGrabBag->push_back(pHandler->getInteropGrabBag());
TablePropertyMapPtr pTblIndMap(new TablePropertyMap);
- sal_Int32 nTblInd = pHandler->getMeasureValue();
- pTblIndMap->setValue(TablePropertyMap::LEFT_MARGIN, nTblInd);
+ sal_uInt32 nTblInd = pHandler->getMeasureValue();
+ pTblIndMap->setValue( TablePropertyMap::LEFT_MARGIN, nTblInd);
insertTableProps(pTblIndMap);
}
}
More information about the Libreoffice-commits
mailing list