LCOV - code coverage report
Current view: top level - configmgr/source - propertynode.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 31 31 100.0 %
Date: 2014-11-03 Functions: 10 10 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 <sal/config.h>
      21             : 
      22             : #include <cassert>
      23             : 
      24             : #include <com/sun/star/beans/Optional.hpp>
      25             : #include <com/sun/star/uno/Any.hxx>
      26             : #include <rtl/ref.hxx>
      27             : #include <rtl/ustring.h>
      28             : #include <rtl/ustring.hxx>
      29             : #include <sal/log.hxx>
      30             : 
      31             : #include "components.hxx"
      32             : #include "node.hxx"
      33             : #include "propertynode.hxx"
      34             : #include "type.hxx"
      35             : 
      36             : namespace configmgr {
      37             : 
      38      954198 : PropertyNode::PropertyNode(
      39             :     int layer, Type staticType, bool nillable, css::uno::Any const & value,
      40             :     bool extension):
      41             :     Node(layer), staticType_(staticType), nillable_(nillable),
      42      954198 :     extension_(extension), value_(value)
      43      954198 : {}
      44             : 
      45     9516252 : rtl::Reference< Node > PropertyNode::clone(bool) const {
      46     9516252 :     return new PropertyNode(*this);
      47             : }
      48             : 
      49             : 
      50             : 
      51     4304631 : css::uno::Any PropertyNode::getValue(Components & components) {
      52     4304631 :     if (!externalDescriptor_.isEmpty()) {
      53             :         css::beans::Optional< css::uno::Any > val(
      54        1722 :             components.getExternalValue(externalDescriptor_));
      55        1722 :         if (val.IsPresent) {
      56         480 :             value_ = val.Value; //TODO: check value type
      57             :         }
      58        1722 :         externalDescriptor_ = ""; // must not throw
      59             :     }
      60             :     SAL_WARN_IF(
      61             :         !(value_.hasValue() || nillable_), "configmgr",
      62             :         "non-nillable property without value");
      63     4304631 :     return value_;
      64             : }
      65             : 
      66      206111 : void PropertyNode::setValue(int layer, css::uno::Any const & value) {
      67      206111 :     setLayer(layer);
      68      206111 :     value_ = value;
      69      206111 :     externalDescriptor_ = "";
      70      206111 : }
      71             : 
      72     5026883 : com::sun::star::uno::Any *PropertyNode::getValuePtr(int layer)
      73             : {
      74     5026883 :     setLayer(layer);
      75     5026883 :     externalDescriptor_ = "";
      76     5026883 :     return &value_;
      77             : }
      78             : 
      79        7239 : void PropertyNode::setExternal(int layer, OUString const & descriptor) {
      80             :     assert(!descriptor.isEmpty());
      81        7239 :     setLayer(layer);
      82        7239 :     externalDescriptor_ = descriptor;
      83        7239 : }
      84             : 
      85             : 
      86     9516252 : PropertyNode::PropertyNode(PropertyNode const & other):
      87             :     Node(other), staticType_(other.staticType_), nillable_(other.nillable_),
      88             :     extension_(other.extension_), externalDescriptor_(other.externalDescriptor_),
      89     9516252 :     value_(other.value_)
      90     9516252 : {}
      91             : 
      92    20791456 : PropertyNode::~PropertyNode() {}
      93             : 
      94    21576720 : Node::Kind PropertyNode::kind() const {
      95    21576720 :     return KIND_PROPERTY;
      96             : }
      97             : 
      98             : }
      99             : 
     100             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10