LCOV - code coverage report
Current view: top level - unoxml/source/rdf - CBlankNode.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 31 71.0 %
Date: 2015-06-13 12:38:46 Functions: 8 11 72.7 %
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 "CNodes.hxx"
      21             : 
      22             : #include <boost/noncopyable.hpp>
      23             : #include <cppuhelper/implbase3.hxx>
      24             : #include <cppuhelper/supportsservice.hxx>
      25             : #include <com/sun/star/lang/XServiceInfo.hpp>
      26             : #include <com/sun/star/lang/XInitialization.hpp>
      27             : #include <com/sun/star/rdf/XBlankNode.hpp>
      28             : 
      29             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      30             : 
      31             : 
      32             : /// anonymous implementation namespace
      33             : namespace {
      34             : 
      35             : class CBlankNode:
      36             :     public ::cppu::WeakImplHelper3<
      37             :         css::lang::XServiceInfo,
      38             :         css::lang::XInitialization,
      39             :         css::rdf::XBlankNode>,
      40             :     private boost::noncopyable
      41             : {
      42             : public:
      43             :     explicit CBlankNode(css::uno::Reference< css::uno::XComponentContext > const & context);
      44          66 :     virtual ~CBlankNode() {}
      45             : 
      46             :     // css::lang::XServiceInfo:
      47             :     virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      48             :     virtual sal_Bool SAL_CALL supportsService(const OUString & ServiceName) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      49             :     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      50             : 
      51             :     // css::lang::XInitialization:
      52             :     virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception, std::exception) SAL_OVERRIDE;
      53             : 
      54             :     // css::rdf::XNode:
      55             :     virtual OUString SAL_CALL getStringValue() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      56             : 
      57             : private:
      58             :     css::uno::Reference< css::uno::XComponentContext > m_xContext;
      59             : 
      60             :     OUString m_NodeID;
      61             : };
      62             : 
      63          33 : CBlankNode::CBlankNode(css::uno::Reference< css::uno::XComponentContext > const & context) :
      64          33 :     m_xContext(context), m_NodeID()
      65          33 : {}
      66             : 
      67             : // com.sun.star.uno.XServiceInfo:
      68           0 : OUString SAL_CALL CBlankNode::getImplementationName() throw (css::uno::RuntimeException, std::exception)
      69             : {
      70           0 :     return comp_CBlankNode::_getImplementationName();
      71             : }
      72             : 
      73           0 : sal_Bool SAL_CALL CBlankNode::supportsService(OUString const & serviceName) throw (css::uno::RuntimeException, std::exception)
      74             : {
      75           0 :     return cppu::supportsService(this, serviceName);
      76             : }
      77             : 
      78           0 : css::uno::Sequence< OUString > SAL_CALL CBlankNode::getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception)
      79             : {
      80           0 :     return comp_CBlankNode::_getSupportedServiceNames();
      81             : }
      82             : 
      83             : // css::lang::XInitialization:
      84          33 : void SAL_CALL CBlankNode::initialize(const css::uno::Sequence< css::uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception, std::exception)
      85             : {
      86          33 :     if (aArguments.getLength() != 1) {
      87             :         throw css::lang::IllegalArgumentException(
      88             :             OUString("CBlankNode::initialize: "
      89           0 :                 "must give exactly 1 argument"), *this, 1);
      90             :     }
      91             : 
      92          33 :     OUString arg;
      93          33 :     if (!(aArguments[0] >>= arg)) {
      94             :         throw css::lang::IllegalArgumentException(
      95             :             OUString("CBlankNode::initialize: "
      96           0 :                 "argument must be string"), *this, 0);
      97             :     }
      98             : 
      99             :     //FIXME: what is legal?
     100          33 :     if (!arg.isEmpty()) {
     101          33 :         m_NodeID = arg;
     102             :     } else {
     103             :         throw css::lang::IllegalArgumentException(
     104             :             OUString("CBlankNode::initialize: "
     105           0 :                 "argument is not valid blank node ID"), *this, 0);
     106          33 :     }
     107          33 : }
     108             : 
     109             : // css::rdf::XNode:
     110          44 : OUString SAL_CALL CBlankNode::getStringValue() throw (css::uno::RuntimeException, std::exception)
     111             : {
     112          44 :     return m_NodeID;
     113             : }
     114             : 
     115             : } // closing anonymous implementation namespace
     116             : 
     117             : 
     118             : 
     119             : // component helper namespace
     120             : namespace comp_CBlankNode {
     121             : 
     122          90 : OUString SAL_CALL _getImplementationName() {
     123          90 :     return OUString( "CBlankNode");
     124             : }
     125             : 
     126           2 : css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames()
     127             : {
     128           2 :     css::uno::Sequence< OUString > s(1);
     129           2 :     s[0] = "com.sun.star.rdf.BlankNode";
     130           2 :     return s;
     131             : }
     132             : 
     133          33 : css::uno::Reference< css::uno::XInterface > SAL_CALL _create(
     134             :     const css::uno::Reference< css::uno::XComponentContext > & context)
     135             : {
     136          33 :     return static_cast< ::cppu::OWeakObject * >(new CBlankNode(context));
     137             : }
     138             : 
     139             : } // closing component helper namespace
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11