/src/libreoffice/svx/source/items/chrtitem.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 <rtl/math.hxx> |
21 | | #include <unotools/intlwrapper.hxx> |
22 | | #include <unotools/localedatawrapper.hxx> |
23 | | #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp> |
24 | | #include <o3tl/hash_combine.hxx> |
25 | | |
26 | | #include <svx/ChartColorPaletteType.hxx> |
27 | | #include <svx/chrtitem.hxx> |
28 | | #include <svx/unomid.hxx> |
29 | | |
30 | | using namespace ::com::sun::star; |
31 | | |
32 | | |
33 | 0 | SfxPoolItem* SvxDoubleItem::CreateDefault() { return new SvxDoubleItem(0.0, TypedWhichId<SvxDoubleItem>(0));} |
34 | | |
35 | | SvxChartTextOrderItem::SvxChartTextOrderItem(SvxChartTextOrder eOrder, |
36 | | TypedWhichId<SvxChartTextOrderItem> nId) : |
37 | 0 | SfxEnumItem(nId, eOrder) |
38 | 0 | { |
39 | 0 | } |
40 | | |
41 | | SvxChartTextOrderItem* SvxChartTextOrderItem::Clone(SfxItemPool* /*pPool*/) const |
42 | 0 | { |
43 | 0 | return new SvxChartTextOrderItem(*this); |
44 | 0 | } |
45 | | |
46 | | bool SvxChartTextOrderItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const |
47 | 0 | { |
48 | | // the order of the two enums is not equal, so a mapping is required |
49 | 0 | css::chart::ChartAxisArrangeOrderType eAO; |
50 | 0 | SvxChartTextOrder eOrder( GetValue()); |
51 | |
|
52 | 0 | switch( eOrder ) |
53 | 0 | { |
54 | 0 | case SvxChartTextOrder::SideBySide: |
55 | 0 | eAO = css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE; break; |
56 | 0 | case SvxChartTextOrder::UpDown: |
57 | 0 | eAO = css::chart::ChartAxisArrangeOrderType_STAGGER_ODD; break; |
58 | 0 | case SvxChartTextOrder::DownUp: |
59 | 0 | eAO = css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN; break; |
60 | 0 | case SvxChartTextOrder::Auto: |
61 | 0 | eAO = css::chart::ChartAxisArrangeOrderType_AUTO; break; |
62 | 0 | } |
63 | | |
64 | 0 | rVal <<= eAO; |
65 | |
|
66 | 0 | return true; |
67 | 0 | } |
68 | | |
69 | | |
70 | | bool SvxChartTextOrderItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) |
71 | 0 | { |
72 | | // the order of the two enums is not equal, so a mapping is required |
73 | 0 | css::chart::ChartAxisArrangeOrderType eAO; |
74 | 0 | SvxChartTextOrder eOrder; |
75 | |
|
76 | 0 | if(!(rVal >>= eAO)) |
77 | 0 | { |
78 | | // also try an int (for Basic) |
79 | 0 | sal_Int32 nAO = 0; |
80 | 0 | if(!(rVal >>= nAO)) |
81 | 0 | return false; |
82 | 0 | eAO = static_cast< css::chart::ChartAxisArrangeOrderType >( nAO ); |
83 | 0 | } |
84 | | |
85 | 0 | switch( eAO ) |
86 | 0 | { |
87 | 0 | case css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE: |
88 | 0 | eOrder = SvxChartTextOrder::SideBySide; break; |
89 | 0 | case css::chart::ChartAxisArrangeOrderType_STAGGER_ODD: |
90 | 0 | eOrder = SvxChartTextOrder::UpDown; break; |
91 | 0 | case css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN: |
92 | 0 | eOrder = SvxChartTextOrder::DownUp; break; |
93 | 0 | case css::chart::ChartAxisArrangeOrderType_AUTO: |
94 | 0 | eOrder = SvxChartTextOrder::Auto; break; |
95 | 0 | default: |
96 | 0 | return false; |
97 | 0 | } |
98 | | |
99 | 0 | SetValue( eOrder ); |
100 | |
|
101 | 0 | return true; |
102 | 0 | } |
103 | | |
104 | | SvxDoubleItem::SvxDoubleItem(double fValue, TypedWhichId<SvxDoubleItem> nId) : |
105 | 0 | SfxPoolItem(nId), |
106 | 0 | m_fVal(fValue) |
107 | 0 | { |
108 | 0 | } |
109 | | |
110 | | SvxDoubleItem::SvxDoubleItem(const SvxDoubleItem& rItem) : |
111 | 0 | SfxPoolItem(rItem), |
112 | 0 | m_fVal(rItem.m_fVal) |
113 | 0 | { |
114 | 0 | } |
115 | | |
116 | | bool SvxDoubleItem::GetPresentation |
117 | | ( SfxItemPresentation /*ePresentation*/, MapUnit /*eCoreMetric*/, |
118 | | MapUnit /*ePresentationMetric*/, OUString& rText, |
119 | | const IntlWrapper& rIntlWrapper) const |
120 | 0 | { |
121 | 0 | rText = ::rtl::math::doubleToUString( m_fVal, rtl_math_StringFormat_E, 4, |
122 | 0 | rIntlWrapper.getLocaleData()->getNumDecimalSep()[0], true ); |
123 | 0 | return true; |
124 | 0 | } |
125 | | |
126 | | bool SvxDoubleItem::operator == (const SfxPoolItem& rItem) const |
127 | 0 | { |
128 | 0 | assert(SfxPoolItem::operator==(rItem)); |
129 | 0 | return static_cast<const SvxDoubleItem&>(rItem).m_fVal == m_fVal; |
130 | 0 | } |
131 | | |
132 | | SvxDoubleItem* SvxDoubleItem::Clone(SfxItemPool* /*pPool*/) const |
133 | 0 | { |
134 | 0 | return new SvxDoubleItem(*this); |
135 | 0 | } |
136 | | |
137 | | bool SvxDoubleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const |
138 | 0 | { |
139 | 0 | rVal <<= m_fVal; |
140 | 0 | return true; |
141 | 0 | } |
142 | | |
143 | | bool SvxDoubleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) |
144 | 0 | { |
145 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
146 | 0 | return rVal >>= m_fVal; |
147 | 0 | } |
148 | | |
149 | | SvxChartKindErrorItem::SvxChartKindErrorItem(SvxChartKindError eOrient, |
150 | | TypedWhichId<SvxChartKindErrorItem> nId) : |
151 | 0 | SfxEnumItem(nId, eOrient) |
152 | 0 | { |
153 | 0 | } |
154 | | |
155 | | SvxChartKindErrorItem* SvxChartKindErrorItem::Clone(SfxItemPool* /*pPool*/) const |
156 | 0 | { |
157 | 0 | return new SvxChartKindErrorItem(*this); |
158 | 0 | } |
159 | | |
160 | | SvxChartIndicateItem::SvxChartIndicateItem(SvxChartIndicate eOrient, |
161 | | TypedWhichId<SvxChartIndicateItem> nId) : |
162 | 0 | SfxEnumItem(nId, eOrient) |
163 | 0 | { |
164 | 0 | } |
165 | | |
166 | | SvxChartIndicateItem* SvxChartIndicateItem::Clone(SfxItemPool* /*pPool*/) const |
167 | 0 | { |
168 | 0 | return new SvxChartIndicateItem(*this); |
169 | 0 | } |
170 | | |
171 | | SvxChartRegressItem::SvxChartRegressItem(SvxChartRegress eOrient, |
172 | | TypedWhichId<SvxChartRegressItem> nId) : |
173 | 0 | SfxEnumItem(nId, eOrient) |
174 | 0 | { |
175 | 0 | } |
176 | | |
177 | | SvxChartRegressItem* SvxChartRegressItem::Clone(SfxItemPool* /*pPool*/) const |
178 | 0 | { |
179 | 0 | return new SvxChartRegressItem(*this); |
180 | 0 | } |
181 | | |
182 | | // SvxChartColorPaletteItem implementation |
183 | | |
184 | | SvxChartColorPaletteItem::SvxChartColorPaletteItem(const ChartColorPaletteType eType, |
185 | | const sal_uInt32 nIndex, |
186 | | const TypedWhichId<SvxChartColorPaletteItem> nId) |
187 | 0 | : SfxPoolItem(nId) |
188 | 0 | , meType(eType) |
189 | 0 | , mnIndex(nIndex) |
190 | 0 | { |
191 | 0 | } |
192 | | |
193 | | SvxChartColorPaletteItem::SvxChartColorPaletteItem(const SvxChartColorPaletteItem& rItem) |
194 | 0 | : SfxPoolItem(rItem) |
195 | 0 | , meType(rItem.meType) |
196 | 0 | , mnIndex(rItem.mnIndex) |
197 | 0 | { |
198 | 0 | } |
199 | | |
200 | | bool SvxChartColorPaletteItem::QueryValue(uno::Any& rVal, const sal_uInt8 nMemberId) const |
201 | 0 | { |
202 | 0 | if (nMemberId == MID_CHART_COLOR_PALETTE_TYPE) |
203 | 0 | { |
204 | 0 | rVal <<= static_cast<sal_uInt8>(meType); |
205 | 0 | return true; |
206 | 0 | } |
207 | 0 | if (nMemberId == MID_CHART_COLOR_PALETTE_INDEX) |
208 | 0 | { |
209 | 0 | rVal <<= mnIndex; |
210 | 0 | return true; |
211 | 0 | } |
212 | 0 | return false; |
213 | 0 | } |
214 | | |
215 | | bool SvxChartColorPaletteItem::PutValue(const uno::Any& rVal, const sal_uInt8 nMemberId) |
216 | 0 | { |
217 | 0 | if (nMemberId == MID_CHART_COLOR_PALETTE_TYPE) |
218 | 0 | { |
219 | 0 | sal_uInt8 nType = 0; |
220 | 0 | rVal >>= nType; |
221 | 0 | meType = static_cast<ChartColorPaletteType>(nType); |
222 | 0 | return true; |
223 | 0 | } |
224 | 0 | if (nMemberId == MID_CHART_COLOR_PALETTE_INDEX) |
225 | 0 | { |
226 | 0 | rVal >>= mnIndex; |
227 | 0 | return true; |
228 | 0 | } |
229 | 0 | return false; |
230 | 0 | } |
231 | | |
232 | | bool SvxChartColorPaletteItem::GetPresentation(SfxItemPresentation /*ePres*/, |
233 | | MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/, |
234 | | OUString& rText, const IntlWrapper&) const |
235 | 0 | { |
236 | 0 | if (meType == ChartColorPaletteType::Colorful) |
237 | 0 | rText = u"Colorful"_ustr; |
238 | 0 | else if (meType == ChartColorPaletteType::Monochromatic) |
239 | 0 | rText = u"Monochromatic"_ustr; |
240 | 0 | else |
241 | 0 | rText = u"Unknown"_ustr; |
242 | |
|
243 | 0 | rText += u" "_ustr; |
244 | 0 | rText += OUString::number(mnIndex); |
245 | |
|
246 | 0 | return true; |
247 | 0 | } |
248 | | |
249 | | bool SvxChartColorPaletteItem::operator==(const SfxPoolItem& rItem) const |
250 | 0 | { |
251 | 0 | assert(SfxPoolItem::operator==(rItem)); |
252 | 0 | const auto& rOther = static_cast<const SvxChartColorPaletteItem&>(rItem); |
253 | 0 | return (meType == rOther.meType && mnIndex == rOther.mnIndex); |
254 | 0 | } |
255 | | |
256 | | SvxChartColorPaletteItem* SvxChartColorPaletteItem::Clone(SfxItemPool* /*pPool*/) const |
257 | 0 | { |
258 | 0 | return new SvxChartColorPaletteItem(*this); |
259 | 0 | } |
260 | | |
261 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |