diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-03-26 17:28:51 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-03-26 17:36:49 +0100 |
commit | 1e47614cdb84b018a22a334dad0cdd9f0f53892c (patch) | |
tree | 37f098a47ac3e07de4a185a3219a39cc66a16079 | |
parent | 77f4c4b8db2671921dd378ac4e255b700c7cf332 (diff) |
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
-rw-r--r-- | writerfilter/source/dmapper/CellMarginHandler.cxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/ConversionHelper.cxx | 10 | ||||
-rw-r--r-- | writerfilter/source/dmapper/ConversionHelper.hxx | 1 |
3 files changed, 10 insertions, 3 deletions
diff --git a/writerfilter/source/dmapper/CellMarginHandler.cxx b/writerfilter/source/dmapper/CellMarginHandler.cxx index 380a8d95772c..6bbb52547a79 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 cba58b7061d2..9de86eeb8f0a 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 5b3b4fd3c3b5..247da5cfdb5a 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 ); |