Kaydet (Commit) 57c23f63 authored tarafından Michael Stahl's avatar Michael Stahl

xmlfix3: #i113682#: unoxml: CDocumentBuilder gets a member mutex

üst e94a328a
......@@ -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;
}
}
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment