From 57c23f6329f58cd359200413c55e7988ab1e32db Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 19 Jan 2011 20:27:26 +0100 Subject: xmlfix3: #i113682#: unoxml: CDocumentBuilder gets a member mutex --- unoxml/source/dom/documentbuilder.cxx | 53 ++++++++++++++++++++++++----------- unoxml/source/dom/documentbuilder.hxx | 21 ++++++++------ 2 files changed, 48 insertions(+), 26 deletions(-) (limited to 'unoxml') diff --git a/unoxml/source/dom/documentbuilder.cxx b/unoxml/source/dom/documentbuilder.cxx index 4b9cba2ec0ed..2e8146f09c41 100644 --- a/unoxml/source/dom/documentbuilder.cxx +++ b/unoxml/source/dom/documentbuilder.cxx @@ -25,9 +25,15 @@ * ************************************************************************/ -#include "documentbuilder.hxx" -#include "node.hxx" -#include "document.hxx" +#include + +#include +#include +#include + +#include +#include + #include #include @@ -35,17 +41,15 @@ #include -#include - #include #include #include + #include #include -#include -#include -#include +#include +#include using ::rtl::OUStringBuffer; @@ -101,9 +105,10 @@ namespace DOM }; - CDocumentBuilder::CDocumentBuilder(const Reference< XMultiServiceFactory >& xFactory) - : m_aFactory(xFactory) - , m_aEntityResolver(Reference< XEntityResolver > (new CDefaultEntityResolver())) + CDocumentBuilder::CDocumentBuilder( + Reference< XMultiServiceFactory > const& xFactory) + : m_xFactory(xFactory) + , m_xEntityResolver(new CDefaultEntityResolver()) { // init libxml. libxml will protect itself against multiple // initializations so there is no problem here if this gets @@ -182,6 +187,8 @@ namespace DOM Reference< XDocument > SAL_CALL CDocumentBuilder::newDocument() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); + // create a new document xmlDocPtr pDocument = xmlNewDoc((const xmlChar*)"1.0"); Reference< XDocument > const xRet( @@ -328,6 +335,7 @@ namespace DOM Reference< XDocument > SAL_CALL CDocumentBuilder::parse(const Reference< XInputStream >& is) throw (RuntimeException, SAXParseException, IOException) { + ::osl::MutexGuard const g(m_Mutex); // encoding... /* @@ -366,6 +374,8 @@ namespace DOM Reference< XDocument > SAL_CALL CDocumentBuilder::parseSource(const InputSource& is) throw (RuntimeException, SAXParseException, IOException) { + ::osl::MutexGuard const g(m_Mutex); + // if there is an encoding specified in the input source, use it xmlCharEncoding enc = XML_CHAR_ENCODING_NONE; if (is.sEncoding.getLength() > 0) { @@ -396,6 +406,8 @@ namespace DOM Reference< XDocument > SAL_CALL CDocumentBuilder::parseURI(const OUString& sUri) throw (RuntimeException, SAXParseException, IOException) { + ::osl::MutexGuard const g(m_Mutex); + xmlParserCtxtPtr ctxt = xmlNewParserCtxt(); ctxt->_private = this; ctxt->sax->error = error_func; @@ -414,22 +426,29 @@ namespace DOM return xRet; } - void SAL_CALL CDocumentBuilder::setEntityResolver(const Reference< XEntityResolver >& er) + void SAL_CALL + CDocumentBuilder::setEntityResolver(Reference< XEntityResolver > const& xER) throw (RuntimeException) { - m_aEntityResolver = er; + ::osl::MutexGuard const g(m_Mutex); + + m_xEntityResolver = xER; } Reference< XEntityResolver > SAL_CALL CDocumentBuilder::getEntityResolver() throw (RuntimeException) { - return m_aEntityResolver; - } + ::osl::MutexGuard const g(m_Mutex); + return m_xEntityResolver; + } - void SAL_CALL CDocumentBuilder::setErrorHandler(const Reference< XErrorHandler >& eh) + void SAL_CALL + CDocumentBuilder::setErrorHandler(Reference< XErrorHandler > const& xEH) throw (RuntimeException) { - m_aErrorHandler = eh; + ::osl::MutexGuard const g(m_Mutex); + + m_xErrorHandler = xEH; } } diff --git a/unoxml/source/dom/documentbuilder.hxx b/unoxml/source/dom/documentbuilder.hxx index 97838c12d823..d6562bede338 100644 --- a/unoxml/source/dom/documentbuilder.hxx +++ b/unoxml/source/dom/documentbuilder.hxx @@ -25,16 +25,17 @@ * ************************************************************************/ -#ifndef _DOCUMENTBUILDER_HXX -#define _DOCUMENTBUILDER_HXX +#ifndef DOM_DOCUMENTBUILDER_HXX +#define DOM_DOCUMENTBUILDER_HXX #include + #include + #include #include #include -#include #include #include #include @@ -44,10 +45,8 @@ #include #include #include -#include #include -#include "libxml/tree.h" using ::rtl::OUString; using namespace com::sun::star::uno; @@ -67,9 +66,11 @@ namespace DOM : public CDocumentBuilder_Base { private: - Reference< ::com::sun::star::lang::XMultiServiceFactory > m_aFactory; - Reference< XEntityResolver > m_aEntityResolver; - Reference< XErrorHandler > m_aErrorHandler; + ::osl::Mutex m_Mutex; + Reference< ::com::sun::star::lang::XMultiServiceFactory > const + m_xFactory; + Reference< XEntityResolver > m_xEntityResolver; + Reference< XErrorHandler > m_xErrorHandler; public: @@ -79,7 +80,9 @@ namespace DOM xFactory); // call for factory - static Reference< XInterface > getInstance(const Reference < ::com::sun::star::lang::XMultiServiceFactory >& xFactory); + static Reference< XInterface > getInstance( + Reference< ::com::sun::star::lang::XMultiServiceFactory > const& + xFactory); // static helpers for service info and component management static const char* aImplementationName; -- cgit