diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2013-10-08 15:17:01 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2013-10-17 21:38:35 +0200 |
commit | 03d76d034e5e5e30cc8de98e103c5a6e881ec06b (patch) | |
tree | debabb8c482eb2da1690f480b11fdf0660e68150 /sax/source/fastparser/fastparser.hxx | |
parent | bd4c869bbb66839506a45b71ab64792289ac7256 (diff) |
fastparser: isolate calls to XFastContextHandler in Entity's methods
Unfortunately, we have to store maNamespace in two stacks.
One for future parser thread to compute tokens and one for
main thread calling XFastContextHandler.
Now we are prepared to implement multithreading.
Change-Id: I421b55afa2e9ea80142e6068c7a515d31913ba69
Diffstat (limited to 'sax/source/fastparser/fastparser.hxx')
-rw-r--r-- | sax/source/fastparser/fastparser.hxx | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/sax/source/fastparser/fastparser.hxx b/sax/source/fastparser/fastparser.hxx index aa71fb0ad4d9..51086965a8b4 100644 --- a/sax/source/fastparser/fastparser.hxx +++ b/sax/source/fastparser/fastparser.hxx @@ -22,12 +22,14 @@ #include <vector> #include <stack> -#include <boost/unordered_map.hpp> +#include <boost/optional.hpp> #include <boost/shared_ptr.hpp> +#include <boost/unordered_map.hpp> #include <rtl/ref.hxx> +#include <com/sun/star/xml/sax/XFastContextHandler.hpp> +#include <com/sun/star/xml/sax/XFastDocumentHandler.hpp> #include <com/sun/star/xml/sax/XFastParser.hpp> #include <com/sun/star/xml/sax/XFastTokenHandler.hpp> -#include <com/sun/star/xml/sax/XFastDocumentHandler.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/implbase2.hxx> @@ -43,9 +45,7 @@ namespace sax_fastparser { class FastLocatorImpl; struct NamespaceDefine; -struct SaxContextImpl; -typedef ::boost::shared_ptr< SaxContextImpl > SaxContextImplPtr; typedef ::boost::shared_ptr< NamespaceDefine > NamespaceDefineRef; typedef ::boost::unordered_map< OUString, sal_Int32, @@ -53,6 +53,17 @@ typedef ::boost::unordered_map< OUString, sal_Int32, // -------------------------------------------------------------------- +struct SaxContext +{ + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > mxContext; + sal_Int32 mnElementToken; + boost::optional< OUString > maNamespace; + boost::optional< OUString > maElementName; + SaxContext( sal_Int32 nElementToken, const OUString& aNamespace, const OUString& aElementName ); +}; + +// -------------------------------------------------------------------- + struct ParserData { ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastDocumentHandler > mxDocumentHandler; @@ -79,13 +90,21 @@ struct Entity : public ParserData // therefore the exception must be saved somewhere. ::com::sun::star::uno::Any maSavedException; - ::std::stack< SaxContextImplPtr > maContextStack; + ::std::stack< OUString > maNamespaceStack; + /* Context for main thread consuming events. + * startElement() stores the data, which characters() and endElement() uses + */ + ::std::stack< SaxContext> maContextStack; // Determines which elements of maNamespaceDefines are valid in current context ::std::stack< sal_uInt32 > maNamespaceCount; ::std::vector< NamespaceDefineRef > maNamespaceDefines; explicit Entity( const ParserData& rData ); ~Entity(); + void startElement( sal_Int32 nElementToken, const OUString& aNamespace, + const OUString& aElementName, FastAttributeList *pAttributes ); + void characters( const OUString& sChars ); + void endElement(); }; // -------------------------------------------------------------------- |