14#include <com/sun/star/chart/ChartDataChangeEvent.hpp>
15#include <com/sun/star/chart/XChartData.hpp>
16#include <com/sun/star/chart/XChartDataArray.hpp>
17#include <com/sun/star/chart/XChartDataChangeEventListener.hpp>
18#include <com/sun/star/lang/EventObject.hpp>
20#include <cppunit/TestAssert.h>
28class MockedChartDataChangeEventListener
29 :
public ::cppu::WeakImplHelper<chart::XChartDataChangeEventListener>
32 MockedChartDataChangeEventListener()
38 virtual void SAL_CALL chartDataChanged(
const chart::ChartDataChangeEvent& )
override
43 virtual void SAL_CALL disposing(
const lang::EventObject& )
override {}
49 uno::Reference<chart::XChartData> xCD(
init(), uno::UNO_QUERY_THROW);
50 const double fNaN = xCD->getNotANumber();
52 CPPUNIT_ASSERT(fNaN != 1.0);
57 uno::Reference<chart::XChartData> xCD(
init(), uno::UNO_QUERY_THROW);
58 const double fNaN = xCD->getNotANumber();
59 CPPUNIT_ASSERT(xCD->isNotANumber(fNaN));
60 CPPUNIT_ASSERT(!xCD->isNotANumber(fNaN + 1.0));
65 uno::Reference<chart::XChartData> xCD(
init(), uno::UNO_QUERY_THROW);
68 =
new MockedChartDataChangeEventListener();
69 xCD->addChartDataChangeEventListener(
70 uno::Reference<chart::XChartDataChangeEventListener>(pListener0));
72 =
new MockedChartDataChangeEventListener();
73 xCD->addChartDataChangeEventListener(
74 uno::Reference<chart::XChartDataChangeEventListener>(pListener1));
76 uno::Reference<chart::XChartDataArray> xCDD(xCD, uno::UNO_QUERY_THROW);
77 uno::Sequence<uno::Sequence<double>>
aData = xCDD->getData();
78 auto& rFirstCell =
aData.getArray()[0].getArray()[0];
81 CPPUNIT_ASSERT(pListener0->m_bListenerCalled);
82 CPPUNIT_ASSERT(pListener1->m_bListenerCalled);
84 pListener0->m_bListenerCalled =
false;
85 pListener1->m_bListenerCalled =
false;
87 xCD->removeChartDataChangeEventListener(
88 uno::Reference<chart::XChartDataChangeEventListener>(pListener1));
91 CPPUNIT_ASSERT(pListener0->m_bListenerCalled);
92 CPPUNIT_ASSERT(!pListener1->m_bListenerCalled);
void testChartDataChangeEventListener()
virtual css::uno::Reference< css::uno::XInterface > init()=0
constexpr OUStringLiteral aData