xref: /aoo4110/main/unoxml/source/xpath/nodelist.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef XPATH_NODELIST_HXX
25 #define XPATH_NODELIST_HXX
26 
27 #include <sal/types.h>
28 #include <rtl/ref.hxx>
29 
30 #include <cppuhelper/implbase1.hxx>
31 
32 #include <com/sun/star/uno/Reference.h>
33 #include <com/sun/star/xml/dom/XNode.hpp>
34 #include <com/sun/star/xml/dom/XNodeList.hpp>
35 #include <com/sun/star/xml/xpath/XXPathObject.hpp>
36 
37 #include "libxml/tree.h"
38 #include "libxml/xpath.h"
39 
40 #include <boost/shared_ptr.hpp>
41 
42 
43 using ::rtl::OUString;
44 using namespace com::sun::star::uno;
45 using namespace com::sun::star::xml::dom;
46 using namespace com::sun::star::xml::xpath;
47 
48 namespace DOM {
49     class CDocument;
50 }
51 
52 namespace XPath
53 {
54 
55     class CNodeList : public cppu::WeakImplHelper1< XNodeList >
56     {
57     private:
58         /// #i115995# keep document alive
59         ::rtl::Reference< DOM::CDocument > const m_pDocument;
60         ::osl::Mutex & m_rMutex;
61         /// retain the result set in case the CXPathObject is released
62         boost::shared_ptr<xmlXPathObject> m_pXPathObj;
63         xmlNodeSetPtr m_pNodeSet;
64 
65     public:
66         CNodeList(
67                 ::rtl::Reference<DOM::CDocument> const& pDocument,
68                 ::osl::Mutex & rMutex,
69                 boost::shared_ptr<xmlXPathObject> const& rxpathObj);
70         /**
71         The number of nodes in the list.
72         */
73         virtual sal_Int32 SAL_CALL getLength() throw (RuntimeException);
74         /**
75         Returns the indexth item in the collection.
76         */
77         virtual Reference< XNode > SAL_CALL item(sal_Int32 index)
78             throw (RuntimeException);
79     };
80 }
81 
82 #endif
83