LCOV - code coverage report
Current view: top level - unoxml/source/dom - childlist.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 25 25 100.0 %
Date: 2015-06-13 12:38:46 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        4230 :     CChildList::CChildList(::rtl::Reference<CNode> const& pBase,
      33             :                 ::osl::Mutex & rMutex)
      34             :         : m_pNode(pBase)
      35        4230 :         , m_rMutex(rMutex)
      36             :     {
      37        4230 :     }
      38             : 
      39             :     /**
      40             :     The number of nodes in the list.
      41             :     */
      42        4234 :     sal_Int32 SAL_CALL CChildList::getLength() throw (RuntimeException, std::exception)
      43             :     {
      44        4234 :         ::osl::MutexGuard const g(m_rMutex);
      45             : 
      46        4234 :         sal_Int32 length = 0;
      47        4234 :         if (m_pNode != NULL)
      48             :         {
      49        4234 :             xmlNodePtr cur = m_pNode->GetNodePtr();
      50        4234 :             if (0 != cur) {
      51        4234 :                 cur = cur->children;
      52             :             }
      53       30793 :             while (cur != NULL)
      54             :             {
      55       22325 :                 length++;
      56       22325 :                 cur = cur->next;
      57             :             }
      58             :         }
      59        4234 :         return length;
      60             : 
      61             :     }
      62             :     /**
      63             :     Returns the indexth item in the collection.
      64             :     */
      65       14973 :     Reference< XNode > SAL_CALL CChildList::item(sal_Int32 index)
      66             :         throw (RuntimeException, std::exception)
      67             :     {
      68       14973 :         ::osl::MutexGuard const g(m_rMutex);
      69             : 
      70       14973 :         if (m_pNode != NULL)
      71             :         {
      72       14973 :             xmlNodePtr cur = m_pNode->GetNodePtr();
      73       14973 :             if (0 != cur) {
      74       14973 :                 cur = cur->children;
      75             :             }
      76       56073 :             while (cur != NULL)
      77             :             {
      78       41099 :                 if (index-- == 0) {
      79             :                     return Reference< XNode >(
      80       14972 :                             m_pNode->GetOwnerDocument().GetCNode(cur).get());
      81             :                 }
      82       26127 :                 cur = cur->next;
      83             :             }
      84             :         }
      85           1 :         return 0;
      86             :     }
      87             : }
      88             : 
      89             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11