/src/libreoffice/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.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 "WrappedSymbolProperties.hxx" |
21 | | #include "WrappedSeriesOrDiagramProperty.hxx" |
22 | | #include <FastPropertyIdRanges.hxx> |
23 | | #include <ChartType.hxx> |
24 | | #include <com/sun/star/chart2/Symbol.hpp> |
25 | | #include <com/sun/star/chart2/SymbolStyle.hpp> |
26 | | #include <com/sun/star/awt/Size.hpp> |
27 | | #include <com/sun/star/beans/PropertyAttribute.hpp> |
28 | | #include <com/sun/star/beans/XPropertyState.hpp> |
29 | | #include <com/sun/star/chart/ChartSymbolType.hpp> |
30 | | #include <com/sun/star/drawing/LineStyle.hpp> |
31 | | #include <vcl/GraphicLoader.hxx> |
32 | | |
33 | | #include <vcl/graph.hxx> |
34 | | #include <comphelper/diagnose_ex.hxx> |
35 | | |
36 | | using namespace ::com::sun::star; |
37 | | using ::com::sun::star::uno::Any; |
38 | | using ::com::sun::star::uno::Reference; |
39 | | using ::com::sun::star::beans::Property; |
40 | | |
41 | | namespace chart::wrapper |
42 | | { |
43 | | |
44 | | namespace |
45 | | { |
46 | | |
47 | | class WrappedSymbolTypeProperty : public WrappedSeriesOrDiagramProperty< sal_Int32 > |
48 | | { |
49 | | public: |
50 | | virtual sal_Int32 getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override; |
51 | | virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& aNewValue ) const override; |
52 | | |
53 | | virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; |
54 | | virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override; |
55 | | |
56 | | explicit WrappedSymbolTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
57 | | tSeriesOrDiagramPropertyType ePropertyType); |
58 | | }; |
59 | | |
60 | | class WrappedSymbolBitmapURLProperty : public WrappedSeriesOrDiagramProperty<OUString> |
61 | | { |
62 | | public: |
63 | | virtual OUString getValueFromSeries(const Reference<beans::XPropertySet>& xSeriesPropertySet) const override; |
64 | | virtual void setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet, OUString const & xNewGraphicURL) const override; |
65 | | |
66 | | explicit WrappedSymbolBitmapURLProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
67 | | tSeriesOrDiagramPropertyType ePropertyType); |
68 | | }; |
69 | | |
70 | | class WrappedSymbolBitmapProperty : public WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>> |
71 | | { |
72 | | public: |
73 | | virtual uno::Reference<graphic::XGraphic> getValueFromSeries(const Reference<beans::XPropertySet>& xSeriesPropertySet) const override; |
74 | | virtual void setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet, uno::Reference<graphic::XGraphic> const & xNewGraphic) const override; |
75 | | |
76 | | explicit WrappedSymbolBitmapProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
77 | | tSeriesOrDiagramPropertyType ePropertyType); |
78 | | }; |
79 | | |
80 | | class WrappedSymbolSizeProperty : public WrappedSeriesOrDiagramProperty< awt::Size > |
81 | | { |
82 | | public: |
83 | | virtual awt::Size getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override; |
84 | | virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const awt::Size& aNewSize ) const override; |
85 | | virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override; |
86 | | |
87 | | explicit WrappedSymbolSizeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
88 | | tSeriesOrDiagramPropertyType ePropertyType); |
89 | | }; |
90 | | |
91 | | class WrappedSymbolAndLinesProperty : public WrappedSeriesOrDiagramProperty< bool > |
92 | | { |
93 | | public: |
94 | | virtual bool getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override; |
95 | | virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const bool& bDrawLines ) const override; |
96 | | virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override; |
97 | | |
98 | | explicit WrappedSymbolAndLinesProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
99 | | tSeriesOrDiagramPropertyType ePropertyType); |
100 | | }; |
101 | | |
102 | | enum |
103 | | { |
104 | | //symbol properties |
105 | | PROP_CHART_SYMBOL_TYPE = FAST_PROPERTY_ID_START_CHART_SYMBOL_PROP, |
106 | | PROP_CHART_SYMBOL_BITMAP_URL, |
107 | | PROP_CHART_SYMBOL_BITMAP, |
108 | | PROP_CHART_SYMBOL_SIZE, |
109 | | PROP_CHART_SYMBOL_AND_LINES |
110 | | }; |
111 | | |
112 | | sal_Int32 lcl_getSymbolType( const css::chart2::Symbol& rSymbol ) |
113 | 0 | { |
114 | 0 | sal_Int32 nSymbol = css::chart::ChartSymbolType::NONE; |
115 | 0 | switch( rSymbol.Style ) |
116 | 0 | { |
117 | 0 | case chart2::SymbolStyle_NONE: |
118 | 0 | break; |
119 | 0 | case chart2::SymbolStyle_AUTO: |
120 | 0 | case chart2::SymbolStyle_POLYGON://new feature |
121 | 0 | nSymbol = css::chart::ChartSymbolType::AUTO; |
122 | 0 | break; |
123 | 0 | case chart2::SymbolStyle_STANDARD: |
124 | 0 | nSymbol = rSymbol.StandardSymbol%15; |
125 | 0 | break; |
126 | 0 | case chart2::SymbolStyle_GRAPHIC: |
127 | 0 | nSymbol = css::chart::ChartSymbolType::BITMAPURL; |
128 | 0 | break; |
129 | 0 | default: |
130 | 0 | nSymbol = css::chart::ChartSymbolType::AUTO; |
131 | 0 | break; |
132 | 0 | } |
133 | 0 | return nSymbol; |
134 | 0 | } |
135 | | void lcl_setSymbolTypeToSymbol( sal_Int32 nSymbolType, chart2::Symbol& rSymbol ) |
136 | 0 | { |
137 | 0 | switch( nSymbolType ) |
138 | 0 | { |
139 | 0 | case css::chart::ChartSymbolType::NONE: |
140 | 0 | rSymbol.Style = chart2::SymbolStyle_NONE; |
141 | 0 | break; |
142 | 0 | case css::chart::ChartSymbolType::AUTO: |
143 | 0 | rSymbol.Style = chart2::SymbolStyle_AUTO; |
144 | 0 | break; |
145 | 0 | case css::chart::ChartSymbolType::BITMAPURL: |
146 | 0 | rSymbol.Style = chart2::SymbolStyle_GRAPHIC; |
147 | 0 | break; |
148 | 0 | default: |
149 | 0 | rSymbol.Style = chart2::SymbolStyle_STANDARD; |
150 | 0 | rSymbol.StandardSymbol = nSymbolType; |
151 | 0 | break; |
152 | 0 | } |
153 | 0 | } |
154 | | |
155 | | void lcl_addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList |
156 | | , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact |
157 | | , tSeriesOrDiagramPropertyType ePropertyType ) |
158 | 0 | { |
159 | 0 | rList.emplace_back( new WrappedSymbolTypeProperty( spChart2ModelContact, ePropertyType ) ); |
160 | 0 | rList.emplace_back( new WrappedSymbolBitmapURLProperty( spChart2ModelContact, ePropertyType ) ); |
161 | 0 | rList.emplace_back( new WrappedSymbolBitmapProperty( spChart2ModelContact, ePropertyType ) ); |
162 | 0 | rList.emplace_back( new WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) ); |
163 | 0 | rList.emplace_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) ); |
164 | 0 | } |
165 | | |
166 | | }//anonymous namespace |
167 | | |
168 | | void WrappedSymbolProperties::addProperties( std::vector< Property > & rOutProperties ) |
169 | 0 | { |
170 | 0 | rOutProperties.emplace_back( "SymbolType", |
171 | 0 | PROP_CHART_SYMBOL_TYPE, |
172 | 0 | cppu::UnoType<sal_Int32>::get(), |
173 | 0 | beans::PropertyAttribute::BOUND |
174 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
175 | |
|
176 | 0 | rOutProperties.emplace_back( "SymbolBitmapURL", |
177 | 0 | PROP_CHART_SYMBOL_BITMAP_URL, |
178 | 0 | cppu::UnoType<OUString>::get(), |
179 | 0 | beans::PropertyAttribute::BOUND |
180 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
181 | |
|
182 | 0 | rOutProperties.emplace_back( "SymbolBitmap", |
183 | 0 | PROP_CHART_SYMBOL_BITMAP, |
184 | 0 | cppu::UnoType<graphic::XGraphic>::get(), |
185 | 0 | beans::PropertyAttribute::BOUND |
186 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
187 | |
|
188 | 0 | rOutProperties.emplace_back( "SymbolSize", |
189 | 0 | PROP_CHART_SYMBOL_SIZE, |
190 | 0 | cppu::UnoType<awt::Size>::get(), |
191 | 0 | beans::PropertyAttribute::BOUND |
192 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
193 | |
|
194 | 0 | rOutProperties.emplace_back( "Lines", |
195 | 0 | PROP_CHART_SYMBOL_AND_LINES, |
196 | 0 | cppu::UnoType<bool>::get(), |
197 | 0 | beans::PropertyAttribute::BOUND |
198 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
199 | 0 | } |
200 | | |
201 | | void WrappedSymbolProperties::addWrappedPropertiesForSeries( std::vector< std::unique_ptr<WrappedProperty> >& rList |
202 | | , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact ) |
203 | 0 | { |
204 | 0 | lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES ); |
205 | 0 | } |
206 | | |
207 | | void WrappedSymbolProperties::addWrappedPropertiesForDiagram( std::vector< std::unique_ptr<WrappedProperty> >& rList |
208 | | , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact ) |
209 | 0 | { |
210 | 0 | lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM ); |
211 | 0 | } |
212 | | |
213 | | WrappedSymbolTypeProperty::WrappedSymbolTypeProperty( |
214 | | const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
215 | | tSeriesOrDiagramPropertyType ePropertyType ) |
216 | 0 | : WrappedSeriesOrDiagramProperty< sal_Int32 >( u"SymbolType"_ustr |
217 | 0 | , uno::Any( css::chart::ChartSymbolType::NONE ) |
218 | 0 | , spChart2ModelContact |
219 | 0 | , ePropertyType ) |
220 | 0 | { |
221 | 0 | } |
222 | | |
223 | | sal_Int32 WrappedSymbolTypeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const |
224 | 0 | { |
225 | 0 | sal_Int32 aRet = 0; |
226 | 0 | m_aDefaultValue >>= aRet; |
227 | 0 | chart2::Symbol aSymbol; |
228 | 0 | if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol ) ) |
229 | 0 | aRet = lcl_getSymbolType( aSymbol ); |
230 | 0 | return aRet; |
231 | 0 | } |
232 | | |
233 | | void WrappedSymbolTypeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& nSymbolType ) const |
234 | 0 | { |
235 | 0 | if(!xSeriesPropertySet.is()) |
236 | 0 | return; |
237 | | |
238 | 0 | chart2::Symbol aSymbol; |
239 | 0 | xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol; |
240 | |
|
241 | 0 | lcl_setSymbolTypeToSymbol( nSymbolType, aSymbol ); |
242 | 0 | xSeriesPropertySet->setPropertyValue( u"Symbol"_ustr, uno::Any( aSymbol ) ); |
243 | 0 | } |
244 | | |
245 | | Any WrappedSymbolTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
246 | 0 | { |
247 | | //the old chart (< OOo 2.3) needs symbol-type="automatic" at the plot-area if any of the series should be able to have symbols |
248 | 0 | if( m_ePropertyType == DIAGRAM ) |
249 | 0 | { |
250 | 0 | bool bHasAmbiguousValue = false; |
251 | 0 | sal_Int32 aValue = 0; |
252 | 0 | if( detectInnerValue( aValue, bHasAmbiguousValue ) ) |
253 | 0 | { |
254 | 0 | if(bHasAmbiguousValue) |
255 | 0 | { |
256 | 0 | m_aOuterValue <<= css::chart::ChartSymbolType::AUTO; |
257 | 0 | } |
258 | 0 | else |
259 | 0 | { |
260 | 0 | if( aValue == css::chart::ChartSymbolType::NONE ) |
261 | 0 | m_aOuterValue <<= css::chart::ChartSymbolType::NONE; |
262 | 0 | else |
263 | 0 | m_aOuterValue <<= css::chart::ChartSymbolType::AUTO; |
264 | 0 | } |
265 | 0 | } |
266 | 0 | return m_aOuterValue; |
267 | 0 | } |
268 | 0 | else |
269 | 0 | { |
270 | 0 | css::uno::Any aRet( m_aDefaultValue ); |
271 | 0 | aRet <<= getValueFromSeries( xInnerPropertySet ); |
272 | 0 | return aRet; |
273 | 0 | } |
274 | 0 | } |
275 | | |
276 | | beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const |
277 | 0 | { |
278 | | //the special situation for this property here is that the diagram default can be |
279 | | //different from the normal default and different from all singles series values |
280 | | //so we need to return PropertyState_DIRECT_VALUE for more cases |
281 | |
|
282 | 0 | if( m_ePropertyType == DATA_SERIES && //single series or point |
283 | 0 | m_spChart2ModelContact) |
284 | 0 | { |
285 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
286 | 0 | rtl::Reference< ::chart::DataSeries > xSeries( dynamic_cast<DataSeries*>(xInnerPropertyState.get()) ); |
287 | 0 | rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); |
288 | 0 | if (xChartType.is() && xChartType->isSupportingSymbolProperties(2)) |
289 | 0 | return beans::PropertyState_DIRECT_VALUE; |
290 | 0 | } |
291 | 0 | return WrappedProperty::getPropertyState( xInnerPropertyState ); |
292 | 0 | } |
293 | | |
294 | | WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty( |
295 | | const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
296 | | tSeriesOrDiagramPropertyType ePropertyType ) |
297 | 0 | : WrappedSeriesOrDiagramProperty<OUString>(u"SymbolBitmapURL"_ustr, |
298 | 0 | uno::Any(OUString()), spChart2ModelContact, ePropertyType) |
299 | 0 | { |
300 | 0 | } |
301 | | |
302 | | OUString WrappedSymbolBitmapURLProperty::getValueFromSeries(const Reference< beans::XPropertySet >& /*xSeriesPropertySet*/) const |
303 | 0 | { |
304 | 0 | return OUString(); |
305 | 0 | } |
306 | | |
307 | | void WrappedSymbolBitmapURLProperty::setValueToSeries( |
308 | | const Reference< beans::XPropertySet >& xSeriesPropertySet, |
309 | | OUString const & xNewGraphicURL) const |
310 | 0 | { |
311 | 0 | if (!xSeriesPropertySet.is()) |
312 | 0 | return; |
313 | | |
314 | 0 | chart2::Symbol aSymbol; |
315 | 0 | if (xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) |
316 | 0 | { |
317 | 0 | if (!xNewGraphicURL.isEmpty()) |
318 | 0 | { |
319 | 0 | Graphic aGraphic = vcl::graphic::loadFromURL(xNewGraphicURL); |
320 | 0 | aSymbol.Graphic.set(aGraphic.GetXGraphic()); |
321 | 0 | xSeriesPropertySet->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol)); |
322 | 0 | } |
323 | 0 | } |
324 | 0 | } |
325 | | |
326 | | WrappedSymbolBitmapProperty::WrappedSymbolBitmapProperty( |
327 | | const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
328 | | tSeriesOrDiagramPropertyType ePropertyType ) |
329 | 0 | : WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>>(u"SymbolBitmap"_ustr, |
330 | 0 | uno::Any(uno::Reference<graphic::XGraphic>()), spChart2ModelContact, ePropertyType) |
331 | 0 | { |
332 | 0 | } |
333 | | |
334 | | uno::Reference<graphic::XGraphic> WrappedSymbolBitmapProperty::getValueFromSeries(const Reference< beans::XPropertySet >& xSeriesPropertySet) const |
335 | 0 | { |
336 | 0 | uno::Reference<graphic::XGraphic> xGraphic; |
337 | 0 | m_aDefaultValue >>= xGraphic; |
338 | |
|
339 | 0 | chart2::Symbol aSymbol; |
340 | 0 | if (xSeriesPropertySet.is() && (xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) |
341 | 0 | && aSymbol.Graphic.is()) |
342 | 0 | { |
343 | 0 | xGraphic = aSymbol.Graphic; |
344 | 0 | } |
345 | 0 | return xGraphic; |
346 | 0 | } |
347 | | |
348 | | void WrappedSymbolBitmapProperty::setValueToSeries( |
349 | | const Reference< beans::XPropertySet >& xSeriesPropertySet, |
350 | | uno::Reference<graphic::XGraphic> const & xNewGraphic) const |
351 | 0 | { |
352 | 0 | if (!xSeriesPropertySet.is()) |
353 | 0 | return; |
354 | | |
355 | 0 | chart2::Symbol aSymbol; |
356 | 0 | if (xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) |
357 | 0 | { |
358 | 0 | if (xNewGraphic.is()) |
359 | 0 | { |
360 | 0 | aSymbol.Graphic.set(xNewGraphic); |
361 | 0 | xSeriesPropertySet->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol)); |
362 | 0 | } |
363 | 0 | } |
364 | 0 | } |
365 | | |
366 | | namespace |
367 | | { |
368 | | |
369 | | void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol ) |
370 | 0 | { |
371 | 0 | if( rSymbol.Style != chart2::SymbolStyle_GRAPHIC ) |
372 | 0 | return; |
373 | 0 | if( rSymbol.Size.Width != -1 ) |
374 | 0 | return; |
375 | 0 | if( rSymbol.Size.Height != -1 ) |
376 | 0 | return; |
377 | | |
378 | | //find a good automatic size |
379 | 0 | try |
380 | 0 | { |
381 | 0 | const awt::Size aDefaultSize(250,250); |
382 | 0 | awt::Size aSize = aDefaultSize; |
383 | 0 | uno::Reference< beans::XPropertySet > xProp( rSymbol.Graphic, uno::UNO_QUERY ); |
384 | 0 | if( xProp.is() ) |
385 | 0 | { |
386 | 0 | bool bFoundSize = false; |
387 | 0 | try |
388 | 0 | { |
389 | 0 | if( xProp->getPropertyValue( u"Size100thMM"_ustr ) >>= aSize ) |
390 | 0 | { |
391 | 0 | if( aSize.Width == 0 && aSize.Height == 0 ) |
392 | 0 | aSize = aDefaultSize; |
393 | 0 | else |
394 | 0 | bFoundSize = true; |
395 | 0 | } |
396 | 0 | } |
397 | 0 | catch( const uno::Exception& ) |
398 | 0 | { |
399 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
400 | 0 | } |
401 | | |
402 | 0 | if(!bFoundSize) |
403 | 0 | { |
404 | 0 | awt::Size aAWTPixelSize(10,10); |
405 | 0 | if( xProp->getPropertyValue( u"SizePixel"_ustr ) >>= aAWTPixelSize ) |
406 | 0 | { |
407 | 0 | Size aPixelSize(aAWTPixelSize.Width,aAWTPixelSize.Height); |
408 | 0 | Size aNewSize = o3tl::convert(aPixelSize, o3tl::Length::pt, o3tl::Length::mm100); |
409 | |
|
410 | 0 | aSize = awt::Size( aNewSize.Width(), aNewSize.Height() ); |
411 | |
|
412 | 0 | if( aSize.Width == 0 && aSize.Height == 0 ) |
413 | 0 | aSize = aDefaultSize; |
414 | 0 | } |
415 | 0 | } |
416 | 0 | } |
417 | 0 | rSymbol.Size = aSize; |
418 | 0 | } |
419 | 0 | catch( const uno::Exception& ) |
420 | 0 | { |
421 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
422 | 0 | } |
423 | 0 | } |
424 | | |
425 | | }//end anonymous namespace |
426 | | |
427 | | WrappedSymbolSizeProperty::WrappedSymbolSizeProperty( |
428 | | const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
429 | | tSeriesOrDiagramPropertyType ePropertyType ) |
430 | 0 | : WrappedSeriesOrDiagramProperty< awt::Size >( u"SymbolSize"_ustr |
431 | 0 | , uno::Any( awt::Size(250,250) ), spChart2ModelContact, ePropertyType ) |
432 | 0 | { |
433 | 0 | } |
434 | | |
435 | | awt::Size WrappedSymbolSizeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const |
436 | 0 | { |
437 | 0 | awt::Size aRet; |
438 | 0 | m_aDefaultValue >>= aRet; |
439 | 0 | chart2::Symbol aSymbol; |
440 | 0 | if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol )) |
441 | 0 | aRet = aSymbol.Size; |
442 | 0 | return aRet; |
443 | 0 | } |
444 | | |
445 | | void WrappedSymbolSizeProperty::setValueToSeries( |
446 | | const Reference< beans::XPropertySet >& xSeriesPropertySet, |
447 | | const awt::Size& aNewSize ) const |
448 | 0 | { |
449 | 0 | if(!xSeriesPropertySet.is()) |
450 | 0 | return; |
451 | | |
452 | 0 | chart2::Symbol aSymbol; |
453 | 0 | if( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol ) |
454 | 0 | { |
455 | 0 | aSymbol.Size = aNewSize; |
456 | 0 | lcl_correctSymbolSizeForBitmaps(aSymbol); |
457 | 0 | xSeriesPropertySet->setPropertyValue( u"Symbol"_ustr, uno::Any( aSymbol ) ); |
458 | 0 | } |
459 | 0 | } |
460 | | |
461 | | beans::PropertyState WrappedSymbolSizeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const |
462 | 0 | { |
463 | | //only export symbol size if necessary |
464 | 0 | if( m_ePropertyType == DIAGRAM ) |
465 | 0 | return beans::PropertyState_DEFAULT_VALUE; |
466 | | |
467 | 0 | try |
468 | 0 | { |
469 | 0 | chart2::Symbol aSymbol; |
470 | 0 | Reference< beans::XPropertySet > xSeriesPropertySet( xInnerPropertyState, uno::UNO_QUERY ); |
471 | 0 | if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol )) |
472 | 0 | { |
473 | 0 | if( aSymbol.Style != chart2::SymbolStyle_NONE ) |
474 | 0 | return beans::PropertyState_DIRECT_VALUE; |
475 | 0 | } |
476 | 0 | } |
477 | 0 | catch( const uno::Exception & ) |
478 | 0 | { |
479 | 0 | DBG_UNHANDLED_EXCEPTION("chart2"); |
480 | 0 | } |
481 | 0 | return beans::PropertyState_DEFAULT_VALUE; |
482 | 0 | } |
483 | | |
484 | | WrappedSymbolAndLinesProperty::WrappedSymbolAndLinesProperty( |
485 | | const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
486 | | tSeriesOrDiagramPropertyType ePropertyType ) |
487 | 0 | : WrappedSeriesOrDiagramProperty< bool >( u"Lines"_ustr |
488 | 0 | , uno::Any( true ), spChart2ModelContact, ePropertyType ) |
489 | 0 | { |
490 | 0 | } |
491 | | |
492 | | bool WrappedSymbolAndLinesProperty::getValueFromSeries( const Reference< beans::XPropertySet >& /*xSeriesPropertySet*/ ) const |
493 | 0 | { |
494 | | //do not export this property anymore, instead use a linestyle none for no lines |
495 | 0 | return true; |
496 | 0 | } |
497 | | |
498 | | void WrappedSymbolAndLinesProperty::setValueToSeries( |
499 | | const Reference< beans::XPropertySet >& xSeriesPropertySet, |
500 | | const bool& bDrawLines ) const |
501 | 0 | { |
502 | 0 | if(!xSeriesPropertySet.is()) |
503 | 0 | return; |
504 | | |
505 | 0 | drawing::LineStyle eOldLineStyle( drawing::LineStyle_SOLID ); |
506 | 0 | xSeriesPropertySet->getPropertyValue( u"LineStyle"_ustr ) >>= eOldLineStyle; |
507 | 0 | if( bDrawLines ) |
508 | 0 | { |
509 | | //#i114298# don't overwrite dashed lines with solid lines here |
510 | 0 | if( eOldLineStyle == drawing::LineStyle_NONE ) |
511 | 0 | xSeriesPropertySet->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_SOLID ) ); |
512 | 0 | } |
513 | 0 | else |
514 | 0 | { |
515 | 0 | if( eOldLineStyle != drawing::LineStyle_NONE ) |
516 | 0 | xSeriesPropertySet->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); |
517 | 0 | } |
518 | 0 | } |
519 | | |
520 | | beans::PropertyState WrappedSymbolAndLinesProperty::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
521 | 0 | { |
522 | | //do not export this property anymore, instead use a linestyle none for no lines |
523 | 0 | return beans::PropertyState_DEFAULT_VALUE; |
524 | 0 | } |
525 | | |
526 | | } //namespace chart |
527 | | |
528 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |