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 INCLUDED_UNOXML_SOURCE_DOM_ELEMENTLIST_HXX
21 : #define INCLUDED_UNOXML_SOURCE_DOM_ELEMENTLIST_HXX
22 :
23 : #include <vector>
24 :
25 : #include <boost/scoped_array.hpp>
26 :
27 : #include <libxml/tree.h>
28 :
29 : #include <sal/types.h>
30 : #include <rtl/ref.hxx>
31 :
32 : #include <com/sun/star/uno/Reference.h>
33 : #include <com/sun/star/uno/Exception.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/dom/events/XEvent.hpp>
37 : #include <com/sun/star/xml/dom/events/XEventListener.hpp>
38 :
39 : #include <cppuhelper/implbase2.hxx>
40 :
41 :
42 : using namespace com::sun::star::uno;
43 : using namespace com::sun::star::xml::dom;
44 : using namespace com::sun::star::xml::dom::events;
45 :
46 : namespace DOM
47 : {
48 : class CElement;
49 :
50 : typedef std::vector< xmlNodePtr > nodevector_t;
51 :
52 0 : class CElementList
53 : : public cppu::WeakImplHelper2< XNodeList,
54 : com::sun::star::xml::dom::events::XEventListener >
55 : {
56 : private:
57 : ::rtl::Reference<CElement> const m_pElement;
58 : ::osl::Mutex & m_rMutex;
59 : ::boost::scoped_array<xmlChar> const m_pName;
60 : ::boost::scoped_array<xmlChar> const m_pURI;
61 : bool m_bRebuild;
62 : nodevector_t m_nodevector;
63 :
64 : void buildlist(xmlNodePtr pNode, sal_Bool start=sal_True);
65 : void registerListener(CElement & rElement);
66 :
67 : public:
68 : CElementList(::rtl::Reference<CElement> const& pElement,
69 : ::osl::Mutex & rMutex,
70 : OUString const& rName, OUString const*const pURI = 0);
71 :
72 : /**
73 : The number of nodes in the list.
74 : */
75 : virtual sal_Int32 SAL_CALL getLength() throw (RuntimeException, std::exception) SAL_OVERRIDE;
76 : /**
77 : Returns the indexth item in the collection.
78 : */
79 : virtual Reference< XNode > SAL_CALL item(sal_Int32 index)
80 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
81 :
82 : // XEventListener
83 : virtual void SAL_CALL handleEvent(const Reference< XEvent >& evt)
84 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
85 : };
86 : }
87 :
88 : #endif
89 :
90 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|