27#include <com/sun/star/beans/PropertyAttribute.hpp>
34using ::com::sun::star::uno::Reference;
35using ::com::sun::star::beans::Property;
42class WrappedStockProperty :
public WrappedProperty
45 explicit WrappedStockProperty(
const OUString& rOuterName
46 , css::uno::Any aDefaultValue
47 , std::shared_ptr<Chart2ModelContact> spChart2ModelContact );
49 void setPropertyValue(
const css::uno::Any& rOuterValue,
const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet )
const override;
51 css::uno::Any getPropertyDefault(
const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState )
const override;
63WrappedStockProperty::WrappedStockProperty(
const OUString& rOuterName
64 , css::uno::Any aDefaultValue
65 , std::shared_ptr<Chart2ModelContact> spChart2ModelContact )
66 : WrappedProperty(rOuterName,OUString())
74 bool bNewValue =
false;
75 if( ! (rOuterValue >>= bNewValue) )
76 throw lang::IllegalArgumentException(
"stock properties require type sal_Bool",
nullptr, 0 );
82 if( !xChartDoc || !xDiagram )
84 sal_Int32 nDimension = xDiagram->getDimension();
89 Diagram::tTemplateWithServiceName aTemplateAndService =
90 xDiagram->getTemplate( xChartTypeManager );
93 getNewTemplate( bNewValue, aTemplateAndService.sServiceName, xChartTypeManager );
102 xTemplate->changeDiagram( xDiagram );
104 catch(
const uno::Exception & )
110css::uno::Any WrappedStockProperty::getPropertyDefault(
const css::uno::Reference< css::beans::XPropertyState >& )
const
117class WrappedVolumeProperty :
public WrappedStockProperty
120 explicit WrappedVolumeProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
122 css::uno::Any
getPropertyValue(
const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet )
const override;
129WrappedVolumeProperty::WrappedVolumeProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
130 : WrappedStockProperty(
"Volume",
uno::
Any(false) , spChart2ModelContact )
134css::uno::Any WrappedVolumeProperty::getPropertyValue(
const css::uno::Reference< css::beans::XPropertySet >& )
const
138 if( xDiagram.is() && xChartDoc.is() )
140 std::vector< rtl::Reference< DataSeries > > aSeriesVector =
141 xDiagram->getDataSeries();
142 if( !aSeriesVector.empty() )
145 Diagram::tTemplateWithServiceName aTemplateAndService =
146 xDiagram->getTemplate( xChartTypeManager );
148 if( aTemplateAndService.sServiceName ==
"com.sun.star.chart2.template.StockVolumeLowHighClose"
149 || aTemplateAndService.sServiceName ==
"com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
151 else if( !aTemplateAndService.sServiceName.isEmpty() || !
m_aOuterValue.hasValue() )
169 if( rCurrentTemplate ==
"com.sun.star.chart2.template.StockLowHighClose" )
170 xTemplate =
xFactory->createTemplate(
"com.sun.star.chart2.template.StockVolumeLowHighClose" );
171 else if( rCurrentTemplate ==
"com.sun.star.chart2.template.StockOpenLowHighClose" )
172 xTemplate =
xFactory->createTemplate(
"com.sun.star.chart2.template.StockVolumeOpenLowHighClose" );
176 if( rCurrentTemplate ==
"com.sun.star.chart2.template.StockVolumeLowHighClose" )
177 xTemplate =
xFactory->createTemplate(
"com.sun.star.chart2.template.StockLowHighClose" );
178 else if( rCurrentTemplate ==
"com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
179 xTemplate =
xFactory->createTemplate(
"com.sun.star.chart2.template.StockOpenLowHighClose" );
186class WrappedUpDownProperty :
public WrappedStockProperty
189 explicit WrappedUpDownProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
191 css::uno::Any
getPropertyValue(
const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet )
const override;
198WrappedUpDownProperty::WrappedUpDownProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
199 : WrappedStockProperty(
"UpDown",
uno::
Any(false) , spChart2ModelContact )
203css::uno::Any WrappedUpDownProperty::getPropertyValue(
const css::uno::Reference< css::beans::XPropertySet >& )
const
207 if( xDiagram.is() && xChartDoc.is() )
209 std::vector< rtl::Reference< DataSeries > > aSeriesVector =
210 xDiagram->getDataSeries();
211 if( !aSeriesVector.empty() )
214 Diagram::tTemplateWithServiceName aTemplateAndService =
215 xDiagram->getTemplate( xChartTypeManager );
217 if( aTemplateAndService.sServiceName ==
"com.sun.star.chart2.template.StockOpenLowHighClose"
218 || aTemplateAndService.sServiceName ==
"com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
220 else if( !aTemplateAndService.sServiceName.isEmpty() || !
m_aOuterValue.hasValue() )
233 if( rCurrentTemplate ==
"com.sun.star.chart2.template.StockLowHighClose" )
234 xTemplate =
xFactory->createTemplate(
"com.sun.star.chart2.template.StockOpenLowHighClose" );
235 else if( rCurrentTemplate ==
"com.sun.star.chart2.template.StockVolumeLowHighClose" )
236 xTemplate =
xFactory->createTemplate(
"com.sun.star.chart2.template.StockVolumeOpenLowHighClose" );
240 if( rCurrentTemplate ==
"com.sun.star.chart2.template.StockOpenLowHighClose" )
241 xTemplate =
xFactory->createTemplate(
"com.sun.star.chart2.template.StockLowHighClose" );
242 else if( rCurrentTemplate ==
"com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
243 xTemplate =
xFactory->createTemplate(
"com.sun.star.chart2.template.StockVolumeLowHighClose" );
254 , PROP_CHART_STOCK_UPDOWN
259void WrappedStockProperties::addProperties( std::vector< Property > & rOutProperties )
261 rOutProperties.emplace_back(
"Volume",
262 PROP_CHART_STOCK_VOLUME,
264 beans::PropertyAttribute::BOUND
265 | beans::PropertyAttribute::MAYBEDEFAULT
266 | beans::PropertyAttribute::MAYBEVOID );
267 rOutProperties.emplace_back(
"UpDown",
268 PROP_CHART_STOCK_UPDOWN,
270 beans::PropertyAttribute::BOUND
271 | beans::PropertyAttribute::MAYBEDEFAULT
272 | beans::PropertyAttribute::MAYBEVOID );
275void WrappedStockProperties::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
276 ,
const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
278 rList.emplace_back(
new WrappedVolumeProperty( spChart2ModelContact ) );
279 rList.emplace_back(
new WrappedUpDownProperty( spChart2ModelContact ) );
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
css::uno::Any m_aOuterValue
css::uno::Any m_aDefaultValue
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XSingleServiceFactory > xFactory
void setPropertyValue(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Set a property to a certain value in the given map.
@ FAST_PROPERTY_ID_START_CHART_STOCK_PROP
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)