28#include <com/sun/star/chart/XChartDocument.hpp>
34#include <osl/diagnose.h>
37using ::com::sun::star::uno::Reference;
38using ::com::sun::star::uno::Sequence;
39using ::com::sun::star::chart2::XAnyDescriptionAccess;
40using ::com::sun::star::chart::XComplexDescriptionAccess;
41using ::com::sun::star::chart::XChartData;
42using ::com::sun::star::chart::XChartDataArray;
43using ::com::sun::star::chart::XDateCategories;
48uno::Sequence< uno::Sequence< double > > lcl_getNANInsteadDBL_MIN(
const uno::Sequence< uno::Sequence< double > >& rData )
50 uno::Sequence< uno::Sequence< double > > aRet;
51 const sal_Int32 nOuterSize = rData.getLength();
52 aRet.realloc( nOuterSize );
53 auto pRet = aRet.getArray();
54 for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter )
56 sal_Int32 nInnerSize = rData[nOuter].getLength();
57 pRet[nOuter].realloc( nInnerSize );
58 auto pRet_nOuter = pRet[nOuter].getArray();
59 for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner )
61 pRet_nOuter[nInner] = rData[nOuter][nInner];
62 double& rValue = pRet_nOuter[nInner];
63 if( rValue == DBL_MIN )
64 rValue = std::numeric_limits<double>::quiet_NaN();
70uno::Sequence< uno::Sequence< double > > lcl_getDBL_MINInsteadNAN(
const uno::Sequence< uno::Sequence< double > >& rData )
72 uno::Sequence< uno::Sequence< double > > aRet;
73 const sal_Int32 nOuterSize = rData.getLength();
74 aRet.realloc( nOuterSize );
75 auto pRet = aRet.getArray();
76 for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter )
78 sal_Int32 nInnerSize = rData[nOuter].getLength();
79 pRet[nOuter].realloc( nInnerSize );
80 auto pRet_nOuter = pRet[nOuter].getArray();
81 for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner )
83 pRet_nOuter[nInner] = rData[nOuter][nInner];
84 double& rValue = pRet_nOuter[nInner];
85 if( std::isnan( rValue ) )
115struct lcl_AllOperator :
public lcl_Operator
122 virtual bool setsCategories(
bool )
override
127 virtual void apply(
const Reference< XAnyDescriptionAccess >& xDataAccess )
override
129 if( !xDataAccess.is() )
132 Reference< XAnyDescriptionAccess > xNewAny(
m_xDataToApply, uno::UNO_QUERY );
133 Reference< XComplexDescriptionAccess > xNewComplex(
m_xDataToApply, uno::UNO_QUERY );
136 xDataAccess->setData( xNewAny->getData() );
137 xDataAccess->setComplexRowDescriptions( xNewAny->getComplexRowDescriptions() );
138 xDataAccess->setComplexColumnDescriptions( xNewAny->getComplexColumnDescriptions() );
140 else if( xNewComplex.is() )
142 xDataAccess->setData( xNewComplex->getData() );
143 xDataAccess->setComplexRowDescriptions( xNewComplex->getComplexRowDescriptions() );
144 xDataAccess->setComplexColumnDescriptions( xNewComplex->getComplexColumnDescriptions() );
148 Reference< XChartDataArray > xNew(
m_xDataToApply, uno::UNO_QUERY );
151 xDataAccess->setData( xNew->getData() );
152 xDataAccess->setRowDescriptions( xNew->getRowDescriptions() );
153 xDataAccess->setColumnDescriptions( xNew->getColumnDescriptions() );
161struct lcl_DataOperator :
public lcl_Operator
163 explicit lcl_DataOperator(
const Sequence< Sequence< double > >& rData )
168 virtual void apply(
const Reference< XAnyDescriptionAccess >& xDataAccess )
override
170 if( xDataAccess.is() )
171 xDataAccess->setData( lcl_getNANInsteadDBL_MIN(
m_rData ) );
174 const Sequence< Sequence< double > >&
m_rData;
177struct lcl_RowDescriptionsOperator :
public lcl_Operator
179 lcl_RowDescriptionsOperator(
const Sequence< OUString >& rRowDescriptions
187 virtual bool setsCategories(
bool bDataInColumns )
override
190 return bDataInColumns;
193 virtual void apply(
const Reference< XAnyDescriptionAccess >& xDataAccess )
override
195 if( xDataAccess.is() )
208struct lcl_ComplexRowDescriptionsOperator :
public lcl_Operator
210 lcl_ComplexRowDescriptionsOperator(
const Sequence< Sequence< OUString > >& rComplexRowDescriptions
218 virtual bool setsCategories(
bool bDataInColumns )
override
221 return bDataInColumns;
224 virtual void apply(
const Reference< XAnyDescriptionAccess >& xDataAccess )
override
226 if( xDataAccess.is() )
239struct lcl_AnyRowDescriptionsOperator :
public lcl_Operator
241 explicit lcl_AnyRowDescriptionsOperator(
const Sequence< Sequence< uno::Any > >& rAnyRowDescriptions )
246 virtual bool setsCategories(
bool bDataInColumns )
override
248 return bDataInColumns;
251 virtual void apply(
const Reference< XAnyDescriptionAccess >& xDataAccess )
override
253 if( xDataAccess.is() )
260struct lcl_ColumnDescriptionsOperator :
public lcl_Operator
262 lcl_ColumnDescriptionsOperator(
const Sequence< OUString >& rColumnDescriptions
270 virtual bool setsCategories(
bool bDataInColumns )
override
273 return !bDataInColumns;
276 virtual void apply(
const Reference< XAnyDescriptionAccess >& xDataAccess )
override
278 if( xDataAccess.is() )
291struct lcl_ComplexColumnDescriptionsOperator :
public lcl_Operator
293 lcl_ComplexColumnDescriptionsOperator(
const Sequence< Sequence< OUString > >& rComplexColumnDescriptions
301 virtual bool setsCategories(
bool bDataInColumns )
override
304 return !bDataInColumns;
307 virtual void apply(
const Reference< XAnyDescriptionAccess >& xDataAccess )
override
309 if( xDataAccess.is() )
322struct lcl_AnyColumnDescriptionsOperator :
public lcl_Operator
324 explicit lcl_AnyColumnDescriptionsOperator(
const Sequence< Sequence< uno::Any > >& rAnyColumnDescriptions )
329 virtual bool setsCategories(
bool bDataInColumns )
override
331 return bDataInColumns;
334 virtual void apply(
const Reference< XAnyDescriptionAccess >& xDataAccess )
override
336 if( xDataAccess.is() )
343struct lcl_DateCategoriesOperator :
public lcl_Operator
345 explicit lcl_DateCategoriesOperator(
const Sequence< double >& rDates )
350 virtual bool setsCategories(
bool )
override
355 virtual void apply(
const Reference< XAnyDescriptionAccess >& xDataAccess )
override
357 Reference< XDateCategories > xDateCategories( xDataAccess, uno::UNO_QUERY );
358 if( xDateCategories.is() )
359 xDateCategories->setDateCategories(
m_rDates );
379 osl_atomic_increment( &m_refCount );
380 lcl_AllOperator aOperator( xNewData );
382 osl_atomic_decrement( &m_refCount );
454 if( xDateCategories.is() )
455 return xDateCategories->getDateCategories();
462 lcl_DataOperator aOperator( rData );
472 lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions,
m_spChart2ModelContact->getDocumentModel() );
479 lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions,
m_spChart2ModelContact->getDocumentModel() );
484 lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions,
m_spChart2ModelContact->getDocumentModel() );
491 lcl_AnyRowDescriptionsOperator aOperator( rRowDescriptions );
496 lcl_AnyColumnDescriptionsOperator aOperator( rColumnDescriptions );
505 lcl_DateCategoriesOperator aOperator( rDates );
532 return nNumber == DBL_MIN
533 || std::isnan( nNumber )
534 || std::isinf( nNumber );
571 OSL_ASSERT( xSrc.is());
580 cl->chartDataChanged(
aEvent);
589 xChartDoc->createInternalDataProvider(
true );
596 if( !xChartDoc.is() )
598 if( xChartDoc->hasInternalDataProvider() )
599 m_xDataAccess.set( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
613 if( !xChartDoc.is() )
617 bool bStacked =
false;
618 bool bPercent =
false;
621 OSL_ASSERT( xOldDoc.is());
625 xDiaProp->getPropertyValue(
"Stacked") >>= bStacked;
626 xDiaProp->getPropertyValue(
"Percent") >>= bPercent;
627 xDiaProp->getPropertyValue(
"Deep") >>= bDeep;
631 OUString aRangeString;
632 bool bUseColumns =
true;
633 bool bFirstCellAsLabel =
true;
634 bool bHasCategories =
true;
639 aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
641 if( !bHasCategories && rDataOperator.
setsCategories( bUseColumns ) )
642 bHasCategories =
true;
644 aRangeString =
"all";
646 aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ) );
655 OSL_ASSERT( xDataProvider.is() );
656 if( !xDataProvider.is() )
665 if( bStacked || bPercent || bDeep )
672 xDia->setStackMode( eStackMode );
676 css::chart::ChartDataChangeEvent
aEvent(
678 css::chart::ChartDataChangeType_ALL, 0, 0, 0, 0 );
685 return "com.sun.star.comp.chart.ChartData";
696 "com.sun.star.chart.ChartDataArray",
697 "com.sun.star.chart.ChartData"
const Sequence< Sequence< uno::Any > > & m_rAnyRowDescriptions
const Sequence< OUString > & m_rRowDescriptions
rtl::Reference<::chart::ChartModel > m_xChartDoc
const Sequence< OUString > & m_rColumnDescriptions
const Sequence< Sequence< OUString > > & m_rComplexColumnDescriptions
Reference< XChartData > m_xDataToApply
const Sequence< Sequence< uno::Any > > & m_rAnyColumnDescriptions
const Sequence< Sequence< OUString > > & m_rComplexRowDescriptions
const Sequence< Sequence< double > > & m_rData
const Sequence< double > & m_rDates
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
static rtl::Reference< InternalDataProvider > createInternalDataProvider(const rtl::Reference<::chart::ChartModel > &xChartDoc, bool bConnectToModel)
This guard calls lockControllers at the given Model in the CTOR and unlockControllers in the DTOR.
static bool detectRangeSegmentation(const rtl::Reference<::chart::ChartModel > &xChartModel, OUString &rOutRangeString, css::uno::Sequence< sal_Int32 > &rSequenceMapping, bool &rOutUseColumns, bool &rOutFirstCellAsLabel, bool &rOutHasCategories)
static css::uno::Sequence< css::beans::PropertyValue > createArguments(bool bUseColumns, bool bFirstCellAsLabel, bool bHasCategories)
static void switchToDateCategories(const rtl::Reference<::chart::ChartModel > &xChartDoc)
static void switchToTextCategories(const rtl::Reference<::chart::ChartModel > &xChartDoc)
virtual double SAL_CALL getNotANumber() override
virtual void SAL_CALL setAnyColumnDescriptions(const css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &aColumnDescriptions) override
virtual void SAL_CALL setDateCategories(const css::uno::Sequence< double > &rDates) override
virtual sal_Bool SAL_CALL isNotANumber(double nNumber) override
virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL getAnyRowDescriptions() override
virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL getAnyColumnDescriptions() override
css::uno::Reference< css::chart2::XAnyDescriptionAccess > m_xDataAccess
void fireChartDataChangeEvent(css::chart::ChartDataChangeEvent &aEvent)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
ChartDataWrapper(std::shared_ptr< Chart2ModelContact > spChart2ModelContact)
virtual void SAL_CALL setColumnDescriptions(const css::uno::Sequence< OUString > &aColumnDescriptions) override
virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions() override
void applyData(lcl_Operator &rDataOperator)
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL dispose() override
virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData() override
virtual css::uno::Sequence< double > SAL_CALL getDateCategories() override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Sequence< OUString > SAL_CALL getColumnDescriptions() override
virtual void SAL_CALL addChartDataChangeEventListener(const css::uno::Reference< css::chart::XChartDataChangeEventListener > &aListener) override
virtual void SAL_CALL setAnyRowDescriptions(const css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &aRowDescriptions) override
virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL getComplexColumnDescriptions() override
void switchToInternalDataProvider()
virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL getComplexRowDescriptions() override
virtual void SAL_CALL setRowDescriptions(const css::uno::Sequence< OUString > &aRowDescriptions) override
virtual ~ChartDataWrapper() override
virtual void SAL_CALL setComplexRowDescriptions(const css::uno::Sequence< css::uno::Sequence< OUString > > &aRowDescriptions) override
::comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aEventListenerContainer
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo declarations.
virtual void SAL_CALL setData(const css::uno::Sequence< css::uno::Sequence< double > > &aData) override
virtual void SAL_CALL removeChartDataChangeEventListener(const css::uno::Reference< css::chart::XChartDataChangeEventListener > &aListener) override
virtual void SAL_CALL setComplexColumnDescriptions(const css::uno::Sequence< css::uno::Sequence< OUString > > &aColumnDescriptions) override
void forEach(std::unique_lock< std::mutex > &rGuard, FuncT const &func) const
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 getLength(std::unique_lock< std::mutex > &rGuard) const
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
Sequence< PropertyValue > aArguments
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual void apply(const Reference< XAnyDescriptionAccess > &xDataAccess)=0
virtual bool setsCategories(bool)