LibreOffice Module chart2 (master) 1
WrappedNumberFormatProperty.cxx
Go to the documentation of this file.
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
22#include <Axis.hxx>
23#include <com/sun/star/chart2/XAxis.hpp>
24#include <com/sun/star/chart2/XDataSeries.hpp>
25#include <unonames.hxx>
26#include <utility>
27#include <osl/diagnose.h>
28
29using namespace ::com::sun::star;
30using ::com::sun::star::uno::Reference;
31using ::com::sun::star::uno::Any;
32
33namespace chart::wrapper
34{
35
36WrappedNumberFormatProperty::WrappedNumberFormatProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact)
38 , m_spChart2ModelContact(std::move(spChart2ModelContact))
39{
40}
41
43{
44}
45
46void WrappedNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
47{
48 sal_Int32 nFormat = 0;
49 if( ! (rOuterValue >>= nFormat) )
50 throw lang::IllegalArgumentException( "Property 'NumberFormat' requires value of type sal_Int32", nullptr, 0 );
51
52 if(xInnerPropertySet.is())
53 xInnerPropertySet->setPropertyValue(getInnerName(), convertOuterToInnerValue(rOuterValue));
54}
55
57{
58 if( !xInnerPropertySet.is() )
59 {
60 OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
61 return Any();
62 }
63 Any aRet( xInnerPropertySet->getPropertyValue(getInnerName()));
64 if( !aRet.hasValue() )
65 {
66 sal_Int32 nKey = 0;
67 Reference< chart2::XDataSeries > xSeries( xInnerPropertySet, uno::UNO_QUERY );
68 if( xSeries.is() )
70 else
71 {
72 rtl::Reference< Axis > xAxis = dynamic_cast<Axis*>(xInnerPropertySet.get());
73 assert(xAxis || !xInnerPropertySet);
74 nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForAxis( xAxis );
75 }
76 aRet <<= nKey;
77 }
78 return aRet;
79}
80
82{
83 return uno::Any( sal_Int32( 0 ) );
84}
85
88{
89}
90
92{
93}
94
95void WrappedLinkNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
96{
97 if( !xInnerPropertySet.is() )
98 {
99 OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::setPropertyValue");
100 return;
101 }
102
103 xInnerPropertySet->setPropertyValue(getInnerName(), rOuterValue);
104}
105
107{
108 if( !xInnerPropertySet.is() )
109 {
110 OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
111 return getPropertyDefault(nullptr);
112 }
113
114 return xInnerPropertySet->getPropertyValue(getInnerName());
115}
116
118{
119 return uno::Any( true ); // bLink
120}
121
122} //namespace chart::wrapper
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
virtual css::uno::Any convertOuterToInnerValue(const css::uno::Any &rOuterValue) const
virtual OUString getInnerName() const
static sal_Int32 getExplicitNumberFormatKeyForSeries(const css::uno::Reference< css::chart2::XDataSeries > &xSeries)
virtual css::uno::Any getPropertyDefault(const css::uno::Reference< css::beans::XPropertyState > &xInnerPropertyState) const override
virtual css::uno::Any getPropertyValue(const css::uno::Reference< css::beans::XPropertySet > &xInnerPropertySet) const override
virtual void setPropertyValue(const css::uno::Any &rOuterValue, const css::uno::Reference< css::beans::XPropertySet > &xInnerPropertySet) const override
virtual void setPropertyValue(const css::uno::Any &rOuterValue, const css::uno::Reference< css::beans::XPropertySet > &xInnerPropertySet) const override
virtual css::uno::Any getPropertyValue(const css::uno::Reference< css::beans::XPropertySet > &xInnerPropertySet) const override
virtual css::uno::Any getPropertyDefault(const css::uno::Reference< css::beans::XPropertyState > &xInnerPropertyState) const override
WrappedNumberFormatProperty(std::shared_ptr< Chart2ModelContact > spChart2ModelContact)
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
constexpr OUStringLiteral CHART_UNONAME_LINK_TO_SRC_NUMFMT
Definition: unonames.hxx:21
constexpr OUStringLiteral CHART_UNONAME_NUMFMT
Definition: unonames.hxx:20