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