LCOV - code coverage report
Current view: top level - unoxml/source/dom - elementlist.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 5 8 62.5 %
Date: 2014-11-03 Functions: 4 5 80.0 %
Legend: Lines: hit not hit

          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/implbase1.hxx>
      40             : #include <cppuhelper/implbase2.hxx>
      41             : 
      42             : namespace DOM
      43             : {
      44             :     class CElement;
      45             : 
      46             :     typedef std::vector< xmlNodePtr > nodevector_t;
      47             : 
      48             :     class CElementListImpl
      49             :         : public cppu::WeakImplHelper2< css::xml::dom::XNodeList,
      50             :                 css::xml::dom::events::XEventListener >
      51             :     {
      52             :     private:
      53             :         /** @short  proxy weak binding to forward Events to ourself without
      54             :                     an ownership cycle
      55             :           */
      56             :         css::uno::Reference< css::xml::dom::events::XEventListener > m_xEventListener;
      57             : 
      58             :         ::rtl::Reference<CElement> const m_pElement;
      59             :         ::osl::Mutex & m_rMutex;
      60             :         ::boost::scoped_array<xmlChar> const m_pName;
      61             :         ::boost::scoped_array<xmlChar> const m_pURI;
      62             :         bool m_bRebuild;
      63             :         nodevector_t m_nodevector;
      64             : 
      65             :         void buildlist(xmlNodePtr pNode, bool start=true);
      66             : 
      67             :     public:
      68             :         CElementListImpl(::rtl::Reference<CElement> const& pElement,
      69             :                 ::osl::Mutex & rMutex,
      70             :                 OUString const& rName, OUString const*const pURI = 0);
      71             : 
      72             :         void registerListener(CElement & rElement);
      73             : 
      74             :         virtual ~CElementListImpl();
      75             : 
      76             :         /**
      77             :         The number of nodes in the list.
      78             :         */
      79             :         virtual sal_Int32 SAL_CALL getLength() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      80             :         /**
      81             :         Returns the indexth item in the collection.
      82             :         */
      83             :         virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL item(sal_Int32 index)
      84             :             throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      85             : 
      86             :         // XEventListener
      87             :         virtual void SAL_CALL handleEvent(const css::uno::Reference< css::xml::dom::events::XEvent >& evt)
      88             :             throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      89             :     };
      90             : 
      91        1828 :     class CElementList
      92             :         : public cppu::WeakImplHelper2< css::xml::dom::XNodeList,
      93             :                 css::xml::dom::events::XEventListener >
      94             :     {
      95             :     private:
      96             :         rtl::Reference<CElementListImpl> m_xImpl;
      97             :     public:
      98             :         CElementList(::rtl::Reference<CElement> const& pElement,
      99             :                 ::osl::Mutex & rMutex,
     100             :                 OUString const& rName, OUString const*const pURI = 0);
     101             : 
     102             :         /**
     103             :         The number of nodes in the list.
     104             :         */
     105         912 :         virtual sal_Int32 SAL_CALL getLength() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     106             :         {
     107         912 :             return m_xImpl->getLength();
     108             :         }
     109             :         /**
     110             :         Returns the indexth item in the collection.
     111             :         */
     112        9766 :         virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL item(sal_Int32 index)
     113             :             throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     114             :         {
     115        9766 :             return m_xImpl->item(index);
     116             :         }
     117             : 
     118             :         // XEventListener
     119           0 :         virtual void SAL_CALL handleEvent(const css::uno::Reference< css::xml::dom::events::XEvent >& evt)
     120             :             throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     121             :         {
     122           0 :             m_xImpl->handleEvent(evt);
     123           0 :         }
     124             :     };
     125             : }
     126             : 
     127             : #endif
     128             : 
     129             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10