summaryrefslogtreecommitdiff
path: root/unoxml
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2011-01-19 20:27:24 +0100
committerMichael Stahl <mst@openoffice.org>2011-01-19 20:27:24 +0100
commitaa85497de77acae2c9e58d7339584dcd7665e425 (patch)
tree927dc441175ad182c6c8bad866e52a0bf9c6117b /unoxml
parentcb42fe10fa5cdefe902e63c735ddf508c68c84e2 (diff)
xmlfix3: unoxml: fix CChildList: member pointer does not keep document alive
Diffstat (limited to 'unoxml')
-rw-r--r--unoxml/source/dom/childlist.cxx31
-rw-r--r--unoxml/source/dom/childlist.hxx28
-rw-r--r--unoxml/source/dom/node.cxx4
3 files changed, 39 insertions, 24 deletions
diff --git a/unoxml/source/dom/childlist.cxx b/unoxml/source/dom/childlist.cxx
index 007cf3d2ad5a..fa06c1ec6bd6 100644
--- a/unoxml/source/dom/childlist.cxx
+++ b/unoxml/source/dom/childlist.cxx
@@ -25,11 +25,17 @@
*
************************************************************************/
-#include "childlist.hxx"
+#include <childlist.hxx>
+
+#include <libxml/tree.h>
+
+#include <node.hxx>
+
+
namespace DOM
{
- CChildList::CChildList(CNode const& rBase)
- : m_pNode(rBase.m_aNodePtr)
+ CChildList::CChildList(::rtl::Reference<CNode> const& pBase)
+ : m_pNode(pBase)
{
}
@@ -41,7 +47,10 @@ namespace DOM
sal_Int32 length = 0;
if (m_pNode != NULL)
{
- xmlNodePtr cur = m_pNode->children;
+ xmlNodePtr cur = m_pNode->m_aNodePtr;
+ if (0 != cur) {
+ cur = cur->children;
+ }
while (cur != NULL)
{
length++;
@@ -54,21 +63,23 @@ namespace DOM
/**
Returns the indexth item in the collection.
*/
- Reference< XNode > SAL_CALL CChildList::item(sal_Int32 index) throw (RuntimeException)
+ Reference< XNode > SAL_CALL CChildList::item(sal_Int32 index)
+ throw (RuntimeException)
{
- Reference< XNode >aNode;
if (m_pNode != NULL)
{
- xmlNodePtr cur = m_pNode->children;
+ xmlNodePtr cur = m_pNode->m_aNodePtr;
+ if (0 != cur) {
+ cur = cur->children;
+ }
while (cur != NULL)
{
if (index-- == 0) {
- aNode = Reference< XNode >(CNode::getCNode(cur).get());
- break;
+ return Reference< XNode >(CNode::getCNode(cur).get());
}
cur = cur->next;
}
}
- return aNode;
+ return 0;
}
}
diff --git a/unoxml/source/dom/childlist.hxx b/unoxml/source/dom/childlist.hxx
index c639d327a7d2..9d3dec0a147a 100644
--- a/unoxml/source/dom/childlist.hxx
+++ b/unoxml/source/dom/childlist.hxx
@@ -25,18 +25,18 @@
*
************************************************************************/
-#ifndef _CHILDLIST_HXX
-#define _CHILDLIST_HXX
+#ifndef DOM_CHILDLIST_HXX
+#define DOM_CHILDLIST_HXX
-#include <map>
#include <sal/types.h>
-#include <cppuhelper/implbase1.hxx>
+#include <rtl/ref.hxx>
+
#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/xml/dom/XNode.hpp>
#include <com/sun/star/xml/dom/XNodeList.hpp>
-#include "node.hxx"
-#include "libxml/tree.h"
+
+#include <cppuhelper/implbase1.hxx>
+
using ::rtl::OUString;
using namespace com::sun::star::uno;
@@ -44,12 +44,17 @@ using namespace com::sun::star::xml::dom;
namespace DOM
{
- class CChildList : public cppu::WeakImplHelper1< XNodeList >
+ class CNode;
+
+ class CChildList
+ : public cppu::WeakImplHelper1< XNodeList >
{
private:
- const xmlNodePtr m_pNode;
+ ::rtl::Reference<CNode> const m_pNode;
+
public:
- CChildList(CNode const& rBase);
+ CChildList(::rtl::Reference<CNode> const& pBase);
+
/**
The number of nodes in the list.
*/
@@ -57,7 +62,8 @@ namespace DOM
/**
Returns the indexth item in the collection.
*/
- virtual Reference< XNode > SAL_CALL item(sal_Int32 index) throw (RuntimeException);
+ virtual Reference< XNode > SAL_CALL item(sal_Int32 index)
+ throw (RuntimeException);
};
}
diff --git a/unoxml/source/dom/node.cxx b/unoxml/source/dom/node.cxx
index 3554811d8b45..2b2885778ff4 100644
--- a/unoxml/source/dom/node.cxx
+++ b/unoxml/source/dom/node.cxx
@@ -562,9 +562,7 @@ namespace DOM
if (0 == m_aNodePtr) {
return 0;
}
- Reference< XNodeList > const xNodeList(
- new CChildList(*CNode::getCNode(m_aNodePtr)));
- // XXX check for errors?
+ Reference< XNodeList > const xNodeList(new CChildList(this));
return xNodeList;
}