[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - writerfilter/source

Luboš Luňák l.lunak at collabora.com
Wed Mar 26 09:36:14 PDT 2014


 writerfilter/source/dmapper/CellMarginHandler.cxx |    2 +-
 writerfilter/source/dmapper/ConversionHelper.cxx  |   10 ++++++++--
 writerfilter/source/dmapper/ConversionHelper.hxx  |    1 +
 3 files changed, 10 insertions(+), 3 deletions(-)

New commits:
commit ebdc472eb717976385c02b8809dd483172b42b01
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 6119831..a32554b 100644
--- a/writerfilter/source/dmapper/CellMarginHandler.cxx
+++ b/writerfilter/source/dmapper/CellMarginHandler.cxx
@@ -55,7 +55,7 @@ void CellMarginHandler::lcl_attribute(Id rName, Value & rVal)
     switch( rName )
     {
         case NS_ooxml::LN_CT_TblWidth_w:
-            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 3ce0133..4cd2539 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -230,18 +230,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 b23872b..3873a39 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_Int32 ConvertColor(sal_Int32 nWordColor );


More information about the Libreoffice-commits mailing list