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