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

Generated by: LCOV version 1.10