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