LCOV - code coverage report
Current view: top level - unoxml/source/xpath - xpathobject.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 48 0.0 %
Date: 2014-04-14 Functions: 0 12 0.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 <xpathobject.hxx>
      21             : 
      22             : #include <string.h>
      23             : 
      24             : #include "../dom/document.hxx"
      25             : #include <nodelist.hxx>
      26             : 
      27             : 
      28             : namespace XPath
      29             : {
      30           0 :     static XPathObjectType lcl_GetType(xmlXPathObjectPtr const pXPathObj)
      31             :     {
      32           0 :         switch (pXPathObj->type)
      33             :         {
      34             :             case XPATH_UNDEFINED:
      35           0 :                 return XPathObjectType_XPATH_UNDEFINED;
      36             :             case XPATH_NODESET:
      37           0 :                 return XPathObjectType_XPATH_NODESET;
      38             :             case XPATH_BOOLEAN:
      39           0 :                 return XPathObjectType_XPATH_BOOLEAN;
      40             :             case XPATH_NUMBER:
      41           0 :                 return XPathObjectType_XPATH_NUMBER;
      42             :             case XPATH_STRING:
      43           0 :                 return XPathObjectType_XPATH_STRING;
      44             :             case XPATH_POINT:
      45           0 :                 return XPathObjectType_XPATH_POINT;
      46             :             case XPATH_RANGE:
      47           0 :                 return XPathObjectType_XPATH_RANGE;
      48             :             case XPATH_LOCATIONSET:
      49           0 :                 return XPathObjectType_XPATH_LOCATIONSET;
      50             :             case XPATH_USERS:
      51           0 :                 return XPathObjectType_XPATH_USERS;
      52             :             case XPATH_XSLT_TREE:
      53           0 :                 return XPathObjectType_XPATH_XSLT_TREE;
      54             :             default:
      55           0 :                 return XPathObjectType_XPATH_UNDEFINED;
      56             :         }
      57             :     }
      58             : 
      59           0 :     CXPathObject::CXPathObject(
      60             :             ::rtl::Reference<DOM::CDocument> const& pDocument,
      61             :             ::osl::Mutex & rMutex,
      62             :             ::boost::shared_ptr<xmlXPathObject> const& pXPathObj)
      63             :         : m_pDocument(pDocument)
      64             :         , m_rMutex(rMutex)
      65             :         , m_pXPathObj(pXPathObj)
      66           0 :         , m_XPathObjectType(lcl_GetType(pXPathObj.get()))
      67             :     {
      68           0 :     }
      69             : 
      70             :     /**
      71             :         get object type
      72             :     */
      73           0 :     XPathObjectType CXPathObject::getObjectType() throw (RuntimeException, std::exception)
      74             :     {
      75           0 :         return m_XPathObjectType;
      76             :     }
      77             : 
      78             :     /**
      79             :         get the nodes from a nodelist type object
      80             :     */
      81             :     Reference< XNodeList > SAL_CALL
      82           0 :     CXPathObject::getNodeList() throw (RuntimeException, std::exception)
      83             :     {
      84           0 :         ::osl::MutexGuard const g(m_rMutex);
      85             : 
      86             :         Reference< XNodeList > const xRet(
      87           0 :             new CNodeList(m_pDocument, m_rMutex, m_pXPathObj));
      88           0 :         return xRet;
      89             :     }
      90             : 
      91             :      /**
      92             :         get value of a boolean object
      93             :      */
      94           0 :     sal_Bool SAL_CALL CXPathObject::getBoolean() throw (RuntimeException, std::exception)
      95             :     {
      96           0 :         ::osl::MutexGuard const g(m_rMutex);
      97             : 
      98           0 :         return (sal_Bool) xmlXPathCastToBoolean(m_pXPathObj.get());
      99             :     }
     100             : 
     101             :     /**
     102             :         get number as byte
     103             :     */
     104           0 :     sal_Int8 SAL_CALL CXPathObject::getByte() throw (RuntimeException, std::exception)
     105             :     {
     106           0 :         ::osl::MutexGuard const g(m_rMutex);
     107             : 
     108           0 :         return (sal_Int8) xmlXPathCastToNumber(m_pXPathObj.get());
     109             :     }
     110             : 
     111             :     /**
     112             :         get number as short
     113             :     */
     114           0 :     sal_Int16 SAL_CALL CXPathObject::getShort() throw (RuntimeException, std::exception)
     115             :     {
     116           0 :         ::osl::MutexGuard const g(m_rMutex);
     117             : 
     118           0 :         return (sal_Int16) xmlXPathCastToNumber(m_pXPathObj.get());
     119             :     }
     120             : 
     121             :     /**
     122             :         get number as long
     123             :     */
     124           0 :     sal_Int32 SAL_CALL CXPathObject::getLong() throw (RuntimeException, std::exception)
     125             :     {
     126           0 :         ::osl::MutexGuard const g(m_rMutex);
     127             : 
     128           0 :         return (sal_Int32) xmlXPathCastToNumber(m_pXPathObj.get());
     129             :     }
     130             : 
     131             :     /**
     132             :         get number as hyper
     133             :     */
     134           0 :     sal_Int64 SAL_CALL CXPathObject::getHyper() throw (RuntimeException, std::exception)
     135             :     {
     136           0 :         ::osl::MutexGuard const g(m_rMutex);
     137             : 
     138           0 :         return (sal_Int64) xmlXPathCastToNumber(m_pXPathObj.get());
     139             :     }
     140             : 
     141             :     /**
     142             :         get number as float
     143             :     */
     144           0 :     float SAL_CALL CXPathObject::getFloat() throw (RuntimeException, std::exception)
     145             :     {
     146           0 :         ::osl::MutexGuard const g(m_rMutex);
     147             : 
     148           0 :         return (float) xmlXPathCastToNumber(m_pXPathObj.get());
     149             :     }
     150             : 
     151             :     /**
     152             :         get number as double
     153             :     */
     154           0 :     double SAL_CALL CXPathObject::getDouble() throw (RuntimeException, std::exception)
     155             :     {
     156           0 :         ::osl::MutexGuard const g(m_rMutex);
     157             : 
     158           0 :         return  xmlXPathCastToNumber(m_pXPathObj.get());
     159             :     }
     160             : 
     161             :     /**
     162             :         get string value
     163             :     */
     164           0 :     OUString SAL_CALL CXPathObject::getString() throw (RuntimeException, std::exception)
     165             :     {
     166           0 :         ::osl::MutexGuard const g(m_rMutex);
     167             : 
     168             :         ::boost::shared_ptr<xmlChar const> str(
     169           0 :             xmlXPathCastToString(m_pXPathObj.get()), xmlFree);
     170           0 :         sal_Char const*const pS(reinterpret_cast<sal_Char const*>(str.get()));
     171           0 :         return OUString(pS, strlen(pS), RTL_TEXTENCODING_UTF8);
     172             :     }
     173             : 
     174             : }
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10