30#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
31#include <com/sun/star/container/NoSuchElementException.hpp>
32#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
36#include <rtl/ustrbuf.hxx>
44using ::com::sun::star::beans::Property;
45using ::com::sun::star::uno::Sequence;
46using ::com::sun::star::uno::Reference;
47using ::osl::MutexGuard;
58 float fDefaultCharHeight = 10.0;
64 return aStaticDefaults;
73 static ::cppu::OPropertyArrayHelper oHelper = []()
89 const uno::Reference< uno::XInterface > & xChildInterface,
90 const uno::Reference< uno::XInterface > & xParentInterface )
92 uno::Reference< container::XChild > xChild( xChildInterface, uno::UNO_QUERY );
94 xChild->setParent( xParentInterface );
97typedef std::map< sal_Int32, css::uno::Reference< css::beans::XPropertySet > >
100void lcl_CloneAttributedDataPoints(
101 const lcl_tDataPointMap & rSource, lcl_tDataPointMap & rDestination,
102 const uno::Reference< uno::XInterface > & xSeries )
104 for (
auto const& elem : rSource)
106 Reference< beans::XPropertySet > xPoint( elem.second );
109 Reference< util::XCloneable > xCloneable( xPoint, uno::UNO_QUERY );
112 xPoint.set( xCloneable->createClone(), uno::UNO_QUERY );
115 lcl_SetParent( xPoint, xSeries );
116 rDestination.emplace( elem.first, xPoint );
152 if( ( aValue >>= xPropertySet )
153 && xPropertySet.is())
157 if( ( aValue >>= xPropertySet )
158 && xPropertySet.is())
168 lcl_CloneAttributedDataPoints(
178 if( ( aValue >>= xPropertySet )
179 && xPropertySet.is())
180 lcl_SetParent( xPropertySet, xThisInterface );
183 if( ( aValue >>= xPropertySet )
184 && xPropertySet.is())
185 lcl_SetParent( xPropertySet, xThisInterface );
201 if( ( aValue >>= xPropertySet )
202 && xPropertySet.is())
206 if( ( aValue >>= xPropertySet )
207 && xPropertySet.is())
210 catch(
const uno::Exception & )
221 pNewSeries->Init( *
this );
230 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find(
nHandle ) );
231 if( aFound == rStaticDefaults.end() )
234 rDest = (*aFound).second;
240 return StaticDataSeriesInfoHelper();
253 sal_Int32 nHandle )
const
263 OPropertySet::getFastPropertyValue( rValue,
nHandle );
267 sal_Int32 nHandle,
const uno::Any& rValue )
276 (aOldValue >>= xBroadcaster) &&
282 OSL_ASSERT( rValue.getValueType().getTypeClass() == uno::TypeClass_INTERFACE );
284 (rValue >>= xBroadcaster) &&
299 std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences;
305 std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValuesSeries(
308 if (aValuesSeries.empty())
309 throw lang::IndexOutOfBoundsException();
318 xResult = (*aIt).second;
326 xParentProperties =
this;
331 xResult.set(
new DataPoint( xParentProperties ) );
353 xDataPointProp = (*aIt).second;
358 if( xDataPointProp.is() )
361 if( xBroadcaster.is() && xModifyEventForwarder.is())
362 xBroadcaster->removeModifyListener( xModifyEventForwarder );
377 aOldAttributedDataPoints.clear();
391 for (
const auto & i : aData)
393 aNewDataSequences.push_back(i);
402void DataSeries::setData(
const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > >& aData )
406 Reference< util::XModifyListener > xModifyEventForwarder;
411 aNewDataSequences =
aData;
423 return comphelper::containerToSequence<Reference< chart2::data::XLabeledDataSequence >>(
m_aDataSequences );
431 assert(pRegressionCurve);
438 throw lang::IllegalArgumentException(
"curve not found",
static_cast<cppu::OWeakObject*
>(
this), 1);
448 if( !xRegressionCurve.is() )
449 throw container::NoSuchElementException();
451 assert(pRegressionCurve);
457 tRegressionCurveContainerType::iterator aIt(
460 throw container::NoSuchElementException(
461 "The given regression curve is no element of this series",
462 static_cast< uno::XWeak *
>(
this ));
473 return comphelper::containerToSequence<uno::Reference< chart2::XRegressionCurve >>(
m_aRegressionCurves );
481 for (
const auto &
i : aRegressionCurves)
484 assert(pRegressionCurve);
485 aNewCurves.push_back(pRegressionCurve);
533using ::property::OPropertySet;
541 return "com.sun.star.comp.chart.DataSeries";
552 "com.sun.star.chart2.DataSeries",
553 "com.sun.star.chart2.DataPointProperties",
554 "com.sun.star.beans.PropertySet" };
562 for(
auto const & labeledData : rDataSequences )
564 OSL_ENSURE( labeledData.is(),
"empty LabeledDataSequence" );
566 if( labeledData.is() &&
567 ( ! labeledData->getValues().is() &&
568 labeledData->getLabel().is()))
570 xResult.set( labeledData );
587 const sal_Int32 nMax =
aSeq.getLength() - 1;
590 for( sal_Int32
i = 0;
i <= nMax; ++
i )
596 aResult =
aBuf.makeStringAndClear();
598 else if( xSequence.is())
602 const sal_Int32 nMax =
aSeq.getLength() - 1;
607 for( sal_Int32
i = 0;
i <= nMax; ++
i )
609 if(
aSeq[
i] >>= aVal )
615 else if(
aSeq[
i ] >>= fNum )
622 aResult =
aBuf.makeStringAndClear();
632 if( xLabeledSeq.is())
637 if( !xSeq.is() || aResult.isEmpty() )
644 chart2::data::LabelOrigin_SHORT_SIDE ) );
647 if( aLabels.hasElements() )
669 if( xLabeledSeq.is())
676 if( xLabeledSeq.is())
689 if (!xDataSequence.is())
697 xProp->getPropertyValue(
"HiddenValues" ) >>= aHiddenValues;
698 if( !aHiddenValues.hasElements() )
701 catch(
const uno::Exception& )
706 return xDataSequence->getData().hasElements();
715 if( !rDataSequence.is() )
726extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
728 css::uno::Sequence<css::uno::Any>
const &)
730 return cppu::acquire(new ::chart::DataSeries );
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_chart_DataSeries_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
PropertiesInfo aProperties
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
The same as getFastPropertyValue, but return the value through rValue and nHandle is always valid.
std::vector< rtl::Reference< ::chart::RegressionCurveModel > > tRegressionCurveContainerType
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
virtual void SAL_CALL setData(const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > &aData) override
virtual void SAL_CALL resetAllDataPoints() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL removeRegressionCurve(const css::uno::Reference< css::chart2::XRegressionCurve > &aRegressionCurve) override
virtual void SAL_CALL resetDataPoint(sal_Int32 nIndex) override
tDataSequenceContainer m_aDataSequences
std::map< sal_Int32, css::uno::Reference< css::beans::XPropertySet > > tDataPointAttributeContainer
virtual void SAL_CALL addRegressionCurve(const css::uno::Reference< css::chart2::XRegressionCurve > &aRegressionCurve) override
OUString getLabelForRole(const OUString &rLabelSequenceRole)
Get the label of a series (e.g.
virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any &rAny) const override
implement this method to provide default values for all properties supporting defaults.
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
The InfoHelper table contains all property names and types of this object.
rtl::Reference< ModifyEventForwarder > m_xModifyEventForwarder
tRegressionCurveContainerType m_aRegressionCurves
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
void Init(const DataSeries &rOther)
virtual css::uno::Sequence< css::uno::Reference< css::chart2::XRegressionCurve > > SAL_CALL getRegressionCurves() override
std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > tDataSequenceContainer
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getDataPointByIndex(sal_Int32 nIndex) override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
The same as setFastPropertyValue; nHandle is always valid.
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
virtual void SAL_CALL setRegressionCurves(const css::uno::Sequence< css::uno::Reference< css::chart2::XRegressionCurve > > &aRegressionCurves) override
virtual css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences() override
tDataPointAttributeContainer m_aAttributedDataPoints
virtual ~DataSeries() override
virtual void firePropertyChangeEvent() override
implement this method in derived classes to get called when properties change.
This helper class serves as forwarder of modify events.
mutable::osl::Mutex m_aMutex
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
void SAL_CALL disposing()
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
The same as setFastPropertyValue; nHandle is always valid.
#define DBG_UNHANDLED_EXCEPTION(...)
Sequence< sal_Int8 > aSeq
constexpr OUStringLiteral aData
double getLength(const B2DPolygon &rCandidate)
OOO_DLLPUBLIC_CHARTTOOLS void AddDefaultsToMap(::chart::tPropertyValueMap &rOutMap)
@ PROP_CHAR_COMPLEX_CHAR_HEIGHT
@ PROP_CHAR_ASIAN_CHAR_HEIGHT
OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector(std::vector< css::beans::Property > &rOutProperties)
void CloneRefVector(const std::vector< css::uno::Reference< Interface > > &rSource, std::vector< css::uno::Reference< Interface > > &rDestination)
clones a vector of UNO-References
@ PROP_DATAPOINT_ERROR_BAR_Y
@ PROP_DATAPOINT_ERROR_BAR_X
OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XLabeledDataSequence > getDataSequenceByRole(const css::uno::Reference< css::chart2::data::XDataSource > &xSource, const OUString &aRole, bool bMatchPrefix=false)
Retrieves the data sequence in the given data source that matches the given role.
OOO_DLLPUBLIC_CHARTTOOLS std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > getAllDataSequencesByRole(const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > &aDataSequences, const OUString &aRole)
Retrieves all data sequences in the given data source that match the given role prefix.
@ PROP_DATASERIES_ATTRIBUTED_DATA_POINTS
void addListenerToAllMapElements(const Container &rContainer, const css::uno::Reference< css::util::XModifyListener > &xListener)
void removeListener(const InterfaceRef &xObject, const css::uno::Reference< css::util::XModifyListener > &xListener)
void removeListenerFromAllElements(const Container &rContainer, const css::uno::Reference< css::util::XModifyListener > &xListener)
void addListenerToAllElements(const Container &rContainer, const css::uno::Reference< css::util::XModifyListener > &xListener)
void addListener(const InterfaceRef &xObject, const css::uno::Reference< css::util::XModifyListener > &xListener)
void removeListenerFromAllMapElements(const Container &rContainer, const css::uno::Reference< css::util::XModifyListener > &xListener)
void setPropertyValue(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Set a property to a certain value in the given map.
::cppu::WeakImplHelper< css::chart2::XDataSeries, css::chart2::data::XDataSink, css::chart2::data::XDataSource, css::lang::XServiceInfo, css::chart2::XRegressionCurveContainer, css::util::XCloneable, css::util::XModifyBroadcaster, css::util::XModifyListener > DataSeries_Base
std::unordered_map< tPropertyValueMapKey, css::uno::Any > tPropertyValueMap
static Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel(const Sequence< Reference< chart2::data::XLabeledDataSequence > > &rDataSequences)
static bool lcl_SequenceHasUnhiddenData(const uno::Reference< chart2::data::XDataSequence > &xDataSequence)
static OUString lcl_getDataSequenceLabel(const Reference< chart2::data::XDataSequence > &xSequence)
OOO_DLLPUBLIC_CHARTTOOLS const tPropertyValueMap & StaticDataSeriesDefaults()
static OUString getLabelForLabeledDataSequence(const Reference< chart2::data::XLabeledDataSequence > &xLabeledSeq)
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
HashMap_OWString_Interface aMap