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