LibreOffice Module unoxml (master) 1
xpathapi.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <map>
23#include <mutex>
24#include <vector>
25
26#include <sal/types.h>
27
29
30#include <com/sun/star/uno/Reference.h>
31#include <com/sun/star/uno/Sequence.h>
32
33#include <com/sun/star/xml/xpath/XXPathAPI.hpp>
34#include <com/sun/star/xml/dom/XNode.hpp>
35#include <com/sun/star/xml/dom/XNodeList.hpp>
36#include <com/sun/star/xml/xpath/XXPathObject.hpp>
37#include <com/sun/star/xml/xpath/XXPathExtension.hpp>
38#include <com/sun/star/lang/XServiceInfo.hpp>
39#include <com/sun/star/uno/XComponentContext.hpp>
40
41namespace XPath
42{
43 typedef std::map<OUString, OUString> nsmap_t;
44 typedef std::vector< css::uno::Reference<css::xml::xpath::XXPathExtension> > extensions_t;
45
46 typedef ::cppu::WeakImplHelper
47 < css::xml::xpath::XXPathAPI
48 , css::lang::XServiceInfo
50
52 : public CXPathAPI_Base
53 {
54
55 private:
56 std::mutex m_Mutex;
58 const css::uno::Reference< css::uno::XComponentContext > m_xContext;
60
61 public:
62 // ctor
63 explicit CXPathAPI( const css::uno::Reference< css::uno::XComponentContext >& );
64
65 // XServiceInfo
66 virtual OUString SAL_CALL getImplementationName() override;
67 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
68 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames () override;
69
70
71 // --- XXPathAPI ---
72
73 virtual void SAL_CALL registerNS(const OUString& aPrefix, const OUString& aURI) override;
74
75 virtual void SAL_CALL unregisterNS(const OUString& aPrefix, const OUString& aURI) override;
76
80 virtual css::uno::Reference< css::xml::dom::XNodeList > SAL_CALL selectNodeList(const css::uno::Reference< css::xml::dom::XNode >& contextNode, const OUString& str) override;
81
85 virtual css::uno::Reference< css::xml::dom::XNodeList > SAL_CALL selectNodeListNS(const css::uno::Reference< css::xml::dom::XNode >& contextNode, const OUString& str, const css::uno::Reference< css::xml::dom::XNode >& namespaceNode) override;
86
90 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL selectSingleNode(const css::uno::Reference< css::xml::dom::XNode >& contextNode, const OUString& str) override;
91
95 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL selectSingleNodeNS(const css::uno::Reference< css::xml::dom::XNode >& contextNode, const OUString& str, const css::uno::Reference< css::xml::dom::XNode >& namespaceNode) override;
96
97 virtual css::uno::Reference< css::xml::xpath::XXPathObject > SAL_CALL eval(const css::uno::Reference< css::xml::dom::XNode >& contextNode, const OUString& str) override;
98
99 virtual css::uno::Reference< css::xml::xpath::XXPathObject > SAL_CALL evalNS(const css::uno::Reference< css::xml::dom::XNode >& contextNode, const OUString& str, const css::uno::Reference< css::xml::dom::XNode >& namespaceNode) override;
100
101 virtual void SAL_CALL registerExtension(const OUString& aName) override;
102 virtual void SAL_CALL registerExtensionInstance(const css::uno::Reference< css::xml::xpath::XXPathExtension>& aExtension) override;
103
104 };
105}
106
107/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL registerNS(const OUString &aPrefix, const OUString &aURI) override
Definition: xpathapi.cxx:71
CXPathAPI(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: xpathapi.cxx:51
virtual css::uno::Reference< css::xml::xpath::XXPathObject > SAL_CALL evalNS(const css::uno::Reference< css::xml::dom::XNode > &contextNode, const OUString &str, const css::uno::Reference< css::xml::dom::XNode > &namespaceNode) override
same as eval but registers all namespace declarations found on namespaceNode
Definition: xpathapi.cxx:346
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: xpathapi.cxx:66
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL selectSingleNode(const css::uno::Reference< css::xml::dom::XNode > &contextNode, const OUString &str) override
Use an XPath string to select a single node.
Definition: xpathapi.cxx:198
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL selectSingleNodeNS(const css::uno::Reference< css::xml::dom::XNode > &contextNode, const OUString &str, const css::uno::Reference< css::xml::dom::XNode > &namespaceNode) override
Use an XPath string to select a single node.
Definition: xpathapi.cxx:211
virtual css::uno::Reference< css::xml::dom::XNodeList > SAL_CALL selectNodeList(const css::uno::Reference< css::xml::dom::XNode > &contextNode, const OUString &str) override
Use an XPath string to select a nodelist.
Definition: xpathapi.cxx:175
virtual OUString SAL_CALL getImplementationName() override
Definition: xpathapi.cxx:61
virtual void SAL_CALL unregisterNS(const OUString &aPrefix, const OUString &aURI) override
Definition: xpathapi.cxx:80
const css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: xpathapi.hxx:58
virtual void SAL_CALL registerExtension(const OUString &aName) override
uses the service manager to create an instance of the service denoted by aName.
Definition: xpathapi.cxx:360
virtual css::uno::Reference< css::xml::dom::XNodeList > SAL_CALL selectNodeListNS(const css::uno::Reference< css::xml::dom::XNode > &contextNode, const OUString &str, const css::uno::Reference< css::xml::dom::XNode > &namespaceNode) override
Use an XPath string to select a nodelist.
Definition: xpathapi.cxx:186
nsmap_t m_nsmap
Definition: xpathapi.hxx:57
std::mutex m_Mutex
Definition: xpathapi.hxx:56
extensions_t m_extensions
Definition: xpathapi.hxx:59
virtual css::uno::Reference< css::xml::xpath::XXPathObject > SAL_CALL eval(const css::uno::Reference< css::xml::dom::XNode > &contextNode, const OUString &str) override
evaluates an XPath string.
Definition: xpathapi.cxx:273
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: xpathapi.cxx:56
virtual void SAL_CALL registerExtensionInstance(const css::uno::Reference< css::xml::xpath::XXPathExtension > &aExtension) override
registers the given extension instance to be used by XPath evaluations performed through this XPathAP...
Definition: xpathapi.cxx:375
std::map< OUString, OUString > nsmap_t
Definition: xpathapi.hxx:43
std::vector< css::uno::Reference< css::xml::xpath::XXPathExtension > > extensions_t
Definition: xpathapi.hxx:44
::cppu::WeakImplHelper< css::xml::xpath::XXPathAPI, css::lang::XServiceInfo > CXPathAPI_Base
Definition: xpathapi.hxx:49
unsigned char sal_Bool