summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-03-21 08:54:05 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-03-21 08:54:05 +0100
commite6ce64b1d7d7a0e451af567360cdaf27079258c9 (patch)
treec3c8eb60780fbcdb6c8ba0d54cfcbf304e36b53f
parent5a5889d1e1bd17c16930b2132d8c2674fb7fa05a (diff)
Only need an OStringBuffer in number2PolyPolygon
...so that later passing the OStringBuffer's aNum[i] to createSevenSegmentPolyPolygon (taking a first parameter of type char) doesn't need to implicitly convert from sal_Unicode to char. Requires addition of some missing OStringBuffer-related function variants in rtl/math.hxx and rtl/strbuf.hxx. Change-Id: I79e6b2a791abc62b6556a6668e4411cced490c11
-rw-r--r--basegfx/source/tools/numbertools.cxx6
-rw-r--r--include/rtl/math.hxx37
-rw-r--r--include/rtl/strbuf.hxx24
3 files changed, 64 insertions, 3 deletions
diff --git a/basegfx/source/tools/numbertools.cxx b/basegfx/source/tools/numbertools.cxx
index d30a8371ab2b..86b926ab55d2 100644
--- a/basegfx/source/tools/numbertools.cxx
+++ b/basegfx/source/tools/numbertools.cxx
@@ -12,7 +12,7 @@
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <rtl/ustrbuf.hxx>
+#include <rtl/strbuf.hxx>
#include <rtl/math.hxx>
#include <utility>
@@ -27,8 +27,8 @@ namespace basegfx { namespace tools
// }
// config here
- rtl::OUStringBuffer aNum;
- rtl::math::doubleToUStringBuffer(aNum,
+ rtl::OStringBuffer aNum;
+ rtl::math::doubleToStringBuffer(aNum,
fValue,
rtl_math_StringFormat_F,
nDecPlaces, '.',
diff --git a/include/rtl/math.hxx b/include/rtl/math.hxx
index fed674fdd210..7572c972a91f 100644
--- a/include/rtl/math.hxx
+++ b/include/rtl/math.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_RTL_MATH_HXX
#include <rtl/math.h>
+#include <rtl/strbuf.hxx>
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
@@ -63,6 +64,42 @@ inline rtl::OString doubleToString(double fValue, rtl_math_StringFormat eFormat,
return aResult;
}
+/** A wrapper around rtl_math_doubleToString that appends to an
+ rtl::OStringBuffer.
+
+ @since LibreOffice 5.4
+*/
+inline void doubleToStringBuffer(
+ rtl::OStringBuffer& rBuffer, double fValue, rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces, sal_Char cDecSeparator, sal_Int32 const * pGroups,
+ sal_Char cGroupSeparator, bool bEraseTrailingDecZeros = false)
+{
+ rtl_String ** pData;
+ sal_Int32 * pCapacity;
+ rBuffer.accessInternals(&pData, &pCapacity);
+ rtl_math_doubleToString(
+ pData, pCapacity, rBuffer.getLength(), fValue, eFormat, nDecPlaces,
+ cDecSeparator, pGroups, cGroupSeparator, bEraseTrailingDecZeros);
+}
+
+/** A wrapper around rtl_math_doubleToString that appends to an
+ rtl::OStringBuffer, with no grouping.
+
+ @since LibreOffice 5.4
+*/
+inline void doubleToStringBuffer(
+ rtl::OStringBuffer& rBuffer, double fValue, rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces, sal_Char cDecSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl_String ** pData;
+ sal_Int32 * pCapacity;
+ rBuffer.accessInternals(&pData, &pCapacity);
+ rtl_math_doubleToString(
+ pData, pCapacity, rBuffer.getLength(), fValue, eFormat, nDecPlaces,
+ cDecSeparator, NULL, 0, bEraseTrailingDecZeros);
+}
+
/** A wrapper around rtl_math_doubleToUString.
*/
inline rtl::OUString doubleToUString(double fValue,
diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx
index 7cf4123d0ae8..791eb142f9dc 100644
--- a/include/rtl/strbuf.hxx
+++ b/include/rtl/strbuf.hxx
@@ -988,6 +988,30 @@ public:
return *this;
}
+ /** Allows access to the internal data of this OStringBuffer, for effective
+ manipulation.
+
+ This function should be used with care. After you have called this
+ function, you may use the returned pInternalData and pInternalCapacity
+ only as long as you make no other calls on this OUStringBuffer.
+
+ @param pInternalData
+ This output parameter receives a pointer to the internal data
+ (rtl_String pointer). pInternalData itself must not be null.
+
+ @param pInternalCapacity
+ This output parameter receives a pointer to the internal capacity.
+ pInternalCapacity itself must not be null.
+
+ @since LibreOffice 5.4
+ */
+ void accessInternals(
+ rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
+ {
+ *pInternalData = &pData;
+ *pInternalCapacity = &nCapacity;
+ }
+
private:
/**
A pointer to the data structure which contains the data.