14#include <com/sun/star/xml/FastAttribute.hpp>
15#include <com/sun/star/xml/sax/XFastAttributeList.hpp>
17#include <oox/token/tokens.hxx>
18#include <oox/token/namespaces.hxx>
19#include <rtl/ustring.hxx>
23#define OPENING( token ) XML_STREAM_OPENING( token )
24#define CLOSING( token ) XML_STREAM_CLOSING( token )
35class AttributeListBuilder
36 :
public XmlStream::AttributeList
39 explicit AttributeListBuilder(
const uno::Reference< xml::sax::XFastAttributeList >&
a );
42AttributeListBuilder::AttributeListBuilder(
const uno::Reference< xml::sax::XFastAttributeList >&
a )
46 const uno::Sequence< xml::FastAttribute > aFastAttrSeq =
a->getFastAttributes();
47 for(
const xml::FastAttribute& rFastAttr : aFastAttrSeq )
49 attrs[ rFastAttr.Token ] = rFastAttr.Value;
53OString tokenToString(
int token )
56 OString tokenname(
reinterpret_cast< const char*
>( aTokenNameSeq.getConstArray() ), aTokenNameSeq.getLength() );
57 if( tokenname.isEmpty())
61 OString namespacename = StaticNamespaceMap::get().count( nmsp ) != 0
62 ? StaticNamespaceMap::get()[ nmsp ] : OString(
"???" );
64 OString namespacename;
80 return "<" + namespacename +
":" + tokenname +
">";
82 return "</" + namespacename +
":" + tokenname +
">";
84 return namespacename +
":" + tokenname;
96 std::map< int, OUString >::const_iterator
find = attrs.find( token );
97 if(
find != attrs.end())
104 std::map< int, OUString >::const_iterator
find = attrs.find( token );
105 if(
find != attrs.end())
107 const OUString sValue =
find->second;
108 if( sValue.equalsIgnoreAsciiCase(
"true") ||
109 sValue.equalsIgnoreAsciiCase(
"on") ||
110 sValue.equalsIgnoreAsciiCase(
"t") ||
111 sValue.equalsIgnoreAsciiCase(
"1") )
113 if( sValue.equalsIgnoreAsciiCase(
"false") ||
114 sValue.equalsIgnoreAsciiCase(
"off") ||
115 sValue.equalsIgnoreAsciiCase(
"f") ||
116 sValue.equalsIgnoreAsciiCase(
"0") )
118 SAL_WARN(
"oox.xmlstream",
"Cannot convert \'" << sValue <<
"\' to bool." );
125 std::map< int, OUString >::const_iterator
find = attrs.find( token );
126 if(
find != attrs.end())
128 if( !
find->second.isEmpty() )
130 if(
find->second.getLength() != 1 )
131 SAL_WARN(
"oox.xmlstream",
"Cannot convert \'" <<
find->second <<
"\' to sal_Unicode, stripping." );
132 return find->second[ 0 ];
140, attributes( AttributeListBuilder(
a ))
146, attributes(
std::move(
a ))
150XmlStream::Tag::operator bool()
const
226 SAL_WARN(
"oox.xmlstream",
"Expected tag " << tokenToString( token ) <<
" not found." );
279 SAL_WARN(
"oox.xmlstream",
"Unexpected end of stream reached." );
285 int closing = ( token & ~TAG_OPENING ) |
TAG_CLOSING;
294 SAL_INFO(
"oox.xmlstream",
"Skipped unexpected element " << tokenToString( token ));
299 SAL_WARN(
"oox.xmlstream",
"Expected end of element " << tokenToString( token ) <<
" not found." );
332 assert( !
tags.empty());
333 tags.back().text += chars;
css::uno::Sequence< sal_Int8 > const & getUtf8TokenName(sal_Int32 nToken) const
Returns the UTF8 name of the passed token identifier as byte sequence.
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
TokenMap & StaticTokenMap()
constexpr sal_Int32 NMSP_MASK
constexpr sal_Int32 TOKEN_MASK
constexpr size_t NMSP_SHIFT