summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-11-10 19:20:06 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-11-11 06:33:53 +0100
commit3de38e95561ab7ca114d9f3307702ba89c4e3e9a (patch)
tree5d4c84a81e68897f325f67bc92b326ae48805f9a /sax
parentcc1e6ee2dd4609c27cb7a09aa47a779592a3e22c (diff)
use fastparser in forms
Change-Id: I7d09d64857e24267b4b4baddb563e28ceea92f2e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105560 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sax')
-rw-r--r--sax/source/tools/fastattribs.cxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index c021e892f91e..a8c3e57cae86 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -63,6 +63,19 @@ FastAttributeList::FastAttributeList( sax_fastparser::FastTokenHandlerBase *pTok
maAttributeValues.push_back( 0 );
}
+FastAttributeList::FastAttributeList( const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList )
+{
+ const auto& rOther = castToFastAttributeList(xAttrList);
+ mpTokenHandler = rOther.mpTokenHandler;
+ mpChunk = static_cast<char *>(malloc( rOther.mnChunkLength ));
+ mnChunkLength = rOther.mnChunkLength;
+ memcpy(mpChunk, rOther.mpChunk, rOther.mnChunkLength);
+ maAttributeValues = rOther.maAttributeValues;
+ maAttributeTokens = rOther.maAttributeTokens;
+ maUnknownAttributes = rOther.maUnknownAttributes;
+}
+
+
FastAttributeList::~FastAttributeList()
{
free( mpChunk );
@@ -79,6 +92,8 @@ void FastAttributeList::clear()
void FastAttributeList::add( sal_Int32 nToken, const char* pValue, size_t nValueLength )
{
assert(nToken != -1);
+ assert(nToken != 0);
+ assert(nValueLength < SAL_MAX_INT32); // protect against absurd values
maAttributeTokens.push_back( nToken );
sal_Int32 nWritePosition = maAttributeValues.back();
maAttributeValues.push_back( maAttributeValues.back() + nValueLength + 1 );
@@ -123,6 +138,20 @@ void FastAttributeList::addUnknown( const OString& rName, const OString& value )
maUnknownAttributes.emplace_back( rName, value );
}
+void FastAttributeList::add( const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList )
+{
+ const auto& rOther = castToFastAttributeList(xAttrList);
+ add(rOther);
+}
+
+void FastAttributeList::add( const FastAttributeList& rOther )
+{
+ for (size_t i=0; i < rOther.maAttributeTokens.size(); ++i)
+ add(rOther.maAttributeTokens[i], rOther.getFastAttributeValue(i), rOther.AttributeValueLength(i));
+ for (const auto & i : rOther.maUnknownAttributes)
+ addUnknown(i.maNamespaceURL, i.maName, i.maValue);
+}
+
// XFastAttributeList
sal_Bool FastAttributeList::hasAttribute( ::sal_Int32 Token )
{