Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef XPATH_XPATHAPI_HXX
21 : : #define XPATH_XPATHAPI_HXX
22 : :
23 : : #include <map>
24 : : #include <vector>
25 : :
26 : : #include <sal/types.h>
27 : :
28 : : #include <cppuhelper/implbase2.hxx>
29 : :
30 : : #include <com/sun/star/uno/Reference.h>
31 : : #include <com/sun/star/uno/Sequence.h>
32 : :
33 : : #include <com/sun/star/uno/XInterface.hpp>
34 : : #include <com/sun/star/uno/Exception.hpp>
35 : : #include <com/sun/star/xml/xpath/XXPathAPI.hpp>
36 : : #include <com/sun/star/xml/dom/XNode.hpp>
37 : : #include <com/sun/star/xml/dom/XNodeList.hpp>
38 : : #include <com/sun/star/xml/xpath/XXPathAPI.hpp>
39 : : #include <com/sun/star/xml/xpath/XXPathObject.hpp>
40 : : #include <com/sun/star/xml/xpath/XXPathExtension.hpp>
41 : : #include <com/sun/star/xml/xpath/Libxml2ExtensionHandle.hpp>
42 : : #include <com/sun/star/xml/xpath/XPathException.hpp>
43 : : #include <com/sun/star/lang/XServiceInfo.hpp>
44 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
45 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 : :
47 : :
48 : : using ::rtl::OUString;
49 : : using namespace com::sun::star::uno;
50 : : using namespace com::sun::star::xml::dom;
51 : : using namespace com::sun::star::xml::xpath;
52 : :
53 : : namespace XPath
54 : : {
55 : : typedef std::map<OUString, OUString> nsmap_t;
56 : : typedef std::vector< Reference<XXPathExtension> > extensions_t;
57 : :
58 : : typedef ::cppu::WeakImplHelper2
59 : : < XXPathAPI
60 : : , ::com::sun::star::lang::XServiceInfo
61 : : > CXPathAPI_Base;
62 : :
63 [ + - ][ - + ]: 24640 : class CXPathAPI
64 : : : public CXPathAPI_Base
65 : : {
66 : :
67 : : private:
68 : : ::osl::Mutex m_Mutex;
69 : : nsmap_t m_nsmap;
70 : : const Reference< ::com::sun::star::lang::XMultiServiceFactory > m_aFactory;
71 : : extensions_t m_extensions;
72 : :
73 : : public:
74 : : // ctor
75 : : CXPathAPI(
76 : : const Reference< ::com::sun::star::lang::XMultiServiceFactory >&
77 : : rSMgr);
78 : :
79 : : // call for factory
80 : : static Reference< XInterface > getInstance(
81 : : const Reference < ::com::sun::star::lang::XMultiServiceFactory >&
82 : : xFactory);
83 : :
84 : : // static helpers for service info and component management
85 : : static const char* aImplementationName;
86 : : static const char* aSupportedServiceNames[];
87 : : static OUString _getImplementationName();
88 : : static Sequence< OUString > _getSupportedServiceNames();
89 : : static Reference< XInterface > _getInstance(
90 : : const Reference< ::com::sun::star::lang::XMultiServiceFactory >&
91 : : rSMgr);
92 : :
93 : : // XServiceInfo
94 : : virtual OUString SAL_CALL getImplementationName()
95 : : throw (RuntimeException);
96 : : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
97 : : throw (RuntimeException);
98 : : virtual Sequence< OUString > SAL_CALL getSupportedServiceNames ()
99 : : throw (RuntimeException);
100 : :
101 : :
102 : : // --- XXPathAPI ---
103 : :
104 : : virtual void SAL_CALL registerNS(const OUString& aPrefix, const OUString& aURI)
105 : : throw (RuntimeException);
106 : :
107 : : virtual void SAL_CALL unregisterNS(const OUString& aPrefix, const OUString& aURI)
108 : : throw (RuntimeException);
109 : :
110 : : /**
111 : : Use an XPath string to select a nodelist.
112 : : */
113 : : virtual Reference< XNodeList > SAL_CALL selectNodeList(const Reference< XNode >& contextNode, const OUString& str)
114 : : throw (RuntimeException, XPathException);
115 : :
116 : : /**
117 : : Use an XPath string to select a nodelist.
118 : : */
119 : : virtual Reference< XNodeList > SAL_CALL selectNodeListNS(const Reference< XNode >& contextNode, const OUString& str, const Reference< XNode >& namespaceNode)
120 : : throw (RuntimeException, XPathException);
121 : :
122 : : /**
123 : : Use an XPath string to select a single node.
124 : : */
125 : : virtual Reference< XNode > SAL_CALL selectSingleNode(const Reference< XNode >& contextNode, const OUString& str)
126 : : throw (RuntimeException, XPathException);
127 : :
128 : : /**
129 : : Use an XPath string to select a single node.
130 : : */
131 : : virtual Reference< XNode > SAL_CALL selectSingleNodeNS(const Reference< XNode >& contextNode, const OUString& str, const Reference< XNode >& namespaceNode)
132 : : throw (RuntimeException, XPathException);
133 : :
134 : : virtual Reference< XXPathObject > SAL_CALL eval(const Reference< XNode >& contextNode, const OUString& str)
135 : : throw (RuntimeException, XPathException);
136 : :
137 : : virtual Reference< XXPathObject > SAL_CALL evalNS(const Reference< XNode >& contextNode, const OUString& str, const Reference< XNode >& namespaceNode)
138 : : throw (RuntimeException, XPathException);
139 : :
140 : : virtual void SAL_CALL registerExtension(const OUString& aName) throw (RuntimeException);
141 : : virtual void SAL_CALL registerExtensionInstance(const Reference< XXPathExtension>& aExtension) throw (RuntimeException);
142 : :
143 : : };
144 : : }
145 : :
146 : : #endif
147 : :
148 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|