summaryrefslogtreecommitdiff
path: root/unoxml/source
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2011-01-19 20:27:25 +0100
committerMichael Stahl <mst@openoffice.org>2011-01-19 20:27:25 +0100
commitdde336f8f0357f39a8547fc8b05c09672df816bf (patch)
treeabac41912042e94e83838654b71249aa4463dfdd /unoxml/source
parent3ba96ffc4bef4a6fa710c178b0bbda217293b9dc (diff)
xmlfix3: unoxml: refactor XPath results a little:
replace Reference<XNode> with Reference<CDocument>. also remove all using namespace css::lang, due to conflicts.
Diffstat (limited to 'unoxml/source')
-rw-r--r--unoxml/source/dom/document.hxx1
-rw-r--r--unoxml/source/dom/documentbuilder.hxx21
-rw-r--r--unoxml/source/dom/entitiesmap.hxx1
-rw-r--r--unoxml/source/dom/text.hxx1
-rw-r--r--unoxml/source/events/testlistener.cxx4
-rw-r--r--unoxml/source/events/testlistener.hxx19
-rw-r--r--unoxml/source/xpath/nodelist.cxx11
-rw-r--r--unoxml/source/xpath/nodelist.hxx26
-rw-r--r--unoxml/source/xpath/xpathapi.cxx26
-rw-r--r--unoxml/source/xpath/xpathapi.hxx22
-rw-r--r--unoxml/source/xpath/xpathobject.cxx84
-rw-r--r--unoxml/source/xpath/xpathobject.hxx37
12 files changed, 156 insertions, 97 deletions
diff --git a/unoxml/source/dom/document.hxx b/unoxml/source/dom/document.hxx
index e3266759d856..0743e39d797c 100644
--- a/unoxml/source/dom/document.hxx
+++ b/unoxml/source/dom/document.hxx
@@ -60,7 +60,6 @@ using namespace std;
using ::rtl::OUString;
using namespace com::sun::star;
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
using namespace com::sun::star::xml::sax;
using namespace com::sun::star::io;
using namespace com::sun::star::xml::dom;
diff --git a/unoxml/source/dom/documentbuilder.hxx b/unoxml/source/dom/documentbuilder.hxx
index 7f5a2079a051..97838c12d823 100644
--- a/unoxml/source/dom/documentbuilder.hxx
+++ b/unoxml/source/dom/documentbuilder.hxx
@@ -58,28 +58,37 @@ using namespace com::sun::star::io;
namespace DOM
{
- class CDocumentBuilder
- : public ::cppu::WeakImplHelper2< XDocumentBuilder, XServiceInfo >
+ typedef ::cppu::WeakImplHelper2
+ < XDocumentBuilder
+ , ::com::sun::star::lang::XServiceInfo
+ > CDocumentBuilder_Base;
+
+ class CDocumentBuilder
+ : public CDocumentBuilder_Base
{
private:
- Reference< XMultiServiceFactory > m_aFactory;
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > m_aFactory;
Reference< XEntityResolver > m_aEntityResolver;
Reference< XErrorHandler > m_aErrorHandler;
public:
// ctor
- CDocumentBuilder(const Reference< XMultiServiceFactory >& xFactory);
+ CDocumentBuilder(
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > const&
+ xFactory);
// call for factory
- static Reference< XInterface > getInstance(const Reference < XMultiServiceFactory >& xFactory);
+ static Reference< XInterface > getInstance(const Reference < ::com::sun::star::lang::XMultiServiceFactory >& xFactory);
// static helpers for service info and component management
static const char* aImplementationName;
static const char* aSupportedServiceNames[];
static OUString _getImplementationName();
static Sequence< OUString > _getSupportedServiceNames();
- static Reference< XInterface > _getInstance(const Reference< XMultiServiceFactory >& rSMgr);
+ static Reference< XInterface > _getInstance(
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > const&
+ rSMgr);
// XServiceInfo
virtual OUString SAL_CALL getImplementationName()
diff --git a/unoxml/source/dom/entitiesmap.hxx b/unoxml/source/dom/entitiesmap.hxx
index d82e1399e9c6..754725a94b4a 100644
--- a/unoxml/source/dom/entitiesmap.hxx
+++ b/unoxml/source/dom/entitiesmap.hxx
@@ -40,7 +40,6 @@
using ::rtl::OUString;
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
using namespace com::sun::star::xml::dom;
namespace DOM
diff --git a/unoxml/source/dom/text.hxx b/unoxml/source/dom/text.hxx
index 58b7e16e7d59..f342cfa334f5 100644
--- a/unoxml/source/dom/text.hxx
+++ b/unoxml/source/dom/text.hxx
@@ -40,7 +40,6 @@
using ::rtl::OUString;
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
using namespace com::sun::star::xml::dom;
namespace DOM
diff --git a/unoxml/source/events/testlistener.cxx b/unoxml/source/events/testlistener.cxx
index 64806c84017d..a493aefb55f8 100644
--- a/unoxml/source/events/testlistener.cxx
+++ b/unoxml/source/events/testlistener.cxx
@@ -33,6 +33,10 @@
#define U2S(s) OUStringToOString(s, RTL_TEXTENCODING_UTF8).getStr()
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::lang::IllegalArgumentException;
+
+
namespace DOM { namespace events
{
diff --git a/unoxml/source/events/testlistener.hxx b/unoxml/source/events/testlistener.hxx
index f404f2dc48bb..1d96edefca34 100644
--- a/unoxml/source/events/testlistener.hxx
+++ b/unoxml/source/events/testlistener.hxx
@@ -47,19 +47,24 @@
using ::rtl::OUString;
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
using namespace com::sun::star::xml::dom;
using namespace com::sun::star::xml::dom::events;
namespace DOM { namespace events
{
+ typedef ::cppu::WeakImplHelper3
+ < ::com::sun::star::xml::dom::events::XEventListener
+ , ::com::sun::star::lang::XInitialization
+ , ::com::sun::star::lang::XServiceInfo
+ > CTestListener_Base;
+
class CTestListener
- : public ::cppu::WeakImplHelper3< com::sun::star::xml::dom::events::XEventListener, XInitialization, XServiceInfo >
+ : public CTestListener_Base
{
private:
- Reference< XMultiServiceFactory > m_factory;
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > m_factory;
Reference <XEventTarget> m_target;
OUString m_type;
sal_Bool m_capture;
@@ -72,9 +77,13 @@ namespace DOM { namespace events
static const char* aSupportedServiceNames[];
static OUString _getImplementationName();
static Sequence< OUString > _getSupportedServiceNames();
- static Reference< XInterface > _getInstance(const Reference< XMultiServiceFactory >& rSMgr);
+ static Reference< XInterface > _getInstance(
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ rSMgr);
- CTestListener(const Reference< XMultiServiceFactory >& rSMgr)
+ CTestListener(
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ rSMgr)
: m_factory(rSMgr){};
virtual ~CTestListener();
diff --git a/unoxml/source/xpath/nodelist.cxx b/unoxml/source/xpath/nodelist.cxx
index 6240d01d7101..3f24205309fb 100644
--- a/unoxml/source/xpath/nodelist.cxx
+++ b/unoxml/source/xpath/nodelist.cxx
@@ -26,14 +26,14 @@
************************************************************************/
#include "nodelist.hxx"
-#include "../dom/node.hxx"
+#include "../dom/document.hxx"
namespace XPath
{
CNodeList::CNodeList(
- Reference<XNode> const& xContextNode,
- boost::shared_ptr<xmlXPathObject>& rxpathObj)
- : m_xContextNode(xContextNode)
+ ::rtl::Reference<DOM::CDocument> const& pDocument,
+ boost::shared_ptr<xmlXPathObject> const& rxpathObj)
+ : m_pDocument(pDocument)
, m_pNodeSet(0)
{
if (rxpathObj != NULL && rxpathObj->type == XPATH_NODESET)
@@ -57,7 +57,8 @@ 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)
{
if (0 == m_pNodeSet) {
return 0;
diff --git a/unoxml/source/xpath/nodelist.hxx b/unoxml/source/xpath/nodelist.hxx
index 38e40e5113af..2b20c39c1e98 100644
--- a/unoxml/source/xpath/nodelist.hxx
+++ b/unoxml/source/xpath/nodelist.hxx
@@ -25,27 +25,34 @@
*
************************************************************************/
-#ifndef _NODELIST_HXX
-#define _NODELIST_HXX
+#ifndef XPATH_NODELIST_HXX
+#define XPATH_NODELIST_HXX
-#include <vector>
#include <sal/types.h>
+#include <rtl/ref.hxx>
+
#include <cppuhelper/implbase1.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 <com/sun/star/xml/xpath/XXPathObject.hpp>
+
#include "libxml/tree.h"
#include "libxml/xpath.h"
+
#include <boost/shared_ptr.hpp>
+
using ::rtl::OUString;
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
using namespace com::sun::star::xml::dom;
using namespace com::sun::star::xml::xpath;
+namespace DOM {
+ class CDocument;
+}
+
namespace XPath
{
@@ -53,14 +60,14 @@ namespace XPath
{
private:
/// #i115995# retain context node to keep document alive
- const Reference< XNode > m_xContextNode;
+ ::rtl::Reference< DOM::CDocument > const m_pDocument;
boost::shared_ptr<xmlXPathObject> m_pXPathObj;
xmlNodeSetPtr m_pNodeSet;
public:
CNodeList(
- Reference<XNode> const& xContextNode,
- boost::shared_ptr<xmlXPathObject> &rxpathObj);
+ ::rtl::Reference<DOM::CDocument> const& pDocument,
+ boost::shared_ptr<xmlXPathObject> const& rxpathObj);
/**
The number of nodes in the list.
*/
@@ -68,7 +75,8 @@ namespace XPath
/**
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/xpath/xpathapi.cxx b/unoxml/source/xpath/xpathapi.cxx
index f40082e25e9b..2b515d0a9241 100644
--- a/unoxml/source/xpath/xpathapi.cxx
+++ b/unoxml/source/xpath/xpathapi.cxx
@@ -26,18 +26,23 @@
************************************************************************/
#include "xpathapi.hxx"
-#include "nodelist.hxx"
-#include "xpathobject.hxx"
-#include "../dom/node.hxx"
-#include <rtl/ustrbuf.hxx>
+#include <stdarg.h>
+#include <string.h>
#include <libxml/xmlerror.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
-#include <stdarg.h>
-#include <string.h>
+#include <rtl/ustrbuf.hxx>
+
+#include <nodelist.hxx>
+#include <xpathobject.hxx>
+#include "../dom/node.hxx"
+#include "../dom/document.hxx"
+
+
+using ::com::sun::star::lang::XMultiServiceFactory;
namespace XPath
@@ -316,6 +321,7 @@ namespace XPath
// get the node and document
xmlNodePtr pNode = DOM::CNode::getNodePtr(contextNode);
+ if (!pNode) { throw RuntimeException(); }
xmlDocPtr pDoc = pNode->doc;
/* NB: workaround for #i87252#:
@@ -352,8 +358,12 @@ namespace XPath
throw XPathException();
}
xmlXPathFreeContext(xpathCtx);
- Reference< XXPathObject > aObj(new CXPathObject(xpathObj, contextNode));
- return aObj;
+ ::rtl::Reference<DOM::CDocument> const pCDoc(
+ dynamic_cast<DOM::CDocument*>(DOM::CNode::getCNode(
+ reinterpret_cast<xmlNodePtr>(pDoc)).get()));
+ OSL_ASSERT(pCDoc.is());
+ Reference<XXPathObject> const xObj(new CXPathObject(pCDoc, xpathObj));
+ return xObj;
}
/**
diff --git a/unoxml/source/xpath/xpathapi.hxx b/unoxml/source/xpath/xpathapi.hxx
index 048fafaae8e9..723c15259008 100644
--- a/unoxml/source/xpath/xpathapi.hxx
+++ b/unoxml/source/xpath/xpathapi.hxx
@@ -54,7 +54,6 @@
using ::rtl::OUString;
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
using namespace com::sun::star::xml::dom;
using namespace com::sun::star::xml::xpath;
@@ -63,28 +62,39 @@ namespace XPath
typedef std::map<OUString, OUString> nsmap_t;
typedef std::vector< Reference<XXPathExtension> > extensions_t;
+ typedef ::cppu::WeakImplHelper2
+ < XXPathAPI
+ , ::com::sun::star::lang::XServiceInfo
+ > CXPathAPI_Base;
+
class CXPathAPI
- : public ::cppu::WeakImplHelper2< XXPathAPI, XServiceInfo >
+ : public CXPathAPI_Base
{
private:
nsmap_t m_nsmap;
- const Reference< XMultiServiceFactory > m_aFactory;
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory > m_aFactory;
extensions_t m_extensions;
public:
// ctor
- CXPathAPI(const Reference< XMultiServiceFactory >& rSMgr);
+ CXPathAPI(
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ rSMgr);
// call for factory
- static Reference< XInterface > getInstance(const Reference < XMultiServiceFactory >& xFactory);
+ static Reference< XInterface > getInstance(
+ const Reference < ::com::sun::star::lang::XMultiServiceFactory >&
+ xFactory);
// static helpers for service info and component management
static const char* aImplementationName;
static const char* aSupportedServiceNames[];
static OUString _getImplementationName();
static Sequence< OUString > _getSupportedServiceNames();
- static Reference< XInterface > _getInstance(const Reference< XMultiServiceFactory >& rSMgr);
+ static Reference< XInterface > _getInstance(
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ rSMgr);
// XServiceInfo
virtual OUString SAL_CALL getImplementationName()
diff --git a/unoxml/source/xpath/xpathobject.cxx b/unoxml/source/xpath/xpathobject.cxx
index a02c79b9945b..98bebf073d71 100644
--- a/unoxml/source/xpath/xpathobject.cxx
+++ b/unoxml/source/xpath/xpathobject.cxx
@@ -25,68 +25,70 @@
*
************************************************************************/
+#include <xpathobject.hxx>
+
#include <string.h>
-#include "xpathobject.hxx"
-#include "nodelist.hxx"
+
+#include "../dom/document.hxx"
+#include <nodelist.hxx>
+
namespace XPath
{
- CXPathObject::CXPathObject(xmlXPathObjectPtr xpathObj, const Reference< XNode >& contextNode)
- : m_pXPathObj(xpathObj, xmlXPathFreeObject), m_xContextNode(contextNode)
+ static XPathObjectType lcl_GetType(xmlXPathObjectPtr const pXPathObj)
{
- switch (m_pXPathObj->type)
+ switch (pXPathObj->type)
{
- case XPATH_UNDEFINED:
- m_xPathObjectType = XPathObjectType_XPATH_UNDEFINED;
- break;
- case XPATH_NODESET:
- m_xPathObjectType = XPathObjectType_XPATH_NODESET;
- break;
- case XPATH_BOOLEAN:
- m_xPathObjectType = XPathObjectType_XPATH_BOOLEAN;
- break;
- case XPATH_NUMBER:
- m_xPathObjectType = XPathObjectType_XPATH_NUMBER;
- break;
- case XPATH_STRING:
- m_xPathObjectType = XPathObjectType_XPATH_STRING;
- break;
- case XPATH_POINT:
- m_xPathObjectType = XPathObjectType_XPATH_POINT;
- break;
- case XPATH_RANGE:
- m_xPathObjectType = XPathObjectType_XPATH_RANGE;
- break;
- case XPATH_LOCATIONSET:
- m_xPathObjectType = XPathObjectType_XPATH_LOCATIONSET;
- break;
- case XPATH_USERS:
- m_xPathObjectType = XPathObjectType_XPATH_USERS;
- break;
- case XPATH_XSLT_TREE:
- m_xPathObjectType = XPathObjectType_XPATH_XSLT_TREE;
- break;
- default:
- m_xPathObjectType = XPathObjectType_XPATH_UNDEFINED;
- break;
+ case XPATH_UNDEFINED:
+ return XPathObjectType_XPATH_UNDEFINED;
+ case XPATH_NODESET:
+ return XPathObjectType_XPATH_NODESET;
+ case XPATH_BOOLEAN:
+ return XPathObjectType_XPATH_BOOLEAN;
+ case XPATH_NUMBER:
+ return XPathObjectType_XPATH_NUMBER;
+ case XPATH_STRING:
+ return XPathObjectType_XPATH_STRING;
+ case XPATH_POINT:
+ return XPathObjectType_XPATH_POINT;
+ case XPATH_RANGE:
+ return XPathObjectType_XPATH_RANGE;
+ case XPATH_LOCATIONSET:
+ return XPathObjectType_XPATH_LOCATIONSET;
+ case XPATH_USERS:
+ return XPathObjectType_XPATH_USERS;
+ case XPATH_XSLT_TREE:
+ return XPathObjectType_XPATH_XSLT_TREE;
+ default:
+ return XPathObjectType_XPATH_UNDEFINED;
}
}
+ CXPathObject::CXPathObject(
+ ::rtl::Reference<DOM::CDocument> const& pDocument,
+ xmlXPathObjectPtr const xpathObj)
+ : m_pDocument(pDocument)
+ , m_pXPathObj(xpathObj, xmlXPathFreeObject)
+ , m_XPathObjectType(lcl_GetType(xpathObj))
+ {
+ }
+
/**
get object type
*/
XPathObjectType CXPathObject::getObjectType() throw (RuntimeException)
{
- return m_xPathObjectType;
+ return m_XPathObjectType;
}
/**
get the nodes from a nodelist type object
*/
- Reference< XNodeList > SAL_CALL CXPathObject::getNodeList() throw (RuntimeException)
+ Reference< XNodeList > SAL_CALL
+ CXPathObject::getNodeList() throw (RuntimeException)
{
Reference< XNodeList > const xRet(
- new CNodeList(m_xContextNode, m_pXPathObj));
+ new CNodeList(m_pDocument, m_pXPathObj));
return xRet;
}
diff --git a/unoxml/source/xpath/xpathobject.hxx b/unoxml/source/xpath/xpathobject.hxx
index 348fae8e21e6..7a0bfb1b0cb6 100644
--- a/unoxml/source/xpath/xpathobject.hxx
+++ b/unoxml/source/xpath/xpathobject.hxx
@@ -25,38 +25,46 @@
*
************************************************************************/
-#ifndef _XPATHOBJECT_HXX
-#define _XPATHOBJECT_HXX
+#ifndef XPATH_XPATHOBJECT_HXX
+#define XPATH_XPATHOBJECT_HXX
+
+#include <boost/shared_ptr.hpp>
+
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
-#include <map>
#include <sal/types.h>
+#include <rtl/ref.hxx>
+
#include <cppuhelper/implbase1.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 <com/sun/star/xml/xpath/XXPathObject.hpp>
-#include <libxml/tree.h>
-#include <libxml/xpath.h>
-#include <boost/shared_ptr.hpp>
+
using ::rtl::OUString;
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
using namespace com::sun::star::xml::dom;
using namespace com::sun::star::xml::xpath;
+
+namespace DOM {
+ class CDocument;
+}
+
namespace XPath
{
class CXPathObject : public cppu::WeakImplHelper1< XXPathObject >
{
private:
- boost::shared_ptr<xmlXPathObject> m_pXPathObj;
- const Reference< XNode > m_xContextNode;
- XPathObjectType m_xPathObjectType;
+ ::rtl::Reference< DOM::CDocument > const m_pDocument;
+ boost::shared_ptr<xmlXPathObject> const m_pXPathObj;
+ XPathObjectType const m_XPathObjectType;
public:
- CXPathObject(xmlXPathObjectPtr xpathObj, const Reference< XNode >& contextNode);
+ CXPathObject( ::rtl::Reference<DOM::CDocument> const& pDocument,
+ xmlXPathObjectPtr const xpathObj);
/**
get object type
@@ -66,7 +74,8 @@ namespace XPath
/**
get the nodes from a nodelist type object
*/
- virtual Reference< XNodeList > SAL_CALL getNodeList() throw (RuntimeException);
+ virtual Reference< XNodeList > SAL_CALL getNodeList()
+ throw (RuntimeException);
/**
get value of a boolean object