Update ooo320-m1
[ooovba.git] / unoxml / source / xpath / xpathapi.hxx
blobe102da241fc2da6045e5ee70ee8579fd285dba72
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xpathapi.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XPATHAPI_HXX
32 #define _XPATHAPI_HXX
34 #include <map>
35 #include <vector>
37 #include <sal/types.h>
38 #include <cppuhelper/implbase2.hxx>
39 #include <com/sun/star/uno/Reference.h>
40 #include <com/sun/star/uno/Sequence.h>
42 #include <com/sun/star/uno/XInterface.hpp>
43 #include <com/sun/star/uno/Exception.hpp>
44 #include <com/sun/star/xml/xpath/XXPathAPI.hpp>
45 #include <com/sun/star/xml/dom/XNode.hpp>
46 #include <com/sun/star/xml/dom/XNodeList.hpp>
47 #include <com/sun/star/xml/xpath/XXPathAPI.hpp>
48 #include <com/sun/star/xml/xpath/XXPathObject.hpp>
49 #include <com/sun/star/xml/xpath/XXPathExtension.hpp>
50 #include <com/sun/star/xml/xpath/Libxml2ExtensionHandle.hpp>
51 #include <com/sun/star/xml/xpath/XPathException.hpp>
52 #include <com/sun/star/lang/XServiceInfo.hpp>
53 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
54 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
56 #include "libxml/tree.h"
58 using ::rtl::OUString;
59 using namespace com::sun::star::uno;
60 using namespace com::sun::star::lang;
61 using namespace com::sun::star::xml::dom;
62 using namespace com::sun::star::xml::xpath;
64 namespace XPath
66 typedef std::map<OUString, OUString> nsmap_t;
67 typedef std::vector< Reference<XXPathExtension> > extensions_t;
69 class CXPathAPI
70 : public ::cppu::WeakImplHelper2< XXPathAPI, XServiceInfo >
73 private:
74 nsmap_t m_nsmap;
75 const Reference < XMultiServiceFactory >& m_aFactory;
76 extensions_t m_extensions;
78 public:
79 // ctor
80 CXPathAPI(const Reference< XMultiServiceFactory >& rSMgr);
82 // call for factory
83 static Reference< XInterface > getInstance(const Reference < XMultiServiceFactory >& xFactory);
85 // static helpers for service info and component management
86 static const char* aImplementationName;
87 static const char* aSupportedServiceNames[];
88 static OUString _getImplementationName();
89 static Sequence< OUString > _getSupportedServiceNames();
90 static Reference< XInterface > _getInstance(const Reference< XMultiServiceFactory >& rSMgr);
92 // XServiceInfo
93 virtual OUString SAL_CALL getImplementationName()
94 throw (RuntimeException);
95 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
96 throw (RuntimeException);
97 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames ()
98 throw (RuntimeException);
101 // --- XXPathAPI ---
103 virtual void SAL_CALL registerNS(const OUString& aPrefix, const OUString& aURI)
104 throw (RuntimeException);
106 virtual void SAL_CALL unregisterNS(const OUString& aPrefix, const OUString& aURI)
107 throw (RuntimeException);
110 Use an XPath string to select a nodelist.
112 virtual Reference< XNodeList > SAL_CALL selectNodeList(const Reference< XNode >& contextNode, const OUString& str)
113 throw (RuntimeException, XPathException);
116 Use an XPath string to select a nodelist.
118 virtual Reference< XNodeList > SAL_CALL selectNodeListNS(const Reference< XNode >& contextNode, const OUString& str, const Reference< XNode >& namespaceNode)
119 throw (RuntimeException, XPathException);
122 Use an XPath string to select a single node.
124 virtual Reference< XNode > SAL_CALL selectSingleNode(const Reference< XNode >& contextNode, const OUString& str)
125 throw (RuntimeException, XPathException);
128 Use an XPath string to select a single node.
130 virtual Reference< XNode > SAL_CALL selectSingleNodeNS(const Reference< XNode >& contextNode, const OUString& str, const Reference< XNode >& namespaceNode)
131 throw (RuntimeException, XPathException);
133 virtual Reference< XXPathObject > SAL_CALL eval(const Reference< XNode >& contextNode, const OUString& str)
134 throw (RuntimeException, XPathException);
136 virtual Reference< XXPathObject > SAL_CALL evalNS(const Reference< XNode >& contextNode, const OUString& str, const Reference< XNode >& namespaceNode)
137 throw (RuntimeException, XPathException);
139 virtual void SAL_CALL registerExtension(const OUString& aName) throw (RuntimeException);
140 virtual void SAL_CALL registerExtensionInstance(const Reference< XXPathExtension>& aExtension) throw (RuntimeException);
145 #endif