summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-02-01 20:51:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-02-04 08:40:49 +0100
commit3c2192c840f8bc86a677dd1394e9e1b1b52f86f3 (patch)
treee9a665d802dc6f43e3983c467c9f3706dcf6a558
parentb78ef5d55b891d8f6788ac53adfab0087d49c7be (diff)
use more concrete types in chart2, DataSeries
Change-Id: I51a30d2a6a3c424dcdc29b6647aa2b67fa35884a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129455 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--chart2/source/controller/dialogs/DataBrowserModel.cxx81
-rw-r--r--chart2/source/controller/dialogs/DialogModel.cxx36
-rw-r--r--chart2/source/controller/dialogs/DialogModel.hxx4
-rw-r--r--chart2/source/controller/dialogs/tp_DataSource.cxx1
-rw-r--r--chart2/source/inc/OPropertySet.hxx3
5 files changed, 55 insertions, 70 deletions
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx
index c7f91e490dcf..a25af6ca5a9f 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.cxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx
@@ -24,6 +24,7 @@
#include <ChartTypeManager.hxx>
#include <DiagramHelper.hxx>
#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <ControllerLockGuard.hxx>
#include <StatisticsHelper.hxx>
@@ -333,63 +334,57 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex )
// only share "values-x" sequences. (TODO: simplify this logic).
lcl_tSharedSeqVec aSharedSequences = lcl_getSharedSequences( xChartType->getDataSeries());
- Reference<chart2::XDataSeries> xNewSeries =
+ rtl::Reference<::chart::DataSeries> xNewSeries =
m_apDialogModel->insertSeriesAfter(xSeries, xChartType, true);
if (!xNewSeries.is())
// Failed to insert new data series to the model. Bail out.
return;
- Reference< chart2::data::XDataSource > xSource( xNewSeries, uno::UNO_QUERY );
- if (xSource.is())
+ Sequence<Reference<chart2::data::XLabeledDataSequence> > aLSequences = xNewSeries->getDataSequences();
+ sal_Int32 nSeqIdx = 0;
+ sal_Int32 nSeqSize = aLSequences.getLength();
+ for (sal_Int32 nIndex = nStartCol; nSeqIdx < nSeqSize; ++nSeqIdx)
{
- Sequence<Reference<chart2::data::XLabeledDataSequence> > aLSequences = xSource->getDataSequences();
- sal_Int32 nSeqIdx = 0;
- sal_Int32 nSeqSize = aLSequences.getLength();
- for (sal_Int32 nIndex = nStartCol; nSeqIdx < nSeqSize; ++nSeqIdx)
- {
- lcl_tSharedSeqVec::const_iterator aSharedIt(
- std::find_if( aSharedSequences.begin(), aSharedSequences.end(),
- lcl_RolesOfLSeqMatch( aLSequences[nSeqIdx] )));
+ lcl_tSharedSeqVec::const_iterator aSharedIt(
+ std::find_if( aSharedSequences.begin(), aSharedSequences.end(),
+ lcl_RolesOfLSeqMatch( aLSequences[nSeqIdx] )));
- if( aSharedIt != aSharedSequences.end())
- {
- // Shared sequence. Most likely "values-x" sequence. Copy it from existing sequence.
- aLSequences[nSeqIdx]->setValues( (*aSharedIt)->getValues());
- aLSequences[nSeqIdx]->setLabel( (*aSharedIt)->getLabel());
- }
- else
- {
- // Insert a new column in the internal data for the new sequence.
- xDataProvider->insertSequence( nIndex - 1 );
-
- // values
- Reference< chart2::data::XDataSequence > xNewSeq(
- xDataProvider->createDataSequenceByRangeRepresentation(
- OUString::number( nIndex )));
- lcl_copyDataSequenceProperties(
- aLSequences[nSeqIdx]->getValues(), xNewSeq );
- aLSequences[nSeqIdx]->setValues( xNewSeq );
-
- // labels
- Reference< chart2::data::XDataSequence > xNewLabelSeq(
- xDataProvider->createDataSequenceByRangeRepresentation(
- "label " +
- OUString::number( nIndex )));
- lcl_copyDataSequenceProperties(
- aLSequences[nSeqIdx]->getLabel(), xNewLabelSeq );
- aLSequences[nSeqIdx]->setLabel( xNewLabelSeq );
- ++nIndex;
- }
+ if( aSharedIt != aSharedSequences.end())
+ {
+ // Shared sequence. Most likely "values-x" sequence. Copy it from existing sequence.
+ aLSequences[nSeqIdx]->setValues( (*aSharedIt)->getValues());
+ aLSequences[nSeqIdx]->setLabel( (*aSharedIt)->getLabel());
+ }
+ else
+ {
+ // Insert a new column in the internal data for the new sequence.
+ xDataProvider->insertSequence( nIndex - 1 );
+
+ // values
+ Reference< chart2::data::XDataSequence > xNewSeq(
+ xDataProvider->createDataSequenceByRangeRepresentation(
+ OUString::number( nIndex )));
+ lcl_copyDataSequenceProperties(
+ aLSequences[nSeqIdx]->getValues(), xNewSeq );
+ aLSequences[nSeqIdx]->setValues( xNewSeq );
+
+ // labels
+ Reference< chart2::data::XDataSequence > xNewLabelSeq(
+ xDataProvider->createDataSequenceByRangeRepresentation(
+ "label " +
+ OUString::number( nIndex )));
+ lcl_copyDataSequenceProperties(
+ aLSequences[nSeqIdx]->getLabel(), xNewLabelSeq );
+ aLSequences[nSeqIdx]->setLabel( xNewLabelSeq );
+ ++nIndex;
}
}
if( nSeriesNumberFormat != 0 )
{
//give the new series the same number format as the former series especially for bubble charts thus the bubble size values can be edited with same format immediately
- Reference< beans::XPropertySet > xNewSeriesProps( xNewSeries, uno::UNO_QUERY );
- if( xNewSeriesProps.is() )
- xNewSeriesProps->setPropertyValue(CHART_UNONAME_NUMFMT , uno::Any(nSeriesNumberFormat));
+ xNewSeries->setPropertyValue(CHART_UNONAME_NUMFMT , uno::Any(nSeriesNumberFormat));
}
updateFromModel();
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx
index 94659adf1114..13c7571b4b17 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -229,8 +229,7 @@ Sequence< OUString > lcl_CopyExcludingValuesFirst(
return aOutput;
}
-Reference< XDataSeries > lcl_CreateNewSeries(
- const Reference< uno::XComponentContext > & xContext,
+rtl::Reference< ::chart::DataSeries > lcl_CreateNewSeries(
const rtl::Reference< ::chart::ChartType > & xChartType,
sal_Int32 nNewSeriesIndex,
sal_Int32 nTotalNumberOfSeriesInCTGroup,
@@ -239,21 +238,14 @@ Reference< XDataSeries > lcl_CreateNewSeries(
bool bCreateDataCachedSequences )
{
// create plain series
- Reference< XDataSeries > xResult(
- xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.DataSeries" ,
- xContext ), uno::UNO_QUERY );
+ rtl::Reference< ::chart::DataSeries > xResult = new ::chart::DataSeries();
if( xTemplate.is())
{
- Reference< beans::XPropertySet > xResultProp( xResult, uno::UNO_QUERY );
- if( xResultProp.is())
- {
- // @deprecated: correct default color should be found by view
- // without setting it as hard attribute
- Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme());
- if( xColorScheme.is())
- xResultProp->setPropertyValue( "Color" , uno::Any( xColorScheme->getColorByIndex( nNewSeriesIndex )));
- }
+ // @deprecated: correct default color should be found by view
+ // without setting it as hard attribute
+ Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme());
+ if( xColorScheme.is())
+ xResult->setPropertyValue( "Color" , uno::Any( xColorScheme->getColorByIndex( nNewSeriesIndex )));
sal_Int32 nGroupIndex=0;
if( xChartType.is())
{
@@ -271,8 +263,7 @@ Reference< XDataSeries > lcl_CreateNewSeries(
if( bCreateDataCachedSequences )
{
// set chart type specific roles
- Reference< data::XDataSink > xSink( xResult, uno::UNO_QUERY );
- if( xChartType.is() && xSink.is())
+ if( xChartType.is() )
{
std::vector< Reference< data::XLabeledDataSequence > > aNewSequences;
const OUString aRoleOfSeqForSeriesLabel = xChartType->getRoleOfSequenceForSeriesLabel();
@@ -327,7 +318,7 @@ Reference< XDataSeries > lcl_CreateNewSeries(
aNewSequences.push_back( ::chart::DataSourceHelper::createLabeledDataSequence( xSeq ));
}
- xSink->setData( comphelper::containerToSequence( aNewSequences ));
+ xResult->setData( comphelper::containerToSequence( aNewSequences ));
}
}
@@ -550,14 +541,14 @@ void DialogModel::moveSeries(
DiagramHelper::moveSeries( xDiagram, xSeries, eDirection==MoveDirection::Down );
}
-Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter(
+rtl::Reference< ::chart::DataSeries > DialogModel::insertSeriesAfter(
const Reference< XDataSeries > & xSeries,
const rtl::Reference< ::chart::ChartType > & xChartType,
bool bCreateDataCachedSequences /* = false */ )
{
m_aTimerTriggeredControllerLock.startTimer();
ControllerLockGuardUNO aLockedControllers( m_xChartDocument );
- Reference< XDataSeries > xNewSeries;
+ rtl::Reference< ::chart::DataSeries > xNewSeries;
try
{
@@ -572,15 +563,14 @@ Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter(
}
// create new series
- xNewSeries.set(
+ xNewSeries =
lcl_CreateNewSeries(
- m_xContext,
xChartType,
nTotalSeries, // new series' index
nSeriesInChartType,
xDiagram,
m_xTemplate,
- bCreateDataCachedSequences ));
+ bCreateDataCachedSequences );
// add new series to container
if( xNewSeries.is())
diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx
index 6e053f84b257..fd3ef59b1fd5 100644
--- a/chart2/source/controller/dialogs/DialogModel.hxx
+++ b/chart2/source/controller/dialogs/DialogModel.hxx
@@ -109,8 +109,8 @@ public:
MoveDirection eDirection );
/// @return the newly inserted series
- css::uno::Reference<
- css::chart2::XDataSeries > insertSeriesAfter(
+ rtl::Reference<
+ ::chart::DataSeries > insertSeriesAfter(
const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
const rtl::Reference< ::chart::ChartType > & xChartType,
bool bCreateDataCachedSequences = false );
diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx
index 558994e03d4c..d9e19e8c5da4 100644
--- a/chart2/source/controller/dialogs/tp_DataSource.cxx
+++ b/chart2/source/controller/dialogs/tp_DataSource.cxx
@@ -25,6 +25,7 @@
#include <ChartTypeTemplate.hxx>
#include <ChartModel.hxx>
#include <RangeSelectionHelper.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <ControllerLockGuard.hxx>
#include <DataSourceHelper.hxx>
diff --git a/chart2/source/inc/OPropertySet.hxx b/chart2/source/inc/OPropertySet.hxx
index 0a810fc6d2d8..bc603dbd977c 100644
--- a/chart2/source/inc/OPropertySet.hxx
+++ b/chart2/source/inc/OPropertySet.hxx
@@ -33,7 +33,7 @@
namespace property
{
-class SAL_DLLPUBLIC_RTTI OPropertySet :
+class OOO_DLLPUBLIC_CHARTTOOLS OPropertySet :
public ::cppu::OBroadcastHelper,
// includes beans::XPropertySet, XMultiPropertySet and XFastPropertySet
public ::cppu::OPropertySetHelper,
@@ -161,7 +161,6 @@ public:
getPropertyState( const OUString& PropertyName ) override;
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
- OOO_DLLPUBLIC_CHARTTOOLS
virtual void SAL_CALL
setPropertyToDefault( const OUString& PropertyName ) override;
virtual css::uno::Any SAL_CALL