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

Generated by: LCOV version 1.11