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/beans/XPropertyState.hpp>
30#include <com/sun/star/chart/ChartSymbolType.hpp>
31#include <com/sun/star/drawing/LineStyle.hpp>
38using ::com::sun::star::uno::Any;
39using ::com::sun::star::uno::Reference;
40using ::com::sun::star::beans::Property;
48class WrappedSymbolTypeProperty :
public WrappedSeriesOrDiagramProperty< sal_Int32 >
51 virtual sal_Int32 getValueFromSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet )
const override;
52 virtual void setValueToSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet,
const sal_Int32& aNewValue )
const override;
54 virtual Any getPropertyValue(
const Reference< beans::XPropertySet >& xInnerPropertySet )
const override;
55 virtual beans::PropertyState getPropertyState(
const Reference< beans::XPropertyState >& xInnerPropertyState )
const override;
57 explicit WrappedSymbolTypeProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
61class WrappedSymbolBitmapURLProperty :
public WrappedSeriesOrDiagramProperty<OUString>
64 virtual OUString getValueFromSeries(
const Reference<beans::XPropertySet>& xSeriesPropertySet)
const override;
65 virtual void setValueToSeries(
const Reference<beans::XPropertySet> & xSeriesPropertySet, OUString
const & xNewGraphicURL)
const override;
67 explicit WrappedSymbolBitmapURLProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
71class WrappedSymbolBitmapProperty :
public WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>>
74 virtual uno::Reference<graphic::XGraphic> getValueFromSeries(
const Reference<beans::XPropertySet>& xSeriesPropertySet)
const override;
75 virtual void setValueToSeries(
const Reference<beans::XPropertySet> & xSeriesPropertySet, uno::Reference<graphic::XGraphic>
const & xNewGraphic)
const override;
77 explicit WrappedSymbolBitmapProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
81class WrappedSymbolSizeProperty :
public WrappedSeriesOrDiagramProperty< awt::Size >
84 virtual awt::Size getValueFromSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet )
const override;
85 virtual void setValueToSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet,
const awt::Size& aNewSize )
const override;
86 virtual beans::PropertyState getPropertyState(
const Reference< beans::XPropertyState >& xInnerPropertyState )
const override;
88 explicit WrappedSymbolSizeProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
92class WrappedSymbolAndLinesProperty :
public WrappedSeriesOrDiagramProperty< bool >
95 virtual bool getValueFromSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet )
const override;
96 virtual void setValueToSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet,
const bool& bDrawLines )
const override;
97 virtual beans::PropertyState getPropertyState(
const Reference< beans::XPropertyState >& xInnerPropertyState )
const override;
99 explicit WrappedSymbolAndLinesProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
107 PROP_CHART_SYMBOL_BITMAP_URL,
108 PROP_CHART_SYMBOL_BITMAP,
109 PROP_CHART_SYMBOL_SIZE,
110 PROP_CHART_SYMBOL_AND_LINES
113sal_Int32 lcl_getSymbolType(
const css::chart2::Symbol& rSymbol )
115 sal_Int32 nSymbol = css::chart::ChartSymbolType::NONE;
116 switch( rSymbol.Style )
118 case chart2::SymbolStyle_NONE:
120 case chart2::SymbolStyle_AUTO:
121 nSymbol = css::chart::ChartSymbolType::AUTO;
123 case chart2::SymbolStyle_STANDARD:
124 nSymbol = rSymbol.StandardSymbol%15;
126 case chart2::SymbolStyle_POLYGON:
127 nSymbol = css::chart::ChartSymbolType::AUTO;
129 case chart2::SymbolStyle_GRAPHIC:
130 nSymbol = css::chart::ChartSymbolType::BITMAPURL;
133 nSymbol = css::chart::ChartSymbolType::AUTO;
138void lcl_setSymbolTypeToSymbol( sal_Int32 nSymbolType, chart2::Symbol& rSymbol )
140 switch( nSymbolType )
142 case css::chart::ChartSymbolType::NONE:
143 rSymbol.Style = chart2::SymbolStyle_NONE;
145 case css::chart::ChartSymbolType::AUTO:
146 rSymbol.Style = chart2::SymbolStyle_AUTO;
148 case css::chart::ChartSymbolType::BITMAPURL:
149 rSymbol.Style = chart2::SymbolStyle_GRAPHIC;
152 rSymbol.Style = chart2::SymbolStyle_STANDARD;
153 rSymbol.StandardSymbol = nSymbolType;
158void lcl_addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
159 ,
const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact
162 rList.emplace_back(
new WrappedSymbolTypeProperty( spChart2ModelContact, ePropertyType ) );
163 rList.emplace_back(
new WrappedSymbolBitmapURLProperty( spChart2ModelContact, ePropertyType ) );
164 rList.emplace_back(
new WrappedSymbolBitmapProperty( spChart2ModelContact, ePropertyType ) );
165 rList.emplace_back(
new WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) );
166 rList.emplace_back(
new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) );
173 rOutProperties.emplace_back(
"SymbolType",
174 PROP_CHART_SYMBOL_TYPE,
176 beans::PropertyAttribute::BOUND
177 | beans::PropertyAttribute::MAYBEDEFAULT );
179 rOutProperties.emplace_back(
"SymbolBitmapURL",
180 PROP_CHART_SYMBOL_BITMAP_URL,
182 beans::PropertyAttribute::BOUND
183 | beans::PropertyAttribute::MAYBEDEFAULT );
185 rOutProperties.emplace_back(
"SymbolBitmap",
186 PROP_CHART_SYMBOL_BITMAP,
188 beans::PropertyAttribute::BOUND
189 | beans::PropertyAttribute::MAYBEDEFAULT );
191 rOutProperties.emplace_back(
"SymbolSize",
192 PROP_CHART_SYMBOL_SIZE,
194 beans::PropertyAttribute::BOUND
195 | beans::PropertyAttribute::MAYBEDEFAULT );
197 rOutProperties.emplace_back(
"Lines",
198 PROP_CHART_SYMBOL_AND_LINES,
200 beans::PropertyAttribute::BOUND
201 | beans::PropertyAttribute::MAYBEDEFAULT );
205 ,
const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
207 lcl_addWrappedProperties( rList, spChart2ModelContact,
DATA_SERIES );
211 ,
const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
213 lcl_addWrappedProperties( rList, spChart2ModelContact,
DIAGRAM );
216WrappedSymbolTypeProperty::WrappedSymbolTypeProperty(
217 const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
221 , spChart2ModelContact
230 chart2::Symbol aSymbol;
231 if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(
"Symbol") >>= aSymbol ) )
232 aRet = lcl_getSymbolType( aSymbol );
236void WrappedSymbolTypeProperty::setValueToSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet,
const sal_Int32& nSymbolType )
const
238 if(!xSeriesPropertySet.is())
241 chart2::Symbol aSymbol;
242 xSeriesPropertySet->getPropertyValue(
"Symbol") >>= aSymbol;
244 lcl_setSymbolTypeToSymbol( nSymbolType, aSymbol );
245 xSeriesPropertySet->setPropertyValue(
"Symbol",
uno::Any( aSymbol ) );
248Any WrappedSymbolTypeProperty::getPropertyValue(
const Reference< beans::XPropertySet >& xInnerPropertySet )
const
251 if( m_ePropertyType ==
DIAGRAM )
253 bool bHasAmbiguousValue =
false;
254 sal_Int32 aValue = 0;
255 if( detectInnerValue( aValue, bHasAmbiguousValue ) )
257 if(bHasAmbiguousValue)
263 if( aValue == css::chart::ChartSymbolType::NONE )
274 aRet <<= getValueFromSeries( xInnerPropertySet );
279beans::PropertyState WrappedSymbolTypeProperty::getPropertyState(
const Reference< beans::XPropertyState >& xInnerPropertyState )
const
292 return beans::PropertyState_DIRECT_VALUE;
297WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty(
298 const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
300 : WrappedSeriesOrDiagramProperty<OUString>(
"SymbolBitmapURL",
301 uno::
Any(OUString()), spChart2ModelContact, ePropertyType)
305OUString WrappedSymbolBitmapURLProperty::getValueFromSeries(
const Reference< beans::XPropertySet >& )
const
310void WrappedSymbolBitmapURLProperty::setValueToSeries(
311 const Reference< beans::XPropertySet >& xSeriesPropertySet,
312 OUString
const & xNewGraphicURL)
const
314 if (!xSeriesPropertySet.is())
317 chart2::Symbol aSymbol;
318 if (xSeriesPropertySet->getPropertyValue(
"Symbol") >>= aSymbol)
320 if (!xNewGraphicURL.isEmpty())
324 xSeriesPropertySet->setPropertyValue(
"Symbol",
uno::Any(aSymbol));
329WrappedSymbolBitmapProperty::WrappedSymbolBitmapProperty(
330 const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
332 : WrappedSeriesOrDiagramProperty<
uno::
Reference<graphic::XGraphic>>(
"SymbolBitmap",
337uno::Reference<graphic::XGraphic> WrappedSymbolBitmapProperty::getValueFromSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet)
const
339 uno::Reference<graphic::XGraphic> xGraphic;
342 chart2::Symbol aSymbol;
343 if (xSeriesPropertySet.is() && (xSeriesPropertySet->getPropertyValue(
"Symbol") >>= aSymbol)
344 && aSymbol.Graphic.is())
346 xGraphic = aSymbol.Graphic;
351void WrappedSymbolBitmapProperty::setValueToSeries(
352 const Reference< beans::XPropertySet >& xSeriesPropertySet,
353 uno::Reference<graphic::XGraphic>
const & xNewGraphic)
const
355 if (!xSeriesPropertySet.is())
358 chart2::Symbol aSymbol;
359 if (xSeriesPropertySet->getPropertyValue(
"Symbol") >>= aSymbol)
361 if (xNewGraphic.is())
363 aSymbol.Graphic.set(xNewGraphic);
364 xSeriesPropertySet->setPropertyValue(
"Symbol",
uno::Any(aSymbol));
372void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol )
374 if( rSymbol.Style != chart2::SymbolStyle_GRAPHIC )
376 if( rSymbol.Size.Width != -1 )
378 if( rSymbol.Size.Height != -1 )
384 const awt::Size aDefaultSize(250,250);
385 awt::Size aSize = aDefaultSize;
386 uno::Reference< beans::XPropertySet > xProp( rSymbol.Graphic, uno::UNO_QUERY );
389 bool bFoundSize =
false;
392 if( xProp->getPropertyValue(
"Size100thMM" ) >>= aSize )
394 if( aSize.Width == 0 && aSize.Height == 0 )
395 aSize = aDefaultSize;
400 catch(
const uno::Exception& )
407 awt::Size aAWTPixelSize(10,10);
408 if( xProp->getPropertyValue(
"SizePixel" ) >>= aAWTPixelSize )
410 Size aPixelSize(aAWTPixelSize.Width,aAWTPixelSize.Height);
413 aSize = awt::Size( aNewSize.
Width(), aNewSize.
Height() );
415 if( aSize.Width == 0 && aSize.Height == 0 )
416 aSize = aDefaultSize;
420 rSymbol.Size = aSize;
422 catch(
const uno::Exception& )
430WrappedSymbolSizeProperty::WrappedSymbolSizeProperty(
431 const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
433 : WrappedSeriesOrDiagramProperty< awt::
Size >(
"SymbolSize"
434 ,
uno::
Any( awt::
Size(250,250) ), spChart2ModelContact, ePropertyType )
438awt::Size WrappedSymbolSizeProperty::getValueFromSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet )
const
442 chart2::Symbol aSymbol;
443 if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(
"Symbol") >>= aSymbol ))
448void WrappedSymbolSizeProperty::setValueToSeries(
449 const Reference< beans::XPropertySet >& xSeriesPropertySet,
450 const awt::Size& aNewSize )
const
452 if(!xSeriesPropertySet.is())
455 chart2::Symbol aSymbol;
456 if( xSeriesPropertySet->getPropertyValue(
"Symbol") >>= aSymbol )
458 aSymbol.Size = aNewSize;
459 lcl_correctSymbolSizeForBitmaps(aSymbol);
460 xSeriesPropertySet->setPropertyValue(
"Symbol",
uno::Any( aSymbol ) );
464beans::PropertyState WrappedSymbolSizeProperty::getPropertyState(
const Reference< beans::XPropertyState >& xInnerPropertyState )
const
467 if( m_ePropertyType ==
DIAGRAM )
468 return beans::PropertyState_DEFAULT_VALUE;
472 chart2::Symbol aSymbol;
473 Reference< beans::XPropertySet > xSeriesPropertySet( xInnerPropertyState, uno::UNO_QUERY );
474 if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(
"Symbol") >>= aSymbol ))
476 if( aSymbol.Style != chart2::SymbolStyle_NONE )
477 return beans::PropertyState_DIRECT_VALUE;
480 catch(
const uno::Exception & )
484 return beans::PropertyState_DEFAULT_VALUE;
487WrappedSymbolAndLinesProperty::WrappedSymbolAndLinesProperty(
488 const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
490 : WrappedSeriesOrDiagramProperty< bool >(
"Lines"
491 ,
uno::
Any( true ), spChart2ModelContact, ePropertyType )
495bool WrappedSymbolAndLinesProperty::getValueFromSeries(
const Reference< beans::XPropertySet >& )
const
501void WrappedSymbolAndLinesProperty::setValueToSeries(
502 const Reference< beans::XPropertySet >& xSeriesPropertySet,
503 const bool& bDrawLines )
const
505 if(!xSeriesPropertySet.is())
508 drawing::LineStyle eOldLineStyle( drawing::LineStyle_SOLID );
509 xSeriesPropertySet->getPropertyValue(
"LineStyle" ) >>= eOldLineStyle;
513 if( eOldLineStyle == drawing::LineStyle_NONE )
514 xSeriesPropertySet->setPropertyValue(
"LineStyle",
uno::Any( drawing::LineStyle_SOLID ) );
518 if( eOldLineStyle != drawing::LineStyle_NONE )
519 xSeriesPropertySet->setPropertyValue(
"LineStyle",
uno::Any( drawing::LineStyle_NONE ) );
523beans::PropertyState WrappedSymbolAndLinesProperty::getPropertyState(
const Reference< beans::XPropertyState >& )
const
526 return beans::PropertyState_DEFAULT_VALUE;
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
css::uno::Any m_aDefaultValue
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static bool isSupportingSymbolProperties(const rtl::Reference< ::chart::ChartType > &xChartType, sal_Int32 nDimensionCount)
virtual css::beans::PropertyState getPropertyState(const css::uno::Reference< css::beans::XPropertyState > &xInnerPropertyState) const
static void addProperties(std::vector< css::beans::Property > &rOutProperties)
static void addWrappedPropertiesForSeries(std::vector< std::unique_ptr< WrappedProperty > > &rList, const std::shared_ptr< Chart2ModelContact > &spChart2ModelContact)
static void addWrappedPropertiesForDiagram(std::vector< std::unique_ptr< WrappedProperty > > &rList, const std::shared_ptr< Chart2ModelContact > &spChart2ModelContact)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
tSeriesOrDiagramPropertyType
@ FAST_PROPERTY_ID_START_CHART_SYMBOL_PROP
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
Graphic loadFromURL(OUString const &rURL, weld::Window *pParentWin)