summaryrefslogtreecommitdiff
path: root/unoxml/source/xpath/nodelist.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'unoxml/source/xpath/nodelist.cxx')
-rw-r--r--unoxml/source/xpath/nodelist.cxx31
1 files changed, 22 insertions, 9 deletions
diff --git a/unoxml/source/xpath/nodelist.cxx b/unoxml/source/xpath/nodelist.cxx
index dd44d8bfcc06..05add3ca44bc 100644
--- a/unoxml/source/xpath/nodelist.cxx
+++ b/unoxml/source/xpath/nodelist.cxx
@@ -25,13 +25,19 @@
*
************************************************************************/
-#include "nodelist.hxx"
-#include "../dom/node.hxx"
+#include <nodelist.hxx>
+
+#include "../dom/document.hxx"
namespace XPath
{
- CNodeList::CNodeList(boost::shared_ptr<xmlXPathObject>& rxpathObj)
- : m_pNodeSet(0)
+ CNodeList::CNodeList(
+ ::rtl::Reference<DOM::CDocument> const& pDocument,
+ ::osl::Mutex & rMutex,
+ boost::shared_ptr<xmlXPathObject> const& rxpathObj)
+ : m_pDocument(pDocument)
+ , m_rMutex(rMutex)
+ , m_pNodeSet(0)
{
if (rxpathObj != NULL && rxpathObj->type == XPATH_NODESET)
{
@@ -45,6 +51,8 @@ namespace XPath
*/
sal_Int32 SAL_CALL CNodeList::getLength() throw (RuntimeException)
{
+ ::osl::MutexGuard const g(m_rMutex);
+
sal_Int32 value = 0;
if (m_pNodeSet != NULL)
value = xmlXPathNodeSetGetLength(m_pNodeSet);
@@ -54,12 +62,17 @@ namespace XPath
/**
Returns the indexth item in the collection.
*/
- Reference< XNode > SAL_CALL CNodeList::item(sal_Int32 index) throw (RuntimeException)
+ Reference< XNode > SAL_CALL CNodeList::item(sal_Int32 index)
+ throw (RuntimeException)
{
- Reference< XNode > aNode;
- if (m_pNodeSet != NULL)
- aNode = Reference< XNode >(DOM::CNode::get(xmlXPathNodeSetItem(m_pNodeSet, index)));
- return aNode;
+ ::osl::MutexGuard const g(m_rMutex);
+
+ if (0 == m_pNodeSet) {
+ return 0;
+ }
+ xmlNodePtr const pNode = xmlXPathNodeSetItem(m_pNodeSet, index);
+ Reference< XNode > const xNode(m_pDocument->GetCNode(pNode).get());
+ return xNode;
}
}