diff options
-rw-r--r-- | include/sax/tools/converter.hxx | 21 | ||||
-rw-r--r-- | include/xmloff/xmluconv.hxx | 8 | ||||
-rw-r--r-- | sax/source/tools/converter.cxx | 223 | ||||
-rw-r--r-- | xmloff/inc/txtfldi.hxx | 78 | ||||
-rw-r--r-- | xmloff/inc/txtvfldi.hxx | 10 | ||||
-rw-r--r-- | xmloff/source/core/xmluconv.cxx | 24 | ||||
-rw-r--r-- | xmloff/source/text/txtfldi.cxx | 162 | ||||
-rw-r--r-- | xmloff/source/text/txtvfldi.cxx | 40 |
8 files changed, 395 insertions, 171 deletions
diff --git a/include/sax/tools/converter.hxx b/include/sax/tools/converter.hxx index 07c2fb3207b1..0d3d68ba301c 100644 --- a/include/sax/tools/converter.hxx +++ b/include/sax/tools/converter.hxx @@ -206,6 +206,10 @@ public: static bool convertDuration(double & rfTime, std::u16string_view rString); + /** convert XMLSchema-2 "duration" string to double; negative durations allowed */ + static bool convertDuration(double & rfTime, + std::string_view rString); + /** convert XMLSchema-2 "duration" string to util::Duration */ static bool convertDuration(css::util::Duration& rDuration, std::u16string_view rString); @@ -229,10 +233,18 @@ public: static bool parseDateTime( css::util::DateTime& rDateTime, std::u16string_view rString ); + /** convert XMLSchema-2 "date" or "dateTime" string to util::DateTime */ + static bool parseDateTime( css::util::DateTime& rDateTime, + std::string_view rString ); + /** convert XMLSchema-2 "time" or "dateTime" string to util::DateTime */ static bool parseTimeOrDateTime(css::util::DateTime& rDateTime, std::u16string_view rString); + /** convert XMLSchema-2 "time" or "dateTime" string to util::DateTime */ + static bool parseTimeOrDateTime(css::util::DateTime& rDateTime, + std::string_view rString); + /** convert XMLSchema-2 "date" or "dateTime" string to util::DateTime or util::Date */ static bool parseDateOrDateTime( @@ -242,6 +254,15 @@ public: std::optional<sal_Int16> * pTimeZoneOffset, std::u16string_view rString ); + /** convert XMLSchema-2 "date" or "dateTime" string to util::DateTime or + util::Date */ + static bool parseDateOrDateTime( + css::util::Date * pDate, + css::util::DateTime & rDateTime, + bool & rbDateTime, + std::optional<sal_Int16> * pTimeZoneOffset, + std::string_view rString ); + /** gets the position of the first comma after npos in the string rStr. Commas inside '"' pairs are not matched */ static sal_Int32 indexOfComma( std::u16string_view rStr, diff --git a/include/xmloff/xmluconv.hxx b/include/xmloff/xmluconv.hxx index 87d2e883be36..a501221c16bb 100644 --- a/include/xmloff/xmluconv.hxx +++ b/include/xmloff/xmluconv.hxx @@ -228,6 +228,10 @@ public: bool convertDateTime(double& fDateTime, std::u16string_view rString); + /** convert ISO Date Time String to double */ + bool convertDateTime(double& fDateTime, + std::string_view rString); + /// these 2 functions use tools Date, so they're not yet moved to sax /** convert double to ISO Date Time String */ @@ -239,6 +243,10 @@ public: static bool convertDateTime( double& fDateTime, std::u16string_view rString, const css::util::Date& aNullDate); + /** convert ISO Date Time String to double */ + static bool convertDateTime( double& fDateTime, + std::string_view rString, + const css::util::Date& aNullDate); /** convert string to ::basegfx::B3DVector */ diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index a4a793c0392e..57cbceaaca7c 100644 --- a/sax/source/tools/converter.cxx +++ b/sax/source/tools/converter.cxx @@ -282,7 +282,7 @@ bool Converter::convertMeasure( sal_Int32& rValue, sal_Int32 nMin /* = SAL_MIN_INT32 */, sal_Int32 nMax /* = SAL_MAX_INT32 */ ) { - return lcl_convertMeasure<std::u16string_view>(rValue, rString, nTargetUnit, nMin, nMax); + return lcl_convertMeasure(rValue, rString, nTargetUnit, nMin, nMax); } /** convert string to measure using optional min and max values*/ @@ -292,7 +292,7 @@ bool Converter::convertMeasure( sal_Int32& rValue, sal_Int32 nMin /* = SAL_MIN_INT32 */, sal_Int32 nMax /* = SAL_MAX_INT32 */ ) { - return lcl_convertMeasure<std::string_view>(rValue, rString, nTargetUnit, nMin, nMax); + return lcl_convertMeasure(rValue, rString, nTargetUnit, nMin, nMax); } @@ -549,13 +549,13 @@ static bool lcl_convertColor( sal_Int32& rColor, V rValue ) /** convert string to rgb color */ bool Converter::convertColor( sal_Int32& rColor, std::u16string_view rValue ) { - return lcl_convertColor<std::u16string_view>(rColor, rValue); + return lcl_convertColor(rColor, rValue); } /** convert string to rgb color */ bool Converter::convertColor( sal_Int32& rColor, std::string_view rValue ) { - return lcl_convertColor<std::string_view>(rColor, rValue); + return lcl_convertColor(rColor, rValue); } const char aHexTab[] = "0123456789abcdef"; @@ -647,7 +647,7 @@ bool Converter::convertNumber64( sal_Int64& rValue, std::u16string_view aString, sal_Int64 nMin, sal_Int64 nMax ) { - return lcl_convertNumber64<std::u16string_view>(rValue, aString, nMin, nMax); + return lcl_convertNumber64(rValue, aString, nMin, nMax); } /** convert string to 64-bit number with optional min and max values */ @@ -655,7 +655,7 @@ bool Converter::convertNumber64( sal_Int64& rValue, std::string_view aString, sal_Int64 nMin, sal_Int64 nMax ) { - return lcl_convertNumber64<std::string_view>(rValue, aString, nMin, nMax); + return lcl_convertNumber64(rValue, aString, nMin, nMax); } @@ -930,6 +930,19 @@ static std::u16string_view trim(std::u16string_view in) { return std::u16string_view(&*left, std::distance(left, right) + 1); } +static std::string_view trim(std::string_view in) { + auto left = in.begin(); + for (;; ++left) { + if (left == in.end()) + return std::string_view(); + if (!isspace(*left)) + break; + } + auto right = in.end() - 1; + for (; right > left && isspace(*right); --right); + return std::string_view(&*left, std::distance(left, right) + 1); +} + /** convert ISO "duration" string to double; negative durations allowed */ bool Converter::convertDuration(double& rfTime, std::u16string_view rString) @@ -1058,6 +1071,134 @@ bool Converter::convertDuration(double& rfTime, return bSuccess; } +/** convert ISO "duration" string to double; negative durations allowed */ +bool Converter::convertDuration(double& rfTime, + std::string_view rString) +{ + std::string_view aTrimmed = trim(rString); + const char* pStr = aTrimmed.data(); + + // negative time duration? + bool bIsNegativeDuration = false; + if ( '-' == (*pStr) ) + { + bIsNegativeDuration = true; + pStr++; + } + + if ( *pStr != 'P' && *pStr != 'p' ) // duration must start with "P" + return false; + pStr++; + + OUStringBuffer sDoubleStr; + bool bSuccess = true; + bool bDone = false; + bool bTimePart = false; + bool bIsFraction = false; + sal_Int32 nDays = 0; + sal_Int32 nHours = 0; + sal_Int32 nMins = 0; + sal_Int32 nSecs = 0; + sal_Int32 nTemp = 0; + + while ( bSuccess && !bDone ) + { + sal_Unicode c = *(pStr++); + if ( !c ) // end + bDone = true; + else if ( '0' <= c && '9' >= c ) + { + if ( nTemp >= SAL_MAX_INT32 / 10 ) + bSuccess = false; + else + { + if ( !bIsFraction ) + { + nTemp *= 10; + nTemp += (c - u'0'); + } + else + { + sDoubleStr.append(c); + } + } + } + else if ( bTimePart ) + { + if ( c == 'H' || c == 'h' ) + { + nHours = nTemp; + nTemp = 0; + } + else if ( c == 'M' || c == 'm') + { + nMins = nTemp; + nTemp = 0; + } + else if ( (c == ',') || (c == '.') ) + { + nSecs = nTemp; + nTemp = 0; + bIsFraction = true; + sDoubleStr = "0."; + } + else if ( c == 'S' || c == 's' ) + { + if ( !bIsFraction ) + { + nSecs = nTemp; + nTemp = 0; + sDoubleStr = "0.0"; + } + } + else + bSuccess = false; // invalid character + } + else + { + if ( c == 'T' || c == 't' ) // "T" starts time part + bTimePart = true; + else if ( c == 'D' || c == 'd') + { + nDays = nTemp; + nTemp = 0; + } + else if ( c == 'Y' || c == 'y' || c == 'M' || c == 'm' ) + { + //! how many days is a year or month? + + OSL_FAIL( "years or months in duration: not implemented"); + bSuccess = false; + } + else + bSuccess = false; // invalid character + } + } + + if ( bSuccess ) + { + if ( nDays ) + nHours += nDays * 24; // add the days to the hours part + double fHour = nHours; + double fMin = nMins; + double fSec = nSecs; + double fFraction = sDoubleStr.makeStringAndClear().toDouble(); + double fTempTime = fHour / 24; + fTempTime += fMin / (24 * 60); + fTempTime += fSec / (24 * 60 * 60); + fTempTime += fFraction / (24 * 60 * 60); + + // negative duration? + if ( bIsNegativeDuration ) + { + fTempTime = -fTempTime; + } + + rfTime = fTempTime; + } + return bSuccess; +} + /** convert util::Duration to ISO8601 "duration" string */ void Converter::convertDuration(OUStringBuffer& rBuffer, const ::util::Duration& rDuration) @@ -1132,15 +1273,16 @@ enum Result { R_NOTHING, R_OVERFLOW, R_SUCCESS }; } +template <typename V> static Result -readUnsignedNumber(std::u16string_view rString, +readUnsignedNumber(V rString, size_t & io_rnPos, sal_Int32 & o_rNumber) { size_t nPos(io_rnPos); while (nPos < rString.size()) { - const sal_Unicode c = rString[nPos]; + const typename V::value_type c = rString[nPos]; if (('0' > c) || (c > '9')) break; ++nPos; @@ -1152,7 +1294,7 @@ readUnsignedNumber(std::u16string_view rString, return R_NOTHING; } - const sal_Int64 nTemp = rtl_ustr_toInt64_WithLength(rString.data() + io_rnPos, 10, nPos - io_rnPos); + const sal_Int64 nTemp = toInt64_WithLength(rString.data() + io_rnPos, 10, nPos - io_rnPos); const bool bOverflow = (nTemp >= SAL_MAX_INT32); @@ -1161,9 +1303,10 @@ readUnsignedNumber(std::u16string_view rString, return bOverflow ? R_OVERFLOW : R_SUCCESS; } +template<typename V> static Result readUnsignedNumberMaxDigits(int maxDigits, - std::u16string_view rString, size_t & io_rnPos, + V rString, size_t & io_rnPos, sal_Int32 & o_rNumber) { bool bOverflow(false); @@ -1570,6 +1713,15 @@ bool Converter::parseDateTime( util::DateTime& rDateTime, rString); } +/** convert ISO "date" or "dateTime" string to util::DateTime */ +bool Converter::parseDateTime( util::DateTime& rDateTime, + std::string_view rString ) +{ + bool isDateTime; + return parseDateOrDateTime(nullptr, rDateTime, isDateTime, nullptr, + rString); +} + static bool lcl_isLeapYear(const sal_uInt32 nYear) { return ((nYear % 4) == 0) @@ -1673,14 +1825,15 @@ static void lcl_ConvertToUTC( } } +template <typename V> static bool -readDateTimeComponent(std::u16string_view rString, +readDateTimeComponent(V rString, size_t & io_rnPos, sal_Int32 & o_rnTarget, const sal_Int32 nMinLength, const bool bExactLength) { const size_t nOldPos(io_rnPos); sal_Int32 nTemp(0); - if (R_SUCCESS != readUnsignedNumber(rString, io_rnPos, nTemp)) + if (R_SUCCESS != readUnsignedNumber<V>(rString, io_rnPos, nTemp)) { return false; } @@ -1695,12 +1848,13 @@ readDateTimeComponent(std::u16string_view rString, } /** convert ISO "date" or "dateTime" string to util::DateTime or util::Date */ +template<typename V> static bool lcl_parseDate( bool & isNegative, sal_Int32 & nYear, sal_Int32 & nMonth, sal_Int32 & nDay, bool & bHaveTime, size_t & nPos, - std::u16string_view string, + V string, bool const bIgnoreInvalidOrMissingDate) { bool bSuccess = true; @@ -1718,7 +1872,7 @@ static bool lcl_parseDate( // While W3C XMLSchema specifies years with a minimum of 4 digits, be // lenient in what we accept for years < 1000. One digit is acceptable // if the remainders match. - bSuccess = readDateTimeComponent(string, nPos, nYear, 1, false); + bSuccess = readDateTimeComponent<V>(string, nPos, nYear, 1, false); if (!bIgnoreInvalidOrMissingDate) { bSuccess &= (0 < nYear); @@ -1733,7 +1887,7 @@ static bool lcl_parseDate( { ++nPos; - bSuccess = readDateTimeComponent(string, nPos, nMonth, 2, true); + bSuccess = readDateTimeComponent<V>(string, nPos, nMonth, 2, true); if (!bIgnoreInvalidOrMissingDate) { bSuccess &= (0 < nMonth); @@ -1774,11 +1928,12 @@ static bool lcl_parseDate( } /** convert ISO "date" or "dateTime" string to util::DateTime or util::Date */ +template <typename V> static bool lcl_parseDateTime( util::Date *const pDate, util::DateTime & rDateTime, bool & rbDateTime, std::optional<sal_Int16> *const pTimeZoneOffset, - std::u16string_view string, + V string, bool const bIgnoreInvalidOrMissingDate) { bool bSuccess = true; @@ -1793,11 +1948,11 @@ static bool lcl_parseDateTime( bool bHaveTime(false); if ( !bIgnoreInvalidOrMissingDate - || string.find(':') == std::u16string_view::npos // no time? - || (string.find('-') != std::u16string_view::npos + || string.find(':') == V::npos // no time? + || (string.find('-') != V::npos && string.find('-') < string.find(':'))) { - bSuccess &= lcl_parseDate(isNegative, nYear, nMonth, nDay, + bSuccess &= lcl_parseDate<V>(isNegative, nYear, nMonth, nDay, bHaveTime, nPos, string, bIgnoreInvalidOrMissingDate); } else @@ -1845,7 +2000,7 @@ static bool lcl_parseDateTime( ++nPos; const sal_Int32 nStart(nPos); sal_Int32 nTemp(0); - if (R_NOTHING == readUnsignedNumberMaxDigits(9, string, nPos, nTemp)) + if (R_NOTHING == readUnsignedNumberMaxDigits<V>(9, string, nPos, nTemp)) { bSuccess = false; } @@ -1902,7 +2057,7 @@ static bool lcl_parseDateTime( sal_Int32 nTimezoneMinutes(0); if (bSuccess && (bHaveTimezonePlus || bHaveTimezoneMinus)) { - bSuccess = readDateTimeComponent( + bSuccess = readDateTimeComponent<V>( string, nPos, nTimezoneHours, 2, true); bSuccess &= (0 <= nTimezoneHours) && (nTimezoneHours <= 14); bSuccess &= (nPos < string.size()); // not last token @@ -1914,7 +2069,7 @@ static bool lcl_parseDateTime( { ++nPos; - bSuccess = readDateTimeComponent( + bSuccess = readDateTimeComponent<V>( string, nPos, nTimezoneMinutes, 2, true); bSuccess &= (0 <= nTimezoneMinutes) && (nTimezoneMinutes < 60); } @@ -2009,6 +2164,16 @@ bool Converter::parseTimeOrDateTime( nullptr, rDateTime, dummy, nullptr, rString, true); } +/** convert ISO "time" or "dateTime" string to util::DateTime */ +bool Converter::parseTimeOrDateTime( + util::DateTime & rDateTime, + std::string_view rString) +{ + bool dummy; + return lcl_parseDateTime( + nullptr, rDateTime, dummy, nullptr, rString, true); +} + /** convert ISO "date" or "dateTime" string to util::DateTime or util::Date */ bool Converter::parseDateOrDateTime( util::Date *const pDate, util::DateTime & rDateTime, @@ -2020,6 +2185,16 @@ bool Converter::parseDateOrDateTime( pDate, rDateTime, rbDateTime, pTimeZoneOffset, rString, false); } +/** convert ISO "date" or "dateTime" string to util::DateTime or util::Date */ +bool Converter::parseDateOrDateTime( + util::Date *const pDate, util::DateTime & rDateTime, + bool & rbDateTime, + std::optional<sal_Int16> *const pTimeZoneOffset, + std::string_view rString ) +{ + return lcl_parseDateTime( + pDate, rDateTime, rbDateTime, pTimeZoneOffset, rString, false); +} /** gets the position of the first comma after npos in the string rStr. Commas inside '"' pairs are not matched */ @@ -2501,11 +2676,11 @@ static sal_Int16 lcl_GetUnitFromString(V rString, sal_Int16 nDefaultUnit) sal_Int16 Converter::GetUnitFromString(std::u16string_view rString, sal_Int16 nDefaultUnit) { - return lcl_GetUnitFromString<std::u16string_view>(rString, nDefaultUnit); + return lcl_GetUnitFromString(rString, nDefaultUnit); } sal_Int16 Converter::GetUnitFromString(std::string_view rString, sal_Int16 nDefaultUnit) { - return lcl_GetUnitFromString<std::string_view>(rString, nDefaultUnit); + return lcl_GetUnitFromString(rString, nDefaultUnit); } bool Converter::convertAny(OUStringBuffer& rsValue, diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx index 736fa5bbd87d..6b3aa3365568 100644 --- a/xmloff/inc/txtfldi.hxx +++ b/xmloff/inc/txtfldi.hxx @@ -97,7 +97,7 @@ protected: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) = 0; + std::string_view sAttrValue ) = 0; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -139,7 +139,7 @@ protected: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -167,7 +167,7 @@ private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -191,7 +191,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -226,7 +226,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -245,7 +245,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; }; /** import page continuation fields (<text:page-continuation-string>) */ @@ -267,7 +267,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -297,7 +297,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -334,7 +334,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -356,7 +356,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; }; /** import database next fields (<text:database-next>) */ @@ -380,7 +380,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -401,7 +401,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -426,7 +426,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -457,7 +457,7 @@ public: protected: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -488,7 +488,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -530,7 +530,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; virtual void PrepareField( const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; }; @@ -552,7 +552,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -582,7 +582,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -611,7 +611,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -636,7 +636,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -658,7 +658,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -679,7 +679,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -705,7 +705,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -730,7 +730,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -751,7 +751,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -781,7 +781,7 @@ private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -814,7 +814,7 @@ private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -860,7 +860,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// create textfield, attach master, and insert into document virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; @@ -882,7 +882,7 @@ public: private: /// no attributes -> empty method virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// no attributes -> empty method virtual void PrepareField( @@ -900,7 +900,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -922,7 +922,7 @@ public: private: /// no attributes -> empty method virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// no attributes -> empty method virtual void PrepareField( @@ -947,7 +947,7 @@ private: /// empty method; all attributes are handled in StartElement virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// convert aValues into sequence and set property virtual void PrepareField( @@ -981,7 +981,7 @@ public: private: /// process attributes virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// set properties virtual void PrepareField( @@ -1009,7 +1009,7 @@ public: private: /// process attributes virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// set properties virtual void PrepareField( @@ -1029,7 +1029,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -1059,7 +1059,7 @@ public: private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -1077,7 +1077,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -1095,7 +1095,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -1113,7 +1113,7 @@ public: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( diff --git a/xmloff/inc/txtvfldi.hxx b/xmloff/inc/txtvfldi.hxx index 8d0fb73bdd51..67bc233b77cb 100644 --- a/xmloff/inc/txtvfldi.hxx +++ b/xmloff/inc/txtvfldi.hxx @@ -63,7 +63,7 @@ public: /// process attribute values void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ); + std::string_view sAttrValue ); /// prepare XTextField for insertion into document void PrepareField( @@ -154,7 +154,7 @@ public: protected: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -343,7 +343,7 @@ private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -414,7 +414,7 @@ private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// prepare XTextField for insertion into document virtual void PrepareField( @@ -444,7 +444,7 @@ private: /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) override; + std::string_view sAttrValue ) override; /// create, prepare and insert database field master and database field virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index 1517c7b8df86..6cda57185a3b 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -359,6 +359,13 @@ bool SvXMLUnitConverter::convertDateTime(double& fDateTime, return convertDateTime(fDateTime, rString, m_pImpl->m_aNullDate); } +/** convert ISO Date Time String to double */ +bool SvXMLUnitConverter::convertDateTime(double& fDateTime, + std::string_view rString) +{ + return convertDateTime(fDateTime, rString, m_pImpl->m_aNullDate); +} + /** convert double to ISO Date Time String */ void SvXMLUnitConverter::convertDateTime( OUStringBuffer& rBuffer, const double& fDateTime, @@ -447,8 +454,9 @@ void SvXMLUnitConverter::convertDateTime( OUStringBuffer& rBuffer, } /** convert ISO Date Time String to double */ -bool SvXMLUnitConverter::convertDateTime( double& fDateTime, - std::u16string_view rString, const css::util::Date& aTempNullDate) +template<typename V> +static bool lcl_convertDateTime( double& fDateTime, + V rString, const css::util::Date& aTempNullDate) { css::util::DateTime aDateTime; bool bSuccess = ::sax::Converter::parseDateTime(aDateTime, rString); @@ -472,6 +480,18 @@ bool SvXMLUnitConverter::convertDateTime( double& fDateTime, return bSuccess; } +bool SvXMLUnitConverter::convertDateTime( double& fDateTime, + std::u16string_view rString, const css::util::Date& aTempNullDate) +{ + return lcl_convertDateTime(fDateTime, rString, aTempNullDate); +} +/** convert ISO Date Time String to double */ +bool SvXMLUnitConverter::convertDateTime( double& fDateTime, + std::string_view rString, const css::util::Date& aTempNullDate) +{ + return lcl_convertDateTime(fDateTime, rString, aTempNullDate); +} + SvXMLTokenEnumerator::SvXMLTokenEnumerator( std::u16string_view rString, sal_Unicode cSeparator /* = ' ' */ ) : maTokenString( rString ), mnNextTokenPos(0), mcSeparator( cSeparator ) diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index da6a7b7710c0..dd73a5d9395b 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -134,7 +134,7 @@ void XMLTextFieldImportContext::startFastElement( { // process attributes for( auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ) ) - ProcessAttribute(aIter.getToken(), aIter.toString() ); + ProcessAttribute(aIter.getToken(), aIter.toView() ); } OUString const & XMLTextFieldImportContext::GetContent() @@ -552,7 +552,7 @@ void XMLSenderFieldImportContext::startFastElement( void XMLSenderFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue) + std::string_view sAttrValue) { if (XML_ELEMENT(TEXT, XML_FIXED) == nAttrToken) { @@ -621,7 +621,7 @@ void XMLAuthorFieldImportContext::startFastElement( XMLTextFieldImportContext::startFastElement(nElement, xAttrList); } -void XMLAuthorFieldImportContext::ProcessAttribute(sal_Int32 nAttrToken, const OUString& sAttrValue) +void XMLAuthorFieldImportContext::ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) { if(nAttrToken == XML_ELEMENT(TEXT, XML_FIXED)) { @@ -685,7 +685,7 @@ XMLPageContinuationImportContext::XMLPageContinuationImportContext( } void XMLPageContinuationImportContext::ProcessAttribute( - sal_Int32 nAttrToken, const OUString& sAttrValue ) + sal_Int32 nAttrToken, std::string_view sAttrValue ) { switch(nAttrToken) { @@ -702,7 +702,7 @@ void XMLPageContinuationImportContext::ProcessAttribute( } case XML_ELEMENT(TEXT, XML_STRING_VALUE): case XML_ELEMENT(OFFICE, XML_STRING_VALUE): - sString = sAttrValue; + sString = OUString::fromUtf8(sAttrValue); sStringOK = true; break; default: @@ -744,16 +744,16 @@ XMLPageNumberImportContext::XMLPageNumberImportContext( void XMLPageNumberImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(STYLE, XML_NUM_FORMAT): - sNumberFormat = sAttrValue; + sNumberFormat = OUString::fromUtf8(sAttrValue); sNumberFormatOK = true; break; case XML_ELEMENT(STYLE, XML_NUM_LETTER_SYNC): - sNumberSync = sAttrValue; + sNumberSync = OUString::fromUtf8(sAttrValue); break; case XML_ELEMENT(TEXT, XML_SELECT_PAGE): SvXMLUnitConverter::convertEnum(eSelectPage, sAttrValue, @@ -838,11 +838,11 @@ XMLPlaceholderFieldImportContext::XMLPlaceholderFieldImportContext( /// process attribute values void XMLPlaceholderFieldImportContext::ProcessAttribute( - sal_Int32 nAttrToken, const OUString& sAttrValue ) + sal_Int32 nAttrToken, std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(TEXT, XML_DESCRIPTION): - sDescription = sAttrValue; + sDescription = OUString::fromUtf8(sAttrValue); break; case XML_ELEMENT(TEXT, XML_PLACEHOLDER_TYPE): @@ -930,7 +930,7 @@ XMLTimeFieldImportContext::XMLTimeFieldImportContext( } void XMLTimeFieldImportContext::ProcessAttribute( - sal_Int32 nAttrToken, const OUString& sAttrValue ) + sal_Int32 nAttrToken, std::string_view sAttrValue ) { switch (nAttrToken) { @@ -955,7 +955,7 @@ void XMLTimeFieldImportContext::ProcessAttribute( case XML_ELEMENT(STYLE, XML_DATA_STYLE_NAME): { sal_Int32 nKey = GetImportHelper().GetDataStyleKey( - sAttrValue, &bIsDefaultLanguage); + OUString::fromUtf8(sAttrValue), &bIsDefaultLanguage); if (-1 != nKey) { nFormatKey = nKey; @@ -1050,7 +1050,7 @@ XMLDateFieldImportContext::XMLDateFieldImportContext( void XMLDateFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { @@ -1109,17 +1109,17 @@ XMLDatabaseFieldImportContext::XMLDatabaseFieldImportContext( } void XMLDatabaseFieldImportContext::ProcessAttribute( - sal_Int32 nAttrToken, const OUString& sAttrValue ) + sal_Int32 nAttrToken, std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(TEXT, XML_DATABASE_NAME): - m_sDatabaseName = sAttrValue; + m_sDatabaseName = OUString::fromUtf8(sAttrValue); m_bDatabaseOK = true; m_bDatabaseNameOK = true; break; case XML_ELEMENT(TEXT, XML_TABLE_NAME): - m_sTableName = sAttrValue; + m_sTableName = OUString::fromUtf8(sAttrValue); m_bTableOK = true; break; case XML_ELEMENT(TEXT, XML_TABLE_TYPE): @@ -1178,7 +1178,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLDatabaseFieldImport } // we call ProcessAttribute in order to set bValid appropriately - ProcessAttribute( XML_TOKEN_INVALID, OUString() ); + ProcessAttribute( XML_TOKEN_INVALID, "" ); } else XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); @@ -1225,7 +1225,7 @@ XMLDatabaseNameImportContext::XMLDatabaseNameImportContext( } void XMLDatabaseNameImportContext::ProcessAttribute( - sal_Int32 nAttrToken, const OUString& sAttrValue ) + sal_Int32 nAttrToken, std::string_view sAttrValue ) { // delegate to superclass and check for success XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken, sAttrValue); @@ -1257,20 +1257,20 @@ XMLDatabaseNextImportContext::XMLDatabaseNextImportContext( } void XMLDatabaseNextImportContext::ProcessAttribute( - sal_Int32 nAttrToken, const OUString& sAttrValue ) + sal_Int32 nAttrToken, std::string_view sAttrValue ) { if (XML_ELEMENT(TEXT, XML_CONDITION) == nAttrToken) { OUString sTmp; sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrValueQName( - sAttrValue, &sTmp ); + OUString::fromUtf8(sAttrValue), &sTmp ); if( XML_NAMESPACE_OOOW == nPrefix ) { sCondition = sTmp; bConditionOK = true; } else - sCondition = sAttrValue; + sCondition = OUString::fromUtf8(sAttrValue); } else { @@ -1307,7 +1307,7 @@ XMLDatabaseSelectImportContext::XMLDatabaseSelectImportContext( void XMLDatabaseSelectImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { if (XML_ELEMENT(TEXT, XML_ROW_NUMBER) == nAttrToken) { @@ -1354,15 +1354,15 @@ XMLDatabaseNumberImportContext::XMLDatabaseNumberImportContext( void XMLDatabaseNumberImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(STYLE, XML_NUM_FORMAT): - sNumberFormat = sAttrValue; + sNumberFormat = OUString::fromUtf8(sAttrValue); break; case XML_ELEMENT(STYLE, XML_NUM_LETTER_SYNC): - sNumberSync = sAttrValue; + sNumberSync = OUString::fromUtf8(sAttrValue); break; case XML_ELEMENT(TEXT, XML_VALUE_TYPE): case XML_ELEMENT(OFFICE, XML_VALUE_TYPE): @@ -1423,7 +1423,7 @@ XMLSimpleDocInfoImportContext::XMLSimpleDocInfoImportContext( void XMLSimpleDocInfoImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { if (XML_ELEMENT(TEXT, XML_FIXED) == nAttrToken) { @@ -1629,14 +1629,14 @@ XMLDateTimeDocInfoImportContext::XMLDateTimeDocInfoImportContext( void XMLDateTimeDocInfoImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(STYLE, XML_DATA_STYLE_NAME): { sal_Int32 nKey = GetImportHelper().GetDataStyleKey( - sAttrValue, &bIsDefaultLanguage); + OUString::fromUtf8(sAttrValue), &bIsDefaultLanguage); if (-1 != nKey) { nFormat = nKey; @@ -1700,14 +1700,14 @@ XMLUserDocInfoImportContext::XMLUserDocInfoImportContext( void XMLUserDocInfoImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(STYLE, XML_DATA_STYLE_NAME): { sal_Int32 nKey = GetImportHelper().GetDataStyleKey( - sAttrValue, &bIsDefaultLanguage); + OUString::fromUtf8(sAttrValue), &bIsDefaultLanguage); if (-1 != nKey) { nFormat = nKey; @@ -1720,7 +1720,7 @@ void XMLUserDocInfoImportContext::ProcessAttribute( if (!bValid) { SetServiceName(sAPI_docinfo_custom ); - aName = sAttrValue; + aName = OUString::fromUtf8(sAttrValue); bValid = true; } break; @@ -1774,20 +1774,20 @@ XMLHiddenParagraphImportContext::XMLHiddenParagraphImportContext( void XMLHiddenParagraphImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { if ( XML_ELEMENT(TEXT, XML_CONDITION) == nAttrToken) { OUString sTmp; sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrValueQName( - sAttrValue, &sTmp ); + OUString::fromUtf8(sAttrValue), &sTmp ); if( XML_NAMESPACE_OOOW == nPrefix ) { sCondition = sTmp; bValid = true; } else - sCondition = sAttrValue; + sCondition = OUString::fromUtf8(sAttrValue); } else if ( XML_ELEMENT(TEXT, XML_IS_HIDDEN) == nAttrToken) { @@ -1829,7 +1829,7 @@ XMLConditionalTextImportContext::XMLConditionalTextImportContext( void XMLConditionalTextImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { @@ -1837,22 +1837,22 @@ void XMLConditionalTextImportContext::ProcessAttribute( { OUString sTmp; sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrValueQName(sAttrValue, &sTmp); + GetKeyByAttrValueQName(OUString::fromUtf8(sAttrValue), &sTmp); if( XML_NAMESPACE_OOOW == nPrefix ) { sCondition = sTmp; bConditionOK = true; } else - sCondition = sAttrValue; + sCondition = OUString::fromUtf8(sAttrValue); } break; case XML_ELEMENT(TEXT, XML_STRING_VALUE_IF_FALSE): - sFalseContent = sAttrValue; + sFalseContent = OUString::fromUtf8(sAttrValue); bFalseOK = true; break; case XML_ELEMENT(TEXT, XML_STRING_VALUE_IF_TRUE): - sTrueContent = sAttrValue; + sTrueContent = OUString::fromUtf8(sAttrValue); bTrueOK = true; break; case XML_ELEMENT(TEXT, XML_CURRENT_VALUE): @@ -1899,7 +1899,7 @@ XMLHiddenTextImportContext::XMLHiddenTextImportContext( void XMLHiddenTextImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { @@ -1907,19 +1907,19 @@ void XMLHiddenTextImportContext::ProcessAttribute( { OUString sTmp; sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrValueQName(sAttrValue, &sTmp); + GetKeyByAttrValueQName(OUString::fromUtf8(sAttrValue), &sTmp); if( XML_NAMESPACE_OOOW == nPrefix ) { sCondition = sTmp; bConditionOK = true; } else - sCondition = sAttrValue; + sCondition = OUString::fromUtf8(sAttrValue); } break; case XML_ELEMENT(TEXT, XML_STRING_VALUE): case XML_ELEMENT(OFFICE, XML_STRING_VALUE): - sString = sAttrValue; + sString = OUString::fromUtf8(sAttrValue); bStringOK = true; break; case XML_ELEMENT(TEXT, XML_IS_HIDDEN): @@ -1974,7 +1974,7 @@ XMLFileNameImportContext::XMLFileNameImportContext( void XMLFileNameImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { @@ -2054,7 +2054,7 @@ XMLTemplateNameImportContext::XMLTemplateNameImportContext( void XMLTemplateNameImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { @@ -2109,7 +2109,7 @@ XMLChapterImportContext::XMLChapterImportContext( void XMLChapterImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { @@ -2170,16 +2170,16 @@ XMLCountFieldImportContext::XMLCountFieldImportContext( void XMLCountFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(STYLE, XML_NUM_FORMAT): - sNumberFormat = sAttrValue; + sNumberFormat = OUString::fromUtf8(sAttrValue); bNumberFormatOK = true; break; case XML_ELEMENT(STYLE, XML_NUM_LETTER_SYNC): - sLetterSync = sAttrValue; + sLetterSync = OUString::fromUtf8(sAttrValue); break; default: XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue); @@ -2263,16 +2263,16 @@ XMLPageVarGetFieldImportContext::XMLPageVarGetFieldImportContext( void XMLPageVarGetFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(STYLE, XML_NUM_FORMAT): - sNumberFormat = sAttrValue; + sNumberFormat = OUString::fromUtf8(sAttrValue); bNumberFormatOK = true; break; case XML_ELEMENT(STYLE, XML_NUM_LETTER_SYNC): - sLetterSync = sAttrValue; + sLetterSync = OUString::fromUtf8(sAttrValue); break; default: XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue); @@ -2313,7 +2313,7 @@ XMLPageVarSetFieldImportContext::XMLPageVarSetFieldImportContext( void XMLPageVarSetFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { @@ -2377,16 +2377,16 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLMacroFieldImportCon void XMLMacroFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(TEXT, XML_DESCRIPTION): - sDescription = sAttrValue; + sDescription = OUString::fromUtf8(sAttrValue); bDescriptionOK = true; break; case XML_ELEMENT(TEXT, XML_NAME): - sMacro = sAttrValue; + sMacro = OUString::fromUtf8(sAttrValue); bValid = true; break; default: @@ -2525,7 +2525,7 @@ void XMLReferenceFieldImportContext::startFastElement( void XMLReferenceFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { @@ -2534,7 +2534,7 @@ void XMLReferenceFieldImportContext::ProcessAttribute( nSource = ReferenceFieldSource::ENDNOTE; break; case XML_ELEMENT(TEXT, XML_REF_NAME): - sName = sAttrValue; + sName = OUString::fromUtf8(sAttrValue); bNameOK = true; break; case XML_ELEMENT(TEXT, XML_REFERENCE_FORMAT): @@ -2559,7 +2559,7 @@ void XMLReferenceFieldImportContext::ProcessAttribute( } case XML_ELEMENT(LO_EXT, XML_REFERENCE_LANGUAGE): case XML_ELEMENT(TEXT, XML_REFERENCE_LANGUAGE): - sLanguage = sAttrValue; + sLanguage = OUString::fromUtf8(sAttrValue); break; default: XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue); @@ -2742,11 +2742,11 @@ XMLDdeFieldImportContext::XMLDdeFieldImportContext( void XMLDdeFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { if ( XML_ELEMENT(TEXT, XML_CONNECTION_NAME) == nAttrToken) { - sName = sAttrValue; + sName = OUString::fromUtf8(sAttrValue); bValid = true; } else @@ -2818,7 +2818,7 @@ XMLSheetNameImportContext::XMLSheetNameImportContext( void XMLSheetNameImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue) + std::string_view sAttrValue) { // no attributes -> nothing to be done XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue); @@ -2842,7 +2842,7 @@ XMLPageNameFieldImportContext::XMLPageNameFieldImportContext( /// process attribute values void XMLPageNameFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue); } @@ -2867,16 +2867,16 @@ XMLUrlFieldImportContext::XMLUrlFieldImportContext( void XMLUrlFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(XLINK, XML_HREF): - sURL = GetImport().GetAbsoluteReference( sAttrValue ); + sURL = GetImport().GetAbsoluteReference( OUString::fromUtf8(sAttrValue) ); bValid = true; break; case XML_ELEMENT(OFFICE, XML_TARGET_FRAME_NAME): - sFrame = sAttrValue; + sFrame = OUString::fromUtf8(sAttrValue); bFrameOK = true; break; default: @@ -2986,7 +2986,7 @@ void XMLBibliographyFieldImportContext::startFastElement( void XMLBibliographyFieldImportContext::ProcessAttribute( sal_Int32 , - const OUString& ) + std::string_view ) { // attributes are handled in StartElement assert(false && "This should not have happened."); @@ -3137,12 +3137,12 @@ XMLAnnotationImportContext::XMLAnnotationImportContext( void XMLAnnotationImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { if (nAttrToken == XML_ELEMENT(OFFICE, XML_NAME)) - aName = sAttrValue; + aName = OUString::fromUtf8(sAttrValue); else if (nAttrToken == XML_ELEMENT(LO_EXT, XML_RESOLVED)) - aResolved = sAttrValue; + aResolved = OUString::fromUtf8(sAttrValue); else XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue); } @@ -3337,17 +3337,17 @@ XMLScriptImportContext::XMLScriptImportContext( void XMLScriptImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(XLINK, XML_HREF): - sContent = GetImport().GetAbsoluteReference( sAttrValue ); + sContent = GetImport().GetAbsoluteReference( OUString::fromUtf8(sAttrValue) ); bContentOK = true; break; case XML_ELEMENT(SCRIPT, XML_LANGUAGE): - sScriptType = sAttrValue; + sScriptType = OUString::fromUtf8(sAttrValue); break; default: @@ -3390,7 +3390,7 @@ XMLMeasureFieldImportContext::XMLMeasureFieldImportContext( void XMLMeasureFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { @@ -3486,21 +3486,21 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLDropDownFieldImport void XMLDropDownFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { if( nAttrToken == XML_ELEMENT(TEXT, XML_NAME)) { - sName = sAttrValue; + sName = OUString::fromUtf8(sAttrValue); bNameOK = true; } else if (nAttrToken == XML_ELEMENT(TEXT, XML_HELP)) { - sHelp = sAttrValue; + sHelp = OUString::fromUtf8(sAttrValue); bHelpOK = true; } else if (nAttrToken == XML_ELEMENT(TEXT, XML_HINT)) { - sHint = sAttrValue; + sHint = OUString::fromUtf8(sAttrValue); bHintOK = true; } else @@ -3556,7 +3556,7 @@ XMLHeaderFieldImportContext::XMLHeaderFieldImportContext( } /// process attribute values -void XMLHeaderFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, const OUString& sAttrValue ) +void XMLHeaderFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, std::string_view sAttrValue ) { XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue); } @@ -3578,7 +3578,7 @@ XMLFooterFieldImportContext::XMLFooterFieldImportContext( } /// process attribute values -void XMLFooterFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, const OUString& sAttrValue) +void XMLFooterFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, std::string_view sAttrValue) { XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue); } @@ -3602,7 +3602,7 @@ XMLDateTimeFieldImportContext::XMLDateTimeFieldImportContext( /// process attribute values void XMLDateTimeFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue); } diff --git a/xmloff/source/text/txtvfldi.cxx b/xmloff/source/text/txtvfldi.cxx index f9e9a8a2fdba..bc59faa149fb 100644 --- a/xmloff/source/text/txtvfldi.cxx +++ b/xmloff/source/text/txtvfldi.cxx @@ -108,38 +108,38 @@ XMLVarFieldImportContext::XMLVarFieldImportContext( void XMLVarFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(TEXT, XML_NAME): - sName = sAttrValue; + sName = OUString::fromUtf8(sAttrValue); bValid = true; // we assume: field with name is valid! break; case XML_ELEMENT(TEXT, XML_DESCRIPTION): - sDescription = sAttrValue; + sDescription = OUString::fromUtf8(sAttrValue); bDescriptionOK = true; break; case XML_ELEMENT(TEXT, XML_HELP): - sHelp = sAttrValue; + sHelp = OUString::fromUtf8(sAttrValue); bHelpOK = true; break; case XML_ELEMENT(TEXT, XML_HINT): - sHint = sAttrValue; + sHint = OUString::fromUtf8(sAttrValue); bHintOK = true; break; case XML_ELEMENT(TEXT, XML_FORMULA): { OUString sTmp; sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrValueQName(sAttrValue, &sTmp); + GetKeyByAttrValueQName(OUString::fromUtf8(sAttrValue), &sTmp); if( XML_NAMESPACE_OOOW == nPrefix ) { sFormula = sTmp; bFormulaOK = true; } else - sFormula = sAttrValue; + sFormula = OUString::fromUtf8(sAttrValue); } break; case XML_ELEMENT(TEXT, XML_DISPLAY): @@ -343,18 +343,18 @@ XMLSequenceFieldImportContext::XMLSequenceFieldImportContext( } void XMLSequenceFieldImportContext::ProcessAttribute( - sal_Int32 nAttrToken, const OUString& sAttrValue ) + sal_Int32 nAttrToken, std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(STYLE, XML_NUM_FORMAT): - sNumFormat = sAttrValue; + sNumFormat = OUString::fromUtf8(sAttrValue); break; case XML_ELEMENT(STYLE, XML_NUM_LETTER_SYNC): - sNumFormatSync = sAttrValue; + sNumFormatSync = OUString::fromUtf8(sAttrValue); break; case XML_ELEMENT(TEXT, XML_REF_NAME): - sRefName = sAttrValue; + sRefName = OUString::fromUtf8(sAttrValue); bRefNameOK = true; break; default: @@ -585,7 +585,7 @@ XMLTableFormulaImportContext::XMLTableFormulaImportContext( void XMLTableFormulaImportContext::ProcessAttribute( sal_Int32 nAttrToken, - const OUString& sAttrValue ) + std::string_view sAttrValue ) { switch (nAttrToken) { @@ -731,7 +731,7 @@ XMLVariableDeclImportContext::XMLVariableDeclImportContext( default: // delegate to value helper - aValueHelper.ProcessAttribute(aIter.getToken(), aIter.toString()); + aValueHelper.ProcessAttribute(aIter.getToken(), aIter.toView()); break; } } @@ -913,12 +913,12 @@ XMLDatabaseDisplayImportContext::XMLDatabaseDisplayImportContext( } void XMLDatabaseDisplayImportContext::ProcessAttribute( - sal_Int32 nAttrToken, const OUString& sAttrValue ) + sal_Int32 nAttrToken, std::string_view sAttrValue ) { switch (nAttrToken) { case XML_ELEMENT(TEXT, XML_COLUMN_NAME): - sColumnName = sAttrValue; + sColumnName = OUString::fromUtf8(sAttrValue); bColumnOK = true; break; case XML_ELEMENT(TEXT, XML_DISPLAY): @@ -1079,7 +1079,7 @@ XMLValueImportHelper::XMLValueImportHelper( } void XMLValueImportHelper::ProcessAttribute( - sal_Int32 nAttrToken, const OUString& sAttrValue ) + sal_Int32 nAttrToken, std::string_view sAttrValue ) { switch (nAttrToken) { @@ -1168,7 +1168,7 @@ void XMLValueImportHelper::ProcessAttribute( case XML_ELEMENT(TEXT, XML_STRING_VALUE): case XML_ELEMENT(OFFICE, XML_STRING_VALUE): - sValue = sAttrValue; + sValue = OUString::fromUtf8(sAttrValue); bStringValueOK = true; break; @@ -1176,21 +1176,21 @@ void XMLValueImportHelper::ProcessAttribute( { OUString sTmp; sal_uInt16 nPrefix = rImport.GetNamespaceMap(). - GetKeyByAttrValueQName(sAttrValue, &sTmp); + GetKeyByAttrValueQName(OUString::fromUtf8(sAttrValue), &sTmp); if( XML_NAMESPACE_OOOW == nPrefix ) { sFormula = sTmp; bFormulaOK = true; } else - sFormula = sAttrValue; + sFormula = OUString::fromUtf8(sAttrValue); } break; case XML_ELEMENT(STYLE, XML_DATA_STYLE_NAME): { sal_Int32 nKey = rHelper.GetDataStyleKey( - sAttrValue, &bIsDefaultLanguage); + OUString::fromUtf8(sAttrValue), &bIsDefaultLanguage); if (-1 != nKey) { nFormatKey = nKey; |