summaryrefslogtreecommitdiff
path: root/unoxml
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2011-01-19 20:27:26 +0100
committerMichael Stahl <mst@openoffice.org>2011-01-19 20:27:26 +0100
commit57c23f6329f58cd359200413c55e7988ab1e32db (patch)
treee838d399c7d3686ae04d9450d7747b73f45d0bf3 /unoxml
parente94a328aa0b1a0f61018e6978dda626b842f6855 (diff)
xmlfix3: #i113682#: unoxml: CDocumentBuilder gets a member mutex
Diffstat (limited to 'unoxml')
-rw-r--r--unoxml/source/dom/documentbuilder.cxx53
-rw-r--r--unoxml/source/dom/documentbuilder.hxx21
2 files changed, 48 insertions, 26 deletions
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 <documentbuilder.hxx>
+
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include <libxml/xmlerror.h>
+#include <libxml/tree.h>
+
#include <rtl/alloc.h>
#include <rtl/memory.h>
@@ -35,17 +41,15 @@
#include <cppuhelper/implbase1.hxx>
-#include <libxml/xmlerror.h>
-
#include <com/sun/star/xml/sax/SAXParseException.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
+
#include <ucbhelper/content.hxx>
#include <ucbhelper/commandenvironment.hxx>
-#include <string.h>
-#include <stdio.h>
-#include <stdarg.h>
+#include <node.hxx>
+#include <document.hxx>
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 <sal/types.h>
+
#include <cppuhelper/implbase2.hxx>
+
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/uno/Sequence.h>
#include <com/sun/star/uno/XInterface.hpp>
-#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
#include <com/sun/star/xml/dom/XDocument.hpp>
#include <com/sun/star/xml/dom/XDOMImplementation.hpp>
@@ -44,10 +45,8 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#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;