diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-02-13 15:59:38 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-02-15 10:30:09 +0000 |
commit | e9461ceb78c759e5f1cffbaad7b1b25491ed3807 (patch) | |
tree | 58b8e03d3761588116946557170c9e11e6fcaad4 /sax/source/expatwrap | |
parent | 4ed8987530d5b6cf79075937bfb12010f3a02a21 (diff) |
fdo#60471: svgio, sax: enable internal entity declarations for SVG
Change-Id: I147acac61dfe0b626268fe1e600dcf641ca63a0c
(cherry picked from commit fcb1e4d8433b49686cd8e53c699dd5d6503ea314)
Reviewed-on: https://gerrit.libreoffice.org/2138
Reviewed-by: Miklos Vajna <vmiklos@suse.cz>
Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'sax/source/expatwrap')
-rw-r--r-- | sax/source/expatwrap/sax_expat.cxx | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx index db17402d1e51..6dd88ed70432 100644 --- a/sax/source/expatwrap/sax_expat.cxx +++ b/sax/source/expatwrap/sax_expat.cxx @@ -24,7 +24,7 @@ #include <osl/diagnose.h> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> #include <com/sun/star/xml/sax/XParser.hpp> #include <com/sun/star/xml/sax/SAXParseException.hpp> @@ -32,8 +32,7 @@ #include <cppuhelper/factory.hxx> #include <cppuhelper/weak.hxx> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase3.hxx> #include <expat.h> @@ -45,7 +44,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::registry; using namespace ::com::sun::star::xml::sax; -using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; #include "factory.hxx" @@ -136,11 +134,10 @@ class SaxExpatParser_Impl; // This class implements the external Parser interface -class SaxExpatParser : - public WeakImplHelper2< - XParser, - XServiceInfo - > +class SaxExpatParser + : public WeakImplHelper3< XInitialization + , XServiceInfo + , XParser > { public: @@ -153,6 +150,10 @@ public: static Sequence< OUString > getSupportedServiceNames_Static(void) throw (); public: + // ::com::sun::star::lang::XInitialization: + virtual void SAL_CALL initialize(Sequence<Any> const& rArguments) + throw (RuntimeException, Exception); + // The SAX-Parser-Interface virtual void SAL_CALL parseStream( const InputSource& structSource) throw ( SAXException, @@ -222,6 +223,7 @@ class SaxExpatParser_Impl public: // module scope Mutex aMutex; OUString sCDATA; + bool m_bEnableDoS; // fdo#60471 thank you Adobe Illustrator Reference< XDocumentHandler > rDocumentHandler; Reference< XExtendedDocumentHandler > rExtendedDocumentHandler; @@ -257,6 +259,7 @@ public: // module scope public: SaxExpatParser_Impl() : sCDATA("CDATA") + , m_bEnableDoS(false) { } @@ -452,6 +455,22 @@ SaxExpatParser::~SaxExpatParser() delete m_pImpl; } +// ::com::sun::star::lang::XInitialization: +void SAL_CALL +SaxExpatParser::initialize(Sequence< Any > const& rArguments) + throw (RuntimeException, Exception) +{ + // possible arguments: a string "DoSmeplease" + if (rArguments.getLength()) + { + OUString str; + if ((rArguments[0] >>= str) && "DoSmeplease" == str) + { + MutexGuard guard( m_pImpl->aMutex ); + m_pImpl->m_bEnableDoS = true; + } + } +} /*************** * @@ -500,7 +519,10 @@ void SaxExpatParser::parseStream( const InputSource& structSource) XML_SetCharacterDataHandler( entity.pParser , call_callbackCharacters ); XML_SetProcessingInstructionHandler(entity.pParser , call_callbackProcessingInstruction ); - XML_SetEntityDeclHandler(entity.pParser, call_callbackEntityDecl); + if (!m_pImpl->m_bEnableDoS) + { + XML_SetEntityDeclHandler(entity.pParser, call_callbackEntityDecl); + } XML_SetNotationDeclHandler( entity.pParser, call_callbackNotationDecl ); XML_SetExternalEntityRefHandler( entity.pParser, call_callbackExternalEntityRef); |