LCOV - code coverage report
Current view: top level - unoxml/source/dom - processinginstruction.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 43 48 89.6 %
Date: 2014-11-03 Functions: 8 8 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 <processinginstruction.hxx>
      21             : 
      22             : #include <string.h>
      23             : 
      24             : #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
      25             : 
      26             : using namespace css::uno;
      27             : using namespace css::xml::dom;
      28             : using namespace css::xml::sax;
      29             : 
      30             : namespace DOM
      31             : {
      32          32 :     CProcessingInstruction::CProcessingInstruction(
      33             :             CDocument const& rDocument, ::osl::Mutex const& rMutex,
      34             :             xmlNodePtr const pNode)
      35             :         : CProcessingInstruction_Base(rDocument, rMutex,
      36          32 :             NodeType_PROCESSING_INSTRUCTION_NODE, pNode)
      37             :     {
      38          32 :     }
      39             : 
      40          24 :     void CProcessingInstruction::saxify(
      41             :             const Reference< XDocumentHandler >& i_xHandler) {
      42          24 :         if (!i_xHandler.is()) throw RuntimeException();
      43          24 :         Reference< XExtendedDocumentHandler > xExtended(i_xHandler, UNO_QUERY);
      44          24 :         if (xExtended.is()) {
      45          24 :             xExtended->processingInstruction(getTarget(), getData());
      46          24 :         }
      47          24 :     }
      48             : 
      49             :     /**
      50             :     The content of this processing instruction.
      51             :     */
      52             :     OUString SAL_CALL
      53          32 :     CProcessingInstruction::getData() throw (RuntimeException, std::exception)
      54             :     {
      55          32 :         ::osl::MutexGuard const g(m_rMutex);
      56             : 
      57          32 :         if (0 == m_aNodePtr) {
      58           0 :             return OUString();
      59             :         }
      60             : 
      61             :         char const*const pContent(
      62          32 :                 reinterpret_cast<char const*>(m_aNodePtr->content));
      63          32 :         if (0 == pContent) {
      64          24 :             return OUString();
      65             :         }
      66          16 :         OUString const ret(pContent, strlen(pContent), RTL_TEXTENCODING_UTF8);
      67          40 :         return ret;
      68             :     }
      69             : 
      70             :     /**
      71             :     The target of this processing instruction.
      72             :     */
      73             :     OUString SAL_CALL
      74          26 :     CProcessingInstruction::getTarget() throw (RuntimeException, std::exception)
      75             :     {
      76          26 :         ::osl::MutexGuard const g(m_rMutex);
      77             : 
      78          26 :         if (0 == m_aNodePtr) {
      79           0 :             return OUString();
      80             :         }
      81             : 
      82             :         char const*const pName(
      83          26 :                 reinterpret_cast<char const*>(m_aNodePtr->name));
      84          26 :         if (0 == pName) {
      85           0 :             return OUString();
      86             :         }
      87          52 :         OUString const ret(pName, strlen(pName), RTL_TEXTENCODING_UTF8);
      88          52 :         return ret;
      89             :     }
      90             : 
      91             :     /**
      92             :     The content of this processing instruction.
      93             :     */
      94           4 :     void SAL_CALL CProcessingInstruction::setData(OUString const& rData)
      95             :         throw (RuntimeException, DOMException, std::exception)
      96             :     {
      97           4 :         ::osl::MutexGuard const g(m_rMutex);
      98             : 
      99           4 :         if (0 == m_aNodePtr) {
     100           0 :             throw RuntimeException();
     101             :         }
     102             : 
     103             :         OString const data(
     104           8 :                 OUStringToOString(rData, RTL_TEXTENCODING_UTF8));
     105             :         xmlChar const*const pData(
     106           4 :                 reinterpret_cast<xmlChar const*>(data.getStr()) );
     107           4 :         xmlFree(m_aNodePtr->content);
     108           8 :         m_aNodePtr->content = xmlStrdup(pData);
     109           4 :     }
     110             : 
     111             :     OUString SAL_CALL
     112           2 :     CProcessingInstruction::getNodeName() throw (RuntimeException, std::exception)
     113             :     {
     114           2 :         ::osl::MutexGuard const g(m_rMutex);
     115             : 
     116           2 :         if (0 == m_aNodePtr) {
     117           0 :             return OUString();
     118             :         }
     119             : 
     120             :         sal_Char const*const pName =
     121           2 :             reinterpret_cast<sal_Char const*>(m_aNodePtr->name);
     122           4 :         OUString const ret(pName, strlen(pName), RTL_TEXTENCODING_UTF8);
     123           4 :         return ret;
     124             :     }
     125             : 
     126           4 :     OUString SAL_CALL CProcessingInstruction::getNodeValue()
     127             :         throw (RuntimeException, std::exception)
     128             :     {
     129           4 :         return getData();
     130             :     }
     131             : 
     132             :     void SAL_CALL
     133           2 :     CProcessingInstruction::setNodeValue(OUString const& rNodeValue)
     134             :         throw (RuntimeException, DOMException, std::exception)
     135             :     {
     136           2 :         return setData(rNodeValue);
     137             :     }
     138             : }
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10