LCOV - code coverage report
Current view: top level - unoxml/source/dom - childlist.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 25 25 100.0 %
Date: 2014-11-03 Functions: 3 3 100.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             : #include <childlist.hxx>
      21             : 
      22             : #include <libxml/tree.h>
      23             : 
      24             : #include <node.hxx>
      25             : #include <document.hxx>
      26             : 
      27             : using namespace css::uno;
      28             : using namespace css::xml::dom;
      29             : 
      30             : namespace DOM
      31             : {
      32        4780 :     CChildList::CChildList(::rtl::Reference<CNode> const& pBase,
      33             :                 ::osl::Mutex & rMutex)
      34             :         : m_pNode(pBase)
      35        4780 :         , m_rMutex(rMutex)
      36             :     {
      37        4780 :     }
      38             : 
      39             :     /**
      40             :     The number of nodes in the list.
      41             :     */
      42        4788 :     sal_Int32 SAL_CALL CChildList::getLength() throw (RuntimeException, std::exception)
      43             :     {
      44        4788 :         ::osl::MutexGuard const g(m_rMutex);
      45             : 
      46        4788 :         sal_Int32 length = 0;
      47        4788 :         if (m_pNode != NULL)
      48             :         {
      49        4788 :             xmlNodePtr cur = m_pNode->GetNodePtr();
      50        4788 :             if (0 != cur) {
      51        4788 :                 cur = cur->children;
      52             :             }
      53       34798 :             while (cur != NULL)
      54             :             {
      55       25222 :                 length++;
      56       25222 :                 cur = cur->next;
      57             :             }
      58             :         }
      59        4788 :         return length;
      60             : 
      61             :     }
      62             :     /**
      63             :     Returns the indexth item in the collection.
      64             :     */
      65       16786 :     Reference< XNode > SAL_CALL CChildList::item(sal_Int32 index)
      66             :         throw (RuntimeException, std::exception)
      67             :     {
      68       16786 :         ::osl::MutexGuard const g(m_rMutex);
      69             : 
      70       16786 :         if (m_pNode != NULL)
      71             :         {
      72       16786 :             xmlNodePtr cur = m_pNode->GetNodePtr();
      73       16786 :             if (0 != cur) {
      74       16786 :                 cur = cur->children;
      75             :             }
      76       61966 :             while (cur != NULL)
      77             :             {
      78       45178 :                 if (index-- == 0) {
      79             :                     return Reference< XNode >(
      80       16784 :                             m_pNode->GetOwnerDocument().GetCNode(cur).get());
      81             :                 }
      82       28394 :                 cur = cur->next;
      83             :             }
      84             :         }
      85           2 :         return 0;
      86             :     }
      87             : }
      88             : 
      89             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10