diff options
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 13 | ||||
-rw-r--r-- | sax/source/tools/fastattribs.cxx | 18 |
2 files changed, 24 insertions, 7 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 2765584a08fc..9477559c12e8 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -178,13 +178,13 @@ struct Entity : public ParserData void throwException( const ::rtl::Reference< FastLocatorImpl > &xDocumentLocator, bool mbDuringParse ); - std::stack< NameWithToken > maNamespaceStack; + std::stack< NameWithToken, std::vector<NameWithToken> > maNamespaceStack; /* Context for main thread consuming events. * startElement() stores the data, which characters() and endElement() uses */ - std::stack< SaxContext> maContextStack; + std::stack< SaxContext, std::vector<SaxContext> > maContextStack; // Determines which elements of maNamespaceDefines are valid in current context - std::stack< sal_uInt32 > maNamespaceCount; + std::stack< sal_uInt32, std::vector<sal_uInt32> > maNamespaceCount; std::vector< std::shared_ptr< NamespaceDefine > > maNamespaceDefines; @@ -270,7 +270,7 @@ private: ParserData maData; /// Cached parser configuration for next call of parseStream(). Entity *mpTop; /// std::stack::top() is amazingly slow => cache this. - std::stack< Entity > maEntities; /// Entity stack for each call of parseStream(). + std::stack< Entity > maEntities; /// Entity stack for each call of parseStream(). OUString pendingCharacters; /// Data from characters() callback that needs to be sent. }; @@ -674,11 +674,12 @@ sal_Int32 FastSaxParserImpl::GetTokenWithPrefix( const xmlChar* pPrefix, int nPr sal_uInt32 nNamespace = rEntity.maNamespaceCount.top(); while( nNamespace-- ) { - const OString& rPrefix( rEntity.maNamespaceDefines[nNamespace]->maPrefix ); + const auto & rNamespaceDefine = rEntity.maNamespaceDefines[nNamespace]; + const OString& rPrefix( rNamespaceDefine->maPrefix ); if( (rPrefix.getLength() == nPrefixLen) && (strncmp( rPrefix.getStr(), XML_CAST( pPrefix ), nPrefixLen ) == 0 ) ) { - nNamespaceToken = rEntity.maNamespaceDefines[nNamespace]->mnToken; + nNamespaceToken = rNamespaceDefine->mnToken; break; } diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx index a9f0baf7a2c0..30a764368947 100644 --- a/sax/source/tools/fastattribs.cxx +++ b/sax/source/tools/fastattribs.cxx @@ -86,7 +86,7 @@ void FastAttributeList::add( sal_Int32 nToken, const sal_Char* pValue, size_t nV maAttributeValues.push_back( maAttributeValues.back() + nValueLength + 1 ); if (maAttributeValues.back() > mnChunkLength) { - mnChunkLength = maAttributeValues.back(); + mnChunkLength = std::max(mnChunkLength * 2, maAttributeValues.back()); mpChunk = static_cast<sal_Char *>(realloc( mpChunk, mnChunkLength )); } strncpy(mpChunk + nWritePosition, pValue, nValueLength); @@ -166,6 +166,11 @@ bool FastAttributeList::getAsInteger( sal_Int32 nToken, sal_Int32 &rInt) const return false; } +sal_Int32 FastAttributeList::getAsIntegerByIndex( sal_Int32 nTokenIndex ) const +{ + return rtl_str_toInt32( getFastAttributeValue(nTokenIndex), 10 ); +} + bool FastAttributeList::getAsDouble( sal_Int32 nToken, double &rDouble) const { rDouble = 0.0; @@ -193,6 +198,12 @@ bool FastAttributeList::getAsChar( sal_Int32 nToken, const char*& rPos ) const return false; } +const char* FastAttributeList::getAsCharByIndex( sal_Int32 nTokenIndex ) const +{ + sal_Int32 nOffset = maAttributeValues[nTokenIndex]; + return mpChunk + nOffset; +} + OUString FastAttributeList::getValue( ::sal_Int32 Token ) { for (size_t i = 0; i < maAttributeTokens.size(); ++i) @@ -202,6 +213,11 @@ OUString FastAttributeList::getValue( ::sal_Int32 Token ) throw SAXException(); } +OUString FastAttributeList::getValueByIndex( ::sal_Int32 nTokenIndex ) const +{ + return OUString( getFastAttributeValue(nTokenIndex), AttributeValueLength(nTokenIndex), RTL_TEXTENCODING_UTF8 ); +} + OUString FastAttributeList::getOptionalValue( ::sal_Int32 Token ) { for (size_t i = 0; i < maAttributeTokens.size(); ++i) |