tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / controller / chartapiwrapper / ChartDataWrapper.cxx
blob18be04d358dee38398a3df418d7b7de4100b6ad7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "ChartDataWrapper.hxx"
21 #include <DiagramHelper.hxx>
22 #include <DataSourceHelper.hxx>
23 #include <ChartModelHelper.hxx>
24 #include <InternalDataProvider.hxx>
25 #include <ControllerLockGuard.hxx>
26 #include "Chart2ModelContact.hxx"
27 #include <cppuhelper/supportsservice.hxx>
28 #include <com/sun/star/chart/XChartDocument.hpp>
30 #include <float.h>
31 #include <cmath>
32 #include <limits>
33 #include <utility>
34 #include <osl/diagnose.h>
36 using namespace ::com::sun::star;
37 using ::com::sun::star::uno::Reference;
38 using ::com::sun::star::uno::Sequence;
39 using ::com::sun::star::chart2::XAnyDescriptionAccess;
40 using ::com::sun::star::chart::XComplexDescriptionAccess;
41 using ::com::sun::star::chart::XChartData;
42 using ::com::sun::star::chart::XChartDataArray;
43 using ::com::sun::star::chart::XDateCategories;
45 namespace
48 uno::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();
67 return aRet;
70 uno::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 ) )
86 rValue = DBL_MIN;
89 return aRet;
92 } // anonymous namespace
94 namespace chart::wrapper
97 struct lcl_Operator
99 lcl_Operator()
102 virtual ~lcl_Operator()
105 virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) = 0;
107 virtual bool setsCategories( bool /*bDataInColumns*/ )
109 return false;
113 namespace {
115 struct lcl_AllOperator : public lcl_Operator
117 explicit lcl_AllOperator( const Reference< XChartData >& xDataToApply )
118 : m_xDataToApply( xDataToApply )
122 virtual bool setsCategories( bool /*bDataInColumns*/ ) override
124 // Do not force creation of categories, when original has no categories
125 if (auto pDataWrapper = dynamic_cast<const ChartDataWrapper*>(m_xDataToApply.get()))
126 if (auto xChartModel = pDataWrapper->getChartModel())
127 if (auto xDiagram = xChartModel->getFirstChartDiagram())
128 return xDiagram->getCategories().is();
129 return true;
132 virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
134 if( !xDataAccess.is() )
135 return;
137 Reference< XAnyDescriptionAccess > xNewAny( m_xDataToApply, uno::UNO_QUERY );
138 Reference< XComplexDescriptionAccess > xNewComplex( m_xDataToApply, uno::UNO_QUERY );
139 if( xNewAny.is() )
141 xDataAccess->setData( xNewAny->getData() );
142 xDataAccess->setComplexRowDescriptions( xNewAny->getComplexRowDescriptions() );
143 xDataAccess->setComplexColumnDescriptions( xNewAny->getComplexColumnDescriptions() );
145 else if( xNewComplex.is() )
147 xDataAccess->setData( xNewComplex->getData() );
148 xDataAccess->setComplexRowDescriptions( xNewComplex->getComplexRowDescriptions() );
149 xDataAccess->setComplexColumnDescriptions( xNewComplex->getComplexColumnDescriptions() );
151 else
153 Reference< XChartDataArray > xNew( m_xDataToApply, uno::UNO_QUERY );
154 if( xNew.is() )
156 xDataAccess->setData( xNew->getData() );
157 xDataAccess->setRowDescriptions( xNew->getRowDescriptions() );
158 xDataAccess->setColumnDescriptions( xNew->getColumnDescriptions() );
163 Reference< XChartData > m_xDataToApply;
166 struct lcl_DataOperator : public lcl_Operator
168 explicit lcl_DataOperator( const Sequence< Sequence< double > >& rData )
169 : m_rData( rData )
173 virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
175 if( xDataAccess.is() )
176 xDataAccess->setData( lcl_getNANInsteadDBL_MIN( m_rData ) );
179 const Sequence< Sequence< double > >& m_rData;
182 struct lcl_RowDescriptionsOperator : public lcl_Operator
184 lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions
185 , rtl::Reference<::chart::ChartModel> xChartDoc )
186 : m_rRowDescriptions( rRowDescriptions )
187 , m_xChartDoc(std::move(xChartDoc))
188 , m_bDataInColumns(true)
192 virtual bool setsCategories( bool bDataInColumns ) override
194 m_bDataInColumns = bDataInColumns;
195 return bDataInColumns;
198 virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
200 if( xDataAccess.is() )
202 xDataAccess->setRowDescriptions( m_rRowDescriptions );
203 if( m_bDataInColumns )
204 DiagramHelper::switchToTextCategories( m_xChartDoc );
208 const Sequence< OUString >& m_rRowDescriptions;
209 rtl::Reference<::chart::ChartModel> m_xChartDoc;
210 bool m_bDataInColumns;
213 struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator
215 lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions
216 , rtl::Reference<::chart::ChartModel> xChartDoc )
217 : m_rComplexRowDescriptions( rComplexRowDescriptions )
218 , m_xChartDoc(std::move(xChartDoc))
219 , m_bDataInColumns(true)
223 virtual bool setsCategories( bool bDataInColumns ) override
225 m_bDataInColumns = bDataInColumns;
226 return bDataInColumns;
229 virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
231 if( xDataAccess.is() )
233 xDataAccess->setComplexRowDescriptions( m_rComplexRowDescriptions );
234 if( m_bDataInColumns )
235 DiagramHelper::switchToTextCategories( m_xChartDoc );
239 const Sequence< Sequence< OUString > >& m_rComplexRowDescriptions;
240 rtl::Reference<::chart::ChartModel> m_xChartDoc;
241 bool m_bDataInColumns;
244 struct lcl_AnyRowDescriptionsOperator : public lcl_Operator
246 explicit lcl_AnyRowDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyRowDescriptions )
247 : m_rAnyRowDescriptions( rAnyRowDescriptions )
251 virtual bool setsCategories( bool bDataInColumns ) override
253 return bDataInColumns;
256 virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
258 if( xDataAccess.is() )
259 xDataAccess->setAnyRowDescriptions( m_rAnyRowDescriptions );
262 const Sequence< Sequence< uno::Any > >& m_rAnyRowDescriptions;
265 struct lcl_ColumnDescriptionsOperator : public lcl_Operator
267 lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions
268 , rtl::Reference<::chart::ChartModel> xChartDoc )
269 : m_rColumnDescriptions( rColumnDescriptions )
270 , m_xChartDoc(std::move(xChartDoc))
271 , m_bDataInColumns(true)
275 virtual bool setsCategories( bool bDataInColumns ) override
277 m_bDataInColumns = bDataInColumns;
278 return !bDataInColumns;
281 virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
283 if( xDataAccess.is() )
285 xDataAccess->setColumnDescriptions( m_rColumnDescriptions );
286 if( !m_bDataInColumns )
287 DiagramHelper::switchToTextCategories( m_xChartDoc );
291 const Sequence< OUString >& m_rColumnDescriptions;
292 rtl::Reference<::chart::ChartModel> m_xChartDoc;
293 bool m_bDataInColumns;
296 struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator
298 lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions
299 , rtl::Reference<::chart::ChartModel> xChartDoc )
300 : m_rComplexColumnDescriptions( rComplexColumnDescriptions )
301 , m_xChartDoc(std::move(xChartDoc))
302 , m_bDataInColumns(true)
306 virtual bool setsCategories( bool bDataInColumns ) override
308 m_bDataInColumns = bDataInColumns;
309 return !bDataInColumns;
312 virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
314 if( xDataAccess.is() )
316 xDataAccess->setComplexColumnDescriptions( m_rComplexColumnDescriptions );
317 if( !m_bDataInColumns )
318 DiagramHelper::switchToTextCategories( m_xChartDoc );
322 const Sequence< Sequence< OUString > >& m_rComplexColumnDescriptions;
323 rtl::Reference<::chart::ChartModel> m_xChartDoc;
324 bool m_bDataInColumns;
327 struct lcl_AnyColumnDescriptionsOperator : public lcl_Operator
329 explicit lcl_AnyColumnDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyColumnDescriptions )
330 : m_rAnyColumnDescriptions( rAnyColumnDescriptions )
334 virtual bool setsCategories( bool bDataInColumns ) override
336 return bDataInColumns;
339 virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
341 if( xDataAccess.is() )
342 xDataAccess->setAnyColumnDescriptions( m_rAnyColumnDescriptions );
345 const Sequence< Sequence< uno::Any > >& m_rAnyColumnDescriptions;
348 struct lcl_DateCategoriesOperator : public lcl_Operator
350 explicit lcl_DateCategoriesOperator( const Sequence< double >& rDates )
351 : m_rDates( rDates )
355 virtual bool setsCategories( bool /*bDataInColumns*/ ) override
357 return true;
360 virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
362 Reference< XDateCategories > xDateCategories( xDataAccess, uno::UNO_QUERY );
363 if( xDateCategories.is() )
364 xDateCategories->setDateCategories( m_rDates );
367 const Sequence< double >& m_rDates;
372 ChartDataWrapper::ChartDataWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact)
373 : m_spChart2ModelContact(std::move(spChart2ModelContact))
375 osl_atomic_increment( &m_refCount );
376 initDataAccess();
377 osl_atomic_decrement( &m_refCount );
380 ChartDataWrapper::ChartDataWrapper( std::shared_ptr<Chart2ModelContact> spChart2ModelContact,
381 const Reference< XChartData >& xNewData ) :
382 m_spChart2ModelContact(std::move( spChart2ModelContact ))
384 osl_atomic_increment( &m_refCount );
385 lcl_AllOperator aOperator( xNewData );
386 applyData( aOperator );
387 osl_atomic_decrement( &m_refCount );
390 ChartDataWrapper::~ChartDataWrapper()
392 // @todo: implement XComponent and call this in dispose(). In the DTOR the
393 // ref-count is 0, thus creating a stack reference to this calls the DTOR at
394 // the end of the block recursively
395 // uno::Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
396 // m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
399 // ____ XChartDataArray (read)____
400 Sequence< Sequence< double > > SAL_CALL ChartDataWrapper::getData()
402 initDataAccess();
403 if( m_xDataAccess.is() )
404 return lcl_getDBL_MINInsteadNAN( m_xDataAccess->getData() );
405 return Sequence< Sequence< double > >();
407 Sequence< OUString > SAL_CALL ChartDataWrapper::getRowDescriptions()
409 initDataAccess();
410 if( m_xDataAccess.is() )
411 return m_xDataAccess->getRowDescriptions();
412 return Sequence< OUString >();
414 Sequence< OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions()
416 initDataAccess();
417 if( m_xDataAccess.is() )
418 return m_xDataAccess->getColumnDescriptions();
419 return Sequence< OUString > ();
422 // ____ XComplexDescriptionAccess (read) ____
423 Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexRowDescriptions()
425 initDataAccess();
426 if( m_xDataAccess.is() )
427 return m_xDataAccess->getComplexRowDescriptions();
428 return Sequence< Sequence< OUString > >();
430 Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexColumnDescriptions()
432 initDataAccess();
433 if( m_xDataAccess.is() )
434 return m_xDataAccess->getComplexColumnDescriptions();
435 return Sequence< Sequence< OUString > >();
438 // ____ XAnyDescriptionAccess (read) ____
439 Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyRowDescriptions()
441 initDataAccess();
442 if( m_xDataAccess.is() )
443 return m_xDataAccess->getAnyRowDescriptions();
444 return Sequence< Sequence< uno::Any > >();
446 Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyColumnDescriptions()
448 initDataAccess();
449 if( m_xDataAccess.is() )
450 return m_xDataAccess->getAnyColumnDescriptions();
451 return Sequence< Sequence< uno::Any > >();
454 // ____ XDateCategories (read) ____
455 Sequence< double > SAL_CALL ChartDataWrapper::getDateCategories()
457 initDataAccess();
458 Reference< XDateCategories > xDateCategories( m_xDataAccess, uno::UNO_QUERY );
459 if( xDateCategories.is() )
460 return xDateCategories->getDateCategories();
461 return Sequence< double >();
464 // ____ XChartDataArray (write)____
465 void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& rData )
467 lcl_DataOperator aOperator( rData );
468 applyData( aOperator );
470 void SAL_CALL ChartDataWrapper::setRowDescriptions( const Sequence< OUString >& rRowDescriptions )
472 lcl_RowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getDocumentModel() );
473 applyData( aOperator );
475 void SAL_CALL ChartDataWrapper::setColumnDescriptions( const Sequence< OUString >& rColumnDescriptions )
477 lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getDocumentModel() );
478 applyData( aOperator );
481 // ____ XComplexDescriptionAccess (write) ____
482 void SAL_CALL ChartDataWrapper::setComplexRowDescriptions( const Sequence< Sequence< OUString > >& rRowDescriptions )
484 lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getDocumentModel() );
485 applyData( aOperator );
487 void SAL_CALL ChartDataWrapper::setComplexColumnDescriptions( const Sequence< Sequence< OUString > >& rColumnDescriptions )
489 lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getDocumentModel() );
490 applyData( aOperator );
493 // ____ XAnyDescriptionAccess (write) ____
494 void SAL_CALL ChartDataWrapper::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& rRowDescriptions )
496 lcl_AnyRowDescriptionsOperator aOperator( rRowDescriptions );
497 applyData( aOperator );
499 void SAL_CALL ChartDataWrapper::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& rColumnDescriptions )
501 lcl_AnyColumnDescriptionsOperator aOperator( rColumnDescriptions );
502 applyData( aOperator );
505 // ____ XDateCategories (write) ____
506 void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& rDates )
508 rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() );
509 ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
510 lcl_DateCategoriesOperator aOperator( rDates );
511 applyData( aOperator );
512 DiagramHelper::switchToDateCategories( xChartDoc );
515 // ____ XChartData (base of XChartDataArray) ____
516 void SAL_CALL ChartDataWrapper::addChartDataChangeEventListener(
517 const uno::Reference< css::chart::XChartDataChangeEventListener >& aListener )
519 std::unique_lock g(m_aMutex);
520 m_aEventListenerContainer.addInterface( g, aListener );
523 void SAL_CALL ChartDataWrapper::removeChartDataChangeEventListener(
524 const uno::Reference< css::chart::XChartDataChangeEventListener >& aListener )
526 std::unique_lock g(m_aMutex);
527 m_aEventListenerContainer.removeInterface( g, aListener );
530 double SAL_CALL ChartDataWrapper::getNotANumber()
532 return DBL_MIN;
535 sal_Bool SAL_CALL ChartDataWrapper::isNotANumber( double nNumber )
537 return nNumber == DBL_MIN
538 || std::isnan( nNumber )
539 || std::isinf( nNumber );
542 // ____ XComponent ____
543 void SAL_CALL ChartDataWrapper::dispose()
545 std::unique_lock g(m_aMutex);
546 m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( static_cast< ::cppu::OWeakObject* >( this )));
547 m_xDataAccess=nullptr;
550 void SAL_CALL ChartDataWrapper::addEventListener(
551 const uno::Reference< lang::XEventListener > & xListener )
553 std::unique_lock g(m_aMutex);
554 m_aEventListenerContainer.addInterface( g, xListener );
557 void SAL_CALL ChartDataWrapper::removeEventListener(
558 const uno::Reference< lang::XEventListener >& aListener )
560 std::unique_lock g(m_aMutex);
561 m_aEventListenerContainer.removeInterface( g, aListener );
564 // ____ XEventListener ____
565 void SAL_CALL ChartDataWrapper::disposing( const lang::EventObject& /* Source */ )
569 void ChartDataWrapper::fireChartDataChangeEvent( css::chart::ChartDataChangeEvent& aEvent )
571 std::unique_lock g(m_aMutex);
572 if( ! m_aEventListenerContainer.getLength(g) )
573 return;
575 uno::Reference< uno::XInterface > xSrc( static_cast< cppu::OWeakObject* >( this ));
576 OSL_ASSERT( xSrc.is());
577 if( xSrc.is() )
578 aEvent.Source = std::move(xSrc);
580 m_aEventListenerContainer.forEach( g,
581 [&aEvent](const uno::Reference<css::lang::XEventListener>& l)
583 uno::Reference<css::chart::XChartDataChangeEventListener> cl(l, uno::UNO_QUERY);
584 if (cl)
585 cl->chartDataChanged(aEvent);
589 void ChartDataWrapper::switchToInternalDataProvider()
591 //create an internal data provider that is connected to the model
592 rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() );
593 if( xChartDoc.is() )
594 xChartDoc->createInternalDataProvider( true /*bCloneExistingData*/ );
595 initDataAccess();
598 void ChartDataWrapper::initDataAccess()
600 rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() );
601 if( !xChartDoc.is() )
602 return;
603 if( xChartDoc->hasInternalDataProvider() )
604 m_xDataAccess.set( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
605 else
607 //create a separate "internal data provider" that is not connected to the model
608 auto xInternal = ChartModelHelper::createInternalDataProvider(
609 xChartDoc, false /*bConnectToModel*/ );
610 m_xDataAccess.set( static_cast<cppu::OWeakObject*>(xInternal.get()), uno::UNO_QUERY_THROW );
614 void ChartDataWrapper::applyData( lcl_Operator& rDataOperator )
616 //bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions
617 rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() );
618 if( !xChartDoc.is() )
619 return;
621 // remember some diagram properties to reset later
622 bool bStacked = false;
623 bool bPercent = false;
624 bool bDeep = false;
625 uno::Reference< css::chart::XChartDocument > xOldDoc( static_cast<cppu::OWeakObject*>(xChartDoc.get()), uno::UNO_QUERY );
626 OSL_ASSERT( xOldDoc.is());
627 uno::Reference< beans::XPropertySet > xDiaProp( xOldDoc->getDiagram(), uno::UNO_QUERY );
628 if( xDiaProp.is())
630 xDiaProp->getPropertyValue(u"Stacked"_ustr) >>= bStacked;
631 xDiaProp->getPropertyValue(u"Percent"_ustr) >>= bPercent;
632 xDiaProp->getPropertyValue(u"Deep"_ustr) >>= bDeep;
635 //detect arguments for the new data source
636 OUString aRangeString;
637 bool bUseColumns = true;
638 bool bFirstCellAsLabel = true;
639 bool bHasCategories = true;
640 uno::Sequence< sal_Int32 > aSequenceMapping;
642 (void)DataSourceHelper::detectRangeSegmentation(
643 xChartDoc,
644 aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
646 if( !bHasCategories && rDataOperator.setsCategories( bUseColumns ) )
647 bHasCategories = true;
649 aRangeString = "all";
650 uno::Sequence< beans::PropertyValue > aArguments( DataSourceHelper::createArguments(
651 aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ) );
653 // -- locked controllers
654 ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
656 // create and attach new data source
657 switchToInternalDataProvider();
658 rDataOperator.apply(m_xDataAccess);
659 uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
660 OSL_ASSERT( xDataProvider.is() );
661 if( !xDataProvider.is() )
662 return;
663 uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) );
665 rtl::Reference< Diagram > xDia( xChartDoc->getFirstChartDiagram() );
666 if( xDia.is() )
667 xDia->setDiagramData( xSource, aArguments );
669 //correct stacking mode
670 if( bStacked || bPercent || bDeep )
672 StackMode eStackMode = StackMode::YStacked;
673 if( bDeep )
674 eStackMode = StackMode::ZStacked;
675 else if( bPercent )
676 eStackMode = StackMode::YStackedPercent;
677 xDia->setStackMode( eStackMode );
680 // notify listeners
681 css::chart::ChartDataChangeEvent aEvent(
682 static_cast< ::cppu::OWeakObject* >( this ),
683 css::chart::ChartDataChangeType_ALL, 0, 0, 0, 0 );
684 fireChartDataChangeEvent( aEvent );
685 // \-- locked controllers
688 OUString SAL_CALL ChartDataWrapper::getImplementationName()
690 return u"com.sun.star.comp.chart.ChartData"_ustr;
693 sal_Bool SAL_CALL ChartDataWrapper::supportsService( const OUString& rServiceName )
695 return cppu::supportsService(this, rServiceName);
698 css::uno::Sequence< OUString > SAL_CALL ChartDataWrapper::getSupportedServiceNames()
700 return {
701 u"com.sun.star.chart.ChartDataArray"_ustr,
702 u"com.sun.star.chart.ChartData"_ustr
706 rtl::Reference<ChartModel> ChartDataWrapper::getChartModel() const
708 return m_spChart2ModelContact->getDocumentModel();
711 } // namespace chart
713 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */