23#include <osl/diagnose.h>
24#include <rtl/ustrbuf.hxx>
37const sal_Int32 XSTRING_ENCCHAR_LEN = 7;
41 if( (
'0' <= cDigit) && (cDigit <=
'9') ) { orcChar |= ((cDigit -
'0') << nBitShift);
return true; }
42 if( (
'a' <= cDigit) && (cDigit <=
'f') ) { orcChar |= ((cDigit -
'a' + 10) << nBitShift);
return true; }
43 if( (
'A' <= cDigit) && (cDigit <=
'F') ) { orcChar |= ((cDigit -
'A' + 10) << nBitShift);
return true; }
50 if( (pcEnd - rpcStr >= XSTRING_ENCCHAR_LEN) &&
51 (rpcStr[ 0 ] ==
'_') &&
52 (rpcStr[ 1 ] ==
'x') &&
53 (rpcStr[ 6 ] ==
'_') &&
54 lclAddHexDigit( cChar, rpcStr[ 2 ], 12 ) &&
55 lclAddHexDigit( cChar, rpcStr[ 3 ], 8 ) &&
56 lclAddHexDigit( cChar, rpcStr[ 4 ], 4 ) &&
57 lclAddHexDigit( cChar, rpcStr[ 5 ], 0 ) )
59 rpcStr += XSTRING_ENCCHAR_LEN;
67#define STRING_TO_TOKEN(color) if (sColorName == u"" #color) return XML_##color
99 if( rValue.getLength() < XSTRING_ENCCHAR_LEN )
101 if (rValue.indexOf(
u"_x") == -1)
106 const sal_Unicode* pcEnd = pcStr + rValue.getLength();
107 while( pcStr < pcEnd )
108 aBuffer.append( lclGetXChar( pcStr, pcEnd ) );
137 mxAttribs( rxAttribs ),
138 mpAttribList( nullptr )
140 OSL_ENSURE( mxAttribs.is(),
"AttributeList::AttributeList - missing attribute list interface" );
154 return mxAttribs->hasAttribute( nAttrToken );
159 OUString sColorVal =
mxAttribs->getValue(nAttrToken);
176 if(
mxAttribs->hasAttribute( nAttrToken ) )
177 return std::optional< OUString >(
mxAttribs->getOptionalValue( nAttrToken ) );
178 return std::optional< OUString >();
184 if(
mxAttribs->hasAttribute( nAttrToken ) )
185 return mxAttribs->getOptionalValue( nAttrToken );
192 if(
mxAttribs->hasAttribute( nAttrToken ) )
194 return std::optional< OUString >();
201 return bValid ? std::optional< double >(
nValue ) : std::optional< double >();
208 return bValid ? std::optional< sal_Int32 >(
nValue ) : std::optional< sal_Int32 >();
213 OUString aValue =
mxAttribs->getOptionalValue( nAttrToken );
214 bool bValid = !aValue.isEmpty();
220 std::string_view aValue =
getView( nAttrToken );
221 bool bValid = !aValue.empty();
222 return bValid ? std::optional< sal_Int64 >(
o3tl::toInt64( aValue ) ) : std::optional< sal_Int64 >();
227 OUString aValue =
mxAttribs->getOptionalValue( nAttrToken );
228 bool bValid = !aValue.isEmpty();
234 std::string_view pAttr;
239 return std::optional< bool >();
240 if( pAttr ==
"false" )
241 return std::optional< bool >(
false );
242 if( pAttr ==
"true" )
243 return std::optional< bool >(
true );
250 case XML_t:
return std::optional< bool >(
true );
251 case XML_true:
return std::optional< bool >(
true );
252 case XML_on:
return std::optional< bool >(
true );
253 case XML_f:
return std::optional< bool >(
false );
254 case XML_false:
return std::optional< bool >(
false );
255 case XML_off:
return std::optional< bool >(
false );
257 std::optional< sal_Int32 > onValue =
getInteger( nAttrToken );
258 return onValue.has_value() ? std::optional< bool >( onValue.value() != 0 ) : std::optional< bool >();
263 std::string_view aValue =
getView( nAttrToken );
264 util::DateTime aDateTime;
265 bool bValid = (aValue.size() == 19 || (aValue.size() == 20 && aValue[19] ==
'Z')) &&
266 (aValue[ 4 ] ==
'-') && (aValue[ 7 ] ==
'-') && (aValue[ 10 ] ==
'T') &&
267 (aValue[ 13 ] ==
':') && (aValue[ 16 ] ==
':');
270 SAL_WARN(
"oox",
"bad date string: " << aValue);
271 return std::optional< util::DateTime >();
273 aDateTime.Year =
static_cast< sal_uInt16
>(
o3tl::toInt32(aValue.substr( 0, 4 )) );
274 aDateTime.Month =
static_cast< sal_uInt16
>(
o3tl::toInt32(aValue.substr( 5, 2 )) );
275 aDateTime.Day =
static_cast< sal_uInt16
>(
o3tl::toInt32(aValue.substr( 8, 2 )) );
276 aDateTime.Hours =
static_cast< sal_uInt16
>(
o3tl::toInt32(aValue.substr( 11, 2 )) );
277 aDateTime.Minutes =
static_cast< sal_uInt16
>(
o3tl::toInt32(aValue.substr( 14, 2 )) );
278 aDateTime.Seconds =
static_cast< sal_uInt16
>(
o3tl::toInt32(aValue.substr( 17, 2 )) );
279 return std::optional< util::DateTime >( aDateTime );
286 return mxAttribs->getOptionalValueToken( nAttrToken, nDefault );
292 if (rDefault.isEmpty())
293 return mxAttribs->getOptionalValue( nAttrToken );
297 return mxAttribs->getValue( nAttrToken );
307 return getXString( nAttrToken ).value_or( rDefault );
319 return getDouble( nAttrToken ).value_or( fDefault );
324 return getInteger( nAttrToken ).value_or( nDefault );
329 return getUnsigned( nAttrToken ).value_or( nDefault );
334 return getHyper( nAttrToken ).value_or( nDefault );
349 return getBool( nAttrToken ).value_or( bDefault );
354 return getDateTime( nAttrToken ).value_or( rDefault );
359 std::vector<sal_Int32> aValues;
360 OUString sValue =
getString(nAttrToken,
"");
#define STRING_TO_TOKEN(color)
static sal_Int32 decodeIntegerHex(std::u16string_view rValue)
Returns the 32-bit signed integer value from the passed string (hexadecimal).
static sal_uInt32 decodeUnsigned(std::u16string_view rValue)
Returns the 32-bit unsigned integer value from the passed string (decimal).
static OUString decodeXString(const OUString &rValue)
Returns the decoded string value.
static sal_Int64 decodeHyper(std::u16string_view rValue)
Returns the 64-bit signed integer value from the passed string (decimal).
static sal_Int32 decodeInteger(std::u16string_view rValue)
Returns the 32-bit signed integer value from the passed string (decimal).
static sal_Int32 decodeToken(std::u16string_view rValue)
Returns the XML token identifier from the passed string.
std::optional< css::util::DateTime > getDateTime(sal_Int32 nAttrToken) const
Returns the date/time value of the specified attribute.
sax_fastparser::FastAttributeList * getAttribList() const
css::uno::Reference< css::xml::sax::XFastAttributeList > mxAttribs
sal_uInt32 getUnsignedHex(sal_Int32 nAttrToken, sal_uInt32 nDefault) const
oox::drawingml::Color getHighlightColor(sal_Int32 nAttrToken) const
Returns the Color object of highlight of the text.
std::vector< sal_Int32 > getTokenList(sal_Int32 nAttrToken) const
OUString getStringDefaulted(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute, returns an empty string if attribute not present...
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
sax_fastparser::FastAttributeList * mpAttribList
std::optional< OUString > getXString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
std::optional< sal_uInt32 > getUnsigned(sal_Int32 nAttrToken) const
Returns the 32-bit unsigned integer value of the specified attribute (decimal).
std::optional< sal_Int32 > getIntegerHex(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (hexadecimal).
AttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs)
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
std::optional< sal_Int64 > getHyper(sal_Int32 nAttrToken) const
Returns the 64-bit signed integer value of the specified attribute (decimal).
std::string_view getView(sal_Int32 nAttrToken) const
std::optional< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
std::optional< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
std::optional< double > getDouble(sal_Int32 nAttrToken) const
Returns the double value of the specified attribute.
static sal_Int32 getTokenFromUnicode(std::u16string_view rUnicodeName)
Returns the token identifier for the passed Unicode token name.
void setHighlight(sal_Int32 nToken)
Sets a predefined color from the w:highlight element.
bool getAsView(sal_Int32 nToken, std::string_view &rPos) const
bool getAsDouble(sal_Int32 nToken, double &rDouble) const
bool getAsInteger(sal_Int32 nToken, sal_Int32 &rInt) const
#define SAL_WARN(area, stream)
OUString sanitizeStringSurrogates(const OUString &rString)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
sal_Int64 toInt64(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
sal_uInt32 toUInt32(std::u16string_view str, sal_Int16 radix=10)
sal_Int32 getHighlightColorTokenFromString(std::u16string_view sColorName)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
std::unique_ptr< char[]> aBuffer