[Libreoffice-commits] .: vcl/source
Michael Meeks
mmeeks at kemper.freedesktop.org
Mon Oct 25 09:24:04 PDT 2010
vcl/source/control/field.cxx | 42 ++++++++++++++++++++----------------------
1 file changed, 20 insertions(+), 22 deletions(-)
New commits:
commit bc0d00745fc2fade52b5345b860c1d18288960c6
Author: John LeMoyne Castle <jlc at mail2lee.com>
Date: Sun Oct 24 23:14:54 2010 -0600
fix 32 bit overflow with 64 bit constants
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 733781e..1f0f7af 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -48,7 +48,6 @@
#include "rtl/math.hxx"
-
#include <unotools/localedatawrapper.hxx>
using namespace ::com::sun::star;
@@ -231,7 +230,7 @@ static void ImplUpdateSeparators( const String& rOldDecSep, const String& rNewDe
{
bool bChangeDec = (rOldDecSep != rNewDecSep);
bool bChangeTh = (rOldThSep != rNewThSep );
-
+
if( bChangeDec || bChangeTh )
{
BOOL bUpdateMode = pEdit->IsUpdateMode();
@@ -242,7 +241,7 @@ static void ImplUpdateSeparators( const String& rOldDecSep, const String& rNewDe
if( bChangeTh )
aText.SearchAndReplaceAll( rNewThSep, rOldThSep );
pEdit->SetText( aText );
-
+
ComboBox* pCombo = dynamic_cast<ComboBox*>(pEdit);
if( pCombo )
{
@@ -479,19 +478,19 @@ void NumericFormatter::ImplLoadRes( const ResId& rResId )
if( pMgr )
{
ULONG nMask = pMgr->ReadLong();
-
+
if ( NUMERICFORMATTER_MIN & nMask )
mnMin = pMgr->ReadLong();
-
+
if ( NUMERICFORMATTER_MAX & nMask )
mnMax = pMgr->ReadLong();
-
+
if ( NUMERICFORMATTER_STRICTFORMAT & nMask )
SetStrictFormat( (BOOL)pMgr->ReadShort() );
-
+
if ( NUMERICFORMATTER_DECIMALDIGITS & nMask )
SetDecimalDigits( pMgr->ReadShort() );
-
+
if ( NUMERICFORMATTER_VALUE & nMask )
{
mnFieldValue = pMgr->ReadLong();
@@ -1080,7 +1079,7 @@ static XubString ImplMetricGetUnitText( const XubString& rStr )
}
}
return aStr;
-
+
/*
// MT: #90545# Preparation for translated strings...
String aMetricText;
@@ -1099,7 +1098,7 @@ static XubString ImplMetricGetUnitText( const XubString& rStr )
break;
}
}
-*/
+*/
}
// -----------------------------------------------------------------------
@@ -1151,33 +1150,32 @@ static FieldUnit ImplMetricGetUnit( const XubString& rStr )
}
#define K *1000L
-#define M *1000000L
+#define M *1000000LL
#define X *5280L
-// Amelia : about measurement unit, 'char' and 'line'
-//static const sal_Int64 aImplFactor[FUNIT_MILE+1][FUNIT_MILE+1] =
+// twip in km = 254 / 14 400 000 000
+// expressions too big for default size 32 bit need LL to avoid overflow
+
static const sal_Int64 aImplFactor[FUNIT_LINE+1][FUNIT_LINE+1] =
{ /*
-mm/100 mm cm m km twip point pica inch foot mile char line*/
+mm/100 mm cm m km twip point pica inch foot mile char line */
{ 1, 100, 1 K, 100 K, 100 M, 2540, 2540, 2540, 2540,2540*12,2540*12 X , 53340, 396240},
{ 1, 1, 10, 1 K, 1 M, 2540, 2540, 2540, 2540,2540*12,2540*12 X , 5334, 396240},
{ 1, 1, 1, 100, 100 K, 254, 254, 254, 254, 254*12, 254*12 X , 5334, 39624},
{ 1, 1, 1, 1, 1 K, 254, 254, 254, 254, 254*12, 254*12 X , 533400, 39624},
-{ 1, 1, 1, 1, 1, 0, 254, 254, 254, 254*12, 254*12 X ,533400 K, 39624},
-{ 1440,144 K,144 K,14400 K, 0, 1, 20, 240, 1440,1440*12,1440*12 X , 210, 3120},
+{ 1, 1, 1, 1, 1, 254, 254, 254, 254, 254*12, 254*12 X ,533400 K, 39624},
+{ 1440,144 K,144 K,14400 K,14400LL M, 1, 20, 240, 1440,1440*12,1440*12 X , 210, 3120},
{ 72, 7200, 7200, 720 K, 720 M, 1, 1, 12, 72, 72*12, 72*12 X , 210, 156},
{ 6, 600, 600, 60 K, 60 M, 1, 1, 1, 6, 6*12, 6*12 X , 210, 10},
{ 1, 100, 100, 10 K, 10 M, 1, 1, 1, 1, 12, 12 X , 210, 45},
{ 1, 100, 100, 10 K, 10 M, 1, 1, 1, 1, 1, 1 X , 210, 45},
{ 1, 100, 100, 10 K, 10 M, 1, 1, 1, 1, 1, 1 , 210, 45},
{ 144, 1440,14400, 14400, 14400, 1, 20, 240, 1440,1440*12, 1440*12 X, 1, 156 },
-{ 720,72000,72000, 7200 K,7200 M, 20, 10, 13, 11, 11*12, 11*12 X, 105, 1 }
+{ 720,72000,72000, 7200 K,7200LL M, 20, 10, 13, 11, 11*12, 11*12 X, 105, 1 }
};
-
#undef X
#undef M
#undef K
-// twip in km 254/14400 M
static FieldUnit eDefaultUnit = FUNIT_NONE;
@@ -1505,10 +1503,10 @@ void MetricFormatter::ImplLoadRes( const ResId& rResId )
if( pMgr )
{
ULONG nMask = pMgr->ReadLong();
-
+
if ( METRICFORMATTER_UNIT & nMask )
meUnit = (FieldUnit)pMgr->ReadLong();
-
+
if ( METRICFORMATTER_CUSTOMUNITTEXT & nMask )
maCustomUnitText = pMgr->ReadString();
}
More information about the Libreoffice-commits
mailing list