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 2794 : sal_Int32 lcl_getSymbolType( const ::com::sun::star::chart2::Symbol& rSymbol )
132 : {
133 2794 : sal_Int32 nSymbol = ::com::sun::star::chart::ChartSymbolType::NONE;
134 2794 : switch( rSymbol.Style )
135 : {
136 : case chart2::SymbolStyle_NONE:
137 2200 : break;
138 : case chart2::SymbolStyle_AUTO:
139 565 : nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO;
140 565 : break;
141 : case chart2::SymbolStyle_STANDARD:
142 28 : nSymbol = rSymbol.StandardSymbol%15;
143 28 : 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 1 : nSymbol = ::com::sun::star::chart::ChartSymbolType::BITMAPURL;
149 1 : break;
150 : default:
151 0 : nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO;
152 0 : break;
153 : }
154 2794 : return nSymbol;
155 : }
156 217 : void lcl_setSymbolTypeToSymbol( sal_Int32 nSymbolType, chart2::Symbol& rSymbol )
157 : {
158 217 : switch( nSymbolType )
159 : {
160 : case ::com::sun::star::chart::ChartSymbolType::NONE:
161 146 : rSymbol.Style = chart2::SymbolStyle_NONE;
162 146 : break;
163 : case ::com::sun::star::chart::ChartSymbolType::AUTO:
164 37 : rSymbol.Style = chart2::SymbolStyle_AUTO;
165 37 : break;
166 : case ::com::sun::star::chart::ChartSymbolType::BITMAPURL:
167 1 : rSymbol.Style = chart2::SymbolStyle_GRAPHIC;
168 1 : break;
169 : default:
170 33 : rSymbol.Style = chart2::SymbolStyle_STANDARD;
171 33 : rSymbol.StandardSymbol = nSymbolType;
172 33 : break;
173 : }
174 217 : }
175 :
176 2058 : void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList
177 : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
178 : , tSeriesOrDiagramPropertyType ePropertyType )
179 : {
180 2058 : rList.push_back( new WrappedSymbolTypeProperty( spChart2ModelContact, ePropertyType ) );
181 2058 : rList.push_back( new WrappedSymbolBitmapURLProperty( spChart2ModelContact, ePropertyType ) );
182 2058 : rList.push_back( new WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) );
183 2058 : rList.push_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) );
184 2058 : }
185 :
186 : }//anonymous namespace
187 :
188 25 : void WrappedSymbolProperties::addProperties( ::std::vector< Property > & rOutProperties )
189 : {
190 : rOutProperties.push_back(
191 : Property( "SymbolType",
192 : PROP_CHART_SYMBOL_TYPE,
193 25 : ::getCppuType( reinterpret_cast< sal_Int32 * >(0)),
194 : beans::PropertyAttribute::BOUND
195 50 : | beans::PropertyAttribute::MAYBEDEFAULT ));
196 :
197 : rOutProperties.push_back(
198 : Property( "SymbolBitmapURL",
199 : PROP_CHART_SYMBOL_BITMAP_URL,
200 25 : ::getCppuType( reinterpret_cast< OUString * >(0)),
201 : beans::PropertyAttribute::BOUND
202 50 : | beans::PropertyAttribute::MAYBEDEFAULT ));
203 :
204 : rOutProperties.push_back(
205 : Property( "SymbolSize",
206 : PROP_CHART_SYMBOL_SIZE,
207 25 : ::getCppuType( reinterpret_cast< awt::Size * >(0)),
208 : beans::PropertyAttribute::BOUND
209 50 : | beans::PropertyAttribute::MAYBEDEFAULT ));
210 :
211 : rOutProperties.push_back(
212 : Property( "Lines",
213 : PROP_CHART_SYMBOL_AND_LINES,
214 25 : ::getBooleanCppuType(),
215 : beans::PropertyAttribute::BOUND
216 50 : | beans::PropertyAttribute::MAYBEDEFAULT ));
217 25 : }
218 :
219 1854 : void WrappedSymbolProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList
220 : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
221 : {
222 1854 : lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES );
223 1854 : }
224 :
225 204 : void WrappedSymbolProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList
226 : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
227 : {
228 204 : lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM );
229 204 : }
230 :
231 2058 : 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 2058 : , ePropertyType )
238 : {
239 2058 : }
240 4104 : WrappedSymbolTypeProperty::~WrappedSymbolTypeProperty()
241 : {
242 4104 : }
243 :
244 2794 : sal_Int32 WrappedSymbolTypeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
245 : {
246 2794 : sal_Int32 aRet = 0;
247 2794 : m_aDefaultValue >>= aRet;
248 2794 : chart2::Symbol aSymbol;
249 2794 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ) )
250 2794 : aRet = lcl_getSymbolType( aSymbol );
251 2794 : return aRet;
252 : }
253 :
254 217 : void WrappedSymbolTypeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& nSymbolType ) const
255 : {
256 217 : if(!xSeriesPropertySet.is())
257 217 : return;
258 :
259 217 : chart2::Symbol aSymbol;
260 217 : xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol;
261 :
262 217 : lcl_setSymbolTypeToSymbol( nSymbolType, aSymbol );
263 217 : xSeriesPropertySet->setPropertyValue( "Symbol", uno::makeAny( aSymbol ) );
264 : }
265 :
266 2361 : 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 2361 : if( m_ePropertyType == DIAGRAM )
271 : {
272 458 : bool bHasAmbiguousValue = false;
273 458 : sal_Int32 aValue = 0;
274 458 : if( detectInnerValue( aValue, bHasAmbiguousValue ) )
275 : {
276 375 : if(bHasAmbiguousValue)
277 : {
278 13 : m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::AUTO );
279 : }
280 : else
281 : {
282 362 : if( ::com::sun::star::chart::ChartSymbolType::NONE == aValue )
283 314 : m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::NONE );
284 : else
285 48 : m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::AUTO );
286 : }
287 : }
288 458 : return m_aOuterValue;
289 : }
290 : else
291 : {
292 1903 : ::com::sun::star::uno::Any aRet( m_aDefaultValue );
293 1903 : aRet <<= getValueFromSeries( xInnerPropertySet );
294 1903 : return aRet;
295 : }
296 : }
297 :
298 1820 : 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 3298 : if( m_ePropertyType == DATA_SERIES && //single series or point
306 1478 : m_spChart2ModelContact.get())
307 : {
308 1478 : Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
309 2890 : Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, uno::UNO_QUERY );
310 2890 : Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
311 1478 : if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) )
312 1478 : return beans::PropertyState_DIRECT_VALUE;
313 : }
314 1754 : return WrappedProperty::getPropertyState( xInnerPropertyState );
315 : }
316 :
317 2058 : WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty(
318 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
319 : tSeriesOrDiagramPropertyType ePropertyType )
320 : : WrappedSeriesOrDiagramProperty< OUString >( "SymbolBitmapURL"
321 2058 : , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType )
322 : {
323 2058 : }
324 :
325 4104 : WrappedSymbolBitmapURLProperty::~WrappedSymbolBitmapURLProperty()
326 : {
327 4104 : }
328 :
329 2974 : OUString WrappedSymbolBitmapURLProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
330 : {
331 2974 : OUString aRet;
332 2974 : m_aDefaultValue >>= aRet;
333 5948 : chart2::Symbol aSymbol;
334 8922 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol )
335 8922 : && aSymbol.Graphic.is())
336 : {
337 9 : GraphicObject aGrObj( Graphic( aSymbol.Graphic ));
338 18 : aRet = UNO_NAME_GRAPHOBJ_URLPREFIX +
339 : OStringToOUString(aGrObj.GetUniqueID(),
340 27 : RTL_TEXTENCODING_ASCII_US);
341 : }
342 5948 : return aRet;
343 : }
344 :
345 5 : void WrappedSymbolBitmapURLProperty::setValueToSeries(
346 : const Reference< beans::XPropertySet >& xSeriesPropertySet,
347 : const OUString& aNewGraphicURL ) const
348 : {
349 5 : if(!xSeriesPropertySet.is())
350 5 : return;
351 :
352 5 : chart2::Symbol aSymbol;
353 5 : if( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol )
354 : {
355 5 : bool bMatchesPrefix = aNewGraphicURL.match( UNO_NAME_GRAPHOBJ_URLPREFIX );
356 5 : if( bMatchesPrefix )
357 : {
358 : GraphicObject aGrObj = GraphicObject(
359 4 : OUStringToOString(aNewGraphicURL.copy( RTL_CONSTASCII_LENGTH(UNO_NAME_GRAPHOBJ_URLPREFIX) ), RTL_TEXTENCODING_ASCII_US));
360 4 : aSymbol.Graphic.set( aGrObj.GetGraphic().GetXGraphic());
361 4 : xSeriesPropertySet->setPropertyValue( "Symbol", uno::makeAny( aSymbol ) );
362 : }
363 : else
364 : {
365 : try
366 : {
367 : // @todo: get factory from some context?
368 1 : Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
369 2 : Reference< graphic::XGraphicProvider > xGraphProv( graphic::GraphicProvider::create(xContext) );
370 2 : Sequence< beans::PropertyValue > aArgs(1);
371 2 : aArgs[0] = beans::PropertyValue( "URL", -1, uno::makeAny( aNewGraphicURL ),
372 1 : beans::PropertyState_DIRECT_VALUE );
373 1 : aSymbol.Graphic.set( xGraphProv->queryGraphic( aArgs ));
374 : OSL_ENSURE( aSymbol.Graphic.is(), "Invalid URL for Symbol Bitmap" );
375 2 : xSeriesPropertySet->setPropertyValue( "Symbol", uno::makeAny( aSymbol ) );
376 : }
377 0 : catch( const uno::Exception & ex )
378 : {
379 : ASSERT_EXCEPTION( ex );
380 : }
381 : }
382 5 : }
383 : }
384 :
385 : namespace
386 : {
387 :
388 37 : void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol )
389 : {
390 37 : if( rSymbol.Style != chart2::SymbolStyle_GRAPHIC )
391 36 : return;
392 1 : if( rSymbol.Size.Width != -1 )
393 1 : 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 2058 : WrappedSymbolSizeProperty::WrappedSymbolSizeProperty(
446 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
447 : tSeriesOrDiagramPropertyType ePropertyType )
448 : : WrappedSeriesOrDiagramProperty< awt::Size >( "SymbolSize"
449 2058 : , uno::makeAny( awt::Size(250,250) ), spChart2ModelContact, ePropertyType )
450 : {
451 2058 : }
452 :
453 4104 : WrappedSymbolSizeProperty::~WrappedSymbolSizeProperty()
454 : {
455 4104 : }
456 :
457 277 : awt::Size WrappedSymbolSizeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
458 : {
459 277 : awt::Size aRet;
460 277 : m_aDefaultValue >>= aRet;
461 277 : chart2::Symbol aSymbol;
462 277 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ))
463 277 : aRet = aSymbol.Size;
464 277 : return aRet;
465 : }
466 :
467 37 : void WrappedSymbolSizeProperty::setValueToSeries(
468 : const Reference< beans::XPropertySet >& xSeriesPropertySet,
469 : const awt::Size& aNewSize ) const
470 : {
471 37 : if(!xSeriesPropertySet.is())
472 37 : return;
473 :
474 37 : chart2::Symbol aSymbol;
475 37 : if( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol )
476 : {
477 37 : aSymbol.Size = aNewSize;
478 37 : lcl_correctSymbolSizeForBitmaps(aSymbol);
479 37 : xSeriesPropertySet->setPropertyValue( "Symbol", uno::makeAny( aSymbol ) );
480 37 : }
481 : }
482 :
483 1820 : 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 1820 : if( m_ePropertyType == DIAGRAM )
488 342 : return beans::PropertyState_DEFAULT_VALUE;
489 :
490 : try
491 : {
492 1478 : chart2::Symbol aSymbol;
493 2686 : Reference< beans::XPropertySet > xSeriesPropertySet( xInnerPropertyState, uno::UNO_QUERY );
494 1478 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ))
495 : {
496 1478 : if( chart2::SymbolStyle_NONE != aSymbol.Style )
497 270 : return beans::PropertyState_DIRECT_VALUE;
498 1208 : }
499 : }
500 0 : catch( const uno::Exception & ex )
501 : {
502 : ASSERT_EXCEPTION( ex );
503 : }
504 1208 : return beans::PropertyState_DEFAULT_VALUE;
505 : }
506 :
507 2058 : WrappedSymbolAndLinesProperty::WrappedSymbolAndLinesProperty(
508 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
509 : tSeriesOrDiagramPropertyType ePropertyType )
510 : : WrappedSeriesOrDiagramProperty< sal_Bool >( "Lines"
511 2058 : , uno::makeAny( sal_True ), spChart2ModelContact, ePropertyType )
512 : {
513 2058 : }
514 :
515 4104 : WrappedSymbolAndLinesProperty::~WrappedSymbolAndLinesProperty()
516 : {
517 4104 : }
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 1820 : 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 1820 : return beans::PropertyState_DEFAULT_VALUE;
552 : }
553 :
554 : } //namespace wrapper
555 : } //namespace chart
556 :
557 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|