summaryrefslogtreecommitdiff
path: root/psprint
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2007-07-03 12:58:58 +0000
committerRüdiger Timm <rt@openoffice.org>2007-07-03 12:58:58 +0000
commitf7cbe3ffc2c774df892b19f49b9b6a5a1f4a89c4 (patch)
treec6c9be3dc5da427fee5d34360a4f8724d42fa664 /psprint
parent2698c3a93f2fb8be1d20b6632bcf1be8ddcb3d9a (diff)
INTEGRATION: CWS vcl79 (1.2.142); FILE MERGED
2007/05/31 08:32:53 pl 1.2.142.1: #i49079# use rtl::math functions instead of creating own double<->string conversion
Diffstat (limited to 'psprint')
-rw-r--r--psprint/inc/psprint/strhelper.hxx31
1 files changed, 23 insertions, 8 deletions
diff --git a/psprint/inc/psprint/strhelper.hxx b/psprint/inc/psprint/strhelper.hxx
index 3f5287454b09..134dd69b02cd 100644
--- a/psprint/inc/psprint/strhelper.hxx
+++ b/psprint/inc/psprint/strhelper.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: strhelper.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: rt $ $Date: 2005-09-08 16:35:58 $
+ * last change: $Author: rt $ $Date: 2007-07-03 13:58:58 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -38,6 +38,8 @@
#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif
+#include <rtl/math.hxx>
+#include <cstring>
namespace psp {
@@ -58,17 +60,30 @@ ByteString WhitespaceToSpace( const ByteString&, BOOL bProtect = TRUE );
// doublequote, singlequote and singleleftquote protect their respective
// contents
-double StringToDouble( const String& rStr );
-double StringToDouble( const ByteString& rStr );
+
// parses the first double in the string; decimal is '.' only
+inline double StringToDouble( const String& rStr )
+{
+ rtl_math_ConversionStatus eStatus;
+ return rtl::math::stringToDouble( rStr, sal_Unicode('.'), sal_Unicode(0), &eStatus, NULL);
+}
+
+inline double StringToDouble( const ByteString& rStr )
+{
+ rtl_math_ConversionStatus eStatus;
+ return rtl::math::stringToDouble( rtl::OStringToOUString( rStr, osl_getThreadTextEncoding() ), sal_Unicode('.'), sal_Unicode(0), &eStatus, NULL);
+}
// fills a character buffer with the string representation of a double
// the buffer has to be long enough (e.g. 128 bytes)
// returns the string len
-int getValueOfDouble( char* pBuffer, double f, int nPrecision = 0 );
-// corresponding convenience functions
-ByteString DoubleToByteString( double f, int nPrecision = 0 );
-String DoubleToString( double f, int nPrecision = 0 );
+inline int getValueOfDouble( char* pBuffer, double f, int nPrecision = 0)
+{
+ rtl::OString aStr( rtl::math::doubleToString( f, rtl_math_StringFormat_G, nPrecision, '.', true ) );
+ int nLen = aStr.getLength();
+ strncpy( pBuffer, aStr.getStr(), nLen+1 ); // copy string including terminating zero
+ return nLen;
+}
} // namespace