20#ifndef INCLUDED_SAX_TOOLS_CONVERTER_HXX
21#define INCLUDED_SAX_TOOLS_CONVERTER_HXX
30#include <rtl/strbuf.hxx>
32#include <rtl/ustrbuf.hxx>
33#include <com/sun/star/util/MeasureUnit.hpp>
63 std::u16string_view rString,
64 sal_Int16 nTargetUnit = css::util::MeasureUnit::MM_100TH,
70 std::string_view rString,
71 sal_Int16 nTargetUnit = css::util::MeasureUnit::MM_100TH,
79 sal_Int16 nTargetUnit );
82 static bool convertBool(
bool& rBool,
83 std::u16string_view rString );
86 static bool convertBool(
bool& rBool,
87 std::string_view rString );
90 static void convertBool( OUStringBuffer& rBuffer,
94 static bool convertPercent( sal_Int32& rValue,
95 std::u16string_view rString );
98 static bool convertPercent( sal_Int32& rValue,
99 std::string_view rString );
102 static void convertPercent( OUStringBuffer& rBuffer,
106 static bool convertMeasurePx( sal_Int32& rValue,
107 std::u16string_view rString );
110 static bool convertMeasurePx( sal_Int32& rValue,
111 std::string_view rString );
114 static void convertMeasurePx( OUStringBuffer& rBuffer,
118 static bool convertColor( sal_Int32& rColor,
119 std::u16string_view rValue );
120 static bool convertColor( sal_Int32& rColor,
121 std::string_view rValue );
123 std::u16string_view rValue )
126 bool b = convertColor(
n, rValue );
131 std::string_view rValue )
134 bool b = convertColor(
n, rValue );
140 static void convertColor( OUStringBuffer &rBuffer,
144 { convertColor( rBuffer, sal_Int32(nColor) ); }
147 static bool convertNumber( sal_Int32& rValue,
148 std::u16string_view aString,
149 sal_Int32 nMin = SAL_MIN_INT32,
150 sal_Int32 nMax = SAL_MAX_INT32 );
153 static bool convertNumber( sal_Int32& rValue,
154 std::string_view aString,
155 sal_Int32 nMin = SAL_MIN_INT32,
156 sal_Int32 nMax = SAL_MAX_INT32 );
159 static bool convertNumber64(sal_Int64& rValue,
160 std::u16string_view aString,
161 sal_Int64 nMin = SAL_MIN_INT64,
162 sal_Int64 nMax = SAL_MAX_INT64);
165 static bool convertNumber64(sal_Int64& rValue,
166 std::string_view aString,
167 sal_Int64 nMin = SAL_MIN_INT64,
168 sal_Int64 nMax = SAL_MAX_INT64);
172 static void convertDouble( OUStringBuffer& rBuffer,
175 sal_Int16 nSourceUnit,
176 sal_Int16 nTargetUnit );
179 static void convertDouble( OUStringBuffer& rBuffer,
double fNumber);
183 static bool convertDouble(
double& rValue,
184 std::u16string_view rString,
185 sal_Int16 nSourceUnit,
186 sal_Int16 nTargetUnit );
190 static bool convertDouble(
double& rValue,
191 std::string_view rString,
192 sal_Int16 nSourceUnit,
193 sal_Int16 nTargetUnit );
196 static bool convertDouble(
double& rValue, std::u16string_view rString);
199 static bool convertDouble(
double& rValue, std::string_view rString);
202 static void convertAngle(OUStringBuffer& rBuffer, sal_Int16 nAngle,
206 static bool convertAngle(sal_Int16& rAngle, std::u16string_view rString,
207 bool isWrongOOo10thDegAngle);
210 static bool convertAngle(sal_Int16& rAngle, std::string_view rString,
211 bool isWrongOOo10thDegAngle);
214 static void convertDuration(OUStringBuffer& rBuffer,
219 const css::util::Duration& rDuration);
222 static bool convertDuration(
double & rfTime,
223 std::string_view rString);
227 std::u16string_view rString);
231 std::string_view rString);
234 static void convertDate( OUStringBuffer& rBuffer,
235 const css::util::Date& rDate,
236 sal_Int16
const* pTimeZoneOffset);
239 static void convertDateTime( OUStringBuffer& rBuffer,
240 const css::util::DateTime& rDateTime,
241 sal_Int16
const* pTimeZoneOffset,
242 bool bAddTimeIf0AM =
false );
245 static void convertTimeOrDateTime(OUStringBuffer& rBuffer,
246 const css::util::DateTime& rDateTime);
250 std::u16string_view rString );
254 std::string_view rString );
258 std::u16string_view rString);
262 std::string_view rString);
267 css::util::Date * pDate,
268 css::util::DateTime & rDateTime,
270 std::optional<sal_Int16> * pTimeZoneOffset,
271 std::u16string_view rString );
276 css::util::Date * pDate,
277 css::util::DateTime & rDateTime,
279 std::optional<sal_Int16> * pTimeZoneOffset,
280 std::string_view rString );
284 static sal_Int32 indexOfComma( std::u16string_view rStr,
287 static double GetConversionFactor(OUStringBuffer& rUnit, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit);
288 static double GetConversionFactor(OStringBuffer& rUnit, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit);
289 static sal_Int16 GetUnitFromString(std::u16string_view rString, sal_Int16 nDefaultUnit);
290 static sal_Int16 GetUnitFromString(std::string_view rString, sal_Int16 nDefaultUnit);
293 static bool convertAny(OUStringBuffer& rsValue,
294 OUStringBuffer& rsType ,
295 const css::uno::Any& rValue);
298 static void convertBytesToHexBinary(OUStringBuffer& rBuffer,
const void* pBytes,
301 template <
typename T, std::enable_if_t<std::is_arithmetic_v<T>,
int> = 0>
304 convertBytesToHexBinary(rBuffer, &
n,
sizeof(
n));
the Converter converts values of various types from their internal representation to the textual form...
static bool parseTimeOrDateTime(css::util::DateTime &rDateTime, std::u16string_view rString)
convert XMLSchema-2 "time" or "dateTime" string to util::DateTime
static void convertColor(OUStringBuffer &rBuffer, ::Color nColor)
static bool parseTimeOrDateTime(css::util::DateTime &rDateTime, std::string_view rString)
convert XMLSchema-2 "time" or "dateTime" string to util::DateTime
static void convertDuration(OUStringBuffer &rBuffer, const css::util::Duration &rDuration)
convert util::Duration to XMLSchema-2 "duration" string
static bool parseDateTime(css::util::DateTime &rDateTime, std::u16string_view rString)
convert XMLSchema-2 "date" or "dateTime" string to util::DateTime
static bool convertColor(::Color &rColor, std::string_view rValue)
static bool parseDateOrDateTime(css::util::Date *pDate, css::util::DateTime &rDateTime, bool &rbDateTime, std::optional< sal_Int16 > *pTimeZoneOffset, std::u16string_view rString)
convert XMLSchema-2 "date" or "dateTime" string to util::DateTime or util::Date
static bool convertDuration(css::util::Duration &rDuration, std::string_view rString)
convert XMLSchema-2 "duration" string to util::Duration
static void convertNumberToHexBinary(OUStringBuffer &rBuffer, T n)
static bool parseDateTime(css::util::DateTime &rDateTime, std::string_view rString)
convert XMLSchema-2 "date" or "dateTime" string to util::DateTime
static bool convertDuration(css::util::Duration &rDuration, std::u16string_view rString)
convert XMLSchema-2 "duration" string to util::Duration
static bool convertColor(::Color &rColor, std::u16string_view rValue)
static bool parseDateOrDateTime(css::util::Date *pDate, css::util::DateTime &rDateTime, bool &rbDateTime, std::optional< sal_Int16 > *pTimeZoneOffset, std::string_view rString)
convert XMLSchema-2 "date" or "dateTime" string to util::DateTime or util::Date
bool convertMeasure(OUString &rString)