LibreOffice Module unoxml (master) 1
elementlist.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 <vector>
23#include <string_view>
24#include <memory>
25
26#include <libxml/tree.h>
27
28#include <sal/types.h>
29#include <rtl/ref.hxx>
30
31#include <com/sun/star/uno/Reference.h>
32#include <com/sun/star/xml/dom/XNode.hpp>
33#include <com/sun/star/xml/dom/XNodeList.hpp>
34#include <com/sun/star/xml/dom/events/XEvent.hpp>
35#include <com/sun/star/xml/dom/events/XEventListener.hpp>
36
38
39namespace DOM
40{
41 class CElement;
42
44 : public cppu::WeakImplHelper< css::xml::dom::XNodeList,
45 css::xml::dom::events::XEventListener >
46 {
47 private:
51 css::uno::Reference< css::xml::dom::events::XEventListener > m_xEventListener;
52
54 ::osl::Mutex & m_rMutex;
55 ::std::unique_ptr<xmlChar[]> const m_pName;
56 ::std::unique_ptr<xmlChar[]> const m_pURI;
58 std::vector< xmlNodePtr > m_nodevector;
59
60 void buildlist(xmlNodePtr pNode, bool start=true);
61
62 public:
64 ::osl::Mutex & rMutex,
65 std::u16string_view rName, OUString const*const pURI);
66
67 void registerListener(CElement & rElement);
68
69 virtual ~CElementListImpl() override;
70
74 virtual sal_Int32 SAL_CALL getLength() override;
78 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL item(sal_Int32 index) override;
79
80 // XEventListener
81 virtual void SAL_CALL handleEvent(const css::uno::Reference< css::xml::dom::events::XEvent >& evt) override;
82 };
83
85 : public cppu::WeakImplHelper< css::xml::dom::XNodeList,
86 css::xml::dom::events::XEventListener >
87 {
88 private:
90 public:
92 ::osl::Mutex & rMutex,
93 std::u16string_view rName, OUString const*const pURI = nullptr);
94
98 virtual sal_Int32 SAL_CALL getLength() override
99 {
100 return m_xImpl->getLength();
101 }
105 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL item(sal_Int32 index) override
106 {
107 return m_xImpl->item(index);
108 }
109
110 // XEventListener
111 virtual void SAL_CALL handleEvent(const css::uno::Reference< css::xml::dom::events::XEvent >& evt) override
112 {
113 m_xImpl->handleEvent(evt);
114 }
115 };
116}
117
118/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL item(sal_Int32 index) override
Returns the indexth item in the collection.
::rtl::Reference< CElement > const m_pElement
Definition: elementlist.hxx:53
css::uno::Reference< css::xml::dom::events::XEventListener > m_xEventListener
proxy weak binding to forward Events to ourself without an ownership cycle
Definition: elementlist.hxx:51
virtual void SAL_CALL handleEvent(const css::uno::Reference< css::xml::dom::events::XEvent > &evt) override
::std::unique_ptr< xmlChar[]> const m_pURI
Definition: elementlist.hxx:56
virtual sal_Int32 SAL_CALL getLength() override
The number of nodes in the list.
virtual ~CElementListImpl() override
Definition: elementlist.cxx:93
::osl::Mutex & m_rMutex
Definition: elementlist.hxx:54
::std::unique_ptr< xmlChar[]> const m_pName
Definition: elementlist.hxx:55
void buildlist(xmlNodePtr pNode, bool start=true)
CElementListImpl(::rtl::Reference< CElement > pElement, ::osl::Mutex &rMutex, std::u16string_view rName, OUString const *const pURI)
Definition: elementlist.cxx:82
std::vector< xmlNodePtr > m_nodevector
Definition: elementlist.hxx:58
void registerListener(CElement &rElement)
virtual sal_Int32 SAL_CALL getLength() override
The number of nodes in the list.
Definition: elementlist.hxx:98
virtual void SAL_CALL handleEvent(const css::uno::Reference< css::xml::dom::events::XEvent > &evt) override
rtl::Reference< CElementListImpl > m_xImpl
Definition: elementlist.hxx:89
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL item(sal_Int32 index) override
Returns the indexth item in the collection.
CElementList(::rtl::Reference< CElement > const &pElement, ::osl::Mutex &rMutex, std::u16string_view rName, OUString const *const pURI=nullptr)
Definition: elementlist.cxx:72
Definition: attr.cxx:38
index