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