diff options
Diffstat (limited to 'unoxml/source/dom/saxbuilder.cxx')
-rw-r--r-- | unoxml/source/dom/saxbuilder.cxx | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/unoxml/source/dom/saxbuilder.cxx b/unoxml/source/dom/saxbuilder.cxx index d6d87754eb6a..6b73cbfb733f 100644 --- a/unoxml/source/dom/saxbuilder.cxx +++ b/unoxml/source/dom/saxbuilder.cxx @@ -29,11 +29,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 { @@ -94,12 +93,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(); @@ -110,6 +113,8 @@ namespace DOM Reference< XDocument > SAL_CALL CSAXDocumentBuilder::getDocument() throw (RuntimeException) { + ::osl::MutexGuard g(m_Mutex); + if (m_aState != SAXDocumentBuilderState_DOCUMENT_FINISHED) throw RuntimeException(); @@ -119,6 +124,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; @@ -127,6 +134,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) @@ -142,6 +151,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(); @@ -157,6 +168,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 @@ -173,6 +185,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(); @@ -187,6 +201,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) { @@ -242,7 +258,8 @@ namespace DOM if ( result != aNSMap.end()) { // found a URI for prefix - aElement = m_aDocument->createElementNS( result->second, aName); // qualified name + // qualified name + aElement = m_aDocument->createElementNS( result->second, aName); } else { @@ -287,6 +304,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 +333,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 +347,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 +358,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 +373,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; } |