xref: /aoo42x/main/unoxml/source/xpath/xpathapi.hxx (revision 7f654276)
1*7f654276SAndrew Rist /**************************************************************
2*7f654276SAndrew Rist  *
3*7f654276SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*7f654276SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*7f654276SAndrew Rist  * distributed with this work for additional information
6*7f654276SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*7f654276SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*7f654276SAndrew Rist  * "License"); you may not use this file except in compliance
9*7f654276SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*7f654276SAndrew Rist  *
11*7f654276SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*7f654276SAndrew Rist  *
13*7f654276SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*7f654276SAndrew Rist  * software distributed under the License is distributed on an
15*7f654276SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*7f654276SAndrew Rist  * KIND, either express or implied.  See the License for the
17*7f654276SAndrew Rist  * specific language governing permissions and limitations
18*7f654276SAndrew Rist  * under the License.
19*7f654276SAndrew Rist  *
20*7f654276SAndrew Rist  *************************************************************/
21*7f654276SAndrew Rist 
22*7f654276SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef XPATH_XPATHAPI_HXX
25cdf0e10cSrcweir #define XPATH_XPATHAPI_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <map>
28cdf0e10cSrcweir #include <vector>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <sal/types.h>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
35cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hpp>
38cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp>
39cdf0e10cSrcweir #include <com/sun/star/xml/xpath/XXPathAPI.hpp>
40cdf0e10cSrcweir #include <com/sun/star/xml/dom/XNode.hpp>
41cdf0e10cSrcweir #include <com/sun/star/xml/dom/XNodeList.hpp>
42cdf0e10cSrcweir #include <com/sun/star/xml/xpath/XXPathAPI.hpp>
43cdf0e10cSrcweir #include <com/sun/star/xml/xpath/XXPathObject.hpp>
44cdf0e10cSrcweir #include <com/sun/star/xml/xpath/XXPathExtension.hpp>
45cdf0e10cSrcweir #include <com/sun/star/xml/xpath/Libxml2ExtensionHandle.hpp>
46cdf0e10cSrcweir #include <com/sun/star/xml/xpath/XPathException.hpp>
47cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
48cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
49cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir using ::rtl::OUString;
53cdf0e10cSrcweir using namespace com::sun::star::uno;
54cdf0e10cSrcweir using namespace com::sun::star::xml::dom;
55cdf0e10cSrcweir using namespace com::sun::star::xml::xpath;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir namespace XPath
58cdf0e10cSrcweir {
59cdf0e10cSrcweir     typedef std::map<OUString, OUString> nsmap_t;
60cdf0e10cSrcweir     typedef std::vector< Reference<XXPathExtension> > extensions_t;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     typedef ::cppu::WeakImplHelper2
63cdf0e10cSrcweir         <   XXPathAPI
64cdf0e10cSrcweir         ,   ::com::sun::star::lang::XServiceInfo
65cdf0e10cSrcweir         > CXPathAPI_Base;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     class  CXPathAPI
68cdf0e10cSrcweir         : public CXPathAPI_Base
69cdf0e10cSrcweir     {
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     private:
72cdf0e10cSrcweir         ::osl::Mutex m_Mutex;
73cdf0e10cSrcweir         nsmap_t m_nsmap;
74cdf0e10cSrcweir         const Reference< ::com::sun::star::lang::XMultiServiceFactory > m_aFactory;
75cdf0e10cSrcweir         extensions_t m_extensions;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     public:
78cdf0e10cSrcweir         // ctor
79cdf0e10cSrcweir         CXPathAPI(
80cdf0e10cSrcweir             const Reference< ::com::sun::star::lang::XMultiServiceFactory >&
81cdf0e10cSrcweir                 rSMgr);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         // call for factory
84cdf0e10cSrcweir         static Reference< XInterface > getInstance(
85cdf0e10cSrcweir             const Reference < ::com::sun::star::lang::XMultiServiceFactory >&
86cdf0e10cSrcweir                 xFactory);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir         // static helpers for service info and component management
89cdf0e10cSrcweir         static const char* aImplementationName;
90cdf0e10cSrcweir 	    static const char* aSupportedServiceNames[];
91cdf0e10cSrcweir         static OUString _getImplementationName();
92cdf0e10cSrcweir         static Sequence< OUString > _getSupportedServiceNames();
93cdf0e10cSrcweir         static Reference< XInterface > _getInstance(
94cdf0e10cSrcweir             const Reference< ::com::sun::star::lang::XMultiServiceFactory >&
95cdf0e10cSrcweir                 rSMgr);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         // XServiceInfo
98cdf0e10cSrcweir         virtual OUString SAL_CALL getImplementationName()
99cdf0e10cSrcweir             throw (RuntimeException);
100cdf0e10cSrcweir         virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
101cdf0e10cSrcweir             throw (RuntimeException);
102cdf0e10cSrcweir         virtual Sequence< OUString > SAL_CALL getSupportedServiceNames ()
103cdf0e10cSrcweir             throw (RuntimeException);
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         // --- XXPathAPI ---
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         virtual void SAL_CALL registerNS(const OUString& aPrefix, const OUString& aURI)
109cdf0e10cSrcweir             throw (RuntimeException);
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         virtual void SAL_CALL unregisterNS(const OUString& aPrefix, const OUString& aURI)
112cdf0e10cSrcweir             throw (RuntimeException);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir         /**
115cdf0e10cSrcweir         Use an XPath string to select a nodelist.
116cdf0e10cSrcweir         */
117cdf0e10cSrcweir         virtual Reference< XNodeList > SAL_CALL selectNodeList(const Reference< XNode >& contextNode, const OUString& str)
118cdf0e10cSrcweir             throw (RuntimeException, XPathException);
119cdf0e10cSrcweir 
120cdf0e10cSrcweir         /**
121cdf0e10cSrcweir         Use an XPath string to select a nodelist.
122cdf0e10cSrcweir         */
123cdf0e10cSrcweir         virtual Reference< XNodeList > SAL_CALL selectNodeListNS(const Reference< XNode >& contextNode, const OUString& str, const Reference< XNode >&  namespaceNode)
124cdf0e10cSrcweir             throw (RuntimeException, XPathException);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir         /**
127cdf0e10cSrcweir         Use an XPath string to select a single node.
128cdf0e10cSrcweir         */
129cdf0e10cSrcweir         virtual Reference< XNode > SAL_CALL selectSingleNode(const Reference< XNode >& contextNode, const OUString& str)
130cdf0e10cSrcweir             throw (RuntimeException, XPathException);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         /**
133cdf0e10cSrcweir         Use an XPath string to select a single node.
134cdf0e10cSrcweir         */
135cdf0e10cSrcweir         virtual Reference< XNode > SAL_CALL selectSingleNodeNS(const Reference< XNode >& contextNode, const OUString& str, const Reference< XNode >&  namespaceNode)
136cdf0e10cSrcweir             throw (RuntimeException, XPathException);
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         virtual Reference< XXPathObject > SAL_CALL eval(const Reference< XNode >& contextNode, const OUString& str)
139cdf0e10cSrcweir             throw (RuntimeException, XPathException);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         virtual Reference< XXPathObject > SAL_CALL evalNS(const Reference< XNode >& contextNode, const OUString& str, const Reference< XNode >&  namespaceNode)
142cdf0e10cSrcweir             throw (RuntimeException, XPathException);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         virtual void SAL_CALL registerExtension(const OUString& aName) throw (RuntimeException);
145cdf0e10cSrcweir         virtual void SAL_CALL registerExtensionInstance(const Reference< XXPathExtension>& aExtension) throw (RuntimeException);
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     };
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir #endif
151