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