Branch data 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 : 184 : sal_Int32 lcl_getSymbolType( const ::com::sun::star::chart2::Symbol& rSymbol )
139 : : {
140 : 184 : sal_Int32 nSymbol = ::com::sun::star::chart::ChartSymbolType::NONE;
141 [ + - + - : 184 : switch( rSymbol.Style )
+ - ]
142 : : {
143 : : case chart2::SymbolStyle_NONE:
144 : 166 : break;
145 : : case chart2::SymbolStyle_AUTO:
146 : 0 : nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO;
147 : 0 : break;
148 : : case chart2::SymbolStyle_STANDARD:
149 : 16 : nSymbol = rSymbol.StandardSymbol%15;
150 : 16 : 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 : 2 : nSymbol = ::com::sun::star::chart::ChartSymbolType::BITMAPURL;
156 : 2 : break;
157 : : default:
158 : 0 : nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO;
159 : 0 : break;
160 : : }
161 : 184 : return nSymbol;
162 : : }
163 : 30 : void lcl_setSymbolTypeToSymbol( sal_Int32 nSymbolType, chart2::Symbol& rSymbol )
164 : : {
165 [ + - + + ]: 30 : switch( nSymbolType )
166 : : {
167 : : case ::com::sun::star::chart::ChartSymbolType::NONE:
168 : 18 : rSymbol.Style = chart2::SymbolStyle_NONE;
169 : 18 : 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 : 2 : rSymbol.Style = chart2::SymbolStyle_GRAPHIC;
175 : 2 : break;
176 : : default:
177 : 10 : rSymbol.Style = chart2::SymbolStyle_STANDARD;
178 : 10 : rSymbol.StandardSymbol = nSymbolType;
179 : 10 : break;
180 : : }
181 : 30 : }
182 : :
183 : 129 : void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList
184 : : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
185 : : , tSeriesOrDiagramPropertyType ePropertyType )
186 : : {
187 [ + - ][ + - ]: 129 : rList.push_back( new WrappedSymbolTypeProperty( spChart2ModelContact, ePropertyType ) );
[ + - ]
188 [ + - ][ + - ]: 129 : rList.push_back( new WrappedSymbolBitmapURLProperty( spChart2ModelContact, ePropertyType ) );
[ + - ]
189 [ + - ][ + - ]: 129 : rList.push_back( new WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) );
[ + - ]
190 [ + - ][ + - ]: 129 : rList.push_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) );
[ + - ]
191 : 129 : }
192 : :
193 : : }//anonymous namespace
194 : :
195 : : //-----------------------------------------------------------------------------
196 : 19 : void WrappedSymbolProperties::addProperties( ::std::vector< Property > & rOutProperties )
197 : : {
198 : : rOutProperties.push_back(
199 : : Property( "SymbolType",
200 : : PROP_CHART_SYMBOL_TYPE,
201 [ + - ]: 19 : ::getCppuType( reinterpret_cast< sal_Int32 * >(0)),
202 : : beans::PropertyAttribute::BOUND
203 [ + - ]: 19 : | beans::PropertyAttribute::MAYBEDEFAULT ));
204 : :
205 : : rOutProperties.push_back(
206 : : Property( "SymbolBitmapURL",
207 : : PROP_CHART_SYMBOL_BITMAP_URL,
208 [ + - ]: 19 : ::getCppuType( reinterpret_cast< ::rtl::OUString * >(0)),
209 : : beans::PropertyAttribute::BOUND
210 [ + - ]: 19 : | beans::PropertyAttribute::MAYBEDEFAULT ));
211 : :
212 : : rOutProperties.push_back(
213 : : Property( "SymbolSize",
214 : : PROP_CHART_SYMBOL_SIZE,
215 [ + - ]: 19 : ::getCppuType( reinterpret_cast< awt::Size * >(0)),
216 : : beans::PropertyAttribute::BOUND
217 [ + - ]: 19 : | beans::PropertyAttribute::MAYBEDEFAULT ));
218 : :
219 : : rOutProperties.push_back(
220 : : Property( "Lines",
221 : : PROP_CHART_SYMBOL_AND_LINES,
222 [ + - ]: 19 : ::getBooleanCppuType(),
223 : : beans::PropertyAttribute::BOUND
224 [ + - ]: 19 : | beans::PropertyAttribute::MAYBEDEFAULT ));
225 : 19 : }
226 : :
227 : : //-----------------------------------------------------------------------------
228 : 96 : void WrappedSymbolProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList
229 : : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
230 : : {
231 [ + - ]: 96 : lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES );
232 : 96 : }
233 : :
234 : : //-----------------------------------------------------------------------------
235 : 33 : void WrappedSymbolProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList
236 : : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
237 : : {
238 [ + - ]: 33 : lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM );
239 : 33 : }
240 : :
241 : : //-----------------------------------------------------------------------------
242 : :
243 : 129 : 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 [ + - ][ + - ]: 129 : , ePropertyType )
250 : : {
251 : 129 : }
252 : 129 : WrappedSymbolTypeProperty::~WrappedSymbolTypeProperty()
253 : : {
254 [ - + ]: 258 : }
255 : :
256 : 184 : sal_Int32 WrappedSymbolTypeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
257 : : {
258 : 184 : sal_Int32 aRet = 0;
259 : 184 : m_aDefaultValue >>= aRet;
260 [ + - ]: 184 : chart2::Symbol aSymbol;
261 [ + - ][ + - ]: 184 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ) )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - # #
# # # # ]
262 : 184 : aRet = lcl_getSymbolType( aSymbol );
263 [ + - ]: 184 : return aRet;
264 : : }
265 : :
266 : 30 : void WrappedSymbolTypeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Int32 nSymbolType ) const
267 : : {
268 [ + - ]: 30 : if(!xSeriesPropertySet.is())
269 : 30 : return;
270 : :
271 [ + - ]: 30 : chart2::Symbol aSymbol;
272 [ + - ][ + - ]: 30 : xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol;
[ + - ]
273 : :
274 : 30 : lcl_setSymbolTypeToSymbol( nSymbolType, aSymbol );
275 [ + - ][ + - ]: 30 : xSeriesPropertySet->setPropertyValue( "Symbol", uno::makeAny( aSymbol ) );
[ + - ][ + - ]
276 : : }
277 : :
278 : 134 : 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 [ + + ]: 134 : if( m_ePropertyType == DIAGRAM )
283 : : {
284 : 24 : bool bHasAmbiguousValue = false;
285 : 24 : sal_Int32 aValue = 0;
286 [ + - ][ + + ]: 24 : if( detectInnerValue( aValue, bHasAmbiguousValue ) )
287 : : {
288 [ - + ]: 18 : if(bHasAmbiguousValue)
289 : : {
290 [ # # ]: 0 : m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::AUTO );
291 : : }
292 : : else
293 : : {
294 [ + - ]: 18 : if( ::com::sun::star::chart::ChartSymbolType::NONE == aValue )
295 [ + - ]: 18 : 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 : 24 : return m_aOuterValue;
301 : : }
302 : : else
303 : : {
304 : 110 : ::com::sun::star::uno::Any aRet( m_aDefaultValue );
305 [ + - ][ + - ]: 110 : aRet <<= getValueFromSeries( xInnerPropertySet );
306 : 134 : return aRet;
307 : : }
308 : : }
309 : :
310 : 92 : 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 [ + + + - ]: 166 : if( m_ePropertyType == DATA_SERIES && //single series or point
[ + + ]
318 : 74 : m_spChart2ModelContact.get())
319 : : {
320 [ + - ]: 74 : Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
321 [ + - ]: 74 : Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, uno::UNO_QUERY );
322 [ + - ]: 74 : Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
323 [ + - ][ - + ]: 74 : if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) )
324 [ - + ][ - + ]: 74 : return beans::PropertyState_DIRECT_VALUE;
[ + - ]
325 : : }
326 : 92 : return WrappedProperty::getPropertyState( xInnerPropertyState );
327 : : }
328 : :
329 : : //-----------------------------------------------------------------------------
330 : :
331 : 129 : WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty(
332 : : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
333 : : tSeriesOrDiagramPropertyType ePropertyType )
334 : : : WrappedSeriesOrDiagramProperty< OUString >( "SymbolBitmapURL"
335 [ + - ][ + - ]: 129 : , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType )
336 : : {
337 : 129 : }
338 : :
339 : 129 : WrappedSymbolBitmapURLProperty::~WrappedSymbolBitmapURLProperty()
340 : : {
341 [ - + ]: 258 : }
342 : :
343 : 152 : OUString WrappedSymbolBitmapURLProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
344 : : {
345 : 152 : OUString aRet;
346 : 152 : m_aDefaultValue >>= aRet;
347 [ + - ]: 152 : chart2::Symbol aSymbol;
348 [ + - ][ + - ]: 304 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol )
[ + - ][ + - ]
[ + - + + ]
[ + - ][ + - ]
[ + - ][ + +
# # # # #
# ]
349 : 152 : && aSymbol.Graphic.is())
350 : : {
351 [ + - ][ + - ]: 2 : GraphicObject aGrObj( Graphic( aSymbol.Graphic ));
[ + - ]
352 : : aRet = OUString(RTL_CONSTASCII_USTRINGPARAM(
353 [ + - ]: 2 : UNO_NAME_GRAPHOBJ_URLPREFIX));
354 : : aRet += OStringToOUString(aGrObj.GetUniqueID(),
355 [ + - ][ + - ]: 2 : RTL_TEXTENCODING_ASCII_US);
[ + - ]
356 : : }
357 [ + - ]: 152 : return aRet;
358 : : }
359 : :
360 : 2 : void WrappedSymbolBitmapURLProperty::setValueToSeries(
361 : : const Reference< beans::XPropertySet >& xSeriesPropertySet,
362 : : OUString aNewGraphicURL ) const
363 : : {
364 [ + - ]: 2 : if(!xSeriesPropertySet.is())
365 : 2 : return;
366 : :
367 [ + - ]: 2 : chart2::Symbol aSymbol;
368 [ + - ][ + - ]: 2 : if( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol )
[ + - ][ + - ]
369 : : {
370 : : bool bMatchesPrefix =
371 : 2 : aNewGraphicURL.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( UNO_NAME_GRAPHOBJ_URLPREFIX ));
372 [ - + ]: 2 : 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 [ + - ]: 2 : Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
385 [ + - ]: 2 : Reference< graphic::XGraphicProvider > xGraphProv( graphic::GraphicProvider::create(xContext) );
386 [ + - ]: 2 : Sequence< beans::PropertyValue > aArgs(1);
387 [ + - ]: 2 : aArgs[0] = beans::PropertyValue( "URL", -1, uno::makeAny( aNewGraphicURL ),
388 [ + - ]: 4 : beans::PropertyState_DIRECT_VALUE );
389 [ + - ][ + - ]: 2 : aSymbol.Graphic.set( xGraphProv->queryGraphic( aArgs ));
[ + - ]
390 : : OSL_ENSURE( aSymbol.Graphic.is(), "Invalid URL for Symbol Bitmap" );
391 [ + - ][ + - ]: 2 : xSeriesPropertySet->setPropertyValue( "Symbol", uno::makeAny( aSymbol ) );
[ + - ][ # # ]
[ + - ]
392 : : }
393 [ # # ]: 0 : catch( const uno::Exception & ex )
394 : : {
395 : : ASSERT_EXCEPTION( ex );
396 : : }
397 : : }
398 [ + - ]: 2 : }
399 : : }
400 : :
401 : :
402 : : //-----------------------------------------------------------------------------
403 : :
404 : : namespace
405 : : {
406 : :
407 : 8 : void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol )
408 : : {
409 [ + + ]: 8 : if( rSymbol.Style != chart2::SymbolStyle_GRAPHIC )
410 : 6 : return;
411 [ + - ]: 2 : if( rSymbol.Size.Width != -1 )
412 : 2 : 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 [ # # ]: 8 : 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 : 129 : WrappedSymbolSizeProperty::WrappedSymbolSizeProperty(
465 : : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
466 : : tSeriesOrDiagramPropertyType ePropertyType )
467 : : : WrappedSeriesOrDiagramProperty< awt::Size >( "SymbolSize"
468 [ + - ][ + - ]: 129 : , uno::makeAny( awt::Size(250,250) ), spChart2ModelContact, ePropertyType )
469 : : {
470 : 129 : }
471 : :
472 : 129 : WrappedSymbolSizeProperty::~WrappedSymbolSizeProperty()
473 : : {
474 [ - + ]: 258 : }
475 : :
476 : 14 : awt::Size WrappedSymbolSizeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
477 : : {
478 : 14 : awt::Size aRet;
479 [ + - ]: 14 : m_aDefaultValue >>= aRet;
480 [ + - ]: 14 : chart2::Symbol aSymbol;
481 [ + - ][ + - ]: 14 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ))
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - # #
# # # # ]
482 : 14 : aRet = aSymbol.Size;
483 [ + - ]: 14 : return aRet;
484 : : }
485 : :
486 : 8 : void WrappedSymbolSizeProperty::setValueToSeries(
487 : : const Reference< beans::XPropertySet >& xSeriesPropertySet,
488 : : awt::Size aNewSize ) const
489 : : {
490 [ + - ]: 8 : if(!xSeriesPropertySet.is())
491 : 8 : return;
492 : :
493 [ + - ]: 8 : chart2::Symbol aSymbol;
494 [ + - ][ + - ]: 8 : if( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol )
[ + - ][ + - ]
495 : : {
496 : 8 : aSymbol.Size = aNewSize;
497 [ + - ]: 8 : lcl_correctSymbolSizeForBitmaps(aSymbol);
498 [ + - ][ + - ]: 8 : xSeriesPropertySet->setPropertyValue( "Symbol", uno::makeAny( aSymbol ) );
[ + - ]
499 [ + - ]: 8 : }
500 : : }
501 : :
502 : 92 : 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 [ + + ]: 92 : if( m_ePropertyType == DIAGRAM )
507 : 18 : return beans::PropertyState_DEFAULT_VALUE;
508 : :
509 : : try
510 : : {
511 [ + - ]: 74 : chart2::Symbol aSymbol;
512 [ + - ]: 74 : Reference< beans::XPropertySet > xSeriesPropertySet( xInnerPropertyState, uno::UNO_QUERY );
513 [ + - ][ + - ]: 74 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ))
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - # #
# # # # ]
514 : : {
515 [ - + ]: 74 : if( chart2::SymbolStyle_NONE != aSymbol.Style )
516 : 74 : return beans::PropertyState_DIRECT_VALUE;
517 [ - + ][ + - ]: 74 : }
[ + - ][ # # ]
518 : : }
519 : 0 : catch( const uno::Exception & ex )
520 : : {
521 : : ASSERT_EXCEPTION( ex );
522 : : }
523 : 92 : return beans::PropertyState_DEFAULT_VALUE;
524 : : }
525 : :
526 : : //-----------------------------------------------------------------------------
527 : :
528 : 129 : WrappedSymbolAndLinesProperty::WrappedSymbolAndLinesProperty(
529 : : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
530 : : tSeriesOrDiagramPropertyType ePropertyType )
531 : : : WrappedSeriesOrDiagramProperty< sal_Bool >( "Lines"
532 [ + - ][ + - ]: 129 : , uno::makeAny( sal_True ), spChart2ModelContact, ePropertyType )
533 : : {
534 : 129 : }
535 : :
536 : 129 : WrappedSymbolAndLinesProperty::~WrappedSymbolAndLinesProperty()
537 : : {
538 [ - + ]: 258 : }
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 : 92 : 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 : 92 : return beans::PropertyState_DEFAULT_VALUE;
573 : : }
574 : :
575 : : } //namespace wrapper
576 : : } //namespace chart
577 : : //.............................................................................
578 : :
579 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|