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

xmlfix3: #i113682#: unoxml: use CDocument mutex in misc classes

üst 12de6d54
......@@ -35,8 +35,10 @@
namespace DOM
{
CAttributesMap::CAttributesMap(::rtl::Reference<CElement> const& pElement)
CAttributesMap::CAttributesMap(::rtl::Reference<CElement> const& pElement,
::osl::Mutex & rMutex)
: m_pElement(pElement)
, m_rMutex(rMutex)
{
}
......@@ -45,6 +47,8 @@ namespace DOM
*/
sal_Int32 SAL_CALL CAttributesMap::getLength() throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
sal_Int32 count = 0;
xmlNodePtr pNode = m_pElement->m_aNodePtr;
if (pNode != NULL)
......@@ -65,6 +69,8 @@ namespace DOM
Reference< XNode > SAL_CALL
CAttributesMap::getNamedItem(OUString const& name) throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
Reference< XNode > aNode;
xmlNodePtr pNode = m_pElement->m_aNodePtr;
if (pNode != NULL)
......@@ -95,6 +101,8 @@ namespace DOM
OUString const& namespaceURI, OUString const& localName)
throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
Reference< XNode > aNode;
xmlNodePtr pNode = m_pElement->m_aNodePtr;
if (pNode != NULL)
......@@ -127,6 +135,8 @@ namespace DOM
Reference< XNode > SAL_CALL
CAttributesMap::item(sal_Int32 index) throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
Reference< XNode > aNode;
xmlNodePtr pNode = m_pElement->m_aNodePtr;
if (pNode != NULL)
......@@ -156,6 +166,8 @@ namespace DOM
CAttributesMap::removeNamedItem(OUString const& name)
throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
xmlNodePtr const pNode = m_pElement->m_aNodePtr;
if (pNode != NULL)
{
......@@ -187,6 +199,8 @@ namespace DOM
OUString const& namespaceURI, OUString const& localName)
throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
xmlNodePtr const pNode = m_pElement->m_aNodePtr;
if (pNode != NULL)
{
......
......@@ -51,9 +51,11 @@ namespace DOM
{
private:
::rtl::Reference<CElement> const m_pElement;
::osl::Mutex & m_rMutex;
public:
CAttributesMap(::rtl::Reference<CElement> const& pElement);
CAttributesMap(::rtl::Reference<CElement> const& pElement,
::osl::Mutex & rMutex);
/**
The number of nodes in this map.
......
......@@ -35,8 +35,10 @@
namespace DOM
{
CChildList::CChildList(::rtl::Reference<CNode> const& pBase)
CChildList::CChildList(::rtl::Reference<CNode> const& pBase,
::osl::Mutex & rMutex)
: m_pNode(pBase)
, m_rMutex(rMutex)
{
}
......@@ -45,6 +47,8 @@ namespace DOM
*/
sal_Int32 SAL_CALL CChildList::getLength() throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
sal_Int32 length = 0;
if (m_pNode != NULL)
{
......@@ -67,6 +71,8 @@ namespace DOM
Reference< XNode > SAL_CALL CChildList::item(sal_Int32 index)
throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
if (m_pNode != NULL)
{
xmlNodePtr cur = m_pNode->m_aNodePtr;
......
......@@ -51,9 +51,11 @@ namespace DOM
{
private:
::rtl::Reference<CNode> const m_pNode;
::osl::Mutex & m_rMutex;
public:
CChildList(::rtl::Reference<CNode> const& pBase);
CChildList(::rtl::Reference<CNode> const& pBase,
::osl::Mutex & rMutex);
/**
The number of nodes in the list.
......
......@@ -686,7 +686,7 @@ namespace DOM
::osl::MutexGuard const g(m_Mutex);
Reference< XNodeList > const xRet(
new CElementList(this->GetDocumentElement(), rTagname));
new CElementList(this->GetDocumentElement(), m_Mutex, rTagname));
return xRet;
}
......@@ -697,8 +697,8 @@ namespace DOM
::osl::MutexGuard const g(m_Mutex);
Reference< XNodeList > const xRet(
new CElementList(
this->GetDocumentElement(), rLocalName, &rNamespaceURI));
new CElementList(this->GetDocumentElement(), m_Mutex,
rLocalName, &rNamespaceURI));
return xRet;
}
......
......@@ -56,7 +56,7 @@ namespace DOM
Reference< XNamedNodeMap > aMap;
if (m_aDtdPtr != NULL)
{
aMap = Reference< XNamedNodeMap >(new CEntitiesMap(this));
aMap.set(new CEntitiesMap(this, m_rMutex));
}
return aMap;
}
......@@ -96,7 +96,7 @@ namespace DOM
Reference< XNamedNodeMap > aMap;
if (m_aDtdPtr != NULL)
{
aMap.set(new CNotationsMap(this));
aMap.set(new CNotationsMap(this, m_rMutex));
}
return aMap;
}
......
......@@ -323,7 +323,8 @@ namespace DOM
{
::osl::MutexGuard const g(m_rMutex);
Reference< XNodeList > const xList(new CElementList(this, rLocalName));
Reference< XNodeList > const xList(
new CElementList(this, m_rMutex, rLocalName));
return xList;
}
......@@ -340,7 +341,7 @@ namespace DOM
::osl::MutexGuard const g(m_rMutex);
Reference< XNodeList > const xList(
new CElementList(this, rLocalName, &rNamespaceURI));
new CElementList(this, m_rMutex, rLocalName, &rNamespaceURI));
return xList;
}
......@@ -693,7 +694,8 @@ namespace DOM
::osl::MutexGuard const g(m_rMutex);
if (!hasAttributes()) { return 0; }
Reference< XNamedNodeMap > const xMap(new CAttributesMap(this));
Reference< XNamedNodeMap > const xMap(
new CAttributesMap(this, m_rMutex));
return xMap;
}
......
......@@ -46,8 +46,10 @@ namespace DOM
}
CElementList::CElementList(::rtl::Reference<CElement> const& pElement,
::osl::Mutex & rMutex,
OUString const& rName, OUString const*const pURI)
: m_pElement(pElement)
, m_rMutex(rMutex)
, m_pName(lcl_initXmlString(rName))
, m_pURI((pURI) ? lcl_initXmlString(*pURI) : 0)
, m_bRebuild(true)
......@@ -111,6 +113,8 @@ namespace DOM
*/
sal_Int32 SAL_CALL CElementList::getLength() throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
// this has to be 'live'
buildlist(static_cast<const CNode*>(m_pElement.get())->m_aNodePtr);
return m_nodevector.size();
......@@ -122,6 +126,9 @@ namespace DOM
throw (RuntimeException)
{
if (index < 0) throw RuntimeException();
::osl::MutexGuard const g(m_rMutex);
buildlist(static_cast<const CNode*>(m_pElement.get())->m_aNodePtr);
if (m_nodevector.size() <= static_cast<size_t>(index)) {
throw RuntimeException();
......@@ -135,6 +142,8 @@ namespace DOM
void SAL_CALL CElementList::handleEvent(Reference< XEvent > const&)
throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
m_bRebuild = true;
}
}
......@@ -64,6 +64,7 @@ namespace DOM
{
private:
::rtl::Reference<CElement> const m_pElement;
::osl::Mutex & m_rMutex;
::boost::scoped_array<xmlChar> const m_pName;
::boost::scoped_array<xmlChar> const m_pURI;
bool m_bRebuild;
......@@ -74,6 +75,7 @@ namespace DOM
public:
CElementList(::rtl::Reference<CElement> const& pElement,
::osl::Mutex & rMutex,
OUString const& rName, OUString const*const pURI = 0);
/**
......
......@@ -32,8 +32,10 @@
namespace DOM
{
CEntitiesMap::CEntitiesMap(::rtl::Reference<CDocumentType> const& pDocType)
CEntitiesMap::CEntitiesMap(::rtl::Reference<CDocumentType> const& pDocType,
::osl::Mutex & rMutex)
: m_pDocType(pDocType)
, m_rMutex(rMutex)
{
}
......
......@@ -51,9 +51,11 @@ namespace DOM
{
private:
::rtl::Reference<CDocumentType> const m_pDocType;
::osl::Mutex & m_rMutex;
public:
CEntitiesMap(::rtl::Reference<CDocumentType> const& pDocType);
CEntitiesMap(::rtl::Reference<CDocumentType> const& pDocType,
::osl::Mutex & rMutex);
/**
The number of nodes in this map.
......
......@@ -452,7 +452,7 @@ namespace DOM
if (0 == m_aNodePtr) {
return 0;
}
Reference< XNodeList > const xNodeList(new CChildList(this));
Reference< XNodeList > const xNodeList(new CChildList(this, m_rMutex));
return xNodeList;
}
......
......@@ -33,8 +33,10 @@
namespace DOM
{
CNotationsMap::CNotationsMap(
::rtl::Reference<CDocumentType> const& pDocType)
::rtl::Reference<CDocumentType> const& pDocType,
::osl::Mutex & rMutex)
: m_pDocType(pDocType)
, m_rMutex(rMutex)
{
}
......
......@@ -51,9 +51,11 @@ namespace DOM
{
private:
::rtl::Reference<CDocumentType> const m_pDocType;
::osl::Mutex & m_rMutex;
public:
CNotationsMap(::rtl::Reference<CDocumentType> const& pDocType);
CNotationsMap(::rtl::Reference<CDocumentType> const& pDocType,
::osl::Mutex & rMutex);
/**
The number of nodes in this map.
......
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