2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-12 21:00:32 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2009-05-15 14:06:56 +02:00
|
|
|
|
2014-05-28 15:24:46 +02:00
|
|
|
#include <sal/config.h>
|
2009-05-15 14:06:56 +02:00
|
|
|
|
2011-11-29 11:54:46 +01:00
|
|
|
#include <cassert>
|
|
|
|
|
2014-05-28 15:24:46 +02:00
|
|
|
#include <com/sun/star/beans/Optional.hpp>
|
|
|
|
#include <com/sun/star/uno/Any.hxx>
|
2014-11-17 22:45:11 +01:00
|
|
|
#include <osl/mutex.hxx>
|
2014-05-28 15:24:46 +02:00
|
|
|
#include <rtl/ref.hxx>
|
|
|
|
#include <rtl/ustring.h>
|
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
#include <sal/log.hxx>
|
2009-05-15 14:06:56 +02:00
|
|
|
|
2009-10-01 16:48:00 +02:00
|
|
|
#include "components.hxx"
|
2009-05-15 14:06:56 +02:00
|
|
|
#include "node.hxx"
|
|
|
|
#include "propertynode.hxx"
|
|
|
|
#include "type.hxx"
|
|
|
|
|
|
|
|
namespace configmgr {
|
|
|
|
|
|
|
|
PropertyNode::PropertyNode(
|
2009-11-11 13:51:17 +01:00
|
|
|
int layer, Type staticType, bool nillable, css::uno::Any const & value,
|
2009-07-22 14:41:57 +02:00
|
|
|
bool extension):
|
2010-10-15 15:12:13 +01:00
|
|
|
Node(layer), staticType_(staticType), nillable_(nillable),
|
|
|
|
extension_(extension), value_(value)
|
2009-05-15 14:06:56 +02:00
|
|
|
{}
|
|
|
|
|
2010-05-11 09:29:37 +02:00
|
|
|
rtl::Reference< Node > PropertyNode::clone(bool) const {
|
2009-07-29 15:30:40 +02:00
|
|
|
return new PropertyNode(*this);
|
2009-05-15 14:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-10-02 15:12:00 +02:00
|
|
|
css::uno::Any PropertyNode::getValue(Components & components) {
|
2011-12-14 10:59:15 -02:00
|
|
|
if (!externalDescriptor_.isEmpty()) {
|
2009-10-01 16:48:00 +02:00
|
|
|
css::beans::Optional< css::uno::Any > val(
|
|
|
|
components.getExternalValue(externalDescriptor_));
|
|
|
|
if (val.IsPresent) {
|
|
|
|
value_ = val.Value; //TODO: check value type
|
|
|
|
}
|
2014-12-16 17:27:07 +01:00
|
|
|
externalDescriptor_.clear(); // must not throw
|
2009-10-01 16:48:00 +02:00
|
|
|
}
|
2012-01-30 12:19:11 +01:00
|
|
|
SAL_WARN_IF(
|
|
|
|
!(value_.hasValue() || nillable_), "configmgr",
|
|
|
|
"non-nillable property without value");
|
2009-05-15 14:06:56 +02:00
|
|
|
return value_;
|
|
|
|
}
|
|
|
|
|
2009-07-23 12:42:37 +02:00
|
|
|
void PropertyNode::setValue(int layer, css::uno::Any const & value) {
|
2009-09-16 17:01:38 +02:00
|
|
|
setLayer(layer);
|
2009-05-15 14:06:56 +02:00
|
|
|
value_ = value;
|
2014-12-16 17:27:07 +01:00
|
|
|
externalDescriptor_.clear();
|
2009-10-01 16:48:00 +02:00
|
|
|
}
|
|
|
|
|
2014-06-26 13:47:54 +01:00
|
|
|
com::sun::star::uno::Any *PropertyNode::getValuePtr(int layer)
|
|
|
|
{
|
|
|
|
setLayer(layer);
|
2014-12-16 17:27:07 +01:00
|
|
|
externalDescriptor_.clear();
|
2014-06-26 13:47:54 +01:00
|
|
|
return &value_;
|
|
|
|
}
|
|
|
|
|
2012-12-10 23:06:10 +02:00
|
|
|
void PropertyNode::setExternal(int layer, OUString const & descriptor) {
|
2011-11-29 11:54:46 +01:00
|
|
|
assert(!descriptor.isEmpty());
|
2009-10-01 16:48:00 +02:00
|
|
|
setLayer(layer);
|
|
|
|
externalDescriptor_ = descriptor;
|
2009-05-15 14:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-29 15:30:40 +02:00
|
|
|
PropertyNode::PropertyNode(PropertyNode const & other):
|
2009-11-11 13:51:17 +01:00
|
|
|
Node(other), staticType_(other.staticType_), nillable_(other.nillable_),
|
2010-10-15 15:12:13 +01:00
|
|
|
extension_(other.extension_), externalDescriptor_(other.externalDescriptor_),
|
|
|
|
value_(other.value_)
|
2009-07-29 15:30:40 +02:00
|
|
|
{}
|
|
|
|
|
2009-05-19 10:49:37 +02:00
|
|
|
PropertyNode::~PropertyNode() {}
|
|
|
|
|
2009-09-04 11:24:45 +02:00
|
|
|
Node::Kind PropertyNode::kind() const {
|
|
|
|
return KIND_PROPERTY;
|
|
|
|
}
|
|
|
|
|
2009-05-15 14:06:56 +02:00
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|