From e6ce64b1d7d7a0e451af567360cdaf27079258c9 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 21 Mar 2017 08:54:05 +0100 Subject: 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 --- include/rtl/math.hxx | 37 +++++++++++++++++++++++++++++++++++++ include/rtl/strbuf.hxx | 24 ++++++++++++++++++++++++ 2 files changed, 61 insertions(+) (limited to 'include/rtl') 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 +#include #include #include #include @@ -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. -- cgit