1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef DOM_ELEMENTLIST_HXX 29 #define DOM_ELEMENTLIST_HXX 30 31 #include <vector> 32 33 #include <boost/scoped_array.hpp> 34 35 #include <libxml/tree.h> 36 37 #include <sal/types.h> 38 #include <rtl/ref.hxx> 39 40 #include <com/sun/star/uno/Reference.h> 41 #include <com/sun/star/uno/Exception.hpp> 42 #include <com/sun/star/xml/dom/XNode.hpp> 43 #include <com/sun/star/xml/dom/XNodeList.hpp> 44 #include <com/sun/star/xml/dom/events/XEvent.hpp> 45 #include <com/sun/star/xml/dom/events/XEventListener.hpp> 46 47 #include <cppuhelper/implbase2.hxx> 48 49 50 using ::rtl::OUString; 51 using namespace com::sun::star::uno; 52 using namespace com::sun::star::xml::dom; 53 using namespace com::sun::star::xml::dom::events; 54 55 namespace DOM 56 { 57 class CElement; 58 59 typedef std::vector< xmlNodePtr > nodevector_t; 60 61 class CElementList 62 : public cppu::WeakImplHelper2< XNodeList, 63 com::sun::star::xml::dom::events::XEventListener > 64 { 65 private: 66 ::rtl::Reference<CElement> const m_pElement; 67 ::osl::Mutex & m_rMutex; 68 ::boost::scoped_array<xmlChar> const m_pName; 69 ::boost::scoped_array<xmlChar> const m_pURI; 70 bool m_bRebuild; 71 nodevector_t m_nodevector; 72 73 void buildlist(xmlNodePtr pNode, sal_Bool start=sal_True); 74 void registerListener(CElement & rElement); 75 76 public: 77 CElementList(::rtl::Reference<CElement> const& pElement, 78 ::osl::Mutex & rMutex, 79 OUString const& rName, OUString const*const pURI = 0); 80 81 /** 82 The number of nodes in the list. 83 */ 84 virtual sal_Int32 SAL_CALL getLength() throw (RuntimeException); 85 /** 86 Returns the indexth item in the collection. 87 */ 88 virtual Reference< XNode > SAL_CALL item(sal_Int32 index) 89 throw (RuntimeException); 90 91 // XEventListener 92 virtual void SAL_CALL handleEvent(const Reference< XEvent >& evt) 93 throw (RuntimeException); 94 }; 95 } 96 97 #endif 98