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