summaryrefslogtreecommitdiff
path: root/unoxml/source/dom
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2011-01-19 20:27:23 +0100
committerMichael Stahl <mst@openoffice.org>2011-01-19 20:27:23 +0100
commit2b0e8719eb3dd4dac2f732fb25db4f47319deb59 (patch)
tree4be870a2bc61575c740f2534d48f71bc623c7e34 /unoxml/source/dom
parent95fbc9f47572aad9ced12ea92c699095c065a4d4 (diff)
xmlfix3: #i113682#: unoxml: mutex for CSAXDocumentBuilder
Diffstat (limited to 'unoxml/source/dom')
-rw-r--r--unoxml/source/dom/saxbuilder.cxx32
-rw-r--r--unoxml/source/dom/saxbuilder.hxx8
2 files changed, 33 insertions, 7 deletions
diff --git a/unoxml/source/dom/saxbuilder.cxx b/unoxml/source/dom/saxbuilder.cxx
index e3f88f53a8eb..524e4353e2a2 100644
--- a/unoxml/source/dom/saxbuilder.cxx
+++ b/unoxml/source/dom/saxbuilder.cxx
@@ -28,11 +28,10 @@
#pragma warning(disable : 4701)
#endif
-#include "node.hxx"
#include "saxbuilder.hxx"
+
#include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
-#include <libxml/tree.h>
-#include <com/sun/star/uno/Sequence.h>
+
namespace DOM
{
@@ -93,12 +92,16 @@ namespace DOM
SAXDocumentBuilderState SAL_CALL CSAXDocumentBuilder::getState()
throw (RuntimeException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
return m_aState;
}
void SAL_CALL CSAXDocumentBuilder::reset()
throw (RuntimeException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
m_aDocument = Reference< XDocument >();
m_aFragment = Reference< XDocumentFragment >();
while (!m_aNodeStack.empty()) m_aNodeStack.pop();
@@ -109,6 +112,8 @@ namespace DOM
Reference< XDocument > SAL_CALL CSAXDocumentBuilder::getDocument()
throw (RuntimeException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
if (m_aState != SAXDocumentBuilderState_DOCUMENT_FINISHED)
throw RuntimeException();
@@ -118,6 +123,8 @@ namespace DOM
Reference< XDocumentFragment > SAL_CALL CSAXDocumentBuilder::getDocumentFragment()
throw (RuntimeException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
if (m_aState != SAXDocumentBuilderState_FRAGMENT_FINISHED)
throw RuntimeException();
return m_aFragment;
@@ -126,6 +133,8 @@ namespace DOM
void SAL_CALL CSAXDocumentBuilder::startDocumentFragment(const Reference< XDocument >& ownerDoc)
throw (RuntimeException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
// start a new document fragment and push it onto the stack
// we have to be in a clean state to do this
if (!m_aState == SAXDocumentBuilderState_READY)
@@ -141,6 +150,8 @@ namespace DOM
void SAL_CALL CSAXDocumentBuilder::endDocumentFragment()
throw (RuntimeException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
// there should only be the document left on the node stack
if (m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT)
throw RuntimeException();
@@ -156,6 +167,7 @@ namespace DOM
void SAL_CALL CSAXDocumentBuilder::startDocument() throw (RuntimeException, SAXException)
{
+ ::osl::MutexGuard g(m_Mutex);
// start a new document and push it onto the stack
// we have to be in a clean state to do this
@@ -172,6 +184,8 @@ namespace DOM
void SAL_CALL CSAXDocumentBuilder::endDocument() throw (RuntimeException, SAXException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
// there should only be the document left on the node stack
if (!m_aState == SAXDocumentBuilderState_BUILDING_DOCUMENT)
throw SAXException();
@@ -186,6 +200,8 @@ namespace DOM
void SAL_CALL CSAXDocumentBuilder::startElement(const OUString& aName, const Reference< XAttributeList>& attribs)
throw (RuntimeException, SAXException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
if ( m_aState != SAXDocumentBuilderState_BUILDING_DOCUMENT &&
m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT)
{
@@ -287,6 +303,8 @@ namespace DOM
void SAL_CALL CSAXDocumentBuilder::endElement(const OUString& aName)
throw (RuntimeException, SAXException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
// pop the current element from the stack
if ( m_aState != SAXDocumentBuilderState_BUILDING_DOCUMENT &&
m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT)
@@ -314,6 +332,8 @@ namespace DOM
void SAL_CALL CSAXDocumentBuilder::characters(const OUString& aChars)
throw (RuntimeException, SAXException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
// append text node to the current top element
if (m_aState != SAXDocumentBuilderState_BUILDING_DOCUMENT &&
m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT)
@@ -326,6 +346,8 @@ namespace DOM
void SAL_CALL CSAXDocumentBuilder::ignorableWhitespace(const OUString& )
throw (RuntimeException, SAXException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
// ignore ignorable whitespace
if ( m_aState != SAXDocumentBuilderState_BUILDING_DOCUMENT &&
m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT)
@@ -335,6 +357,8 @@ namespace DOM
void SAL_CALL CSAXDocumentBuilder::processingInstruction(const OUString& aTarget, const OUString& aData)
throw (RuntimeException, SAXException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
// append PI node to the current top
if ( m_aState != SAXDocumentBuilderState_BUILDING_DOCUMENT &&
m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT)
@@ -348,6 +372,8 @@ namespace DOM
void SAL_CALL CSAXDocumentBuilder::setDocumentLocator(const Reference< XLocator >& aLocator)
throw (RuntimeException, SAXException)
{
+ ::osl::MutexGuard g(m_Mutex);
+
// set the document locator...
m_aLocator = aLocator;
}
diff --git a/unoxml/source/dom/saxbuilder.hxx b/unoxml/source/dom/saxbuilder.hxx
index c243877aae2b..cd280c9f7129 100644
--- a/unoxml/source/dom/saxbuilder.hxx
+++ b/unoxml/source/dom/saxbuilder.hxx
@@ -25,13 +25,14 @@
*
************************************************************************/
-#ifndef _SAXBUILDER_HXX
-#define _SAXBUILDER_HXX
+#ifndef DOM_SAXBUILDER_HXX
+#define DOM_SAXBUILDER_HXX
#include <stack>
#include <map>
#include <sal/types.h>
+#include <osl/mutex.hxx>
#include <cppuhelper/implbase3.hxx>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/uno/Sequence.h>
@@ -49,8 +50,6 @@
#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;
using namespace com::sun::star::xml::dom;
@@ -73,6 +72,7 @@ namespace DOM
{
private:
+ ::osl::Mutex m_Mutex;
const Reference< XMultiServiceFactory > m_aServiceManager;
SAXDocumentBuilderState m_aState;