22 #include <osl/diagnose.h>
23 #include <rtl/ustrbuf.hxx>
35 const sal_Int32 XSTRING_ENCCHAR_LEN = 7;
39 if( (
'0' <= cDigit) && (cDigit <=
'9') ) { orcChar |= ((cDigit -
'0') << nBitShift);
return true; }
40 if( (
'a' <= cDigit) && (cDigit <=
'f') ) { orcChar |= ((cDigit -
'a' + 10) << nBitShift);
return true; }
41 if( (
'A' <= cDigit) && (cDigit <=
'F') ) { orcChar |= ((cDigit -
'A' + 10) << nBitShift);
return true; }
48 if( (pcEnd - rpcStr >= XSTRING_ENCCHAR_LEN) &&
49 (rpcStr[ 0 ] ==
'_') &&
50 (rpcStr[ 1 ] ==
'x') &&
51 (rpcStr[ 6 ] ==
'_') &&
52 lclAddHexDigit( cChar, rpcStr[ 2 ], 12 ) &&
53 lclAddHexDigit( cChar, rpcStr[ 3 ], 8 ) &&
54 lclAddHexDigit( cChar, rpcStr[ 4 ], 4 ) &&
55 lclAddHexDigit( cChar, rpcStr[ 5 ], 0 ) )
57 rpcStr += XSTRING_ENCCHAR_LEN;
65 #define STRING_TO_TOKEN(color) if (sColorName == u"" #color) return XML_##color
97 if( rValue.getLength() < XSTRING_ENCCHAR_LEN )
101 const sal_Unicode* pcEnd = pcStr + rValue.getLength();
102 while( pcStr < pcEnd )
103 aBuffer.append( lclGetXChar( pcStr, pcEnd ) );
104 return aBuffer.makeStringAndClear();
109 return rValue.toInt32();
114 return getLimitedValue< sal_uInt32, sal_Int64 >( rValue.toInt64(), 0,
SAL_MAX_UINT32 );
119 return rValue.toInt64();
126 return static_cast< sal_Int32
>(rValue.toUInt32( 16 ));
132 mxAttribs( rxAttribs ),
133 mpAttribList( nullptr )
135 OSL_ENSURE( mxAttribs.is(),
"AttributeList::AttributeList - missing attribute list interface" );
149 return mxAttribs->hasAttribute( nAttrToken );
154 OUString sColorVal =
mxAttribs->getValue(nAttrToken);
171 if(
mxAttribs->hasAttribute( nAttrToken ) )
179 if(
mxAttribs->hasAttribute( nAttrToken ) )
200 OUString aValue =
mxAttribs->getOptionalValue( nAttrToken );
201 bool bValid = !aValue.isEmpty();
207 OUString aValue =
mxAttribs->getOptionalValue( nAttrToken );
208 bool bValid = !aValue.isEmpty();
214 OUString aValue =
mxAttribs->getOptionalValue( nAttrToken );
215 bool bValid = !aValue.isEmpty();
227 if( !strcmp( pAttr,
"false" ) )
229 if( !strcmp( pAttr,
"true" ) )
250 OUString aValue =
mxAttribs->getOptionalValue( nAttrToken );
251 util::DateTime aDateTime;
252 bool bValid = (aValue.getLength() == 19) && (aValue[ 4 ] ==
'-') && (aValue[ 7 ] ==
'-') &&
253 (aValue[ 10 ] ==
'T') && (aValue[ 13 ] ==
':') && (aValue[ 16 ] ==
':');
256 aDateTime.Year =
static_cast< sal_uInt16
>( aValue.copy( 0, 4 ).toInt32() );
257 aDateTime.Month =
static_cast< sal_uInt16
>( aValue.copy( 5, 2 ).toInt32() );
258 aDateTime.Day =
static_cast< sal_uInt16
>( aValue.copy( 8, 2 ).toInt32() );
259 aDateTime.Hours =
static_cast< sal_uInt16
>( aValue.copy( 11, 2 ).toInt32() );
260 aDateTime.Minutes =
static_cast< sal_uInt16
>( aValue.copy( 14, 2 ).toInt32() );
261 aDateTime.Seconds =
static_cast< sal_uInt16
>( aValue.copy( 17, 2 ).toInt32() );
270 return mxAttribs->getOptionalValueToken( nAttrToken, nDefault );
276 if (rDefault.isEmpty())
277 return mxAttribs->getOptionalValue( nAttrToken );
281 return mxAttribs->getValue( nAttrToken );
296 const char*
p =
nullptr;
346 std::vector<sal_Int32> aValues;
347 OUString sValue =
getString(nAttrToken,
"");
352 }
while (nIndex >= 0);
OptValue< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
void setHighlight(sal_Int32 nToken)
Sets a predefined color from the w:highlight element.
OptValue< OUString > getXString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
static OUString decodeXString(const OUString &rValue)
Returns the decoded string value.
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
css::uno::Reference< css::xml::sax::XFastAttributeList > mxAttribs
AttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
OptValue< double > getDouble(sal_Int32 nAttrToken) const
Returns the double value of the specified attribute.
OptValue< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
oox::drawingml::Color getHighlightColor(sal_Int32 nAttrToken) const
Returns the Color object of highlight of the text.
sal_uInt32 getUnsignedHex(sal_Int32 nAttrToken, sal_uInt32 nDefault) const
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
OptValue< css::util::DateTime > getDateTime(sal_Int32 nAttrToken) const
Returns the date/time value of the specified attribute.
sal_Int32 getHighlightColorTokenFromString(std::u16string_view sColorName)
OptValue< sal_uInt32 > getUnsigned(sal_Int32 nAttrToken) const
Returns the 32-bit unsigned integer value of the specified attribute (decimal).
#define STRING_TO_TOKEN(color)
static sal_Int32 getTokenFromUnicode(std::u16string_view rUnicodeName)
Returns the token identifier for the passed Unicode token name.
OptValue< sal_Int64 > getHyper(sal_Int32 nAttrToken) const
Returns the 64-bit signed integer value of the specified attribute (decimal).
sax_fastparser::FastAttributeList * mpAttribList
static sal_Int32 decodeToken(std::u16string_view rValue)
Returns the XML token identifier from the passed string.
const char * getChar(sal_Int32 nAttrToken) const
bool getAsInteger(sal_Int32 nToken, sal_Int32 &rInt) const
std::unique_ptr< char[]> aBuffer
OptValue< sal_Int32 > getIntegerHex(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (hexadecimal). ...
bool getAsDouble(sal_Int32 nToken, double &rDouble) const
static sal_Int32 decodeInteger(const OUString &rValue)
Returns the 32-bit signed integer value from the passed string (decimal).
sax_fastparser::FastAttributeList * getAttribList() const
std::vector< sal_Int32 > getTokenList(sal_Int32 nAttrToken) const
bool getAsChar(sal_Int32 nToken, const char *&rPos) const
static sal_Int64 decodeHyper(const OUString &rValue)
Returns the 64-bit signed integer value from the passed string (decimal).
static sal_uInt32 decodeUnsigned(const OUString &rValue)
Returns the 32-bit unsigned integer value from the passed string (decimal).
static sal_Int32 decodeIntegerHex(const OUString &rValue)
Returns the 32-bit signed integer value from the passed string (hexadecimal).
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.