LCOV - code coverage report
Current view: top level - unoxml/source/xpath - nodelist.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 19 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 23 38 60.5 %

           Branch data     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 <nodelist.hxx>
      21                 :            : 
      22                 :            : #include "../dom/document.hxx"
      23                 :            : 
      24                 :            : namespace XPath
      25                 :            : {
      26                 :      95132 :     CNodeList::CNodeList(
      27                 :            :                 ::rtl::Reference<DOM::CDocument> const& pDocument,
      28                 :            :                 ::osl::Mutex & rMutex,
      29                 :            :                 boost::shared_ptr<xmlXPathObject> const& rxpathObj)
      30                 :            :         : m_pDocument(pDocument)
      31                 :            :         , m_rMutex(rMutex)
      32         [ +  - ]:      95132 :         , m_pNodeSet(0)
      33                 :            :     {
      34 [ +  - ][ +  - ]:      95132 :         if (rxpathObj != NULL && rxpathObj->type == XPATH_NODESET)
                 [ +  - ]
      35                 :            :         {
      36                 :      95132 :             m_pNodeSet = rxpathObj->nodesetval;
      37         [ +  - ]:      95132 :             m_pXPathObj = rxpathObj;
      38                 :            :         }
      39                 :      95132 :     }
      40                 :            : 
      41                 :            :     /**
      42                 :            :     The number of nodes in the list.
      43                 :            :     */
      44                 :       7548 :     sal_Int32 SAL_CALL CNodeList::getLength() throw (RuntimeException)
      45                 :            :     {
      46         [ +  - ]:       7548 :         ::osl::MutexGuard const g(m_rMutex);
      47                 :            : 
      48                 :       7548 :         sal_Int32 value = 0;
      49         [ +  + ]:       7548 :         if (m_pNodeSet != NULL)
      50         [ +  - ]:       6910 :             value = xmlXPathNodeSetGetLength(m_pNodeSet);
      51         [ +  - ]:       7548 :         return value;
      52                 :            :     }
      53                 :            : 
      54                 :            :     /**
      55                 :            :     Returns the indexth item in the collection.
      56                 :            :     */
      57                 :      89194 :     Reference< XNode > SAL_CALL CNodeList::item(sal_Int32 index)
      58                 :            :         throw (RuntimeException)
      59                 :            :     {
      60         [ +  - ]:      89194 :         ::osl::MutexGuard const g(m_rMutex);
      61                 :            : 
      62         [ +  + ]:      89194 :         if (0 == m_pNodeSet) {
      63         [ +  - ]:        992 :             return 0;
      64                 :            :         }
      65 [ +  - ][ +  - ]:      88202 :         xmlNodePtr const pNode = xmlXPathNodeSetItem(m_pNodeSet, index);
                 [ +  + ]
      66 [ +  - ][ +  + ]:      88202 :         Reference< XNode > const xNode(m_pDocument->GetCNode(pNode).get());
                 [ +  - ]
      67         [ +  - ]:      89194 :         return xNode;
      68                 :            :     }
      69                 :            : }
      70                 :            : 
      71                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10