summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjp <jp@openoffice.org>2000-11-21 13:24:56 +0000
committerjp <jp@openoffice.org>2000-11-21 13:24:56 +0000
commitfa05fff1347f9427a7fc362c8e062fb9608a8f78 (patch)
tree6acff2c43cf67db535e2f760f5aaab992313bead
parent77da25c56d9efa0f899c1cdf475c7d713daa1dc6 (diff)
Bug #79951#: Str2Double - new method with doc
-rw-r--r--sw/inc/calc.hxx6
-rw-r--r--sw/source/core/bastyp/calc.cxx34
-rw-r--r--sw/source/core/fields/fldbas.cxx35
3 files changed, 47 insertions, 28 deletions
diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx
index 8c9e9fc3ef57..8bc3bd350bd7 100644
--- a/sw/inc/calc.hxx
+++ b/sw/inc/calc.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: calc.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jp $ $Date: 2000-11-20 09:16:31 $
+ * last change: $Author: jp $ $Date: 2000-11-21 14:22:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -256,6 +256,8 @@ public:
static FASTBOOL Str2Double( const String& rStr, xub_StrLen& rPos,
double& rVal,
const LocaleDataWrapper* pData = 0 );
+ static FASTBOOL Str2Double( const String& rStr, xub_StrLen& rPos,
+ double& rVal, SwDoc* pDoc );
};
#endif
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index e8b22d7f931d..6d5be08e2e2c 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: calc.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: jp $ $Date: 2000-11-21 13:22:35 $
+ * last change: $Author: jp $ $Date: 2000-11-21 14:24:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -104,7 +104,6 @@
#ifndef _UNOTOOLS_CHARCLASS_HXX
#include <unotools/charclass.hxx>
#endif
-
#ifndef _UNO_LINGU_HXX
#include <svx/unolingu.hxx>
#endif
@@ -1564,6 +1563,35 @@ FASTBOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos,
return 0 == nErrno && nCurrCmdPos != rCommandPos;
}
+FASTBOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos,
+ double& rVal, SwDoc* pDoc )
+{
+ const LocaleDataWrapper* pLclD = &GetAppLocaleData();
+ if( pDoc )
+ {
+ LanguageType eLang = ((SvxLanguageItem&)pDoc->GetDefault(
+ RES_CHRATR_LANGUAGE )).GetLanguage();
+ if( eLang != SvxLocaleToLanguage( pLclD->getLocale() ) )
+ pLclD = new LocaleDataWrapper(
+ ::comphelper::getProcessServiceFactory(),
+ SvxCreateLocale( eLang ) );
+ }
+
+ const xub_Unicode *pEnd, nCurrCmdPos = rCommandPos;
+ int nErrno;
+ rVal = SolarMath::StringToDouble( rCommand.GetBuffer() + rCommandPos,
+ pLclD->getNumThousandSep().GetChar(0),
+ pLclD->getNumDecimalSep().GetChar(0),
+ nErrno, &pEnd );
+ rCommandPos = pEnd - rCommand.GetBuffer();
+
+ if( pLclD != &GetAppLocaleData() )
+ delete (LocaleDataWrapper*)pLclD;
+
+ return 0 == nErrno && nCurrCmdPos != rCommandPos;
+}
+
+
//------------------------------------------------------------------------------
/******************************************************************************
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 2c3fe357fb98..84d4f9bec99f 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fldbas.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jp $ $Date: 2000-11-20 09:14:45 $
+ * last change: $Author: jp $ $Date: 2000-11-21 14:23:59 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,18 +65,14 @@
#pragma hdrstop
-
#include <math.h>
#ifdef MAC
#include <stdlib.h>
#endif
#include <float.h>
-#ifndef _SV_SVAPP_HXX //autogen
-#include <vcl/svapp.hxx>
-#endif
-#ifndef _SV_SYSTEM_HXX //autogen
-#include <vcl/system.hxx>
+#ifndef _TOOLS_SOLMATH_HXX
+#include <tools/solmath.hxx>
#endif
#ifndef _ZFORLIST_HXX //autogen
#include <svtools/zforlist.hxx>
@@ -84,9 +80,6 @@
#ifndef _ZFORMAT_HXX //autogen
#include <svtools/zformat.hxx>
#endif
-#ifndef _TOOLS_SOLMATH_HXX //autogen wg. SolarMath
-#include <tools/solmath.hxx>
-#endif
#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
#include <unotools/localedatawrapper.hxx>
#endif
@@ -139,6 +132,11 @@
#ifndef _SHELLRES_HXX
#include <shellres.hxx>
#endif
+#ifndef _CALC_HXX
+#include <calc.hxx>
+#endif
+
+
using namespace ::com::sun::star;
USHORT lcl_GetLanguageOfFormat( USHORT nLng, ULONG nFmt,
@@ -953,18 +951,9 @@ void SwFormulaField::SetFormula(const String& rStr)
if( nFmt && ULONG_MAX != nFmt )
{
- // String muss im Systemformat vorliegen!
- // Geht bei Import/Export mit unterschiedlichen Systemformaten
- // voll in die Hose. Ist aber nicht anders moeglich, da der Kalkulator
- // nur im Systemformat rechnen kann und es keine Konvertierungsroutine
- // gibt.
- const LocaleDataWrapper& rLclD = GetAppLocaleData();
- int nErrno;
- double fValue = SolarMath::StringToDouble( rStr.GetBuffer(),
- rLclD.getNumThousandSep().GetChar(0),
- rLclD.getNumDecimalSep().GetChar(0),
- nErrno );
- if( !nErrno )
+ xub_StrLen nPos = 0;
+ double fValue;
+ if( SwCalc::Str2Double( rStr, nPos, fValue, GetDoc() ) )
SwValueField::SetValue( fValue );
}
}