summaryrefslogtreecommitdiff
path: root/chart2/source/tools
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/tools')
-rw-r--r--chart2/source/tools/AxisHelper.cxx561
-rw-r--r--chart2/source/tools/BaseGFXHelper.cxx38
-rw-r--r--chart2/source/tools/CachedDataSequence.cxx66
-rw-r--r--chart2/source/tools/CharacterProperties.cxx19
-rw-r--r--chart2/source/tools/ChartModelHelper.cxx139
-rw-r--r--chart2/source/tools/ChartTypeHelper.cxx100
-rw-r--r--chart2/source/tools/ChartViewHelper.cxx22
-rw-r--r--chart2/source/tools/ColorPerPointHelper.cxx23
-rw-r--r--chart2/source/tools/CommonConverters.cxx217
-rw-r--r--chart2/source/tools/ConfigColorScheme.cxx34
-rw-r--r--chart2/source/tools/ControllerLockGuard.cxx11
-rw-r--r--chart2/source/tools/DataSeriesHelper.cxx470
-rw-r--r--chart2/source/tools/DataSource.cxx7
-rw-r--r--chart2/source/tools/DataSourceHelper.cxx174
-rw-r--r--chart2/source/tools/DiagramHelper.cxx1256
-rw-r--r--chart2/source/tools/ErrorBar.cxx62
-rw-r--r--chart2/source/tools/ExplicitCategoriesProvider.cxx72
-rw-r--r--chart2/source/tools/ExponentialRegressionCurveCalculator.cxx37
-rw-r--r--chart2/source/tools/FillProperties.cxx18
-rw-r--r--chart2/source/tools/FormattedStringHelper.cxx31
-rw-r--r--chart2/source/tools/ImplOPropertySet.cxx176
-rw-r--r--chart2/source/tools/ImplOPropertySet.hxx82
-rw-r--r--chart2/source/tools/InternalData.cxx133
-rw-r--r--chart2/source/tools/InternalDataProvider.cxx315
-rw-r--r--chart2/source/tools/LabeledDataSequence.cxx62
-rw-r--r--chart2/source/tools/LegendHelper.cxx45
-rw-r--r--chart2/source/tools/LifeTime.cxx100
-rw-r--r--chart2/source/tools/LinePropertiesHelper.cxx9
-rw-r--r--chart2/source/tools/LinearRegressionCurveCalculator.cxx16
-rw-r--r--chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx36
-rw-r--r--chart2/source/tools/MeanValueRegressionCurveCalculator.cxx16
-rw-r--r--chart2/source/tools/MediaDescriptorHelper.cxx10
-rw-r--r--chart2/source/tools/ModifyListenerCallBack.cxx13
-rw-r--r--chart2/source/tools/ModifyListenerHelper.cxx141
-rw-r--r--chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx109
-rw-r--r--chart2/source/tools/NameContainer.cxx38
-rw-r--r--chart2/source/tools/NumberFormatterWrapper.cxx29
-rw-r--r--chart2/source/tools/OPropertySet.cxx151
-rw-r--r--chart2/source/tools/ObjectIdentifier.cxx845
-rw-r--r--chart2/source/tools/PolynomialRegressionCurveCalculator.cxx16
-rw-r--r--chart2/source/tools/PopupRequest.cxx9
-rw-r--r--chart2/source/tools/PotentialRegressionCurveCalculator.cxx35
-rw-r--r--chart2/source/tools/PropertyHelper.cxx117
-rw-r--r--chart2/source/tools/RangeHighlighter.cxx88
-rw-r--r--chart2/source/tools/ReferenceSizeProvider.cxx163
-rw-r--r--chart2/source/tools/RegressionCurveCalculator.cxx43
-rw-r--r--chart2/source/tools/RegressionCurveHelper.cxx344
-rw-r--r--chart2/source/tools/RegressionCurveModel.cxx117
-rw-r--r--chart2/source/tools/RegressionCurveModel.hxx241
-rw-r--r--chart2/source/tools/RegressionEquation.cxx165
-rw-r--r--chart2/source/tools/RegressionEquation.hxx9
-rw-r--r--chart2/source/tools/RelativePositionHelper.cxx4
-rw-r--r--chart2/source/tools/RelativeSizeHelper.cxx40
-rw-r--r--chart2/source/tools/ResId.cxx5
-rw-r--r--chart2/source/tools/Scaling.cxx44
-rw-r--r--chart2/source/tools/SceneProperties.cxx7
-rw-r--r--chart2/source/tools/StatisticsHelper.cxx95
-rw-r--r--chart2/source/tools/ThreeDHelper.cxx810
-rw-r--r--chart2/source/tools/TitleHelper.cxx357
-rw-r--r--chart2/source/tools/TrueGuard.cxx34
-rw-r--r--chart2/source/tools/UncachedDataSequence.cxx89
-rw-r--r--chart2/source/tools/WeakListenerAdapter.cxx15
-rw-r--r--chart2/source/tools/WrappedDefaultProperty.cxx7
-rw-r--r--chart2/source/tools/WrappedProperty.cxx9
-rw-r--r--chart2/source/tools/WrappedPropertySet.cxx11
-rw-r--r--chart2/source/tools/XMLRangeHelper.cxx7
66 files changed, 2987 insertions, 5577 deletions
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index aefa18b248b2..b48fd313a91c 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -19,10 +19,15 @@
#include <AxisHelper.hxx>
#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
#include <ChartTypeHelper.hxx>
+#include <ChartType.hxx>
+#include <Axis.hxx>
#include <AxisIndexDefines.hxx>
+#include <DataSource.hxx>
#include <LinePropertiesHelper.hxx>
#include <servicenames_coosystems.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <Scaling.hxx>
#include <ChartModel.hxx>
@@ -31,23 +36,22 @@
#include <ReferenceSizeProvider.hxx>
#include <ExplicitCategoriesProvider.hxx>
#include <unonames.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <GridProperties.hxx>
+#include <o3tl/safeint.hxx>
#include <unotools/saveopt.hxx>
#include <com/sun/star/chart/ChartAxisPosition.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
-#include <com/sun/star/chart2/data/XDataSource.hpp>
#include <sal/log.hxx>
#include <com/sun/star/lang/XServiceName.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <comphelper/sequence.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <cstddef>
#include <map>
namespace chart
@@ -73,16 +77,13 @@ ScaleData AxisHelper::createDefaultScale()
aScaleData.AxisType = chart2::AxisType::REALNUMBER;
aScaleData.AutoDateAxis = true;
aScaleData.ShiftedCategoryPosition = false;
- Sequence< SubIncrement > aSubIncrements(1);
- aSubIncrements[0] = SubIncrement();
- aScaleData.IncrementData.SubIncrements = aSubIncrements;
+ aScaleData.IncrementData.SubIncrements = { SubIncrement() };
return aScaleData;
}
void AxisHelper::removeExplicitScaling( ScaleData& rScaleData )
{
- uno::Any aEmpty;
- rScaleData.Minimum = rScaleData.Maximum = rScaleData.Origin = aEmpty;
+ rScaleData.Minimum = rScaleData.Maximum = rScaleData.Origin = uno::Any();
rScaleData.Scaling = nullptr;
ScaleData aDefaultScale( createDefaultScale() );
rScaleData.IncrementData = aDefaultScale.IncrementData;
@@ -96,10 +97,10 @@ bool AxisHelper::isLogarithmic( const Reference< XScaling >& xScaling )
&& xServiceName->getServiceName() == "com.sun.star.chart2.LogarithmicScaling";
}
-chart2::ScaleData AxisHelper::getDateCheckedScale( const Reference< chart2::XAxis >& xAxis, ChartModel& rModel )
+chart2::ScaleData AxisHelper::getDateCheckedScale( const rtl::Reference< Axis >& xAxis, ChartModel& rModel )
{
ScaleData aScale = xAxis->getScaleData();
- Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( rModel ) );
+ rtl::Reference< BaseCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( &rModel ) );
if( aScale.AutoDateAxis && aScale.AxisType == AxisType::CATEGORY )
{
sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0;
@@ -132,41 +133,33 @@ void AxisHelper::checkDateAxis( chart2::ScaleData& rScale, ExplicitCategoriesPro
}
sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
- const Reference< chart2::XAxis >& xAxis
- , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem
- , const Reference<chart2::XChartDocument>& xChartDoc
+ const rtl::Reference< Axis >& xAxis
+ , const rtl::Reference< BaseCoordinateSystem > & xCorrespondingCoordinateSystem
+ , const rtl::Reference<ChartModel>& xChartDoc
, bool bSearchForParallelAxisIfNothingIsFound )
{
sal_Int32 nNumberFormatKey(0);
sal_Int32 nAxisIndex = 0;
sal_Int32 nDimensionIndex = 1;
AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex );
- Reference<util::XNumberFormatsSupplier> const xNumberFormatsSupplier(xChartDoc, uno::UNO_QUERY);
- Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY );
- if (!xProp.is())
+ if (!xAxis.is())
return 0;
bool bLinkToSource = true;
- xProp->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkToSource;
- xProp->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormatKey;
+ xAxis->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkToSource;
+ xAxis->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormatKey;
if (bLinkToSource)
{
bool bFormatSet = false;
//check whether we have a percent scale -> use percent format
- ChartModel* pModel = nullptr;
- if( xNumberFormatsSupplier.is() )
+ if (xChartDoc)
{
- pModel = dynamic_cast<ChartModel*>( xChartDoc.get() );
- assert(pModel);
- }
- if (pModel)
- {
- ScaleData aData = AxisHelper::getDateCheckedScale( xAxis, *pModel );
+ ScaleData aData = AxisHelper::getDateCheckedScale( xAxis, *xChartDoc );
if( aData.AxisType==AxisType::PERCENT )
{
- sal_Int32 nPercentFormat = DiagramHelper::getPercentNumberFormat( xNumberFormatsSupplier );
+ sal_Int32 nPercentFormat = DiagramHelper::getPercentNumberFormat( xChartDoc );
if( nPercentFormat != -1 )
{
nNumberFormatKey = nPercentFormat;
@@ -181,27 +174,27 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
if( xSeq.is() && !( xChartDoc.is() && xChartDoc->hasInternalDataProvider()) )
nNumberFormatKey = xSeq->getNumberFormatKeyByIndex( -1 );
else
- nNumberFormatKey = DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier );
+ nNumberFormatKey = DiagramHelper::getDateNumberFormat( xChartDoc );
bFormatSet = true;
}
}
else if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() && nDimensionIndex == 0 ) //maybe date axis
{
- Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram() );
- if( DiagramHelper::isSupportingDateAxis( xDiagram ) )
+ rtl::Reference< Diagram > xDiagram( xChartDoc->getFirstChartDiagram() );
+ if( xDiagram->isSupportingDateAxis() )
{
- nNumberFormatKey = DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier );
+ nNumberFormatKey = DiagramHelper::getDateNumberFormat( xChartDoc );
}
else
{
- Reference< data::XDataSource > xSource( DataSourceHelper::getUsedData( xChartDoc ) );
+ rtl::Reference< DataSource > xSource = DataSourceHelper::getUsedData( *xChartDoc );
if( xSource.is() )
{
- std::vector< Reference< chart2::data::XLabeledDataSequence > > aXValues(
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aXValues(
DataSeriesHelper::getAllDataSequencesByRole( xSource->getDataSequences(), "values-x" ) );
if( aXValues.empty() )
{
- Reference< data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) );
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories( xDiagram->getCategories() );
if( xCategories.is() )
{
Reference< data::XDataSequence > xSeq( xCategories->getValues());
@@ -220,7 +213,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
}
}
if( bHasValidDoubles )
- nNumberFormatKey = DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier );
+ nNumberFormatKey = DiagramHelper::getDateNumberFormat( xChartDoc );
}
}
}
@@ -237,21 +230,16 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
try
{
- Reference< XChartTypeContainer > xCTCnt( xCorrespondingCoordinateSystem, uno::UNO_QUERY_THROW );
OUString aRoleToMatch;
if( nDimensionIndex == 0 )
aRoleToMatch = "values-x";
- const Sequence< Reference< XChartType > > aChartTypes( xCTCnt->getChartTypes());
- for( Reference< XChartType > const & chartType : aChartTypes )
+ const std::vector< rtl::Reference< ChartType > > & aChartTypes( xCorrespondingCoordinateSystem->getChartTypes2());
+ for( rtl::Reference< ChartType > const & chartType : aChartTypes )
{
if( nDimensionIndex != 0 )
aRoleToMatch = ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( chartType );
- Reference< XDataSeriesContainer > xDSCnt( chartType, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XDataSeries > > aDataSeriesSeq( xDSCnt->getDataSeries());
- for( Reference< chart2::XDataSeries > const & xDataSeries : aDataSeriesSeq )
+ for( rtl::Reference< DataSeries > const & xDataSeries : chartType->getDataSeries2() )
{
- Reference< data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY_THROW );
-
if( nDimensionIndex == 1 )
{
//only take those series into account that are attached to this axis
@@ -261,7 +249,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
}
Reference< data::XLabeledDataSequence > xLabeledSeq(
- DataSeriesHelper::getDataSequenceByRole( xSource, aRoleToMatch ) );
+ DataSeriesHelper::getDataSequenceByRole( xDataSeries, aRoleToMatch ) );
if( !xLabeledSeq.is() && nDimensionIndex==0 )
{
@@ -314,7 +302,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
if( !bNumberFormatKeyFoundViaAttachedData && nDimensionIndex == 1 )
{
sal_Int32 nParallelAxisIndex = (nAxisIndex==1) ?0 :1;
- Reference< XAxis > xParallelAxis( AxisHelper::getAxis( 1, nParallelAxisIndex, xCorrespondingCoordinateSystem ) );
+ rtl::Reference< Axis > xParallelAxis = AxisHelper::getAxis( 1, nParallelAxisIndex, xCorrespondingCoordinateSystem );
nNumberFormatKey = AxisHelper::getExplicitNumberFormatKeyForAxis(xParallelAxis, xCorrespondingCoordinateSystem, xChartDoc, false);
}
}
@@ -324,10 +312,10 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
return nNumberFormatKey;
}
-Reference< XAxis > AxisHelper::createAxis(
+rtl::Reference< Axis > AxisHelper::createAxis(
sal_Int32 nDimensionIndex
, sal_Int32 nAxisIndex // 0==main or 1==secondary axis
- , const Reference< XCoordinateSystem >& xCooSys
+ , const rtl::Reference< BaseCoordinateSystem >& xCooSys
, const Reference< uno::XComponentContext > & xContext
, ReferenceSizeProvider * pRefSizeProvider )
{
@@ -336,65 +324,53 @@ Reference< XAxis > AxisHelper::createAxis(
if( nDimensionIndex >= xCooSys->getDimension() )
return nullptr;
- Reference< XAxis > xAxis( xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.Axis", xContext ), uno::UNO_QUERY );
+ rtl::Reference< Axis > xAxis = new Axis();
- OSL_ASSERT( xAxis.is());
- if( xAxis.is())
+ xCooSys->setAxisByDimension( nDimensionIndex, xAxis, nAxisIndex );
+
+ if( nAxisIndex>0 )//when inserting secondary axes copy some things from the main axis
{
- xCooSys->setAxisByDimension( nDimensionIndex, xAxis, nAxisIndex );
+ css::chart::ChartAxisPosition eNewAxisPos( css::chart::ChartAxisPosition_END );
- if( nAxisIndex>0 )//when inserting secondary axes copy some things from the main axis
+ rtl::Reference< Axis > xMainAxis = xCooSys->getAxisByDimension2( nDimensionIndex, 0 );
+ if( xMainAxis.is() )
{
- css::chart::ChartAxisPosition eNewAxisPos( css::chart::ChartAxisPosition_END );
-
- Reference< XAxis > xMainAxis( xCooSys->getAxisByDimension( nDimensionIndex, 0 ) );
- if( xMainAxis.is() )
- {
- ScaleData aScale = xAxis->getScaleData();
- ScaleData aMainScale = xMainAxis->getScaleData();
-
- aScale.AxisType = aMainScale.AxisType;
- aScale.AutoDateAxis = aMainScale.AutoDateAxis;
- aScale.Categories = aMainScale.Categories;
- aScale.Orientation = aMainScale.Orientation;
- aScale.ShiftedCategoryPosition = aMainScale.ShiftedCategoryPosition;
-
- xAxis->setScaleData( aScale );
-
- //ensure that the second axis is not placed on the main axis
- Reference< beans::XPropertySet > xMainProp( xMainAxis, uno::UNO_QUERY );
- if( xMainProp.is() )
- {
- css::chart::ChartAxisPosition eMainAxisPos( css::chart::ChartAxisPosition_ZERO );
- xMainProp->getPropertyValue("CrossoverPosition") >>= eMainAxisPos;
- if( eMainAxisPos == css::chart::ChartAxisPosition_END )
- eNewAxisPos = css::chart::ChartAxisPosition_START;
- }
- }
-
- Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY );
- if( xProp.is() )
- xProp->setPropertyValue("CrossoverPosition", uno::Any(eNewAxisPos) );
+ ScaleData aScale = xAxis->getScaleData();
+ ScaleData aMainScale = xMainAxis->getScaleData();
+
+ aScale.AxisType = aMainScale.AxisType;
+ aScale.AutoDateAxis = aMainScale.AutoDateAxis;
+ aScale.Categories = aMainScale.Categories;
+ aScale.Orientation = aMainScale.Orientation;
+ aScale.ShiftedCategoryPosition = aMainScale.ShiftedCategoryPosition;
+
+ xAxis->setScaleData( aScale );
+
+ //ensure that the second axis is not placed on the main axis
+ css::chart::ChartAxisPosition eMainAxisPos( css::chart::ChartAxisPosition_ZERO );
+ xMainAxis->getPropertyValue("CrossoverPosition") >>= eMainAxisPos;
+ if( eMainAxisPos == css::chart::ChartAxisPosition_END )
+ eNewAxisPos = css::chart::ChartAxisPosition_START;
}
- Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY );
- if( xProp.is() ) try
- {
- // set correct initial AutoScale
- if( pRefSizeProvider )
- pRefSizeProvider->setValuesAtPropertySet( xProp );
- }
- catch( const uno::Exception& )
- {
- TOOLS_WARN_EXCEPTION("chart2", "" );
- }
+ xAxis->setPropertyValue("CrossoverPosition", uno::Any(eNewAxisPos) );
+ }
+
+ try
+ {
+ // set correct initial AutoScale
+ if( pRefSizeProvider )
+ pRefSizeProvider->setValuesAtPropertySet( xAxis );
+ }
+ catch( const uno::Exception& )
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "" );
}
return xAxis;
}
-Reference< XAxis > AxisHelper::createAxis( sal_Int32 nDimensionIndex, bool bMainAxis
- , const Reference< chart2::XDiagram >& xDiagram
+rtl::Reference< Axis > AxisHelper::createAxis( sal_Int32 nDimensionIndex, bool bMainAxis
+ , const rtl::Reference< Diagram >& xDiagram
, const Reference< uno::XComponentContext >& xContext
, ReferenceSizeProvider * pRefSizeProvider )
{
@@ -403,7 +379,7 @@ Reference< XAxis > AxisHelper::createAxis( sal_Int32 nDimensionIndex, bool bMain
return nullptr;
sal_Int32 nAxisIndex = bMainAxis ? MAIN_AXIS_INDEX : SECONDARY_AXIS_INDEX;
- Reference< XCoordinateSystem > xCooSys = AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 );
+ rtl::Reference< BaseCoordinateSystem > xCooSys = AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 );
// create axis
return AxisHelper::createAxis(
@@ -411,7 +387,7 @@ Reference< XAxis > AxisHelper::createAxis( sal_Int32 nDimensionIndex, bool bMain
}
void AxisHelper::showAxis( sal_Int32 nDimensionIndex, bool bMainAxis
- , const Reference< chart2::XDiagram >& xDiagram
+ , const rtl::Reference< Diagram >& xDiagram
, const Reference< uno::XComponentContext >& xContext
, ReferenceSizeProvider * pRefSizeProvider )
{
@@ -419,12 +395,12 @@ void AxisHelper::showAxis( sal_Int32 nDimensionIndex, bool bMainAxis
return;
bool bNewAxisCreated = false;
- Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram );
if( !xAxis.is() && xContext.is() )
{
// create axis
bNewAxisCreated = true;
- xAxis.set( AxisHelper::createAxis( nDimensionIndex, bMainAxis, xDiagram, xContext, pRefSizeProvider ) );
+ xAxis = AxisHelper::createAxis( nDimensionIndex, bMainAxis, xDiagram, xContext, pRefSizeProvider );
}
OSL_ASSERT( xAxis.is());
@@ -433,16 +409,16 @@ void AxisHelper::showAxis( sal_Int32 nDimensionIndex, bool bMainAxis
}
void AxisHelper::showGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
- , const Reference< XDiagram >& xDiagram )
+ , const rtl::Reference< Diagram >& xDiagram )
{
if( !xDiagram.is() )
return;
- Reference< XCoordinateSystem > xCooSys = AxisHelper::getCoordinateSystemByIndex( xDiagram, nCooSysIndex );
+ rtl::Reference< BaseCoordinateSystem > xCooSys = AxisHelper::getCoordinateSystemByIndex( xDiagram, nCooSysIndex );
if(!xCooSys.is())
return;
- Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, MAIN_AXIS_INDEX, xCooSys ) );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( nDimensionIndex, MAIN_AXIS_INDEX, xCooSys );
if(!xAxis.is())
{
//hhhh todo create axis without axis visibility
@@ -451,27 +427,26 @@ void AxisHelper::showGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bo
return;
if( bMainGrid )
- AxisHelper::makeGridVisible( xAxis->getGridProperties() );
+ AxisHelper::makeGridVisible( xAxis->getGridProperties2() );
else
{
- const Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
+ std::vector< rtl::Reference< GridProperties > > aSubGrids( xAxis->getSubGridProperties2() );
for( auto const & i : aSubGrids )
AxisHelper::makeGridVisible( i );
}
}
-void AxisHelper::makeAxisVisible( const Reference< XAxis >& xAxis )
+void AxisHelper::makeAxisVisible( const rtl::Reference< Axis >& xAxis )
{
- Reference< beans::XPropertySet > xProps( xAxis, uno::UNO_QUERY );
- if( xProps.is() )
+ if( xAxis.is() )
{
- xProps->setPropertyValue( "Show", uno::Any( true ) );
- LinePropertiesHelper::SetLineVisible( xProps );
- xProps->setPropertyValue( "DisplayLabels", uno::Any( true ) );
+ xAxis->setPropertyValue( "Show", uno::Any( true ) );
+ LinePropertiesHelper::SetLineVisible( xAxis );
+ xAxis->setPropertyValue( "DisplayLabels", uno::Any( true ) );
}
}
-void AxisHelper::makeGridVisible( const Reference< beans::XPropertySet >& xGridProperties )
+void AxisHelper::makeGridVisible( const rtl::Reference< GridProperties >& xGridProperties )
{
if( xGridProperties.is() )
{
@@ -481,28 +456,27 @@ void AxisHelper::makeGridVisible( const Reference< beans::XPropertySet >& xGridP
}
void AxisHelper::hideAxis( sal_Int32 nDimensionIndex, bool bMainAxis
- , const Reference< XDiagram >& xDiagram )
+ , const rtl::Reference< Diagram >& xDiagram )
{
AxisHelper::makeAxisInvisible( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) );
}
-void AxisHelper::makeAxisInvisible( const Reference< XAxis >& xAxis )
+void AxisHelper::makeAxisInvisible( const rtl::Reference< Axis >& xAxis )
{
- Reference< beans::XPropertySet > xProps( xAxis, uno::UNO_QUERY );
- if( xProps.is() )
+ if( xAxis.is() )
{
- xProps->setPropertyValue( "Show", uno::Any( false ) );
+ xAxis->setPropertyValue( "Show", uno::Any( false ) );
}
}
-void AxisHelper::hideAxisIfNoDataIsAttached( const Reference< XAxis >& xAxis, const Reference< XDiagram >& xDiagram )
+void AxisHelper::hideAxisIfNoDataIsAttached( const rtl::Reference< Axis >& xAxis, const rtl::Reference< Diagram >& xDiagram )
{
//axis is hidden if no data is attached anymore but data is available
bool bOtherSeriesAttachedToThisAxis = false;
- std::vector< Reference< chart2::XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ std::vector< rtl::Reference< DataSeries > > aSeriesVector = xDiagram->getDataSeries();
for (auto const& series : aSeriesVector)
{
- uno::Reference< chart2::XAxis > xCurrentAxis = DiagramHelper::getAttachedAxis(series, xDiagram );
+ rtl::Reference< Axis > xCurrentAxis = xDiagram->getAttachedAxis(series);
if( xCurrentAxis==xAxis )
{
bOtherSeriesAttachedToThisAxis = true;
@@ -514,30 +488,30 @@ void AxisHelper::hideAxisIfNoDataIsAttached( const Reference< XAxis >& xAxis, co
}
void AxisHelper::hideGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
- , const Reference< XDiagram >& xDiagram )
+ , const rtl::Reference< Diagram >& xDiagram )
{
if( !xDiagram.is() )
return;
- Reference< XCoordinateSystem > xCooSys = AxisHelper::getCoordinateSystemByIndex( xDiagram, nCooSysIndex );
+ rtl::Reference< BaseCoordinateSystem > xCooSys = AxisHelper::getCoordinateSystemByIndex( xDiagram, nCooSysIndex );
if(!xCooSys.is())
return;
- Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, MAIN_AXIS_INDEX, xCooSys ) );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( nDimensionIndex, MAIN_AXIS_INDEX, xCooSys );
if(!xAxis.is())
return;
if( bMainGrid )
- AxisHelper::makeGridInvisible( xAxis->getGridProperties() );
+ AxisHelper::makeGridInvisible( xAxis->getGridProperties2() );
else
{
- const Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
+ std::vector< rtl::Reference< ::chart::GridProperties > > aSubGrids( xAxis->getSubGridProperties2() );
for( auto const & i : aSubGrids)
AxisHelper::makeGridInvisible( i );
}
}
-void AxisHelper::makeGridInvisible( const Reference< beans::XPropertySet >& xGridProperties )
+void AxisHelper::makeGridInvisible( const rtl::Reference< ::chart::GridProperties >& xGridProperties )
{
if( xGridProperties.is() )
{
@@ -546,50 +520,49 @@ void AxisHelper::makeGridInvisible( const Reference< beans::XPropertySet >& xGri
}
bool AxisHelper::isGridShown( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
- , const Reference< css::chart2::XDiagram >& xDiagram )
+ , const rtl::Reference< Diagram >& xDiagram )
{
bool bRet = false;
- Reference< XCoordinateSystem > xCooSys = AxisHelper::getCoordinateSystemByIndex( xDiagram, nCooSysIndex );
+ rtl::Reference< BaseCoordinateSystem > xCooSys = AxisHelper::getCoordinateSystemByIndex( xDiagram, nCooSysIndex );
if(!xCooSys.is())
return bRet;
- Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, MAIN_AXIS_INDEX, xCooSys ) );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( nDimensionIndex, MAIN_AXIS_INDEX, xCooSys );
if(!xAxis.is())
return bRet;
if( bMainGrid )
- bRet = AxisHelper::isGridVisible( xAxis->getGridProperties() );
+ bRet = AxisHelper::isGridVisible( xAxis->getGridProperties2() );
else
{
- Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
- if( aSubGrids.hasElements() )
+ std::vector< rtl::Reference< ::chart::GridProperties > > aSubGrids( xAxis->getSubGridProperties2() );
+ if( !aSubGrids.empty() )
bRet = AxisHelper::isGridVisible( aSubGrids[0] );
}
return bRet;
}
-Reference< XCoordinateSystem > AxisHelper::getCoordinateSystemByIndex(
- const Reference< XDiagram >& xDiagram, sal_Int32 nIndex )
+rtl::Reference< ::chart::BaseCoordinateSystem > AxisHelper::getCoordinateSystemByIndex(
+ const rtl::Reference< Diagram >& xDiagram, sal_Int32 nIndex )
{
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if(!xCooSysContainer.is())
+ if(!xDiagram.is())
return nullptr;
- Sequence< Reference< XCoordinateSystem > > aCooSysList = xCooSysContainer->getCoordinateSystems();
- if(0<=nIndex && nIndex<aCooSysList.getLength())
+ auto aCooSysList = xDiagram->getBaseCoordinateSystems();
+ if(0<=nIndex && o3tl::make_unsigned(nIndex) < aCooSysList.size())
return aCooSysList[nIndex];
return nullptr;
}
-Reference< XAxis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, bool bMainAxis
- , const Reference< XDiagram >& xDiagram )
+rtl::Reference< Axis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, bool bMainAxis
+ , const rtl::Reference< Diagram >& xDiagram )
{
- Reference< XAxis > xRet;
+ rtl::Reference< Axis > xRet;
try
{
- Reference< XCoordinateSystem > xCooSys = AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 );
- xRet.set( AxisHelper::getAxis( nDimensionIndex, bMainAxis ? 0 : 1, xCooSys ) );
+ rtl::Reference< BaseCoordinateSystem > xCooSys = AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 );
+ xRet = AxisHelper::getAxis( nDimensionIndex, bMainAxis ? 0 : 1, xCooSys );
}
catch( const uno::Exception & )
{
@@ -597,10 +570,10 @@ Reference< XAxis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, bool bMainAxi
return xRet;
}
-Reference< XAxis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex
- , const Reference< XCoordinateSystem >& xCooSys )
+rtl::Reference< Axis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex
+ , const rtl::Reference< BaseCoordinateSystem >& xCooSys )
{
- Reference< XAxis > xRet;
+ rtl::Reference< Axis > xRet;
if(!xCooSys.is())
return xRet;
@@ -612,12 +585,12 @@ Reference< XAxis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAx
assert(nAxisIndex >= 0);
assert(nDimensionIndex >= 0);
- xRet.set( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
+ xRet = xCooSys->getAxisByDimension2( nDimensionIndex, nAxisIndex );
return xRet;
}
-Reference< XAxis > AxisHelper::getCrossingMainAxis( const Reference< XAxis >& xAxis
- , const Reference< XCoordinateSystem >& xCooSys )
+rtl::Reference< Axis > AxisHelper::getCrossingMainAxis( const rtl::Reference< Axis >& xAxis
+ , const rtl::Reference< BaseCoordinateSystem >& xCooSys )
{
sal_Int32 nDimensionIndex = 0;
sal_Int32 nAxisIndex = 0;
@@ -626,8 +599,7 @@ Reference< XAxis > AxisHelper::getCrossingMainAxis( const Reference< XAxis >& xA
{
nDimensionIndex=1;
bool bSwapXY = false;
- Reference< beans::XPropertySet > xCooSysProp( xCooSys, uno::UNO_QUERY );
- if( xCooSysProp.is() && (xCooSysProp->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXY) && bSwapXY )
+ if( (xCooSys->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXY) && bSwapXY )
nDimensionIndex=0;
}
else if( nDimensionIndex==1 )
@@ -637,8 +609,8 @@ Reference< XAxis > AxisHelper::getCrossingMainAxis( const Reference< XAxis >& xA
return AxisHelper::getAxis( nDimensionIndex, 0, xCooSys );
}
-Reference< XAxis > AxisHelper::getParallelAxis( const Reference< XAxis >& xAxis
- , const Reference< XDiagram >& xDiagram )
+rtl::Reference< Axis > AxisHelper::getParallelAxis( const rtl::Reference< Axis >& xAxis
+ , const rtl::Reference< Diagram >& xDiagram )
{
try
{
@@ -658,37 +630,36 @@ Reference< XAxis > AxisHelper::getParallelAxis( const Reference< XAxis >& xAxis
}
bool AxisHelper::isAxisShown( sal_Int32 nDimensionIndex, bool bMainAxis
- , const Reference< XDiagram >& xDiagram )
+ , const rtl::Reference< Diagram >& xDiagram )
{
return AxisHelper::isAxisVisible( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) );
}
-bool AxisHelper::isAxisVisible( const Reference< XAxis >& xAxis )
+bool AxisHelper::isAxisVisible( const rtl::Reference< Axis >& xAxis )
{
bool bRet = false;
- Reference< beans::XPropertySet > xProps( xAxis, uno::UNO_QUERY );
- if( xProps.is() )
+ if( xAxis.is() )
{
- xProps->getPropertyValue( "Show" ) >>= bRet;
- bRet = bRet && ( LinePropertiesHelper::IsLineVisible( xProps )
- || areAxisLabelsVisible( xProps ) );
+ xAxis->getPropertyValue( "Show" ) >>= bRet;
+ bRet = bRet && ( LinePropertiesHelper::IsLineVisible( xAxis )
+ || areAxisLabelsVisible( xAxis ) );
}
return bRet;
}
-bool AxisHelper::areAxisLabelsVisible( const Reference< beans::XPropertySet >& xAxisProperties )
+bool AxisHelper::areAxisLabelsVisible( const rtl::Reference< Axis >& xAxis )
{
bool bRet = false;
- if( xAxisProperties.is() )
+ if( xAxis.is() )
{
- xAxisProperties->getPropertyValue( "DisplayLabels" ) >>= bRet;
+ xAxis->getPropertyValue( "DisplayLabels" ) >>= bRet;
}
return bRet;
}
-bool AxisHelper::isGridVisible( const Reference< beans::XPropertySet >& xGridproperties )
+bool AxisHelper::isGridVisible( const rtl::Reference< ::chart::GridProperties >& xGridproperties )
{
bool bRet = false;
@@ -701,22 +672,22 @@ bool AxisHelper::isGridVisible( const Reference< beans::XPropertySet >& xGridpro
return bRet;
}
-Reference< beans::XPropertySet > AxisHelper::getGridProperties(
- const Reference< XCoordinateSystem >& xCooSys
+rtl::Reference< GridProperties > AxisHelper::getGridProperties(
+ const rtl::Reference< BaseCoordinateSystem >& xCooSys
, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex, sal_Int32 nSubGridIndex )
{
- Reference< beans::XPropertySet > xRet;
+ rtl::Reference< GridProperties > xRet;
- Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, nAxisIndex, xCooSys ) );
+ rtl::Reference< Axis > xAxis( AxisHelper::getAxis( nDimensionIndex, nAxisIndex, xCooSys ) );
if( xAxis.is() )
{
if( nSubGridIndex<0 )
- xRet.set( xAxis->getGridProperties() );
+ xRet = xAxis->getGridProperties2();
else
{
- Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
- if (nSubGridIndex < aSubGrids.getLength())
- xRet.set( aSubGrids[nSubGridIndex] );
+ std::vector< rtl::Reference< GridProperties > > aSubGrids( xAxis->getSubGridProperties2() );
+ if (nSubGridIndex < static_cast<sal_Int32>(aSubGrids.size()))
+ xRet = aSubGrids[nSubGridIndex];
}
}
@@ -724,8 +695,8 @@ Reference< beans::XPropertySet > AxisHelper::getGridProperties(
}
sal_Int32 AxisHelper::getDimensionIndexOfAxis(
- const Reference< XAxis >& xAxis
- , const Reference< XDiagram >& xDiagram )
+ const rtl::Reference< Axis >& xAxis
+ , const rtl::Reference< Diagram >& xDiagram )
{
sal_Int32 nDimensionIndex = -1;
sal_Int32 nCooSysIndex = -1;
@@ -735,8 +706,8 @@ sal_Int32 AxisHelper::getDimensionIndexOfAxis(
}
bool AxisHelper::getIndicesForAxis(
- const Reference< XAxis >& xAxis
- , const Reference< XCoordinateSystem >& xCooSys
+ const rtl::Reference< Axis >& xAxis
+ , const rtl::Reference< BaseCoordinateSystem >& xCooSys
, sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex )
{
//returns true if indices are found
@@ -744,29 +715,29 @@ bool AxisHelper::getIndicesForAxis(
rOutDimensionIndex = -1;
rOutAxisIndex = -1;
- if( xCooSys.is() && xAxis.is() )
+ if( !xCooSys || !xAxis )
+ return false;
+
+ rtl::Reference< Axis > xCurrentAxis;
+ sal_Int32 nDimensionCount( xCooSys->getDimension() );
+ for( sal_Int32 nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
{
- Reference< XAxis > xCurrentAxis;
- sal_Int32 nDimensionCount( xCooSys->getDimension() );
- for( sal_Int32 nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
+ sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
+ for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
{
- sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
- for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
- {
- xCurrentAxis = xCooSys->getAxisByDimension(nDimensionIndex,nAxisIndex);
- if( xCurrentAxis == xAxis )
- {
- rOutDimensionIndex = nDimensionIndex;
- rOutAxisIndex = nAxisIndex;
- return true;
- }
- }
+ xCurrentAxis = xCooSys->getAxisByDimension2(nDimensionIndex,nAxisIndex);
+ if( xCurrentAxis == xAxis )
+ {
+ rOutDimensionIndex = nDimensionIndex;
+ rOutAxisIndex = nAxisIndex;
+ return true;
+ }
}
}
return false;
}
-bool AxisHelper::getIndicesForAxis( const Reference< XAxis >& xAxis, const Reference< XDiagram >& xDiagram
+bool AxisHelper::getIndicesForAxis( const rtl::Reference< Axis >& xAxis, const rtl::Reference< Diagram >& xDiagram
, sal_Int32& rOutCooSysIndex, sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex )
{
//returns true if indices are found
@@ -775,28 +746,24 @@ bool AxisHelper::getIndicesForAxis( const Reference< XAxis >& xAxis, const Refer
rOutDimensionIndex = -1;
rOutAxisIndex = -1;
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if(xCooSysContainer.is())
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysList = xDiagram->getBaseCoordinateSystems();
+ for( std::size_t nC=0; nC < aCooSysList.size(); ++nC )
{
- Sequence< Reference< XCoordinateSystem > > aCooSysList = xCooSysContainer->getCoordinateSystems();
- for( sal_Int32 nC=0; nC<aCooSysList.getLength(); ++nC )
+ if( AxisHelper::getIndicesForAxis( xAxis, aCooSysList[nC], rOutDimensionIndex, rOutAxisIndex ) )
{
- if( AxisHelper::getIndicesForAxis( xAxis, aCooSysList[nC], rOutDimensionIndex, rOutAxisIndex ) )
- {
- rOutCooSysIndex = nC;
- return true;
- }
+ rOutCooSysIndex = nC;
+ return true;
}
}
return false;
}
-std::vector< Reference< XAxis > > AxisHelper::getAllAxesOfCoordinateSystem(
- const Reference< XCoordinateSystem >& xCooSys
+std::vector< rtl::Reference< Axis > > AxisHelper::getAllAxesOfCoordinateSystem(
+ const rtl::Reference< BaseCoordinateSystem >& xCooSys
, bool bOnlyVisible /* = false */ )
{
- std::vector< Reference< XAxis > > aAxisVector;
+ std::vector< rtl::Reference< Axis > > aAxisVector;
if(xCooSys.is())
{
@@ -811,15 +778,13 @@ std::vector< Reference< XAxis > > AxisHelper::getAllAxesOfCoordinateSystem(
{
try
{
- Reference< XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( nDimensionIndex, nAxisIndex );
if( xAxis.is() )
{
bool bAddAxis = true;
if( bOnlyVisible )
{
- Reference< beans::XPropertySet > xAxisProp( xAxis, uno::UNO_QUERY );
- if( !xAxisProp.is() ||
- !(xAxisProp->getPropertyValue( "Show") >>= bAddAxis) )
+ if( !(xAxis->getPropertyValue( "Show") >>= bAddAxis) )
bAddAxis = false;
}
if( bAddAxis )
@@ -838,99 +803,89 @@ std::vector< Reference< XAxis > > AxisHelper::getAllAxesOfCoordinateSystem(
return aAxisVector;
}
-Sequence< Reference< XAxis > > AxisHelper::getAllAxesOfDiagram(
- const Reference< XDiagram >& xDiagram
+std::vector< rtl::Reference< Axis > > AxisHelper::getAllAxesOfDiagram(
+ const rtl::Reference< Diagram >& xDiagram
, bool bOnlyVisible )
{
- std::vector< Reference< XAxis > > aAxisVector;
+ std::vector< rtl::Reference< Axis > > aAxisVector;
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if(xCooSysContainer.is())
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : xDiagram->getBaseCoordinateSystems() )
{
- const Sequence< Reference< XCoordinateSystem > > aCooSysList = xCooSysContainer->getCoordinateSystems();
- for( Reference< XCoordinateSystem > const & coords : aCooSysList )
- {
- std::vector< Reference< XAxis > > aAxesPerCooSys( AxisHelper::getAllAxesOfCoordinateSystem( coords, bOnlyVisible ) );
- aAxisVector.insert( aAxisVector.end(), aAxesPerCooSys.begin(), aAxesPerCooSys.end() );
- }
+ std::vector< rtl::Reference< Axis > > aAxesPerCooSys = AxisHelper::getAllAxesOfCoordinateSystem( coords, bOnlyVisible );
+ aAxisVector.insert( aAxisVector.end(), aAxesPerCooSys.begin(), aAxesPerCooSys.end() );
}
- return comphelper::containerToSequence( aAxisVector );
+ return aAxisVector;
}
-Sequence< Reference< beans::XPropertySet > > AxisHelper::getAllGrids( const Reference< XDiagram >& xDiagram )
+std::vector< rtl::Reference< GridProperties > > AxisHelper::getAllGrids( const rtl::Reference< Diagram >& xDiagram )
{
- const Sequence< Reference< XAxis > > aAllAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
- std::vector< Reference< beans::XPropertySet > > aGridVector;
+ const std::vector< rtl::Reference< Axis > > aAllAxes = AxisHelper::getAllAxesOfDiagram( xDiagram );
+ std::vector< rtl::Reference< GridProperties > > aGridVector;
- for( Reference< XAxis > const & xAxis : aAllAxes )
+ for( rtl::Reference< Axis > const & xAxis : aAllAxes )
{
- if(!xAxis.is())
- continue;
- Reference< beans::XPropertySet > xGridProperties( xAxis->getGridProperties() );
+ rtl::Reference< GridProperties > xGridProperties( xAxis->getGridProperties2() );
if( xGridProperties.is() )
aGridVector.push_back( xGridProperties );
- const Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
- for( Reference< beans::XPropertySet > const & xSubGrid : aSubGrids )
+ std::vector< rtl::Reference< GridProperties > > aSubGrids( xAxis->getSubGridProperties2() );
+ for( rtl::Reference< GridProperties > const & xSubGrid : aSubGrids )
{
if( xSubGrid.is() )
aGridVector.push_back( xSubGrid );
}
}
- return comphelper::containerToSequence( aGridVector );
+ return aGridVector;
}
void AxisHelper::getAxisOrGridPossibilities( Sequence< sal_Bool >& rPossibilityList
- , const Reference< XDiagram>& xDiagram, bool bAxis )
+ , const rtl::Reference< Diagram>& xDiagram, bool bAxis )
{
rPossibilityList.realloc(6);
+ sal_Bool* pPossibilityList = rPossibilityList.getArray();
- sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+ sal_Int32 nDimensionCount = -1;
+ if (xDiagram)
+ nDimensionCount = xDiagram->getDimension();
//set possibilities:
sal_Int32 nIndex=0;
- Reference< XChartType > xChartType = DiagramHelper::getChartTypeByIndex( xDiagram, 0 );
+ rtl::Reference< ChartType > xChartType;
+ if (xDiagram)
+ xChartType = xDiagram->getChartTypeByIndex( 0 );
for(nIndex=0;nIndex<3;nIndex++)
- rPossibilityList[nIndex]=ChartTypeHelper::isSupportingMainAxis(xChartType,nDimensionCount,nIndex);
+ pPossibilityList[nIndex]=ChartTypeHelper::isSupportingMainAxis(xChartType,nDimensionCount,nIndex);
for(nIndex=3;nIndex<6;nIndex++)
if( bAxis )
- rPossibilityList[nIndex]=ChartTypeHelper::isSupportingSecondaryAxis(xChartType,nDimensionCount);
+ pPossibilityList[nIndex]=ChartTypeHelper::isSupportingSecondaryAxis(xChartType,nDimensionCount);
else
- rPossibilityList[nIndex] = rPossibilityList[nIndex-3];
+ pPossibilityList[nIndex] = rPossibilityList[nIndex-3];
}
-bool AxisHelper::isSecondaryYAxisNeeded( const Reference< XCoordinateSystem >& xCooSys )
+bool AxisHelper::isSecondaryYAxisNeeded( const rtl::Reference< BaseCoordinateSystem >& xCooSys )
{
- Reference< chart2::XChartTypeContainer > xCTCnt( xCooSys, uno::UNO_QUERY );
- if( xCTCnt.is() )
+ if( !xCooSys.is() )
+ return false;
+
+ const std::vector< rtl::Reference< ChartType > > & aChartTypes( xCooSys->getChartTypes2() );
+ for( rtl::Reference< ChartType > const & chartType : aChartTypes )
{
- const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes() );
- for( Reference< chart2::XChartType > const & chartType : aChartTypes )
+ const std::vector< rtl::Reference< DataSeries > > & aSeriesList = chartType->getDataSeries2();
+ for( sal_Int32 nS = aSeriesList.size(); nS-- ; )
{
- Reference< XDataSeriesContainer > xSeriesContainer( chartType, uno::UNO_QUERY );
- if( !xSeriesContainer.is() )
- continue;
-
- Sequence< Reference< XDataSeries > > aSeriesList( xSeriesContainer->getDataSeries() );
- for( sal_Int32 nS = aSeriesList.getLength(); nS-- ; )
- {
- Reference< beans::XPropertySet > xProp( aSeriesList[nS], uno::UNO_QUERY );
- if(xProp.is())
- {
- sal_Int32 nAttachedAxisIndex = 0;
- if( ( xProp->getPropertyValue( "AttachedAxisIndex" ) >>= nAttachedAxisIndex ) && nAttachedAxisIndex>0 )
- return true;
- }
- }
+ sal_Int32 nAttachedAxisIndex = 0;
+ if( ( aSeriesList[nS]->getPropertyValue( "AttachedAxisIndex" ) >>= nAttachedAxisIndex ) &&
+ nAttachedAxisIndex>0 )
+ return true;
}
}
return false;
}
-bool AxisHelper::shouldAxisBeDisplayed( const Reference< XAxis >& xAxis
- , const Reference< XCoordinateSystem >& xCooSys )
+bool AxisHelper::shouldAxisBeDisplayed( const rtl::Reference< Axis >& xAxis
+ , const rtl::Reference< BaseCoordinateSystem >& xCooSys )
{
bool bRet = false;
@@ -941,7 +896,7 @@ bool AxisHelper::shouldAxisBeDisplayed( const Reference< XAxis >& xAxis
if( AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex ) )
{
sal_Int32 nDimensionCount = xCooSys->getDimension();
- Reference< XChartType > xChartType( AxisHelper::getChartTypeByIndex( xCooSys, 0 ) );
+ rtl::Reference< ChartType > xChartType( AxisHelper::getChartTypeByIndex( xCooSys, 0 ) );
bool bMainAxis = (nAxisIndex==MAIN_AXIS_INDEX);
if( bMainAxis )
@@ -955,30 +910,31 @@ bool AxisHelper::shouldAxisBeDisplayed( const Reference< XAxis >& xAxis
}
void AxisHelper::getAxisOrGridExistence( Sequence< sal_Bool >& rExistenceList
- , const Reference< XDiagram>& xDiagram, bool bAxis )
+ , const rtl::Reference< Diagram>& xDiagram, bool bAxis )
{
rExistenceList.realloc(6);
+ sal_Bool* pExistenceList = rExistenceList.getArray();
if(bAxis)
{
sal_Int32 nN;
for(nN=0;nN<3;nN++)
- rExistenceList[nN] = AxisHelper::isAxisShown( nN, true, xDiagram );
+ pExistenceList[nN] = AxisHelper::isAxisShown( nN, true, xDiagram );
for(nN=3;nN<6;nN++)
- rExistenceList[nN] = AxisHelper::isAxisShown( nN%3, false, xDiagram );
+ pExistenceList[nN] = AxisHelper::isAxisShown( nN%3, false, xDiagram );
}
else
{
sal_Int32 nN;
for(nN=0;nN<3;nN++)
- rExistenceList[nN] = AxisHelper::isGridShown( nN, 0, true, xDiagram );
+ pExistenceList[nN] = AxisHelper::isGridShown( nN, 0, true, xDiagram );
for(nN=3;nN<6;nN++)
- rExistenceList[nN] = AxisHelper::isGridShown( nN%3, 0, false, xDiagram );
+ pExistenceList[nN] = AxisHelper::isGridShown( nN%3, 0, false, xDiagram );
}
}
-bool AxisHelper::changeVisibilityOfAxes( const Reference< XDiagram >& xDiagram
+bool AxisHelper::changeVisibilityOfAxes( const rtl::Reference< Diagram >& xDiagram
, const Sequence< sal_Bool >& rOldExistenceList
, const Sequence< sal_Bool >& rNewExistenceList
, const Reference< uno::XComponentContext >& xContext
@@ -1001,7 +957,7 @@ bool AxisHelper::changeVisibilityOfAxes( const Reference< XDiagram >& xDiagram
return bChanged;
}
-bool AxisHelper::changeVisibilityOfGrids( const Reference< XDiagram >& xDiagram
+bool AxisHelper::changeVisibilityOfGrids( const rtl::Reference< Diagram >& xDiagram
, const Sequence< sal_Bool >& rOldExistenceList
, const Sequence< sal_Bool >& rNewExistenceList )
{
@@ -1020,48 +976,43 @@ bool AxisHelper::changeVisibilityOfGrids( const Reference< XDiagram >& xDiagram
return bChanged;
}
-Reference< XCoordinateSystem > AxisHelper::getCoordinateSystemOfAxis(
- const Reference< XAxis >& xAxis
- , const Reference< XDiagram >& xDiagram )
+rtl::Reference< BaseCoordinateSystem > AxisHelper::getCoordinateSystemOfAxis(
+ const rtl::Reference< Axis >& xAxis
+ , const rtl::Reference< Diagram >& xDiagram )
{
- Reference< XCoordinateSystem > xRet;
+ if (!xDiagram)
+ return nullptr;
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( xCooSysContainer.is() )
+ rtl::Reference< BaseCoordinateSystem > xRet;
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : xDiagram->getBaseCoordinateSystems() )
{
- const Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( Reference< XCoordinateSystem > const & xCooSys : aCooSysList )
- {
- std::vector< Reference< XAxis > > aAllAxis( AxisHelper::getAllAxesOfCoordinateSystem( xCooSys ) );
+ std::vector< rtl::Reference< Axis > > aAllAxis = AxisHelper::getAllAxesOfCoordinateSystem( xCooSys );
- std::vector< Reference< XAxis > >::iterator aFound =
- std::find( aAllAxis.begin(), aAllAxis.end(), xAxis );
- if( aFound != aAllAxis.end())
- {
- xRet.set( xCooSys );
- break;
- }
+ auto aFound = std::find( aAllAxis.begin(), aAllAxis.end(), xAxis );
+ if( aFound != aAllAxis.end())
+ {
+ xRet = xCooSys;
+ break;
}
}
return xRet;
}
-Reference< XChartType > AxisHelper::getChartTypeByIndex( const Reference< XCoordinateSystem >& xCooSys, sal_Int32 nIndex )
+rtl::Reference< ChartType > AxisHelper::getChartTypeByIndex( const rtl::Reference< BaseCoordinateSystem >& xCooSys, sal_Int32 nIndex )
{
- Reference< XChartType > xChartType;
+ rtl::Reference< ChartType > xChartType;
- Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
- if( xChartTypeContainer.is() )
+ if( xCooSys.is() )
{
- Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- if( nIndex >= 0 && nIndex < aChartTypeList.getLength() )
- xChartType.set( aChartTypeList[nIndex] );
+ const std::vector< rtl::Reference< ChartType > > aChartTypeList( xCooSys->getChartTypes2() );
+ if( nIndex >= 0 && o3tl::make_unsigned(nIndex) < aChartTypeList.size() )
+ xChartType = aChartTypeList[nIndex];
}
return xChartType;
}
-void AxisHelper::setRTLAxisLayout( const Reference< XCoordinateSystem >& xCooSys )
+void AxisHelper::setRTLAxisLayout( const rtl::Reference< BaseCoordinateSystem >& xCooSys )
{
if( !xCooSys.is() )
return;
@@ -1071,9 +1022,7 @@ void AxisHelper::setRTLAxisLayout( const Reference< XCoordinateSystem >& xCooSys
return;
bool bVertical = false;
- Reference< beans::XPropertySet > xCooSysProp( xCooSys, uno::UNO_QUERY );
- if( xCooSysProp.is() )
- xCooSysProp->getPropertyValue( "SwapXAndYAxis" ) >>= bVertical;
+ xCooSys->getPropertyValue( "SwapXAndYAxis" ) >>= bVertical;
sal_Int32 nHorizontalAxisDimension = bVertical ? 1 : 0;
sal_Int32 nVerticalAxisDimension = bVertical ? 0 : 1;
@@ -1081,7 +1030,7 @@ void AxisHelper::setRTLAxisLayout( const Reference< XCoordinateSystem >& xCooSys
try
{
//reverse direction for horizontal main axis
- Reference< chart2::XAxis > xHorizontalMainAxis( AxisHelper::getAxis( nHorizontalAxisDimension, MAIN_AXIS_INDEX, xCooSys ) );
+ rtl::Reference< Axis > xHorizontalMainAxis = AxisHelper::getAxis( nHorizontalAxisDimension, MAIN_AXIS_INDEX, xCooSys );
if( xHorizontalMainAxis.is() )
{
chart2::ScaleData aScale = xHorizontalMainAxis->getScaleData();
@@ -1090,7 +1039,7 @@ void AxisHelper::setRTLAxisLayout( const Reference< XCoordinateSystem >& xCooSys
}
//mathematical direction for vertical main axis
- Reference< chart2::XAxis > xVerticalMainAxis( AxisHelper::getAxis( nVerticalAxisDimension, MAIN_AXIS_INDEX, xCooSys ) );
+ rtl::Reference< Axis > xVerticalMainAxis = AxisHelper::getAxis( nVerticalAxisDimension, MAIN_AXIS_INDEX, xCooSys );
if( xVerticalMainAxis.is() )
{
chart2::ScaleData aScale = xVerticalMainAxis->getScaleData();
@@ -1106,7 +1055,7 @@ void AxisHelper::setRTLAxisLayout( const Reference< XCoordinateSystem >& xCooSys
try
{
//reverse direction for horizontal secondary axis
- Reference< chart2::XAxis > xHorizontalSecondaryAxis( AxisHelper::getAxis( nHorizontalAxisDimension, SECONDARY_AXIS_INDEX, xCooSys ) );
+ rtl::Reference< Axis > xHorizontalSecondaryAxis = AxisHelper::getAxis( nHorizontalAxisDimension, SECONDARY_AXIS_INDEX, xCooSys );
if( xHorizontalSecondaryAxis.is() )
{
chart2::ScaleData aScale = xHorizontalSecondaryAxis->getScaleData();
@@ -1115,7 +1064,7 @@ void AxisHelper::setRTLAxisLayout( const Reference< XCoordinateSystem >& xCooSys
}
//mathematical direction for vertical secondary axis
- Reference< chart2::XAxis > xVerticalSecondaryAxis( AxisHelper::getAxis( nVerticalAxisDimension, SECONDARY_AXIS_INDEX, xCooSys ) );
+ rtl::Reference< Axis > xVerticalSecondaryAxis = AxisHelper::getAxis( nVerticalAxisDimension, SECONDARY_AXIS_INDEX, xCooSys );
if( xVerticalSecondaryAxis.is() )
{
chart2::ScaleData aScale = xVerticalSecondaryAxis->getScaleData();
@@ -1129,16 +1078,16 @@ void AxisHelper::setRTLAxisLayout( const Reference< XCoordinateSystem >& xCooSys
}
}
-Reference< XChartType > AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisIndex( const Reference< chart2::XDiagram >& xDiagram, const sal_Int32 nAttachedAxisIndex )
+rtl::Reference< ChartType > AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisIndex( const rtl::Reference< Diagram >& xDiagram, const sal_Int32 nAttachedAxisIndex )
{
- Reference< XChartType > xChartType;
- std::vector< Reference< XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ rtl::Reference< ChartType > xChartType;
+ std::vector< rtl::Reference< DataSeries > > aSeriesVector = xDiagram->getDataSeries();
for (auto const& series : aSeriesVector)
{
sal_Int32 nCurrentIndex = DataSeriesHelper::getAttachedAxisIndex(series);
if( nAttachedAxisIndex == nCurrentIndex )
{
- xChartType = DiagramHelper::getChartTypeOfSeries(xDiagram, series);
+ xChartType = xDiagram->getChartTypeOfSeries(series);
if(xChartType.is())
break;
}
@@ -1148,7 +1097,7 @@ Reference< XChartType > AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisInd
bool AxisHelper::isAxisPositioningEnabled()
{
- const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(SvtSaveOptions().GetODFSaneDefaultVersion());
+ const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(GetODFSaneDefaultVersion());
return nCurrentVersion >= SvtSaveOptions::ODFSVER_012;
}
diff --git a/chart2/source/tools/BaseGFXHelper.cxx b/chart2/source/tools/BaseGFXHelper.cxx
index 9c475bc759d1..17bd4f5e1809 100644
--- a/chart2/source/tools/BaseGFXHelper.cxx
+++ b/chart2/source/tools/BaseGFXHelper.cxx
@@ -60,6 +60,38 @@ namespace chart::BaseGFXHelper
return aRet;
}
+::basegfx::B3DRange getBoundVolume( const std::vector<std::vector<css::drawing::Position3D>>& rPolyPoly )
+{
+ ::basegfx::B3DRange aRet;
+
+ bool bInited = false;
+ sal_Int32 nPolyCount = rPolyPoly.size();
+ for(sal_Int32 nPoly = 0; nPoly < nPolyCount; nPoly++)
+ {
+ sal_Int32 nPointCount = rPolyPoly[nPoly].size();
+ for( sal_Int32 nPoint = 0; nPoint < nPointCount; nPoint++)
+ {
+ if(!bInited)
+ {
+ aRet = ::basegfx::B3DRange(::basegfx::B3DTuple(
+ rPolyPoly[nPoly][nPoint].PositionX
+ , rPolyPoly[nPoly][nPoint].PositionY
+ , rPolyPoly[nPoly][nPoint].PositionZ));
+ bInited = true;
+ }
+ else
+ {
+ aRet.expand( ::basegfx::B3DTuple(
+ rPolyPoly[nPoly][nPoint].PositionX
+ , rPolyPoly[nPoly][nPoint].PositionY
+ , rPolyPoly[nPoly][nPoint].PositionZ));
+ }
+ }
+ }
+
+ return aRet;
+}
+
B2IRectangle makeRectangle( const awt::Point& rPos, const awt::Size& rSize )
{
return B2IRectangle(rPos.X,rPos.Y,rPos.X+rSize.Width,rPos.Y+rSize.Height);
@@ -81,6 +113,12 @@ awt::Size B2IRectangleToAWTSize( const ::basegfx::B2IRectangle& rB2IRectangle )
static_cast< sal_Int32 >( rB2IRectangle.getHeight()));
}
+awt::Rectangle toAwtRectangle(const basegfx::B2IRectangle& rRectangle)
+{
+ return awt::Rectangle(rRectangle.getMinX(), rRectangle.getMinY(),
+ rRectangle.getWidth(), rRectangle.getHeight());
+}
+
B3DVector Direction3DToB3DVector( const Direction3D& rDirection )
{
return B3DVector(
diff --git a/chart2/source/tools/CachedDataSequence.cxx b/chart2/source/tools/CachedDataSequence.cxx
index 4eaf5d8f2743..7ddc9a010408 100644
--- a/chart2/source/tools/CachedDataSequence.cxx
+++ b/chart2/source/tools/CachedDataSequence.cxx
@@ -23,7 +23,6 @@
#include <comphelper/sequenceashashmap.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
#include <algorithm>
@@ -35,14 +34,11 @@ using ::com::sun::star::uno::Any;
using ::osl::MutexGuard;
// necessary for MS compiler
-using ::comphelper::OPropertyContainer;
-using ::comphelper::OMutexAndBroadcastHelper;
-using ::comphelper::OPropertyArrayUsageHelper;
using ::chart::impl::CachedDataSequence_Base;
namespace
{
-const char lcl_aServiceName[] = "com.sun.star.comp.chart.CachedDataSequence";
+constexpr OUString lcl_aServiceName = u"com.sun.star.comp.chart.CachedDataSequence"_ustr;
enum
{
@@ -56,41 +52,31 @@ namespace chart
{
CachedDataSequence::CachedDataSequence()
- : OPropertyContainer( GetBroadcastHelper()),
- CachedDataSequence_Base( GetMutex()),
- m_eCurrentDataType( NUMERICAL ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ : m_eCurrentDataType( NUMERICAL ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
registerProperties();
}
CachedDataSequence::CachedDataSequence( const Reference< uno::XComponentContext > & /*xContext*/ )
- : OPropertyContainer( GetBroadcastHelper()),
- CachedDataSequence_Base( GetMutex()),
- m_eCurrentDataType( MIXED ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder( ))
+ : m_eCurrentDataType( MIXED ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
registerProperties();
}
CachedDataSequence::CachedDataSequence( const OUString & rSingleText )
- : OPropertyContainer( GetBroadcastHelper()),
- CachedDataSequence_Base( GetMutex()),
- m_eCurrentDataType( TEXTUAL ),
+ : m_eCurrentDataType( TEXTUAL ),
m_aTextualSequence({rSingleText}),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
registerProperties();
}
CachedDataSequence::CachedDataSequence( const CachedDataSequence & rSource )
- : OMutexAndBroadcastHelper(),
- OPropertyContainer( GetBroadcastHelper()),
- OPropertyArrayUsageHelper< CachedDataSequence >(),
- CachedDataSequence_Base( GetMutex()),
- m_nNumberFormatKey( rSource.m_nNumberFormatKey ),
+ : m_nNumberFormatKey( rSource.m_nNumberFormatKey ),
m_sRole( rSource.m_sRole ),
m_eCurrentDataType( rSource.m_eCurrentDataType ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
switch( m_eCurrentDataType )
{
@@ -218,8 +204,8 @@ Sequence< Any > CachedDataSequence::Impl_getMixedData() const
return aResult;
}
-IMPLEMENT_FORWARD_XINTERFACE2( CachedDataSequence, CachedDataSequence_Base, OPropertyContainer )
-IMPLEMENT_FORWARD_XTYPEPROVIDER2( CachedDataSequence, CachedDataSequence_Base, OPropertyContainer )
+IMPLEMENT_FORWARD_XINTERFACE2( CachedDataSequence, CachedDataSequence_Base, comphelper::OPropertyContainer2 )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( CachedDataSequence, CachedDataSequence_Base, comphelper::OPropertyContainer2 )
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL CachedDataSequence::getPropertySetInfo()
@@ -266,7 +252,7 @@ css::uno::Sequence< OUString > SAL_CALL CachedDataSequence::getSupportedServiceN
// ________ XNumericalDataSequence ________
Sequence< double > SAL_CALL CachedDataSequence::getNumericalData()
{
- MutexGuard aGuard( GetMutex() );
+ std::unique_lock aGuard( m_aMutex );
if( m_eCurrentDataType == NUMERICAL )
return m_aNumericalSequence;
@@ -277,7 +263,7 @@ Sequence< double > SAL_CALL CachedDataSequence::getNumericalData()
// ________ XTextualDataSequence ________
Sequence< OUString > SAL_CALL CachedDataSequence::getTextualData()
{
- MutexGuard aGuard( GetMutex() );
+ std::unique_lock aGuard( m_aMutex );
if( m_eCurrentDataType == TEXTUAL )
return m_aTextualSequence;
@@ -288,7 +274,7 @@ Sequence< OUString > SAL_CALL CachedDataSequence::getTextualData()
// ________ XDataSequence ________
Sequence< Any > SAL_CALL CachedDataSequence::getData()
{
- MutexGuard aGuard( GetMutex() );
+ std::unique_lock aGuard( m_aMutex );
return Impl_getMixedData();
}
@@ -310,35 +296,17 @@ Sequence< OUString > SAL_CALL CachedDataSequence::generateLabel( chart2::data::L
Reference< util::XCloneable > SAL_CALL CachedDataSequence::createClone()
{
- CachedDataSequence * pNewSeq = new CachedDataSequence( *this );
-
- return Reference< util::XCloneable >( pNewSeq );
+ return new CachedDataSequence( *this );
}
void SAL_CALL CachedDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL CachedDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// lang::XInitialization:
diff --git a/chart2/source/tools/CharacterProperties.cxx b/chart2/source/tools/CharacterProperties.cxx
index 659ef6d955f3..bf44c6a4c08f 100644
--- a/chart2/source/tools/CharacterProperties.cxx
+++ b/chart2/source/tools/CharacterProperties.cxx
@@ -35,7 +35,9 @@
#include <unotools/lingucfg.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <i18nlangtag/languagetag.hxx>
+#include <tools/color.hxx>
#include <vcl/outdev.hxx>
+#include <vcl/svapp.hxx>
using namespace ::com::sun::star;
@@ -339,15 +341,16 @@ void CharacterProperties::AddPropertiesToVector(
void CharacterProperties::AddDefaultsToMap(
::chart::tPropertyValueMap & rOutMap )
{
+ SolarMutexGuard aGuard;
const float fDefaultFontHeight = 13.0;
SvtLinguConfig aLinguConfig;
lang::Locale aDefaultLocale;
- aLinguConfig.GetProperty("DefaultLocale") >>= aDefaultLocale;
+ aLinguConfig.GetProperty(u"DefaultLocale") >>= aDefaultLocale;
lang::Locale aDefaultLocale_CJK;
- aLinguConfig.GetProperty("DefaultLocale_CJK") >>= aDefaultLocale_CJK;
+ aLinguConfig.GetProperty(u"DefaultLocale_CJK") >>= aDefaultLocale_CJK;
lang::Locale aDefaultLocale_CTL;
- aLinguConfig.GetProperty("DefaultLocale_CTL") >>= aDefaultLocale_CTL;
+ aLinguConfig.GetProperty(u"DefaultLocale_CTL") >>= aDefaultLocale_CTL;
using namespace ::com::sun::star::i18n::ScriptType;
LanguageType nLang;
@@ -363,19 +366,19 @@ void CharacterProperties::AddDefaultsToMap(
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_FAMILY, sal_Int16(aFont.GetFamilyType()) );//awt::FontFamily::SWISS
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_CHAR_SET, sal_Int16(aFont.GetCharSet()) );//use awt::CharSet::DONTKNOW instead of SYSTEM to avoid assertion issue 50249
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_PITCH, sal_Int16(aFont.GetPitch()) );//awt::FontPitch::VARIABLE
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_CHAR_COLOR, -1 ); //automatic color (COL_AUTO)
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COLOR, COL_AUTO ); //automatic color
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_CHAR_HEIGHT, fDefaultFontHeight );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_UNDERLINE, awt::FontUnderline::NONE );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_CHAR_UNDERLINE_COLOR, -1 ); //automatic color (COL_AUTO)
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_UNDERLINE_COLOR, COL_AUTO ); //automatic color
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_UNDERLINE_HAS_COLOR, false );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_OVERLINE, awt::FontUnderline::NONE );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_CHAR_OVERLINE_COLOR, -1 ); //automatic color (COL_AUTO)
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_OVERLINE_COLOR, COL_AUTO ); //automatic color
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_OVERLINE_HAS_COLOR, false );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_WEIGHT, awt::FontWeight::NORMAL );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_POSTURE, awt::FontSlant_NONE );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_AUTO_KERNING, true );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_CHAR_KERNING, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_CHAR_STRIKE_OUT, awt::FontStrikeout::NONE );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_KERNING, sal_Int16(0) );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_STRIKE_OUT, awt::FontStrikeout::NONE );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_WORD_MODE, false );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_LOCALE, aDefaultLocale );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_SHADOWED, false );
diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx
index 2d684b059355..6c2420e7bd7c 100644
--- a/chart2/source/tools/ChartModelHelper.cxx
+++ b/chart2/source/tools/ChartModelHelper.cxx
@@ -18,36 +18,29 @@
*/
#include <ChartModelHelper.hxx>
-#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
+#include <DataSource.hxx>
#include <DataSourceHelper.hxx>
#include <ControllerLockGuard.hxx>
-#include <RangeHighlighter.hxx>
#include <InternalDataProvider.hxx>
#include <ChartModel.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <ChartType.hxx>
+#include <DataSeries.hxx>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
-#include <com/sun/star/chart2/data/XDataReceiver.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/embed/Aspects.hpp>
-#include <com/sun/star/embed/XVisualObject.hpp>
#include <com/sun/star/view/XSelectionChangeListener.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace chart
{
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-uno::Reference< chart2::data::XRangeHighlighter > ChartModelHelper::createRangeHighlighter(
- const uno::Reference< view::XSelectionSupplier > & xSelectionSupplier )
-{
- return new RangeHighlighter( xSelectionSupplier );
-}
-
-uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDataProvider(
- const uno::Reference< css::chart2::XChartDocument >& xChartDoc, bool bConnectToModel )
+rtl::Reference< InternalDataProvider > ChartModelHelper::createInternalDataProvider(
+ const rtl::Reference<::chart::ChartModel>& xChartDoc, bool bConnectToModel )
{
bool bDefaultDataInColumns(true);
@@ -55,7 +48,8 @@ uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDa
// chart data and use it as default for creating a new InternalDataProvider
if(xChartDoc.is())
{
- css::uno::Reference< css::chart::XChartDocument > xDoc(xChartDoc, uno::UNO_QUERY);
+ // old XChartDocument interface
+ css::uno::Reference< css::chart::XChartDocument > xDoc(static_cast<cppu::OWeakObject*>(xChartDoc.get()), uno::UNO_QUERY);
if(xDoc.is())
{
@@ -80,89 +74,36 @@ uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDa
return new InternalDataProvider( xChartDoc, bConnectToModel, bDefaultDataInColumns );
}
-uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< frame::XModel >& xModel )
-{
- uno::Reference< XChartDocument > xChartDoc( xModel, uno::UNO_QUERY );
- if( xChartDoc.is())
- return ChartModelHelper::findDiagram( xChartDoc );
- return nullptr;
-}
-
-uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< chart2::XChartDocument >& xChartDoc )
+rtl::Reference< BaseCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( const rtl::Reference<::chart::ChartModel>& xModel )
{
- try
+ rtl::Reference< Diagram > xDiagram = xModel->getFirstChartDiagram();
+ if( xDiagram.is() )
{
- if( xChartDoc.is())
- return xChartDoc->getFirstDiagram();
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
+ auto aCooSysSeq( xDiagram->getBaseCoordinateSystems() );
+ if( !aCooSysSeq.empty() )
+ return aCooSysSeq[0];
}
return nullptr;
}
-uno::Reference< XCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( ChartModel& rModel )
-{
- uno::Reference< XCoordinateSystem > XCooSys;
- uno::Reference< XCoordinateSystemContainer > xCooSysCnt( rModel.getFirstDiagram(), uno::UNO_QUERY );
- if( xCooSysCnt.is() )
- {
- uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
- if( aCooSysSeq.hasElements() )
- XCooSys = aCooSysSeq[0];
- }
- return XCooSys;
-}
-
-uno::Reference< XCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( const uno::Reference< frame::XModel >& xModel )
-{
- uno::Reference< XCoordinateSystem > XCooSys;
- uno::Reference< XCoordinateSystemContainer > xCooSysCnt( ChartModelHelper::findDiagram( xModel ), uno::UNO_QUERY );
- if( xCooSysCnt.is() )
- {
- uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
- if( aCooSysSeq.hasElements() )
- XCooSys = aCooSysSeq[0];
- }
- return XCooSys;
-}
-
-std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
- ChartModel& rModel )
-{
- std::vector< uno::Reference< XDataSeries > > aResult;
-
- uno::Reference< XDiagram > xDiagram = rModel.getFirstDiagram();
- if( xDiagram.is())
- aResult = DiagramHelper::getDataSeriesFromDiagram( xDiagram );
-
- return aResult;
-}
-
-std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
- const uno::Reference< XChartDocument > & xChartDoc )
+std::vector< rtl::Reference< DataSeries > > ChartModelHelper::getDataSeries(
+ const rtl::Reference<::chart::ChartModel> & xChartDoc )
{
- std::vector< uno::Reference< XDataSeries > > aResult;
+ std::vector< rtl::Reference< DataSeries > > aResult;
- uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartDoc );
+ rtl::Reference< Diagram > xDiagram = xChartDoc->getFirstChartDiagram();
if( xDiagram.is())
- aResult = DiagramHelper::getDataSeriesFromDiagram( xDiagram );
+ aResult = xDiagram->getDataSeries();
return aResult;
}
-std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
- const uno::Reference< frame::XModel > & xModel )
-{
- return getDataSeries( uno::Reference< chart2::XChartDocument >( xModel, uno::UNO_QUERY ));
-}
-
-uno::Reference< XChartType > ChartModelHelper::getChartTypeOfSeries(
- const uno::Reference< frame::XModel >& xModel
- , const uno::Reference< XDataSeries >& xGivenDataSeries )
+rtl::Reference< ChartType > ChartModelHelper::getChartTypeOfSeries(
+ const rtl::Reference<::chart::ChartModel>& xModel
+ , const rtl::Reference< DataSeries >& xGivenDataSeries )
{
- return DiagramHelper::getChartTypeOfSeries( ChartModelHelper::findDiagram( xModel ), xGivenDataSeries );
+ rtl::Reference<Diagram> xDiagram = xModel->getFirstChartDiagram();
+ return xDiagram ? xDiagram->getChartTypeOfSeries( xGivenDataSeries ) : nullptr;
}
awt::Size ChartModelHelper::getDefaultPageSize()
@@ -170,22 +111,20 @@ awt::Size ChartModelHelper::getDefaultPageSize()
return awt::Size( 16000, 9000 );
}
-awt::Size ChartModelHelper::getPageSize( const uno::Reference< frame::XModel >& xModel )
+awt::Size ChartModelHelper::getPageSize( const rtl::Reference<::chart::ChartModel>& xModel )
{
awt::Size aPageSize( ChartModelHelper::getDefaultPageSize() );
- uno::Reference< embed::XVisualObject > xVisualObject(xModel,uno::UNO_QUERY);
- OSL_ENSURE(xVisualObject.is(),"need xVisualObject for page size");
- if( xVisualObject.is() )
- aPageSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
+ OSL_ENSURE(xModel.is(),"need xVisualObject for page size");
+ if( xModel.is() )
+ aPageSize = xModel->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
return aPageSize;
}
-void ChartModelHelper::triggerRangeHighlighting( const uno::Reference< frame::XModel >& xModel )
+void ChartModelHelper::triggerRangeHighlighting( const rtl::Reference<::chart::ChartModel>& xModel )
{
- uno::Reference< chart2::data::XDataReceiver > xDataReceiver( xModel, uno::UNO_QUERY );
- if( xDataReceiver.is() )
+ if( xModel.is() )
{
- uno::Reference< view::XSelectionChangeListener > xSelectionChangeListener( xDataReceiver->getRangeHighlighter(), uno::UNO_QUERY );
+ uno::Reference< view::XSelectionChangeListener > xSelectionChangeListener( xModel->getRangeHighlighter(), uno::UNO_QUERY );
//trigger selection of cell range
if( xSelectionChangeListener.is() )
{
@@ -195,21 +134,17 @@ void ChartModelHelper::triggerRangeHighlighting( const uno::Reference< frame::XM
}
}
-bool ChartModelHelper::isIncludeHiddenCells( const uno::Reference< frame::XModel >& xChartModel )
+bool ChartModelHelper::isIncludeHiddenCells( const rtl::Reference<::chart::ChartModel>& xChartModel )
{
bool bIncluded = true; // hidden cells are included by default.
- uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) );
+ rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() );
if (!xDiagram.is())
return bIncluded;
- uno::Reference< beans::XPropertySet > xProp( xDiagram, uno::UNO_QUERY );
- if (!xProp.is())
- return bIncluded;
-
try
{
- xProp->getPropertyValue("IncludeHiddenCells") >>= bIncluded;
+ xDiagram->getPropertyValue("IncludeHiddenCells") >>= bIncluded;
}
catch( const beans::UnknownPropertyException& )
{
@@ -250,7 +185,7 @@ bool ChartModelHelper::setIncludeHiddenCells( bool bIncludeHiddenCells, ChartMod
try
{
- uno::Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( rModel ) );
+ rtl::Reference< DataSource > xUsedData = DataSourceHelper::getUsedData( rModel );
if( xUsedData.is() )
{
uno::Reference< beans::XPropertySet > xProp;
diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx
index a4b8059ffb19..b8df30edfbd5 100644
--- a/chart2/source/tools/ChartTypeHelper.cxx
+++ b/chart2/source/tools/ChartTypeHelper.cxx
@@ -18,24 +18,27 @@
*/
#include <ChartTypeHelper.hxx>
+#include <ChartType.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <DataSeriesProperties.hxx>
#include <DiagramHelper.hxx>
#include <servicenames_charttypes.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/chart/DataLabelPlacement.hpp>
+#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/StackingDirection.hpp>
-#include <com/sun/star/chart/MissingValueTreatment.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
+using namespace ::chart::DataSeriesProperties;
namespace chart
{
bool ChartTypeHelper::isSupportingAxisSideBySide(
- const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
+ const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount )
{
bool bResult = false;
@@ -56,7 +59,7 @@ bool ChartTypeHelper::isSupportingAxisSideBySide(
return bResult;
}
-bool ChartTypeHelper::isSupportingGeometryProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
+bool ChartTypeHelper::isSupportingGeometryProperties( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount )
{
//form tab only for 3D-bar and 3D-column charts.
@@ -75,7 +78,7 @@ bool ChartTypeHelper::isSupportingGeometryProperties( const uno::Reference< XCha
return false;
}
-bool ChartTypeHelper::isSupportingStatisticProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
+bool ChartTypeHelper::isSupportingStatisticProperties( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount )
{
//3D charts, pie, net and stock do not support statistic properties
@@ -100,20 +103,20 @@ bool ChartTypeHelper::isSupportingStatisticProperties( const uno::Reference< XCh
return true;
}
-bool ChartTypeHelper::isSupportingRegressionProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
+bool ChartTypeHelper::isSupportingRegressionProperties( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount )
{
// note: old chart: only scatter chart
return isSupportingStatisticProperties( xChartType, nDimensionCount );
}
-bool ChartTypeHelper::isSupportingAreaProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
+bool ChartTypeHelper::isSupportingAreaProperties( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount )
{
//2D line charts, net and stock do not support area properties
//@todo ask charttype itself --> need model change first
if(xChartType.is())
{
- if(nDimensionCount==2)
+ if(nDimensionCount==2)
{
OUString aChartTypeName = xChartType->getChartType();
if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
@@ -129,7 +132,7 @@ bool ChartTypeHelper::isSupportingAreaProperties( const uno::Reference< XChartTy
return true;
}
-bool ChartTypeHelper::isSupportingSymbolProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
+bool ChartTypeHelper::isSupportingSymbolProperties( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount )
{
//2D line charts, 2D scatter charts and 2D net charts do support symbols
@@ -150,7 +153,7 @@ bool ChartTypeHelper::isSupportingSymbolProperties( const uno::Reference< XChart
return false;
}
-bool ChartTypeHelper::isSupportingMainAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
+bool ChartTypeHelper::isSupportingMainAxis( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
{
//pie charts do not support axis at all
//no 3rd axis for 2D charts
@@ -168,7 +171,7 @@ bool ChartTypeHelper::isSupportingMainAxis( const uno::Reference< XChartType >&
return true;
}
-bool ChartTypeHelper::isSupportingSecondaryAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
+bool ChartTypeHelper::isSupportingSecondaryAxis( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount )
{
//3D, pie and net charts do not support a secondary axis at all
@@ -190,7 +193,7 @@ bool ChartTypeHelper::isSupportingSecondaryAxis( const uno::Reference< XChartTyp
}
bool ChartTypeHelper::isSupportingOverlapAndGapWidthProperties(
- const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
+ const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount )
{
//2D bar charts do support a this special properties
@@ -210,7 +213,7 @@ bool ChartTypeHelper::isSupportingOverlapAndGapWidthProperties(
}
bool ChartTypeHelper::isSupportingBarConnectors(
- const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
+ const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount )
{
//2D bar charts with stacked series support this
@@ -235,9 +238,9 @@ bool ChartTypeHelper::isSupportingBarConnectors(
return false;
}
-uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const uno::Reference< chart2::XChartType >& xChartType
+uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const rtl::Reference< ChartType >& xChartType
, bool bSwapXAndY
- , const uno::Reference< chart2::XDataSeries >& xSeries )
+ , const rtl::Reference< DataSeries >& xSeries )
{
uno::Sequence < sal_Int32 > aRet;
if( !xChartType.is() )
@@ -247,8 +250,7 @@ uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const
if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
{
bool bDonut = false;
- uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
- xChartTypeProp->getPropertyValue( "UseRings") >>= bDonut;
+ xChartType->getFastPropertyValue( PROP_PIECHARTTYPE_USE_RINGS ) >>= bDonut; // "UseRings"
if(!bDonut)
{
@@ -286,9 +288,8 @@ uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const
bool bStacked = false;
{
- uno::Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
chart2::StackingDirection eStacking = chart2::StackingDirection_NO_STACKING;
- xSeriesProp->getPropertyValue( "StackingDirection" ) >>= eStacking;
+ xSeries->getFastPropertyValue( PROP_DATASERIES_STACKING_DIRECTION ) >>= eStacking; // "StackingDirection"
bStacked = (eStacking == chart2::StackingDirection_Y_STACKING);
}
@@ -317,9 +318,8 @@ uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const
{
bool bStacked = false;
{
- uno::Reference<beans::XPropertySet> xSeriesProp(xSeries, uno::UNO_QUERY);
chart2::StackingDirection eStacking = chart2::StackingDirection_NO_STACKING;
- xSeriesProp->getPropertyValue("StackingDirection") >>= eStacking;
+ xSeries->getFastPropertyValue(PROP_DATASERIES_STACKING_DIRECTION) >>= eStacking; // "StackingDirection"
bStacked = (eStacking == chart2::StackingDirection_Y_STACKING);
}
@@ -367,7 +367,7 @@ uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const
return aRet;
}
-bool ChartTypeHelper::isSupportingRightAngledAxes( const uno::Reference< chart2::XChartType >& xChartType )
+bool ChartTypeHelper::isSupportingRightAngledAxes( const rtl::Reference< ChartType >& xChartType )
{
if(xChartType.is())
{
@@ -378,7 +378,7 @@ bool ChartTypeHelper::isSupportingRightAngledAxes( const uno::Reference< chart2:
return true;
}
-bool ChartTypeHelper::isSupportingStartingAngle( const uno::Reference< chart2::XChartType >& xChartType )
+bool ChartTypeHelper::isSupportingStartingAngle( const rtl::Reference< ChartType >& xChartType )
{
if(xChartType.is())
{
@@ -388,7 +388,7 @@ bool ChartTypeHelper::isSupportingStartingAngle( const uno::Reference< chart2::X
}
return false;
}
-bool ChartTypeHelper::isSupportingBaseValue( const uno::Reference< chart2::XChartType >& xChartType )
+bool ChartTypeHelper::isSupportingBaseValue( const rtl::Reference< ChartType >& xChartType )
{
if(xChartType.is())
{
@@ -402,7 +402,7 @@ bool ChartTypeHelper::isSupportingBaseValue( const uno::Reference< chart2::XChar
return false;
}
-bool ChartTypeHelper::isSupportingAxisPositioning( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
+bool ChartTypeHelper::isSupportingAxisPositioning( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
{
if(xChartType.is())
{
@@ -417,7 +417,7 @@ bool ChartTypeHelper::isSupportingAxisPositioning( const uno::Reference< chart2:
return true;
}
-bool ChartTypeHelper::isSupportingDateAxis( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionIndex )
+bool ChartTypeHelper::isSupportingDateAxis( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionIndex )
{
if( nDimensionIndex!=0 )
return false;
@@ -437,7 +437,7 @@ bool ChartTypeHelper::isSupportingDateAxis( const uno::Reference< chart2::XChart
return true;
}
-bool ChartTypeHelper::isSupportingComplexCategory( const uno::Reference< chart2::XChartType >& xChartType )
+bool ChartTypeHelper::isSupportingComplexCategory( const rtl::Reference< ChartType >& xChartType )
{
if( xChartType.is() )
{
@@ -448,7 +448,7 @@ bool ChartTypeHelper::isSupportingComplexCategory( const uno::Reference< chart2:
return true;
}
-bool ChartTypeHelper::isSupportingCategoryPositioning( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
+bool ChartTypeHelper::isSupportingCategoryPositioning( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionCount )
{
if( xChartType.is() )
{
@@ -464,7 +464,20 @@ bool ChartTypeHelper::isSupportingCategoryPositioning( const uno::Reference< cha
return false;
}
-bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XChartType >& xChartType )
+bool ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( const rtl::Reference< ChartType >& xChartType )
+{
+ if(xChartType.is())
+ {
+ OUString aChartTypeName = xChartType->getChartType();
+ if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
+ || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR)
+ || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
+ return true;
+ }
+ return false;
+}
+
+bool ChartTypeHelper::noBordersForSimpleScheme( const rtl::Reference< ChartType >& xChartType )
{
if(xChartType.is())
{
@@ -475,7 +488,7 @@ bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XC
return false;
}
-sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
+sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const rtl::Reference< ChartType >& xChartType )
{
sal_Int32 nRet = static_cast< sal_Int32 >( 0x808080 ); // grey
if( xChartType .is() )
@@ -495,7 +508,7 @@ sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const uno::
return nRet;
}
-sal_Int32 ChartTypeHelper::getDefaultAmbientLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
+sal_Int32 ChartTypeHelper::getDefaultAmbientLightColor( bool bSimple, const rtl::Reference< ChartType >& xChartType )
{
sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40
if( xChartType .is() )
@@ -512,7 +525,7 @@ sal_Int32 ChartTypeHelper::getDefaultAmbientLightColor( bool bSimple, const uno:
return nRet;
}
-drawing::Direction3D ChartTypeHelper::getDefaultSimpleLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
+drawing::Direction3D ChartTypeHelper::getDefaultSimpleLightDirection( const rtl::Reference< ChartType >& xChartType )
{
drawing::Direction3D aRet(0.0, 0.0, 1.0);
if( xChartType .is() )
@@ -527,7 +540,7 @@ drawing::Direction3D ChartTypeHelper::getDefaultSimpleLightDirection( const uno:
return aRet;
}
-drawing::Direction3D ChartTypeHelper::getDefaultRealisticLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
+drawing::Direction3D ChartTypeHelper::getDefaultRealisticLightDirection( const rtl::Reference< ChartType >& xChartType )
{
drawing::Direction3D aRet(0.0, 0.0, 1.0);
if( xChartType .is() )
@@ -542,8 +555,8 @@ drawing::Direction3D ChartTypeHelper::getDefaultRealisticLightDirection( const u
return aRet;
}
-sal_Int32 ChartTypeHelper::getAxisType( const uno::Reference<
- XChartType >& xChartType, sal_Int32 nDimensionIndex )
+sal_Int32 ChartTypeHelper::getAxisType( const rtl::Reference<
+ ChartType >& xChartType, sal_Int32 nDimensionIndex )
{
//returned is a constant from constant group css::chart2::AxisType
@@ -567,7 +580,7 @@ sal_Int32 ChartTypeHelper::getAxisType( const uno::Reference<
}
sal_Int32 ChartTypeHelper::getNumberOfDisplayedSeries(
- const uno::Reference< XChartType >& xChartType,
+ const rtl::Reference< ChartType >& xChartType,
sal_Int32 nNumberOfSeries )
{
if( xChartType.is() )
@@ -577,9 +590,8 @@ sal_Int32 ChartTypeHelper::getNumberOfDisplayedSeries(
OUString aChartTypeName = xChartType->getChartType();
if( aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_PIE )
{
- uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
bool bDonut = false;
- if( (xChartTypeProp->getPropertyValue( "UseRings") >>= bDonut)
+ if( (xChartType->getFastPropertyValue( PROP_PIECHARTTYPE_USE_RINGS ) >>= bDonut) // "UseRings"
&& !bDonut )
{
return nNumberOfSeries>0 ? 1 : 0;
@@ -594,7 +606,7 @@ sal_Int32 ChartTypeHelper::getNumberOfDisplayedSeries(
return nNumberOfSeries;
}
-uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedMissingValueTreatments( const uno::Reference< XChartType >& xChartType )
+uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedMissingValueTreatments( const rtl::Reference< ChartType >& xChartType )
{
uno::Sequence < sal_Int32 > aRet;
if( !xChartType.is() )
@@ -655,7 +667,7 @@ uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedMissingValueTreatments(
return aRet;
}
-bool ChartTypeHelper::isSeriesInFrontOfAxisLine( const uno::Reference< XChartType >& xChartType )
+bool ChartTypeHelper::isSeriesInFrontOfAxisLine( const rtl::Reference< ChartType >& xChartType )
{
if( xChartType.is() )
{
@@ -666,7 +678,7 @@ bool ChartTypeHelper::isSeriesInFrontOfAxisLine( const uno::Reference< XChartTyp
return true;
}
-OUString ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
+OUString ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( const rtl::Reference< ChartType >& xChartType )
{
OUString aRet( "values-y" );
if( !xChartType.is() )
@@ -677,7 +689,7 @@ OUString ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( const
return aRet;
}
-OUString ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
+OUString ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( const rtl::Reference< ChartType >& xChartType )
{
OUString aRet( "values-y" );
if( !xChartType.is() )
@@ -689,7 +701,7 @@ OUString ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( co
return aRet;
}
-bool ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( const uno::Reference< XChartType >& xChartType )
+bool ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( const rtl::Reference< ChartType >& xChartType )
{
bool bRet = false;
if( !xChartType.is() )
diff --git a/chart2/source/tools/ChartViewHelper.cxx b/chart2/source/tools/ChartViewHelper.cxx
index 8caaeddb1e94..8011da3c171c 100644
--- a/chart2/source/tools/ChartViewHelper.cxx
+++ b/chart2/source/tools/ChartViewHelper.cxx
@@ -18,30 +18,29 @@
*/
#include <ChartViewHelper.hxx>
+#include <ChartModel.hxx>
#include <servicenames.hxx>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/util/XModifyListener.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace chart
{
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
-void ChartViewHelper::setViewToDirtyState(const uno::Reference<frame::XModel>& xChartModel)
+void ChartViewHelper::setViewToDirtyState(const rtl::Reference<::chart::ChartModel>& xChartModel)
{
try
{
- uno::Reference<lang::XMultiServiceFactory> xFact(xChartModel, uno::UNO_QUERY);
- if (xFact.is())
+ if (xChartModel.is())
{
Reference<util::XModifyListener> xModifyListener(
- xFact->createInstance(CHART_VIEW_SERVICE_NAME), uno::UNO_QUERY);
+ xChartModel->createInstance(CHART_VIEW_SERVICE_NAME), uno::UNO_QUERY);
if (xModifyListener.is())
{
- lang::EventObject aEvent(xChartModel);
+ lang::EventObject aEvent(static_cast<cppu::OWeakObject*>(xChartModel.get()));
xModifyListener->modified(aEvent);
}
}
@@ -51,6 +50,13 @@ void ChartViewHelper::setViewToDirtyState(const uno::Reference<frame::XModel>& x
DBG_UNHANDLED_EXCEPTION("chart2");
}
}
+
+void ChartViewHelper::setViewToDirtyState_UNO(
+ const css::uno::Reference<css::chart2::XChartDocument>& xChartModel)
+{
+ if (auto pChartModel = dynamic_cast<ChartModel*>(xChartModel.get()))
+ setViewToDirtyState(rtl::Reference(pChartModel));
+}
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/tools/ColorPerPointHelper.cxx b/chart2/source/tools/ColorPerPointHelper.cxx
index 34aeb7866021..abc940c51357 100644
--- a/chart2/source/tools/ColorPerPointHelper.cxx
+++ b/chart2/source/tools/ColorPerPointHelper.cxx
@@ -18,33 +18,34 @@
*/
#include <ColorPerPointHelper.hxx>
+#include <DataSeries.hxx>
+#include <DataSeriesProperties.hxx>
#include <com/sun/star/chart2/XDataSeries.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
#include <algorithm>
+using namespace ::com::sun::star;
+using namespace ::chart::DataSeriesProperties;
+
namespace chart
{
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::chart2;
bool ColorPerPointHelper::hasPointOwnColor(
- const css::uno::Reference< css::beans::XPropertySet >& xDataSeriesProperties
+ const rtl::Reference< DataSeries >& xDataSeries
, sal_Int32 nPointIndex
, const css::uno::Reference< css::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance
)
{
- if( !xDataSeriesProperties.is() )
+ if( !xDataSeries.is() )
return false;
- if( hasPointOwnProperties( xDataSeriesProperties, nPointIndex ))
+ if( hasPointOwnProperties( xDataSeries, nPointIndex ))
{
uno::Reference< beans::XPropertyState > xPointState( xDataPointProperties, uno::UNO_QUERY );
if( !xPointState.is() )
{
- uno::Reference< XDataSeries > xSeries( xDataSeriesProperties, uno::UNO_QUERY );
- if(xSeries.is())
- xPointState.set( xSeries->getDataPointByIndex( nPointIndex ), uno::UNO_QUERY );
+ xPointState.set( xDataSeries->getDataPointByIndex( nPointIndex ), uno::UNO_QUERY );
}
if( !xPointState.is() )
return false;
@@ -56,13 +57,13 @@ bool ColorPerPointHelper::hasPointOwnColor(
}
bool ColorPerPointHelper::hasPointOwnProperties(
- const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties
+ const rtl::Reference< ::chart::DataSeries >& xDataSeries
, sal_Int32 nPointIndex )
{
- if( xSeriesProperties.is() )
+ if( xDataSeries.is() )
{
uno::Sequence< sal_Int32 > aIndexList;
- if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aIndexList )
+ if( xDataSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aIndexList ) // "AttributedDataPoints"
{
const sal_Int32 * pBegIt = aIndexList.getConstArray();
const sal_Int32 * pEndIt = pBegIt + aIndexList.getLength();
diff --git a/chart2/source/tools/CommonConverters.cxx b/chart2/source/tools/CommonConverters.cxx
index 01b2c2c758a4..293fa7b11ddf 100644
--- a/chart2/source/tools/CommonConverters.cxx
+++ b/chart2/source/tools/CommonConverters.cxx
@@ -24,9 +24,13 @@
#include <com/sun/star/chart2/data/XDataSequence.hpp>
#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
-#include <rtl/math.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <basegfx/matrix/b3dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+#include <cstddef>
+#include <limits>
namespace chart
{
@@ -88,9 +92,10 @@ drawing::HomogenMatrix B3DHomMatrixToHomogenMatrix( const ::basegfx::B3DHomMatri
aM.set(1, 0, rM.get(1, 0));
aM.set(1, 1, rM.get(1, 1));
aM.set(1, 2, rM.get(1, 3));
- aM.set(2, 0, rM.get(3, 0));
- aM.set(2, 1, rM.get(3, 1));
- aM.set(2, 2, rM.get(3, 3));
+ // For this to be a valid 2D transform matrix, the last row must be [0,0,1]
+ assert( rM.get(3, 0) == 0 );
+ assert( rM.get(3, 1) == 0 );
+ assert( rM.get(3, 3) == 1 );
return aM;
}
@@ -103,9 +108,9 @@ drawing::HomogenMatrix3 B2DHomMatrixToHomogenMatrix3( const ::basegfx::B2DHomMat
aHM.Line2.Column1 = rM.get(1, 0);
aHM.Line2.Column2 = rM.get(1, 1);
aHM.Line2.Column3 = rM.get(1, 2);
- aHM.Line3.Column1 = rM.get(2, 0);
- aHM.Line3.Column2 = rM.get(2, 1);
- aHM.Line3.Column3 = rM.get(2, 2);
+ aHM.Line3.Column1 = 0;
+ aHM.Line3.Column2 = 0;
+ aHM.Line3.Column3 = 1;
return aHM;
}
@@ -179,6 +184,24 @@ void AddPointToPoly( drawing::PolyPolygonShape3D& rPoly, const drawing::Position
pInnerSequenceZ[nOldPointCount] = rPos.PositionZ;
}
+void AddPointToPoly( std::vector<std::vector<css::drawing::Position3D>>& rPoly, const drawing::Position3D& rPos, sal_Int32 nPolygonIndex )
+{
+ if(nPolygonIndex<0)
+ {
+ OSL_FAIL( "The polygon index needs to be > 0");
+ nPolygonIndex=0;
+ }
+
+ //make sure that we have enough polygons
+ if(o3tl::make_unsigned(nPolygonIndex) >= rPoly.size() )
+ {
+ rPoly.resize(nPolygonIndex+1);
+ }
+
+ std::vector<css::drawing::Position3D>* pOuterSequence = &rPoly[nPolygonIndex];
+ pOuterSequence->push_back(rPos);
+}
+
drawing::Position3D getPointFromPoly( const drawing::PolyPolygonShape3D& rPolygon, sal_Int32 nPointIndex, sal_Int32 nPolyIndex )
{
drawing::Position3D aRet(0.0,0.0,0.0);
@@ -203,13 +226,34 @@ drawing::Position3D getPointFromPoly( const drawing::PolyPolygonShape3D& rPolygo
return aRet;
}
-void addPolygon( drawing::PolyPolygonShape3D& rRet, const drawing::PolyPolygonShape3D& rAdd )
+drawing::Position3D getPointFromPoly( const std::vector<std::vector<css::drawing::Position3D>>& rPolygon, sal_Int32 nPointIndex, sal_Int32 nPolyIndex )
+{
+ drawing::Position3D aRet(0.0,0.0,0.0);
+
+ if( nPolyIndex>=0 && o3tl::make_unsigned(nPolyIndex)<rPolygon.size())
+ {
+ if(nPointIndex<static_cast<sal_Int32>(rPolygon[nPolyIndex].size()))
+ {
+ aRet = rPolygon[nPolyIndex][nPointIndex];
+ }
+ else
+ {
+ OSL_FAIL("polygon was accessed with a wrong index");
+ }
+ }
+ else
+ {
+ OSL_FAIL("polygon was accessed with a wrong index");
+ }
+ return aRet;
+}
+
+void addPolygon( std::vector<std::vector<css::drawing::Position3D>>& rRet, const std::vector<std::vector<css::drawing::Position3D>>& rAdd )
{
- sal_Int32 nAddOuterCount = rAdd.SequenceX.getLength();
- sal_Int32 nOuterCount = rRet.SequenceX.getLength() + nAddOuterCount;
- rRet.SequenceX.realloc( nOuterCount );
- rRet.SequenceY.realloc( nOuterCount );
- rRet.SequenceZ.realloc( nOuterCount );
+ sal_Int32 nAddOuterCount = rAdd.size();
+ sal_Int32 nOuterCount = rRet.size() + nAddOuterCount;
+ rRet.resize( nOuterCount );
+ auto pSequence = rRet.data();
sal_Int32 nIndex = 0;
sal_Int32 nOuter = nOuterCount - nAddOuterCount;
@@ -218,43 +262,37 @@ void addPolygon( drawing::PolyPolygonShape3D& rRet, const drawing::PolyPolygonSh
if( nIndex >= nAddOuterCount )
break;
- rRet.SequenceX[nOuter] = rAdd.SequenceX[nIndex];
- rRet.SequenceY[nOuter] = rAdd.SequenceY[nIndex];
- rRet.SequenceZ[nOuter] = rAdd.SequenceZ[nIndex];
+ pSequence[nOuter] = rAdd[nIndex];
nIndex++;
}
}
-void appendPoly( drawing::PolyPolygonShape3D& rRet, const drawing::PolyPolygonShape3D& rAdd )
+void appendPoly( std::vector<std::vector<css::drawing::Position3D>>& rRet, const std::vector<std::vector<css::drawing::Position3D>>& rAdd )
{
- sal_Int32 nOuterCount = std::max( rRet.SequenceX.getLength(), rAdd.SequenceX.getLength() );
- rRet.SequenceX.realloc(nOuterCount);
- rRet.SequenceY.realloc(nOuterCount);
- rRet.SequenceZ.realloc(nOuterCount);
+ std::size_t nOuterCount = std::max( rRet.size(), rAdd.size() );
+ rRet.resize(nOuterCount);
+ auto pSequence = rRet.data();
- for( sal_Int32 nOuter=0;nOuter<nOuterCount;nOuter++ )
+ for( std::size_t nOuter=0;nOuter<nOuterCount;nOuter++ )
{
- sal_Int32 nOldPointCount = rRet.SequenceX[nOuter].getLength();
+ sal_Int32 nOldPointCount = rRet[nOuter].size();
sal_Int32 nAddPointCount = 0;
- if(nOuter<rAdd.SequenceX.getLength())
- nAddPointCount = rAdd.SequenceX[nOuter].getLength();
+ if(nOuter<rAdd.size())
+ nAddPointCount = rAdd[nOuter].size();
if(!nAddPointCount)
continue;
sal_Int32 nNewPointCount = nOldPointCount + nAddPointCount;
- rRet.SequenceX[nOuter].realloc(nNewPointCount);
- rRet.SequenceY[nOuter].realloc(nNewPointCount);
- rRet.SequenceZ[nOuter].realloc(nNewPointCount);
+ pSequence[nOuter].resize(nNewPointCount);
+ auto pSequence_nOuter = pSequence[nOuter].data();
sal_Int32 nPointTarget=nOldPointCount;
sal_Int32 nPointSource=nAddPointCount;
for( ; nPointSource-- ; nPointTarget++ )
{
- rRet.SequenceX[nOuter][nPointTarget] = rAdd.SequenceX[nOuter][nPointSource];
- rRet.SequenceY[nOuter][nPointTarget] = rAdd.SequenceY[nOuter][nPointSource];
- rRet.SequenceZ[nOuter][nPointTarget] = rAdd.SequenceZ[nOuter][nPointSource];
+ pSequence_nOuter[nPointTarget] = rAdd[nOuter][nPointSource];
}
}
}
@@ -266,16 +304,22 @@ drawing::PolyPolygonShape3D BezierToPoly(
drawing::PolyPolygonShape3D aRet;
aRet.SequenceX.realloc( rPointSequence.getLength() );
+ auto pSequenceX = aRet.SequenceX.getArray();
aRet.SequenceY.realloc( rPointSequence.getLength() );
+ auto pSequenceY = aRet.SequenceY.getArray();
aRet.SequenceZ.realloc( rPointSequence.getLength() );
+ auto pSequenceZ = aRet.SequenceZ.getArray();
sal_Int32 nRealOuter = 0;
for(sal_Int32 nN = 0; nN < rPointSequence.getLength(); nN++)
{
sal_Int32 nInnerLength = rPointSequence[nN].getLength();
- aRet.SequenceX[nN].realloc( nInnerLength );
- aRet.SequenceY[nN].realloc( nInnerLength );
- aRet.SequenceZ[nN].realloc( nInnerLength );
+ pSequenceX[nRealOuter].realloc( nInnerLength );
+ auto pSequenceX_nRealOuter = pSequenceX[nRealOuter].getArray();
+ pSequenceY[nRealOuter].realloc( nInnerLength );
+ auto pSequenceY_nRealOuter = pSequenceY[nRealOuter].getArray();
+ pSequenceZ[nRealOuter].realloc( nInnerLength );
+ auto pSequenceZ_nRealOuter = pSequenceZ[nRealOuter].getArray();
bool bHasOuterFlags = nN < rBezier.Flags.getLength();
@@ -286,16 +330,16 @@ drawing::PolyPolygonShape3D BezierToPoly(
if( !bHasInnerFlags || (rBezier.Flags[nN][nM] == drawing::PolygonFlags_NORMAL) )
{
- aRet.SequenceX[nRealOuter][nRealInner] = rPointSequence[nN][nM].X;
- aRet.SequenceY[nRealOuter][nRealInner] = rPointSequence[nN][nM].Y;
- aRet.SequenceZ[nRealOuter][nRealInner] = 0.0;
+ pSequenceX_nRealOuter[nRealInner] = rPointSequence[nN][nM].X;
+ pSequenceY_nRealOuter[nRealInner] = rPointSequence[nN][nM].Y;
+ pSequenceZ_nRealOuter[nRealInner] = 0.0;
nRealInner++;
}
}
- aRet.SequenceX[nRealOuter].realloc( nRealInner );
- aRet.SequenceY[nRealOuter].realloc( nRealInner );
- aRet.SequenceZ[nRealOuter].realloc( nRealInner );
+ pSequenceX[nRealOuter].realloc( nRealInner );
+ pSequenceY[nRealOuter].realloc( nRealInner );
+ pSequenceZ[nRealOuter].realloc( nRealInner );
if( nRealInner>0 )
nRealOuter++;
@@ -313,22 +357,72 @@ drawing::PointSequenceSequence PolyToPointSequence(
{
drawing::PointSequenceSequence aRet;
aRet.realloc( rPolyPolygon.SequenceX.getLength() );
+ auto pRet = aRet.getArray();
for(sal_Int32 nN = 0; nN < rPolyPolygon.SequenceX.getLength(); nN++)
{
sal_Int32 nInnerLength = rPolyPolygon.SequenceX[nN].getLength();
- aRet[nN].realloc( nInnerLength );
+ pRet[nN].realloc( nInnerLength );
+ auto pRet_nN = pRet[nN].getArray();
for( sal_Int32 nM = 0; nM < nInnerLength; nM++)
{
- aRet[nN][nM].X = static_cast<sal_Int32>(rPolyPolygon.SequenceX[nN][nM]);
- aRet[nN][nM].Y = static_cast<sal_Int32>(rPolyPolygon.SequenceY[nN][nM]);
+ pRet_nN[nM].X = static_cast<sal_Int32>(rPolyPolygon.SequenceX[nN][nM]);
+ pRet_nN[nM].Y = static_cast<sal_Int32>(rPolyPolygon.SequenceY[nN][nM]);
}
}
return aRet;
}
+drawing::PointSequenceSequence PolyToPointSequence(
+ const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon )
+{
+ drawing::PointSequenceSequence aRet;
+ aRet.realloc( rPolyPolygon.size() );
+ auto pRet = aRet.getArray();
+
+ for(std::size_t nN = 0; nN < rPolyPolygon.size(); nN++)
+ {
+ sal_Int32 nInnerLength = rPolyPolygon[nN].size();
+ pRet[nN].realloc( nInnerLength );
+ auto pRet_nN = pRet[nN].getArray();
+ for( sal_Int32 nM = 0; nM < nInnerLength; nM++)
+ {
+ pRet_nN[nM].X = static_cast<sal_Int32>(rPolyPolygon[nN][nM].PositionX);
+ pRet_nN[nM].Y = static_cast<sal_Int32>(rPolyPolygon[nN][nM].PositionY);
+ }
+ }
+ return aRet;
+}
+
+basegfx::B2DPolyPolygon PolyToB2DPolyPolygon(
+ const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon )
+{
+ basegfx::B2DPolyPolygon aRetval;
+
+ for(auto const & nN: rPolyPolygon)
+ {
+ basegfx::B2DPolygon aNewPolygon;
+ sal_Int32 nInnerLength = nN.size();
+ if(nInnerLength)
+ {
+ aNewPolygon.reserve(nInnerLength);
+ for( sal_Int32 nM = 0; nM < nInnerLength; nM++)
+ {
+ auto X = static_cast<sal_Int32>(nN[nM].PositionX);
+ auto Y = static_cast<sal_Int32>(nN[nM].PositionY);
+ aNewPolygon.append(basegfx::B2DPoint(X, Y));
+ }
+ // check for closed state flag
+ basegfx::utils::checkClosed(aNewPolygon);
+ }
+ aRetval.append(std::move(aNewPolygon));
+ }
+
+ return aRetval;
+}
+
void appendPointSequence( drawing::PointSequenceSequence& rTarget
- , drawing::PointSequenceSequence& rAdd )
+ , const drawing::PointSequenceSequence& rAdd )
{
sal_Int32 nAddCount = rAdd.getLength();
if(!nAddCount)
@@ -336,8 +430,9 @@ void appendPointSequence( drawing::PointSequenceSequence& rTarget
sal_Int32 nOldCount = rTarget.getLength();
rTarget.realloc(nOldCount+nAddCount);
+ auto pTarget = rTarget.getArray();
for(sal_Int32 nS=0; nS<nAddCount; nS++ )
- rTarget[nOldCount+nS]=rAdd[nS];
+ pTarget[nOldCount+nS]=rAdd[nS];
}
drawing::Position3D operator+( const drawing::Position3D& rPos
@@ -386,15 +481,6 @@ awt::Size Direction3DToAWTSize( const drawing::Direction3D& rDirection )
return aRet;
}
-uno::Sequence< double > B3DPointToSequence( const ::basegfx::B3DPoint& rPoint )
-{
- uno::Sequence< double > aRet(3);
- aRet[0] = rPoint.getX();
- aRet[1] = rPoint.getY();
- aRet[2] = rPoint.getZ();
- return aRet;
-}
-
drawing::Position3D SequenceToPosition3D( const uno::Sequence< double >& rSeq )
{
OSL_ENSURE(rSeq.getLength()==3,"The sequence needs to have length 3 for conversion into vector");
@@ -406,15 +492,6 @@ drawing::Position3D SequenceToPosition3D( const uno::Sequence< double >& rSeq )
return aRet;
}
-uno::Sequence< double > Position3DToSequence( const drawing::Position3D& rPosition )
-{
- uno::Sequence< double > aRet(3);
- aRet[0] = rPosition.PositionX;
- aRet[1] = rPosition.PositionY;
- aRet[2] = rPosition.PositionZ;
- return aRet;
-}
-
using namespace ::com::sun::star::chart2;
uno::Sequence< double > DataSequenceToDoubleSequence(
@@ -434,10 +511,11 @@ uno::Sequence< double > DataSequenceToDoubleSequence(
{
uno::Sequence< uno::Any > aValues = xDataSequence->getData();
aResult.realloc(aValues.getLength());
+ auto pResult = aResult.getArray();
for(sal_Int32 nN=aValues.getLength();nN--;)
{
- if( !(aValues[nN] >>= aResult[nN]) )
- ::rtl::math::setNan( &aResult[nN] );
+ if( !(aValues[nN] >>= pResult[nN]) )
+ pResult[nN] = std::numeric_limits<double>::quiet_NaN();
}
}
@@ -460,9 +538,10 @@ uno::Sequence< OUString > DataSequenceToStringSequence(
{
uno::Sequence< uno::Any > aValues = xDataSequence->getData();
aResult.realloc(aValues.getLength());
+ auto pResult = aResult.getArray();
for(sal_Int32 nN=aValues.getLength();nN--;)
- aValues[nN] >>= aResult[nN];
+ aValues[nN] >>= pResult[nN];
}
return aResult;
@@ -505,15 +584,15 @@ sal_Int16 getShortForLongAlso( const uno::Any& rAny )
}
bool replaceParamterInString( OUString & rInOutResourceString,
- const OUString & rParamToReplace,
- const OUString & rReplaceWith )
+ std::u16string_view rParamToReplace,
+ std::u16string_view rReplaceWith )
{
sal_Int32 nPos = rInOutResourceString.indexOf( rParamToReplace );
if( nPos == -1 )
return false;
rInOutResourceString = rInOutResourceString.replaceAt( nPos
- , rParamToReplace.getLength(), rReplaceWith );
+ , rParamToReplace.size(), rReplaceWith );
return true;
}
diff --git a/chart2/source/tools/ConfigColorScheme.cxx b/chart2/source/tools/ConfigColorScheme.cxx
index 5645fb22b68f..6ea26d99c5fb 100644
--- a/chart2/source/tools/ConfigColorScheme.cxx
+++ b/chart2/source/tools/ConfigColorScheme.cxx
@@ -20,11 +20,7 @@
#include <ConfigColorScheme.hxx>
#include <unotools/configitem.hxx>
-#include <sal/macros.h>
#include <cppuhelper/supportsservice.hxx>
-#include <comphelper/sequence.hxx>
-
-#include <set>
using namespace ::com::sun::star;
@@ -34,7 +30,7 @@ using ::com::sun::star::uno::Sequence;
namespace
{
-const char aSeriesPropName[] = "Series";
+constexpr OUString aSeriesPropName = u"Series"_ustr;
} // anonymous namespace
@@ -53,7 +49,6 @@ class ChartConfigItem : public ::utl::ConfigItem
public:
explicit ChartConfigItem( ConfigColorScheme & rListener );
- void addPropertyNotification( const OUString & rPropertyName );
uno::Any getProperty( const OUString & aPropertyName );
protected:
@@ -63,32 +58,27 @@ protected:
private:
ConfigColorScheme & m_rListener;
- std::set< OUString > m_aPropertiesToNotify;
};
ChartConfigItem::ChartConfigItem( ConfigColorScheme & rListener ) :
::utl::ConfigItem( "Office.Chart/DefaultColor" ),
m_rListener( rListener )
-{}
+{
+ EnableNotification( { aSeriesPropName } );
+}
void ChartConfigItem::Notify( const Sequence< OUString > & aPropertyNames )
{
for( OUString const & s : aPropertyNames )
{
- if( m_aPropertiesToNotify.find( s ) != m_aPropertiesToNotify.end())
- m_rListener.notify( s );
+ if( s == aSeriesPropName )
+ m_rListener.notify();
}
}
void ChartConfigItem::ImplCommit()
{}
-void ChartConfigItem::addPropertyNotification( const OUString & rPropertyName )
-{
- m_aPropertiesToNotify.insert( rPropertyName );
- EnableNotification( comphelper::containerToSequence( m_aPropertiesToNotify ));
-}
-
uno::Any ChartConfigItem::getProperty( const OUString & aPropertyName )
{
Sequence< uno::Any > aValues(
@@ -122,11 +112,8 @@ void ConfigColorScheme::retrieveConfigColors()
{
m_apChartConfigItem.reset(
new impl::ChartConfigItem( *this ));
- m_apChartConfigItem->addPropertyNotification( aSeriesPropName );
}
- OSL_ASSERT(m_apChartConfigItem);
- if (!m_apChartConfigItem)
- return;
+ assert(m_apChartConfigItem && "this can only be set at this point");
// retrieve colors
uno::Any aValue(
@@ -153,14 +140,13 @@ void ConfigColorScheme::retrieveConfigColors()
0xff00ff, 0x00ffff, 0xffff00
};
- static const sal_Int32 nMaxDefaultColors = SAL_N_ELEMENTS( nDefaultColors );
+ static const sal_Int32 nMaxDefaultColors = std::size( nDefaultColors );
return nDefaultColors[ nIndex % nMaxDefaultColors ];
}
-void ConfigColorScheme::notify( const OUString & rPropertyName )
+void ConfigColorScheme::notify()
{
- if( rPropertyName == aSeriesPropName )
- m_bNeedsUpdate = true;
+ m_bNeedsUpdate = true;
}
OUString SAL_CALL ConfigColorScheme::getImplementationName()
diff --git a/chart2/source/tools/ControllerLockGuard.cxx b/chart2/source/tools/ControllerLockGuard.cxx
index 7719755e9aff..6bfe8e4a95d2 100644
--- a/chart2/source/tools/ControllerLockGuard.cxx
+++ b/chart2/source/tools/ControllerLockGuard.cxx
@@ -19,16 +19,15 @@
#include <ControllerLockGuard.hxx>
#include <ChartModel.hxx>
+#include <utility>
using namespace ::com::sun::star;
-using ::com::sun::star::uno::Reference;
-
namespace chart
{
-ControllerLockGuardUNO::ControllerLockGuardUNO( const uno::Reference< frame::XModel >& xModel ) :
- mxModel( xModel )
+ControllerLockGuardUNO::ControllerLockGuardUNO( rtl::Reference<::chart::ChartModel> xModel ) :
+ mxModel(std::move( xModel ))
{
mxModel->lockControllers();
}
@@ -49,8 +48,8 @@ ControllerLockGuard::~ControllerLockGuard()
mrModel.unlockControllers();
}
-ControllerLockHelper::ControllerLockHelper( const Reference< frame::XModel > & xModel ) :
- m_xModel( xModel )
+ControllerLockHelper::ControllerLockHelper( rtl::Reference<::chart::ChartModel> xModel ) :
+ m_xModel(std::move( xModel ))
{}
ControllerLockHelper::~ControllerLockHelper()
diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx
index c7dabaf1d4da..45f235cd2810 100644
--- a/chart2/source/tools/DataSeriesHelper.cxx
+++ b/chart2/source/tools/DataSeriesHelper.cxx
@@ -18,34 +18,36 @@
*/
#include <DataSeriesHelper.hxx>
+#include <DataSeries.hxx>
+#include <DataSeriesProperties.hxx>
#include <DataSource.hxx>
+#include <ChartType.hxx>
#include <unonames.hxx>
+#include <Diagram.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <Axis.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp>
-#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
#include <com/sun/star/chart2/StackingDirection.hpp>
-#include <com/sun/star/chart2/data/LabelOrigin.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/SymbolStyle.hpp>
#include <com/sun/star/chart2/Symbol.hpp>
#include <com/sun/star/chart2/XDiagram.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
#include <comphelper/sequence.hxx>
-#include <rtl/ustrbuf.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
#include <iterator>
+#include <utility>
#include <vector>
#include <set>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
+using namespace ::chart::DataSeriesProperties;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -56,8 +58,8 @@ namespace
class lcl_MatchesRole
{
public:
- explicit lcl_MatchesRole( const OUString & aRole, bool bMatchPrefix ) :
- m_aRole( aRole ),
+ explicit lcl_MatchesRole( OUString aRole, bool bMatchPrefix ) :
+ m_aRole(std::move( aRole )),
m_bMatchPrefix( bMatchPrefix )
{}
@@ -83,80 +85,50 @@ private:
bool m_bMatchPrefix;
};
-Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel(
- const Reference< chart2::data::XDataSource > & xDataSource )
-{
- Reference< chart2::data::XLabeledDataSequence > xResult;
- const Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences());
-
- for( auto const & labeledData : aSequences )
- {
- OSL_ENSURE( labeledData.is(), "empty LabeledDataSequence" );
- // no values are set but a label exists
- if( labeledData.is() &&
- ( ! labeledData->getValues().is() &&
- labeledData->getLabel().is()))
- {
- xResult.set( labeledData );
- break;
- }
- }
-
- return xResult;
-}
-
void lcl_getCooSysAndChartTypeOfSeries(
- const Reference< chart2::XDataSeries > & xSeries,
+ const rtl::Reference< ::chart::DataSeries > & xSeries,
const Reference< chart2::XDiagram > & xDiagram,
- Reference< chart2::XCoordinateSystem > & xOutCooSys,
- Reference< chart2::XChartType > & xOutChartType )
+ rtl::Reference< ::chart::BaseCoordinateSystem > & xOutCooSys,
+ rtl::Reference< ::chart::ChartType > & xOutChartType )
{
- Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY );
- if( !xCooSysCnt.is())
+ if( !xDiagram.is())
return;
+ ::chart::Diagram* pDiagram = dynamic_cast<::chart::Diagram*>(xDiagram.get());
- const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
- for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq )
+ for( rtl::Reference< ::chart::BaseCoordinateSystem > const & coords : pDiagram->getBaseCoordinateSystems() )
{
- Reference< chart2::XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
- const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
- for( Reference< chart2::XChartType > const & chartType : aChartTypes )
+ for( rtl::Reference< ::chart::ChartType > const & chartType : coords->getChartTypes2() )
{
- Reference< chart2::XDataSeriesContainer > xSeriesCnt( chartType, uno::UNO_QUERY );
- if( xSeriesCnt.is())
+ for( rtl::Reference< ::chart::DataSeries > const & dataSeries : chartType->getDataSeries2() )
{
- const Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries());
- for( Reference< chart2::XDataSeries > const & dataSeries : aSeries )
+ if( dataSeries == xSeries )
{
- if( dataSeries == xSeries )
- {
- xOutCooSys.set( coords );
- xOutChartType.set( chartType );
- }
+ xOutCooSys = coords;
+ xOutChartType = chartType;
}
}
}
}
}
-void lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( const Reference< chart2::XDataSeries >& xSeries, bool bInsert )
+void lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( const rtl::Reference< ::chart::DataSeries >& xSeries, bool bInsert )
{
try
{
- Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
- if( xSeriesProperties.is() )
+ if( xSeries.is() )
{
DataPointLabel aLabelAtSeries;
- xSeriesProperties->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabelAtSeries;
+ xSeries->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabelAtSeries;
aLabelAtSeries.ShowNumber = bInsert;
if( !bInsert )
{
aLabelAtSeries.ShowNumberInPercent = false;
aLabelAtSeries.ShowCategoryName = false;
}
- xSeriesProperties->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabelAtSeries));
+ xSeries->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabelAtSeries));
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ // "AttributedDataPoints"
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
{
for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
{
@@ -171,6 +143,7 @@ void lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( const Reference< chart2::
aLabel.ShowNumberInPercent = false;
aLabel.ShowCategoryName = false;
aLabel.ShowCustomLabel = false;
+ aLabel.ShowSeriesName = false;
}
xPointProp->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel));
xPointProp->setPropertyValue(CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any());
@@ -202,186 +175,79 @@ OUString getRole( const uno::Reference< chart2::data::XLabeledDataSequence >& xL
return aRet;
}
-Reference< chart2::data::XLabeledDataSequence >
+uno::Reference< chart2::data::XLabeledDataSequence >
getDataSequenceByRole(
const Reference< chart2::data::XDataSource > & xSource,
const OUString& aRole,
bool bMatchPrefix /* = false */ )
{
- Reference< chart2::data::XLabeledDataSequence > aNoResult;
+ uno::Reference< chart2::data::XLabeledDataSequence > aNoResult;
if( ! xSource.is())
return aNoResult;
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aLabeledSeq( xSource->getDataSequences());
-
- const Reference< chart2::data::XLabeledDataSequence > * pBegin = aLabeledSeq.getConstArray();
- const Reference< chart2::data::XLabeledDataSequence > * pEnd = pBegin + aLabeledSeq.getLength();
- const Reference< chart2::data::XLabeledDataSequence > * pMatch =
- std::find_if( pBegin, pEnd, lcl_MatchesRole( aRole, bMatchPrefix ));
-
- if( pMatch != pEnd )
- return *pMatch;
+ const Sequence< Reference< chart2::data::XLabeledDataSequence > > aLabeledSeq( xSource->getDataSequences());
+ try
+ {
+ for (auto const & i : aLabeledSeq)
+ {
+ if (lcl_MatchesRole(aRole, bMatchPrefix)(i))
+ return i;
+ }
+ }
+ catch (const lang::DisposedException&)
+ {
+ TOOLS_WARN_EXCEPTION( "chart2", "unexpected exception caught" );
+ }
return aNoResult;
}
-std::vector< Reference< chart2::data::XLabeledDataSequence > >
+std::vector< uno::Reference< chart2::data::XLabeledDataSequence > >
getAllDataSequencesByRole( const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aDataSequences,
const OUString& aRole )
{
- std::vector< Reference< chart2::data::XLabeledDataSequence > > aResultVec;
- std::copy_if( aDataSequences.begin(), aDataSequences.end(),
- std::back_inserter( aResultVec ),
- lcl_MatchesRole(aRole, /*bMatchPrefix*/true) );
- return aResultVec;
-}
-
-std::vector<Reference<css::chart2::data::XLabeledDataSequence> >
-getAllDataSequences( const uno::Sequence<uno::Reference<chart2::XDataSeries> >& aSeries )
-{
- std::vector< Reference< chart2::data::XLabeledDataSequence > > aSeqVec;
-
- for( uno::Reference<chart2::XDataSeries> const & dataSeries : aSeries )
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aResultVec;
+ for (const auto & i : aDataSequences)
{
- Reference< chart2::data::XDataSource > xSource( dataSeries, uno::UNO_QUERY );
- if( xSource.is())
- {
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( xSource->getDataSequences());
- aSeqVec.insert( aSeqVec.end(), aSeq.begin(), aSeq.end() );
- }
+ if (lcl_MatchesRole(aRole, /*bMatchPrefix*/true)(i))
+ aResultVec.push_back(i);
}
-
- return aSeqVec;
+ return aResultVec;
}
-Reference< chart2::data::XDataSource >
- getDataSource( const Sequence< Reference< chart2::XDataSeries > > & aSeries )
+std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > >
+ getAllDataSequencesByRole( const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aDataSequences,
+ const OUString& aRole )
{
- return Reference< chart2::data::XDataSource >(
- new DataSource(comphelper::containerToSequence(getAllDataSequences(aSeries))));
+ std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > aResultVec;
+ std::copy_if( aDataSequences.begin(), aDataSequences.end(),
+ std::back_inserter( aResultVec ),
+ lcl_MatchesRole(aRole, /*bMatchPrefix*/true) );
+ return aResultVec;
}
-namespace
-{
-OUString lcl_getDataSequenceLabel( const Reference< chart2::data::XDataSequence > & xSequence )
+std::vector<uno::Reference<chart2::data::XLabeledDataSequence> >
+getAllDataSequences( const std::vector<rtl::Reference<DataSeries> >& aSeries )
{
- OUString aResult;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSeqVec;
- Reference< chart2::data::XTextualDataSequence > xTextSeq( xSequence, uno::UNO_QUERY );
- if( xTextSeq.is())
+ for( rtl::Reference<DataSeries> const & dataSeries : aSeries )
{
- Sequence< OUString > aSeq( xTextSeq->getTextualData());
-
- const sal_Int32 nMax = aSeq.getLength() - 1;
- OUStringBuffer aBuf;
-
- for( sal_Int32 i = 0; i <= nMax; ++i )
- {
- aBuf.append( aSeq[i] );
- if( i < nMax )
- aBuf.append( ' ');
- }
- aResult = aBuf.makeStringAndClear();
+ const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aSeq( dataSeries->getDataSequences2());
+ aSeqVec.insert( aSeqVec.end(), aSeq.begin(), aSeq.end() );
}
- else if( xSequence.is())
- {
- Sequence< uno::Any > aSeq( xSequence->getData());
- const sal_Int32 nMax = aSeq.getLength() - 1;
- OUString aVal;
- OUStringBuffer aBuf;
- double fNum = 0;
-
- for( sal_Int32 i = 0; i <= nMax; ++i )
- {
- if( aSeq[i] >>= aVal )
- {
- aBuf.append( aVal );
- if( i < nMax )
- aBuf.append( ' ');
- }
- else if( aSeq[ i ] >>= fNum )
- {
- aBuf.append( fNum );
- if( i < nMax )
- aBuf.append( ' ');
- }
- }
- aResult = aBuf.makeStringAndClear();
- }
-
- return aResult;
-}
-}
-
-OUString getLabelForLabeledDataSequence(
- const Reference< chart2::data::XLabeledDataSequence > & xLabeledSeq )
-{
- OUString aResult;
- if( xLabeledSeq.is())
- {
- Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getLabel());
- if( xSeq.is() )
- aResult = lcl_getDataSequenceLabel( xSeq );
- if( !xSeq.is() || aResult.isEmpty() )
- {
- // no label set or label content is empty -> use auto-generated one
- Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues() );
- if( xValueSeq.is() )
- {
- Sequence< OUString > aLabels( xValueSeq->generateLabel(
- chart2::data::LabelOrigin_SHORT_SIDE ) );
- // no labels returned is interpreted as: auto-generation not
- // supported by sequence
- if( aLabels.hasElements() )
- aResult=aLabels[0];
- else
- {
- //todo?: maybe use the index of the series as name
- //but as the index may change it would be better to have such a name persistent
- //what is not possible at the moment
- //--> maybe use the identifier as part of the name ...
- aResult = lcl_getDataSequenceLabel( xValueSeq );
- }
- }
- }
- }
- return aResult;
+ return aSeqVec;
}
-OUString getDataSeriesLabel(
- const Reference< chart2::XDataSeries > & xSeries,
- const OUString & rLabelSequenceRole )
+rtl::Reference< DataSource >
+ getDataSource( const std::vector< rtl::Reference< DataSeries > > & aSeries )
{
- OUString aResult;
-
- Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
- if( xSource.is())
- {
- Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
- ::chart::DataSeriesHelper::getDataSequenceByRole( xSource, rLabelSequenceRole ));
- if( xLabeledSeq.is())
- aResult = getLabelForLabeledDataSequence( xLabeledSeq );
- else
- {
- // special case: labeled data series with only a label and no values may
- // serve as label
- xLabeledSeq.set( lcl_findLSequenceWithOnlyLabel( xSource ));
- if( xLabeledSeq.is())
- {
- Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getLabel());
- if( xSeq.is())
- aResult = lcl_getDataSequenceLabel( xSeq );
- }
- }
-
- }
-
- return aResult;
+ return new DataSource(getAllDataSequences(aSeries));
}
void setStackModeAtSeries(
- const Sequence< Reference< chart2::XDataSeries > > & aSeries,
- const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem,
+ const std::vector< rtl::Reference< DataSeries > > & aSeries,
+ const rtl::Reference< BaseCoordinateSystem > & xCorrespondingCoordinateSystem,
StackMode eStackMode )
{
const uno::Any aPropValue(
@@ -393,17 +259,16 @@ void setStackModeAtSeries(
: chart2::StackingDirection_NO_STACKING );
std::set< sal_Int32 > aAxisIndexSet;
- for( Reference< chart2::XDataSeries > const & dataSeries : aSeries )
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< beans::XPropertySet > xProp( dataSeries, uno::UNO_QUERY );
- if( xProp.is() )
+ if( dataSeries.is() )
{
- xProp->setPropertyValue( "StackingDirection", aPropValue );
+ dataSeries->setPropertyValue( "StackingDirection", aPropValue );
- sal_Int32 nAxisIndex;
- xProp->getPropertyValue( "AttachedAxisIndex" ) >>= nAxisIndex;
+ sal_Int32 nAxisIndex = 0;
+ dataSeries->getPropertyValue( "AttachedAxisIndex" ) >>= nAxisIndex;
aAxisIndexSet.insert(nAxisIndex);
}
}
@@ -424,8 +289,8 @@ void setStackModeAtSeries(
for (auto const& axisIndex : aAxisIndexSet)
{
- Reference< chart2::XAxis > xAxis(
- xCorrespondingCoordinateSystem->getAxisByDimension(1, axisIndex));
+ rtl::Reference< Axis > xAxis =
+ xCorrespondingCoordinateSystem->getAxisByDimension2(1, axisIndex);
if( xAxis.is())
{
bool bPercent = (eStackMode == StackMode::YStackedPercent);
@@ -443,15 +308,14 @@ void setStackModeAtSeries(
}
}
-sal_Int32 getAttachedAxisIndex( const Reference< chart2::XDataSeries > & xSeries )
+sal_Int32 getAttachedAxisIndex( const rtl::Reference< DataSeries > & xSeries )
{
sal_Int32 nRet = 0;
try
{
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY );
- if( xProp.is() )
+ if( xSeries.is() )
{
- xProp->getPropertyValue( "AttachedAxisIndex" ) >>= nRet;
+ xSeries->getFastPropertyValue( PROP_DATASERIES_ATTACHED_AXIS_INDEX ) >>= nRet;
}
}
catch( const uno::Exception & )
@@ -462,8 +326,8 @@ sal_Int32 getAttachedAxisIndex( const Reference< chart2::XDataSeries > & xSeries
}
sal_Int32 getNumberFormatKeyFromAxis(
- const Reference< chart2::XDataSeries > & xSeries,
- const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem,
+ const rtl::Reference< DataSeries > & xSeries,
+ const rtl::Reference< BaseCoordinateSystem > & xCorrespondingCoordinateSystem,
sal_Int32 nDimensionIndex,
sal_Int32 nAxisIndex /* = -1 */ )
{
@@ -472,8 +336,8 @@ sal_Int32 getNumberFormatKeyFromAxis(
nAxisIndex = getAttachedAxisIndex( xSeries );
try
{
- Reference< beans::XPropertySet > xAxisProp(
- xCorrespondingCoordinateSystem->getAxisByDimension( nDimensionIndex, nAxisIndex ), uno::UNO_QUERY );
+ rtl::Reference< Axis > xAxisProp =
+ xCorrespondingCoordinateSystem->getAxisByDimension2( nDimensionIndex, nAxisIndex );
if( xAxisProp.is())
xAxisProp->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nResult;
}
@@ -485,43 +349,40 @@ sal_Int32 getNumberFormatKeyFromAxis(
return nResult;
}
-Reference< chart2::XCoordinateSystem > getCoordinateSystemOfSeries(
- const Reference< chart2::XDataSeries > & xSeries,
- const Reference< chart2::XDiagram > & xDiagram )
+rtl::Reference< ::chart::BaseCoordinateSystem > getCoordinateSystemOfSeries(
+ const rtl::Reference< DataSeries > & xSeries,
+ const rtl::Reference< Diagram > & xDiagram )
{
- Reference< chart2::XCoordinateSystem > xResult;
- Reference< chart2::XChartType > xDummy;
+ rtl::Reference< ::chart::BaseCoordinateSystem > xResult;
+ rtl::Reference< ::chart::ChartType > xDummy;
lcl_getCooSysAndChartTypeOfSeries( xSeries, xDiagram, xResult, xDummy );
return xResult;
}
-Reference< chart2::XChartType > getChartTypeOfSeries(
- const Reference< chart2::XDataSeries > & xSeries,
- const Reference< chart2::XDiagram > & xDiagram )
+rtl::Reference< ::chart::ChartType > getChartTypeOfSeries(
+ const rtl::Reference< DataSeries > & xSeries,
+ const rtl::Reference< Diagram > & xDiagram )
{
- Reference< chart2::XChartType > xResult;
- Reference< chart2::XCoordinateSystem > xDummy;
+ rtl::Reference< ::chart::ChartType > xResult;
+ rtl::Reference< ::chart::BaseCoordinateSystem > xDummy;
lcl_getCooSysAndChartTypeOfSeries( xSeries, xDiagram, xDummy, xResult );
return xResult;
}
void deleteSeries(
- const Reference< chart2::XDataSeries > & xSeries,
- const Reference< chart2::XChartType > & xChartType )
+ const rtl::Reference< ::chart::DataSeries > & xSeries,
+ const rtl::Reference< ::chart::ChartType > & xChartType )
{
try
{
- Reference< chart2::XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY_THROW );
- auto aSeries(
- comphelper::sequenceToContainer<std::vector< Reference< chart2::XDataSeries > > >( xSeriesCnt->getDataSeries()));
- std::vector< Reference< chart2::XDataSeries > >::iterator aIt =
- std::find( aSeries.begin(), aSeries.end(), xSeries );
+ std::vector< rtl::Reference< DataSeries > > aSeries = xChartType->getDataSeries2();
+ auto aIt = std::find( aSeries.begin(), aSeries.end(), xSeries );
if( aIt != aSeries.end())
{
aSeries.erase( aIt );
- xSeriesCnt->setDataSeries( comphelper::containerToSequence( aSeries ));
+ xChartType->setDataSeries( aSeries );
}
}
catch( const uno::Exception & )
@@ -530,14 +391,14 @@ void deleteSeries(
}
}
-void switchSymbolsOnOrOff( const Reference< beans::XPropertySet > & xSeriesProperties,
+void switchSymbolsOnOrOff( const rtl::Reference< DataSeries > & xSeries,
bool bSymbolsOn, sal_Int32 nSeriesIndex )
{
- if( !xSeriesProperties.is() )
+ if( !xSeries )
return;
chart2::Symbol aSymbProp;
- if( xSeriesProperties->getPropertyValue( "Symbol") >>= aSymbProp )
+ if( xSeries->getPropertyValue( "Symbol") >>= aSymbProp )
{
if( !bSymbolsOn )
aSymbProp.Style = chart2::SymbolStyle_NONE;
@@ -546,55 +407,55 @@ void switchSymbolsOnOrOff( const Reference< beans::XPropertySet > & xSeriesPrope
aSymbProp.Style = chart2::SymbolStyle_STANDARD;
aSymbProp.StandardSymbol = nSeriesIndex;
}
- xSeriesProperties->setPropertyValue( "Symbol", uno::Any( aSymbProp ));
+ xSeries->setPropertyValue( "Symbol", uno::Any( aSymbProp ));
}
//todo: check attributed data points
}
-void switchLinesOnOrOff( const Reference< beans::XPropertySet > & xSeriesProperties, bool bLinesOn )
+void switchLinesOnOrOff( const rtl::Reference< DataSeries > & xSeries, bool bLinesOn )
{
- if( !xSeriesProperties.is() )
+ if( !xSeries )
return;
if( bLinesOn )
{
// keep line-styles that are not NONE
drawing::LineStyle eLineStyle;
- if( (xSeriesProperties->getPropertyValue( "LineStyle") >>= eLineStyle ) &&
+ if( (xSeries->getPropertyValue( "LineStyle") >>= eLineStyle ) &&
eLineStyle == drawing::LineStyle_NONE )
{
- xSeriesProperties->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID ) );
+ xSeries->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID ) );
}
}
else
- xSeriesProperties->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ) );
+ xSeries->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ) );
}
-void makeLinesThickOrThin( const Reference< beans::XPropertySet > & xSeriesProperties, bool bThick )
+void makeLinesThickOrThin( const rtl::Reference< ::chart::DataSeries > & xSeries, bool bThick )
{
- if( !xSeriesProperties.is() )
+ if( !xSeries )
return;
sal_Int32 nNewValue = bThick ? 80 : 0;
sal_Int32 nOldValue = 0;
- if( (xSeriesProperties->getPropertyValue( "LineWidth") >>= nOldValue ) &&
+ if( (xSeries->getPropertyValue( "LineWidth") >>= nOldValue ) &&
nOldValue != nNewValue )
{
if( !(bThick && nOldValue>0))
- xSeriesProperties->setPropertyValue( "LineWidth", uno::Any( nNewValue ) );
+ xSeries->setPropertyValue( "LineWidth", uno::Any( nNewValue ) );
}
}
-void setPropertyAlsoToAllAttributedDataPoints( const Reference< chart2::XDataSeries >& xSeries,
+void setPropertyAlsoToAllAttributedDataPoints( const rtl::Reference< ::chart::DataSeries >& xSeries,
const OUString& rPropertyName, const uno::Any& rPropertyValue )
{
- Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
- if( !xSeriesProperties.is() )
+ if( !xSeries.is() )
return;
- xSeriesProperties->setPropertyValue( rPropertyName, rPropertyValue );
+ xSeries->setPropertyValue( rPropertyName, rPropertyValue );
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ // "AttributedDataPoints"
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
{
for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
{
@@ -603,20 +464,23 @@ void setPropertyAlsoToAllAttributedDataPoints( const Reference< chart2::XDataSer
continue;
xPointProp->setPropertyValue( rPropertyName, rPropertyValue );
if( rPropertyName == "LabelPlacement" )
+ {
xPointProp->setPropertyValue("CustomLabelPosition", uno::Any());
+ xPointProp->setPropertyValue("CustomLabelSize", uno::Any());
+ }
}
}
}
-bool hasAttributedDataPointDifferentValue( const Reference< chart2::XDataSeries >& xSeries,
+bool hasAttributedDataPointDifferentValue( const rtl::Reference< DataSeries >& xSeries,
const OUString& rPropertyName, const uno::Any& rPropertyValue )
{
- Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
- if( !xSeriesProperties.is() )
+ if( !xSeries.is() )
return false;
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ // "AttributedDataPoints"
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
{
for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
{
@@ -634,46 +498,6 @@ bool hasAttributedDataPointDifferentValue( const Reference< chart2::XDataSeries
namespace
{
-bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
-{
- if( !xDataSequence.is() )
- return false;
- uno::Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY );
- if( xProp.is() )
- {
- uno::Sequence< sal_Int32 > aHiddenValues;
- try
- {
- xProp->getPropertyValue( "HiddenValues" ) >>= aHiddenValues;
- if( !aHiddenValues.hasElements() )
- return true;
- }
- catch( const uno::Exception& )
- {
- return true;
- }
- }
- return xDataSequence->getData().hasElements();
-}
-
-}
-
-bool hasUnhiddenData( const uno::Reference< chart2::XDataSeries >& xSeries )
-{
- uno::Reference< chart2::data::XDataSource > xDataSource( xSeries, uno::UNO_QUERY );
-
- uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aDataSequences = xDataSource->getDataSequences();
-
- for(sal_Int32 nN = aDataSequences.getLength();nN--;)
- {
- if( !aDataSequences[nN].is() )
- continue;
- if( lcl_SequenceHasUnhiddenData( aDataSequences[nN]->getValues() ) )
- return true;
- if( lcl_SequenceHasUnhiddenData( aDataSequences[nN]->getLabel() ) )
- return true;
- }
- return false;
}
sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nIndex, const Reference< chart2::data::XDataSequence >& xDataSequence, bool bTranslate )
@@ -710,17 +534,17 @@ sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nIndex, const Refere
return nIndex;
}
-bool hasDataLabelsAtSeries( const Reference< chart2::XDataSeries >& xSeries )
+bool hasDataLabelsAtSeries( const rtl::Reference< DataSeries >& xSeries )
{
bool bRet = false;
try
{
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY );
- if( xProp.is() )
+ if( xSeries.is() )
{
DataPointLabel aLabel;
- if( xProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel )
- bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName;
+ if( xSeries->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel )
+ bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName
+ || aLabel.ShowSeriesName;
}
}
catch(const uno::Exception &)
@@ -730,16 +554,16 @@ bool hasDataLabelsAtSeries( const Reference< chart2::XDataSeries >& xSeries )
return bRet;
}
-bool hasDataLabelsAtPoints( const Reference< chart2::XDataSeries >& xSeries )
+bool hasDataLabelsAtPoints( const rtl::Reference< DataSeries >& xSeries )
{
bool bRet = false;
try
{
- Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
- if( xSeriesProperties.is() )
+ if( xSeries.is() )
{
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ // "AttributedDataPoints"
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
{
for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
{
@@ -748,7 +572,9 @@ bool hasDataLabelsAtPoints( const Reference< chart2::XDataSeries >& xSeries )
{
DataPointLabel aLabel;
if( xPointProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel )
- bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName || aLabel.ShowCustomLabel;
+ bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent
+ || aLabel.ShowCategoryName || aLabel.ShowCustomLabel
+ || aLabel.ShowSeriesName;
if( bRet )
break;
}
@@ -763,30 +589,31 @@ bool hasDataLabelsAtPoints( const Reference< chart2::XDataSeries >& xSeries )
return bRet;
}
-bool hasDataLabelAtPoint( const Reference< chart2::XDataSeries >& xSeries, sal_Int32 nPointIndex )
+bool hasDataLabelAtPoint( const rtl::Reference< DataSeries >& xSeries, sal_Int32 nPointIndex )
{
bool bRet = false;
try
{
Reference< beans::XPropertySet > xProp;
- Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
- if( xSeriesProperties.is() )
+ if( xSeries.is() )
{
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ // "AttributedDataPoints"
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
{
- auto aIndices( comphelper::sequenceToContainer<std::vector< sal_Int32 >>( aAttributedDataPointIndexList ) );
- std::vector< sal_Int32 >::iterator aIt = std::find( aIndices.begin(), aIndices.end(), nPointIndex );
- if( aIt != aIndices.end())
+ auto aIt = std::find( aAttributedDataPointIndexList.begin(), aAttributedDataPointIndexList.end(), nPointIndex );
+ if (aIt != aAttributedDataPointIndexList.end())
xProp = xSeries->getDataPointByIndex(nPointIndex);
else
- xProp = xSeriesProperties;
+ xProp = xSeries;
}
if( xProp.is() )
{
DataPointLabel aLabel;
if( xProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel )
- bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName || aLabel.ShowCustomLabel;
+ bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent
+ || aLabel.ShowCategoryName || aLabel.ShowCustomLabel
+ || aLabel.ShowSeriesName;
}
}
}
@@ -797,12 +624,12 @@ bool hasDataLabelAtPoint( const Reference< chart2::XDataSeries >& xSeries, sal_I
return bRet;
}
-void insertDataLabelsToSeriesAndAllPoints( const Reference< chart2::XDataSeries >& xSeries )
+void insertDataLabelsToSeriesAndAllPoints( const rtl::Reference< DataSeries >& xSeries )
{
lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( xSeries, true /*bInsert*/ );
}
-void deleteDataLabelsFromSeriesAndAllPoints( const Reference< chart2::XDataSeries >& xSeries )
+void deleteDataLabelsFromSeriesAndAllPoints( const rtl::Reference< DataSeries >& xSeries )
{
lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( xSeries, false /*bInsert*/ );
}
@@ -837,6 +664,7 @@ void deleteDataLabelsFromPoint( const Reference< beans::XPropertySet >& xPointPr
aLabel.ShowNumberInPercent = false;
aLabel.ShowCategoryName = false;
aLabel.ShowCustomLabel = false;
+ aLabel.ShowSeriesName = false;
xPointProp->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel));
xPointProp->setPropertyValue(CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any());
}
diff --git a/chart2/source/tools/DataSource.cxx b/chart2/source/tools/DataSource.cxx
index bdcac98ef1e6..c74687c1485a 100644
--- a/chart2/source/tools/DataSource.cxx
+++ b/chart2/source/tools/DataSource.cxx
@@ -19,6 +19,7 @@
#include <DataSource.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequence.hxx>
namespace com::sun::star::uno { class XComponentContext; }
@@ -39,6 +40,12 @@ DataSource::DataSource(
m_aDataSeq( rSequences )
{}
+DataSource::DataSource(
+ const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & rSequences )
+{
+ m_aDataSeq = comphelper::containerToSequence< Reference< chart2::data::XLabeledDataSequence > >(rSequences);
+}
+
DataSource::~DataSource()
{}
diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx
index 3d6bb54592fe..dc6c1b9c87f1 100644
--- a/chart2/source/tools/DataSourceHelper.cxx
+++ b/chart2/source/tools/DataSourceHelper.cxx
@@ -20,7 +20,9 @@
#include <DataSourceHelper.hxx>
#include <ChartModel.hxx>
#include <ChartModelHelper.hxx>
-#include <DiagramHelper.hxx>
+#include <ChartTypeManager.hxx>
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <DataSource.hxx>
#include <ControllerLockGuard.hxx>
@@ -28,13 +30,12 @@
#include <LabeledDataSequence.hxx>
#include <unonames.hxx>
-#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/data/XDataSource.hpp>
#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace chart
{
@@ -72,16 +73,15 @@ void lcl_addDataSourceRanges(
void lcl_addErrorBarRanges(
std::vector< OUString > & rOutResult,
- const uno::Reference< XDataSeries > & xDataSeries )
+ const rtl::Reference< DataSeries > & xDataSeries )
{
- uno::Reference< beans::XPropertySet > xSeriesProp( xDataSeries, uno::UNO_QUERY );
- if( !xSeriesProp.is())
+ if( !xDataSeries.is())
return;
try
{
uno::Reference< beans::XPropertySet > xErrorBarProp;
- if( ( xSeriesProp->getPropertyValue( CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarProp ) &&
+ if( ( xDataSeries->getPropertyValue( CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarProp ) &&
xErrorBarProp.is())
{
sal_Int32 eStyle = css::chart::ErrorBarStyle::NONE;
@@ -94,7 +94,7 @@ void lcl_addErrorBarRanges(
}
}
- if( ( xSeriesProp->getPropertyValue(CHART_UNONAME_ERRORBAR_X) >>= xErrorBarProp ) && xErrorBarProp.is())
+ if( ( xDataSeries->getPropertyValue(CHART_UNONAME_ERRORBAR_X) >>= xErrorBarProp ) && xErrorBarProp.is())
{
sal_Int32 eStyle = css::chart::ErrorBarStyle::NONE;
if( ( xErrorBarProp->getPropertyValue("ErrorBarStyle") >>= eStyle ) &&
@@ -114,12 +114,6 @@ void lcl_addErrorBarRanges(
} // anonymous namespace
-Reference< chart2::data::XDataSource > DataSourceHelper::createDataSource(
- const Sequence< Reference< chart2::data::XLabeledDataSequence > >& rSequences )
-{
- return new DataSource(rSequences);
-}
-
Reference< chart2::data::XDataSequence > DataSourceHelper::createCachedDataSequence()
{
return new ::chart::CachedDataSequence();
@@ -130,20 +124,20 @@ Reference< chart2::data::XDataSequence > DataSourceHelper::createCachedDataSeque
return new ::chart::CachedDataSequence( rSingleText );
}
-Reference< chart2::data::XLabeledDataSequence > DataSourceHelper::createLabeledDataSequence(
+rtl::Reference< LabeledDataSequence > DataSourceHelper::createLabeledDataSequence(
const Reference< chart2::data::XDataSequence >& xValues ,
const Reference< chart2::data::XDataSequence >& xLabels )
{
return new ::chart::LabeledDataSequence( xValues, xLabels );
}
-Reference< chart2::data::XLabeledDataSequence > DataSourceHelper::createLabeledDataSequence(
+rtl::Reference< LabeledDataSequence > DataSourceHelper::createLabeledDataSequence(
const Reference< chart2::data::XDataSequence >& xValues )
{
return new ::chart::LabeledDataSequence( xValues );
}
-Reference< chart2::data::XLabeledDataSequence > DataSourceHelper::createLabeledDataSequence()
+rtl::Reference< LabeledDataSequence > DataSourceHelper::createLabeledDataSequence()
{
return new ::chart::LabeledDataSequence;
}
@@ -155,18 +149,12 @@ uno::Sequence< beans::PropertyValue > DataSourceHelper::createArguments(
if( bUseColumns )
eRowSource = css::chart::ChartDataRowSource_COLUMNS;
- uno::Sequence< beans::PropertyValue > aArguments(3);
- aArguments[0] = beans::PropertyValue( "DataRowSource"
- , -1, uno::Any( eRowSource )
- , beans::PropertyState_DIRECT_VALUE );
- aArguments[1] = beans::PropertyValue( "FirstCellAsLabel"
- , -1, uno::Any( bFirstCellAsLabel )
- , beans::PropertyState_DIRECT_VALUE );
- aArguments[2] = beans::PropertyValue( "HasCategories"
- , -1, uno::Any( bHasCategories )
- , beans::PropertyState_DIRECT_VALUE );
-
- return aArguments;
+ return
+ {
+ { "DataRowSource", -1, uno::Any( eRowSource), beans::PropertyState_DIRECT_VALUE },
+ { "FirstCellAsLabel", -1, uno::Any( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE },
+ { "HasCategories", -1, uno::Any( bHasCategories ), beans::PropertyState_DIRECT_VALUE }
+ };
}
uno::Sequence< beans::PropertyValue > DataSourceHelper::createArguments(
@@ -176,14 +164,14 @@ uno::Sequence< beans::PropertyValue > DataSourceHelper::createArguments(
{
uno::Sequence< beans::PropertyValue > aArguments( createArguments( bUseColumns, bFirstCellAsLabel, bHasCategories ));
aArguments.realloc( aArguments.getLength() + 1 );
- aArguments[aArguments.getLength() - 1] =
+ aArguments.getArray()[aArguments.getLength() - 1] =
beans::PropertyValue( "CellRangeRepresentation"
, -1, uno::Any( rRangeRepresentation )
, beans::PropertyState_DIRECT_VALUE );
if( rSequenceMapping.hasElements() )
{
aArguments.realloc( aArguments.getLength() + 1 );
- aArguments[aArguments.getLength() - 1] =
+ aArguments.getArray()[aArguments.getLength() - 1] =
beans::PropertyValue( "SequenceMapping"
, -1, uno::Any( rSequenceMapping )
, beans::PropertyState_DIRECT_VALUE );
@@ -222,21 +210,25 @@ void DataSourceHelper::readArguments( const uno::Sequence< beans::PropertyValue
}
}
-uno::Reference< chart2::data::XDataSource > DataSourceHelper::pressUsedDataIntoRectangularFormat(
- const uno::Reference< chart2::XChartDocument >& xChartDoc )
+rtl::Reference< DataSource > DataSourceHelper::pressUsedDataIntoRectangularFormat(
+ const rtl::Reference< ChartModel >& xChartDoc )
{
std::vector< Reference< chart2::data::XLabeledDataSequence > > aResultVector;
//categories are always the first sequence
- Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
+ rtl::Reference< Diagram > xDiagram( xChartDoc->getFirstChartDiagram());
- Reference< chart2::data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) );
+ Reference< chart2::data::XLabeledDataSequence > xCategories;
+ if (xDiagram)
+ xCategories = xDiagram->getCategories();
if( xCategories.is() )
aResultVector.push_back( xCategories );
- std::vector< Reference< chart2::XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
- uno::Reference< chart2::data::XDataSource > xSeriesSource(
- DataSeriesHelper::getDataSource( comphelper::containerToSequence(aSeriesVector) ) );
+ std::vector< rtl::Reference< DataSeries > > aSeriesVector;
+ if (xDiagram)
+ aSeriesVector = xDiagram->getDataSeries();
+ uno::Reference< chart2::data::XDataSource > xSeriesSource =
+ DataSeriesHelper::getDataSource( aSeriesVector );
const Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xSeriesSource->getDataSequences() );
//the first x-values is always the next sequence //todo ... other x-values get lost for old format
@@ -253,25 +245,24 @@ uno::Reference< chart2::data::XDataSource > DataSourceHelper::pressUsedDataIntoR
aResultVector.push_back( labeledData );
}
- return new DataSource( comphelper::containerToSequence(aResultVector) );
+ return new DataSource( aResultVector );
}
uno::Sequence< OUString > DataSourceHelper::getUsedDataRanges(
- const uno::Reference< chart2::XDiagram > & xDiagram )
+ const rtl::Reference< Diagram > & xDiagram )
{
std::vector< OUString > aResult;
if( xDiagram.is())
{
- uno::Reference< data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) );
+ uno::Reference< data::XLabeledDataSequence > xCategories( xDiagram->getCategories() );
if( xCategories.is() )
lcl_addRanges( aResult, xCategories );
- std::vector< uno::Reference< XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ std::vector< rtl::Reference< DataSeries > > aSeriesVector( xDiagram->getDataSeries() );
for (auto const& series : aSeriesVector)
{
- uno::Reference< data::XDataSource > xDataSource(series, uno::UNO_QUERY);
- lcl_addDataSourceRanges( aResult, xDataSource );
+ lcl_addDataSourceRanges( aResult, series );
lcl_addErrorBarRanges( aResult, series );
}
}
@@ -279,69 +270,34 @@ uno::Sequence< OUString > DataSourceHelper::getUsedDataRanges(
return comphelper::containerToSequence( aResult );
}
-uno::Sequence< OUString > DataSourceHelper::getUsedDataRanges( const uno::Reference< frame::XModel > & xChartModel )
+uno::Sequence< OUString > DataSourceHelper::getUsedDataRanges( const rtl::Reference<::chart::ChartModel> & xChartModel )
{
- uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
+ rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() );
return getUsedDataRanges( xDiagram );
}
-uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
- const uno::Reference< chart2::XChartDocument >& xChartDoc )
-{
- return pressUsedDataIntoRectangularFormat( xChartDoc );
-}
-
-uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
- const uno::Reference< frame::XModel >& xChartModel )
-{
- std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aResult;
-
- uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
- uno::Reference< data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) );
- if( xCategories.is() )
- aResult.push_back( xCategories );
-
- std::vector< uno::Reference< XDataSeries > > aSeriesVector( ChartModelHelper::getDataSeries( xChartModel ) );
- for (auto const& series : aSeriesVector)
- {
- uno::Reference< data::XDataSource > xDataSource(series, uno::UNO_QUERY);
- if( !xDataSource.is() )
- continue;
- uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
- aResult.insert( aResult.end(), aDataSequences.begin(), aDataSequences.end() );
- }
-
- return uno::Reference< chart2::data::XDataSource >(
- new DataSource( comphelper::containerToSequence( aResult )));
-}
-
-uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
+rtl::Reference< DataSource > DataSourceHelper::getUsedData(
ChartModel& rModel )
{
std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aResult;
- uno::Reference< XDiagram > xDiagram( rModel.getFirstDiagram() );
- uno::Reference< data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) );
+ rtl::Reference< Diagram > xDiagram = rModel.getFirstChartDiagram();
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories( xDiagram->getCategories() );
if( xCategories.is() )
aResult.push_back( xCategories );
- std::vector< uno::Reference< XDataSeries > > aSeriesVector( ChartModelHelper::getDataSeries( rModel ) );
+ std::vector< rtl::Reference< DataSeries > > aSeriesVector = ChartModelHelper::getDataSeries( &rModel );
for (auto const& series : aSeriesVector)
{
- uno::Reference< data::XDataSource > xDataSource(series, uno::UNO_QUERY);
- if( !xDataSource.is() )
- continue;
- uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
+ const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aDataSequences( series->getDataSequences2() );
aResult.insert( aResult.end(), aDataSequences.begin(), aDataSequences.end() );
}
- return uno::Reference< chart2::data::XDataSource >(
- new DataSource( comphelper::containerToSequence( aResult )));
+ return new DataSource( aResult );
}
bool DataSourceHelper::detectRangeSegmentation(
- const uno::Reference<
- frame::XModel >& xChartModel
+ const rtl::Reference<::chart::ChartModel>& xChartModel
, OUString& rOutRangeString
, css::uno::Sequence< sal_Int32 >& rSequenceMapping
, bool& rOutUseColumns
@@ -350,22 +306,23 @@ bool DataSourceHelper::detectRangeSegmentation(
{
bool bSomethingDetected = false;
- uno::Reference< XChartDocument > xChartDocument( xChartModel, uno::UNO_QUERY );
- if( !xChartDocument.is() )
+ if( !xChartModel.is() )
return bSomethingDetected;
- uno::Reference< data::XDataProvider > xDataProvider( xChartDocument->getDataProvider() );
+ uno::Reference< data::XDataProvider > xDataProvider( xChartModel->getDataProvider() );
if( !xDataProvider.is() )
return bSomethingDetected;
try
{
DataSourceHelper::readArguments(
- xDataProvider->detectArguments( pressUsedDataIntoRectangularFormat( xChartDocument ) ),
+ xDataProvider->detectArguments( pressUsedDataIntoRectangularFormat( xChartModel ) ),
rOutRangeString, rSequenceMapping, rOutUseColumns, rOutFirstCellAsLabel, rOutHasCategories );
bSomethingDetected = !rOutRangeString.isEmpty();
- uno::Reference< chart2::data::XLabeledDataSequence > xCategories(
- DiagramHelper::getCategoriesFromDiagram( xChartDocument->getFirstDiagram() ));
+ rtl::Reference<Diagram> xDiagram = xChartModel->getFirstChartDiagram();
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories;
+ if (xDiagram)
+ xCategories = xDiagram->getCategories();
rOutHasCategories = xCategories.is();
}
catch( uno::Exception & )
@@ -376,7 +333,7 @@ bool DataSourceHelper::detectRangeSegmentation(
}
bool DataSourceHelper::allArgumentsForRectRangeDetected(
- const uno::Reference< chart2::XChartDocument >& xChartDocument )
+ const rtl::Reference<::chart::ChartModel>& xChartDocument )
{
bool bHasDataRowSource = false;
bool bHasFirstCellAsLabel = false;
@@ -420,30 +377,24 @@ bool DataSourceHelper::allArgumentsForRectRangeDetected(
}
void DataSourceHelper::setRangeSegmentation(
- const uno::Reference< frame::XModel >& xChartModel
+ const rtl::Reference<::chart::ChartModel>& xChartModel
, const css::uno::Sequence< sal_Int32 >& rSequenceMapping
, bool bUseColumns , bool bFirstCellAsLabel, bool bUseCategories )
{
- uno::Reference< XChartDocument > xChartDocument( xChartModel, uno::UNO_QUERY );
- if( !xChartDocument.is() )
- return;
- uno::Reference< data::XDataProvider > xDataProvider( xChartDocument->getDataProvider() );
+ uno::Reference< data::XDataProvider > xDataProvider( xChartModel->getDataProvider() );
if( !xDataProvider.is() )
return;
- uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
+ rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() );
if( !xDiagram.is() )
return;
- uno::Reference< chart2::XChartTypeManager > xChartTypeManager( xChartDocument->getChartTypeManager() );
+ rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartModel->getTypeManager();
if( !xChartTypeManager.is() )
return;
- uno::Reference< lang::XMultiServiceFactory > xTemplateFactory( xChartTypeManager, uno::UNO_QUERY );
- if( !xTemplateFactory.is() )
- return;
OUString aRangeString;
bool bDummy;
uno::Sequence< sal_Int32 > aDummy;
- readArguments( xDataProvider->detectArguments( pressUsedDataIntoRectangularFormat( xChartDocument )),
+ readArguments( xDataProvider->detectArguments( pressUsedDataIntoRectangularFormat( xChartModel )),
aRangeString, aDummy, bDummy, bDummy, bDummy );
uno::Sequence< beans::PropertyValue > aArguments(
@@ -471,20 +422,17 @@ Sequence< OUString > DataSourceHelper::getRangesFromLabeledDataSequence(
{
if( xValues.is())
{
- aResult.realloc( 2 );
- aResult[0] = xLabel->getSourceRangeRepresentation();
- aResult[1] = xValues->getSourceRangeRepresentation();
+ aResult = { xLabel->getSourceRangeRepresentation(),
+ xValues->getSourceRangeRepresentation() };
}
else
{
- aResult.realloc( 1 );
- aResult[0] = xLabel->getSourceRangeRepresentation();
+ aResult = { xLabel->getSourceRangeRepresentation() };
}
}
else if( xValues.is())
{
- aResult.realloc( 1 );
- aResult[0] = xValues->getSourceRangeRepresentation();
+ aResult = { xValues->getSourceRangeRepresentation() };
}
}
return aResult;
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 5805f929aebb..38aa97265396 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -18,48 +18,43 @@
*/
#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
-#include <ChartTypeHelper.hxx>
+#include <ChartType.hxx>
#include <ChartModel.hxx>
#include <ChartModelHelper.hxx>
#include <ExplicitCategoriesProvider.hxx>
-#include <servicenames_charttypes.hxx>
#include <RelativePositionHelper.hxx>
#include <ControllerLockGuard.hxx>
#include <NumberFormatterWrapper.hxx>
#include <unonames.hxx>
+#include <BaseCoordinateSystem.hxx>
-#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include <com/sun/star/chart/XDiagramPositioning.hpp>
#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
-#include <com/sun/star/chart2/XTitled.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
-#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
#include <com/sun/star/chart2/StackingDirection.hpp>
-#include <com/sun/star/util/CloseVetoException.hpp>
#include <com/sun/star/util/NumberFormat.hpp>
-#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#include <unotools/saveopt.hxx>
-#include <rtl/math.hxx>
+#include <svl/numformat.hxx>
#include <svl/zforlist.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <comphelper/sequence.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
+#include <limits>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -69,283 +64,10 @@ using ::com::sun::star::chart2::XAnyDescriptionAccess;
namespace chart
{
-DiagramHelper::tTemplateWithServiceName
- DiagramHelper::getTemplateForDiagram(
- const Reference< XDiagram > & xDiagram,
- const Reference< lang::XMultiServiceFactory > & xChartTypeManager )
-{
- DiagramHelper::tTemplateWithServiceName aResult;
-
- if( ! (xChartTypeManager.is() && xDiagram.is()))
- return aResult;
-
- Sequence< OUString > aServiceNames( xChartTypeManager->getAvailableServiceNames());
- const sal_Int32 nLength = aServiceNames.getLength();
-
- bool bTemplateFound = false;
-
- for( sal_Int32 i = 0; ! bTemplateFound && i < nLength; ++i )
- {
- try
- {
- Reference< XChartTypeTemplate > xTempl(
- xChartTypeManager->createInstance( aServiceNames[ i ] ), uno::UNO_QUERY_THROW );
-
- if (xTempl.is() && xTempl->matchesTemplate(xDiagram, true))
- {
- aResult.first = xTempl;
- aResult.second = aServiceNames[ i ];
- bTemplateFound = true;
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
- }
-
- return aResult;
-}
-
-void DiagramHelper::setVertical(
- const Reference< XDiagram > & xDiagram,
- bool bVertical /* = true */ )
-{
- try
- {
- Reference< XCoordinateSystemContainer > xCnt( xDiagram, uno::UNO_QUERY );
- if (!xCnt.is())
- return;
-
- const Sequence< Reference<XCoordinateSystem> > aCooSys = xCnt->getCoordinateSystems();
- uno::Any aValue;
- aValue <<= bVertical;
- for( uno::Reference< XCoordinateSystem > const & xCooSys : aCooSys )
- {
- Reference< beans::XPropertySet > xProp( xCooSys, uno::UNO_QUERY );
- bool bChanged = false;
- if (xProp.is())
- {
- bool bOldSwap = false;
- if( !(xProp->getPropertyValue("SwapXAndYAxis") >>= bOldSwap)
- || bVertical != bOldSwap )
- bChanged = true;
-
- if( bChanged )
- xProp->setPropertyValue("SwapXAndYAxis", aValue);
- }
-
- if (!xCooSys.is())
- continue;
-
- const sal_Int32 nDimensionCount = xCooSys->getDimension();
- sal_Int32 nDimIndex = 0;
- for (nDimIndex=0; nDimIndex < nDimensionCount; ++nDimIndex)
- {
- const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nDimIndex);
- for (sal_Int32 nI = 0; nI <= nMaximumScaleIndex; ++nI)
- {
- Reference<chart2::XAxis> xAxis = xCooSys->getAxisByDimension(nDimIndex,nI);
- if (!xAxis.is())
- continue;
-
- //adapt title rotation only when axis swapping has changed
- if (!bChanged)
- continue;
-
- Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY );
- if (!xTitled.is())
- continue;
-
- Reference< beans::XPropertySet > xTitleProps( xTitled->getTitleObject(), uno::UNO_QUERY );
- if (!xTitleProps.is())
- continue;
-
- double fAngleDegree = 0.0;
- xTitleProps->getPropertyValue("TextRotation") >>= fAngleDegree;
- if (fAngleDegree != 0.0 &&
- !rtl::math::approxEqual(fAngleDegree, 90.0))
- continue;
-
- double fNewAngleDegree = 0.0;
- if( !bVertical && nDimIndex == 1 )
- fNewAngleDegree = 90.0;
- else if( bVertical && nDimIndex == 0 )
- fNewAngleDegree = 90.0;
-
- xTitleProps->setPropertyValue("TextRotation", uno::Any(fNewAngleDegree));
- }
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
-bool DiagramHelper::getVertical( const uno::Reference< chart2::XDiagram > & xDiagram,
- bool& rbFound, bool& rbAmbiguous )
-{
- bool bValue = false;
- rbFound = false;
- rbAmbiguous = false;
-
- Reference< XCoordinateSystemContainer > xCnt( xDiagram, uno::UNO_QUERY );
- if (!xCnt.is())
- return false;
-
- const Sequence< Reference<XCoordinateSystem> > aCooSys = xCnt->getCoordinateSystems();
-
- for (Reference<XCoordinateSystem> const & coords : aCooSys)
- {
- Reference<beans::XPropertySet> xProp(coords, uno::UNO_QUERY);
- if (!xProp.is())
- continue;
-
- bool bCurrent = false;
- if (xProp->getPropertyValue("SwapXAndYAxis") >>= bCurrent)
- {
- if (!rbFound)
- {
- bValue = bCurrent;
- rbFound = true;
- }
- else if (bCurrent != bValue)
- {
- // ambiguous -> choose always first found
- rbAmbiguous = true;
- }
- }
- }
- return bValue;
-}
-
-void DiagramHelper::setStackMode(
- const Reference< XDiagram > & xDiagram,
- StackMode eStackMode
-)
-{
- try
- {
- bool bValueFound = false;
- bool bIsAmbiguous = false;
- StackMode eOldStackMode = DiagramHelper::getStackMode( xDiagram, bValueFound, bIsAmbiguous );
-
- if( eStackMode == eOldStackMode && !bIsAmbiguous )
- return;
-
- StackingDirection eNewDirection = StackingDirection_NO_STACKING;
- if( eStackMode == StackMode::YStacked || eStackMode == StackMode::YStackedPercent )
- eNewDirection = StackingDirection_Y_STACKING;
- else if( eStackMode == StackMode::ZStacked )
- eNewDirection = StackingDirection_Z_STACKING;
-
- uno::Any aNewDirection( eNewDirection );
-
- bool bPercent = false;
- if( eStackMode == StackMode::YStackedPercent )
- bPercent = true;
-
- //iterate through all coordinate systems
- uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( !xCooSysContainer.is() )
- return;
- const uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( uno::Reference< XCoordinateSystem > const & xCooSys : aCooSysList )
- {
- //set correct percent stacking
- const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(1);
- for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
- {
- Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension( 1,nI ));
- if( xAxis.is())
- {
- chart2::ScaleData aScaleData = xAxis->getScaleData();
- if( (aScaleData.AxisType==AxisType::PERCENT) != bPercent )
- {
- if( bPercent )
- aScaleData.AxisType = AxisType::PERCENT;
- else
- aScaleData.AxisType = AxisType::REALNUMBER;
- xAxis->setScaleData( aScaleData );
- }
- }
- }
- //iterate through all chart types in the current coordinate system
- uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
- if( !xChartTypeContainer.is() )
- continue;
- uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- if (!aChartTypeList.hasElements())
- continue;
-
- uno::Reference< XChartType > xChartType( aChartTypeList[0] );
-
- //iterate through all series in this chart type
- uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
- OSL_ASSERT( xDataSeriesContainer.is());
- if( !xDataSeriesContainer.is() )
- continue;
-
- const uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
- for( uno::Reference< XDataSeries > const & dataSeries : aSeriesList )
- {
- Reference< beans::XPropertySet > xProp( dataSeries, uno::UNO_QUERY );
- if(xProp.is())
- xProp->setPropertyValue( "StackingDirection", aNewDirection );
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
-StackMode DiagramHelper::getStackMode( const Reference< XDiagram > & xDiagram, bool& rbFound, bool& rbAmbiguous )
-{
- rbFound=false;
- rbAmbiguous=false;
-
- StackMode eGlobalStackMode = StackMode::NONE;
-
- //iterate through all coordinate systems
- uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( !xCooSysContainer.is() )
- return eGlobalStackMode;
- const uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( uno::Reference< XCoordinateSystem > const & xCooSys : aCooSysList )
- {
- //iterate through all chart types in the current coordinate system
- uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
- if( !xChartTypeContainer.is() )
- continue;
- uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
- {
- uno::Reference< XChartType > xChartType( aChartTypeList[nT] );
-
- StackMode eLocalStackMode = DiagramHelper::getStackModeFromChartType(
- xChartType, rbFound, rbAmbiguous, xCooSys );
-
- if( rbFound && eLocalStackMode != eGlobalStackMode && nT>0 )
- {
- rbAmbiguous = true;
- return eGlobalStackMode;
- }
-
- eGlobalStackMode = eLocalStackMode;
- }
- }
-
- return eGlobalStackMode;
-}
-
StackMode DiagramHelper::getStackModeFromChartType(
- const Reference< XChartType > & xChartType,
+ const rtl::Reference< ChartType > & xChartType,
bool& rbFound, bool& rbAmbiguous,
- const Reference< XCoordinateSystem > & xCorrespondingCoordinateSystem )
+ const rtl::Reference< BaseCoordinateSystem > & xCorrespondingCoordinateSystem )
{
StackMode eStackMode = StackMode::NONE;
rbFound = false;
@@ -353,23 +75,21 @@ StackMode DiagramHelper::getStackModeFromChartType(
try
{
- Reference< XDataSeriesContainer > xDSCnt( xChartType, uno::UNO_QUERY_THROW );
- Sequence< Reference< chart2::XDataSeries > > aSeries( xDSCnt->getDataSeries());
+ const std::vector< rtl::Reference< DataSeries > > & aSeries = xChartType->getDataSeries2();
chart2::StackingDirection eCommonDirection = chart2::StackingDirection_NO_STACKING;
bool bDirectionInitialized = false;
// first series is irrelevant for stacking, start with second, unless
// there is only one series
- const sal_Int32 nSeriesCount = aSeries.getLength();
+ const sal_Int32 nSeriesCount = aSeries.size();
sal_Int32 i = (nSeriesCount == 1) ? 0: 1;
for( ; i<nSeriesCount; ++i )
{
rbFound = true;
- Reference< beans::XPropertySet > xProp( aSeries[i], uno::UNO_QUERY_THROW );
chart2::StackingDirection eCurrentDirection = eCommonDirection;
// property is not MAYBEVOID
- bool bSuccess = ( xProp->getPropertyValue( "StackingDirection" ) >>= eCurrentDirection );
+ bool bSuccess = ( aSeries[i]->getPropertyValue( "StackingDirection" ) >>= eCurrentDirection );
OSL_ASSERT( bSuccess );
if( ! bDirectionInitialized )
{
@@ -403,8 +123,8 @@ StackMode DiagramHelper::getStackModeFromChartType(
if( nSeriesCount )
nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(aSeries[0]);
- Reference< chart2::XAxis > xAxis(
- xCorrespondingCoordinateSystem->getAxisByDimension( 1,nAxisIndex ));
+ rtl::Reference< Axis > xAxis =
+ xCorrespondingCoordinateSystem->getAxisByDimension2( 1,nAxisIndex );
if( xAxis.is())
{
chart2::ScaleData aScaleData = xAxis->getScaleData();
@@ -424,502 +144,26 @@ StackMode DiagramHelper::getStackModeFromChartType(
return eStackMode;
}
-sal_Int32 DiagramHelper::getDimension( const Reference< XDiagram > & xDiagram )
-{
- // -1: not yet set
- sal_Int32 nResult = -1;
-
- try
- {
- Reference< XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY );
- if( xCooSysCnt.is() )
- {
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
-
- for( Reference< XCoordinateSystem > const & xCooSys : aCooSysSeq )
- {
- if(xCooSys.is())
- {
- nResult = xCooSys->getDimension();
- break;
- }
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- return nResult;
-}
-
-void DiagramHelper::setDimension(
- const Reference< XDiagram > & xDiagram,
- sal_Int32 nNewDimensionCount )
-{
- if( ! xDiagram.is())
- return;
-
- if( DiagramHelper::getDimension( xDiagram ) == nNewDimensionCount )
- return;
-
- try
- {
- bool rbFound = false;
- bool rbAmbiguous = true;
- StackMode eStackMode = DiagramHelper::getStackMode( xDiagram, rbFound, rbAmbiguous );
- bool bIsSupportingOnlyDeepStackingFor3D=false;
-
- //change all coordinate systems:
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( Reference<XCoordinateSystem> const & xOldCooSys : aCooSysList )
- {
- Reference< XCoordinateSystem > xNewCooSys;
-
- Reference< XChartTypeContainer > xChartTypeContainer( xOldCooSys, uno::UNO_QUERY );
- if( !xChartTypeContainer.is() )
- continue;
-
- const Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- for( Reference< XChartType > const & xChartType : aChartTypeList )
- {
- bIsSupportingOnlyDeepStackingFor3D = ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( xChartType );
- if(!xNewCooSys.is())
- {
- xNewCooSys = xChartType->createCoordinateSystem( nNewDimensionCount );
- break;
- }
- //@todo make sure that all following charttypes are also capable of the new dimension
- //otherwise separate them in a different group
- //BM: might be done in replaceCoordinateSystem()
- }
-
- // replace the old coordinate system at all places where it was used
- DiagramHelper::replaceCoordinateSystem( xDiagram, xOldCooSys, xNewCooSys );
- }
-
- //correct stack mode if necessary
- if( nNewDimensionCount==3 && eStackMode != StackMode::ZStacked && bIsSupportingOnlyDeepStackingFor3D )
- DiagramHelper::setStackMode( xDiagram, StackMode::ZStacked );
- else if( nNewDimensionCount==2 && eStackMode == StackMode::ZStacked )
- DiagramHelper::setStackMode( xDiagram, StackMode::NONE );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
-void DiagramHelper::replaceCoordinateSystem(
- const Reference< XDiagram > & xDiagram,
- const Reference< XCoordinateSystem > & xCooSysToReplace,
- const Reference< XCoordinateSystem > & xReplacement )
-{
- OSL_ASSERT( xDiagram.is());
- if( ! xDiagram.is())
- return;
-
- // update the coordinate-system container
- Reference< XCoordinateSystemContainer > xCont( xDiagram, uno::UNO_QUERY );
- if( !xCont.is())
- return;
-
- try
- {
- Reference< chart2::data::XLabeledDataSequence > xCategories = DiagramHelper::getCategoriesFromDiagram( xDiagram );
-
- // move chart types of xCooSysToReplace to xReplacement
- Reference< XChartTypeContainer > xCTCntCooSys( xCooSysToReplace, uno::UNO_QUERY_THROW );
- Reference< XChartTypeContainer > xCTCntReplacement( xReplacement, uno::UNO_QUERY_THROW );
- xCTCntReplacement->setChartTypes( xCTCntCooSys->getChartTypes());
-
- xCont->removeCoordinateSystem( xCooSysToReplace );
- xCont->addCoordinateSystem( xReplacement );
-
- if( xCategories.is() )
- DiagramHelper::setCategoriesToDiagram( xCategories, xDiagram );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
bool DiagramHelper::isSeriesAttachedToMainAxis(
- const uno::Reference< chart2::XDataSeries >& xDataSeries )
+ const rtl::Reference< ::chart::DataSeries >& xDataSeries )
{
sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
return (nAxisIndex==0);
}
-bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis
- , const uno::Reference< chart2::XDataSeries >& xDataSeries
- , const uno::Reference< chart2::XDiagram >& xDiagram
- , const uno::Reference< uno::XComponentContext > & xContext
- , bool bAdaptAxes )
-{
- bool bChanged = false;
-
- //set property at axis
- Reference< beans::XPropertySet > xProp( xDataSeries, uno::UNO_QUERY_THROW );
-
- sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1;
- sal_Int32 nOldAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
- uno::Reference< chart2::XAxis > xOldAxis( DiagramHelper::getAttachedAxis( xDataSeries, xDiagram ) );
-
- if( nOldAxisIndex != nNewAxisIndex )
- {
- try
- {
- xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( nNewAxisIndex ) );
- bChanged = true;
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
- }
-
- if( bChanged && xDiagram.is() )
- {
- uno::Reference< XAxis > xAxis( AxisHelper::getAxis( 1, bAttachToMainAxis, xDiagram ) );
- if(!xAxis.is()) //create an axis if necessary
- xAxis = AxisHelper::createAxis( 1, bAttachToMainAxis, xDiagram, xContext );
- if( bAdaptAxes )
- {
- AxisHelper::makeAxisVisible( xAxis );
- AxisHelper::hideAxisIfNoDataIsAttached( xOldAxis, xDiagram );
- }
- }
-
- return bChanged;
-}
-
-uno::Reference< XAxis > DiagramHelper::getAttachedAxis(
- const uno::Reference< XDataSeries >& xSeries,
- const uno::Reference< XDiagram >& xDiagram )
-{
- return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( xSeries ), xDiagram );
-}
-
-uno::Reference< XChartType > DiagramHelper::getChartTypeOfSeries(
- const uno::Reference< chart2::XDiagram >& xDiagram
- , const uno::Reference< XDataSeries >& xGivenDataSeries )
-{
- if( !xGivenDataSeries.is() )
- return nullptr;
- if(!xDiagram.is())
- return nullptr;
-
- //iterate through the model to find the given xSeries
- //the found parent indicates the charttype
-
- //iterate through all coordinate systems
- uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( !xCooSysContainer.is())
- return nullptr;
-
- const uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( uno::Reference< XCoordinateSystem > const & xCooSys : aCooSysList )
- {
- //iterate through all chart types in the current coordinate system
- uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
- OSL_ASSERT( xChartTypeContainer.is());
- if( !xChartTypeContainer.is() )
- continue;
- const uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- for( uno::Reference< XChartType > const & xChartType : aChartTypeList )
- {
- //iterate through all series in this chart type
- uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
- OSL_ASSERT( xDataSeriesContainer.is());
- if( !xDataSeriesContainer.is() )
- continue;
-
- const uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
- for( uno::Reference< XDataSeries > const & dataSeries : aSeriesList )
- {
- if( xGivenDataSeries==dataSeries )
- return xChartType;
- }
- }
- }
- return nullptr;
-}
-
-std::vector< Reference< XDataSeries > >
- DiagramHelper::getDataSeriesFromDiagram(
- const Reference< XDiagram > & xDiagram )
-{
- std::vector< Reference< XDataSeries > > aResult;
-
- try
- {
- Reference< XCoordinateSystemContainer > xCooSysCnt(
- xDiagram, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
- for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
- {
- Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
- for( Reference< XChartType> const & chartType : aChartTypeSeq )
- {
- Reference< XDataSeriesContainer > xDSCnt( chartType, uno::UNO_QUERY_THROW );
- Sequence< Reference< XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() );
- aResult.insert( aResult.end(), aSeriesSeq.begin(), aSeriesSeq.end() );
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- return aResult;
-}
-
-Sequence< Sequence< Reference< XDataSeries > > >
- DiagramHelper::getDataSeriesGroups( const Reference< XDiagram > & xDiagram )
-{
- vector< Sequence< Reference< XDataSeries > > > aResult;
-
- //iterate through all coordinate systems
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( xCooSysContainer.is() )
- {
- const Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( Reference< XCoordinateSystem > const & coords : aCooSysList )
- {
- //iterate through all chart types in the current coordinate system
- Reference< XChartTypeContainer > xChartTypeContainer( coords, uno::UNO_QUERY );
- if( !xChartTypeContainer.is() )
- continue;
- const Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- for( Reference< XChartType > const & chartType : aChartTypeList )
- {
- Reference< XDataSeriesContainer > xDataSeriesContainer( chartType, uno::UNO_QUERY );
- if( !xDataSeriesContainer.is() )
- continue;
- aResult.push_back( xDataSeriesContainer->getDataSeries() );
- }
- }
- }
- return comphelper::containerToSequence( aResult );
-}
-
-Reference< XChartType >
- DiagramHelper::getChartTypeByIndex( const Reference< XDiagram >& xDiagram, sal_Int32 nIndex )
-{
- Reference< XChartType > xChartType;
-
- //iterate through all coordinate systems
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( ! xCooSysContainer.is())
- return xChartType;
-
- const Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- sal_Int32 nTypesSoFar = 0;
- for( Reference< XCoordinateSystem > const & coords : aCooSysList )
- {
- Reference< XChartTypeContainer > xChartTypeContainer( coords, uno::UNO_QUERY );
- if( !xChartTypeContainer.is() )
- continue;
- Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- if( nIndex >= 0 && nIndex < (nTypesSoFar + aChartTypeList.getLength()) )
- {
- xChartType.set( aChartTypeList[nIndex - nTypesSoFar] );
- break;
- }
- nTypesSoFar += aChartTypeList.getLength();
- }
-
- return xChartType;
-}
-
-namespace
-{
-
-std::vector< Reference< XAxis > > lcl_getAxisHoldingCategoriesFromDiagram(
- const Reference< XDiagram > & xDiagram )
-{
- std::vector< Reference< XAxis > > aRet;
-
- // return first x-axis as fall-back
- Reference< XAxis > xFallBack;
- try
- {
- Reference< XCoordinateSystemContainer > xCooSysCnt(
- xDiagram, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
- for( Reference< XCoordinateSystem > const & xCooSys : aCooSysSeq )
- {
- OSL_ASSERT( xCooSys.is());
- for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
- {
- const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
- for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
- {
- Reference< XAxis > xAxis = xCooSys->getAxisByDimension( nN,nI );
- OSL_ASSERT( xAxis.is());
- if( xAxis.is())
- {
- ScaleData aScaleData = xAxis->getScaleData();
- if( aScaleData.Categories.is() || (aScaleData.AxisType == AxisType::CATEGORY) )
- {
- aRet.push_back(xAxis);
- }
- if( (nN == 0) && !xFallBack.is())
- xFallBack.set( xAxis );
- }
- }
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2" );
- }
-
- if( aRet.empty() )
- aRet.push_back(xFallBack);
-
- return aRet;
-}
-
-} // anonymous namespace
-
-bool DiagramHelper::isCategoryDiagram(
- const Reference< XDiagram >& xDiagram )
-{
- try
- {
- Reference< XCoordinateSystemContainer > xCooSysCnt(
- xDiagram, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
- for( Reference< XCoordinateSystem > const & xCooSys : aCooSysSeq )
- {
- OSL_ASSERT( xCooSys.is());
- for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
- {
- const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
- for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
- {
- Reference< XAxis > xAxis = xCooSys->getAxisByDimension( nN,nI );
- OSL_ASSERT( xAxis.is());
- if( xAxis.is())
- {
- ScaleData aScaleData = xAxis->getScaleData();
- if( aScaleData.AxisType == AxisType::CATEGORY || aScaleData.AxisType == AxisType::DATE )
- return true;
- }
- }
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- return false;
-}
-
-void DiagramHelper::setCategoriesToDiagram(
- const Reference< chart2::data::XLabeledDataSequence >& xCategories,
- const Reference< XDiagram >& xDiagram,
- bool bSetAxisType /* = false */,
- bool bCategoryAxis /* = true */ )
-{
- std::vector< Reference< chart2::XAxis > > aCatAxes(
- lcl_getAxisHoldingCategoriesFromDiagram( xDiagram ));
-
- for (const Reference< chart2::XAxis >& xCatAxis : aCatAxes)
- {
- if( xCatAxis.is())
- {
- ScaleData aScaleData( xCatAxis->getScaleData());
- aScaleData.Categories = xCategories;
- if( bSetAxisType )
- {
- if( bCategoryAxis )
- aScaleData.AxisType = AxisType::CATEGORY;
- else if( aScaleData.AxisType == AxisType::CATEGORY || aScaleData.AxisType == AxisType::DATE )
- aScaleData.AxisType = AxisType::REALNUMBER;
- }
- xCatAxis->setScaleData( aScaleData );
- }
- }
-}
-
-Reference< data::XLabeledDataSequence >
- DiagramHelper::getCategoriesFromDiagram(
- const Reference< XDiagram > & xDiagram )
-{
- Reference< data::XLabeledDataSequence > xResult;
-
- try
- {
- std::vector< Reference< chart2::XAxis > > aCatAxes(
- lcl_getAxisHoldingCategoriesFromDiagram( xDiagram ));
- //search for first categories
- if (!aCatAxes.empty())
- {
- Reference< chart2::XAxis > xCatAxis(aCatAxes[0]);
- if( xCatAxis.is())
- {
- ScaleData aScaleData( xCatAxis->getScaleData());
- if( aScaleData.Categories.is() )
- {
- xResult.set( aScaleData.Categories );
- uno::Reference<beans::XPropertySet> xProp(aScaleData.Categories->getValues(), uno::UNO_QUERY );
- if( xProp.is() )
- {
- try
- {
- xProp->setPropertyValue( "Role", uno::Any( OUString("categories") ) );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
- }
- }
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- return xResult;
-}
-
static void lcl_generateAutomaticCategoriesFromChartType(
Sequence< OUString >& rRet,
- const Reference< XChartType >& xChartType )
+ const rtl::Reference< ChartType >& xChartType )
{
if(!xChartType.is())
return;
OUString aMainSeq( xChartType->getRoleOfSequenceForSeriesLabel() );
- Reference< XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY );
- if( !xSeriesCnt.is() )
- return;
- const Sequence< Reference< XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries() );
- for( Reference< XDataSeries > const & dataSeries : aSeriesSeq )
+ const std::vector< rtl::Reference< DataSeries > > & aSeriesSeq = xChartType->getDataSeries2();
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeriesSeq )
{
- Reference< data::XDataSource > xDataSource( dataSeries, uno::UNO_QUERY );
- if( !xDataSource.is() )
- continue;
- Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
- ::chart::DataSeriesHelper::getDataSequenceByRole( xDataSource, aMainSeq ));
+ uno::Reference< data::XLabeledDataSequence > xLabeledSeq =
+ ::chart::DataSeriesHelper::getDataSequenceByRole( dataSeries, aMainSeq );
if( !xLabeledSeq.is() )
continue;
Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues() );
@@ -931,15 +175,14 @@ static void lcl_generateAutomaticCategoriesFromChartType(
}
}
-Sequence< OUString > DiagramHelper::generateAutomaticCategoriesFromCooSys( const Reference< XCoordinateSystem > & xCooSys )
+Sequence< OUString > DiagramHelper::generateAutomaticCategoriesFromCooSys( const rtl::Reference< BaseCoordinateSystem > & xCooSys )
{
Sequence< OUString > aRet;
- Reference< XChartTypeContainer > xTypeCntr( xCooSys, uno::UNO_QUERY );
- if( xTypeCntr.is() )
+ if( xCooSys.is() )
{
- const Sequence< Reference< XChartType > > aChartTypes( xTypeCntr->getChartTypes() );
- for( Reference< XChartType > const & chartType : aChartTypes )
+ const std::vector< rtl::Reference< ChartType > > & aChartTypes( xCooSys->getChartTypes2() );
+ for( rtl::Reference< ChartType > const & chartType : aChartTypes )
{
lcl_generateAutomaticCategoriesFromChartType( aRet, chartType );
if( aRet.hasElements() )
@@ -952,14 +195,14 @@ Sequence< OUString > DiagramHelper::generateAutomaticCategoriesFromCooSys( const
Sequence< OUString > DiagramHelper::getExplicitSimpleCategories(
ChartModel& rModel )
{
- uno::Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( rModel ) );
+ rtl::Reference< BaseCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( &rModel ) );
ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, rModel );
return aExplicitCategoriesProvider.getSimpleCategories();
}
namespace
{
-void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, const Reference< XAxis >& xAxis )
+void lcl_switchToDateCategories( const rtl::Reference< ChartModel >& xChartDoc, const Reference< XAxis >& xAxis )
{
if( !xAxis.is() )
return;
@@ -974,21 +217,20 @@ void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, c
if( xDataAccess.is() )
{
Sequence< Sequence< Any > > aAnyCategories( xDataAccess->getAnyRowDescriptions() );
+ auto aAnyCategoriesRange = asNonConstRange(aAnyCategories);
double fTest = 0.0;
- double fNan = 0.0;
- ::rtl::math::setNan( & fNan );
sal_Int32 nN = aAnyCategories.getLength();
for( ; nN--; )
{
- Sequence< Any >& rCat = aAnyCategories[nN];
+ Sequence< Any >& rCat = aAnyCategoriesRange[nN];
if( rCat.getLength() > 1 )
rCat.realloc(1);
if( rCat.getLength() == 1 )
{
- Any& rAny = rCat[0];
+ Any& rAny = rCat.getArray()[0];
if( !(rAny>>=fTest) )
{
- rAny <<= fNan;
+ rAny <<= std::numeric_limits<double>::quiet_NaN();
}
}
}
@@ -996,13 +238,12 @@ void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, c
}
//check the numberformat at the axis
Reference< beans::XPropertySet > xAxisProps( xAxis, uno::UNO_QUERY );
- Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartDoc, uno::UNO_QUERY );
- if( xAxisProps.is() && xNumberFormatsSupplier.is() )
+ if( xAxisProps.is() )
{
sal_Int32 nNumberFormat = -1;
xAxisProps->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
- Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() );
+ Reference< util::XNumberFormats > xNumberFormats( xChartDoc->getNumberFormats() );
if( xNumberFormats.is() )
{
Reference< beans::XPropertySet > xKeyProps;
@@ -1036,7 +277,7 @@ void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, c
xAxis->setScaleData( aScale );
}
-void lcl_switchToTextCategories( const Reference< XChartDocument >& xChartDoc, const Reference< XAxis >& xAxis )
+void lcl_switchToTextCategories( const rtl::Reference< ChartModel >& xChartDoc, const Reference< XAxis >& xAxis )
{
if( !xAxis.is() )
return;
@@ -1053,42 +294,36 @@ void lcl_switchToTextCategories( const Reference< XChartDocument >& xChartDoc, c
}
-void DiagramHelper::switchToDateCategories( const Reference< XChartDocument >& xChartDoc )
+void DiagramHelper::switchToDateCategories( const rtl::Reference<::chart::ChartModel>& xChartDoc )
{
if(xChartDoc.is())
{
ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
- Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartDoc ) );
+ rtl::Reference< BaseCoordinateSystem > xCooSys = ChartModelHelper::getFirstCoordinateSystem( xChartDoc );
if( xCooSys.is() )
{
- Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) );
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2(0,0);
lcl_switchToDateCategories( xChartDoc, xAxis );
}
}
}
-void DiagramHelper::switchToTextCategories( const Reference< XChartDocument >& xChartDoc )
+void DiagramHelper::switchToTextCategories( const rtl::Reference<::chart::ChartModel>& xChartDoc )
{
if(xChartDoc.is())
{
ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
- Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartDoc ) );
+ rtl::Reference< BaseCoordinateSystem > xCooSys = ChartModelHelper::getFirstCoordinateSystem( xChartDoc );
if( xCooSys.is() )
{
- Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) );
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2(0,0);
lcl_switchToTextCategories( xChartDoc, xAxis );
}
}
}
-bool DiagramHelper::isSupportingDateAxis( const Reference< chart2::XDiagram >& xDiagram )
-{
- return ::chart::ChartTypeHelper::isSupportingDateAxis(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), 0 );
-}
-
bool DiagramHelper::isDateNumberFormat( sal_Int32 nNumberFormat, const Reference< util::XNumberFormats >& xNumberFormats )
{
bool bIsDate = false;
@@ -1148,7 +383,7 @@ sal_Int32 DiagramHelper::getDateTimeInputNumberFormat( const Reference< util::XN
// Obtain best matching date, time or datetime format.
nRet = pNumFormatter->GuessDateTimeFormat( nType, fNumber, LANGUAGE_SYSTEM);
// Obtain the corresponding edit format.
- nRet = pNumFormatter->GetEditFormat( fNumber, nRet, nType, LANGUAGE_SYSTEM, nullptr);
+ nRet = pNumFormatter->GetEditFormat( fNumber, nRet, nType, nullptr);
}
return nRet;
}
@@ -1183,38 +418,8 @@ sal_Int32 DiagramHelper::getPercentNumberFormat( const Reference< util::XNumberF
return nRet;
}
-Sequence< Reference< XChartType > >
- DiagramHelper::getChartTypesFromDiagram(
- const Reference< XDiagram > & xDiagram )
-{
- std::vector< Reference< XChartType > > aResult;
-
- if(xDiagram.is())
- {
- try
- {
- Reference< XCoordinateSystemContainer > xCooSysCnt(
- xDiagram, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
- for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
- {
- Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
- Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
- aResult.insert( aResult.end(), aChartTypeSeq.begin(), aChartTypeSeq.end() );
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
- }
-
- return comphelper::containerToSequence( aResult );
-}
-
-bool DiagramHelper::areChartTypesCompatible( const Reference< ::chart2::XChartType >& xFirstType,
- const Reference< ::chart2::XChartType >& xSecondType )
+bool DiagramHelper::areChartTypesCompatible( const rtl::Reference< ChartType >& xFirstType,
+ const rtl::Reference< ChartType >& xSecondType )
{
if( !xFirstType.is() || !xSecondType.is() )
return false;
@@ -1226,353 +431,6 @@ bool DiagramHelper::areChartTypesCompatible( const Reference< ::chart2::XChartTy
return ( aFirstRoles == aSecondRoles );
}
-namespace
-{
- /**
- * This method implements the logic of checking if a series can be moved
- * forward/backward. Depending on the "bDoMove" parameter the series will
- * be moved (bDoMove = true) or the function just will test if the
- * series can be moved without doing the move (bDoMove = false).
- *
- * @param xDiagram
- * Reference to the diagram that contains the series.
- *
- * @param xGivenDataSeries
- * Reference to the series that should moved or tested for moving.
- *
- * @param bForward
- * Direction in which the series should be moved or tested for moving.
- *
- * @param bDoMove
- * Should this function really move the series (true) or just test if it is
- * possible (false).
- *
- *
- * @returns
- * in case of bDoMove == true
- * - True : if the move was done
- * - False : the move failed
- * in case of bDoMove == false
- * - True : the series can be moved
- * - False : the series can not be moved
- *
- */
-
-bool lcl_moveSeriesOrCheckIfMoveIsAllowed(
- const Reference< XDiagram >& xDiagram,
- const Reference< XDataSeries >& xGivenDataSeries,
- bool bForward,
- bool bDoMove )
-{
- bool bMovedOrMoveAllowed = false;
-
- try
- {
- uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
-
- if( xGivenDataSeries.is() && xCooSysContainer.is() )
- {
- //find position of series.
- bool bFound = false;
- uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
-
- for( sal_Int32 nCS = 0; !bFound && nCS < aCooSysList.getLength(); ++nCS )
- {
- uno::Reference< XCoordinateSystem > xCooSys( aCooSysList[nCS] );
-
- //iterate through all chart types in the current coordinate system
- uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
- OSL_ASSERT( xChartTypeContainer.is());
- if( !xChartTypeContainer.is() )
- continue;
- uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- uno::Reference< XChartType > xFormerChartType;
-
- for( sal_Int32 nT = 0; !bFound && nT < aChartTypeList.getLength(); ++nT )
- {
- uno::Reference< XChartType > xCurrentChartType( aChartTypeList[nT] );
-
- //iterate through all series in this chart type
- uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xCurrentChartType, uno::UNO_QUERY );
- OSL_ASSERT( xDataSeriesContainer.is());
- if( !xDataSeriesContainer.is() )
- continue;
-
- uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
-
- for( sal_Int32 nS = 0; !bFound && nS < aSeriesList.getLength(); ++nS )
- {
-
- // We found the series we are interested in!
- if( xGivenDataSeries==aSeriesList[nS] )
- {
- sal_Int32 nOldSeriesIndex = nS;
- bFound = true;
-
- try
- {
- sal_Int32 nNewSeriesIndex = nS;
-
- // tdf#34517 Bringing forward means increasing, backwards means decreasing series position
- if( !bForward )
- nNewSeriesIndex--;
- else
- nNewSeriesIndex++;
-
- if( nNewSeriesIndex >= 0 && nNewSeriesIndex < aSeriesList.getLength() )
- {
- //move series in the same charttype
- bMovedOrMoveAllowed = true;
- if( bDoMove )
- {
- aSeriesList[ nOldSeriesIndex ] = aSeriesList[ nNewSeriesIndex ];
- aSeriesList[ nNewSeriesIndex ] = xGivenDataSeries;
- xDataSeriesContainer->setDataSeries( aSeriesList );
- }
- }
- else if( nNewSeriesIndex<0 )
- {
- //exchange series with former charttype
- if( xFormerChartType.is() && DiagramHelper::areChartTypesCompatible( xFormerChartType, xCurrentChartType ) )
- {
- bMovedOrMoveAllowed = true;
- if( bDoMove )
- {
- uno::Reference< XDataSeriesContainer > xOtherDataSeriesContainer( xFormerChartType, uno::UNO_QUERY );
- if( xOtherDataSeriesContainer.is() )
- {
- uno::Sequence< uno::Reference< XDataSeries > > aOtherSeriesList( xOtherDataSeriesContainer->getDataSeries() );
- sal_Int32 nOtherSeriesIndex = aOtherSeriesList.getLength()-1;
- if( nOtherSeriesIndex >= 0 && nOtherSeriesIndex < aOtherSeriesList.getLength() )
- {
- uno::Reference< XDataSeries > xExchangeSeries( aOtherSeriesList[nOtherSeriesIndex] );
- aOtherSeriesList[nOtherSeriesIndex] = xGivenDataSeries;
- xOtherDataSeriesContainer->setDataSeries(aOtherSeriesList);
-
- aSeriesList[nOldSeriesIndex]=xExchangeSeries;
- xDataSeriesContainer->setDataSeries(aSeriesList);
- }
- }
- }
- }
- }
- else if( nT+1 < aChartTypeList.getLength() )
- {
- //exchange series with next charttype
- uno::Reference< XChartType > xOtherChartType( aChartTypeList[nT+1] );
- if( xOtherChartType.is() && DiagramHelper::areChartTypesCompatible( xOtherChartType, xCurrentChartType ) )
- {
- bMovedOrMoveAllowed = true;
- if( bDoMove )
- {
- uno::Reference< XDataSeriesContainer > xOtherDataSeriesContainer( xOtherChartType, uno::UNO_QUERY );
- if( xOtherDataSeriesContainer.is() )
- {
- uno::Sequence< uno::Reference< XDataSeries > > aOtherSeriesList( xOtherDataSeriesContainer->getDataSeries() );
- if( aOtherSeriesList.hasElements() )
- {
- uno::Reference< XDataSeries > xExchangeSeries( aOtherSeriesList[0] );
- aOtherSeriesList[0] = xGivenDataSeries;
- xOtherDataSeriesContainer->setDataSeries(aOtherSeriesList);
-
- aSeriesList[nOldSeriesIndex]=xExchangeSeries;
- xDataSeriesContainer->setDataSeries(aSeriesList);
- }
- }
- }
- }
- }
- }
- catch( const util::CloseVetoException& )
- {
- }
- catch( const uno::RuntimeException& )
- {
- }
- }
- }
- xFormerChartType = xCurrentChartType;
- }
- }
- }
- }
- catch( const util::CloseVetoException& )
- {
- }
- catch( const uno::RuntimeException& )
- {
- }
- return bMovedOrMoveAllowed;
-}
-} // anonymous namespace
-
-bool DiagramHelper::isSeriesMoveable(
- const Reference< XDiagram >& xDiagram,
- const Reference< XDataSeries >& xGivenDataSeries,
- bool bForward )
-{
- const bool bDoMove = false;
-
- bool bIsMoveable = lcl_moveSeriesOrCheckIfMoveIsAllowed(
- xDiagram, xGivenDataSeries, bForward, bDoMove );
-
- return bIsMoveable;
-}
-
-bool DiagramHelper::moveSeries( const Reference< XDiagram >& xDiagram, const Reference< XDataSeries >& xGivenDataSeries, bool bForward )
-{
- const bool bDoMove = true;
-
- bool bMoved = lcl_moveSeriesOrCheckIfMoveIsAllowed(
- xDiagram, xGivenDataSeries, bForward, bDoMove );
-
- return bMoved;
-}
-
-bool DiagramHelper::isSupportingFloorAndWall( const Reference<
- chart2::XDiagram >& xDiagram )
-{
- //pies and donuts currently do not support this because of wrong files from older versions
- //todo: allow this in future again, if fileversion is available for OLE objects (metastream)
- //thus the wrong bottom can be removed on import
-
- const Sequence< Reference< chart2::XChartType > > aTypes(
- ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
- for( Reference< chart2::XChartType > const & xType : aTypes )
- {
- if( xType.is() && xType->getChartType().match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
- return false;
- if( xType.is() && xType->getChartType().match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
- return false;
- if( xType.is() && xType->getChartType().match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
- return false;
- }
- return true;
-}
-
-bool DiagramHelper::isPieOrDonutChart( const css::uno::Reference< css::chart2::XDiagram >& xDiagram )
-{
- uno::Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex(
- xDiagram, 0 ) );
-
- if( xChartType .is() )
- {
- OUString aChartType = xChartType->getChartType();
- if( aChartType == CHART2_SERVICE_NAME_CHARTTYPE_PIE )
- return true;
- }
- return false;
-}
-
-sal_Int32 DiagramHelper::getGeometry3D(
- const uno::Reference< chart2::XDiagram > & xDiagram,
- bool& rbFound, bool& rbAmbiguous )
-{
- sal_Int32 nCommonGeom( DataPointGeometry3D::CUBOID );
- rbFound = false;
- rbAmbiguous = false;
-
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
-
- if( aSeriesVec.empty())
- rbAmbiguous = true;
-
- for (auto const& series : aSeriesVec)
- {
- try
- {
- sal_Int32 nGeom = 0;
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
- if( xProp->getPropertyValue( "Geometry3D") >>= nGeom )
- {
- if( ! rbFound )
- {
- // first series
- nCommonGeom = nGeom;
- rbFound = true;
- }
- // further series: compare for uniqueness
- else if( nCommonGeom != nGeom )
- {
- rbAmbiguous = true;
- break;
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
- }
-
- return nCommonGeom;
-}
-
-void DiagramHelper::setGeometry3D(
- const Reference< chart2::XDiagram > & xDiagram,
- sal_Int32 nNewGeometry )
-{
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
-
- for (auto const& series : aSeriesVec)
- {
- DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(
- series, "Geometry3D", uno::Any( nNewGeometry ));
- }
-}
-
-sal_Int32 DiagramHelper::getCorrectedMissingValueTreatment(
- const Reference< chart2::XDiagram > & xDiagram,
- const Reference< chart2::XChartType >& xChartType )
-{
- sal_Int32 nResult = css::chart::MissingValueTreatment::LEAVE_GAP;
- const uno::Sequence < sal_Int32 > aAvailableMissingValueTreatments(
- ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) );
-
- uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
- if( xDiaProp.is() && (xDiaProp->getPropertyValue( "MissingValueTreatment" ) >>= nResult) )
- {
- //ensure that the set value is supported by this charttype
- for( sal_Int32 n : aAvailableMissingValueTreatments )
- if( n == nResult )
- return nResult; //ok
- }
-
- //otherwise use the first supported one
- if( aAvailableMissingValueTreatments.hasElements() )
- {
- nResult = aAvailableMissingValueTreatments[0];
- return nResult;
- }
-
- return nResult;
-}
-
-DiagramPositioningMode DiagramHelper::getDiagramPositioningMode( const uno::Reference<
- chart2::XDiagram > & xDiagram )
-{
- DiagramPositioningMode eMode = DiagramPositioningMode_AUTO;
- uno::Reference< beans::XPropertySet > xDiaProps( xDiagram, uno::UNO_QUERY );
- if( xDiaProps.is() )
- {
- RelativePosition aRelPos;
- RelativeSize aRelSize;
- if( (xDiaProps->getPropertyValue("RelativePosition") >>= aRelPos ) &&
- (xDiaProps->getPropertyValue("RelativeSize") >>= aRelSize ) )
- {
- bool bPosSizeExcludeAxes=false;
- xDiaProps->getPropertyValue("PosSizeExcludeAxes") >>= bPosSizeExcludeAxes;
- if( bPosSizeExcludeAxes )
- eMode = DiagramPositioningMode_EXCLUDING;
- else
- eMode = DiagramPositioningMode_INCLUDING;
- }
- }
- return eMode;
-}
-
static void lcl_ensureRange0to1( double& rValue )
{
if(rValue<0.0)
@@ -1581,21 +439,21 @@ static void lcl_ensureRange0to1( double& rValue )
rValue=1.0;
}
-bool DiagramHelper::setDiagramPositioning( const uno::Reference< frame::XModel >& xChartModel,
+bool DiagramHelper::setDiagramPositioning( const rtl::Reference<::chart::ChartModel>& xChartModel,
const awt::Rectangle& rPosRect /*100th mm*/ )
{
ControllerLockGuardUNO aCtrlLockGuard( xChartModel );
bool bChanged = false;
awt::Size aPageSize( ChartModelHelper::getPageSize(xChartModel) );
- uno::Reference< beans::XPropertySet > xDiaProps( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY );
- if( !xDiaProps.is() )
+ rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram();
+ if( !xDiagram.is() )
return bChanged;
RelativePosition aOldPos;
RelativeSize aOldSize;
- xDiaProps->getPropertyValue("RelativePosition" ) >>= aOldPos;
- xDiaProps->getPropertyValue("RelativeSize" ) >>= aOldSize;
+ xDiagram->getPropertyValue("RelativePosition" ) >>= aOldPos;
+ xDiagram->getPropertyValue("RelativeSize" ) >>= aOldSize;
RelativePosition aNewPos;
aNewPos.Anchor = drawing::Alignment_TOP_LEFT;
@@ -1615,8 +473,8 @@ bool DiagramHelper::setDiagramPositioning( const uno::Reference< frame::XModel >
if( (aNewPos.Secondary + aNewSize.Secondary) > 1.0 )
aNewPos.Secondary = 1.0 - aNewSize.Secondary;
- xDiaProps->setPropertyValue( "RelativePosition", uno::Any(aNewPos) );
- xDiaProps->setPropertyValue( "RelativeSize", uno::Any(aNewSize) );
+ xDiagram->setPropertyValue( "RelativePosition", uno::Any(aNewPos) );
+ xDiagram->setPropertyValue( "RelativeSize", uno::Any(aNewSize) );
bChanged = (aOldPos.Anchor!=aNewPos.Anchor) ||
(aOldPos.Primary!=aNewPos.Primary) ||
@@ -1626,20 +484,20 @@ bool DiagramHelper::setDiagramPositioning( const uno::Reference< frame::XModel >
return bChanged;
}
-awt::Rectangle DiagramHelper::getDiagramRectangleFromModel( const uno::Reference< frame::XModel >& xChartModel )
+awt::Rectangle DiagramHelper::getDiagramRectangleFromModel( const rtl::Reference<::chart::ChartModel>& xChartModel )
{
awt::Rectangle aRet(-1,-1,-1,-1);
- uno::Reference< beans::XPropertySet > xDiaProps( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY );
- if( !xDiaProps.is() )
+ rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram();
+ if( !xDiagram.is() )
return aRet;
awt::Size aPageSize( ChartModelHelper::getPageSize(xChartModel) );
RelativePosition aRelPos;
RelativeSize aRelSize;
- xDiaProps->getPropertyValue("RelativePosition" ) >>= aRelPos;
- xDiaProps->getPropertyValue("RelativeSize" ) >>= aRelSize;
+ xDiagram->getPropertyValue("RelativePosition" ) >>= aRelPos;
+ xDiagram->getPropertyValue("RelativeSize" ) >>= aRelSize;
awt::Size aAbsSize(
static_cast< sal_Int32 >( aRelSize.Primary * aPageSize.Width ),
@@ -1660,7 +518,7 @@ bool DiagramHelper::switchDiagramPositioningToExcludingPositioning(
ChartModel& rModel, bool bResetModifiedState, bool bConvertAlsoFromAutoPositioning )
{
//return true if something was changed
- const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion());
+ const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(GetODFSaneDefaultVersion());
if (SvtSaveOptions::ODFSVER_012 < nCurrentODFVersion)
{
uno::Reference< css::chart::XDiagramPositioning > xDiagramPositioning( rModel.getFirstDiagram(), uno::UNO_QUERY );
diff --git a/chart2/source/tools/ErrorBar.cxx b/chart2/source/tools/ErrorBar.cxx
index 91d6c003a067..3d049a44527f 100644
--- a/chart2/source/tools/ErrorBar.cxx
+++ b/chart2/source/tools/ErrorBar.cxx
@@ -33,7 +33,7 @@
#include <com/sun/star/util/Color.hpp>
#include <com/sun/star/drawing/LineJoint.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
using namespace ::com::sun::star;
@@ -41,7 +41,7 @@ using namespace ::com::sun::star;
namespace
{
-const char lcl_aServiceName[] = "com.sun.star.comp.chart2.ErrorBar";
+constexpr OUString lcl_aServiceName = u"com.sun.star.comp.chart2.ErrorBar"_ustr;
bool lcl_isInternalData( const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq )
{
@@ -53,22 +53,21 @@ const SfxItemPropertySet* GetErrorBarPropertySet()
{
static const SfxItemPropertyMapEntry aErrorBarPropertyMap_Impl[] =
{
- {u"ShowPositiveError",0,cppu::UnoType<bool>::get(), 0, 0},
- {u"ShowNegativeError",1,cppu::UnoType<bool>::get(), 0, 0},
- {u"PositiveError",2,cppu::UnoType<double>::get(),0,0},
- {u"NegativeError",3,cppu::UnoType<double>::get(), 0, 0},
- {u"PercentageError",4,cppu::UnoType<double>::get(), 0, 0},
- {u"ErrorBarStyle",5,cppu::UnoType<sal_Int32>::get(),0,0},
- {u"ErrorBarRangePositive",6,cppu::UnoType<OUString>::get(),0,0}, // read-only for export
- {u"ErrorBarRangeNegative",7,cppu::UnoType<OUString>::get(),0,0}, // read-only for export
- {u"Weight",8,cppu::UnoType<double>::get(),0,0},
- {u"LineStyle",9,cppu::UnoType<css::drawing::LineStyle>::get(),0,0},
- {u"LineDash",10,cppu::UnoType<drawing::LineDash>::get(),0,0},
- {u"LineWidth",11,cppu::UnoType<sal_Int32>::get(),0,0},
- {u"LineColor",12,cppu::UnoType<css::util::Color>::get(),0,0},
- {u"LineTransparence",13,cppu::UnoType<sal_Int16>::get(),0,0},
- {u"LineJoint",14,cppu::UnoType<css::drawing::LineJoint>::get(),0,0},
- { u"", 0, css::uno::Type(), 0, 0 }
+ {u"ShowPositiveError"_ustr,0,cppu::UnoType<bool>::get(), 0, 0},
+ {u"ShowNegativeError"_ustr,1,cppu::UnoType<bool>::get(), 0, 0},
+ {u"PositiveError"_ustr,2,cppu::UnoType<double>::get(),0,0},
+ {u"NegativeError"_ustr,3,cppu::UnoType<double>::get(), 0, 0},
+ {u"PercentageError"_ustr,4,cppu::UnoType<double>::get(), 0, 0},
+ {u"ErrorBarStyle"_ustr,5,cppu::UnoType<sal_Int32>::get(),0,0},
+ {u"ErrorBarRangePositive"_ustr,6,cppu::UnoType<OUString>::get(),0,0}, // read-only for export
+ {u"ErrorBarRangeNegative"_ustr,7,cppu::UnoType<OUString>::get(),0,0}, // read-only for export
+ {u"Weight"_ustr,8,cppu::UnoType<double>::get(),0,0},
+ {u"LineStyle"_ustr,9,cppu::UnoType<css::drawing::LineStyle>::get(),0,0},
+ {u"LineDash"_ustr,10,cppu::UnoType<drawing::LineDash>::get(),0,0},
+ {u"LineWidth"_ustr,11,cppu::UnoType<sal_Int32>::get(),0,0},
+ {u"LineColor"_ustr,12,cppu::UnoType<css::util::Color>::get(),0,0},
+ {u"LineTransparence"_ustr,13,cppu::UnoType<sal_Int16>::get(),0,0},
+ {u"LineJoint"_ustr,14,cppu::UnoType<css::drawing::LineJoint>::get(),0,0},
};
static SfxItemPropertySet aPropSet( aErrorBarPropertyMap_Impl );
return &aPropSet;
@@ -91,7 +90,7 @@ ErrorBar::ErrorBar() :
mfNegativeError(0),
mfWeight(1),
meStyle(css::chart::ErrorBarStyle::NONE),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
ErrorBar::ErrorBar( const ErrorBar & rOther ) :
@@ -109,7 +108,7 @@ ErrorBar::ErrorBar( const ErrorBar & rOther ) :
mfNegativeError(rOther.mfNegativeError),
mfWeight(rOther.mfWeight),
meStyle(rOther.meStyle),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
if( ! rOther.m_aDataSequences.empty())
{
@@ -363,9 +362,10 @@ beans::PropertyState ErrorBar::getPropertyState( const OUString& rPropName )
uno::Sequence< beans::PropertyState > ErrorBar::getPropertyStates( const uno::Sequence< OUString >& rPropNames )
{
uno::Sequence< beans::PropertyState > aRet( rPropNames.getLength() );
+ auto aRetRange = asNonConstRange(aRet);
for(sal_Int32 i = 0; i < rPropNames.getLength(); ++i)
{
- aRet[i] = getPropertyState(rPropNames[i]);
+ aRetRange[i] = getPropertyState(rPropNames[i]);
}
return aRet;
}
@@ -400,28 +400,12 @@ void ErrorBar::removeVetoableChangeListener( const OUString&, const css::uno::Re
// ____ XModifyBroadcaster ____
void SAL_CALL ErrorBar::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL ErrorBar::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx
index bf65f58ec850..7f6de91b6e82 100644
--- a/chart2/source/tools/ExplicitCategoriesProvider.cxx
+++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx
@@ -19,18 +19,25 @@
#include <ExplicitCategoriesProvider.hxx>
#include <DiagramHelper.hxx>
+#include <ChartType.hxx>
#include <ChartTypeHelper.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <DataSourceHelper.hxx>
#include <ChartModel.hxx>
#include <ChartModelHelper.hxx>
#include <NumberFormatterWrapper.hxx>
#include <unonames.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <DataSeries.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
+#include <o3tl/compare.hxx>
#include <o3tl/safeint.hxx>
-#include <rtl/math.hxx>
-#include <tools/diagnose_ex.h>
+#include <rtl/ustrbuf.hxx>
+#include <comphelper/diagnose_ex.hxx>
+
+#include <limits>
namespace chart
{
@@ -41,12 +48,11 @@ using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
using std::vector;
-ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2::XCoordinateSystem >& xCooSysModel
+ExplicitCategoriesProvider::ExplicitCategoriesProvider( const rtl::Reference< BaseCoordinateSystem >& xCooSysModel
, ChartModel& rModel )
: m_bDirty(true)
- , m_xCooSysModel( xCooSysModel )
+ , m_xCooSysModel( xCooSysModel.get() )
, mrModel(rModel)
- , m_xOriginalCategories()
, m_bIsExplicitCategoriesInited(false)
, m_bIsDateAxis(false)
, m_bIsAutoDate(false)
@@ -56,7 +62,7 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2:
if( xCooSysModel.is() )
{
// TODO: handle different category names on the primary and secondary category axis.
- uno::Reference< XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) );
+ rtl::Reference< Axis > xAxis = xCooSysModel->getAxisByDimension2(0,0);
if( xAxis.is() )
{
ScaleData aScale( xAxis->getScaleData() );
@@ -98,10 +104,10 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2:
//->split them in the direction of the first series
//detect whether the first series is a row or a column
bool bSeriesUsesColumns = true;
- std::vector< Reference< XDataSeries > > aSeries( ChartModelHelper::getDataSeries( mrModel ) );
+ std::vector< rtl::Reference< DataSeries > > aSeries = ChartModelHelper::getDataSeries( &mrModel );
if( !aSeries.empty() )
{
- uno::Reference< data::XDataSource > xSeriesSource( aSeries.front(), uno::UNO_QUERY );
+ rtl::Reference< DataSeries > xSeriesSource = aSeries.front();
OUString aStringDummy;
bool bDummy;
uno::Sequence< sal_Int32 > aSeqDummy;
@@ -109,16 +115,15 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2:
aStringDummy, aSeqDummy, bSeriesUsesColumns, bDummy, bDummy );
}
if( bSeriesUsesColumns )
- m_aSplitCategoriesList=aColumns;
+ m_aSplitCategoriesList = comphelper::sequenceToContainer<std::vector<Reference<data::XLabeledDataSequence>>>(aColumns);
else
- m_aSplitCategoriesList=aRows;
+ m_aSplitCategoriesList = comphelper::sequenceToContainer<std::vector<Reference<data::XLabeledDataSequence>>>(aRows);
}
}
}
- if( !m_aSplitCategoriesList.hasElements() )
+ if( m_aSplitCategoriesList.empty() )
{
- m_aSplitCategoriesList.realloc(1);
- m_aSplitCategoriesList[0]=m_xOriginalCategories;
+ m_aSplitCategoriesList = { m_xOriginalCategories };
}
}
}
@@ -141,12 +146,12 @@ Reference< chart2::data::XDataSequence > ExplicitCategoriesProvider::getOriginal
bool ExplicitCategoriesProvider::hasComplexCategories() const
{
- return m_aSplitCategoriesList.getLength() > 1;
+ return m_aSplitCategoriesList.size() > 1;
}
sal_Int32 ExplicitCategoriesProvider::getCategoryLevelCount() const
{
- sal_Int32 nCount = m_aSplitCategoriesList.getLength();
+ sal_Int32 nCount = m_aSplitCategoriesList.size();
if(!nCount)
nCount = 1;
return nCount;
@@ -170,14 +175,15 @@ void ExplicitCategoriesProvider::convertCategoryAnysToText( uno::Sequence< OUStr
if(!nCount)
return;
rOutTexts.realloc(nCount);
+ auto pOutTexts = rOutTexts.getArray();
sal_Int32 nAxisNumberFormat = 0;
- Reference< XCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( rModel ) );
+ rtl::Reference< BaseCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( &rModel ) );
if( xCooSysModel.is() )
{
- Reference< chart2::XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) );
+ rtl::Reference< Axis > xAxis = xCooSysModel->getAxisByDimension2(0,0);
nAxisNumberFormat = AxisHelper::getExplicitNumberFormatKeyForAxis(
- xAxis, xCooSysModel, uno::Reference<chart2::XChartDocument>(static_cast< ::cppu::OWeakObject* >(&rModel), uno::UNO_QUERY), false );
+ xAxis, xCooSysModel, &rModel, false );
}
Color nLabelColor;
@@ -203,7 +209,7 @@ void ExplicitCategoriesProvider::convertCategoryAnysToText( uno::Sequence< OUStr
aAny>>=aText;
}
}
- rOutTexts[nN] = aText;
+ pOutTexts[nN] = aText;
}
}
@@ -218,8 +224,7 @@ class SplitCategoriesProvider_ForLabeledDataSequences : public SplitCategoriesPr
public:
explicit SplitCategoriesProvider_ForLabeledDataSequences(
- const css::uno::Sequence<
- css::uno::Reference< css::chart2::data::XLabeledDataSequence> >& rSplitCategoriesList
+ const std::vector< Reference< data::XLabeledDataSequence> >& rSplitCategoriesList
, ChartModel& rModel )
: m_rSplitCategoriesList( rSplitCategoriesList )
, mrModel( rModel )
@@ -229,8 +234,7 @@ public:
virtual uno::Sequence< OUString > getStringsForLevel( sal_Int32 nIndex ) const override;
private:
- const css::uno::Sequence< css::uno::Reference<
- css::chart2::data::XLabeledDataSequence> >& m_rSplitCategoriesList;
+ const std::vector< Reference< data::XLabeledDataSequence> >& m_rSplitCategoriesList;
ChartModel& mrModel;
};
@@ -239,7 +243,7 @@ private:
sal_Int32 SplitCategoriesProvider_ForLabeledDataSequences::getLevelCount() const
{
- return m_rSplitCategoriesList.getLength();
+ return m_rSplitCategoriesList.size();
}
uno::Sequence< OUString > SplitCategoriesProvider_ForLabeledDataSequences::getStringsForLevel( sal_Int32 nLevel ) const
{
@@ -358,6 +362,7 @@ static Sequence< OUString > lcl_getExplicitSimpleCategories(
if(nMaxCategoryCount)
{
aRet.realloc(nMaxCategoryCount);
+ auto pRet = aRet.getArray();
for(sal_Int32 nN=0; nN<nMaxCategoryCount; nN++)
{
OUStringBuffer aText;
@@ -374,7 +379,7 @@ static Sequence< OUString > lcl_getExplicitSimpleCategories(
}
}
}
- aRet[nN]=aText.makeStringAndClear();
+ pRet[nN]=aText.makeStringAndClear();
}
}
return aRet;
@@ -402,13 +407,13 @@ static bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >&
bool bOwnData = false;
bool bOwnDataAnddAxisHasAnyFormat = false;
bool bOwnDataAnddAxisHasDateFormat = false;
- Reference< XCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( rModel ) );
+ rtl::Reference< BaseCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( &rModel ) );
if( xCooSysModel.is() )
{
if( rModel.hasInternalDataProvider() )
{
bOwnData = true;
- Reference< beans::XPropertySet > xAxisProps( xCooSysModel->getAxisByDimension(0,0), uno::UNO_QUERY );
+ rtl::Reference< Axis > xAxisProps = xCooSysModel->getAxisByDimension2(0,0);
sal_Int32 nAxisNumberFormat = 0;
if (xAxisProps.is() && (xAxisProps->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nAxisNumberFormat))
{
@@ -453,11 +458,12 @@ static bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >&
{
if( aAny.hasValue() && !bContainsEmptyString )//empty string does not count as non date value!
bOnlyDatesFound=false;
- ::rtl::math::setNan( &aDate );
- rDateCategories.push_back( aDate );
+ rDateCategories.push_back( std::numeric_limits<double>::quiet_NaN() );
}
}
- std::sort( rDateCategories.begin(), rDateCategories.end() );
+ std::sort(
+ rDateCategories.begin(), rDateCategories.end(),
+ [](auto x, auto y) { return o3tl::strong_order(x, y) < 0; } );
}
return bAnyDataFound && bOnlyDatesFound;
@@ -477,7 +483,7 @@ void ExplicitCategoriesProvider::init()
{
if(m_bIsDateAxis)
{
- if( ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ), 0 ) )
+ if( ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( m_xCooSysModel.get(), 0 ), 0 ) )
m_bIsDateAxis = lcl_fillDateCategories( m_xOriginalCategories->getValues(), m_aDateCategories, m_bIsAutoDate, mrModel );
else
m_bIsDateAxis = false;
@@ -514,7 +520,7 @@ Sequence< OUString > const & ExplicitCategoriesProvider::getSimpleCategories()
}
}
if(!m_aExplicitCategories.hasElements())
- m_aExplicitCategories = DiagramHelper::generateAutomaticCategoriesFromCooSys( m_xCooSysModel );
+ m_aExplicitCategories = DiagramHelper::generateAutomaticCategoriesFromCooSys( m_xCooSysModel.get() );
m_bIsExplicitCategoriesInited = true;
}
return m_aExplicitCategories;
@@ -530,7 +536,7 @@ const std::vector<ComplexCategory>* ExplicitCategoriesProvider::getCategoriesByL
}
OUString ExplicitCategoriesProvider::getCategoryByIndex(
- const Reference< XCoordinateSystem >& xCooSysModel
+ const rtl::Reference< BaseCoordinateSystem >& xCooSysModel
, ChartModel& rModel
, sal_Int32 nIndex )
{
diff --git a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx
index 1aa962ab5e3e..9c41822d3618 100644
--- a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx
@@ -19,6 +19,7 @@
#include <sal/config.h>
+#include <limits>
#include <string_view>
#include <ExponentialRegressionCurveCalculator.hxx>
@@ -34,12 +35,10 @@ namespace chart
{
ExponentialRegressionCurveCalculator::ExponentialRegressionCurveCalculator()
- : m_fLogSlope(0.0)
- , m_fLogIntercept(0.0)
+ : m_fLogSlope(std::numeric_limits<double>::quiet_NaN())
+ , m_fLogIntercept(std::numeric_limits<double>::quiet_NaN())
, m_fSign(1.0)
{
- ::rtl::math::setNan( & m_fLogSlope );
- ::rtl::math::setNan( & m_fLogIntercept );
}
ExponentialRegressionCurveCalculator::~ExponentialRegressionCurveCalculator()
@@ -65,9 +64,9 @@ void SAL_CALL ExponentialRegressionCurveCalculator::recalculateRegression(
nMax = aValues.first.size();
if( nMax <= 1 )
{
- ::rtl::math::setNan( & m_fLogSlope );
- ::rtl::math::setNan( & m_fLogIntercept );
- ::rtl::math::setNan( & m_fCorrelationCoefficient );// actual it is coefficient of determination
+ m_fLogSlope = std::numeric_limits<double>::quiet_NaN();
+ m_fLogIntercept = std::numeric_limits<double>::quiet_NaN();
+ m_fCorrelationCoefficient = std::numeric_limits<double>::quiet_NaN();// actual it is coefficient of determination
return;
}
m_fSign = -1.0;
@@ -116,16 +115,13 @@ void SAL_CALL ExponentialRegressionCurveCalculator::recalculateRegression(
double SAL_CALL ExponentialRegressionCurveCalculator::getCurveValue( double x )
{
- double fResult;
- ::rtl::math::setNan( & fResult );
-
if( ! ( std::isnan( m_fLogSlope ) ||
std::isnan( m_fLogIntercept )))
{
- fResult = m_fSign * exp(m_fLogIntercept + x * m_fLogSlope);
+ return m_fSign * exp(m_fLogIntercept + x * m_fLogSlope);
}
- return fResult;
+ return std::numeric_limits<double>::quiet_NaN();
}
uno::Sequence< geometry::RealPoint2D > SAL_CALL ExponentialRegressionCurveCalculator::getCurveValues(
@@ -139,11 +135,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL ExponentialRegressionCurveCalcul
isLogarithmicScaling( xScalingY ))
{
// optimize result
- uno::Sequence< geometry::RealPoint2D > aResult( 2 );
- aResult[0].X = min;
- aResult[0].Y = getCurveValue( min );
- aResult[1].X = max;
- aResult[1].Y = getCurveValue( max );
+ uno::Sequence< geometry::RealPoint2D > aResult{ { min, getCurveValue( min ) },
+ { max, getCurveValue( max ) } };
return aResult;
}
@@ -183,13 +176,13 @@ OUString ExponentialRegressionCurveCalculator::ImplGetRepresentation(
// if nValueLength not calculated then nullptr
sal_Int32* pValueLength = nValueLength ? &nValueLength : nullptr;
if ( m_fSign < 0.0 )
- aTmpBuf.append( OUStringChar(aMinusSign) ).append( " " );
+ aTmpBuf.append( OUStringChar(aMinusSign) + " " );
if ( bHasIntercept )
{
OUString aValueString = getFormattedString( xNumFormatter, nNumberFormatKey, fIntercept, pValueLength );
if ( aValueString != "1" ) // aValueString may be rounded to 1 if nValueLength is small
{
- aTmpBuf.append( aValueString ).append( " " );
+ aTmpBuf.append( aValueString + " " );
addStringToEquation( aBuf, nLineLength, aTmpBuf, pFormulaMaxWidth );
aTmpBuf.truncate();
}
@@ -208,16 +201,16 @@ OUString ExponentialRegressionCurveCalculator::ImplGetRepresentation(
}
}
if ( m_fLogSlope < 0.0 )
- aTmpBuf.append( OUStringChar(aMinusSign) ).append( " " );
+ aTmpBuf.append( OUStringChar(aMinusSign) + " " );
if ( bHasLogSlope )
{
OUString aValueString = getFormattedString( xNumFormatter, nNumberFormatKey, fabs(m_fLogSlope), pValueLength );
if ( aValueString != "1" ) // aValueString may be rounded to 1 if nValueLength is small
{
- aTmpBuf.append( aValueString ).append( " " );
+ aTmpBuf.append( aValueString + " " );
}
}
- aTmpBuf.append( mXName ).append(" )");
+ aTmpBuf.append( mXName + " )");
addStringToEquation( aBuf, nLineLength, aTmpBuf, pFormulaMaxWidth );
return aBuf.makeStringAndClear();
diff --git a/chart2/source/tools/FillProperties.cxx b/chart2/source/tools/FillProperties.cxx
index d0c888d748f2..ba3b63c83db1 100644
--- a/chart2/source/tools/FillProperties.cxx
+++ b/chart2/source/tools/FillProperties.cxx
@@ -23,6 +23,8 @@
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/RectanglePoint.hpp>
+#include <tools/color.hxx>
+
using namespace ::com::sun::star;
using ::com::sun::star::beans::Property;
@@ -158,23 +160,23 @@ void lcl_AddDefaultsToMap_without_BitmapProperties(
::chart::tPropertyValueMap & rOutMap )
{
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_STYLE, drawing::FillStyle_SOLID );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_COLOR, 0xd9d9d9 ); // gray85
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_TRANSPARENCE, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_COLOR, Color(0xd9, 0xd9, 0xd9) ); // gray85
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_TRANSPARENCE, sal_Int16(0) );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BACKGROUND, false );
}
void lcl_AddDefaultsToMap_only_BitmapProperties(
::chart::tPropertyValueMap & rOutMap )
{
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETX, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETY, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETX, sal_Int16(0) );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETY, sal_Int16(0) );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX, sal_Int16(0) );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY, sal_Int16(0) );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_RECTANGLEPOINT, drawing::RectanglePoint_MIDDLE_MIDDLE );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_LOGICALSIZE, true );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEX, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEY, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEX, sal_Int32(0) );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEY, sal_Int32(0) );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_MODE, drawing::BitmapMode_REPEAT );
}
diff --git a/chart2/source/tools/FormattedStringHelper.cxx b/chart2/source/tools/FormattedStringHelper.cxx
index ff885494d231..6b881160670f 100644
--- a/chart2/source/tools/FormattedStringHelper.cxx
+++ b/chart2/source/tools/FormattedStringHelper.cxx
@@ -18,8 +18,8 @@
*/
#include <FormattedStringHelper.hxx>
-#include <com/sun/star/chart2/FormattedString.hpp>
-#include <tools/diagnose_ex.h>
+#include <FormattedString.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <comphelper/property.hxx>
namespace chart
@@ -28,34 +28,29 @@ namespace chart
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-Sequence< Reference< chart2::XFormattedString2 > >
- FormattedStringHelper::createFormattedStringSequence(
- const Reference< uno::XComponentContext > & xContext
- , const OUString & rString
- , const Reference< beans::XPropertySet > & xTextProperties ) throw()
+rtl::Reference< ::chart::FormattedString >
+ FormattedStringHelper::createFormattedString(
+ const OUString & rString
+ , const Reference< beans::XPropertySet > & xTextProperties ) noexcept
{
- Reference< XFormattedString2 > xFormStr;
+ rtl::Reference< FormattedString > xFormStr;
try
{
- if( xContext.is() )
- {
- xFormStr = chart2::FormattedString::create(xContext);
+ xFormStr = new FormattedString();
- xFormStr->setString( rString );
+ xFormStr->setString( rString );
- // set character properties
- comphelper::copyProperties(
- xTextProperties, Reference< beans::XPropertySet >( xFormStr, uno::UNO_QUERY_THROW ) );
- }
+ // set character properties
+ comphelper::copyProperties(
+ xTextProperties, Reference< beans::XPropertySet >( static_cast<cppu::OWeakObject*>(xFormStr.get()), uno::UNO_QUERY_THROW ) );
}
catch( const uno::Exception & )
{
DBG_UNHANDLED_EXCEPTION("chart2");
}
- return Sequence< Reference< XFormattedString2 > >( & xFormStr, 1 );
+ return xFormStr;
}
} //namespace chart
diff --git a/chart2/source/tools/ImplOPropertySet.cxx b/chart2/source/tools/ImplOPropertySet.cxx
deleted file mode 100644
index 537adef9d94d..000000000000
--- a/chart2/source/tools/ImplOPropertySet.cxx
+++ /dev/null
@@ -1,176 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "ImplOPropertySet.hxx"
-#include <CloneHelper.hxx>
-
-#include <algorithm>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/style/XStyle.hpp>
-
-using namespace ::com::sun::star;
-
-using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Any;
-
-namespace
-{
-
-struct lcl_getPropertyStateByHandle
-{
- explicit lcl_getPropertyStateByHandle(
- const ::property::impl::ImplOPropertySet::tPropertyMap & rMap )
- : m_rMap( rMap )
- {}
-
- beans::PropertyState operator() ( sal_Int32 nHandle )
- {
- if( m_rMap.end() == m_rMap.find( nHandle ))
- return beans::PropertyState_DEFAULT_VALUE;
- return beans::PropertyState_DIRECT_VALUE;
- }
-
-private:
- const ::property::impl::ImplOPropertySet::tPropertyMap & m_rMap;
-};
-
-template< typename K, typename V >
-struct lcl_eraseMapEntry
-{
- explicit lcl_eraseMapEntry( std::map< K, V > & rMap )
- : m_rMap( rMap )
- {}
-
- void operator() ( const K & aKey )
- {
- m_rMap.erase( aKey );
- }
-
-private:
- std::map< K, V > m_rMap;
-};
-
-struct lcl_replaceInterfacePropertiesByClones
-{
- void operator() ( ::property::impl::ImplOPropertySet::tPropertyMap::value_type & rProp )
- {
- if( rProp.second.hasValue() &&
- rProp.second.getValueType().getTypeClass() == uno::TypeClass_INTERFACE )
- {
- Reference< util::XCloneable > xCloneable;
- if( rProp.second >>= xCloneable )
- rProp.second <<= xCloneable->createClone();
- }
- }
-};
-
-} // anonymous namespace
-
-namespace property::impl
-{
-
-ImplOPropertySet::ImplOPropertySet()
-{}
-
-ImplOPropertySet::ImplOPropertySet( const ImplOPropertySet & rOther )
-{
- m_aProperties = rOther.m_aProperties;
-
- // clone interface properties
- std::for_each( m_aProperties.begin(), m_aProperties.end(),
- lcl_replaceInterfacePropertiesByClones());
-
- m_xStyle.set( ::chart::CloneHelper::CreateRefClone< style::XStyle >()( rOther.m_xStyle ));
-}
-
-beans::PropertyState ImplOPropertySet::GetPropertyStateByHandle( sal_Int32 nHandle ) const
-{
- return lcl_getPropertyStateByHandle( m_aProperties ) ( nHandle );
-}
-
-Sequence< beans::PropertyState > ImplOPropertySet::GetPropertyStatesByHandle(
- const std::vector< sal_Int32 > & aHandles ) const
-{
- Sequence< beans::PropertyState > aResult( aHandles.size());
-
- std::transform( aHandles.begin(), aHandles.end(),
- aResult.getArray(),
- lcl_getPropertyStateByHandle( m_aProperties ));
-
- return aResult;
-}
-
-void ImplOPropertySet::SetPropertyToDefault( sal_Int32 nHandle )
-{
- tPropertyMap::iterator aFoundIter( m_aProperties.find( nHandle ) );
-
- if( m_aProperties.end() != aFoundIter )
- {
- m_aProperties.erase( aFoundIter );
- }
-}
-
-void ImplOPropertySet::SetPropertiesToDefault(
- const std::vector< sal_Int32 > & aHandles )
-{
- std::for_each( aHandles.begin(), aHandles.end(),
- lcl_eraseMapEntry< sal_Int32, Any >( m_aProperties ) );
-}
-
-void ImplOPropertySet::SetAllPropertiesToDefault()
-{
- m_aProperties.clear();
-}
-
-bool ImplOPropertySet::GetPropertyValueByHandle(
- Any & rValue,
- sal_Int32 nHandle ) const
-{
- bool bResult = false;
-
- tPropertyMap::const_iterator aFoundIter( m_aProperties.find( nHandle ) );
-
- if( m_aProperties.end() != aFoundIter )
- {
- rValue = (*aFoundIter).second;
- bResult = true;
- }
-
- return bResult;
-}
-
-void ImplOPropertySet::SetPropertyValueByHandle(
- sal_Int32 nHandle, const Any & rValue )
-{
- m_aProperties[ nHandle ] = rValue;
-}
-
-bool ImplOPropertySet::SetStyle( const Reference< style::XStyle > & xStyle )
-{
- if( ! xStyle.is())
- return false;
-
- m_xStyle = xStyle;
- return true;
-}
-
-} // namespace property::impl
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/tools/ImplOPropertySet.hxx b/chart2/source/tools/ImplOPropertySet.hxx
deleted file mode 100644
index 5a6bc54aa429..000000000000
--- a/chart2/source/tools/ImplOPropertySet.hxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#pragma once
-
-#include <com/sun/star/beans/PropertyState.hpp>
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/uno/Any.hxx>
-
-#include <map>
-#include <vector>
-
-namespace com::sun::star::style { class XStyle; }
-
-namespace property::impl
-{
-
-class ImplOPropertySet
-{
-public:
- ImplOPropertySet();
- explicit ImplOPropertySet( const ImplOPropertySet & rOther );
-
- /** supports states DIRECT_VALUE and DEFAULT_VALUE
- */
- css::beans::PropertyState
- GetPropertyStateByHandle( sal_Int32 nHandle ) const;
-
- css::uno::Sequence< css::beans::PropertyState >
- GetPropertyStatesByHandle( const std::vector< sal_Int32 > & aHandles ) const;
-
- void SetPropertyToDefault( sal_Int32 nHandle );
- void SetPropertiesToDefault( const std::vector< sal_Int32 > & aHandles );
- void SetAllPropertiesToDefault();
-
- /** @param rValue is set to the value for the property given in nHandle. If
- the property is not set, the style chain is searched for any
- instance set there. If there was no value found either in the
- property set itself or any of its styles, rValue remains
- unchanged and false is returned.
-
- @return false if the property is default, true otherwise.
- */
- bool GetPropertyValueByHandle(
- css::uno::Any & rValue,
- sal_Int32 nHandle ) const;
-
- void SetPropertyValueByHandle( sal_Int32 nHandle,
- const css::uno::Any & rValue );
-
- bool SetStyle( const css::uno::Reference< css::style::XStyle > & xStyle );
- const css::uno::Reference< css::style::XStyle >&
- GetStyle() const { return m_xStyle;}
-
- typedef
- std::map< sal_Int32, css::uno::Any >
- tPropertyMap;
-
-private:
- tPropertyMap m_aProperties;
- css::uno::Reference< css::style::XStyle >
- m_xStyle;
-};
-
-} // namespace chart::impl
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx
index 91a9fbaa16fa..e6e926078eb3 100644
--- a/chart2/source/tools/InternalData.cxx
+++ b/chart2/source/tools/InternalData.cxx
@@ -21,8 +21,10 @@
#include <ResId.hxx>
#include <strings.hrc>
+#include <comphelper/sequence.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
-#include <rtl/math.hxx>
+
#ifdef DEBUG_CHART2_TOOLS
#define DEBUG_INTERNAL_DATA 1
#endif
@@ -33,11 +35,11 @@
#include <algorithm>
#include <iterator>
+#include <limits>
using ::com::sun::star::uno::Sequence;
using namespace ::com::sun::star;
-using namespace ::std;
namespace chart
{
@@ -46,18 +48,16 @@ namespace
{
struct lcl_NumberedStringGenerator
{
- lcl_NumberedStringGenerator( const OUString & rStub, const OUString & rWildcard ) :
+ lcl_NumberedStringGenerator( const OUString & rStub, std::u16string_view rWildcard ) :
m_aStub( rStub ),
m_nCounter( 0 ),
m_nStubStartIndex( rStub.indexOf( rWildcard )),
- m_nWildcardLength( rWildcard.getLength())
+ m_nWildcardLength( rWildcard.size())
{
}
- vector< uno::Any > operator()()
+ std::vector< uno::Any > operator()()
{
- vector< uno::Any > aRet(1);
- aRet[0] <<= m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::number( ++m_nCounter ));
- return aRet;
+ return { uno::Any(m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::number( ++m_nCounter ))) };
}
private:
OUString m_aStub;
@@ -69,11 +69,13 @@ private:
template< typename T >
Sequence< T > lcl_ValarrayToSequence( const std::valarray< T > & rValarray )
{
- // is there a more elegant way of conversion?
- Sequence< T > aResult( rValarray.size());
- for( size_t i = 0; i < rValarray.size(); ++i )
- aResult[i] = rValarray[i];
- return aResult;
+#if defined __GLIBCXX__ && (!defined _GLIBCXX_RELEASE || _GLIBCXX_RELEASE < 12)
+ // workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103022
+ if (!size(rValarray))
+ return Sequence<T>();
+#endif
+
+ return comphelper::containerToSequence(rValarray);
}
} // anonymous namespace
@@ -111,12 +113,12 @@ void InternalData::createDefaultData()
m_aRowLabels.clear();
m_aRowLabels.reserve( m_nRowCount );
generate_n( back_inserter( m_aRowLabels ), m_nRowCount,
- lcl_NumberedStringGenerator( aRowName, "%ROWNUMBER" ));
+ lcl_NumberedStringGenerator( aRowName, u"%ROWNUMBER" ));
m_aColumnLabels.clear();
m_aColumnLabels.reserve( m_nColumnCount );
generate_n( back_inserter( m_aColumnLabels ), m_nColumnCount,
- lcl_NumberedStringGenerator( aColName, "%COLUMNNUMBER" ));
+ lcl_NumberedStringGenerator( aColName, u"%COLUMNNUMBER" ));
}
void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows )
@@ -130,10 +132,8 @@ void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows )
m_aColumnLabels.resize( m_nColumnCount );
m_aData.resize( m_nRowCount * m_nColumnCount );
- double fNan;
- ::rtl::math::setNan( & fNan );
// set all values to Nan
- m_aData = fNan;
+ m_aData = std::numeric_limits<double>::quiet_NaN();
for( sal_Int32 nRow=0; nRow<m_nRowCount; ++nRow )
{
@@ -150,9 +150,10 @@ void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows )
Sequence< Sequence< double > > InternalData::getData() const
{
Sequence< Sequence< double > > aResult( m_nRowCount );
+ auto aResultRange = asNonConstRange(aResult);
for( sal_Int32 i=0; i<m_nRowCount; ++i )
- aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >(
+ aResultRange[i] = lcl_ValarrayToSequence< tDataType::value_type >(
m_aData[ std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
return aResult;
@@ -173,49 +174,49 @@ Sequence< double > InternalData::getRowValues( sal_Int32 nRowIndex ) const
return Sequence< double >();
}
-void InternalData::setColumnValues( sal_Int32 nColumnIndex, const vector< double > & rNewData )
+void InternalData::setColumnValues( sal_Int32 nColumnIndex, const std::vector< double > & rNewData )
{
if( nColumnIndex < 0 )
return;
enlargeData( nColumnIndex + 1, rNewData.size() );
tDataType aSlice = m_aData[ std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ];
- for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
+ for( std::vector< double >::size_type i = 0; i < rNewData.size(); ++i )
aSlice[i] = rNewData[i];
m_aData[ std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ] = aSlice;
}
-void InternalData::setRowValues( sal_Int32 nRowIndex, const vector< double > & rNewData )
+void InternalData::setRowValues( sal_Int32 nRowIndex, const std::vector< double > & rNewData )
{
if( nRowIndex < 0 )
return;
enlargeData( rNewData.size(), nRowIndex+1 );
tDataType aSlice = m_aData[ std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ];
- for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
+ for( std::vector< double >::size_type i = 0; i < rNewData.size(); ++i )
aSlice[i] = rNewData[i];
m_aData[ std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ]= aSlice;
}
-void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< uno::Any >& rComplexLabel )
+void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, std::vector< uno::Any >&& rComplexLabel )
{
if( nColumnIndex < 0 )
return;
- if( nColumnIndex >= static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
+ if( o3tl::make_unsigned(nColumnIndex) >= m_aColumnLabels.size() )
{
m_aColumnLabels.resize(nColumnIndex+1);
enlargeData( nColumnIndex+1, 0 );
}
- m_aColumnLabels[nColumnIndex]=rComplexLabel;
+ m_aColumnLabels[nColumnIndex] = std::move(rComplexLabel);
dump();
}
-void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< uno::Any >& rComplexLabel )
+void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, std::vector< uno::Any >&& rComplexLabel )
{
if( nRowIndex < 0 )
return;
- if( nRowIndex >= static_cast< sal_Int32 >( m_aRowLabels.size() ) )
+ if( o3tl::make_unsigned(nRowIndex) >= m_aRowLabels.size() )
{
m_aRowLabels.resize(nRowIndex+1);
enlargeData( 0, nRowIndex+1 );
@@ -228,23 +229,23 @@ void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< uno::A
}
else
{
- m_aRowLabels[nRowIndex] = rComplexLabel;
+ m_aRowLabels[nRowIndex] = std::move(rComplexLabel);
}
}
-vector< uno::Any > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const
+std::vector< uno::Any > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const
{
if( nColumnIndex < static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
return m_aColumnLabels[nColumnIndex];
else
- return vector< uno::Any >();
+ return std::vector< uno::Any >();
}
-vector< uno::Any > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const
+std::vector< uno::Any > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const
{
if( nRowIndex < static_cast< sal_Int32 >( m_aRowLabels.size() ) )
return m_aRowLabels[nRowIndex];
else
- return vector< uno::Any >();
+ return std::vector< uno::Any >();
}
void InternalData::swapRowWithNext( sal_Int32 nRowIndex )
@@ -257,14 +258,10 @@ void InternalData::swapRowWithNext( sal_Int32 nRowIndex )
{
size_t nIndex1 = nColIdx + nRowIndex*m_nColumnCount;
size_t nIndex2 = nIndex1 + m_nColumnCount;
- double fTemp = m_aData[nIndex1];
- m_aData[nIndex1] = m_aData[nIndex2];
- m_aData[nIndex2] = fTemp;
+ std::swap(m_aData[nIndex1], m_aData[nIndex2]);
}
- vector< uno::Any > aTemp( m_aRowLabels[nRowIndex] );
- m_aRowLabels[nRowIndex] = m_aRowLabels[nRowIndex + 1];
- m_aRowLabels[nRowIndex + 1] = aTemp;
+ std::swap(m_aRowLabels[nRowIndex], m_aRowLabels[nRowIndex + 1]);
}
void InternalData::swapColumnWithNext( sal_Int32 nColumnIndex )
@@ -277,14 +274,10 @@ void InternalData::swapColumnWithNext( sal_Int32 nColumnIndex )
{
size_t nIndex1 = nColumnIndex + nRowIdx*m_nColumnCount;
size_t nIndex2 = nIndex1 + 1;
- double fTemp = m_aData[nIndex1];
- m_aData[nIndex1] = m_aData[nIndex2];
- m_aData[nIndex2] = fTemp;
+ std::swap(m_aData[nIndex1], m_aData[nIndex2]);
}
- vector< uno::Any > aTemp( m_aColumnLabels[nColumnIndex] );
- m_aColumnLabels[nColumnIndex] = m_aColumnLabels[nColumnIndex + 1];
- m_aColumnLabels[nColumnIndex + 1] = aTemp;
+ std::swap(m_aColumnLabels[nColumnIndex], m_aColumnLabels[nColumnIndex + 1]);
}
bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount )
@@ -297,9 +290,7 @@ bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount )
if( bGrow )
{
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
+ tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize );
// copy old data
for( int nCol=0; nCol<m_nColumnCount; ++nCol )
static_cast< tDataType >(
@@ -323,9 +314,7 @@ void InternalData::insertColumn( sal_Int32 nAfterIndex )
sal_Int32 nNewColumnCount = m_nColumnCount + 1;
sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
+ tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize );
// copy old data
int nCol=0;
@@ -344,7 +333,7 @@ void InternalData::insertColumn( sal_Int32 nAfterIndex )
// labels
if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
- m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), vector< uno::Any >(1) );
+ m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), std::vector< uno::Any >(1) );
dump();
}
@@ -380,9 +369,7 @@ void InternalData::insertRow( sal_Int32 nAfterIndex )
sal_Int32 nNewRowCount = m_nRowCount + 1;
sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
+ tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize );
// copy old data
sal_Int32 nIndex = nAfterIndex + 1;
@@ -404,7 +391,7 @@ void InternalData::insertRow( sal_Int32 nAfterIndex )
// labels
if( nAfterIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
- m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, vector< uno::Any > (1));
+ m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, std::vector< uno::Any > (1));
dump();
}
@@ -417,9 +404,7 @@ void InternalData::deleteColumn( sal_Int32 nAtIndex )
sal_Int32 nNewColumnCount = m_nColumnCount - 1;
sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
+ tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize );
// copy old data
int nCol=0;
@@ -451,9 +436,7 @@ void InternalData::deleteRow( sal_Int32 nAtIndex )
sal_Int32 nNewRowCount = m_nRowCount - 1;
sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
+ tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize );
// copy old data
sal_Int32 nIndex = nAtIndex;
@@ -481,9 +464,9 @@ void InternalData::deleteRow( sal_Int32 nAtIndex )
dump();
}
-void InternalData::setComplexRowLabels( const tVecVecAny& rNewRowLabels )
+void InternalData::setComplexRowLabels( tVecVecAny&& rNewRowLabels )
{
- m_aRowLabels = rNewRowLabels;
+ m_aRowLabels = std::move(rNewRowLabels);
sal_Int32 nNewRowCount = static_cast< sal_Int32 >( m_aRowLabels.size() );
if( nNewRowCount < m_nRowCount )
m_aRowLabels.resize( m_nRowCount );
@@ -496,9 +479,9 @@ const InternalData::tVecVecAny& InternalData::getComplexRowLabels() const
return m_aRowLabels;
}
-void InternalData::setComplexColumnLabels( const tVecVecAny& rNewColumnLabels )
+void InternalData::setComplexColumnLabels( tVecVecAny&& rNewColumnLabels )
{
- m_aColumnLabels = rNewColumnLabels;
+ m_aColumnLabels = std::move(rNewColumnLabels);
sal_Int32 nNewColumnCount = static_cast< sal_Int32 >( m_aColumnLabels.size() );
if( nNewColumnCount < m_nColumnCount )
m_aColumnLabels.resize( m_nColumnCount );
@@ -517,22 +500,22 @@ void InternalData::dump() const
// Header
if (!m_aColumnLabels.empty())
{
- svl::GridPrinter aPrinter(1, m_aColumnLabels.size(), true);
+ svl::GridPrinter aPrinter(m_aColumnLabels[0].size(), m_aColumnLabels.size(), true);
for (size_t nCol = 0; nCol < m_aColumnLabels.size(); ++nCol)
{
- if (m_aColumnLabels[nCol].empty())
- continue;
-
- OUString aStr;
- if (m_aColumnLabels[nCol][0] >>= aStr)
- aPrinter.set(0, nCol, aStr);
+ for (size_t nRow = 0; nRow < m_aColumnLabels[nCol].size(); ++nRow)
+ {
+ OUString aStr;
+ if (m_aColumnLabels[nCol].at(nRow) >>= aStr)
+ aPrinter.set(nRow, nCol, aStr);
+ }
}
aPrinter.print("Header");
}
if (!m_aRowLabels.empty())
{
- svl::GridPrinter aPrinter(m_aRowLabels.size(), m_aRowLabels[0].size());
+ svl::GridPrinter aPrinter(m_aRowLabels.size(), m_aRowLabels[0].size(), true);
for (size_t nRow = 0; nRow < m_aRowLabels.size(); ++nRow)
{
for (size_t nCol = 0; nCol < m_aRowLabels[nRow].size(); ++nCol)
@@ -545,7 +528,7 @@ void InternalData::dump() const
aPrinter.print("Row labels");
}
- svl::GridPrinter aPrinter(m_nRowCount, m_nColumnCount);
+ svl::GridPrinter aPrinter(m_nRowCount, m_nColumnCount, true);
for (sal_Int32 nRow = 0; nRow < m_nRowCount; ++nRow)
{
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx
index 94481ce9e5f8..7e76708d596b 100644
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <rtl/math.hxx>
-
+#include <cstddef>
#include <iterator>
#include <InternalDataProvider.hxx>
@@ -30,23 +29,26 @@
#include <DataSourceHelper.hxx>
#include <ChartModel.hxx>
#include <ChartModelHelper.hxx>
-#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
#include <ExplicitCategoriesProvider.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <DataSeries.hxx>
#include <com/sun/star/chart2/data/XDataSequence.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/property.hxx>
-#include <tools/diagnose_ex.h>
+#include <o3tl/string_view.hxx>
+#include <comphelper/diagnose_ex.hxx>
+#include <limits>
#include <vector>
#include <algorithm>
namespace com::sun::star::chart2 { class XChartDocument; }
using namespace ::com::sun::star;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -57,12 +59,12 @@ namespace chart
namespace
{
-const char lcl_aCategoriesRangeName[] = "categories";
+constexpr OUString lcl_aCategoriesRangeName = u"categories"_ustr;
const char lcl_aCategoriesLevelRangeNamePrefix[] = "categoriesL "; //L <-> level
const char lcl_aCategoriesPointRangeNamePrefix[] = "categoriesP "; //P <-> point
-const char lcl_aCategoriesRoleName[] = "categories";
+constexpr OUString lcl_aCategoriesRoleName = u"categories"_ustr;
const char lcl_aLabelRangePrefix[] = "label ";
-const char lcl_aCompleteRange[] = "all";
+constexpr OUString lcl_aCompleteRange = u"all"_ustr;
typedef std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > >
lcl_tSequenceMap;
@@ -112,16 +114,11 @@ struct lcl_internalizeSeries
m_bConnectToModel( bConnectToModel ),
m_bDataInColumns( bDataInColumns )
{}
- void operator() ( const Reference< chart2::XDataSeries > & xSeries )
+ void operator() ( const rtl::Reference< DataSeries > & xSeries )
{
- Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
- Reference< chart2::data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
- if( !(xSource.is() && xSink.is()) )
- return;
-
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeriesData = xSource->getDataSequences();
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeriesData( aOldSeriesData.getLength() );
- for( sal_Int32 i=0; i<aOldSeriesData.getLength(); ++i )
+ const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aOldSeriesData = xSeries->getDataSequences2();
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewSeriesData( aOldSeriesData.size() );
+ for( std::size_t i=0; i<aOldSeriesData.size(); ++i )
{
sal_Int32 nNewIndex( m_bDataInColumns ? m_rInternalData.appendColumn() : m_rInternalData.appendRow() );
OUString aIdentifier( OUString::number( nNewIndex ));
@@ -169,7 +166,7 @@ struct lcl_internalizeSeries
}
}
if( m_bConnectToModel )
- xSink->setData( aNewSeriesData );
+ xSeries->setData( aNewSeriesData );
}
private:
@@ -186,7 +183,7 @@ public:
explicit lcl_copyFromLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
{}
- uno::Any operator() ( const vector< uno::Any >& rVector )
+ uno::Any operator() ( const std::vector< uno::Any >& rVector )
{
uno::Any aRet;
if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) )
@@ -205,7 +202,7 @@ public:
explicit lcl_getStringFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel )
{}
- OUString operator() ( const vector< uno::Any >& rVector )
+ OUString operator() ( const std::vector< uno::Any >& rVector )
{
OUString aString;
if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) )
@@ -224,9 +221,9 @@ public:
explicit lcl_setAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
{}
- vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const uno::Any& rNewValue )
+ std::vector< uno::Any > operator() ( const std::vector< uno::Any >& rVector, const uno::Any& rNewValue )
{
- vector< uno::Any > aRet( rVector );
+ std::vector< uno::Any > aRet( rVector );
if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) )
aRet.resize( m_nLevel+1 );
aRet[ m_nLevel ]=rNewValue;
@@ -244,9 +241,9 @@ public:
explicit lcl_setAnyAtLevelFromStringSequence( sal_Int32 nLevel ) : m_nLevel( nLevel )
{}
- vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const OUString& rNewValue )
+ std::vector< uno::Any > operator() ( const std::vector< uno::Any >& rVector, const OUString& rNewValue )
{
- vector< uno::Any > aRet( rVector );
+ std::vector< uno::Any > aRet( rVector );
if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) )
aRet.resize( m_nLevel+1 );
aRet[ m_nLevel ] <<= rNewValue;
@@ -264,7 +261,7 @@ public:
explicit lcl_insertAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
{}
- void operator() ( vector< uno::Any >& rVector )
+ void operator() ( std::vector< uno::Any >& rVector )
{
if( m_nLevel >= static_cast< sal_Int32 >(rVector.size()) )
{
@@ -287,7 +284,7 @@ public:
explicit lcl_removeAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
{}
- void operator() ( vector< uno::Any >& rVector )
+ void operator() ( std::vector< uno::Any >& rVector )
{
if( m_nLevel < static_cast<sal_Int32>(rVector.size()) )
{
@@ -306,18 +303,18 @@ InternalDataProvider::InternalDataProvider()
{}
InternalDataProvider::InternalDataProvider(
- const Reference< chart2::XChartDocument > & xChartDoc,
+ const rtl::Reference< ChartModel > & xModel,
bool bConnectToModel,
bool bDefaultDataInColumns)
: m_bDataInColumns( bDefaultDataInColumns )
{
+ if (!xModel.is())
+ return;
try
{
- Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartDoc ) );
+ rtl::Reference< Diagram > xDiagram( xModel->getFirstChartDiagram() );
if( xDiagram.is())
{
- Reference< frame::XModel > xChartModel = xChartDoc;
-
//data in columns?
{
OUString aRangeString;
@@ -326,7 +323,7 @@ InternalDataProvider::InternalDataProvider(
uno::Sequence< sal_Int32 > aSequenceMapping;
const bool bSomethingDetected(
DataSourceHelper::detectRangeSegmentation(
- xChartModel, aRangeString, aSequenceMapping, m_bDataInColumns, bFirstCellAsLabel, bHasCategories ));
+ xModel, aRangeString, aSequenceMapping, m_bDataInColumns, bFirstCellAsLabel, bHasCategories ));
// #i120559# if no data was available, restore default
if(!bSomethingDetected && m_bDataInColumns != bDefaultDataInColumns)
@@ -337,13 +334,12 @@ InternalDataProvider::InternalDataProvider(
// categories
{
- vector< vector< uno::Any > > aNewCategories;//inner count is level
+ std::vector< std::vector< uno::Any > > aNewCategories;//inner count is level
{
- ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartModel);
- ExplicitCategoriesProvider aExplicitCategoriesProvider(ChartModelHelper::getFirstCoordinateSystem(xChartModel), rModel);
+ ExplicitCategoriesProvider aExplicitCategoriesProvider(ChartModelHelper::getFirstCoordinateSystem(xModel), *xModel);
- const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() );
- sal_Int32 nLevelCount = rSplitCategoriesList.getLength();
+ const std::vector< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() );
+ sal_Int32 nLevelCount = rSplitCategoriesList.size();
for( sal_Int32 nL = 0; nL<nLevelCount; nL++ )
{
Reference< chart2::data::XLabeledDataSequence > xLDS( rSplitCategoriesList[nL] );
@@ -369,24 +365,24 @@ InternalDataProvider::InternalDataProvider(
aNewCategories.reserve( nLength );
for( sal_Int32 nN=0; nN<nLength; nN++)
{
- vector< uno::Any > aVector(1);
- aVector[0] <<= aSimplecategories[nN];
- aNewCategories.push_back( aVector );
+ aNewCategories.push_back( { uno::Any(aSimplecategories[nN]) } );
}
}
}
if( m_bDataInColumns )
- m_aInternalData.setComplexRowLabels( aNewCategories );
+ m_aInternalData.setComplexRowLabels( std::move(aNewCategories) );
else
- m_aInternalData.setComplexColumnLabels( aNewCategories );
+ m_aInternalData.setComplexColumnLabels( std::move(aNewCategories) );
if( bConnectToModel )
- DiagramHelper::setCategoriesToDiagram( new LabeledDataSequence(
- createDataSequenceByRangeRepresentation( lcl_aCategoriesRangeName )), xDiagram );
+ xDiagram->setCategories(
+ new LabeledDataSequence(
+ createDataSequenceByRangeRepresentation( lcl_aCategoriesRangeName ))
+ );
}
// data series
- std::vector< Reference< chart2::XDataSeries > > aSeriesVector( ChartModelHelper::getDataSeries( xChartDoc ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVector( ChartModelHelper::getDataSeries( xModel ));
lcl_internalizeSeries ftor( m_aInternalData, *this, bConnectToModel, m_bDataInColumns );
for( const auto& rxScreen : aSeriesVector )
ftor( rxScreen );
@@ -483,29 +479,29 @@ void InternalDataProvider::decreaseMapReferences(
}
}
-Reference< chart2::data::XDataSequence > InternalDataProvider::createDataSequenceAndAddToMap(
+rtl::Reference< UncachedDataSequence > InternalDataProvider::createDataSequenceAndAddToMap(
const OUString & rRangeRepresentation )
{
- Reference<chart2::data::XDataSequence> xSeq = createDataSequenceFromArray(rRangeRepresentation, u"");
+ rtl::Reference<UncachedDataSequence> xSeq = createDataSequenceFromArray(rRangeRepresentation, u"", u"");
if (xSeq.is())
- return xSeq;
+ return nullptr;
xSeq.set(new UncachedDataSequence(this, rRangeRepresentation));
addDataSequenceToMap(rRangeRepresentation, xSeq);
return xSeq;
}
-uno::Reference<chart2::data::XDataSequence>
-InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, std::u16string_view rRole )
+rtl::Reference<UncachedDataSequence>
+InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, std::u16string_view rRole, std::u16string_view rRoleQualifier )
{
if (rArrayStr.indexOf('{') != 0 || rArrayStr[rArrayStr.getLength()-1] != '}')
{
// Not an array string.
- return uno::Reference<chart2::data::XDataSequence>();
+ return nullptr;
}
bool bAllNumeric = true;
- uno::Reference<chart2::data::XDataSequence> xSeq;
+ rtl::Reference<UncachedDataSequence> xSeq;
const sal_Unicode* p = rArrayStr.getStr();
const sal_Unicode* pEnd = p + rArrayStr.getLength();
@@ -518,7 +514,14 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, st
bool bInQuote = false;
for (; p != pEnd; ++p)
{
- if (*p == '"')
+ // Skip next "" within the title text: it's an escaped double quotation mark.
+ if (bInQuote && *p == '"' && *(p + 1) == '"')
+ {
+ if (!pElem)
+ pElem = p;
+ ++p;
+ }
+ else if (*p == '"')
{
bInQuote = !bInQuote;
if (bInQuote)
@@ -534,7 +537,8 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, st
// Non empty string
if (!aElem.isEmpty())
bAllNumeric = false;
- aRawElems.push_back(aElem);
+ // Restore also escaped double quotation marks
+ aRawElems.push_back(aElem.replaceAll("\"\"", "\""));
pElem = nullptr;
aElem.clear();
@@ -563,7 +567,8 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, st
}
if (rRole == u"values-y" || rRole == u"values-first" || rRole == u"values-last" ||
- rRole == u"values-min" || rRole == u"values-max" || rRole == u"values-size")
+ rRole == u"values-min" || rRole == u"values-max" || rRole == u"values-size" ||
+ rRole == u"error-bars-y-positive" || rRole == u"error-bars-y-negative")
{
// Column values. Append a new data column and populate it.
@@ -615,10 +620,20 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, st
{
// Category labels.
+ // Store date categories as numbers.
+ bool bStoreNumeric = rRoleQualifier == u"date";
+ double fValue;
for (size_t i = 0; i < aRawElems.size(); ++i)
{
- std::vector<uno::Any> aLabels(1, uno::Any(aRawElems[i]));
- m_aInternalData.setComplexRowLabel(i, aLabels);
+ if (bStoreNumeric)
+ {
+ bool bGetDouble = bAllNumeric && !aRawElems[i].isEmpty();
+ fValue = bGetDouble ? aRawElems[i].toDouble() :
+ std::numeric_limits<double>::quiet_NaN();
+ }
+ std::vector<uno::Any> aLabels(1,
+ bStoreNumeric ? uno::Any(fValue) : uno::Any(aRawElems[i]));
+ m_aInternalData.setComplexRowLabel(i, std::move(aLabels));
}
xSeq.set(new UncachedDataSequence(this, lcl_aCategoriesRangeName));
@@ -631,8 +646,12 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, st
sal_Int32 nColSize = m_aInternalData.getColumnCount();
if (!aRawElems.empty() && nColSize)
{
- std::vector<uno::Any> aLabels(1, uno::Any(aRawElems[0]));
- m_aInternalData.setComplexColumnLabel(nColSize-1, aLabels);
+ // Do not overwrite an existing label (attempted by series with no data values)
+ if (!m_aInternalData.getComplexColumnLabel(nColSize-1)[0].hasValue())
+ {
+ std::vector<uno::Any> aLabels(1, uno::Any(aRawElems[0]));
+ m_aInternalData.setComplexColumnLabel(nColSize-1, std::move(aLabels));
+ }
OUString aRangeRep = lcl_aLabelRangePrefix + OUString::number(nColSize-1);
xSeq.set(new UncachedDataSequence(this, aRangeRep));
@@ -647,8 +666,8 @@ Reference< chart2::data::XDataSequence > InternalDataProvider::createDataSequenc
const OUString & rRangeRepresentation,
const OUString & rRole )
{
- Reference< chart2::data::XDataSequence > xSeq(
- new UncachedDataSequence( this, rRangeRepresentation, rRole ));
+ rtl::Reference< UncachedDataSequence > xSeq =
+ new UncachedDataSequence( this, rRangeRepresentation, rRole );
addDataSequenceToMap( rRangeRepresentation, xSeq );
return xSeq;
}
@@ -662,7 +681,7 @@ sal_Bool SAL_CALL InternalDataProvider::createDataSourcePossible( const Sequence
namespace
{
-sal_Int32 lcl_getInnerLevelCount( const vector< vector< uno::Any > >& rLabels )
+sal_Int32 lcl_getInnerLevelCount( const std::vector< std::vector< uno::Any > >& rLabels )
{
sal_Int32 nCount = 1;//minimum is 1!
for (auto const& elemLabel : rLabels)
@@ -688,7 +707,7 @@ Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createData
{
//return split complex categories if we have any:
std::vector< Reference< chart2::data::XLabeledDataSequence > > aComplexCategories;
- vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
+ const std::vector< std::vector< uno::Any > > & aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
if( bUseColumns==m_bDataInColumns )
{
sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories );
@@ -765,22 +784,22 @@ Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createData
Sequence< beans::PropertyValue > SAL_CALL InternalDataProvider::detectArguments(
const Reference< chart2::data::XDataSource >& /* xDataSource */ )
{
- Sequence< beans::PropertyValue > aArguments( 4 );
- aArguments[0] = beans::PropertyValue(
- "CellRangeRepresentation", -1, uno::Any( OUString(lcl_aCompleteRange) ),
- beans::PropertyState_DIRECT_VALUE );
- aArguments[1] = beans::PropertyValue(
- "DataRowSource", -1, uno::Any(
- m_bDataInColumns
- ? css::chart::ChartDataRowSource_COLUMNS
- : css::chart::ChartDataRowSource_ROWS ),
- beans::PropertyState_DIRECT_VALUE );
- // internal data always contains labels and categories
- aArguments[2] = beans::PropertyValue(
- "FirstCellAsLabel", -1, uno::Any( true ), beans::PropertyState_DIRECT_VALUE );
- aArguments[3] = beans::PropertyValue(
- "HasCategories", -1, uno::Any( true ), beans::PropertyState_DIRECT_VALUE );
-
+ Sequence< beans::PropertyValue > aArguments{
+ beans::PropertyValue(
+ "CellRangeRepresentation", -1, uno::Any( lcl_aCompleteRange ),
+ beans::PropertyState_DIRECT_VALUE ),
+ beans::PropertyValue(
+ "DataRowSource", -1, uno::Any(
+ m_bDataInColumns
+ ? css::chart::ChartDataRowSource_COLUMNS
+ : css::chart::ChartDataRowSource_ROWS ),
+ beans::PropertyState_DIRECT_VALUE ),
+ // internal data always contains labels and categories
+ beans::PropertyValue(
+ "FirstCellAsLabel", -1, uno::Any( true ), beans::PropertyState_DIRECT_VALUE ),
+ beans::PropertyValue(
+ "HasCategories", -1, uno::Any( true ), beans::PropertyState_DIRECT_VALUE )
+ };
// #i85913# Sequence Mapping is not needed for internal data, as it is
// applied to the data when the data source is created.
@@ -805,7 +824,7 @@ Reference< chart2::data::XDataSequence > SAL_CALL InternalDataProvider::createDa
else if( aRangeRepresentation.match( lcl_aLabelRangePrefix ))
{
// label
- sal_Int32 nIndex = aRangeRepresentation.copy( strlen(lcl_aLabelRangePrefix)).toInt32();
+ sal_Int32 nIndex = o3tl::toInt32(aRangeRepresentation.subView( strlen(lcl_aLabelRangePrefix)));
return createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::number( nIndex ));
}
else if ( aRangeRepresentation == "last" )
@@ -826,9 +845,9 @@ Reference< chart2::data::XDataSequence > SAL_CALL InternalDataProvider::createDa
Reference<chart2::data::XDataSequence> SAL_CALL
InternalDataProvider::createDataSequenceByValueArray(
- const OUString& aRole, const OUString& aRangeRepresentation )
+ const OUString& aRole, const OUString& aRangeRepresentation, const OUString& aRoleQualifier )
{
- return createDataSequenceFromArray(aRangeRepresentation, aRole);
+ return createDataSequenceFromArray(aRangeRepresentation, aRole, aRoleQualifier);
}
Reference< sheet::XRangeSelection > SAL_CALL InternalDataProvider::getRangeSelection()
@@ -849,7 +868,7 @@ sal_Bool SAL_CALL InternalDataProvider::hasDataByRangeRepresentation( const OUSt
}
else if( aRange.match( lcl_aLabelRangePrefix ))
{
- sal_Int32 nIndex = aRange.copy( strlen(lcl_aLabelRangePrefix)).toInt32();
+ sal_Int32 nIndex = o3tl::toInt32(aRange.subView( strlen(lcl_aLabelRangePrefix)));
bResult = (nIndex < (m_bDataInColumns ? m_aInternalData.getColumnCount(): m_aInternalData.getRowCount()));
}
else
@@ -867,8 +886,8 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation
if( aRange.match( lcl_aLabelRangePrefix ) )
{
- auto nIndex = aRange.copy( strlen(lcl_aLabelRangePrefix)).toUInt32();
- vector< uno::Any > aComplexLabel = m_bDataInColumns
+ auto nIndex = o3tl::toUInt32(aRange.subView( strlen(lcl_aLabelRangePrefix)));
+ std::vector< uno::Any > aComplexLabel = m_bDataInColumns
? m_aInternalData.getComplexColumnLabel( nIndex )
: m_aInternalData.getComplexRowLabel( nIndex );
if( !aComplexLabel.empty() )
@@ -876,8 +895,8 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation
}
else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) )
{
- auto nPointIndex = aRange.copy( strlen(lcl_aCategoriesPointRangeNamePrefix) ).toUInt32();
- vector< uno::Any > aComplexCategory = m_bDataInColumns
+ auto nPointIndex = o3tl::toUInt32(aRange.subView( strlen(lcl_aCategoriesPointRangeNamePrefix) ));
+ std::vector< uno::Any > aComplexCategory = m_bDataInColumns
? m_aInternalData.getComplexRowLabel( nPointIndex )
: m_aInternalData.getComplexColumnLabel( nPointIndex );
if( !aComplexCategory.empty() )
@@ -885,8 +904,8 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation
}
else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) )
{
- sal_Int32 nLevel = aRange.copy( strlen(lcl_aCategoriesLevelRangeNamePrefix) ).toInt32();
- vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
+ sal_Int32 nLevel = o3tl::toInt32(aRange.subView( strlen(lcl_aCategoriesLevelRangeNamePrefix) ));
+ const std::vector< std::vector< uno::Any > > & aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
if( nLevel < lcl_getInnerLevelCount( aCategories ) )
{
aResult.realloc( aCategories.size() );
@@ -896,7 +915,7 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation
}
else if( aRange == lcl_aCategoriesRangeName )
{
- vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
+ const std::vector< std::vector< uno::Any > > & aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories );
if( nLevelCount == 1 )
{
@@ -905,9 +924,9 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation
else
{
// Maybe this 'else' part and the functions is not necessary anymore.
- Sequence< OUString > aLabels = m_bDataInColumns ? getRowDescriptions() : getColumnDescriptions();
+ const Sequence< OUString > aLabels = m_bDataInColumns ? getRowDescriptions() : getColumnDescriptions();
aResult.realloc( aLabels.getLength() );
- transform( aLabels.begin(), aLabels.end(),
+ std::transform( aLabels.begin(), aLabels.end(),
aResult.getArray(), CommonFunctors::makeAny< OUString >() );
}
}
@@ -916,15 +935,13 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation
sal_Int32 nIndex = aRange.toInt32();
if( nIndex >= 0 )
{
- Sequence< double > aData;
- if( m_bDataInColumns )
- aData = m_aInternalData.getColumnValues(nIndex);
- else
- aData = m_aInternalData.getRowValues(nIndex);
+ const Sequence< double > aData = m_bDataInColumns
+ ? m_aInternalData.getColumnValues(nIndex)
+ : m_aInternalData.getRowValues(nIndex);
if( aData.hasElements() )
{
aResult.realloc( aData.getLength());
- transform( aData.begin(), aData.end(),
+ std::transform( aData.begin(), aData.end(),
aResult.getArray(), CommonFunctors::makeAny< double >());
}
}
@@ -936,27 +953,27 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation
void SAL_CALL InternalDataProvider::setDataByRangeRepresentation(
const OUString& aRange, const Sequence< uno::Any >& aNewData )
{
- auto aNewVector( comphelper::sequenceToContainer<vector< uno::Any >>(aNewData) );
+ auto aNewVector( comphelper::sequenceToContainer<std::vector< uno::Any >>(aNewData) );
if( aRange.match( lcl_aLabelRangePrefix ) )
{
- sal_uInt32 nIndex = aRange.copy( strlen(lcl_aLabelRangePrefix)).toInt32();
+ sal_uInt32 nIndex = o3tl::toInt32(aRange.subView( strlen(lcl_aLabelRangePrefix)));
if( m_bDataInColumns )
- m_aInternalData.setComplexColumnLabel( nIndex, aNewVector );
+ m_aInternalData.setComplexColumnLabel( nIndex, std::move(aNewVector) );
else
- m_aInternalData.setComplexRowLabel( nIndex, aNewVector );
+ m_aInternalData.setComplexRowLabel( nIndex, std::move(aNewVector) );
}
else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) )
{
- sal_Int32 nPointIndex = aRange.copy( strlen(lcl_aCategoriesLevelRangeNamePrefix)).toInt32();
+ sal_Int32 nPointIndex = o3tl::toInt32(aRange.subView( strlen(lcl_aCategoriesLevelRangeNamePrefix)));
if( m_bDataInColumns )
- m_aInternalData.setComplexRowLabel( nPointIndex, aNewVector );
+ m_aInternalData.setComplexRowLabel( nPointIndex, std::move(aNewVector) );
else
- m_aInternalData.setComplexColumnLabel( nPointIndex, aNewVector );
+ m_aInternalData.setComplexColumnLabel( nPointIndex, std::move(aNewVector) );
}
else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) )
{
- sal_Int32 nLevel = aRange.copy( strlen(lcl_aCategoriesLevelRangeNamePrefix)).toInt32();
- vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
+ sal_Int32 nLevel = o3tl::toInt32(aRange.subView( strlen(lcl_aCategoriesLevelRangeNamePrefix)));
+ std::vector< std::vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
//ensure equal length
if( aNewVector.size() > aComplexCategories.size() )
@@ -968,27 +985,27 @@ void SAL_CALL InternalDataProvider::setDataByRangeRepresentation(
aComplexCategories.begin(), lcl_setAnyAtLevel(nLevel) );
if( m_bDataInColumns )
- m_aInternalData.setComplexRowLabels( aComplexCategories );
+ m_aInternalData.setComplexRowLabels( std::move(aComplexCategories) );
else
- m_aInternalData.setComplexColumnLabels( aComplexCategories );
+ m_aInternalData.setComplexColumnLabels( std::move(aComplexCategories) );
}
else if( aRange == lcl_aCategoriesRangeName )
{
- vector< vector< uno::Any > > aComplexCategories;
+ std::vector< std::vector< uno::Any > > aComplexCategories;
aComplexCategories.resize( aNewVector.size() );
transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(),
aComplexCategories.begin(), lcl_setAnyAtLevel(0) );
if( m_bDataInColumns )
- m_aInternalData.setComplexRowLabels( aComplexCategories );
+ m_aInternalData.setComplexRowLabels( std::move(aComplexCategories) );
else
- m_aInternalData.setComplexColumnLabels( aComplexCategories );
+ m_aInternalData.setComplexColumnLabels( std::move(aComplexCategories) );
}
else
{
sal_Int32 nIndex = aRange.toInt32();
if( nIndex>=0 )
{
- vector< double > aNewDataVec;
+ std::vector< double > aNewDataVec;
transform( aNewData.begin(), aNewData.end(),
back_inserter( aNewDataVec ), CommonFunctors::AnyToDouble());
if( m_bDataInColumns )
@@ -1042,12 +1059,12 @@ void SAL_CALL InternalDataProvider::insertComplexCategoryLevel( sal_Int32 nLevel
OSL_ENSURE( nLevel> 0, "you can only insert category levels > 0" );//the first categories level cannot be deleted, check the calling code for error
if( nLevel>0 )
{
- vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
+ std::vector< std::vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertAnyAtLevel(nLevel) );
if( m_bDataInColumns )
- m_aInternalData.setComplexRowLabels( aComplexCategories );
+ m_aInternalData.setComplexRowLabels( std::move(aComplexCategories) );
else
- m_aInternalData.setComplexColumnLabels( aComplexCategories );
+ m_aInternalData.setComplexColumnLabels( std::move(aComplexCategories) );
tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
std::for_each( aRange.first, aRange.second, lcl_setModified());
@@ -1058,12 +1075,12 @@ void SAL_CALL InternalDataProvider::deleteComplexCategoryLevel( sal_Int32 nLevel
OSL_ENSURE( nLevel>0, "you can only delete category levels > 0" );//the first categories level cannot be deleted, check the calling code for error
if( nLevel>0 )
{
- vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
+ std::vector< std::vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeAnyAtLevel(nLevel) );
if( m_bDataInColumns )
- m_aInternalData.setComplexRowLabels( aComplexCategories );
+ m_aInternalData.setComplexRowLabels( std::move(aComplexCategories) );
else
- m_aInternalData.setComplexColumnLabels( aComplexCategories );
+ m_aInternalData.setComplexColumnLabels( std::move(aComplexCategories) );
tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
std::for_each( aRange.first, aRange.second, lcl_setModified());
@@ -1172,7 +1189,7 @@ OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRang
}
else if( aRangeRepresentation.match( lcl_aLabelRangePrefix ))
{
- sal_Int32 nIndex = aRangeRepresentation.copy( strlen(lcl_aLabelRangePrefix)).toInt32();
+ sal_Int32 nIndex = o3tl::toInt32(aRangeRepresentation.subView( strlen(lcl_aLabelRangePrefix)));
aRange.aUpperLeft.bIsEmpty = false;
aRange.aLowerRight.bIsEmpty = true;
if( m_bDataInColumns )
@@ -1220,7 +1237,14 @@ OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRang
OUString SAL_CALL InternalDataProvider::convertRangeFromXML( const OUString& aXMLRange )
{
- const OUString aPivotTableID("PT@");
+ // Handle non-standards-conforming table:cell-range-address="PivotChart", see
+ // <https://bugs.documentfoundation.org/show_bug.cgi?id=112783> "PIVOT CHARTS: Save produces
+ // invalid file because of invalid cell address":
+ if (aXMLRange == "PivotChart") {
+ return "";
+ }
+
+ static constexpr OUString aPivotTableID(u"PT@"_ustr);
if (aXMLRange.startsWith(aPivotTableID))
return aXMLRange.copy(aPivotTableID.getLength());
@@ -1266,34 +1290,35 @@ namespace
{
template< class Type >
-Sequence< Sequence< Type > > lcl_convertVectorVectorToSequenceSequence( const vector< vector< Type > >& rIn )
+Sequence< Sequence< Type > > lcl_convertVectorVectorToSequenceSequence( const std::vector< std::vector< Type > >& rIn )
{
Sequence< Sequence< Type > > aRet;
sal_Int32 nOuterCount = rIn.size();
if( nOuterCount )
{
aRet.realloc(nOuterCount);
+ auto pRet = aRet.getArray();
for( sal_Int32 nN=0; nN<nOuterCount; nN++)
- aRet[nN]= comphelper::containerToSequence( rIn[nN] );
+ pRet[nN]= comphelper::containerToSequence( rIn[nN] );
}
return aRet;
}
template< class Type >
-vector< vector< Type > > lcl_convertSequenceSequenceToVectorVector( const Sequence< Sequence< Type > >& rIn )
+std::vector< std::vector< Type > > lcl_convertSequenceSequenceToVectorVector( const Sequence< Sequence< Type > >& rIn )
{
- vector< vector< Type > > aRet;
+ std::vector< std::vector< Type > > aRet;
sal_Int32 nOuterCount = rIn.getLength();
if( nOuterCount )
{
aRet.resize(nOuterCount);
for( sal_Int32 nN=0; nN<nOuterCount; nN++)
- aRet[nN]= comphelper::sequenceToContainer<vector< Type >>( rIn[nN] );
+ aRet[nN]= comphelper::sequenceToContainer<std::vector< Type >>( rIn[nN] );
}
return aRet;
}
-std::vector< Sequence< OUString > > lcl_convertComplexAnyVectorToStringSequence( const vector< vector< uno::Any > >& rIn )
+std::vector< Sequence< OUString > > lcl_convertComplexAnyVectorToStringSequence( const std::vector< std::vector< uno::Any > >& rIn )
{
std::vector< Sequence< OUString > > aRet;
sal_Int32 nOuterCount = rIn.size();
@@ -1306,9 +1331,9 @@ std::vector< Sequence< OUString > > lcl_convertComplexAnyVectorToStringSequence(
return aRet;
}
-vector< vector< uno::Any > > lcl_convertComplexStringSequenceToAnyVector( const Sequence< Sequence< OUString > >& rIn )
+std::vector< std::vector< uno::Any > > lcl_convertComplexStringSequenceToAnyVector( const Sequence< Sequence< OUString > >& rIn )
{
- vector< vector< uno::Any > > aRet;
+ std::vector< std::vector< uno::Any > > aRet;
sal_Int32 nOuterCount = rIn.getLength();
aRet.reserve(nOuterCount);
for (sal_Int32 nN = 0; nN < nOuterCount; nN++)
@@ -1352,17 +1377,17 @@ uno::Sequence< OUString > SplitCategoriesProvider_ForComplexDescriptions::getStr
// ____ XDateCategories ____
Sequence< double > SAL_CALL InternalDataProvider::getDateCategories()
{
- double fNan = InternalDataProvider::getNotANumber();
- double fValue = fNan;
- vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
+ const std::vector< std::vector< uno::Any > > & aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
sal_Int32 nCount = aCategories.size();
Sequence< double > aDoubles( nCount );
+ auto aDoublesRange = asNonConstRange(aDoubles);
sal_Int32 nN=0;
for (auto const& category : aCategories)
{
+ double fValue;
if( category.empty() || !(category[0]>>=fValue) )
- fValue = fNan;
- aDoubles[nN++]=fValue;
+ fValue = std::numeric_limits<double>::quiet_NaN();
+ aDoublesRange[nN++]=fValue;
}
return aDoubles;
}
@@ -1370,9 +1395,9 @@ Sequence< double > SAL_CALL InternalDataProvider::getDateCategories()
void SAL_CALL InternalDataProvider::setDateCategories( const Sequence< double >& rDates )
{
sal_Int32 nCount = rDates.getLength();
- vector< vector< uno::Any > > aNewCategories;
+ std::vector< std::vector< uno::Any > > aNewCategories;
aNewCategories.reserve(nCount);
- vector< uno::Any > aSingleLabel(1);
+ std::vector< uno::Any > aSingleLabel(1);
for(sal_Int32 nN=0; nN<nCount; ++nN )
{
@@ -1381,9 +1406,9 @@ void SAL_CALL InternalDataProvider::setDateCategories( const Sequence< double >&
}
if( m_bDataInColumns )
- m_aInternalData.setComplexRowLabels( aNewCategories );
+ m_aInternalData.setComplexRowLabels( std::move(aNewCategories) );
else
- m_aInternalData.setComplexColumnLabels( aNewCategories );
+ m_aInternalData.setComplexColumnLabels( std::move(aNewCategories) );
}
// ____ XAnyDescriptionAccess ____
@@ -1435,30 +1460,30 @@ void SAL_CALL InternalDataProvider::setData( const Sequence< Sequence< double >
void SAL_CALL InternalDataProvider::setRowDescriptions( const Sequence< OUString >& aRowDescriptions )
{
- vector< vector< uno::Any > > aComplexDescriptions( aRowDescriptions.getLength() );
+ std::vector< std::vector< uno::Any > > aComplexDescriptions( aRowDescriptions.getLength() );
transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aRowDescriptions.getConstArray(),
aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) );
- m_aInternalData.setComplexRowLabels( aComplexDescriptions );
+ m_aInternalData.setComplexRowLabels( std::move(aComplexDescriptions) );
}
void SAL_CALL InternalDataProvider::setColumnDescriptions( const Sequence< OUString >& aColumnDescriptions )
{
- vector< vector< uno::Any > > aComplexDescriptions( aColumnDescriptions.getLength() );
+ std::vector< std::vector< uno::Any > > aComplexDescriptions( aColumnDescriptions.getLength() );
transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aColumnDescriptions.getConstArray(),
aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) );
- m_aInternalData.setComplexColumnLabels( aComplexDescriptions );
+ m_aInternalData.setComplexColumnLabels( std::move(aComplexDescriptions) );
}
Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions()
{
- vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexRowLabels() );
+ const std::vector< std::vector< uno::Any > > & aComplexLabels( m_aInternalData.getComplexRowLabels() );
SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels );
return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider );
}
Sequence< OUString > SAL_CALL InternalDataProvider::getColumnDescriptions()
{
- vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexColumnLabels() );
+ const std::vector< std::vector< uno::Any > > & aComplexLabels( m_aInternalData.getComplexColumnLabels() );
SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels );
return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider );
}
@@ -1476,9 +1501,7 @@ void SAL_CALL InternalDataProvider::removeChartDataChangeEventListener(
double SAL_CALL InternalDataProvider::getNotANumber()
{
- double fNan;
- ::rtl::math::setNan( & fNan );
- return fNan;
+ return std::numeric_limits<double>::quiet_NaN();
}
sal_Bool SAL_CALL InternalDataProvider::isNotANumber( double nNumber )
diff --git a/chart2/source/tools/LabeledDataSequence.cxx b/chart2/source/tools/LabeledDataSequence.cxx
index c3a896b22ff6..bf7b13443d1d 100644
--- a/chart2/source/tools/LabeledDataSequence.cxx
+++ b/chart2/source/tools/LabeledDataSequence.cxx
@@ -20,7 +20,7 @@
#include <LabeledDataSequence.hxx>
#include <ModifyListenerHelper.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <utility>
namespace com::sun::star::uno { class XComponentContext; }
@@ -33,28 +33,50 @@ namespace chart
{
LabeledDataSequence::LabeledDataSequence() :
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
LabeledDataSequence::LabeledDataSequence(
- const uno::Reference< chart2::data::XDataSequence > & rValues ) :
- m_xData( rValues ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ uno::Reference< chart2::data::XDataSequence > xValues ) :
+ m_xData(std::move( xValues )),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
}
LabeledDataSequence::LabeledDataSequence(
- const uno::Reference< chart2::data::XDataSequence > & rValues,
- const uno::Reference< chart2::data::XDataSequence > & rLabel ) :
- m_xData( rValues ),
- m_xLabel( rLabel ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ uno::Reference< chart2::data::XDataSequence > xValues,
+ uno::Reference< chart2::data::XDataSequence > xLabel ) :
+ m_xData(std::move( xValues )),
+ m_xLabel(std::move( xLabel )),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
}
+LabeledDataSequence::LabeledDataSequence( const LabeledDataSequence& rSource ) :
+ impl::LabeledDataSequence_Base(),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
+{
+ uno::Reference< chart2::data::XDataSequence > xNewValues( rSource.m_xData );
+ uno::Reference< chart2::data::XDataSequence > xNewLabel( rSource.m_xLabel );
+
+ uno::Reference< util::XCloneable > xLabelCloneable( rSource.m_xLabel, uno::UNO_QUERY );
+ if( xLabelCloneable.is())
+ xNewLabel.set( xLabelCloneable->createClone(), uno::UNO_QUERY );
+
+ uno::Reference< util::XCloneable > xValuesCloneable( rSource.m_xData, uno::UNO_QUERY );
+ if( xValuesCloneable.is())
+ xNewValues.set( xValuesCloneable->createClone(), uno::UNO_QUERY );
+
+ m_xData = xNewValues;
+ m_xLabel = xNewLabel;
+
+ ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
+ ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
+}
+
LabeledDataSequence::~LabeledDataSequence()
{
if( m_xModifyEventForwarder.is())
@@ -120,28 +142,12 @@ uno::Reference< util::XCloneable > SAL_CALL LabeledDataSequence::createClone()
// ____ XModifyBroadcaster ____
void SAL_CALL LabeledDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL LabeledDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
OUString SAL_CALL LabeledDataSequence::getImplementationName()
diff --git a/chart2/source/tools/LegendHelper.cxx b/chart2/source/tools/LegendHelper.cxx
index 6fbd6bf63143..2c52f136398d 100644
--- a/chart2/source/tools/LegendHelper.cxx
+++ b/chart2/source/tools/LegendHelper.cxx
@@ -18,12 +18,14 @@
*/
#include <LegendHelper.hxx>
+#include <Legend.hxx>
#include <ChartModel.hxx>
+#include <Diagram.hxx>
#include <com/sun/star/chart/ChartLegendExpansion.hpp>
#include <com/sun/star/chart2/LegendPosition.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
@@ -31,31 +33,30 @@ using ::com::sun::star::uno::Reference;
namespace chart
{
-Reference< chart2::XLegend > LegendHelper::showLegend( ChartModel& rModel
+rtl::Reference< Legend > LegendHelper::showLegend( ChartModel& rModel
, const uno::Reference< uno::XComponentContext >& xContext )
{
- uno::Reference< chart2::XLegend > xLegend = LegendHelper::getLegend( rModel, xContext, true );
- uno::Reference< beans::XPropertySet > xProp( xLegend, uno::UNO_QUERY );
- if( xProp.is())
+ rtl::Reference< Legend > xLegend = LegendHelper::getLegend( rModel, xContext, true );
+ if( xLegend.is())
{
- xProp->setPropertyValue( "Show", uno::Any(true) );
+ xLegend->setPropertyValue( "Show", uno::Any(true) );
chart2::RelativePosition aRelativePosition;
- if( !(xProp->getPropertyValue( "RelativePosition") >>= aRelativePosition) )
+ if( !(xLegend->getPropertyValue( "RelativePosition") >>= aRelativePosition) )
{
chart2::LegendPosition ePos = chart2::LegendPosition_LINE_END;
- if( !(xProp->getPropertyValue( "AnchorPosition") >>= ePos ) )
- xProp->setPropertyValue( "AnchorPosition", uno::Any( ePos ));
+ if( !(xLegend->getPropertyValue( "AnchorPosition") >>= ePos ) )
+ xLegend->setPropertyValue( "AnchorPosition", uno::Any( ePos ));
css::chart::ChartLegendExpansion eExpansion =
( ePos == chart2::LegendPosition_LINE_END ||
ePos == chart2::LegendPosition_LINE_START )
? css::chart::ChartLegendExpansion_HIGH
: css::chart::ChartLegendExpansion_WIDE;
- if( !(xProp->getPropertyValue( "Expansion") >>= eExpansion ) )
- xProp->setPropertyValue( "Expansion", uno::Any( eExpansion ));
+ if( !(xLegend->getPropertyValue( "Expansion") >>= eExpansion ) )
+ xLegend->setPropertyValue( "Expansion", uno::Any( eExpansion ));
- xProp->setPropertyValue( "RelativePosition", uno::Any());
+ xLegend->setPropertyValue( "RelativePosition", uno::Any());
}
}
@@ -64,31 +65,29 @@ Reference< chart2::XLegend > LegendHelper::showLegend( ChartModel& rModel
void LegendHelper::hideLegend( ChartModel& rModel )
{
- uno::Reference< chart2::XLegend > xLegend = LegendHelper::getLegend( rModel, nullptr );
- uno::Reference< beans::XPropertySet > xProp( xLegend, uno::UNO_QUERY );
- if( xProp.is())
+ rtl::Reference< Legend > xLegend = LegendHelper::getLegend( rModel, nullptr );
+ if( xLegend.is())
{
- xProp->setPropertyValue( "Show", uno::Any(false) );
+ xLegend->setPropertyValue( "Show", uno::Any(false) );
}
}
-uno::Reference< chart2::XLegend > LegendHelper::getLegend(
+rtl::Reference< Legend > LegendHelper::getLegend(
ChartModel& rModel
, const uno::Reference< uno::XComponentContext >& xContext
, bool bCreate )
{
- uno::Reference< chart2::XLegend > xResult;
+ rtl::Reference< Legend > xResult;
try
{
- uno::Reference< chart2::XDiagram > xDia( rModel.getFirstDiagram());
+ rtl::Reference< Diagram > xDia( rModel.getFirstChartDiagram());
if( xDia.is() )
{
- xResult.set( xDia->getLegend() );
+ xResult = xDia->getLegend2();
if( bCreate && !xResult.is() && xContext.is() )
{
- xResult.set( xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.Legend", xContext ), uno::UNO_QUERY );
+ xResult = new Legend();
xDia->setLegend( xResult );
}
}
@@ -105,7 +104,7 @@ uno::Reference< chart2::XLegend > LegendHelper::getLegend(
return xResult;
}
-bool LegendHelper::hasLegend( const uno::Reference< chart2::XDiagram > & xDiagram )
+bool LegendHelper::hasLegend( const rtl::Reference< Diagram > & xDiagram )
{
bool bReturn = false;
if( xDiagram.is())
diff --git a/chart2/source/tools/LifeTime.cxx b/chart2/source/tools/LifeTime.cxx
index 5817db73a2e1..45550b93efdd 100644
--- a/chart2/source/tools/LifeTime.cxx
+++ b/chart2/source/tools/LifeTime.cxx
@@ -20,11 +20,14 @@
#include <LifeTime.hxx>
#include <osl/diagnose.h>
+#include <com/sun/star/document/XStorageChangeListener.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/util/CloseVetoException.hpp>
#include <com/sun/star/util/XCloseListener.hpp>
#include <com/sun/star/util/XCloseable.hpp>
-#include <tools/diagnose_ex.h>
+#include <com/sun/star/util/XModifyListener.hpp>
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
using namespace ::com::sun::star;
@@ -33,8 +36,7 @@ namespace apphelper
{
LifeTimeManager::LifeTimeManager( lang::XComponent* pComponent )
- : m_aListenerContainer( m_aAccessMutex )
- , m_pComponent(pComponent)
+ : m_pComponent(pComponent)
{
m_bDisposed = false;
m_bInDispose = false;
@@ -85,7 +87,7 @@ void LifeTimeManager::impl_registerApiCall(bool bLongLastingCall)
m_aNoLongLastingCallCountCondition.reset();
}
-void LifeTimeManager::impl_unregisterApiCall(bool bLongLastingCall)
+void LifeTimeManager::impl_unregisterApiCall(std::unique_lock<std::mutex>& rGuard, bool bLongLastingCall)
{
//Mutex needs to be acquired exactly once
//mutex may be released inbetween in special case of impl_apiCallCountReachedNull()
@@ -101,7 +103,7 @@ void LifeTimeManager::impl_unregisterApiCall(bool bLongLastingCall)
if( m_nAccessCount== 0)
{
m_aNoAccessCountCondition.set();
- impl_apiCallCountReachedNull();
+ impl_apiCallCountReachedNull(rGuard);
}
}
@@ -110,7 +112,7 @@ bool LifeTimeManager::dispose()
{
//hold no mutex
{
- osl::MutexGuard aGuard( m_aAccessMutex );
+ std::unique_lock aGuard( m_aAccessMutex );
if( m_bDisposed || m_bInDispose )
{
@@ -122,23 +124,19 @@ bool LifeTimeManager::dispose()
//adding any listener is not allowed anymore
//new calls will not be accepted
//still running calls have the freedom to finish their work without crash
- }
- //no mutex is acquired
- //--do the disposing of listeners after calling this method
- {
uno::Reference< lang::XComponent > xComponent(m_pComponent);
if(xComponent.is())
{
// notify XCLoseListeners
lang::EventObject aEvent( xComponent );
- m_aListenerContainer.disposeAndClear( aEvent );
+ m_aCloseListeners.disposeAndClear( aGuard, aEvent );
+ m_aModifyListeners.disposeAndClear( aGuard, aEvent );
+ m_aStorageChangeListeners.disposeAndClear( aGuard, aEvent );
+ m_aEventListeners.disposeAndClear( aGuard, aEvent );
+ m_aSelectionChangeListeners.disposeAndClear( aGuard, aEvent );
}
- }
- //no mutex is acquired
- {
- osl::MutexGuard aGuard( m_aAccessMutex );
OSL_ENSURE( !m_bDisposed, "dispose was called already" );
m_bDisposed = true;
}
@@ -189,7 +187,7 @@ bool CloseableLifeTimeManager::g_close_startTryClose(bool bDeliverOwnership)
{
//no mutex is allowed to be acquired
{
- osl::MutexGuard aGuard( m_aAccessMutex );
+ std::unique_lock aGuard( m_aAccessMutex );
if( impl_isDisposedOrClosed(false) )
return false;
@@ -217,19 +215,16 @@ bool CloseableLifeTimeManager::g_close_startTryClose(bool bDeliverOwnership)
uno::Reference< util::XCloseable > xCloseable(m_pCloseable);
if(xCloseable.is())
{
+ std::unique_lock aGuard( m_aAccessMutex );
//--call queryClosing on all registered close listeners
- ::cppu::OInterfaceContainerHelper* pIC = m_aListenerContainer.getContainer(
- cppu::UnoType<util::XCloseListener>::get());
- if( pIC )
+ if( m_aCloseListeners.getLength(aGuard) )
{
lang::EventObject aEvent( xCloseable );
- ::cppu::OInterfaceIteratorHelper aIt( *pIC );
- while( aIt.hasMoreElements() )
- {
- uno::Reference< util::XCloseListener > xCloseListener( aIt.next(), uno::UNO_QUERY );
- if(xCloseListener.is())
- xCloseListener->queryClosing( aEvent, bDeliverOwnership );
- }
+ m_aCloseListeners.forEach(aGuard,
+ [&aEvent, bDeliverOwnership](const uno::Reference<util::XCloseListener>& l)
+ {
+ l->queryClosing(aEvent, bDeliverOwnership);
+ });
}
}
}
@@ -245,7 +240,7 @@ bool CloseableLifeTimeManager::g_close_startTryClose(bool bDeliverOwnership)
void CloseableLifeTimeManager::g_close_endTryClose(bool bDeliverOwnership )
{
//this method is called, if the try to close was not successful
- osl::MutexGuard aGuard( m_aAccessMutex );
+ std::unique_lock aGuard( m_aAccessMutex );
impl_setOwnership( bDeliverOwnership, false );
m_bInTryClose = false;
@@ -253,7 +248,7 @@ void CloseableLifeTimeManager::g_close_endTryClose(bool bDeliverOwnership )
//Mutex needs to be acquired exactly once
//mutex may be released inbetween in special case of impl_apiCallCountReachedNull()
- impl_unregisterApiCall(false);
+ impl_unregisterApiCall(aGuard, false);
}
void CloseableLifeTimeManager::g_close_isNeedToCancelLongLastingCalls( bool bDeliverOwnership, util::CloseVetoException const & ex )
@@ -263,7 +258,7 @@ void CloseableLifeTimeManager::g_close_isNeedToCancelLongLastingCalls( bool bDel
//it returns true, if some longlasting calls are running, which might be cancelled
//it throws the given exception, if long calls are running but not cancelable
- osl::MutexGuard aGuard( m_aAccessMutex );
+ std::unique_lock aGuard( m_aAccessMutex );
//this count cannot grow after try of close has started, because we wait in all those methods for end of try closing
if( !m_nLongLastingCallCount )
return;
@@ -275,7 +270,7 @@ void CloseableLifeTimeManager::g_close_isNeedToCancelLongLastingCalls( bool bDel
//Mutex needs to be acquired exactly once
//mutex may be released inbetween in special case of impl_apiCallCountReachedNull()
- impl_unregisterApiCall(false);
+ impl_unregisterApiCall(aGuard, false);
throw ex;
}
@@ -283,15 +278,15 @@ void CloseableLifeTimeManager::g_close_isNeedToCancelLongLastingCalls( bool bDel
void CloseableLifeTimeManager::g_close_endTryClose_doClose()
{
//this method is called, if the try to close was successful
- osl::MutexGuard aGuard( m_aAccessMutex );
+ std::unique_lock aGuard( m_aAccessMutex );
m_bInTryClose = false;
m_aEndTryClosingCondition.set();
//Mutex needs to be acquired exactly once
//mutex may be released inbetween in special case of impl_apiCallCountReachedNull()
- impl_unregisterApiCall(false);
- impl_doClose();
+ impl_unregisterApiCall(aGuard, false);
+ impl_doClose(aGuard);
}
void CloseableLifeTimeManager::impl_setOwnership( bool bDeliverOwnership, bool bMyVeto )
@@ -299,15 +294,15 @@ void CloseableLifeTimeManager::impl_setOwnership( bool bDeliverOwnership, bool b
m_bOwnership = bDeliverOwnership && bMyVeto;
}
-void CloseableLifeTimeManager::impl_apiCallCountReachedNull()
+void CloseableLifeTimeManager::impl_apiCallCountReachedNull(std::unique_lock<std::mutex>& rGuard)
{
//Mutex needs to be acquired exactly once
//mutex will be released inbetween in impl_doClose()
if( m_pCloseable && m_bOwnership )
- impl_doClose();
+ impl_doClose(rGuard);
}
-void CloseableLifeTimeManager::impl_doClose()
+void CloseableLifeTimeManager::impl_doClose(std::unique_lock<std::mutex>& rGuard)
{
//Mutex needs to be acquired exactly once before calling impl_doClose()
@@ -318,28 +313,17 @@ void CloseableLifeTimeManager::impl_doClose()
m_bClosed = true;
- NegativeGuard< osl::Mutex > aNegativeGuard( m_aAccessMutex );
- //mutex is not acquired, mutex will be reacquired at the end of this method automatically
-
uno::Reference< util::XCloseable > xCloseable;
+ xCloseable.set(m_pCloseable);
try
{
- xCloseable.set(m_pCloseable);
if(xCloseable.is())
{
//--call notifyClosing on all registered close listeners
- ::cppu::OInterfaceContainerHelper* pIC = m_aListenerContainer.getContainer(
- cppu::UnoType<util::XCloseListener>::get());
- if( pIC )
+ if( m_aCloseListeners.getLength(rGuard) )
{
lang::EventObject aEvent( xCloseable );
- ::cppu::OInterfaceIteratorHelper aIt( *pIC );
- while( aIt.hasMoreElements() )
- {
- uno::Reference< util::XCloseListener > xListener( aIt.next(), uno::UNO_QUERY );
- if( xListener.is() )
- xListener->notifyClosing( aEvent );
- }
+ m_aCloseListeners.notifyEach(rGuard, &util::XCloseListener::notifyClosing, aEvent);
}
}
}
@@ -348,6 +332,7 @@ void CloseableLifeTimeManager::impl_doClose()
DBG_UNHANDLED_EXCEPTION("chart2");
}
+ rGuard.unlock();
if(xCloseable.is())
{
uno::Reference< lang::XComponent > xComponent( xCloseable, uno::UNO_QUERY );
@@ -357,18 +342,18 @@ void CloseableLifeTimeManager::impl_doClose()
xComponent->dispose();
}
}
- //mutex will be reacquired in destructor of aNegativeGuard
+ rGuard.lock();
}
void CloseableLifeTimeManager::g_addCloseListener( const uno::Reference< util::XCloseListener > & xListener )
{
- osl::MutexGuard aGuard( m_aAccessMutex );
+ std::unique_lock aGuard( m_aAccessMutex );
//Mutex needs to be acquired exactly once; will be released inbetween
if( !impl_canStartApiCall() )
return;
//mutex is acquired
- m_aListenerContainer.addInterface( cppu::UnoType<util::XCloseListener>::get(),xListener );
+ m_aCloseListeners.addInterface( aGuard, xListener );
m_bOwnership = false;
}
@@ -389,9 +374,9 @@ bool CloseableLifeTimeManager::impl_canStartApiCall()
//we need to wait for his end because the result of the preceding call
//is relevant for our behaviour here
- m_aAccessMutex.release();
+ m_aAccessMutex.unlock();
m_aEndTryClosingCondition.wait(); //@todo??? this may block??? try closing
- m_aAccessMutex.acquire();
+ m_aAccessMutex.lock();
if( m_bDisposed || m_bInDispose || m_bClosed )
return false; //return if closed already
}
@@ -424,12 +409,13 @@ LifeTimeGuard::~LifeTimeGuard()
try
{
//do acquire the mutex if it was cleared before
- osl::MutexGuard g(m_rManager.m_aAccessMutex);
+ if (!m_guard.owns_lock())
+ m_guard.lock();
if(m_bCallRegistered)
{
//Mutex needs to be acquired exactly once
//mutex may be released inbetween in special case of impl_apiCallCountReachedNull()
- m_rManager.impl_unregisterApiCall(m_bLongLastingCallRegistered);
+ m_rManager.impl_unregisterApiCall(m_guard, m_bLongLastingCallRegistered);
}
}
catch( uno::Exception& ex )
diff --git a/chart2/source/tools/LinePropertiesHelper.cxx b/chart2/source/tools/LinePropertiesHelper.cxx
index 7e6d28860903..b3c5fc6ccf53 100644
--- a/chart2/source/tools/LinePropertiesHelper.cxx
+++ b/chart2/source/tools/LinePropertiesHelper.cxx
@@ -24,7 +24,8 @@
#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/drawing/LineCap.hpp>
#include <com/sun/star/drawing/LineJoint.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <tools/color.hxx>
using namespace ::com::sun::star;
@@ -92,9 +93,9 @@ void LinePropertiesHelper::AddDefaultsToMap(
::chart::tPropertyValueMap & rOutMap )
{
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_WIDTH, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_COLOR, 0x000000 ); // black
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_LINE_TRANSPARENCE, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_WIDTH, sal_Int32(0) );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_COLOR, COL_BLACK );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_TRANSPARENCE, sal_Int16(0) );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_CAP, drawing::LineCap_BUTT );
}
diff --git a/chart2/source/tools/LinearRegressionCurveCalculator.cxx b/chart2/source/tools/LinearRegressionCurveCalculator.cxx
index 9cf3492d8e8e..ee836555b1e4 100644
--- a/chart2/source/tools/LinearRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/LinearRegressionCurveCalculator.cxx
@@ -24,8 +24,7 @@ using namespace ::com::sun::star;
namespace chart
{
-LinearRegressionCurveCalculator::LinearRegressionCurveCalculator() :
- PolynomialRegressionCurveCalculator()
+LinearRegressionCurveCalculator::LinearRegressionCurveCalculator()
{}
LinearRegressionCurveCalculator::~LinearRegressionCurveCalculator()
@@ -35,13 +34,15 @@ void LinearRegressionCurveCalculator::setRegressionProperties(
sal_Int32 /*aDegree*/,
sal_Bool aForceIntercept,
double aInterceptValue,
- sal_Int32 aPeriod )
+ sal_Int32 aPeriod,
+ sal_Int32 /*nMovingType*/)
{
PolynomialRegressionCurveCalculator::setRegressionProperties(
1,
aForceIntercept,
aInterceptValue,
- aPeriod);
+ aPeriod,
+ 0);
}
uno::Sequence< geometry::RealPoint2D > SAL_CALL LinearRegressionCurveCalculator::getCurveValues(
@@ -55,11 +56,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL LinearRegressionCurveCalculator:
isLinearScaling( xScalingY ))
{
// optimize result
- uno::Sequence< geometry::RealPoint2D > aResult( 2 );
- aResult[0].X = min;
- aResult[0].Y = getCurveValue( min );
- aResult[1].X = max;
- aResult[1].Y = getCurveValue( max );
+ uno::Sequence< geometry::RealPoint2D > aResult{ { min, getCurveValue( min ) },
+ { max, getCurveValue( max ) } };
return aResult;
}
diff --git a/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx b/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx
index c09eab50975c..5e68235d14cd 100644
--- a/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx
@@ -30,11 +30,9 @@ namespace chart
{
LogarithmicRegressionCurveCalculator::LogarithmicRegressionCurveCalculator() :
- m_fSlope( 0.0 ),
- m_fIntercept( 0.0 )
+ m_fSlope( std::numeric_limits<double>::quiet_NaN() ),
+ m_fIntercept( std::numeric_limits<double>::quiet_NaN() )
{
- ::rtl::math::setNan( & m_fSlope );
- ::rtl::math::setNan( & m_fIntercept );
}
LogarithmicRegressionCurveCalculator::~LogarithmicRegressionCurveCalculator()
@@ -53,9 +51,9 @@ void SAL_CALL LogarithmicRegressionCurveCalculator::recalculateRegression(
const size_t nMax = aValues.first.size();
if( nMax <= 1 ) // at least 2 points
{
- ::rtl::math::setNan( & m_fSlope );
- ::rtl::math::setNan( & m_fIntercept );
- ::rtl::math::setNan( & m_fCorrelationCoefficient );
+ m_fSlope = std::numeric_limits<double>::quiet_NaN();
+ m_fIntercept = std::numeric_limits<double>::quiet_NaN();
+ m_fCorrelationCoefficient = std::numeric_limits<double>::quiet_NaN();
return;
}
@@ -89,16 +87,13 @@ void SAL_CALL LogarithmicRegressionCurveCalculator::recalculateRegression(
double SAL_CALL LogarithmicRegressionCurveCalculator::getCurveValue( double x )
{
- double fResult;
- ::rtl::math::setNan( & fResult );
-
if( ! ( std::isnan( m_fSlope ) ||
std::isnan( m_fIntercept )))
{
- fResult = m_fSlope * log( x ) + m_fIntercept;
+ return m_fSlope * log( x ) + m_fIntercept;
}
- return fResult;
+ return std::numeric_limits<double>::quiet_NaN();
}
uno::Sequence< geometry::RealPoint2D > SAL_CALL LogarithmicRegressionCurveCalculator::getCurveValues(
@@ -112,11 +107,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL LogarithmicRegressionCurveCalcul
isLinearScaling( xScalingY ))
{
// optimize result
- uno::Sequence< geometry::RealPoint2D > aResult( 2 );
- aResult[0].X = min;
- aResult[0].Y = getCurveValue( min );
- aResult[1].X = max;
- aResult[1].Y = getCurveValue( max );
+ uno::Sequence< geometry::RealPoint2D > aResult{ { min, getCurveValue( min ) },
+ { max, getCurveValue( max ) } };
return aResult;
}
@@ -156,17 +148,17 @@ OUString LogarithmicRegressionCurveCalculator::ImplGetRepresentation(
{
if( m_fSlope < 0.0 )
{
- aTmpBuf.append( OUStringChar(aMinusSign) ).append( " " );
+ aTmpBuf.append( OUStringChar(aMinusSign) + " " );
}
if( bHasSlope )
{
OUString aValueString = getFormattedString( xNumFormatter, nNumberFormatKey, fabs(m_fSlope), pValueLength );
if ( aValueString != "1" ) // aValueString may be rounded to 1 if nValueLength is small
{
- aTmpBuf.append( aValueString ).append( " " );
+ aTmpBuf.append( aValueString + " " );
}
}
- aTmpBuf.append( "ln(" ).append( mXName ).append( ") " );
+ aTmpBuf.append( "ln(" + mXName + ") " );
addStringToEquation( aBuf, nLineLength, aTmpBuf, pFormulaMaxWidth );
aTmpBuf.truncate();
@@ -175,7 +167,7 @@ OUString LogarithmicRegressionCurveCalculator::ImplGetRepresentation(
}
// add intercept value
if( m_fIntercept < 0.0 )
- aTmpBuf.append( OUStringChar(aMinusSign) ).append( " " );
+ aTmpBuf.append( OUStringChar(aMinusSign) + " " );
OUString aValueString = getFormattedString( xNumFormatter, nNumberFormatKey, fabs(m_fIntercept), pValueLength );
if ( aValueString != "0" ) // aValueString may be rounded to 0 if nValueLength is small
{
@@ -183,7 +175,7 @@ OUString LogarithmicRegressionCurveCalculator::ImplGetRepresentation(
addStringToEquation( aBuf, nLineLength, aTmpBuf, pFormulaMaxWidth );
}
- if ( aBuf.toString() == (mYName + " = ") )
+ if ( std::u16string_view(aBuf) == Concat2View(mYName + " = ") )
aBuf.append( "0" );
return aBuf.makeStringAndClear();
diff --git a/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx b/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx
index c9821343b4ec..aefd3f8f05aa 100644
--- a/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx
@@ -20,7 +20,9 @@
#include <MeanValueRegressionCurveCalculator.hxx>
#include <osl/diagnose.h>
-#include <rtl/math.hxx>
+
+#include <cmath>
+#include <limits>
using namespace ::com::sun::star;
@@ -28,9 +30,8 @@ namespace chart
{
MeanValueRegressionCurveCalculator::MeanValueRegressionCurveCalculator() :
- m_fMeanValue( 0.0 )
+ m_fMeanValue( std::numeric_limits<double>::quiet_NaN() )
{
- ::rtl::math::setNan( & m_fMeanValue );
}
MeanValueRegressionCurveCalculator::~MeanValueRegressionCurveCalculator()
@@ -59,7 +60,7 @@ void SAL_CALL MeanValueRegressionCurveCalculator::recalculateRegression(
if( nMax == 0 )
{
- ::rtl::math::setNan( & m_fMeanValue );
+ m_fMeanValue = std::numeric_limits<double>::quiet_NaN();
}
else
{
@@ -98,11 +99,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL MeanValueRegressionCurveCalculat
if( bMaySkipPointsInCalculation )
{
// optimize result
- uno::Sequence< geometry::RealPoint2D > aResult( 2 );
- aResult[0].X = min;
- aResult[0].Y = m_fMeanValue;
- aResult[1].X = max;
- aResult[1].Y = m_fMeanValue;
+ uno::Sequence< geometry::RealPoint2D > aResult{ { min, m_fMeanValue },
+ { max, m_fMeanValue } };
return aResult;
}
diff --git a/chart2/source/tools/MediaDescriptorHelper.cxx b/chart2/source/tools/MediaDescriptorHelper.cxx
index 73c326fdcb38..bd217b0fbf8c 100644
--- a/chart2/source/tools/MediaDescriptorHelper.cxx
+++ b/chart2/source/tools/MediaDescriptorHelper.cxx
@@ -33,21 +33,23 @@ MediaDescriptorHelper::MediaDescriptorHelper( const uno::Sequence<
beans::PropertyValue > & rMediaDescriptor )
: m_aModelProperties(rMediaDescriptor.getLength())
{
+ auto aModelPropertiesRange = asNonConstRange(m_aModelProperties);
css::uno::Sequence< css::beans::PropertyValue >
aRegularProperties(rMediaDescriptor.getLength()); //these are the properties which are described in service com.sun.star.document.MediaDescriptor and not marked as deprecated
+ auto aRegularPropertiesRange = asNonConstRange(aRegularProperties);
impl_init();
sal_Int32 nRegularCount = 0;
sal_Int32 nModelCount = 0;
- auto addRegularProp = [&aRegularProperties, &nRegularCount](const beans::PropertyValue& rRegularProp)
+ auto addRegularProp = [&aRegularPropertiesRange, &nRegularCount](const beans::PropertyValue& rRegularProp)
{
- aRegularProperties[nRegularCount] = rRegularProp;
+ aRegularPropertiesRange[nRegularCount] = rRegularProp;
++nRegularCount;
};
- auto addModelProp = [this, &nModelCount, &addRegularProp](const beans::PropertyValue& rModelProp)
+ auto addModelProp = [&aModelPropertiesRange, &nModelCount, &addRegularProp](const beans::PropertyValue& rModelProp)
{
addRegularProp(rModelProp);
- m_aModelProperties[nModelCount] = rModelProp;
+ aModelPropertiesRange[nModelCount] = rModelProp;
++nModelCount;
};
diff --git a/chart2/source/tools/ModifyListenerCallBack.cxx b/chart2/source/tools/ModifyListenerCallBack.cxx
index 55d681061f8d..037ee7a7820d 100644
--- a/chart2/source/tools/ModifyListenerCallBack.cxx
+++ b/chart2/source/tools/ModifyListenerCallBack.cxx
@@ -18,20 +18,18 @@
*/
#include <ModifyListenerCallBack.hxx>
-#include <cppuhelper/compbase.hxx>
-#include <MutexContainer.hxx>
+#include <comphelper/compbase.hxx>
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
namespace chart {
-typedef ::cppu::WeakComponentImplHelper< css::util::XModifyListener >
+typedef comphelper::WeakComponentImplHelper< css::util::XModifyListener >
ModifyListenerCallBack_Base;
class ModifyListenerCallBack_impl
- : public ::chart::MutexContainer
- , public ModifyListenerCallBack_Base
+ : public ModifyListenerCallBack_Base
{
public:
explicit ModifyListenerCallBack_impl( const Link<void*,void>& rCallBack );
@@ -45,7 +43,7 @@ public:
//XEventListener
virtual void SAL_CALL disposing( const lang::EventObject& Source ) override;
- using ::cppu::WeakComponentImplHelperBase::disposing;
+ using ::comphelper::WeakComponentImplHelperBase::disposing;
private:
Link<void*,void> m_aLink;//will be called on modify
@@ -53,8 +51,7 @@ private:
};
ModifyListenerCallBack_impl::ModifyListenerCallBack_impl( const Link<void*,void>& rCallBack )
- : ModifyListenerCallBack_Base( m_aMutex )
- , m_aLink( rCallBack )
+ : m_aLink( rCallBack )
{
}
diff --git a/chart2/source/tools/ModifyListenerHelper.cxx b/chart2/source/tools/ModifyListenerHelper.cxx
index 3266af1d037e..507e79fa32e2 100644
--- a/chart2/source/tools/ModifyListenerHelper.cxx
+++ b/chart2/source/tools/ModifyListenerHelper.cxx
@@ -18,151 +18,42 @@
*/
#include <ModifyListenerHelper.hxx>
-#include <WeakListenerAdapter.hxx>
-
-#include <tools/diagnose_ex.h>
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
-namespace
-{
-
-void lcl_fireModifyEvent(
- ::cppu::OBroadcastHelper const & rBroadcastHelper,
- const Reference< uno::XWeak > & xEventSource,
- const lang::EventObject * pEvent )
-{
- ::cppu::OInterfaceContainerHelper * pCntHlp = rBroadcastHelper.getContainer(
- cppu::UnoType<util::XModifyListener>::get());
- if( !pCntHlp )
- return;
-
- lang::EventObject aEventToSend;
- if( pEvent )
- aEventToSend = *pEvent;
- else
- aEventToSend.Source.set( xEventSource );
- OSL_ENSURE( aEventToSend.Source.is(), "Sending event without source" );
-
- ::cppu::OInterfaceIteratorHelper aIt( *pCntHlp );
-
- while( aIt.hasMoreElements())
- {
- Reference< util::XModifyListener > xModListener( aIt.next(), uno::UNO_QUERY );
- if( xModListener.is())
- xModListener->modified( aEventToSend );
- }
-}
-
-struct lcl_weakReferenceToSame
-{
- explicit lcl_weakReferenceToSame( const Reference< util::XModifyListener > & xModListener ) :
- m_xHardRef( xModListener )
- {}
-
- // argument type is same as tListenerMap::value_type&
- bool operator() ( const std::pair<css::uno::WeakReference< css::util::XModifyListener>,
- css::uno::Reference< css::util::XModifyListener> > & xElem )
- {
- Reference< util::XModifyListener > xWeakAsHard( xElem.first );
- if( xWeakAsHard.is())
- return (xWeakAsHard == m_xHardRef);
- return false;
- }
-
-private:
- Reference< util::XModifyListener > m_xHardRef;
-};
-
-} // anonymous namespace
-
-namespace chart::ModifyListenerHelper
-{
-
-uno::Reference< util::XModifyListener > createModifyEventForwarder()
-{
- return new ModifyEventForwarder();
-}
-
-ModifyEventForwarder::ModifyEventForwarder() :
- ::cppu::WeakComponentImplHelper<
- css::util::XModifyBroadcaster,
- css::util::XModifyListener >( m_aMutex ),
- m_aModifyListeners( m_aMutex )
+namespace chart
{
-}
-void ModifyEventForwarder::AddListener( const Reference< util::XModifyListener >& aListener )
+ModifyEventForwarder::ModifyEventForwarder()
{
- try
- {
- Reference< util::XModifyListener > xListenerToAdd( aListener );
-
- Reference< uno::XWeak > xWeak( aListener, uno::UNO_QUERY );
- if( xWeak.is())
- {
- // remember the helper class for later remove
- uno::WeakReference< util::XModifyListener > xWeakRef( aListener );
- xListenerToAdd.set( new WeakModifyListenerAdapter( xWeakRef ));
- m_aListenerMap.emplace_back( xWeakRef, xListenerToAdd );
- }
-
- m_aModifyListeners.addListener( cppu::UnoType<decltype(xListenerToAdd)>::get(), xListenerToAdd );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
-void ModifyEventForwarder::RemoveListener( const Reference< util::XModifyListener >& aListener )
-{
- try
- {
- // look up fitting helper class that has been added
- Reference< util::XModifyListener > xListenerToRemove( aListener );
- tListenerMap::iterator aIt(
- std::find_if( m_aListenerMap.begin(), m_aListenerMap.end(), lcl_weakReferenceToSame( aListener )));
- if( aIt != m_aListenerMap.end())
- {
- xListenerToRemove.set( (*aIt).second );
- // map entry is no longer needed
- m_aListenerMap.erase( aIt );
- }
-
- m_aModifyListeners.removeListener( cppu::UnoType<decltype(aListener)>::get(), xListenerToRemove );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
-void ModifyEventForwarder::DisposeAndClear( const Reference< uno::XWeak > & xSource )
-{
- ::cppu::OInterfaceContainerHelper * pCntHlp = m_aModifyListeners.getContainer(
- cppu::UnoType<util::XModifyListener>::get());
- if( pCntHlp )
- pCntHlp->disposeAndClear( lang::EventObject( xSource ) );
}
// ____ XModifyBroadcaster ____
void SAL_CALL ModifyEventForwarder::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- AddListener( aListener );
+ std::unique_lock aGuard(m_aMutex);
+
+ m_aModifyListeners.addInterface( aGuard, aListener );
}
void SAL_CALL ModifyEventForwarder::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- RemoveListener( aListener );
+ std::unique_lock aGuard(m_aMutex);
+
+ m_aModifyListeners.removeInterface( aGuard, aListener );
}
// ____ XModifyListener ____
void SAL_CALL ModifyEventForwarder::modified( const lang::EventObject& aEvent )
{
- lcl_fireModifyEvent( m_aModifyListeners, Reference< uno::XWeak >(), &aEvent );
+ std::unique_lock aGuard(m_aMutex);
+
+ if( m_aModifyListeners.getLength(aGuard) == 0 )
+ return;
+
+ m_aModifyListeners.notifyEach( aGuard, &util::XModifyListener::modified, aEvent );
}
// ____ XEventListener (base of XModifyListener) ____
@@ -172,10 +63,10 @@ void SAL_CALL ModifyEventForwarder::disposing( const lang::EventObject& /* Sourc
}
// ____ WeakComponentImplHelperBase ____
-void SAL_CALL ModifyEventForwarder::disposing()
+void ModifyEventForwarder::disposing(std::unique_lock<std::mutex>& rGuard)
{
// dispose was called at this
- DisposeAndClear( this );
+ m_aModifyListeners.disposeAndClear( rGuard, lang::EventObject( static_cast<cppu::OWeakObject*>(this) ) );
}
} // namespace chart::ModifyListenerHelper
diff --git a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx
index 7774bec02a4f..f71262f738b9 100644
--- a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx
@@ -22,9 +22,13 @@
#include <ResId.hxx>
#include <strings.hrc>
-#include <rtl/math.hxx>
+#include <algorithm>
+#include <limits>
+
+#include <com/sun/star/chart2/MovingAverageType.hpp>
using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
namespace chart
{
@@ -40,40 +44,100 @@ void SAL_CALL MovingAverageRegressionCurveCalculator::recalculateRegression(
const uno::Sequence< double >& aXValues,
const uno::Sequence< double >& aYValues )
{
- ::rtl::math::setNan( & m_fCorrelationCoefficient );
+ m_fCorrelationCoefficient = std::numeric_limits<double>::quiet_NaN();
RegressionCalculationHelper::tDoubleVectorPair aValues(
RegressionCalculationHelper::cleanup(
aXValues, aYValues,
RegressionCalculationHelper::isValid()));
- const size_t aSize = aValues.first.size();
-
aYList.clear();
aXList.clear();
- for( size_t i = mPeriod - 1; i < aSize; ++i )
+ // For formulas, see
+ // https://docs.oasis-open.org/office/OpenDocument/v1.3/cs02/part3-schema/OpenDocument-v1.3-cs02-part3-schema.html#property-chart_regression-moving-type
+
+ switch (mnMovingType)
{
- double yAvg;
- yAvg = 0.0;
+ case MovingAverageType::Central:
+ {
+
+ calculateValuesCentral(std::move(aValues));
+ break;
+ }
+
+ case MovingAverageType::AveragedAbscissa:
+ {
+ calculateValues(std::move(aValues), true);
+ break;
+ }
+ case MovingAverageType::Prior:
+ default:
+ {
+ calculateValues(std::move(aValues), false);
+ break;
+ }
+ }
+}
+
+void MovingAverageRegressionCurveCalculator::calculateValuesCentral(
+ RegressionCalculationHelper::tDoubleVectorPair aValues)
+{
+ const size_t aSize = aValues.first.size();
+ if (aSize == 0)
+ return;
+ for (size_t i = mPeriod - 1; i < aSize; ++i)
+ {
+ double yAvg = 0.0;
for (sal_Int32 j = 0; j < mPeriod; j++)
{
yAvg += aValues.second[i - j];
}
yAvg /= mPeriod;
-
- double x = aValues.first[i];
aYList.push_back(yAvg);
+ }
+ sal_Int32 nPeriodLocal = (mPeriod % 2 == 0) ? (mPeriod / 2) : ((mPeriod - 1) / 2);
+ for (size_t i = nPeriodLocal; i < aSize - 1; ++i)
+ {
+ double x = aValues.first[i];
aXList.push_back(x);
}
}
+void MovingAverageRegressionCurveCalculator::calculateValues(
+ RegressionCalculationHelper::tDoubleVectorPair aValues, bool bUseXAvg)
+{
+ const size_t aSize = aValues.first.size();
+ for (size_t i = mPeriod - 1; i < aSize; ++i)
+ {
+ double xAvg = 0.0;
+ double yAvg = 0.0;
+
+ for (sal_Int32 j = 0; j < mPeriod; j++)
+ {
+ xAvg += aValues.first[i - j];
+ yAvg += aValues.second[i - j];
+ }
+ yAvg /= mPeriod;
+ xAvg /= mPeriod;
+
+ aYList.push_back(yAvg);
+ if (bUseXAvg)
+ {
+ aXList.push_back(xAvg);
+ }
+ else
+ {
+ double x = aValues.first[i];
+ aXList.push_back(x);
+ }
+ }
+}
+
double SAL_CALL MovingAverageRegressionCurveCalculator::getCurveValue( double /*x*/ )
{
- double fResult;
- rtl::math::setNan(&fResult);
- return fResult;
+ return std::numeric_limits<double>::quiet_NaN();
}
uno::Sequence< geometry::RealPoint2D > SAL_CALL MovingAverageRegressionCurveCalculator::getCurveValues(
@@ -82,13 +146,10 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL MovingAverageRegressionCurveCalc
const uno::Reference< chart2::XScaling >& /*xScalingY*/,
sal_Bool /*bMaySkipPointsInCalculation*/ )
{
- uno::Sequence< geometry::RealPoint2D > aResult( aYList.size() );
-
- for( size_t i = 0; i < aYList.size(); ++i )
- {
- aResult[i].X = aXList[i];
- aResult[i].Y = aYList[i];
- }
+ size_t nSize = std::min(aXList.size(), aYList.size());
+ uno::Sequence< geometry::RealPoint2D > aResult( nSize );
+ std::transform(aXList.begin(), aXList.begin() + nSize, aYList.begin(), aResult.getArray(),
+ [](const auto& x, const auto& y) { return geometry::RealPoint2D(x, y); });
return aResult;
}
@@ -96,7 +157,15 @@ OUString MovingAverageRegressionCurveCalculator::ImplGetRepresentation(
const uno::Reference< util::XNumberFormatter >& /*xNumFormatter*/,
sal_Int32 /*nNumberFormatKey*/, sal_Int32* /*pFormulaLength = nullptr */ ) const
{
- return SchResId( STR_OBJECT_MOVING_AVERAGE_WITH_PARAMETERS );
+ OUString aRet = SchResId( STR_OBJECT_MOVING_AVERAGE_WITH_PARAMETERS );
+ // change text for Moving Average
+ OUString aWildcard( "%PERIOD" );
+ sal_Int32 nIndex = aRet.indexOf( aWildcard );
+ if( nIndex != -1 )
+ { // replace period
+ aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), OUString::number(mPeriod) );
+ }
+ return aRet;
}
} // namespace chart
diff --git a/chart2/source/tools/NameContainer.cxx b/chart2/source/tools/NameContainer.cxx
index b5e730ba552e..1cc79a8eaec0 100644
--- a/chart2/source/tools/NameContainer.cxx
+++ b/chart2/source/tools/NameContainer.cxx
@@ -20,7 +20,9 @@
#include <NameContainer.hxx>
#include <com/sun/star/uno/Any.hxx>
- #include <cppuhelper/supportsservice.hxx>
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/supportsservice.hxx>
using namespace ::com::sun::star;
using ::com::sun::star::uno::Sequence;
@@ -29,26 +31,13 @@ using ::com::sun::star::uno::Any;
namespace chart
{
-uno::Reference< container::XNameContainer > createNameContainer(
- const css::uno::Type& rType, const OUString& rServicename, const OUString& rImplementationName )
-{
- return new NameContainer( rType, rServicename, rImplementationName );
-}
-NameContainer::NameContainer( const css::uno::Type& rType, const OUString& rServicename, const OUString& rImplementationName )
- : m_aType( rType )
- , m_aServicename( rServicename )
- , m_aImplementationName( rImplementationName )
- , m_aMap()
+NameContainer::NameContainer()
{
}
-NameContainer::NameContainer(
- const NameContainer & rOther )
+NameContainer::NameContainer( const NameContainer & rOther )
: impl::NameContainer_Base(rOther)
- , m_aType( rOther.m_aType )
- , m_aServicename( rOther.m_aServicename )
- , m_aImplementationName( rOther.m_aImplementationName )
, m_aMap( rOther.m_aMap )
{
}
@@ -60,7 +49,7 @@ NameContainer::~NameContainer()
//XServiceInfo
OUString SAL_CALL NameContainer::getImplementationName()
{
- return m_aImplementationName;
+ return "com.sun.star.comp.chart.XMLNameSpaceMap";
}
sal_Bool SAL_CALL NameContainer::supportsService( const OUString& ServiceName )
@@ -70,13 +59,13 @@ sal_Bool SAL_CALL NameContainer::supportsService( const OUString& ServiceName )
Sequence< OUString > SAL_CALL NameContainer::getSupportedServiceNames()
{
- return { m_aServicename };
+ return { "com.sun.star.xml.NamespaceMap" };
}
// XNameContainer
void SAL_CALL NameContainer::insertByName( const OUString& rName, const Any& rElement )
{
- if( m_aMap.find( rName ) != m_aMap.end() )
+ if( m_aMap.contains( rName ))
throw container::ElementExistException();
m_aMap.emplace( rName, rElement );
}
@@ -109,14 +98,7 @@ Any SAL_CALL NameContainer::getByName( const OUString& rName )
Sequence< OUString > SAL_CALL NameContainer::getElementNames()
{
- sal_Int32 nCount = m_aMap.size();
- Sequence< OUString > aSeq(nCount);
- sal_Int32 nN = 0;
- for (auto const& elem : m_aMap)
- {
- aSeq[nN++]=elem.first;
- }
- return aSeq;
+ return comphelper::mapKeysToSequence(m_aMap);
}
sal_Bool SAL_CALL NameContainer::hasByName( const OUString& rName )
@@ -132,7 +114,7 @@ sal_Bool SAL_CALL NameContainer::hasElements()
uno::Type SAL_CALL NameContainer::getElementType()
{
- return m_aType;
+ return ::cppu::UnoType<OUString>::get();
}
// XCloneable
diff --git a/chart2/source/tools/NumberFormatterWrapper.cxx b/chart2/source/tools/NumberFormatterWrapper.cxx
index ef40617b07dd..e00df1fae04e 100644
--- a/chart2/source/tools/NumberFormatterWrapper.cxx
+++ b/chart2/source/tools/NumberFormatterWrapper.cxx
@@ -18,8 +18,8 @@
*/
#include <NumberFormatterWrapper.hxx>
+#include <svl/numformat.hxx>
#include <svl/numuno.hxx>
-#include <svl/zforlist.hxx>
#include <tools/color.hxx>
#include <com/sun/star/util/Date.hpp>
#include <osl/diagnose.h>
@@ -56,7 +56,7 @@ NumberFormatterWrapper::NumberFormatterWrapper( const uno::Reference< util::XNum
OUString sNullDate( "NullDate" );
if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(sNullDate) )
m_aNullDate = xProp->getPropertyValue(sNullDate);
- SvNumberFormatsSupplierObj* pSupplierObj = comphelper::getUnoTunnelImplementation<SvNumberFormatsSupplierObj>( xSupplier );
+ SvNumberFormatsSupplierObj* pSupplierObj = comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>( xSupplier );
if( pSupplierObj )
m_pNumberFormatter = pSupplierObj->GetNumberFormatter();
SAL_WARN_IF(!m_pNumberFormatter,"chart2.tools","need a numberformatter");
@@ -66,12 +66,31 @@ NumberFormatterWrapper::~NumberFormatterWrapper()
{
}
+namespace
+{
+ bool getDate(const css::uno::Any& rAny, util::Date& rDate)
+ {
+ if (rAny >>= rDate)
+ return true;
+ util::DateTime aUtilDateTime;
+ if (rAny >>= aUtilDateTime)
+ {
+ rDate.Day = aUtilDateTime.Day;
+ rDate.Month = aUtilDateTime.Month;
+ rDate.Year = aUtilDateTime.Year;
+ return true;
+ }
+ SAL_WARN("chart2.tools", "neither a util::Date nor a util::DateTime");
+ return false;
+ }
+}
+
Date NumberFormatterWrapper::getNullDate() const
{
Date aRet(30,12,1899);
util::Date aUtilDate;
- if( m_aNullDate.hasValue() && (m_aNullDate >>= aUtilDate) )
+ if (m_aNullDate.hasValue() && getDate(m_aNullDate, aUtilDate))
{
aRet = Date(aUtilDate.Day,aUtilDate.Month,aUtilDate.Year);
}
@@ -102,8 +121,8 @@ OUString NumberFormatterWrapper::getFormattedString( sal_Int32 nNumberFormatKey,
nMonth = rDate.GetMonth();
nDay = rDate.GetDay();
util::Date aNewNullDate;
- m_aNullDate >>= aNewNullDate;
- m_pNumberFormatter->ChangeNullDate(aNewNullDate.Day,aNewNullDate.Month,aNewNullDate.Year);
+ if (getDate(m_aNullDate, aNewNullDate))
+ m_pNumberFormatter->ChangeNullDate(aNewNullDate.Day,aNewNullDate.Month,aNewNullDate.Year);
}
// tdf#130969: use UNLIMITED_PRECISION in case of GENERAL Number Format
if( m_pNumberFormatter->GetStandardPrec() != SvNumberFormatter::UNLIMITED_PRECISION )
diff --git a/chart2/source/tools/OPropertySet.cxx b/chart2/source/tools/OPropertySet.cxx
index 252cfb605be1..29e7298974da 100644
--- a/chart2/source/tools/OPropertySet.cxx
+++ b/chart2/source/tools/OPropertySet.cxx
@@ -18,10 +18,12 @@
*/
#include <OPropertySet.hxx>
-#include "ImplOPropertySet.hxx"
+#include <CloneHelper.hxx>
#include <cppuhelper/queryinterface.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/style/XStyle.hpp>
-#include <vector>
+#include <algorithm>
#include <memory>
using namespace ::com::sun::star;
@@ -38,26 +40,41 @@ using ::cppu::OPropertySetHelper;
namespace property
{
-OPropertySet::OPropertySet( ::osl::Mutex & par_rMutex ) :
- OBroadcastHelper( par_rMutex ),
+OPropertySet::OPropertySet( ) :
+ OBroadcastHelper( m_aMutex ),
// the following causes a warning; there seems to be no way to avoid it
OPropertySetHelper( static_cast< OBroadcastHelper & >( *this )),
- m_rMutex( par_rMutex ),
- m_pImplProperties( new impl::ImplOPropertySet() ),
m_bSetNewValuesExplicitlyEvenIfTheyEqualDefault(false)
{
}
-OPropertySet::OPropertySet( const OPropertySet & rOther, ::osl::Mutex & par_rMutex ) :
- OBroadcastHelper( par_rMutex ),
+OPropertySet::OPropertySet( const OPropertySet & rOther ) :
+ OBroadcastHelper( m_aMutex ),
// the following causes a warning; there seems to be no way to avoid it
OPropertySetHelper( static_cast< OBroadcastHelper & >( *this )),
- m_rMutex( par_rMutex ),
+ css::lang::XTypeProvider(),
+ css::beans::XPropertyState(),
+ css::beans::XMultiPropertyStates(),
+ css::style::XStyleSupplier(),
m_bSetNewValuesExplicitlyEvenIfTheyEqualDefault(false)
{
- MutexGuard aGuard( m_rMutex );
- if (rOther.m_pImplProperties)
- m_pImplProperties.reset(new impl::ImplOPropertySet(*rOther.m_pImplProperties));
+ MutexGuard aGuard( m_aMutex );
+
+ m_aProperties = rOther.m_aProperties;
+
+ // clone interface properties
+ for(auto& rProp : m_aProperties)
+ {
+ if( rProp.second.hasValue() &&
+ rProp.second.getValueType().getTypeClass() == uno::TypeClass_INTERFACE )
+ {
+ Reference< util::XCloneable > xCloneable;
+ if( rProp.second >>= xCloneable )
+ rProp.second <<= xCloneable->createClone();
+ }
+ }
+
+ m_xStyle.set( ::chart::CloneHelper::CreateRefClone< style::XStyle >()( rOther.m_xStyle ));
}
void OPropertySet::SetNewValuesExplicitlyEvenIfTheyEqualDefault()
@@ -109,7 +126,7 @@ beans::PropertyState SAL_CALL
{
cppu::IPropertyArrayHelper & rPH = getInfoHelper();
- return m_pImplProperties->GetPropertyStateByHandle(
+ return GetPropertyStateByHandle(
rPH.getHandleByName( PropertyName ));
}
@@ -124,7 +141,7 @@ Sequence< beans::PropertyState > SAL_CALL
std::vector< sal_Int32 > aHandles( pHandles.get(), pHandles.get() + aPropertyName.getLength());
pHandles.reset();
- return m_pImplProperties->GetPropertyStatesByHandle( aHandles );
+ return GetPropertyStatesByHandle( aHandles );
}
void SAL_CALL
@@ -132,7 +149,7 @@ void SAL_CALL
{
cppu::IPropertyArrayHelper & rPH = getInfoHelper();
- m_pImplProperties->SetPropertyToDefault( rPH.getHandleByName( PropertyName ));
+ SetPropertyToDefault( rPH.getHandleByName( PropertyName ));
firePropertyChangeEvent();
}
@@ -141,7 +158,9 @@ Any SAL_CALL
{
cppu::IPropertyArrayHelper & rPH = getInfoHelper();
- return GetDefaultValue( rPH.getHandleByName( aPropertyName ) );
+ Any any;
+ GetDefaultValue( rPH.getHandleByName( aPropertyName ), any );
+ return any;
}
// ____ XMultiPropertyStates ____
@@ -152,7 +171,7 @@ Any SAL_CALL
void SAL_CALL
OPropertySet::setAllPropertiesToDefault()
{
- m_pImplProperties->SetAllPropertiesToDefault();
+ SetAllPropertiesToDefault();
firePropertyChangeEvent();
}
@@ -167,7 +186,7 @@ void SAL_CALL
std::vector< sal_Int32 > aHandles( pHandles.get(), pHandles.get() + aPropertyNames.getLength());
pHandles.reset();
- m_pImplProperties->SetPropertiesToDefault( aHandles );
+ SetPropertiesToDefault( aHandles );
}
Sequence< Any > SAL_CALL
@@ -182,8 +201,9 @@ Sequence< Any > SAL_CALL
for( ; nI < nElements; ++nI )
{
- pResultArray[ nI ] = GetDefaultValue(
- rPH.getHandleByName( aPropertyNames[ nI ] ));
+ GetDefaultValue(
+ rPH.getHandleByName( aPropertyNames[ nI ] ),
+ pResultArray[ nI ]);
}
return aResult;
@@ -240,28 +260,27 @@ void SAL_CALL OPropertySet::setFastPropertyValue_NoBroadcast
Any aDefault;
try
{
- aDefault = GetDefaultValue( nHandle );
+ GetDefaultValue( nHandle, aDefault );
}
catch( const beans::UnknownPropertyException& )
{
aDefault.clear();
}
- m_pImplProperties->SetPropertyValueByHandle( nHandle, rValue );
if( !m_bSetNewValuesExplicitlyEvenIfTheyEqualDefault && aDefault.hasValue() && aDefault == rValue ) //#i98893# don't export defaults to file
- m_pImplProperties->SetPropertyToDefault( nHandle );
+ SetPropertyToDefault( nHandle );
else
- m_pImplProperties->SetPropertyValueByHandle( nHandle, rValue );
+ SetPropertyValueByHandle( nHandle, rValue );
}
void SAL_CALL OPropertySet::getFastPropertyValue
( Any& rValue,
sal_Int32 nHandle ) const
{
- if( m_pImplProperties->GetPropertyValueByHandle( rValue, nHandle ))
+ if( GetPropertyValueByHandle( rValue, nHandle ))
return;
// property was not set -> try style
- uno::Reference< beans::XFastPropertySet > xStylePropSet( m_pImplProperties->GetStyle(), uno::UNO_QUERY );
+ uno::Reference< beans::XFastPropertySet > xStylePropSet( m_xStyle, uno::UNO_QUERY );
if( xStylePropSet.is() )
{
#ifdef DBG_UTIL
@@ -321,7 +340,7 @@ void SAL_CALL OPropertySet::getFastPropertyValue
// => take the default value
try
{
- rValue = GetDefaultValue( nHandle );
+ GetDefaultValue( nHandle, rValue );
}
catch( const beans::UnknownPropertyException& )
{
@@ -338,12 +357,12 @@ void OPropertySet::firePropertyChangeEvent()
// ____ XStyleSupplier ____
Reference< style::XStyle > SAL_CALL OPropertySet::getStyle()
{
- return m_pImplProperties->GetStyle();
+ return m_xStyle;
}
void SAL_CALL OPropertySet::setStyle( const Reference< style::XStyle >& xStyle )
{
- if( ! m_pImplProperties->SetStyle( xStyle ))
+ if( ! SetStyle( xStyle ))
throw lang::IllegalArgumentException(
"Empty Style",
static_cast< beans::XPropertySet * >( this ),
@@ -367,6 +386,80 @@ void SAL_CALL OPropertySet::setFastPropertyValue( sal_Int32 nHandle, const Any&
firePropertyChangeEvent();
}
+beans::PropertyState OPropertySet::GetPropertyStateByHandle( sal_Int32 nHandle ) const
+{
+ if( m_aProperties.end() == m_aProperties.find( nHandle ))
+ return beans::PropertyState_DEFAULT_VALUE;
+ return beans::PropertyState_DIRECT_VALUE;
+}
+
+Sequence< beans::PropertyState > OPropertySet::GetPropertyStatesByHandle(
+ const std::vector< sal_Int32 > & aHandles ) const
+{
+ Sequence< beans::PropertyState > aResult( aHandles.size());
+
+ std::transform( aHandles.begin(), aHandles.end(),
+ aResult.getArray(),
+ [this](sal_Int32 nHandle) { return GetPropertyStateByHandle(nHandle); });
+
+ return aResult;
+}
+
+void OPropertySet::SetPropertyToDefault( sal_Int32 nHandle )
+{
+ auto aFoundIter( m_aProperties.find( nHandle ) );
+
+ if( m_aProperties.end() != aFoundIter )
+ {
+ m_aProperties.erase( aFoundIter );
+ }
+}
+
+void OPropertySet::SetPropertiesToDefault(
+ const std::vector< sal_Int32 > & aHandles )
+{
+ for(auto nHandle : aHandles)
+ m_aProperties.erase(nHandle);
+}
+
+void OPropertySet::SetAllPropertiesToDefault()
+{
+ m_aProperties.clear();
+}
+
+bool OPropertySet::GetPropertyValueByHandle(
+ Any & rValue,
+ sal_Int32 nHandle ) const
+{
+ bool bResult = false;
+
+ auto aFoundIter( m_aProperties.find( nHandle ) );
+
+ if( m_aProperties.end() != aFoundIter )
+ {
+ rValue = (*aFoundIter).second;
+ bResult = true;
+ }
+
+ return bResult;
+}
+
+void OPropertySet::SetPropertyValueByHandle(
+ sal_Int32 nHandle, const Any & rValue )
+{
+ m_aProperties[ nHandle ] = rValue;
+}
+
+bool OPropertySet::SetStyle( const Reference< style::XStyle > & xStyle )
+{
+ if( ! xStyle.is())
+ return false;
+
+ m_xStyle = xStyle;
+ return true;
+}
+
+
} // namespace property
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx
index c2979f13f5b3..d5b2f068c8a0 100644
--- a/chart2/source/tools/ObjectIdentifier.cxx
+++ b/chart2/source/tools/ObjectIdentifier.cxx
@@ -19,28 +19,31 @@
#include <sal/config.h>
+#include <cstddef>
#include <map>
#include <ObjectIdentifier.hxx>
#include <TitleHelper.hxx>
#include <ChartModel.hxx>
-#include <ChartModelHelper.hxx>
+#include <ChartType.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <servicenames_charttypes.hxx>
-#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
#include <unonames.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <DataSeries.hxx>
+#include <RegressionCurveModel.hxx>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
#include <com/sun/star/chart2/XAxis.hpp>
-#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/awt/Point.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <rtl/ustrbuf.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <o3tl/safeint.hxx>
+#include <o3tl/string_view.hxx>
+#include <utility>
namespace com::sun::star::drawing { class XShape; }
@@ -52,18 +55,18 @@ using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Any;
-const char m_aMultiClick[] = "MultiClick";
-const char m_aDragMethodEquals[] = "DragMethod=";
-const char m_aDragParameterEquals[] = "DragParameter=";
-const char m_aProtocol[] = "CID/";
-const OUString m_aPieSegmentDragMethodServiceName("PieSegmentDragging");
+constexpr OUString m_aMultiClick = u"MultiClick"_ustr;
+constexpr OUString m_aDragMethodEquals = u"DragMethod="_ustr;
+constexpr OUString m_aDragParameterEquals = u"DragParameter="_ustr;
+constexpr OUString m_aProtocol = u"CID/"_ustr;
+constexpr OUString m_aPieSegmentDragMethodServiceName(u"PieSegmentDragging"_ustr);
namespace
{
OUString lcl_createClassificationStringForType( ObjectType eObjectType
- , const OUString& rDragMethodServiceName
- , const OUString& rDragParameterString
+ , std::u16string_view rDragMethodServiceName
+ , std::u16string_view rDragParameterString
)
{
OUStringBuffer aRet;
@@ -81,19 +84,17 @@ OUString lcl_createClassificationStringForType( ObjectType eObjectType
default:
break;//empty string
}
- if( !rDragMethodServiceName.isEmpty() )
+ if( !rDragMethodServiceName.empty() )
{
if( !aRet.isEmpty() )
aRet.append(":");
- aRet.append( m_aDragMethodEquals );
- aRet.append( rDragMethodServiceName );
+ aRet.append( OUString::Concat(m_aDragMethodEquals) + rDragMethodServiceName );
- if( !rDragParameterString.isEmpty() )
+ if( !rDragParameterString.empty() )
{
if( !aRet.isEmpty() )
aRet.append(":");
- aRet.append( m_aDragParameterEquals );
- aRet.append( rDragParameterString );
+ aRet.append( OUString::Concat(m_aDragParameterEquals) + rDragParameterString );
}
}
return aRet.makeStringAndClear();
@@ -126,30 +127,20 @@ OUString lcl_getTitleParentParticle( TitleHelper::eTitleType aTitleType )
return aRet;
}
-Reference<XChartType> lcl_getFirstStockChartType( const Reference< frame::XModel >& xChartModel )
+rtl::Reference<ChartType> lcl_getFirstStockChartType( const rtl::Reference<::chart::ChartModel>& xChartModel )
{
- Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
+ rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() );
if(!xDiagram.is())
return nullptr;
//iterate through all coordinate systems
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( !xCooSysContainer.is())
- return nullptr;
- const uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( Reference< XCoordinateSystem > const & coords : aCooSysList )
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysList( xDiagram->getBaseCoordinateSystems() );
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysList )
{
//iterate through all chart types in the current coordinate system
- Reference< XChartTypeContainer > xChartTypeContainer( coords, uno::UNO_QUERY );
- if( !xChartTypeContainer.is() )
- continue;
-
- const uno::Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- for( Reference< XChartType > const & xChartType : aChartTypeList )
+ for( rtl::Reference< ChartType > const & xChartType : coords->getChartTypes2() )
{
- if(!xChartType.is())
- continue;
OUString aChartType = xChartType->getChartType();
if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
return xChartType;
@@ -158,107 +149,95 @@ Reference<XChartType> lcl_getFirstStockChartType( const Reference< frame::XModel
return nullptr;
}
-OUString lcl_getIndexStringAfterString( const OUString& rString, const OUString& rSearchString )
+std::u16string_view lcl_getIndexStringAfterString( std::u16string_view rString, std::u16string_view rSearchString )
{
- OUStringBuffer aRet;
-
- sal_Int32 nIndexStart = rString.lastIndexOf( rSearchString );
- if( nIndexStart != -1 )
- {
- nIndexStart += rSearchString.getLength();
- sal_Int32 nIndexEnd = rString.getLength();
- sal_Int32 nNextColon = rString.indexOf( ':', nIndexStart );
- if( nNextColon != -1 )
- nIndexEnd = nNextColon;
- aRet = rString.copy(nIndexStart,nIndexEnd-nIndexStart);
- }
-
- return aRet.makeStringAndClear();
+ size_t nIndexStart = rString.rfind( rSearchString );
+ if( nIndexStart == std::u16string_view::npos )
+ return std::u16string_view();
+ nIndexStart += rSearchString.size();
+ size_t nIndexEnd = rString.size();
+ size_t nNextColon = rString.find( ':', nIndexStart );
+ if( nNextColon != std::u16string_view::npos )
+ nIndexEnd = nNextColon;
+ return rString.substr(nIndexStart,nIndexEnd-nIndexStart);
}
-sal_Int32 lcl_StringToIndex( const OUString& rIndexString )
+sal_Int32 lcl_StringToIndex( std::u16string_view rIndexString )
{
sal_Int32 nRet = -1;
- if( !rIndexString.isEmpty() )
+ if( !rIndexString.empty() )
{
- nRet = rIndexString.toInt32();
+ nRet = o3tl::toInt32(rIndexString);
if( nRet < -1 )
nRet = -1;
}
return nRet;
}
-void lcl_parseCooSysIndices( sal_Int32& rnDiagram, sal_Int32& rnCooSys, const OUString& rString )
+void lcl_parseCooSysIndices( sal_Int32& rnDiagram, sal_Int32& rnCooSys, std::u16string_view rString )
{
- rnDiagram = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, "D=" ) );
- rnCooSys = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, "CS=" ) );
+ rnDiagram = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, u"D=" ) );
+ rnCooSys = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, u"CS=" ) );
}
-void lcl_parseAxisIndices( sal_Int32& rnDimensionIndex, sal_Int32& rnAxisIndex, const OUString& rString )
+void lcl_parseAxisIndices( sal_Int32& rnDimensionIndex, sal_Int32& rnAxisIndex, std::u16string_view rString )
{
- OUString aAxisIndexString = lcl_getIndexStringAfterString( rString, ":Axis=" );
+ std::u16string_view aAxisIndexString = lcl_getIndexStringAfterString( rString, u":Axis=" );
sal_Int32 nCharacterIndex=0;
- rnDimensionIndex = lcl_StringToIndex( aAxisIndexString.getToken( 0, ',', nCharacterIndex ) );
- rnAxisIndex = lcl_StringToIndex( aAxisIndexString.getToken( 0, ',', nCharacterIndex ) );
+ rnDimensionIndex = lcl_StringToIndex( o3tl::getToken(aAxisIndexString, 0, ',', nCharacterIndex ) );
+ rnAxisIndex = lcl_StringToIndex( o3tl::getToken(aAxisIndexString, 0, ',', nCharacterIndex ) );
}
-void lcl_parseGridIndices( sal_Int32& rnSubGridIndex, const OUString& rString )
+void lcl_parseGridIndices( sal_Int32& rnSubGridIndex, std::u16string_view rString )
{
rnSubGridIndex = -1;
- rnSubGridIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, ":SubGrid=" ) );
+ rnSubGridIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, u":SubGrid=" ) );
}
-void lcl_parseSeriesIndices( sal_Int32& rnChartTypeIndex, sal_Int32& rnSeriesIndex, sal_Int32& rnPointIndex, const OUString& rString )
+void lcl_parseSeriesIndices( sal_Int32& rnChartTypeIndex, sal_Int32& rnSeriesIndex, sal_Int32& rnPointIndex, std::u16string_view rString )
{
- rnChartTypeIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, "CT=" ) );
- rnSeriesIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, "Series=" ) );
- rnPointIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, "Point=" ) );
+ rnChartTypeIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, u"CT=" ) );
+ rnSeriesIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, u"Series=" ) );
+ rnPointIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, u"Point=" ) );
}
-void lcl_getDiagramAndCooSys( const OUString& rObjectCID
- , const Reference< frame::XModel >& xChartModel
- , Reference< XDiagram >& xDiagram
- , Reference< XCoordinateSystem >& xCooSys )
+void lcl_getDiagramAndCooSys( std::u16string_view rObjectCID
+ , const rtl::Reference<::chart::ChartModel>& xChartModel
+ , rtl::Reference< Diagram >& xDiagram
+ , rtl::Reference< BaseCoordinateSystem >& xCooSys )
{
sal_Int32 nDiagramIndex = -1;
sal_Int32 nCooSysIndex = -1;
lcl_parseCooSysIndices( nDiagramIndex, nCooSysIndex, rObjectCID );
- xDiagram = ChartModelHelper::findDiagram( xChartModel );//todo use nDiagramIndex when more than one diagram is possible in future
+ xDiagram = xChartModel->getFirstChartDiagram();//todo use nDiagramIndex when more than one diagram is possible in future
if( !xDiagram.is() )
return;
if( nCooSysIndex > -1 )
{
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( xCooSysContainer.is() )
- {
- uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- if( nCooSysIndex < aCooSysList.getLength() )
- xCooSys = aCooSysList[nCooSysIndex];
- }
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysList( xDiagram->getBaseCoordinateSystems() );
+ if( o3tl::make_unsigned(nCooSysIndex) < aCooSysList.size() )
+ xCooSys = aCooSysList[nCooSysIndex];
}
}
} //anonymous namespace
ObjectIdentifier::ObjectIdentifier()
- :m_aObjectCID( OUString() )
{
}
-ObjectIdentifier::ObjectIdentifier( const OUString& rObjectCID )
- :m_aObjectCID( rObjectCID )
+ObjectIdentifier::ObjectIdentifier( OUString aObjectCID )
+ :m_aObjectCID(std::move( aObjectCID ))
{
}
ObjectIdentifier::ObjectIdentifier( const Reference< drawing::XShape >& rxShape )
- :m_aObjectCID( OUString() )
- ,m_xAdditionalShape( rxShape )
+ : m_xAdditionalShape( rxShape )
{
}
ObjectIdentifier::ObjectIdentifier( const Any& rAny )
- :m_aObjectCID( OUString() )
{
const uno::Type& rType = rAny.getValueType();
if ( rType == cppu::UnoType<OUString>::get() )
@@ -277,11 +256,6 @@ bool ObjectIdentifier::operator==( const ObjectIdentifier& rOID ) const
( m_xAdditionalShape == rOID.m_xAdditionalShape );
}
-bool ObjectIdentifier::operator!=( const ObjectIdentifier& rOID ) const
-{
- return !operator==( rOID );
-}
-
bool ObjectIdentifier::operator<( const ObjectIdentifier& rOID ) const
{
bool bReturn = false;
@@ -305,41 +279,55 @@ bool ObjectIdentifier::operator<( const ObjectIdentifier& rOID ) const
}
OUString ObjectIdentifier::createClassifiedIdentifierForObject(
+ const rtl::Reference< ::chart::Title >& xTitle
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
+{
+ TitleHelper::eTitleType aTitleType;
+ OUString aRet;
+ const std::u16string_view aObjectID;
+ const std::u16string_view aDragMethodServiceName;
+ const std::u16string_view aDragParameterString;
+ if( TitleHelper::getTitleType( aTitleType, xTitle, xChartModel ) )
+ {
+ enum ObjectType eObjectType = OBJECTTYPE_TITLE;
+ OUString aParentParticle = lcl_getTitleParentParticle( aTitleType );
+ aRet = ObjectIdentifier::createClassifiedIdentifierWithParent(
+ eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString );
+ }
+ return aRet;
+}
+
+OUString ObjectIdentifier::createClassifiedIdentifierForObject(
const Reference< uno::XInterface >& xObject
- , ChartModel& rModel)
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
OUString aRet;
enum ObjectType eObjectType = OBJECTTYPE_UNKNOWN;
- const OUString aObjectID;
+ const std::u16string_view aObjectID;
OUString aParentParticle;
- const OUString aDragMethodServiceName;
- const OUString aDragParameterString;
+ const std::u16string_view aDragMethodServiceName;
+ const std::u16string_view aDragParameterString;
try
{
//title
- Reference< XTitle > xTitle( xObject, uno::UNO_QUERY );
- if( xTitle.is() )
- {
- TitleHelper::eTitleType aTitleType;
- if( TitleHelper::getTitleType( aTitleType, xTitle, rModel ) )
- {
- eObjectType = OBJECTTYPE_TITLE;
- aParentParticle = lcl_getTitleParentParticle( aTitleType );
- aRet = ObjectIdentifier::createClassifiedIdentifierWithParent(
- eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString );
- }
- return aRet;
+ if( ::chart::Title* pTitle = dynamic_cast<::chart::Title*>(xObject.get()) )
+ return createClassifiedIdentifierForObject(rtl::Reference<Title>(pTitle), xChartModel);
+ uno::Reference<chart2::XDataTable> xDataTable(xObject, uno::UNO_QUERY);
+ if (xDataTable.is())
+ {
+ return createClassifiedIdentifierForParticle(createParticleForDataTable(xChartModel));
}
//axis
- Reference< XAxis > xAxis( xObject, uno::UNO_QUERY );
+ rtl::Reference< Axis > xAxis = dynamic_cast<Axis*>( xObject.get() );
if( xAxis.is() )
{
- Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, rModel.getFirstDiagram() ) );
- OUString aCooSysParticle( createParticleForCoordinateSystem( xCooSys, rModel ) );
+ rtl::Reference<Diagram> xDiagram = xChartModel->getFirstChartDiagram();
+ rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, xDiagram ) );
+ OUString aCooSysParticle( createParticleForCoordinateSystem( xCooSys, xChartModel ) );
sal_Int32 nDimensionIndex=-1;
sal_Int32 nAxisIndex=-1;
AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex );
@@ -351,7 +339,7 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject(
Reference< XLegend > xLegend( xObject, uno::UNO_QUERY );
if( xLegend.is() )
{
- return createClassifiedIdentifierForParticle( createParticleForLegend( rModel ) );
+ return createClassifiedIdentifierForParticle( createParticleForLegend( xChartModel ) );
}
//diagram
@@ -387,40 +375,37 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject(
}
OUString ObjectIdentifier::createClassifiedIdentifierForObject(
- const Reference< uno::XInterface >& xObject
- , const Reference< frame::XModel >& xChartModel )
+ const rtl::Reference< Legend >& xLegend
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
- OUString aRet;
-
- enum ObjectType eObjectType = OBJECTTYPE_UNKNOWN;
- const OUString aObjectID;
- OUString aParentParticle;
- const OUString aDragMethodServiceName;
- const OUString aDragParameterString;
-
try
{
- //title
- Reference< XTitle > xTitle( xObject, uno::UNO_QUERY );
- if( xTitle.is() )
+ if( xLegend.is() )
{
- TitleHelper::eTitleType aTitleType;
- if( TitleHelper::getTitleType( aTitleType, xTitle, xChartModel ) )
- {
- eObjectType = OBJECTTYPE_TITLE;
- aParentParticle = lcl_getTitleParentParticle( aTitleType );
- aRet = ObjectIdentifier::createClassifiedIdentifierWithParent(
- eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString );
- }
- return aRet;
-
+ return createClassifiedIdentifierForParticle( createParticleForLegend( xChartModel ) );
}
+ }
+ catch(const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
+ return OUString();
+}
+
+OUString ObjectIdentifier::createClassifiedIdentifierForObject(
+ const rtl::Reference<::chart::Axis>& xAxis
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
+{
+ try
+ {
//axis
- Reference< XAxis > xAxis( xObject, uno::UNO_QUERY );
if( xAxis.is() )
{
- Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ) ) );
+ rtl::Reference<Diagram> xDiagram = xChartModel->getFirstChartDiagram();
+ rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, xDiagram ) );
OUString aCooSysParticle( createParticleForCoordinateSystem( xCooSys, xChartModel ) );
sal_Int32 nDimensionIndex=-1;
sal_Int32 nAxisIndex=-1;
@@ -428,71 +413,42 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject(
OUString aAxisParticle( createParticleForAxis( nDimensionIndex, nAxisIndex ) );
return createClassifiedIdentifierForParticles( aCooSysParticle, aAxisParticle );
}
-
- //legend
- Reference< XLegend > xLegend( xObject, uno::UNO_QUERY );
- if( xLegend.is() )
- {
- return createClassifiedIdentifierForParticle( createParticleForLegend( xChartModel ) );
- }
-
- //diagram
- Reference< XDiagram > xDiagram( xObject, uno::UNO_QUERY );
- if( xDiagram.is() )
- {
- return createClassifiedIdentifierForParticle( createParticleForDiagram() );
- }
-
- //todo
- //XDataSeries
- //CooSys
- //charttype
- //datapoint?
- //Gridproperties
}
catch(const uno::Exception&)
{
DBG_UNHANDLED_EXCEPTION("chart2");
}
- if( eObjectType != OBJECTTYPE_UNKNOWN )
- {
- aRet = ObjectIdentifier::createClassifiedIdentifierWithParent(
- eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString );
- }
- else
- {
- OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
- }
+ OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
- return aRet;
+ return OUString();
}
OUString ObjectIdentifier::createClassifiedIdentifierForParticle(
- const OUString& rParticle )
+ std::u16string_view rParticle )
{
- return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle, OUString() );
+ return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle, u"" );
}
OUString ObjectIdentifier::createClassifiedIdentifierForParticles(
- const OUString& rParentParticle
- , const OUString& rChildParticle
- , const OUString& rDragMethodServiceName
- , const OUString& rDragParameterString )
+ std::u16string_view rParentParticle
+ , std::u16string_view rChildParticle
+ , std::u16string_view rDragMethodServiceName
+ , std::u16string_view rDragParameterString )
{
ObjectType eObjectType( ObjectIdentifier::getObjectType( rChildParticle ) );
if( eObjectType == OBJECTTYPE_UNKNOWN )
eObjectType = ObjectIdentifier::getObjectType( rParentParticle );
- OUStringBuffer aRet( m_aProtocol );
- aRet.append( lcl_createClassificationStringForType( eObjectType, rDragMethodServiceName, rDragParameterString ));
- if(aRet.getLength() > static_cast<sal_Int32>(strlen(m_aProtocol)))
+ OUStringBuffer aRet( m_aProtocol +
+ lcl_createClassificationStringForType( eObjectType, rDragMethodServiceName, rDragParameterString ));
+ if(aRet.getLength() > m_aProtocol.getLength())
aRet.append("/");
- if(!rParentParticle.isEmpty())
+ if(!rParentParticle.empty())
{
aRet.append(rParentParticle);
- if( !rChildParticle.isEmpty() )
+ if( !rChildParticle.empty() )
aRet.append(":");
}
aRet.append(rChildParticle);
@@ -507,59 +463,27 @@ OUString ObjectIdentifier::createParticleForDiagram()
}
OUString ObjectIdentifier::createParticleForCoordinateSystem(
- const Reference< XCoordinateSystem >& xCooSys
- , ChartModel& rModel )
-{
- OUStringBuffer aRet;
-
- Reference< XDiagram > xDiagram( rModel.getFirstDiagram() );
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( xCooSysContainer.is() )
- {
- sal_Int32 nCooSysIndex = 0;
- uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( ; nCooSysIndex < aCooSysList.getLength(); ++nCooSysIndex )
- {
- Reference< XCoordinateSystem > xCurrentCooSys( aCooSysList[nCooSysIndex] );
- if( xCooSys == xCurrentCooSys )
- {
- aRet = ObjectIdentifier::createParticleForDiagram();
- aRet.append(":CS=");
- aRet.append( OUString::number( nCooSysIndex ) );
- break;
- }
- }
- }
-
- return aRet.makeStringAndClear();
-}
-
-OUString ObjectIdentifier::createParticleForCoordinateSystem(
- const Reference< XCoordinateSystem >& xCooSys
- , const Reference< frame::XModel >& xChartModel )
+ const rtl::Reference< BaseCoordinateSystem >& xCooSys
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
- OUStringBuffer aRet;
+ OUString aRet;
- Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
- Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( xCooSysContainer.is() )
+ rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() );
+ if( xDiagram.is() )
{
- sal_Int32 nCooSysIndex = 0;
- uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( ; nCooSysIndex < aCooSysList.getLength(); ++nCooSysIndex )
+ std::size_t nCooSysIndex = 0;
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysList( xDiagram->getBaseCoordinateSystems() );
+ for( ; nCooSysIndex < aCooSysList.size(); ++nCooSysIndex )
{
- Reference< XCoordinateSystem > xCurrentCooSys( aCooSysList[nCooSysIndex] );
- if( xCooSys == xCurrentCooSys )
+ if( xCooSys == aCooSysList[nCooSysIndex] )
{
- aRet = ObjectIdentifier::createParticleForDiagram();
- aRet.append(":CS=");
- aRet.append( OUString::number( nCooSysIndex ) );
+ aRet = ObjectIdentifier::createParticleForDiagram() + ":CS=" + OUString::number( nCooSysIndex );
break;
}
}
}
- return aRet.makeStringAndClear();
+ return aRet;
}
OUString ObjectIdentifier::createParticleForAxis(
@@ -584,7 +508,7 @@ OUString ObjectIdentifier::createParticleForGrid(
OUString ObjectIdentifier::createClassifiedIdentifierForGrid(
const Reference< XAxis >& xAxis
- , const Reference< frame::XModel >& xChartModel
+ , const rtl::Reference<::chart::ChartModel>& xChartModel
, sal_Int32 nSubGridIndex )
{
//-1: main grid, 0: first subgrid etc
@@ -604,81 +528,56 @@ OUString ObjectIdentifier::createParticleForSeries(
sal_Int32 nDiagramIndex, sal_Int32 nCooSysIndex
, sal_Int32 nChartTypeIndex, sal_Int32 nSeriesIndex )
{
- OUStringBuffer aRet;
-
- aRet.append("D=");
- aRet.append( OUString::number( nDiagramIndex ) );
- aRet.append(":CS=");
- aRet.append( OUString::number( nCooSysIndex ) );
- aRet.append(":CT=");
- aRet.append( OUString::number( nChartTypeIndex ) );
- aRet.append(":");
- aRet.append(getStringForType( OBJECTTYPE_DATA_SERIES ));
- aRet.append("=");
- aRet.append( OUString::number( nSeriesIndex ) );
-
- return aRet.makeStringAndClear();
+ return
+ "D=" + OUString::number( nDiagramIndex ) +
+ ":CS=" + OUString::number( nCooSysIndex ) +
+ ":CT=" + OUString::number( nChartTypeIndex ) +
+ ":" + getStringForType( OBJECTTYPE_DATA_SERIES ) + "=" +
+ OUString::number( nSeriesIndex );
}
-OUString ObjectIdentifier::createParticleForLegend( ChartModel& )
-{
- OUStringBuffer aRet;
-
- //todo: if more than one diagram is implemented, find the correct diagram which is owner of the given legend
-
- aRet.append( ObjectIdentifier::createParticleForDiagram() );
- aRet.append(":");
- aRet.append(getStringForType( OBJECTTYPE_LEGEND ));
- aRet.append("=");
-
- return aRet.makeStringAndClear();
-}
OUString ObjectIdentifier::createParticleForLegend(
- const Reference< frame::XModel >& )
+ const rtl::Reference<::chart::ChartModel>& )
{
- OUStringBuffer aRet;
-
//todo: if more than one diagram is implemented, find the correct diagram which is owner of the given legend
- aRet.append( ObjectIdentifier::createParticleForDiagram() );
- aRet.append(":");
- aRet.append(getStringForType( OBJECTTYPE_LEGEND ));
- aRet.append("=");
+ return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType( OBJECTTYPE_LEGEND ) + "=";
+}
- return aRet.makeStringAndClear();
+OUString ObjectIdentifier::createParticleForDataTable(const rtl::Reference<::chart::ChartModel>& /* xChartModel */)
+{
+ return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType(OBJECTTYPE_DATA_TABLE) + "=";
}
OUString ObjectIdentifier::createClassifiedIdentifier(
enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_SERIES
- , const OUString& rParticleID )//e.g. SeriesID
+ , std::u16string_view rParticleID )//e.g. SeriesID
{
return createClassifiedIdentifierWithParent(
- eObjectType, rParticleID, OUString() );
+ eObjectType, rParticleID, u"" );
}
OUString ObjectIdentifier::createClassifiedIdentifierWithParent(
enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID
- , const OUString& rParticleID //e.g. Point Index or SubGrid Index
- , const OUString& rParentPartical //e.g. "Series=SeriesID" or "Grid=GridId"
- , const OUString& rDragMethodServiceName
- , const OUString& rDragParameterString
+ , std::u16string_view rParticleID //e.g. Point Index or SubGrid Index
+ , std::u16string_view rParentPartical //e.g. "Series=SeriesID" or "Grid=GridId"
+ , std::u16string_view rDragMethodServiceName
+ , std::u16string_view rDragParameterString
)
//, bool bIsMultiClickObject ) //e.g. true
{
//e.g. "MultiClick/Series=2:Point=34"
- OUStringBuffer aRet( m_aProtocol );
- aRet.append( lcl_createClassificationStringForType( eObjectType, rDragMethodServiceName, rDragParameterString ));
- if(aRet.getLength() > static_cast<sal_Int32>(strlen(m_aProtocol)))
+ OUStringBuffer aRet( m_aProtocol +
+ lcl_createClassificationStringForType( eObjectType, rDragMethodServiceName, rDragParameterString ));
+ if(aRet.getLength() > m_aProtocol.getLength())
aRet.append("/");
aRet.append(rParentPartical);
- if(!rParentPartical.isEmpty())
+ if(!rParentPartical.empty())
aRet.append(":");
- aRet.append(getStringForType( eObjectType ));
- aRet.append("=");
- aRet.append(rParticleID);
+ aRet.append(getStringForType( eObjectType ) + "=" + rParticleID);
return aRet.makeStringAndClear();
}
@@ -702,89 +601,89 @@ OUString ObjectIdentifier::createPieSegmentDragParameterString(
}
bool ObjectIdentifier::parsePieSegmentDragParameterString(
- const OUString& rDragParameterString
+ std::u16string_view rDragParameterString
, sal_Int32& rOffsetPercent
, awt::Point& rMinimumPosition
, awt::Point& rMaximumPosition )
{
sal_Int32 nCharacterIndex = 0;
- OUString aValueString( rDragParameterString.getToken( 0, ',', nCharacterIndex ) );
- rOffsetPercent = aValueString.toInt32();
+ std::u16string_view aValueString( o3tl::getToken(rDragParameterString, 0, ',', nCharacterIndex ) );
+ rOffsetPercent = o3tl::toInt32(aValueString);
if( nCharacterIndex < 0 )
return false;
- aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
- rMinimumPosition.X = aValueString.toInt32();
+ aValueString = o3tl::getToken(rDragParameterString, 0, ',', nCharacterIndex );
+ rMinimumPosition.X = o3tl::toInt32(aValueString);
if( nCharacterIndex < 0 )
return false;
- aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
- rMinimumPosition.Y = aValueString.toInt32();
+ aValueString = o3tl::getToken(rDragParameterString, 0, ',', nCharacterIndex );
+ rMinimumPosition.Y = o3tl::toInt32(aValueString);
if( nCharacterIndex < 0 )
return false;
- aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
- rMaximumPosition.X = aValueString.toInt32();
+ aValueString = o3tl::getToken(rDragParameterString, 0, ',', nCharacterIndex );
+ rMaximumPosition.X = o3tl::toInt32(aValueString);
if( nCharacterIndex < 0 )
return false;
- aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
- rMaximumPosition.Y = aValueString.toInt32();
+ aValueString = o3tl::getToken(rDragParameterString, 0, ',', nCharacterIndex );
+ rMaximumPosition.Y = o3tl::toInt32(aValueString);
return nCharacterIndex >= 0;
}
-OUString ObjectIdentifier::getDragMethodServiceName( const OUString& rCID )
+std::u16string_view ObjectIdentifier::getDragMethodServiceName( std::u16string_view rCID )
{
- OUString aRet;
+ std::u16string_view aRet;
- sal_Int32 nIndexStart = rCID.indexOf( m_aDragMethodEquals );
- if( nIndexStart != -1 )
+ size_t nIndexStart = rCID.find( m_aDragMethodEquals );
+ if( nIndexStart != std::u16string_view::npos )
{
- nIndexStart = rCID.indexOf( '=', nIndexStart );
- if( nIndexStart != -1 )
+ nIndexStart = rCID.find( '=', nIndexStart );
+ if( nIndexStart != std::u16string_view::npos )
{
nIndexStart++;
- sal_Int32 nNextSlash = rCID.indexOf( '/', nIndexStart );
- if( nNextSlash != -1 )
+ size_t nNextSlash = rCID.find( '/', nIndexStart );
+ if( nNextSlash != std::u16string_view::npos )
{
sal_Int32 nIndexEnd = nNextSlash;
- sal_Int32 nNextColon = rCID.indexOf( ':', nIndexStart );
- if( nNextColon < nNextSlash )
+ size_t nNextColon = rCID.find( ':', nIndexStart );
+ if( nNextColon == std::u16string_view::npos || nNextColon < nNextSlash )
nIndexEnd = nNextColon;
- aRet = rCID.copy(nIndexStart,nIndexEnd-nIndexStart);
+ aRet = rCID.substr(nIndexStart,nIndexEnd-nIndexStart);
}
}
}
return aRet;
}
-OUString ObjectIdentifier::getDragParameterString( const OUString& rCID )
+std::u16string_view ObjectIdentifier::getDragParameterString( std::u16string_view rCID )
{
- OUString aRet;
+ std::u16string_view aRet;
- sal_Int32 nIndexStart = rCID.indexOf( m_aDragParameterEquals );
- if( nIndexStart != -1 )
+ size_t nIndexStart = rCID.find( m_aDragParameterEquals );
+ if( nIndexStart != std::u16string_view::npos )
{
- nIndexStart = rCID.indexOf( '=', nIndexStart );
- if( nIndexStart != -1 )
+ nIndexStart = rCID.find( '=', nIndexStart );
+ if( nIndexStart != std::u16string_view::npos )
{
nIndexStart++;
- sal_Int32 nNextSlash = rCID.indexOf( '/', nIndexStart );
- if( nNextSlash != -1 )
+ size_t nNextSlash = rCID.find( '/', nIndexStart );
+ if( nNextSlash != std::u16string_view::npos )
{
sal_Int32 nIndexEnd = nNextSlash;
- sal_Int32 nNextColon = rCID.indexOf( ':', nIndexStart );
- if( nNextColon < nNextSlash )
+ size_t nNextColon = rCID.find( ':', nIndexStart );
+ if( nNextColon == std::u16string_view::npos || nNextColon < nNextSlash )
nIndexEnd = nNextColon;
- aRet = rCID.copy(nIndexStart,nIndexEnd-nIndexStart);
+ aRet = rCID.substr(nIndexStart,nIndexEnd-nIndexStart);
}
}
}
return aRet;
}
-bool ObjectIdentifier::isDragableObject( const OUString& rClassifiedIdentifier )
+bool ObjectIdentifier::isDragableObject( std::u16string_view rClassifiedIdentifier )
{
bool bReturn = false;
ObjectType eObjectType = ObjectIdentifier::getObjectType( rClassifiedIdentifier );
@@ -799,8 +698,8 @@ bool ObjectIdentifier::isDragableObject( const OUString& rClassifiedIdentifier )
bReturn = true;
break;
default:
- OUString aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( rClassifiedIdentifier ) );
- bReturn = !aDragMethodServiceName.isEmpty();
+ std::u16string_view aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( rClassifiedIdentifier ) );
+ bReturn = !aDragMethodServiceName.empty();
break;
}
return bReturn;
@@ -820,7 +719,7 @@ bool ObjectIdentifier::isDragableObject() const
return bReturn;
}
-bool ObjectIdentifier::isRotateableObject( const OUString& rClassifiedIdentifier )
+bool ObjectIdentifier::isRotateableObject( std::u16string_view rClassifiedIdentifier )
{
bool bReturn = false;
ObjectType eObjectType = ObjectIdentifier::getObjectType( rClassifiedIdentifier );
@@ -837,7 +736,7 @@ bool ObjectIdentifier::isRotateableObject( const OUString& rClassifiedIdentifier
return bReturn;
}
-bool ObjectIdentifier::isMultiClickObject( const OUString& rClassifiedIdentifier )
+bool ObjectIdentifier::isMultiClickObject( std::u16string_view rClassifiedIdentifier )
{
//the name of a shape is it's ClassifiedIdentifier
@@ -846,27 +745,27 @@ bool ObjectIdentifier::isMultiClickObject( const OUString& rClassifiedIdentifier
//was selected before;
//!!!!! by definition the name of a MultiClickObject starts with "CID/MultiClick:"
- bool bRet = rClassifiedIdentifier.match( m_aMultiClick, strlen(m_aProtocol) );
+ bool bRet = o3tl::starts_with(rClassifiedIdentifier.substr( m_aProtocol.getLength() ), m_aMultiClick);
return bRet;
}
-bool ObjectIdentifier::areSiblings( const OUString& rCID1, const OUString& rCID2 )
+bool ObjectIdentifier::areSiblings( std::u16string_view rCID1, std::u16string_view rCID2 )
{
bool bRet=false;
- sal_Int32 nLastSign1 = rCID1.lastIndexOf( '=' );
- sal_Int32 nLastSign2 = rCID2.lastIndexOf( '=' );
- if( nLastSign1 == rCID1.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs
+ size_t nLastSign1 = rCID1.rfind( '=' );
+ size_t nLastSign2 = rCID2.rfind( '=' );
+ if( nLastSign1 == rCID1.find( '=' ) )//CID cannot be sibling if only one "=" occurs
bRet=false;
- else if( nLastSign2 == rCID2.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs
+ else if( nLastSign2 == rCID2.find( '=' ) )//CID cannot be sibling if only one "=" occurs
bRet=false;
else if( ObjectIdentifier::areIdenticalObjects( rCID1, rCID2 ) )
bRet=false;
else
{
- OUString aParent1( ObjectIdentifier::getFullParentParticle( rCID1 ) );
- if( !aParent1.isEmpty() )
+ std::u16string_view aParent1( ObjectIdentifier::getFullParentParticle( rCID1 ) );
+ if( !aParent1.empty() )
{
- OUString aParent2( ObjectIdentifier::getFullParentParticle( rCID2 ) );
+ std::u16string_view aParent2( ObjectIdentifier::getFullParentParticle( rCID2 ) );
bRet=aParent1 == aParent2;
}
//legend entries are special:
@@ -880,14 +779,14 @@ bool ObjectIdentifier::areSiblings( const OUString& rCID1, const OUString& rCID2
return bRet;
}
-bool ObjectIdentifier::areIdenticalObjects( const OUString& rCID1, const OUString& rCID2 )
+bool ObjectIdentifier::areIdenticalObjects( std::u16string_view rCID1, std::u16string_view rCID2 )
{
if( rCID1 == rCID2 )
return true;
//draggable pie or donut segments need special treatment, as their CIDs do change with offset
{
- if( rCID1.indexOf( m_aPieSegmentDragMethodServiceName ) < 0
- || rCID2.indexOf( m_aPieSegmentDragMethodServiceName ) < 0 )
+ if( rCID1.find( m_aPieSegmentDragMethodServiceName ) == std::u16string_view::npos
+ || rCID2.find( m_aPieSegmentDragMethodServiceName ) == std::u16string_view::npos )
return false;
OUString aID1( ObjectIdentifier::getObjectID( rCID1 ) );
@@ -975,76 +874,82 @@ OUString ObjectIdentifier::getStringForType( ObjectType eObjectType )
case OBJECTTYPE_DATA_STOCK_GAIN:
aRet="StockGain";
break;
+ case OBJECTTYPE_DATA_TABLE:
+ aRet="DataTable";
+ break;
default: //OBJECTTYPE_UNKNOWN
;
}
return aRet;
}
-ObjectType ObjectIdentifier::getObjectType( const OUString& rCID )
+ObjectType ObjectIdentifier::getObjectType( std::u16string_view aCID )
{
ObjectType eRet;
- sal_Int32 nLastSign = rCID.lastIndexOf( ':' );//last sign before the type string
- if(nLastSign==-1)
- nLastSign = rCID.lastIndexOf( '/' );
- if(nLastSign==-1)
+ size_t nLastSign = aCID.rfind( ':' );//last sign before the type string
+ if(nLastSign == std::u16string_view::npos)
+ nLastSign = aCID.rfind( '/' );
+ if(nLastSign == std::u16string_view::npos)
{
- sal_Int32 nEndIndex = rCID.lastIndexOf( '=' );
- if(nEndIndex==-1)
+ size_t nEndIndex = aCID.rfind( '=' );
+ if(nEndIndex == std::u16string_view::npos)
return OBJECTTYPE_UNKNOWN;
nLastSign = 0;
}
if( nLastSign>0 )
nLastSign++;
- if( rCID.match("Page",nLastSign) )
+ aCID = aCID.substr(nLastSign);
+ if( o3tl::starts_with(aCID, u"Page") )
eRet = OBJECTTYPE_PAGE;
- else if( rCID.match("Title",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"Title") )
eRet = OBJECTTYPE_TITLE;
- else if( rCID.match("LegendEntry",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"LegendEntry") )
eRet = OBJECTTYPE_LEGEND_ENTRY;
- else if( rCID.match("Legend",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"Legend") )
eRet = OBJECTTYPE_LEGEND;
- else if( rCID.match("DiagramWall",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"DiagramWall") )
eRet = OBJECTTYPE_DIAGRAM_WALL;
- else if( rCID.match("DiagramFloor",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"DiagramFloor") )
eRet = OBJECTTYPE_DIAGRAM_FLOOR;
- else if( rCID.match("D=",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"D=") )
eRet = OBJECTTYPE_DIAGRAM;
- else if( rCID.match("AxisUnitLabel",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"AxisUnitLabel") )
eRet = OBJECTTYPE_AXIS_UNITLABEL;
- else if( rCID.match("Axis",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"Axis") )
eRet = OBJECTTYPE_AXIS;
- else if( rCID.match("Grid",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"Grid") )
eRet = OBJECTTYPE_GRID;
- else if( rCID.match("SubGrid",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"SubGrid") )
eRet = OBJECTTYPE_SUBGRID;
- else if( rCID.match("Series",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"Series") )
eRet = OBJECTTYPE_DATA_SERIES;
- else if( rCID.match("Point",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"Point") )
eRet = OBJECTTYPE_DATA_POINT;
- else if( rCID.match("DataLabels",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"DataLabels") )
eRet = OBJECTTYPE_DATA_LABELS;
- else if( rCID.match("DataLabel",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"DataLabel") )
eRet = OBJECTTYPE_DATA_LABEL;
- else if( rCID.match("ErrorsX",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"ErrorsX") )
eRet = OBJECTTYPE_DATA_ERRORS_X;
- else if( rCID.match("ErrorsY",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"ErrorsY") )
eRet = OBJECTTYPE_DATA_ERRORS_Y;
- else if( rCID.match("ErrorsZ",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"ErrorsZ") )
eRet = OBJECTTYPE_DATA_ERRORS_Z;
- else if( rCID.match("Curve",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"Curve") )
eRet = OBJECTTYPE_DATA_CURVE;
- else if( rCID.match("Equation",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"Equation") )
eRet = OBJECTTYPE_DATA_CURVE_EQUATION;
- else if( rCID.match("Average",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"Average") )
eRet = OBJECTTYPE_DATA_AVERAGE_LINE;
- else if( rCID.match("StockRange",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"StockRange") )
eRet = OBJECTTYPE_DATA_STOCK_RANGE;
- else if( rCID.match("StockLoss",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"StockLoss") )
eRet = OBJECTTYPE_DATA_STOCK_LOSS;
- else if( rCID.match("StockGain",nLastSign) )
+ else if( o3tl::starts_with(aCID, u"StockGain") )
eRet = OBJECTTYPE_DATA_STOCK_GAIN;
+ else if( o3tl::starts_with(aCID, u"DataTable") )
+ eRet = OBJECTTYPE_DATA_TABLE;
else
eRet = OBJECTTYPE_UNKNOWN;
@@ -1066,7 +971,7 @@ ObjectType ObjectIdentifier::getObjectType() const
}
OUString ObjectIdentifier::createDataCurveCID(
- const OUString& rSeriesParticle
+ std::u16string_view rSeriesParticle
, sal_Int32 nCurveIndex
, bool bAverageLine )
{
@@ -1076,20 +981,20 @@ OUString ObjectIdentifier::createDataCurveCID(
}
OUString ObjectIdentifier::createDataCurveEquationCID(
- const OUString& rSeriesParticle
+ std::u16string_view rSeriesParticle
, sal_Int32 nCurveIndex )
{
OUString aParticleID( OUString::number( nCurveIndex ) );
return createClassifiedIdentifierWithParent( OBJECTTYPE_DATA_CURVE_EQUATION, aParticleID, rSeriesParticle );
}
-OUString ObjectIdentifier::addChildParticle( const OUString& rParticle, const OUString& rChildParticle )
+OUString ObjectIdentifier::addChildParticle( std::u16string_view rParticle, std::u16string_view rChildParticle )
{
OUStringBuffer aRet(rParticle);
- if( !aRet.isEmpty() && !rChildParticle.isEmpty() )
+ if( !aRet.isEmpty() && !rChildParticle.empty() )
aRet.append(":");
- if( !rChildParticle.isEmpty() )
+ if( !rChildParticle.empty() )
aRet.append(rChildParticle);
return aRet.makeStringAndClear();
@@ -1100,22 +1005,21 @@ OUString ObjectIdentifier::createChildParticleWithIndex( ObjectType eObjectType,
OUStringBuffer aRet( getStringForType( eObjectType ) );
if( !aRet.isEmpty() )
{
- aRet.append("=");
- aRet.append(OUString::number(nIndex));
+ aRet.append("=" + OUString::number(nIndex));
}
return aRet.makeStringAndClear();
}
-sal_Int32 ObjectIdentifier::getIndexFromParticleOrCID( const OUString& rParticleOrCID )
+sal_Int32 ObjectIdentifier::getIndexFromParticleOrCID( std::u16string_view rParticleOrCID )
{
- const OUString aIndexString = lcl_getIndexStringAfterString( rParticleOrCID, "=" );
- return lcl_StringToIndex( aIndexString.getToken( 0, ',' ) );
+ const std::u16string_view aIndexString = lcl_getIndexStringAfterString( rParticleOrCID, u"=" );
+ return lcl_StringToIndex( o3tl::getToken(aIndexString, 0, ',' ) );
}
OUString ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType
- , const OUString& rSeriesParticle
- , const OUString& rDragMethodServiceName
- , const OUString& rDragParameterString )
+ , std::u16string_view rSeriesParticle
+ , std::u16string_view rDragMethodServiceName
+ , std::u16string_view rDragParameterString )
{
OUString aChildParticle = getStringForType( eSubObjectType ) + "=";
@@ -1124,72 +1028,64 @@ OUString ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType
, rDragMethodServiceName, rDragParameterString );
}
-OUString ObjectIdentifier::createPointCID( const OUString& rPointCID_Stub, sal_Int32 nIndex )
+OUString ObjectIdentifier::createPointCID( std::u16string_view rPointCID_Stub, sal_Int32 nIndex )
{
return rPointCID_Stub + OUString::number( nIndex );
}
-OUString ObjectIdentifier::getParticleID( const OUString& rCID )
+std::u16string_view ObjectIdentifier::getParticleID( std::u16string_view rCID )
{
- OUString aRet;
- sal_Int32 nLast = rCID.lastIndexOf('=');
- if(nLast>=0)
- aRet = rCID.copy(++nLast);
+ std::u16string_view aRet;
+ size_t nLast = rCID.rfind('=');
+ if(nLast != std::u16string_view::npos)
+ aRet = rCID.substr(++nLast);
return aRet;
}
-OUString ObjectIdentifier::getFullParentParticle( const OUString& rCID )
+std::u16string_view ObjectIdentifier::getFullParentParticle( std::u16string_view rCID )
{
- OUString aRet;
+ std::u16string_view aRet;
- sal_Int32 nStartPos = rCID.lastIndexOf('/');
- if( nStartPos>=0 )
+ size_t nStartPos = rCID.rfind('/');
+ if( nStartPos != std::u16string_view::npos )
{
nStartPos++;
- sal_Int32 nEndPos = rCID.lastIndexOf(':');
- if( nEndPos>=0 && nStartPos < nEndPos )
+ size_t nEndPos = rCID.rfind(':');
+ if( nEndPos != std::u16string_view::npos && nStartPos < nEndPos )
{
- aRet = rCID.copy(nStartPos,nEndPos-nStartPos);
+ aRet = rCID.substr(nStartPos,nEndPos-nStartPos);
}
}
return aRet;
}
-OUString ObjectIdentifier::getObjectID( const OUString& rCID )
+OUString ObjectIdentifier::getObjectID( std::u16string_view rCID )
{
OUString aRet;
- sal_Int32 nStartPos = rCID.lastIndexOf('/');
- if( nStartPos>=0 )
+ size_t nStartPos = rCID.rfind('/');
+ if( nStartPos != std::u16string_view::npos )
{
nStartPos++;
- sal_Int32 nEndPos = rCID.getLength();
- aRet = rCID.copy(nStartPos,nEndPos-nStartPos);
+ size_t nEndPos = rCID.size();
+ aRet = rCID.substr(nStartPos,nEndPos-nStartPos);
}
return aRet;
}
-bool ObjectIdentifier::isCID( const OUString& rName )
+bool ObjectIdentifier::isCID( std::u16string_view rName )
{
- return !rName.isEmpty() && rName.match( m_aProtocol );
+ return !rName.empty() && o3tl::starts_with( rName, m_aProtocol );
}
Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
- const OUString& rObjectCID,
- const Reference< chart2::XChartDocument >& xChartDocument )
-{
- return ObjectIdentifier::getObjectPropertySet(
- rObjectCID, Reference< frame::XModel >( xChartDocument ));
-}
-
-Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
- const OUString& rObjectCID
- , const Reference< frame::XModel >& xChartModel )
+ std::u16string_view rObjectCID
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
//return the model object that is indicated by rObjectCID
- if(rObjectCID.isEmpty())
+ if(rObjectCID.empty())
return nullptr;
if(!xChartModel.is())
return nullptr;
@@ -1198,26 +1094,24 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
try
{
ObjectType eObjectType = ObjectIdentifier::getObjectType( rObjectCID );
- OUString aParticleID = ObjectIdentifier::getParticleID( rObjectCID );
+ std::u16string_view aParticleID = ObjectIdentifier::getParticleID( rObjectCID );
- Reference< XDiagram > xDiagram;
- Reference< XCoordinateSystem > xCooSys;
+ rtl::Reference< Diagram > xDiagram;
+ rtl::Reference< BaseCoordinateSystem > xCooSys;
lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
switch(eObjectType)
{
case OBJECTTYPE_PAGE:
{
- Reference< XChartDocument > xChartDocument( xChartModel, uno::UNO_QUERY );
- if( xChartDocument.is())
- xObjectProperties.set( xChartDocument->getPageBackground() );
+ xObjectProperties.set( xChartModel->getPageBackground() );
}
break;
case OBJECTTYPE_TITLE:
{
TitleHelper::eTitleType aTitleType = getTitleTypeForCID( rObjectCID );
- Reference< XTitle > xTitle( TitleHelper::getTitle( aTitleType, xChartModel ) );
- xObjectProperties.set( xTitle, uno::UNO_QUERY );
+ rtl::Reference< Title > xTitle( TitleHelper::getTitle( aTitleType, xChartModel ) );
+ xObjectProperties = xTitle;
}
break;
case OBJECTTYPE_LEGEND:
@@ -1230,7 +1124,7 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
break;
case OBJECTTYPE_DIAGRAM:
{
- xObjectProperties.set( xDiagram, uno::UNO_QUERY );
+ xObjectProperties = xDiagram;
}
break;
case OBJECTTYPE_DIAGRAM_WALL:
@@ -1251,10 +1145,10 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
sal_Int32 nAxisIndex = -1;
lcl_parseAxisIndices( nDimensionIndex, nAxisIndex, rObjectCID );
- Reference< chart2::XAxis > xAxis(
- AxisHelper::getAxis( nDimensionIndex, nAxisIndex, xCooSys ) );
+ rtl::Reference< Axis > xAxis =
+ AxisHelper::getAxis( nDimensionIndex, nAxisIndex, xCooSys );
if( xAxis.is() )
- xObjectProperties.set( xAxis, uno::UNO_QUERY );
+ xObjectProperties = xAxis;
}
break;
case OBJECTTYPE_AXIS_UNITLABEL:
@@ -1269,27 +1163,27 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
sal_Int32 nSubGridIndex = -1;
lcl_parseGridIndices( nSubGridIndex, rObjectCID );
- xObjectProperties.set( AxisHelper::getGridProperties( xCooSys , nDimensionIndex, nAxisIndex, nSubGridIndex ) );
+ xObjectProperties = AxisHelper::getGridProperties( xCooSys , nDimensionIndex, nAxisIndex, nSubGridIndex );
}
break;
case OBJECTTYPE_DATA_LABELS:
case OBJECTTYPE_DATA_SERIES:
{
- Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(
+ rtl::Reference< DataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(
rObjectCID, xChartModel ) );
if( xSeries.is() )
- xObjectProperties.set( xSeries, uno::UNO_QUERY );
+ xObjectProperties = xSeries;
break;
}
case OBJECTTYPE_DATA_LABEL:
case OBJECTTYPE_DATA_POINT:
{
- Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(
- rObjectCID, xChartModel ) );
+ rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID(
+ rObjectCID, xChartModel );
if(xSeries.is())
{
- sal_Int32 nIndex = aParticleID.toInt32();
+ sal_Int32 nIndex = o3tl::toInt32(aParticleID);
xObjectProperties = xSeries->getDataPointByIndex( nIndex );
}
break;
@@ -1298,26 +1192,22 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
case OBJECTTYPE_DATA_ERRORS_Y:
case OBJECTTYPE_DATA_ERRORS_Z:
{
- Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(
- rObjectCID, xChartModel ) );
+ rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID(
+ rObjectCID, xChartModel );
if(xSeries.is())
{
- Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
Reference< beans::XPropertySet > xErrorBarProp;
- if( xSeriesProp.is() )
- {
- OUString errorBar;
+ OUString errorBar;
- if ( eObjectType == OBJECTTYPE_DATA_ERRORS_X)
- errorBar = CHART_UNONAME_ERRORBAR_X;
- else if (eObjectType == OBJECTTYPE_DATA_ERRORS_Y)
- errorBar = CHART_UNONAME_ERRORBAR_Y;
- else
- errorBar = "ErrorBarZ";
+ if ( eObjectType == OBJECTTYPE_DATA_ERRORS_X)
+ errorBar = CHART_UNONAME_ERRORBAR_X;
+ else if (eObjectType == OBJECTTYPE_DATA_ERRORS_Y)
+ errorBar = CHART_UNONAME_ERRORBAR_Y;
+ else
+ errorBar = "ErrorBarZ";
- xSeriesProp->getPropertyValue( errorBar ) >>= xErrorBarProp;
- xObjectProperties = xErrorBarProp;
- }
+ xSeries->getPropertyValue( errorBar ) >>= xErrorBarProp;
+ xObjectProperties = xErrorBarProp;
}
break;
}
@@ -1325,19 +1215,19 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
case OBJECTTYPE_DATA_CURVE:
case OBJECTTYPE_DATA_CURVE_EQUATION:
{
- Reference< XRegressionCurveContainer > xRegressionContainer( ObjectIdentifier::getDataSeriesForCID(
- rObjectCID, xChartModel ), uno::UNO_QUERY );
+ rtl::Reference< DataSeries > xRegressionContainer = ObjectIdentifier::getDataSeriesForCID(
+ rObjectCID, xChartModel );
if(xRegressionContainer.is())
{
- sal_Int32 nIndex = aParticleID.toInt32();
- uno::Sequence< Reference< XRegressionCurve > > aCurveList =
- xRegressionContainer->getRegressionCurves();
- if( nIndex >= 0 && nIndex <aCurveList.getLength() )
+ sal_Int32 nIndex = o3tl::toInt32(aParticleID);
+ const std::vector< rtl::Reference< RegressionCurveModel > > & aCurveList =
+ xRegressionContainer->getRegressionCurves2();
+ if( nIndex >= 0 && o3tl::make_unsigned(nIndex) < aCurveList.size() )
{
if( eObjectType == OBJECTTYPE_DATA_CURVE_EQUATION )
- xObjectProperties.set( aCurveList[nIndex]->getEquationProperties());
+ xObjectProperties = aCurveList[nIndex]->getEquationProperties();
else
- xObjectProperties.set( aCurveList[nIndex], uno::UNO_QUERY );
+ xObjectProperties = aCurveList[nIndex];
}
}
break;
@@ -1346,20 +1236,25 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
break;
case OBJECTTYPE_DATA_STOCK_LOSS:
{
- Reference<XChartType> xChartType( lcl_getFirstStockChartType( xChartModel ) );
- Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY );
- if(xChartTypeProps.is())
- xChartTypeProps->getPropertyValue( "BlackDay" ) >>= xObjectProperties;
+ rtl::Reference<ChartType> xChartType( lcl_getFirstStockChartType( xChartModel ) );
+ if(xChartType.is())
+ xChartType->getPropertyValue( "BlackDay" ) >>= xObjectProperties;
}
break;
case OBJECTTYPE_DATA_STOCK_GAIN:
{
- Reference<XChartType> xChartType( lcl_getFirstStockChartType( xChartModel ) );
- Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY );
- if(xChartTypeProps.is())
- xChartTypeProps->getPropertyValue( "WhiteDay" ) >>= xObjectProperties;
+ rtl::Reference<ChartType> xChartType( lcl_getFirstStockChartType( xChartModel ) );
+ if(xChartType.is())
+ xChartType->getPropertyValue( "WhiteDay" ) >>= xObjectProperties;
}
break;
+ case OBJECTTYPE_DATA_TABLE:
+ {
+ if (xDiagram.is())
+ xObjectProperties.set(xDiagram->getDataTable(), uno::UNO_QUERY);
+ }
+ break;
+ break;
default: //OBJECTTYPE_UNKNOWN
break;
}
@@ -1371,12 +1266,12 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
return xObjectProperties;
}
-Reference< XAxis > ObjectIdentifier::getAxisForCID(
- const OUString& rObjectCID
- , const Reference< frame::XModel >& xChartModel )
+rtl::Reference< Axis > ObjectIdentifier::getAxisForCID(
+ std::u16string_view rObjectCID
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
- Reference< XDiagram > xDiagram;
- Reference< XCoordinateSystem > xCooSys;
+ rtl::Reference< Diagram > xDiagram;
+ rtl::Reference< BaseCoordinateSystem > xCooSys;
lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
sal_Int32 nDimensionIndex = -1;
@@ -1386,14 +1281,12 @@ Reference< XAxis > ObjectIdentifier::getAxisForCID(
return AxisHelper::getAxis( nDimensionIndex, nAxisIndex, xCooSys );
}
-Reference< XDataSeries > ObjectIdentifier::getDataSeriesForCID(
- const OUString& rObjectCID
- , const Reference< frame::XModel >& xChartModel )
+rtl::Reference< DataSeries > ObjectIdentifier::getDataSeriesForCID(
+ std::u16string_view rObjectCID
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
- Reference< XDataSeries > xSeries;
-
- Reference< XDiagram > xDiagram;
- Reference< XCoordinateSystem > xCooSys;
+ rtl::Reference< Diagram > xDiagram;
+ rtl::Reference< BaseCoordinateSystem > xCooSys;
lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
sal_Int32 nChartTypeIndex = -1;
@@ -1401,34 +1294,36 @@ Reference< XDataSeries > ObjectIdentifier::getDataSeriesForCID(
sal_Int32 nPointIndex = -1;
lcl_parseSeriesIndices( nChartTypeIndex, nSeriesIndex, nPointIndex, rObjectCID );
- Reference< XDataSeriesContainer > xDataSeriesContainer( DiagramHelper::getChartTypeByIndex( xDiagram, nChartTypeIndex ), uno::UNO_QUERY );
- if( xDataSeriesContainer.is() )
+ rtl::Reference< DataSeries > xSeries;
+ if (xDiagram)
{
- uno::Sequence< uno::Reference< XDataSeries > > aDataSeriesSeq( xDataSeriesContainer->getDataSeries() );
- if( nSeriesIndex >= 0 && nSeriesIndex < aDataSeriesSeq.getLength() )
- xSeries.set( aDataSeriesSeq[nSeriesIndex] );
+ rtl::Reference< ChartType > xDataSeriesContainer( xDiagram->getChartTypeByIndex( nChartTypeIndex ) );
+ if( xDataSeriesContainer.is() )
+ {
+ const std::vector< rtl::Reference< DataSeries > > & aDataSeriesSeq( xDataSeriesContainer->getDataSeries2() );
+ if( nSeriesIndex >= 0 && o3tl::make_unsigned(nSeriesIndex) < aDataSeriesSeq.size() )
+ xSeries = aDataSeriesSeq[nSeriesIndex];
+ }
}
-
return xSeries;
}
-Reference< XDiagram > ObjectIdentifier::getDiagramForCID(
- const OUString& rObjectCID
- , const uno::Reference< frame::XModel >& xChartModel )
+rtl::Reference< Diagram > ObjectIdentifier::getDiagramForCID(
+ std::u16string_view rObjectCID
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
- Reference< XDiagram > xDiagram;
-
- Reference< XCoordinateSystem > xCooSys;
+ rtl::Reference< Diagram > xDiagram;
+ rtl::Reference< BaseCoordinateSystem > xCooSys;
lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
return xDiagram;
}
-TitleHelper::eTitleType ObjectIdentifier::getTitleTypeForCID( const OUString& rCID )
+TitleHelper::eTitleType ObjectIdentifier::getTitleTypeForCID( std::u16string_view rCID )
{
TitleHelper::eTitleType eRet( TitleHelper::MAIN_TITLE );
- OUString aParentParticle = ObjectIdentifier::getFullParentParticle( rCID );
+ std::u16string_view aParentParticle = ObjectIdentifier::getFullParentParticle( rCID );
const tTitleMap& rMap = lcl_getTitleMap();
tTitleMap::const_iterator aIt = std::find_if(rMap.begin(), rMap.end(),
[&aParentParticle](tTitleMap::const_reference rEntry) { return aParentParticle == rEntry.second; });
@@ -1438,7 +1333,7 @@ TitleHelper::eTitleType ObjectIdentifier::getTitleTypeForCID( const OUString& rC
return eRet;
}
-OUString ObjectIdentifier::getSeriesParticleFromCID( const OUString& rCID )
+OUString ObjectIdentifier::getSeriesParticleFromCID( std::u16string_view rCID )
{
sal_Int32 nDiagramIndex = -1;
sal_Int32 nCooSysIndex = -1;
@@ -1452,12 +1347,12 @@ OUString ObjectIdentifier::getSeriesParticleFromCID( const OUString& rCID )
return ObjectIdentifier::createParticleForSeries( nDiagramIndex, nCooSysIndex, nChartTypeIndex, nSeriesIndex );
}
-OUString ObjectIdentifier::getMovedSeriesCID( const OUString& rObjectCID, bool bForward )
+OUString ObjectIdentifier::getMovedSeriesCID( std::u16string_view rObjectCID, bool bForward )
{
- sal_Int32 nDiagramIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, "CID/D=" ) );
- sal_Int32 nCooSysIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, "CS=" ) );
- sal_Int32 nChartTypeIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, "CT=" ) );
- sal_Int32 nSeriesIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, "Series=" ) );
+ sal_Int32 nDiagramIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, u"CID/D=" ) );
+ sal_Int32 nCooSysIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, u"CS=" ) );
+ sal_Int32 nChartTypeIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, u"CT=" ) );
+ sal_Int32 nSeriesIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, u"Series=" ) );
if( bForward )
nSeriesIndex--;
diff --git a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
index b3585b71f5e3..f8921d73c266 100644
--- a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
@@ -21,6 +21,7 @@
#include <RegressionCalculationHelper.hxx>
#include <cmath>
+#include <limits>
#include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx>
@@ -90,7 +91,7 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression(
const uno::Sequence< double >& aXValues,
const uno::Sequence< double >& aYValues )
{
- rtl::math::setNan(&m_fCorrelationCoefficient);
+ m_fCorrelationCoefficient = std::numeric_limits<double>::quiet_NaN();
RegressionCalculationHelper::tDoubleVectorPair aValues(
RegressionCalculationHelper::cleanup( aXValues, aYValues, RegressionCalculationHelper::isValid()));
@@ -269,18 +270,13 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression(
double SAL_CALL PolynomialRegressionCurveCalculator::getCurveValue( double x )
{
- double fResult;
- rtl::math::setNan(&fResult);
-
if (mCoefficients.empty())
- {
- return fResult;
- }
+ return std::numeric_limits<double>::quiet_NaN();
sal_Int32 aNoCoefficients = static_cast<sal_Int32>(mCoefficients.size());
// Horner's method
- fResult = 0.0;
+ double fResult = 0.0;
for (sal_Int32 i = aNoCoefficients - 1; i >= 0; i--)
{
fResult = mCoefficients[i] + (x * fResult);
@@ -345,7 +341,7 @@ OUString PolynomialRegressionCurveCalculator::ImplGetRepresentation(
{
if ( bFindValue ) // if it is not the first aValue
aTmpBuf.append( " " );
- aTmpBuf.append( OUStringChar(aMinusSign) ).append(" ");
+ aTmpBuf.append( OUStringChar(aMinusSign) + " ");
aValue = - aValue;
}
else
@@ -385,7 +381,7 @@ OUString PolynomialRegressionCurveCalculator::ImplGetRepresentation(
}
addStringToEquation( aBuf, nLineLength, aTmpBuf, pFormulaMaxWidth );
}
- if ( aBuf.toString() == ( mYName + " = ") )
+ if ( std::u16string_view(aBuf) == Concat2View( mYName + " = ") )
aBuf.append( "0" );
return aBuf.makeStringAndClear();
diff --git a/chart2/source/tools/PopupRequest.cxx b/chart2/source/tools/PopupRequest.cxx
index 685dac49369c..70dd65b78393 100644
--- a/chart2/source/tools/PopupRequest.cxx
+++ b/chart2/source/tools/PopupRequest.cxx
@@ -14,10 +14,7 @@ using namespace css;
namespace chart
{
-PopupRequest::PopupRequest()
- : impl::PopupRequest_Base(m_aMutex)
-{
-}
+PopupRequest::PopupRequest() {}
PopupRequest::~PopupRequest() {}
@@ -29,10 +26,6 @@ void SAL_CALL PopupRequest::addCallback(const uno::Reference<awt::XCallback>& xC
m_xCallback = xCallback;
}
-// ____ WeakComponentImplHelperBase ____
-// is called when dispose() is called at this component
-void SAL_CALL PopupRequest::disposing() {}
-
} // namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx
index eb054bd8db66..504048641b59 100644
--- a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx
@@ -21,6 +21,7 @@
#include <RegressionCalculationHelper.hxx>
#include <SpecialCharacters.hxx>
+#include <limits>
#include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx>
@@ -30,12 +31,10 @@ namespace chart
{
PotentialRegressionCurveCalculator::PotentialRegressionCurveCalculator()
- : m_fSlope(0.0)
- , m_fIntercept(0.0)
+ : m_fSlope(std::numeric_limits<double>::quiet_NaN())
+ , m_fIntercept(std::numeric_limits<double>::quiet_NaN())
, m_fSign(1.0)
{
- ::rtl::math::setNan( & m_fSlope );
- ::rtl::math::setNan( & m_fIntercept );
}
PotentialRegressionCurveCalculator::~PotentialRegressionCurveCalculator()
@@ -61,9 +60,9 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression(
nMax = aValues.first.size();
if( nMax <= 1 )
{
- ::rtl::math::setNan( & m_fSlope );
- ::rtl::math::setNan( & m_fIntercept );
- ::rtl::math::setNan( & m_fCorrelationCoefficient );
+ m_fSlope = std::numeric_limits<double>::quiet_NaN();
+ m_fIntercept = std::numeric_limits<double>::quiet_NaN();
+ m_fCorrelationCoefficient = std::numeric_limits<double>::quiet_NaN();
return;
}
m_fSign = -1.0;
@@ -101,16 +100,13 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression(
double SAL_CALL PotentialRegressionCurveCalculator::getCurveValue( double x )
{
- double fResult;
- ::rtl::math::setNan( & fResult );
-
if( ! ( std::isnan( m_fSlope ) ||
std::isnan( m_fIntercept )))
{
- fResult = m_fIntercept * pow( x, m_fSlope );
+ return m_fIntercept * pow( x, m_fSlope );
}
- return fResult;
+ return std::numeric_limits<double>::quiet_NaN();
}
uno::Sequence< geometry::RealPoint2D > SAL_CALL PotentialRegressionCurveCalculator::getCurveValues(
@@ -124,11 +120,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL PotentialRegressionCurveCalculat
isLogarithmicScaling( xScalingY ))
{
// optimize result
- uno::Sequence< geometry::RealPoint2D > aResult( 2 );
- aResult[0].X = min;
- aResult[0].Y = getCurveValue( min );
- aResult[1].X = max;
- aResult[1].Y = getCurveValue( max );
+ uno::Sequence< geometry::RealPoint2D > aResult{ { min, getCurveValue( min ) },
+ { max, getCurveValue( max ) } };
return aResult;
}
@@ -170,19 +163,19 @@ OUString PotentialRegressionCurveCalculator::ImplGetRepresentation(
// if nValueLength not calculated then nullptr
sal_Int32* pValueLength = nValueLength ? &nValueLength : nullptr;
if ( m_fIntercept < 0.0 ) // add intercept value
- aTmpBuf.append( OUStringChar(aMinusSign) ).append( " " );
+ aTmpBuf.append( OUStringChar(aMinusSign) + " " );
if( bHasIntercept )
{
OUString aValueString = getFormattedString( xNumFormatter, nNumberFormatKey, fabs(m_fIntercept), pValueLength );
if ( aValueString != "1" ) // aValueString may be rounded to 1 if nValueLength is small
{
- aTmpBuf.append( aValueString ).append( " " );
+ aTmpBuf.append( aValueString + " " );
}
}
if( m_fSlope != 0.0 ) // add slope value
{
- aTmpBuf.append( mXName ).append( "^" );
- aTmpBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fSlope, pValueLength ));
+ aTmpBuf.append( mXName + "^" +
+ getFormattedString( xNumFormatter, nNumberFormatKey, m_fSlope, pValueLength ));
}
addStringToEquation( aBuf, nLineLength, aTmpBuf, pFormulaMaxWidth );
}
diff --git a/chart2/source/tools/PropertyHelper.cxx b/chart2/source/tools/PropertyHelper.cxx
index cb3e860c0350..48e21eccaf25 100644
--- a/chart2/source/tools/PropertyHelper.cxx
+++ b/chart2/source/tools/PropertyHelper.cxx
@@ -20,10 +20,13 @@
#include <PropertyHelper.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <docmodel/uno/UnoGradientTools.hxx>
#include <comphelper/sequence.hxx>
#include <osl/diagnose.h>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <o3tl/string_view.hxx>
+#include <utility>
#include <vector>
#include <algorithm>
#include <iterator>
@@ -37,8 +40,8 @@ namespace
{
struct lcl_EqualsElement
{
- explicit lcl_EqualsElement( const Any & rValue, const Reference< container::XNameAccess > & xAccess )
- : m_aValue( rValue ), m_xAccess( xAccess )
+ explicit lcl_EqualsElement( Any rValue, const Reference< container::XNameAccess > & xAccess )
+ : m_aValue(std::move( rValue )), m_xAccess( xAccess )
{
OSL_ASSERT( m_xAccess.is());
}
@@ -63,13 +66,13 @@ private:
struct lcl_StringMatches
{
- explicit lcl_StringMatches( const OUString & rCmpStr ) :
- m_aCmpStr( rCmpStr )
+ explicit lcl_StringMatches( OUString aCmpStr ) :
+ m_aCmpStr(std::move( aCmpStr ))
{}
- bool operator() ( const OUString & rStr )
+ bool operator() ( std::u16string_view rStr )
{
- return rStr.match( m_aCmpStr );
+ return o3tl::starts_with( rStr, m_aCmpStr );
}
private:
@@ -81,11 +84,11 @@ struct lcl_OUStringRestToInt32
explicit lcl_OUStringRestToInt32( sal_Int32 nPrefixLength ) :
m_nPrefixLength( nPrefixLength )
{}
- sal_Int32 operator() ( const OUString & rStr )
+ sal_Int32 operator() ( std::u16string_view rStr )
{
- if( m_nPrefixLength > rStr.getLength() )
+ if( m_nPrefixLength > static_cast<sal_Int32>(rStr.size()) )
return 0;
- return rStr.copy( m_nPrefixLength ).toInt32();
+ return o3tl::toInt32(rStr.substr( m_nPrefixLength ));
}
private:
sal_Int32 m_nPrefixLength;
@@ -111,56 +114,68 @@ OUString lcl_addNamedPropertyUniqueNameToTable(
const OUString & rPreferredName )
{
if( ! xNameContainer.is() ||
- ! rValue.hasValue() ||
- ( rValue.getValueType() != xNameContainer->getElementType()))
+ ! rValue.hasValue() )
+ return rPreferredName;
+
+ Any aValue(rValue);
+
+ if ( rValue.has<css::awt::Gradient>())
+ {
+ // tdf#158421 the lists for Gradients needs awt::Gradient2
+ // as type, convert input data if needed (and warn about it,
+ // the caller should be changed to offer the needed type)
+ SAL_WARN("chart2","input value needs to be awt::Gradient2");
+ const basegfx::BGradient aTemp(model::gradient::getFromAny(rValue));
+ aValue <<= model::gradient::createUnoGradient2(aTemp);
+ }
+
+ if ( aValue.getValueType() != xNameContainer->getElementType())
return rPreferredName;
try
{
Reference< container::XNameAccess > xNameAccess( xNameContainer, uno::UNO_QUERY_THROW );
- auto aNames( comphelper::sequenceToContainer<std::vector< OUString >>( xNameAccess->getElementNames()));
- std::vector< OUString >::const_iterator aIt(
- std::find_if( aNames.begin(), aNames.end(), lcl_EqualsElement( rValue, xNameAccess )));
+ const uno::Sequence<OUString> aElementNames = xNameAccess->getElementNames();
+ auto it = std::find_if( aElementNames.begin(), aElementNames.end(), lcl_EqualsElement( aValue, xNameAccess ));
+
+ // element found => return name
+ if( it != aElementNames.end())
+ return *it;
// element not found in container
- if( aIt == aNames.end())
+ OUString aUniqueName;
+
+ // check if preferred name is already used
+ if( !rPreferredName.isEmpty())
+ {
+ auto aIt = std::find( aElementNames.begin(), aElementNames.end(), rPreferredName );
+ if( aIt == aElementNames.end())
+ aUniqueName = rPreferredName;
+ }
+
+ if( aUniqueName.isEmpty())
{
- OUString aUniqueName;
-
- // check if preferred name is already used
- if( !rPreferredName.isEmpty())
- {
- aIt = std::find( aNames.begin(), aNames.end(), rPreferredName );
- if( aIt == aNames.end())
- aUniqueName = rPreferredName;
- }
-
- if( aUniqueName.isEmpty())
- {
- // create a unique id using the prefix plus a number
- std::vector< sal_Int32 > aNumbers;
- std::vector< OUString >::iterator aNonConstIt(
- std::partition( aNames.begin(), aNames.end(), lcl_StringMatches( rPrefix )));
- std::transform( aNames.begin(), aNonConstIt,
- back_inserter( aNumbers ),
- lcl_OUStringRestToInt32( rPrefix.getLength() ));
- std::vector< sal_Int32 >::const_iterator aMaxIt(
- std::max_element( aNumbers.begin(), aNumbers.end()));
-
- sal_Int32 nIndex = 1;
- if( aMaxIt != aNumbers.end())
- nIndex = (*aMaxIt) + 1;
-
- aUniqueName = rPrefix + OUString::number( nIndex );
- }
-
- OSL_ASSERT( !aUniqueName.isEmpty());
- xNameContainer->insertByName( aUniqueName, rValue );
- return aUniqueName;
+ auto aNames( comphelper::sequenceToContainer<std::vector< OUString >>( aElementNames ));
+ // create a unique id using the prefix plus a number
+ std::vector< sal_Int32 > aNumbers;
+ std::vector< OUString >::iterator aNonConstIt(
+ std::partition( aNames.begin(), aNames.end(), lcl_StringMatches( rPrefix )));
+ std::transform( aNames.begin(), aNonConstIt,
+ back_inserter( aNumbers ),
+ lcl_OUStringRestToInt32( rPrefix.getLength() ));
+ std::vector< sal_Int32 >::const_iterator aMaxIt(
+ std::max_element( aNumbers.begin(), aNumbers.end()));
+
+ sal_Int32 nIndex = 1;
+ if( aMaxIt != aNumbers.end())
+ nIndex = (*aMaxIt) + 1;
+
+ aUniqueName = rPrefix + OUString::number( nIndex );
}
- else
- // element found => return name
- return *aIt;
+
+ OSL_ASSERT( !aUniqueName.isEmpty());
+ xNameContainer->insertByName( aUniqueName, aValue );
+ return aUniqueName;
}
catch( const uno::Exception & )
{
diff --git a/chart2/source/tools/RangeHighlighter.cxx b/chart2/source/tools/RangeHighlighter.cxx
index b326d0bacce9..1b2ae9153fcd 100644
--- a/chart2/source/tools/RangeHighlighter.cxx
+++ b/chart2/source/tools/RangeHighlighter.cxx
@@ -19,20 +19,22 @@
#include <RangeHighlighter.hxx>
#include <WeakListenerAdapter.hxx>
+#include <ChartModel.hxx>
#include <ChartModelHelper.hxx>
#include <DataSourceHelper.hxx>
#include <ObjectIdentifier.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
+#include <Diagram.hxx>
#include <com/sun/star/chart2/ScaleData.hpp>
#include <com/sun/star/chart2/XAxis.hpp>
#include <com/sun/star/chart2/XDataSeries.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <comphelper/sequence.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/color.hxx>
using namespace ::com::sun::star;
@@ -52,12 +54,13 @@ void lcl_fillRanges(
sal_Int32 nIndex = -1 )
{
rOutRanges.realloc( aRangeStrings.getLength());
+ auto pOutRanges = rOutRanges.getArray();
for( sal_Int32 i=0; i<aRangeStrings.getLength(); ++i )
{
- rOutRanges[i].RangeRepresentation = aRangeStrings[i];
- rOutRanges[i].PreferredColor = sal_Int32(nPreferredColor);
- rOutRanges[i].AllowMerginigWithOtherRanges = false;
- rOutRanges[i].Index = nIndex;
+ pOutRanges[i].RangeRepresentation = aRangeStrings[i];
+ pOutRanges[i].PreferredColor = sal_Int32(nPreferredColor);
+ pOutRanges[i].AllowMerginigWithOtherRanges = false;
+ pOutRanges[i].Index = nIndex;
}
}
@@ -67,9 +70,9 @@ namespace chart
{
RangeHighlighter::RangeHighlighter(
- const Reference< view::XSelectionSupplier > & xSelectionSupplier ) :
- impl::RangeHighlighter_Base( m_aMutex ),
- m_xSelectionSupplier( xSelectionSupplier ),
+ const rtl::Reference< ChartModel > & xChartModel ) :
+ m_xSelectionSupplier(xChartModel->getCurrentController(), uno::UNO_QUERY),
+ m_xChartModel( xChartModel ),
m_nAddedListenerCount( 0 ),
m_bIncludeHiddenCells(true)
{
@@ -87,17 +90,14 @@ Sequence< chart2::data::HighlightedRange > SAL_CALL RangeHighlighter::getSelecte
void RangeHighlighter::determineRanges()
{
m_aSelectedRanges.realloc( 0 );
+ if( !m_xChartModel.is())
+ return;
if( !m_xSelectionSupplier.is())
return;
try
{
- Reference< frame::XController > xController( m_xSelectionSupplier, uno::UNO_QUERY );
- Reference< frame::XModel > xChartModel;
- if( xController.is())
- xChartModel.set( xController->getModel());
-
- m_bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( xChartModel );
+ m_bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( m_xChartModel );
uno::Any aSelection( m_xSelectionSupplier->getSelection());
const uno::Type& rType = aSelection.getValueType();
@@ -112,7 +112,7 @@ void RangeHighlighter::determineRanges()
{
ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID );
sal_Int32 nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aCID );
- Reference< chart2::XDataSeries > xDataSeries( ObjectIdentifier::getDataSeriesForCID( aCID, xChartModel ) );
+ rtl::Reference< DataSeries > xDataSeries( ObjectIdentifier::getDataSeriesForCID( aCID, m_xChartModel ) );
if( eObjectType == OBJECTTYPE_LEGEND_ENTRY )
{
OUString aParentParticel( ObjectIdentifier::getFullParentParticle( aCID ) );
@@ -134,7 +134,7 @@ void RangeHighlighter::determineRanges()
{
// select error bar ranges, or data series, if the style is
// not set to FROM_DATA
- fillRangesForErrorBars( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), xDataSeries );
+ fillRangesForErrorBars( ObjectIdentifier::getObjectPropertySet( aCID, m_xChartModel ), xDataSeries );
return;
}
else if( xDataSeries.is() )
@@ -146,7 +146,7 @@ void RangeHighlighter::determineRanges()
else if( eObjectType == OBJECTTYPE_AXIS )
{
// Axis (Categories)
- Reference< chart2::XAxis > xAxis( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), uno::UNO_QUERY );
+ Reference< chart2::XAxis > xAxis( ObjectIdentifier::getObjectPropertySet( aCID, m_xChartModel ), uno::UNO_QUERY );
if( xAxis.is())
{
fillRangesForCategories( xAxis );
@@ -160,7 +160,7 @@ void RangeHighlighter::determineRanges()
)
{
// Diagram
- Reference< chart2::XDiagram > xDia( ObjectIdentifier::getDiagramForCID( aCID, xChartModel ) );
+ rtl::Reference< ::chart::Diagram > xDia( ObjectIdentifier::getDiagramForCID( aCID, m_xChartModel ) );
if( xDia.is())
{
fillRangesForDiagram( xDia );
@@ -182,8 +182,7 @@ void RangeHighlighter::determineRanges()
else
{
//if nothing is selected select all ranges
- Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY_THROW );
- fillRangesForDiagram( xChartDoc->getFirstDiagram() );
+ fillRangesForDiagram( m_xChartModel->getFirstChartDiagram() );
return;
}
}
@@ -193,17 +192,18 @@ void RangeHighlighter::determineRanges()
}
}
-void RangeHighlighter::fillRangesForDiagram( const Reference< chart2::XDiagram > & xDiagram )
+void RangeHighlighter::fillRangesForDiagram( const rtl::Reference< Diagram > & xDiagram )
{
Sequence< OUString > aSelectedRanges( DataSourceHelper::getUsedDataRanges( xDiagram ));
m_aSelectedRanges.realloc( aSelectedRanges.getLength());
+ auto pSelectedRanges = m_aSelectedRanges.getArray();
// @todo: merge ranges
for( sal_Int32 i=0; i<aSelectedRanges.getLength(); ++i )
{
- m_aSelectedRanges[i].RangeRepresentation = aSelectedRanges[i];
- m_aSelectedRanges[i].Index = -1;
- m_aSelectedRanges[i].PreferredColor = sal_Int32(defaultPreferredColor);
- m_aSelectedRanges[i].AllowMerginigWithOtherRanges = true;
+ pSelectedRanges[i].RangeRepresentation = aSelectedRanges[i];
+ pSelectedRanges[i].Index = -1;
+ pSelectedRanges[i].PreferredColor = sal_Int32(defaultPreferredColor);
+ pSelectedRanges[i].AllowMerginigWithOtherRanges = true;
}
}
@@ -263,19 +263,15 @@ void RangeHighlighter::fillRangesForCategories( const Reference< chart2::XAxis >
defaultPreferredColor );
}
-void RangeHighlighter::fillRangesForDataPoint( const Reference< uno::XInterface > & xDataSeries, sal_Int32 nIndex )
+void RangeHighlighter::fillRangesForDataPoint( const rtl::Reference< DataSeries > & xDataSeries, sal_Int32 nIndex )
{
if( !xDataSeries.is())
return;
- Reference< chart2::data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY );
- if( !xSource.is() )
- return;
-
Color nPreferredColor = defaultPreferredColor;
std::vector< chart2::data::HighlightedRange > aHilightedRanges;
- const Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeqSeq( xSource->getDataSequences());
- for( Reference< chart2::data::XLabeledDataSequence > const & labelDataSeq : aLSeqSeq )
+ const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aLSeqSeq( xDataSeries->getDataSequences2());
+ for( uno::Reference< chart2::data::XLabeledDataSequence > const & labelDataSeq : aLSeqSeq )
{
Reference< chart2::data::XDataSequence > xLabel( labelDataSeq->getLabel());
Reference< chart2::data::XDataSequence > xValues( labelDataSeq->getValues());
@@ -305,7 +301,8 @@ void SAL_CALL RangeHighlighter::addSelectionChangeListener( const Reference< vie
if( m_nAddedListenerCount == 0 )
startListening();
- rBHelper.addListener( cppu::UnoType<decltype(xListener)>::get(), xListener);
+ std::unique_lock g(m_aMutex);
+ maSelectionChangeListeners.addInterface( g, xListener);
++m_nAddedListenerCount;
//bring the new listener up to the current state
@@ -315,7 +312,8 @@ void SAL_CALL RangeHighlighter::addSelectionChangeListener( const Reference< vie
void SAL_CALL RangeHighlighter::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& xListener )
{
- rBHelper.removeListener( cppu::UnoType<decltype(xListener)>::get(), xListener );
+ std::unique_lock g(m_aMutex);
+ maSelectionChangeListeners.removeInterface( g, xListener );
--m_nAddedListenerCount;
if( m_nAddedListenerCount == 0 )
stopListening();
@@ -333,18 +331,16 @@ void SAL_CALL RangeHighlighter::selectionChanged( const lang::EventObject& /*aEv
void RangeHighlighter::fireSelectionEvent()
{
- ::cppu::OInterfaceContainerHelper* pIC = rBHelper.getContainer(
- cppu::UnoType< view::XSelectionChangeListener >::get() );
- if( pIC )
+ std::unique_lock g(m_aMutex);
+ if( maSelectionChangeListeners.getLength(g) )
{
lang::EventObject aEvent( static_cast< lang::XComponent* >( this ) );
- ::cppu::OInterfaceIteratorHelper aIt( *pIC );
- while( aIt.hasMoreElements() )
- {
- uno::Reference< view::XSelectionChangeListener > xListener( aIt.next(), uno::UNO_QUERY );
- if( xListener.is() )
- xListener->selectionChanged( aEvent );
- }
+ maSelectionChangeListeners.forEach(g,
+ [&aEvent](const css::uno::Reference<view::XSelectionChangeListener>& xListener)
+ {
+ xListener->selectionChanged(aEvent);
+ }
+ );
}
}
@@ -382,7 +378,7 @@ void RangeHighlighter::stopListening()
// ____ WeakComponentImplHelperBase ____
// is called when dispose() is called at this component
-void SAL_CALL RangeHighlighter::disposing()
+void RangeHighlighter::disposing(std::unique_lock<std::mutex>&)
{
// @todo: remove listener. Currently the controller shows an assertion
// because it is already disposed
diff --git a/chart2/source/tools/ReferenceSizeProvider.cxx b/chart2/source/tools/ReferenceSizeProvider.cxx
index 44109500552a..714fa83b425c 100644
--- a/chart2/source/tools/ReferenceSizeProvider.cxx
+++ b/chart2/source/tools/ReferenceSizeProvider.cxx
@@ -19,19 +19,20 @@
#include <ReferenceSizeProvider.hxx>
#include <RelativeSizeHelper.hxx>
-#include <ChartModelHelper.hxx>
-#include <DiagramHelper.hxx>
+#include <ChartModel.hxx>
+#include <DataSeries.hxx>
+#include <DataSeriesProperties.hxx>
+#include <Diagram.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
-#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/chart2/XTitled.hpp>
-#include <com/sun/star/chart2/XTitle.hpp>
-#include <com/sun/star/chart2/XDataSeries.hpp>
-#include <tools/diagnose_ex.h>
+#include <Legend.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <vector>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
+using namespace ::chart::DataSeriesProperties;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -41,7 +42,7 @@ namespace chart
ReferenceSizeProvider::ReferenceSizeProvider(
awt::Size aPageSize,
- const Reference< XChartDocument > & xChartDoc ) :
+ const rtl::Reference<::chart::ChartModel> & xChartDoc ) :
m_aPageSize( aPageSize ),
m_xChartDoc( xChartDoc ),
m_bUseAutoScale( getAutoResizeState( xChartDoc ) == AUTO_RESIZE_YES )
@@ -91,36 +92,35 @@ void ReferenceSizeProvider::setValuesAtTitle(
void ReferenceSizeProvider::setValuesAtAllDataSeries()
{
- Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDoc ));
+ rtl::Reference< Diagram > xDiagram( m_xChartDoc->getFirstChartDiagram());
+ if (!xDiagram)
+ return;
// DataSeries/Points
- std::vector< Reference< XDataSeries > > aSeries(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeries =
+ xDiagram->getDataSeries();
for (auto const& elem : aSeries)
{
- Reference< beans::XPropertySet > xSeriesProp(elem, uno::UNO_QUERY );
- if( xSeriesProp.is())
+ // data points
+ Sequence< sal_Int32 > aPointIndexes;
+ try
{
- // data points
- Sequence< sal_Int32 > aPointIndexes;
- try
- {
- if( xSeriesProp->getPropertyValue( "AttributedDataPoints") >>= aPointIndexes )
- {
- for( sal_Int32 idx : aPointIndexes )
- setValuesAtPropertySet(
- elem->getDataPointByIndex( idx ) );
- }
- }
- catch (const uno::Exception&)
+ // "AttributedDataPoints"
+ if( elem->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS) >>= aPointIndexes )
{
- DBG_UNHANDLED_EXCEPTION("chart2");
+ for (sal_Int32 idx : aPointIndexes)
+ setValuesAtPropertySet(
+ elem->getDataPointByIndex( idx ) );
}
-
- //it is important to correct the datapoint properties first as they do reference the series properties
- setValuesAtPropertySet( xSeriesProp );
}
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ //it is important to correct the datapoint properties first as they do reference the series properties
+ setValuesAtPropertySet( elem );
}
}
@@ -131,7 +131,7 @@ void ReferenceSizeProvider::setValuesAtPropertySet(
if( ! xProp.is())
return;
- static const char aRefSizeName[] = "ReferencePageSize";
+ static constexpr OUString aRefSizeName = u"ReferencePageSize"_ustr;
try
{
@@ -217,84 +217,73 @@ void ReferenceSizeProvider::impl_getAutoResizeFromTitled(
with state NO, AUTO_RESIZE_AMBIGUOUS is returned.
*/
ReferenceSizeProvider::AutoResizeState ReferenceSizeProvider::getAutoResizeState(
- const Reference< XChartDocument > & xChartDoc )
+ const rtl::Reference<::chart::ChartModel> & xChartDoc )
{
AutoResizeState eResult = AUTO_RESIZE_UNKNOWN;
// Main Title
- Reference< XTitled > xDocTitled( xChartDoc, uno::UNO_QUERY );
- if( xDocTitled.is())
- impl_getAutoResizeFromTitled( xDocTitled, eResult );
+ if( xChartDoc.is())
+ impl_getAutoResizeFromTitled( xChartDoc, eResult );
if( eResult == AUTO_RESIZE_AMBIGUOUS )
return eResult;
// diagram is needed by the rest of the objects
- Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartDoc );
+ rtl::Reference< Diagram > xDiagram = xChartDoc->getFirstChartDiagram();
if( ! xDiagram.is())
return eResult;
// Sub Title
- Reference< XTitled > xDiaTitled( xDiagram, uno::UNO_QUERY );
- if( xDiaTitled.is())
- impl_getAutoResizeFromTitled( xDiaTitled, eResult );
+ if( xDiagram.is())
+ impl_getAutoResizeFromTitled( xDiagram, eResult );
if( eResult == AUTO_RESIZE_AMBIGUOUS )
return eResult;
// Legend
- Reference< beans::XPropertySet > xLegendProp( xDiagram->getLegend(), uno::UNO_QUERY );
- if( xLegendProp.is())
- getAutoResizeFromPropSet( xLegendProp, eResult );
+ rtl::Reference< Legend > xLegend( xDiagram->getLegend2() );
+ if( xLegend.is())
+ getAutoResizeFromPropSet( xLegend, eResult );
if( eResult == AUTO_RESIZE_AMBIGUOUS )
return eResult;
// Axes (incl. Axis Titles)
- const Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
- for( Reference< XAxis > const & axis : aAxes )
+ const std::vector< rtl::Reference< Axis > > aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram );
+ for( rtl::Reference< Axis > const & axis : aAxes )
{
- Reference< beans::XPropertySet > xProp( axis, uno::UNO_QUERY );
- if( xProp.is())
- getAutoResizeFromPropSet( xProp, eResult );
- Reference< XTitled > xTitled( axis, uno::UNO_QUERY );
- if( xTitled.is())
- {
- impl_getAutoResizeFromTitled( xTitled, eResult );
- if( eResult == AUTO_RESIZE_AMBIGUOUS )
- return eResult;
- }
+ getAutoResizeFromPropSet( axis, eResult );
+ impl_getAutoResizeFromTitled( axis, eResult );
+ if( eResult == AUTO_RESIZE_AMBIGUOUS )
+ return eResult;
}
// DataSeries/Points
- std::vector< Reference< XDataSeries > > aSeries(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeries =
+ xDiagram->getDataSeries();
for (auto const& elem : aSeries)
{
- Reference< beans::XPropertySet > xSeriesProp(elem, uno::UNO_QUERY);
- if( xSeriesProp.is())
- {
- getAutoResizeFromPropSet( xSeriesProp, eResult );
- if( eResult == AUTO_RESIZE_AMBIGUOUS )
- return eResult;
+ getAutoResizeFromPropSet( elem, eResult );
+ if( eResult == AUTO_RESIZE_AMBIGUOUS )
+ return eResult;
- // data points
- Sequence< sal_Int32 > aPointIndexes;
- try
+ // data points
+ Sequence< sal_Int32 > aPointIndexes;
+ try
+ {
+ // "AttributedDataPoints"
+ if( elem->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS) >>= aPointIndexes )
{
- if( xSeriesProp->getPropertyValue( "AttributedDataPoints") >>= aPointIndexes )
+ for (sal_Int32 idx : aPointIndexes)
{
- for( sal_Int32 idx : aPointIndexes )
- {
- getAutoResizeFromPropSet(
- elem->getDataPointByIndex( idx ), eResult );
- if( eResult == AUTO_RESIZE_AMBIGUOUS )
- return eResult;
- }
+ getAutoResizeFromPropSet(
+ elem->getDataPointByIndex( idx ), eResult );
+ if( eResult == AUTO_RESIZE_AMBIGUOUS )
+ return eResult;
}
}
- catch (const uno::Exception&)
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
}
}
@@ -314,29 +303,27 @@ void ReferenceSizeProvider::setAutoResizeState( ReferenceSizeProvider::AutoResiz
m_bUseAutoScale = (eNewState == AUTO_RESIZE_YES);
// Main Title
- impl_setValuesAtTitled( Reference< XTitled >( m_xChartDoc, uno::UNO_QUERY ));
+ impl_setValuesAtTitled( m_xChartDoc );
// diagram is needed by the rest of the objects
- Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_xChartDoc );
+ rtl::Reference< Diagram > xDiagram = m_xChartDoc->getFirstChartDiagram();
if( ! xDiagram.is())
return;
// Sub Title
- impl_setValuesAtTitled( Reference< XTitled >( xDiagram, uno::UNO_QUERY ));
+ impl_setValuesAtTitled( xDiagram );
// Legend
- Reference< beans::XPropertySet > xLegendProp( xDiagram->getLegend(), uno::UNO_QUERY );
- if( xLegendProp.is())
- setValuesAtPropertySet( xLegendProp );
+ rtl::Reference< Legend > xLegend( xDiagram->getLegend2() );
+ if( xLegend.is())
+ setValuesAtPropertySet( xLegend );
// Axes (incl. Axis Titles)
- const Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
- for( Reference< XAxis > const & axis : aAxes )
+ const std::vector< rtl::Reference< Axis > > aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram );
+ for( rtl::Reference< Axis > const & axis : aAxes )
{
- Reference< beans::XPropertySet > xProp( axis, uno::UNO_QUERY );
- if( xProp.is())
- setValuesAtPropertySet( xProp );
- impl_setValuesAtTitled( Reference< XTitled >( axis, uno::UNO_QUERY ));
+ setValuesAtPropertySet( axis );
+ impl_setValuesAtTitled( axis );
}
// DataSeries/Points
diff --git a/chart2/source/tools/RegressionCurveCalculator.cxx b/chart2/source/tools/RegressionCurveCalculator.cxx
index 5b65375b0376..8f22f9834bdc 100644
--- a/chart2/source/tools/RegressionCurveCalculator.cxx
+++ b/chart2/source/tools/RegressionCurveCalculator.cxx
@@ -36,16 +36,16 @@ using ::com::sun::star::uno::Sequence;
namespace chart
{
-RegressionCurveCalculator::RegressionCurveCalculator() :
- m_fCorrelationCoefficient(0.0),
- mDegree(2),
- mForceIntercept(false),
- mInterceptValue(0.0),
- mPeriod(2),
- mXName("x"), mYName("f(x)")
+RegressionCurveCalculator::RegressionCurveCalculator()
+ : m_fCorrelationCoefficient(std::numeric_limits<double>::quiet_NaN())
+ , mDegree(2)
+ , mForceIntercept(false)
+ , mInterceptValue(std::numeric_limits<double>::quiet_NaN())
+ , mPeriod(2)
+ , mXName("x")
+ , mYName("f(x)")
+ , mnMovingType(0)
{
- rtl::math::setNan( &m_fCorrelationCoefficient );
- rtl::math::setNan( &mInterceptValue );
}
RegressionCurveCalculator::~RegressionCurveCalculator()
@@ -72,12 +72,16 @@ void RegressionCurveCalculator::setRegressionProperties(
sal_Int32 aDegree,
sal_Bool aForceIntercept,
double aInterceptValue,
- sal_Int32 aPeriod )
+ sal_Int32 aPeriod,
+ sal_Int32 nMovingType )
{
+ if( aPeriod < 0 )
+ throw lang::IllegalArgumentException("aPeriod may not be < 0", static_cast<cppu::OWeakObject*>(this), 3);
mDegree = aDegree;
mForceIntercept = aForceIntercept;
mInterceptValue = aInterceptValue;
mPeriod = aPeriod;
+ mnMovingType = nMovingType;
}
OUString RegressionCurveCalculator::getFormattedString(
@@ -96,9 +100,7 @@ OUString RegressionCurveCalculator::getFormattedString(
{ // round fNumber to *pStringLength characters
const sal_Int32 nMinDigit = 6; // minimum significant digits for General format
sal_Int32 nSignificantDigit = ( *pStringLength <= nMinDigit ? nMinDigit : *pStringLength );
- aResult = OStringToOUString(
- ::rtl::math::doubleToString( fNumber, rtl_math_StringFormat_G1, nSignificantDigit, '.', true ),
- RTL_TEXTENCODING_ASCII_US );
+ aResult = ::rtl::math::doubleToUString( fNumber, rtl_math_StringFormat_G1, nSignificantDigit, '.', true );
// count characters different from significant digits (decimal separator, scientific notation)
sal_Int32 nExtraChar = aResult.getLength() - *pStringLength;
if ( nExtraChar > 0 && *pStringLength > nMinDigit )
@@ -106,9 +108,7 @@ OUString RegressionCurveCalculator::getFormattedString(
nSignificantDigit = *pStringLength - nExtraChar;
if ( nSignificantDigit < nMinDigit )
nSignificantDigit = nMinDigit;
- aResult = OStringToOUString(
- ::rtl::math::doubleToString( fNumber, rtl_math_StringFormat_G1, nSignificantDigit, '.', true ),
- RTL_TEXTENCODING_ASCII_US );
+ aResult = ::rtl::math::doubleToUString( fNumber, rtl_math_StringFormat_G1, nSignificantDigit, '.', true );
}
fNumber = ::rtl::math::stringToDouble( aResult, '.', ',' );
}
@@ -119,9 +119,7 @@ OUString RegressionCurveCalculator::getFormattedString(
sal_Int32 nStringLength = 4; // default length
if ( pStringLength )
nStringLength = *pStringLength;
- aResult = OStringToOUString(
- ::rtl::math::doubleToString( fNumber, rtl_math_StringFormat_G1, nStringLength, '.', true ),
- RTL_TEXTENCODING_ASCII_US );
+ aResult = ::rtl::math::doubleToUString( fNumber, rtl_math_StringFormat_G1, nStringLength, '.', true );
}
return aResult;
}
@@ -133,7 +131,7 @@ Sequence< geometry::RealPoint2D > SAL_CALL RegressionCurveCalculator::getCurveVa
sal_Bool /* bMaySkipPointsInCalculation */ )
{
if( nPointCount < 2 )
- throw lang::IllegalArgumentException();
+ throw lang::IllegalArgumentException("too few points", static_cast<cppu::OWeakObject*>(this), 2);
// determine if scaling and inverse scaling for x-values work
bool bDoXScaling( xScalingX.is());
@@ -143,6 +141,7 @@ Sequence< geometry::RealPoint2D > SAL_CALL RegressionCurveCalculator::getCurveVa
bDoXScaling = bDoXScaling && xInverseScaling.is();
Sequence< geometry::RealPoint2D > aResult( nPointCount );
+ auto pResult = aResult.getArray();
double fMin( min );
double fFact = (max - min) / double(nPointCount-1);
@@ -158,8 +157,8 @@ Sequence< geometry::RealPoint2D > SAL_CALL RegressionCurveCalculator::getCurveVa
double x = fMin + nP * fFact;
if( bDoXScaling )
x = xInverseScaling->doScaling( x );
- aResult[nP].X = x;
- aResult[nP].Y = getCurveValue( x );
+ pResult[nP].X = x;
+ pResult[nP].Y = getCurveValue( x );
}
return aResult;
diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx
index 66f56725133b..efb6bea5c3aa 100644
--- a/chart2/source/tools/RegressionCurveHelper.cxx
+++ b/chart2/source/tools/RegressionCurveHelper.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cstddef>
+
#include <RegressionCurveHelper.hxx>
#include <MeanValueRegressionCurveCalculator.hxx>
#include <LinearRegressionCurveCalculator.hxx>
@@ -26,16 +30,20 @@
#include <ExponentialRegressionCurveCalculator.hxx>
#include <PotentialRegressionCurveCalculator.hxx>
#include <CommonConverters.hxx>
-#include "RegressionCurveModel.hxx"
+#include <RegressionCurveModel.hxx>
#include <ChartTypeHelper.hxx>
+#include <ChartType.hxx>
+#include <ChartModel.hxx>
#include <ChartModelHelper.hxx>
+#include <DataSeries.hxx>
#include <ResId.hxx>
#include <strings.hrc>
-#include <DiagramHelper.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/XRegressionCurveCalculator.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
-#include <tools/diagnose_ex.h>
+#include <com/sun/star/chart2/data/XDataSource.hpp>
+#include <o3tl/safeint.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <comphelper/property.hxx>
using namespace ::com::sun::star;
@@ -85,15 +93,15 @@ OUString lcl_getServiceNameForType(SvxChartRegress eType)
namespace chart
{
-Reference< XRegressionCurve > RegressionCurveHelper::createMeanValueLine()
+rtl::Reference< RegressionCurveModel > RegressionCurveHelper::createMeanValueLine()
{
- return Reference< XRegressionCurve >( new MeanValueRegressionCurve );
+ return new MeanValueRegressionCurve;
}
-Reference< XRegressionCurve > RegressionCurveHelper::createRegressionCurveByServiceName(
+rtl::Reference< RegressionCurveModel > RegressionCurveHelper::createRegressionCurveByServiceName(
std::u16string_view aServiceName )
{
- Reference< XRegressionCurve > xResult;
+ rtl::Reference< RegressionCurveModel > xResult;
// todo: use factory methods with service name
if( aServiceName == u"com.sun.star.chart2.LinearRegressionCurve" )
@@ -124,10 +132,10 @@ Reference< XRegressionCurve > RegressionCurveHelper::createRegressionCurveByServ
return xResult;
}
-Reference< XRegressionCurveCalculator > RegressionCurveHelper::createRegressionCurveCalculatorByServiceName(
+rtl::Reference< RegressionCurveCalculator > RegressionCurveHelper::createRegressionCurveCalculatorByServiceName(
std::u16string_view aServiceName )
{
- Reference< XRegressionCurveCalculator > xResult;
+ rtl::Reference< RegressionCurveCalculator > xResult;
// todo: use factory methods with service name
if( aServiceName == u"com.sun.star.chart2.MeanValueRegressionCurve" )
@@ -211,8 +219,9 @@ void RegressionCurveHelper::initializeCurveCalculator(
// initialize with 1, 2, ...
//first category (index 0) matches with real number 1.0
aXValues.realloc( aYValues.getLength());
+ auto pXValues = aXValues.getArray();
for( i=0; i<aXValues.getLength(); ++i )
- aXValues[i] = i+1;
+ pXValues[i] = i+1;
bXValuesFound = true;
}
@@ -224,14 +233,14 @@ void RegressionCurveHelper::initializeCurveCalculator(
void RegressionCurveHelper::initializeCurveCalculator(
const Reference< XRegressionCurveCalculator > & xOutCurveCalculator,
- const Reference< XDataSeries > & xSeries,
- const Reference< frame::XModel > & xModel )
+ const rtl::Reference< ::chart::DataSeries > & xSeries,
+ const rtl::Reference<::chart::ChartModel> & xModel )
{
sal_Int32 nAxisType = ChartTypeHelper::getAxisType(
ChartModelHelper::getChartTypeOfSeries( xModel, xSeries ), 0 ); // x-axis
initializeCurveCalculator( xOutCurveCalculator,
- uno::Reference< data::XDataSource >( xSeries, uno::UNO_QUERY ),
+ xSeries,
(nAxisType == AxisType::REALNUMBER) );
}
@@ -259,6 +268,28 @@ bool RegressionCurveHelper::hasMeanValueLine(
return false;
}
+bool RegressionCurveHelper::hasMeanValueLine(
+ const rtl::Reference< DataSeries > & xRegCnt )
+{
+ if( !xRegCnt.is())
+ return false;
+
+ try
+ {
+ for( rtl::Reference< RegressionCurveModel > const & curve : xRegCnt->getRegressionCurves2() )
+ {
+ if( isMeanValueLine( curve ))
+ return true;
+ }
+ }
+ catch( const Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return false;
+}
+
bool RegressionCurveHelper::isMeanValueLine(
const uno::Reference< chart2::XRegressionCurve > & xRegCurve )
{
@@ -268,7 +299,15 @@ bool RegressionCurveHelper::isMeanValueLine(
"com.sun.star.chart2.MeanValueRegressionCurve";
}
-uno::Reference< chart2::XRegressionCurve >
+bool RegressionCurveHelper::isMeanValueLine(
+ const rtl::Reference< RegressionCurveModel > & xRegCurve )
+{
+ return xRegCurve.is() &&
+ xRegCurve->getServiceName() ==
+ "com.sun.star.chart2.MeanValueRegressionCurve";
+}
+
+rtl::Reference< RegressionCurveModel >
RegressionCurveHelper::getMeanValueLine(
const uno::Reference< chart2::XRegressionCurveContainer > & xRegCnt )
{
@@ -281,6 +320,29 @@ uno::Reference< chart2::XRegressionCurve >
for( uno::Reference< XRegressionCurve > const & curve : aCurves )
{
if( isMeanValueLine( curve ))
+ return dynamic_cast<RegressionCurveModel*>(curve.get());
+ }
+ }
+ catch( const Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return nullptr;
+}
+
+rtl::Reference< RegressionCurveModel >
+ RegressionCurveHelper::getMeanValueLine(
+ const rtl::Reference< DataSeries > & xRegCnt )
+{
+ if( xRegCnt.is())
+ {
+ try
+ {
+ for( rtl::Reference< RegressionCurveModel > const & curve : xRegCnt->getRegressionCurves2() )
+ {
+ if( isMeanValueLine( curve ))
return curve;
}
}
@@ -290,7 +352,7 @@ uno::Reference< chart2::XRegressionCurve >
}
}
- return uno::Reference< chart2::XRegressionCurve >();
+ return nullptr;
}
void RegressionCurveHelper::addMeanValueLine(
@@ -316,6 +378,25 @@ void RegressionCurveHelper::addMeanValueLine(
}
}
+void RegressionCurveHelper::addMeanValueLine(
+ rtl::Reference< DataSeries > const & xRegCnt,
+ const uno::Reference< XPropertySet > & xSeriesProp )
+{
+ if( !xRegCnt.is() ||
+ ::chart::RegressionCurveHelper::hasMeanValueLine( xRegCnt ) )
+ return;
+
+ // todo: use a valid context
+ rtl::Reference< RegressionCurveModel > xCurve( createMeanValueLine() );
+ xRegCnt->addRegressionCurve( xCurve );
+
+ if( xSeriesProp.is())
+ {
+ xCurve->setPropertyValue( "LineColor",
+ xSeriesProp->getPropertyValue( "Color"));
+ }
+}
+
void RegressionCurveHelper::removeMeanValueLine(
Reference< XRegressionCurveContainer > const & xRegCnt )
{
@@ -345,13 +426,40 @@ void RegressionCurveHelper::removeMeanValueLine(
}
}
-uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::addRegressionCurve(
+void RegressionCurveHelper::removeMeanValueLine(
+ rtl::Reference< DataSeries > const & xRegCnt )
+{
+ if( !xRegCnt.is())
+ return;
+
+ try
+ {
+ for( rtl::Reference< RegressionCurveModel > const & curve : xRegCnt->getRegressionCurves2() )
+ {
+ if( isMeanValueLine( curve ))
+ {
+ xRegCnt->removeRegressionCurve( curve );
+ // attention: the iterator i has become invalid now
+
+ // note: assume that there is only one mean-value curve
+ // to remove multiple mean-value curves remove the break
+ break;
+ }
+ }
+ }
+ catch( const Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+rtl::Reference< RegressionCurveModel > RegressionCurveHelper::addRegressionCurve(
SvxChartRegress eType,
uno::Reference< XRegressionCurveContainer > const & xRegressionCurveContainer,
const uno::Reference< beans::XPropertySet >& xPropertySource,
const uno::Reference< beans::XPropertySet >& xEquationProperties )
{
- uno::Reference< chart2::XRegressionCurve > xCurve;
+ rtl::Reference< RegressionCurveModel > xCurve;
if( !xRegressionCurveContainer.is() )
return xCurve;
@@ -366,24 +474,20 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::addRegressionC
if( !aServiceName.isEmpty())
{
// todo: use a valid context
- xCurve.set( createRegressionCurveByServiceName( aServiceName ) );
+ xCurve = createRegressionCurveByServiceName( aServiceName );
if( xEquationProperties.is())
xCurve->setEquationProperties( xEquationProperties );
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- if( xProperties.is())
+ if( xPropertySource.is())
+ comphelper::copyProperties( xPropertySource, xCurve );
+ else
{
- if( xPropertySource.is())
- comphelper::copyProperties( xPropertySource, xProperties );
- else
+ uno::Reference< XPropertySet > xSeriesProp( xRegressionCurveContainer, uno::UNO_QUERY );
+ if( xSeriesProp.is())
{
- uno::Reference< XPropertySet > xSeriesProp( xRegressionCurveContainer, uno::UNO_QUERY );
- if( xSeriesProp.is())
- {
- xProperties->setPropertyValue( "LineColor",
- xSeriesProp->getPropertyValue( "Color"));
- }
+ xCurve->setPropertyValue( "LineColor",
+ xSeriesProp->getPropertyValue( "Color"));
}
}
}
@@ -392,67 +496,98 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::addRegressionC
return xCurve;
}
+rtl::Reference< RegressionCurveModel > RegressionCurveHelper::addRegressionCurve(
+ SvxChartRegress eType,
+ rtl::Reference< DataSeries > const & xRegressionCurveContainer,
+ const uno::Reference< beans::XPropertySet >& xPropertySource,
+ const uno::Reference< beans::XPropertySet >& xEquationProperties )
+{
+ rtl::Reference< RegressionCurveModel > xCurve;
+
+ if( !xRegressionCurveContainer.is() )
+ return xCurve;
+
+ if( eType == SvxChartRegress::NONE )
+ {
+ OSL_FAIL("don't create a regression curve of type none");
+ return xCurve;
+ }
+
+ OUString aServiceName( lcl_getServiceNameForType( eType ));
+ if( !aServiceName.isEmpty())
+ {
+ // todo: use a valid context
+ xCurve = createRegressionCurveByServiceName( aServiceName );
+
+ if( xEquationProperties.is())
+ xCurve->setEquationProperties( xEquationProperties );
+
+ if( xPropertySource.is())
+ comphelper::copyProperties( xPropertySource, xCurve );
+ else
+ {
+ xCurve->setPropertyValue( "LineColor",
+ xRegressionCurveContainer->getPropertyValue( "Color"));
+ }
+ }
+ xRegressionCurveContainer->addRegressionCurve( xCurve );
+
+ return xCurve;
+}
+
/** removes all regression curves that are not of type mean value
and returns true, if anything was removed
*/
bool RegressionCurveHelper::removeAllExceptMeanValueLine(
- uno::Reference< chart2::XRegressionCurveContainer > const & xRegCnt )
+ rtl::Reference< DataSeries > const & xRegCnt )
{
+ if( !xRegCnt.is())
+ return false;
+
bool bRemovedSomething = false;
- if( xRegCnt.is())
+ try
{
- try
+ std::vector< rtl::Reference< RegressionCurveModel > > aCurvesToDelete;
+ for( rtl::Reference< RegressionCurveModel > const & curve : xRegCnt->getRegressionCurves2() )
{
- const uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves(
- xRegCnt->getRegressionCurves());
- std::vector< uno::Reference< chart2::XRegressionCurve > > aCurvesToDelete;
- for( uno::Reference< chart2::XRegressionCurve > const & curve : aCurves )
- {
- if( ! isMeanValueLine( curve ))
- {
- aCurvesToDelete.push_back( curve );
- }
- }
-
- for (auto const& curveToDelete : aCurvesToDelete)
+ if( ! isMeanValueLine( curve ))
{
- xRegCnt->removeRegressionCurve(curveToDelete);
- bRemovedSomething = true;
+ aCurvesToDelete.push_back( curve );
}
}
- catch( const uno::Exception & )
+
+ for (auto const& curveToDelete : aCurvesToDelete)
{
- DBG_UNHANDLED_EXCEPTION("chart2");
+ xRegCnt->removeRegressionCurve(curveToDelete);
+ bRemovedSomething = true;
}
}
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
return bRemovedSomething;
}
void RegressionCurveHelper::removeEquations(
- uno::Reference< chart2::XRegressionCurveContainer > const & xRegCnt )
+ rtl::Reference< DataSeries > const & xRegCnt )
{
if( !xRegCnt.is())
return;
try
{
- const uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves(
- xRegCnt->getRegressionCurves());
- for( uno::Reference< chart2::XRegressionCurve > const & curve : aCurves )
+ for( rtl::Reference< RegressionCurveModel > const & curve : xRegCnt->getRegressionCurves2() )
{
if( !isMeanValueLine( curve ) )
{
- uno::Reference< chart2::XRegressionCurve > xRegCurve( curve );
- if( xRegCurve.is() )
+ uno::Reference< beans::XPropertySet > xEqProp( curve->getEquationProperties() ) ;
+ if( xEqProp.is())
{
- uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties() ) ;
- if( xEqProp.is())
- {
- xEqProp->setPropertyValue( "ShowEquation", uno::Any( false ));
- xEqProp->setPropertyValue( "XName", uno::Any( OUString("x") ));
- xEqProp->setPropertyValue( "YName", uno::Any( OUString("f(x) ") ));
- xEqProp->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( false ));
- }
+ xEqProp->setPropertyValue( "ShowEquation", uno::Any( false ));
+ xEqProp->setPropertyValue( "XName", uno::Any( OUString("x") ));
+ xEqProp->setPropertyValue( "YName", uno::Any( OUString("f(x) ") ));
+ xEqProp->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( false ));
}
}
}
@@ -463,7 +598,7 @@ void RegressionCurveHelper::removeEquations(
}
}
-uno::Reference< XRegressionCurve > RegressionCurveHelper::changeRegressionCurveType(
+rtl::Reference< RegressionCurveModel > RegressionCurveHelper::changeRegressionCurveType(
SvxChartRegress eType,
uno::Reference< XRegressionCurveContainer > const & xRegressionCurveContainer,
uno::Reference< XRegressionCurve > const & xRegressionCurve )
@@ -476,7 +611,7 @@ uno::Reference< XRegressionCurve > RegressionCurveHelper::changeRegressionCurveT
xRegressionCurve->getEquationProperties());
}
-uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getFirstCurveNotMeanValueLine(
+rtl::Reference< RegressionCurveModel > RegressionCurveHelper::getFirstCurveNotMeanValueLine(
const Reference< XRegressionCurveContainer > & xRegCnt )
{
if( !xRegCnt.is())
@@ -490,6 +625,30 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getFirstCurveN
{
if( ! isMeanValueLine( curve ))
{
+ return dynamic_cast<RegressionCurveModel*>(curve.get());
+ }
+ }
+ }
+ catch( const Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return nullptr;
+}
+
+rtl::Reference< RegressionCurveModel > RegressionCurveHelper::getFirstCurveNotMeanValueLine(
+ const rtl::Reference< DataSeries > & xRegCnt )
+{
+ if( !xRegCnt.is())
+ return nullptr;
+
+ try
+ {
+ for( rtl::Reference< RegressionCurveModel > const & curve : xRegCnt->getRegressionCurves2() )
+ {
+ if( ! isMeanValueLine( curve ))
+ {
return curve;
}
}
@@ -502,8 +661,8 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getFirstCurveN
return nullptr;
}
-uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getRegressionCurveAtIndex(
- const Reference< XRegressionCurveContainer >& xCurveContainer,
+rtl::Reference< RegressionCurveModel > RegressionCurveHelper::getRegressionCurveAtIndex(
+ const rtl::Reference< DataSeries >& xCurveContainer,
sal_Int32 aIndex )
{
if( !xCurveContainer.is())
@@ -511,8 +670,8 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getRegressionC
try
{
- uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves(xCurveContainer->getRegressionCurves());
- if(0 <= aIndex && aIndex < aCurves.getLength())
+ const std::vector< rtl::Reference< RegressionCurveModel > > aCurves(xCurveContainer->getRegressionCurves2());
+ if(0 <= aIndex && o3tl::make_unsigned(aIndex) < aCurves.size())
{
if(!isMeanValueLine(aCurves[aIndex]))
return aCurves[aIndex];
@@ -681,29 +840,6 @@ OUString RegressionCurveHelper::getRegressionCurveName( const Reference< XRegres
return aResult;
}
-std::vector< Reference< chart2::XRegressionCurve > >
- RegressionCurveHelper::getAllRegressionCurvesNotMeanValueLine(
- const Reference< chart2::XDiagram > & xDiagram )
-{
- std::vector< Reference< chart2::XRegressionCurve > > aResult;
- std::vector< Reference< chart2::XDataSeries > > aSeries( DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
- for (auto const& elem : aSeries)
- {
- Reference< chart2::XRegressionCurveContainer > xContainer(elem, uno::UNO_QUERY);
- if(xContainer.is())
- {
- const uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves(xContainer->getRegressionCurves());
- for( Reference< XRegressionCurve > const & curve : aCurves )
- {
- if( ! isMeanValueLine( curve ))
- aResult.push_back( curve );
- }
- }
- }
-
- return aResult;
-}
-
void RegressionCurveHelper::resetEquationPosition(
const Reference< chart2::XRegressionCurve > & xCurve )
{
@@ -712,7 +848,7 @@ void RegressionCurveHelper::resetEquationPosition(
try
{
- const OUString aPosPropertyName( "RelativePosition" );
+ static constexpr OUString aPosPropertyName( u"RelativePosition"_ustr );
Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); // since m233: , uno::UNO_SET_THROW );
if( xEqProp->getPropertyValue( aPosPropertyName ).hasValue())
xEqProp->setPropertyValue( aPosPropertyName, uno::Any());
@@ -724,15 +860,15 @@ void RegressionCurveHelper::resetEquationPosition(
}
sal_Int32 RegressionCurveHelper::getRegressionCurveIndex(
- const Reference< chart2::XRegressionCurveContainer >& xContainer,
- const Reference< chart2::XRegressionCurve >& xCurve )
+ const rtl::Reference< DataSeries >& xContainer,
+ const rtl::Reference< RegressionCurveModel >& xCurve )
{
if( xContainer.is())
{
- uno::Sequence< uno::Reference< XRegressionCurve > > aCurves(
- xContainer->getRegressionCurves());
+ const std::vector< rtl::Reference< RegressionCurveModel > > & aCurves(
+ xContainer->getRegressionCurves2());
- for( sal_Int32 i = 0; i < aCurves.getLength(); ++i )
+ for( std::size_t i = 0; i < aCurves.size(); ++i )
{
if( xCurve == aCurves[i] )
return i;
@@ -759,6 +895,20 @@ bool RegressionCurveHelper::hasEquation( const Reference< chart2::XRegressionCur
return bHasEquation;
}
+bool RegressionCurveHelper::MayHaveCorrelationCoefficient( const Reference< chart2::XRegressionCurve > & xCurve )
+{
+ bool bMayHaveCorrelationCoefficient = true;
+ if( xCurve.is())
+ {
+ uno::Reference< beans::XPropertySet > xEquationProp( xCurve->getEquationProperties() );
+ if( xEquationProp.is() )
+ {
+ xEquationProp->getPropertyValue( "MayHaveCorrelationCoefficient") >>= bMayHaveCorrelationCoefficient;
+ }
+ }
+ return bMayHaveCorrelationCoefficient;
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/tools/RegressionCurveModel.cxx b/chart2/source/tools/RegressionCurveModel.cxx
index 649e93e2702f..06be003ef106 100644
--- a/chart2/source/tools/RegressionCurveModel.cxx
+++ b/chart2/source/tools/RegressionCurveModel.cxx
@@ -17,8 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "RegressionCurveModel.hxx"
+#include <RegressionCurveModel.hxx>
#include <LinePropertiesHelper.hxx>
+#include <RegressionCurveCalculator.hxx>
#include <RegressionCurveHelper.hxx>
#include "RegressionEquation.hxx"
#include <CloneHelper.hxx>
@@ -26,7 +27,6 @@
#include <ModifyListenerHelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
-#include <tools/diagnose_ex.h>
namespace com::sun::star::uno { class XComponentContext; }
@@ -44,7 +44,8 @@ enum
PROPERTY_EXTRAPOLATE_BACKWARD,
PROPERTY_FORCE_INTERCEPT,
PROPERTY_INTERCEPT_VALUE,
- PROPERTY_CURVE_NAME
+ PROPERTY_CURVE_NAME,
+ PROPERTY_MOVING_AVERAGE_TYPE
};
void lcl_AddPropertiesToVector(
@@ -62,6 +63,12 @@ void lcl_AddPropertiesToVector(
beans::PropertyAttribute::BOUND |
beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "MovingAverageType",
+ PROPERTY_MOVING_AVERAGE_TYPE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND |
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
rOutProperties.emplace_back( "ExtrapolateForward",
PROPERTY_EXTRAPOLATE_FORWARD,
cppu::UnoType<double>::get(),
@@ -92,31 +99,21 @@ void lcl_AddPropertiesToVector(
beans::PropertyAttribute::BOUND );
}
-struct StaticXXXDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::LinePropertiesHelper::AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-};
-
-struct StaticXXXDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticXXXDefaults_Initializer >
+const ::chart::tPropertyValueMap & GetStaticXXXDefaults()
{
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ [](){
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
-struct StaticRegressionCurveInfoHelper_Initializer
+::cppu::OPropertyArrayHelper& GetStaticRegressionCurveInfoHelper()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::Sequence< Property > lcl_GetPropertySequence()
- {
+ static ::cppu::OPropertyArrayHelper aPropHelper =
+ [](){
std::vector< css::beans::Property > aProperties;
lcl_AddPropertiesToVector( aProperties );
::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
@@ -125,25 +122,15 @@ private:
::chart::PropertyNameLess() );
return comphelper::containerToSequence( aProperties );
- }
-};
-
-struct StaticRegressionCurveInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticRegressionCurveInfoHelper_Initializer >
-{
+ }();
+ return aPropHelper;
};
-struct StaticRegressionCurveInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticRegressionCurveInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticRegressionCurveInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticRegressionCurveInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& GetStaticRegressionCurveInfo()
{
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(GetStaticRegressionCurveInfoHelper() ) );
+ return xPropertySetInfo;
};
} // anonymous namespace
@@ -152,9 +139,8 @@ namespace chart
{
RegressionCurveModel::RegressionCurveModel( tCurveType eCurveType ) :
- ::property::OPropertySet( m_aMutex ),
m_eRegressionCurveType( eCurveType ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_xEquationProperties( new RegressionEquation )
{
// set 0 line width (default) hard, so that it is always written to XML,
@@ -166,9 +152,9 @@ RegressionCurveModel::RegressionCurveModel( tCurveType eCurveType ) :
RegressionCurveModel::RegressionCurveModel( const RegressionCurveModel & rOther ) :
impl::RegressionCurveModel_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
+ ::property::OPropertySet( rOther ),
m_eRegressionCurveType( rOther.m_eRegressionCurveType ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
m_xEquationProperties.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( rOther.m_xEquationProperties ));
ModifyListenerHelper::addListener( m_xEquationProperties, m_xModifyEventForwarder );
@@ -197,11 +183,20 @@ void SAL_CALL RegressionCurveModel::setEquationProperties( const uno::Reference<
ModifyListenerHelper::removeListener( m_xEquationProperties, m_xModifyEventForwarder );
m_xEquationProperties.set( xEquationProperties );
+ setPropertyMayHaveR2();
ModifyListenerHelper::addListener( m_xEquationProperties, m_xModifyEventForwarder );
fireModifyEvent();
}
}
+void RegressionCurveModel::setPropertyMayHaveR2()
+{
+ if( m_xEquationProperties.is()) {
+ bool bMayHaveR2 = m_eRegressionCurveType != CURVE_TYPE_MOVING_AVERAGE;
+ m_xEquationProperties->setPropertyValue( "MayHaveCorrelationCoefficient", uno::Any( bMayHaveR2 ) );
+ }
+}
+
// ____ XServiceName ____
OUString SAL_CALL RegressionCurveModel::getServiceName()
{
@@ -229,28 +224,12 @@ OUString SAL_CALL RegressionCurveModel::getServiceName()
// ____ XModifyBroadcaster ____
void SAL_CALL RegressionCurveModel::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL RegressionCurveModel::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -268,6 +247,7 @@ void SAL_CALL RegressionCurveModel::disposing( const lang::EventObject& /* Sourc
// ____ OPropertySet ____
void RegressionCurveModel::firePropertyChangeEvent()
{
+ setPropertyMayHaveR2();
fireModifyEvent();
}
@@ -277,24 +257,25 @@ void RegressionCurveModel::fireModifyEvent()
}
// ____ OPropertySet ____
-uno::Any RegressionCurveModel::GetDefaultValue( sal_Int32 nHandle ) const
+void RegressionCurveModel::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticXXXDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = GetStaticXXXDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL RegressionCurveModel::getInfoHelper()
{
- return *StaticRegressionCurveInfoHelper::get();
+ return GetStaticRegressionCurveInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL RegressionCurveModel::getPropertySetInfo()
{
- return *StaticRegressionCurveInfo::get();
+ return GetStaticRegressionCurveInfo();
}
// needed by MSC compiler
diff --git a/chart2/source/tools/RegressionCurveModel.hxx b/chart2/source/tools/RegressionCurveModel.hxx
deleted file mode 100644
index c20e773601a4..000000000000
--- a/chart2/source/tools/RegressionCurveModel.hxx
+++ /dev/null
@@ -1,241 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#pragma once
-
-#include <MutexContainer.hxx>
-#include <OPropertySet.hxx>
-
-#include <cppuhelper/implbase.hxx>
-#include <comphelper/uno3.hxx>
-
-#include <com/sun/star/chart2/XRegressionCurve.hpp>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XServiceName.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakImplHelper<
- css::lang::XServiceInfo,
- css::lang::XServiceName,
- css::chart2::XRegressionCurve,
- css::util::XCloneable,
- css::util::XModifyBroadcaster,
- css::util::XModifyListener >
- RegressionCurveModel_Base;
-}
-
-class RegressionCurveModel :
- public MutexContainer,
- public impl::RegressionCurveModel_Base,
- public ::property::OPropertySet
-{
-public:
- enum tCurveType
- {
- CURVE_TYPE_MEAN_VALUE,
- CURVE_TYPE_LINEAR,
- CURVE_TYPE_LOGARITHM,
- CURVE_TYPE_EXPONENTIAL,
- CURVE_TYPE_POWER,
- CURVE_TYPE_POLYNOMIAL,
- CURVE_TYPE_MOVING_AVERAGE
- };
-
- RegressionCurveModel( tCurveType eCurveType );
- RegressionCurveModel( const RegressionCurveModel & rOther );
- virtual ~RegressionCurveModel() override;
-
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
- /// merge XTypeProvider implementations
- DECLARE_XTYPEPROVIDER()
-
-protected:
- // ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
-
- // ____ OPropertySet ____
- virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
-
- // ____ XPropertySet ____
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo() override;
-
- // ____ XRegressionCurve ____
- virtual css::uno::Reference< css::chart2::XRegressionCurveCalculator > SAL_CALL getCalculator() override;
- virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getEquationProperties() override;
- virtual void SAL_CALL setEquationProperties(
- const css::uno::Reference< css::beans::XPropertySet >& xEquationProperties ) override;
-
- // ____ XServiceName ____
- virtual OUString SAL_CALL getServiceName() override;
-
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
- virtual void SAL_CALL removeModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
-
- // ____ XModifyListener ____
- virtual void SAL_CALL modified(
- const css::lang::EventObject& aEvent ) override;
-
- // ____ XEventListener (base of XModifyListener) ____
- virtual void SAL_CALL disposing(
- const css::lang::EventObject& Source ) override;
-
- using ::cppu::OPropertySetHelper::disposing;
-
- // ____ OPropertySet ____
- virtual void firePropertyChangeEvent() override;
-
- void fireModifyEvent();
-
-private:
- const tCurveType m_eRegressionCurveType;
-
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
- css::uno::Reference< css::beans::XPropertySet > m_xEquationProperties;
-};
-
-// implementations for factory instantiation
-
-class MeanValueRegressionCurve : public RegressionCurveModel
-{
-public:
- explicit MeanValueRegressionCurve();
- explicit MeanValueRegressionCurve(
- const MeanValueRegressionCurve & rOther );
- virtual ~MeanValueRegressionCurve() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- /// XServiceInfo declarations
- virtual OUString SAL_CALL getImplementationName() override;
- virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
-};
-
-class LinearRegressionCurve : public RegressionCurveModel
-{
-public:
- explicit LinearRegressionCurve();
- explicit LinearRegressionCurve( const LinearRegressionCurve & rOther );
- virtual ~LinearRegressionCurve() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- /// XServiceInfo declarations
- virtual OUString SAL_CALL getImplementationName() override;
- virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
-};
-
-class LogarithmicRegressionCurve : public RegressionCurveModel
-{
-public:
- explicit LogarithmicRegressionCurve();
- explicit LogarithmicRegressionCurve( const LogarithmicRegressionCurve & rOther );
- virtual ~LogarithmicRegressionCurve() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- /// XServiceInfo declarations
- virtual OUString SAL_CALL getImplementationName() override;
- virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
-};
-
-class ExponentialRegressionCurve : public RegressionCurveModel
-{
-public:
- explicit ExponentialRegressionCurve();
- explicit ExponentialRegressionCurve( const ExponentialRegressionCurve & rOther );
- virtual ~ExponentialRegressionCurve() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- /// XServiceInfo declarations
- virtual OUString SAL_CALL getImplementationName() override;
- virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
-};
-
-class PotentialRegressionCurve : public RegressionCurveModel
-{
-public:
- explicit PotentialRegressionCurve();
- explicit PotentialRegressionCurve( const PotentialRegressionCurve & rOther );
- virtual ~PotentialRegressionCurve() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- /// XServiceInfo declarations
- virtual OUString SAL_CALL getImplementationName() override;
- virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
-};
-
-class PolynomialRegressionCurve : public RegressionCurveModel
-{
-public:
- explicit PolynomialRegressionCurve();
- explicit PolynomialRegressionCurve( const PolynomialRegressionCurve & rOther );
- virtual ~PolynomialRegressionCurve() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- /// XServiceInfo declarations
- virtual OUString SAL_CALL getImplementationName() override;
- virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
-};
-
-class MovingAverageRegressionCurve : public RegressionCurveModel
-{
-public:
- explicit MovingAverageRegressionCurve();
- explicit MovingAverageRegressionCurve( const MovingAverageRegressionCurve & rOther );
- virtual ~MovingAverageRegressionCurve() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- /// XServiceInfo declarations
- virtual OUString SAL_CALL getImplementationName() override;
- virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/tools/RegressionEquation.cxx b/chart2/source/tools/RegressionEquation.cxx
index 1c46dc69f054..34bbd6b491d9 100644
--- a/chart2/source/tools/RegressionEquation.cxx
+++ b/chart2/source/tools/RegressionEquation.cxx
@@ -33,7 +33,6 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/awt/Size.hpp>
-#include <tools/diagnose_ex.h>
#include <algorithm>
@@ -54,6 +53,7 @@ enum
PROP_EQUATION_XNAME,
PROP_EQUATION_YNAME,
PROP_EQUATION_SHOW_CORRELATION_COEFF,
+ PROP_EQUATION_MAY_HAVE_CORRELATION_COEFF,
PROP_EQUATION_REF_PAGE_SIZE,
PROP_EQUATION_REL_POS,
PROP_EQUATION_NUMBER_FORMAT
@@ -86,6 +86,12 @@ void lcl_AddPropertiesToVector(
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "MayHaveCorrelationCoefficient",
+ PROP_EQUATION_MAY_HAVE_CORRELATION_COEFF,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
rOutProperties.emplace_back( "ReferencePageSize",
PROP_EQUATION_REF_PAGE_SIZE,
cppu::UnoType<awt::Size>::get(),
@@ -105,84 +111,59 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEVOID );
}
-struct StaticRegressionEquationDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
- ::chart::FillProperties::AddDefaultsToMap( rOutMap );
- ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
-
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_XNAME, OUString("x") );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_YNAME, OUString("f(x)") );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW_CORRELATION_COEFF, false );
- //::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SEPARATOR, OUString( '\n' ));
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
-
- float fDefaultCharHeight = 10.0;
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
- }
-};
-
-struct StaticRegressionEquationDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticRegressionEquationDefaults_Initializer >
-{
-};
-
-struct StaticRegressionEquationInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
- ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
- ::chart::FillProperties::AddPropertiesToVector( aProperties );
- ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticRegressionEquationInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticRegressionEquationInfoHelper_Initializer >
+::chart::tPropertyValueMap& GetStaticRegressionEquationDefaults()
{
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ [](){
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aOutMap );
+ ::chart::FillProperties::AddDefaultsToMap( aOutMap );
+ ::chart::CharacterProperties::AddDefaultsToMap( aOutMap );
+
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_SHOW, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_XNAME, OUString("x") );
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_YNAME, OUString("f(x)") );
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_SHOW_CORRELATION_COEFF, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_MAY_HAVE_CORRELATION_COEFF, true );
+ //::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_SEPARATOR, OUString( '\n' ));
+
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue( aOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
+ ::chart::PropertyHelper::setPropertyValue( aOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
+
+ float fDefaultCharHeight = 10.0;
+ ::chart::PropertyHelper::setPropertyValue( aOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
};
-struct StaticRegressionEquationInfo_Initializer
+::cppu::OPropertyArrayHelper& GetStaticRegressionEquationInfoHelper()
{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticRegressionEquationInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
+ static ::cppu::OPropertyArrayHelper aPropHelper =
+ [](){
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
-struct StaticRegressionEquationInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticRegressionEquationInfo_Initializer >
+const uno::Reference< beans::XPropertySetInfo > & GetStaticRegressionEquationInfo()
{
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(GetStaticRegressionEquationInfoHelper()) );
+ return xPropertySetInfo;
};
} // anonymous namespace
@@ -191,14 +172,13 @@ namespace chart
{
RegressionEquation::RegressionEquation() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( new ModifyListenerHelper::ModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder())
{}
RegressionEquation::RegressionEquation( const RegressionEquation & rOther ) :
impl::RegressionEquation_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( new ModifyListenerHelper::ModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder())
{}
RegressionEquation::~RegressionEquation()
@@ -211,51 +191,36 @@ uno::Reference< util::XCloneable > SAL_CALL RegressionEquation::createClone()
}
// ____ OPropertySet ____
-uno::Any RegressionEquation::GetDefaultValue( sal_Int32 nHandle ) const
+void RegressionEquation::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticRegressionEquationDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = GetStaticRegressionEquationDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL RegressionEquation::getInfoHelper()
{
- return *StaticRegressionEquationInfoHelper::get();
+ return GetStaticRegressionEquationInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL RegressionEquation::getPropertySetInfo()
{
- return *StaticRegressionEquationInfo::get();
+ return GetStaticRegressionEquationInfo();
}
// ____ XModifyBroadcaster ____
void SAL_CALL RegressionEquation::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL RegressionEquation::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
diff --git a/chart2/source/tools/RegressionEquation.hxx b/chart2/source/tools/RegressionEquation.hxx
index 03d1a7f295e5..8a500cd1d73c 100644
--- a/chart2/source/tools/RegressionEquation.hxx
+++ b/chart2/source/tools/RegressionEquation.hxx
@@ -20,15 +20,13 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
#include <com/sun/star/chart2/XTitle.hpp>
-#include <MutexContainer.hxx>
#include <OPropertySet.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/uno3.hxx>
+#include <ModifyListenerHelper.hxx>
namespace chart
{
@@ -45,7 +43,6 @@ typedef ::cppu::WeakImplHelper<
}
class RegressionEquation final :
- public MutexContainer,
public impl::RegressionEquation_Base,
public ::property::OPropertySet
{
@@ -70,7 +67,7 @@ private:
explicit RegressionEquation( const RegressionEquation & rOther );
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -111,7 +108,7 @@ private:
css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > > m_aStrings;
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+ rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
};
} // namespace chart
diff --git a/chart2/source/tools/RelativePositionHelper.cxx b/chart2/source/tools/RelativePositionHelper.cxx
index deb3e5ca5a2c..260888e907dd 100644
--- a/chart2/source/tools/RelativePositionHelper.cxx
+++ b/chart2/source/tools/RelativePositionHelper.cxx
@@ -237,9 +237,9 @@ awt::Point RelativePositionHelper::getCenterOfAnchoredObject(
//take rotation into account:
aResult.X += static_cast< sal_Int32 >(
- ::rtl::math::round( fXDelta * rtl::math::cos( fAnglePi ) + fYDelta * rtl::math::sin( fAnglePi ) ) );
+ ::rtl::math::round( fXDelta * std::cos( fAnglePi ) + fYDelta * std::sin( fAnglePi ) ) );
aResult.Y += static_cast< sal_Int32 >(
- ::rtl::math::round( - fXDelta * rtl::math::sin( fAnglePi ) + fYDelta * rtl::math::cos( fAnglePi ) ) );
+ ::rtl::math::round( - fXDelta * std::sin( fAnglePi ) + fYDelta * std::cos( fAnglePi ) ) );
return aResult;
}
diff --git a/chart2/source/tools/RelativeSizeHelper.cxx b/chart2/source/tools/RelativeSizeHelper.cxx
index a142d5b293e8..4a3cd84cfb88 100644
--- a/chart2/source/tools/RelativeSizeHelper.cxx
+++ b/chart2/source/tools/RelativeSizeHelper.cxx
@@ -20,14 +20,13 @@
#include <RelativeSizeHelper.hxx>
#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <tools/diagnose_ex.h>
-
+#include <comphelper/diagnose_ex.hxx>
+#include <svx/unoshape.hxx>
#include <vector>
#include <algorithm>
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Any;
@@ -45,13 +44,44 @@ double RelativeSizeHelper::calculate(
rOldReferenceSize.Height <= 0 )
return fValue;
- return min(
+ return std::min(
static_cast< double >( rNewReferenceSize.Width ) / static_cast< double >( rOldReferenceSize.Width ),
static_cast< double >( rNewReferenceSize.Height ) / static_cast< double >( rOldReferenceSize.Height ))
* fValue;
}
void RelativeSizeHelper::adaptFontSizes(
+ SvxShapeText& xTargetProperties,
+ const awt::Size & rOldReferenceSize,
+ const awt::Size & rNewReferenceSize )
+{
+ float fFontHeight = 0;
+
+ std::vector< OUString > aProperties;
+ aProperties.emplace_back("CharHeight" );
+ aProperties.emplace_back("CharHeightAsian" );
+ aProperties.emplace_back("CharHeightComplex" );
+
+ for (auto const& property : aProperties)
+ {
+ try
+ {
+ if( xTargetProperties.SvxShape::getPropertyValue(property) >>= fFontHeight )
+ {
+ xTargetProperties.SvxShape::setPropertyValue(
+ property,
+ Any( static_cast< float >(
+ calculate( fFontHeight, rOldReferenceSize, rNewReferenceSize ))));
+ }
+ }
+ catch( const Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+}
+
+void RelativeSizeHelper::adaptFontSizes(
const Reference< XPropertySet > & xTargetProperties,
const awt::Size & rOldReferenceSize,
const awt::Size & rNewReferenceSize )
@@ -61,7 +91,7 @@ void RelativeSizeHelper::adaptFontSizes(
float fFontHeight = 0;
- vector< OUString > aProperties;
+ std::vector< OUString > aProperties;
aProperties.emplace_back("CharHeight" );
aProperties.emplace_back("CharHeightAsian" );
aProperties.emplace_back("CharHeightComplex" );
diff --git a/chart2/source/tools/ResId.cxx b/chart2/source/tools/ResId.cxx
index 850eb9b84dd7..aaa1d840c95c 100644
--- a/chart2/source/tools/ResId.cxx
+++ b/chart2/source/tools/ResId.cxx
@@ -18,13 +18,12 @@
*/
#include <ResId.hxx>
-#include <unotools/resmgr.hxx>
namespace chart
{
- OUString SchResId(const char *pId)
+ OUString SchResId(TranslateId aId)
{
- return Translate::get(pId, Translate::Create("chart"));
+ return Translate::get(aId, Translate::Create("chart"));
}
} // namespace chart
diff --git a/chart2/source/tools/Scaling.cxx b/chart2/source/tools/Scaling.cxx
index 27a9c51a7a44..b7179537c43b 100644
--- a/chart2/source/tools/Scaling.cxx
+++ b/chart2/source/tools/Scaling.cxx
@@ -18,19 +18,21 @@
*/
#include <Scaling.hxx>
-#include <rtl/math.hxx>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <cppuhelper/supportsservice.hxx>
+#include <cmath>
+#include <limits>
+
namespace com::sun::star::uno { class XComponentContext; }
namespace
{
-const char lcl_aServiceName_Logarithmic[] = "com.sun.star.chart2.LogarithmicScaling";
-const char lcl_aServiceName_Exponential[] = "com.sun.star.chart2.ExponentialScaling";
-const char lcl_aServiceName_Linear[] = "com.sun.star.chart2.LinearScaling";
-const char lcl_aServiceName_Power[] = "com.sun.star.chart2.PowerScaling";
+constexpr OUString lcl_aServiceName_Logarithmic = u"com.sun.star.chart2.LogarithmicScaling"_ustr;
+constexpr OUString lcl_aServiceName_Exponential = u"com.sun.star.chart2.ExponentialScaling"_ustr;
+constexpr OUString lcl_aServiceName_Linear = u"com.sun.star.chart2.LinearScaling"_ustr;
+constexpr OUString lcl_aServiceName_Power = u"com.sun.star.chart2.PowerScaling"_ustr;
}
@@ -57,12 +59,9 @@ LogarithmicScaling::~LogarithmicScaling()
double SAL_CALL LogarithmicScaling::doScaling( double value )
{
- double fResult;
if( std::isnan( value ) || std::isinf( value ) )
- ::rtl::math::setNan( & fResult );
- else
- fResult = log( value ) / m_fLogOfBase;
- return fResult;
+ return std::numeric_limits<double>::quiet_NaN();
+ return std::log( value ) / m_fLogOfBase;
}
uno::Reference< XScaling > SAL_CALL LogarithmicScaling::getInverseScaling()
@@ -106,12 +105,9 @@ ExponentialScaling::~ExponentialScaling()
double SAL_CALL ExponentialScaling::doScaling( double value )
{
- double fResult;
if( std::isnan( value ) || std::isinf( value ) )
- ::rtl::math::setNan( & fResult );
- else
- fResult = pow( m_fBase, value );
- return fResult;
+ return std::numeric_limits<double>::quiet_NaN();
+ return std::pow( m_fBase, value );
}
uno::Reference< XScaling > SAL_CALL ExponentialScaling::getInverseScaling()
@@ -154,12 +150,9 @@ LinearScaling::~LinearScaling()
double SAL_CALL LinearScaling::doScaling( double value )
{
- double fResult;
if( std::isnan( value ) || std::isinf( value ) )
- ::rtl::math::setNan( & fResult );
- else
- fResult = m_fOffset + m_fSlope * value;
- return fResult;
+ return std::numeric_limits<double>::quiet_NaN();
+ return m_fOffset + m_fSlope * value;
}
uno::Reference< XScaling > SAL_CALL
@@ -167,7 +160,7 @@ uno::Reference< XScaling > SAL_CALL
{
// ToDo: ApproxEqual ?
if( m_fSlope == 0 )
- throw uno::RuntimeException();
+ throw uno::RuntimeException("Divide by zero exception");
return new LinearScaling( 1.0 / m_fSlope, m_fOffset / m_fSlope );
}
@@ -205,12 +198,9 @@ PowerScaling::~PowerScaling()
double SAL_CALL PowerScaling::doScaling( double value )
{
- double fResult;
if( std::isnan( value ) || std::isinf( value ) )
- ::rtl::math::setNan( & fResult );
- else
- fResult = pow( value, m_fExponent );
- return fResult;
+ return std::numeric_limits<double>::quiet_NaN();
+ return std::pow( value, m_fExponent );
}
uno::Reference< XScaling > SAL_CALL
@@ -218,7 +208,7 @@ uno::Reference< XScaling > SAL_CALL
{
// ToDo: ApproxEqual ?
if( m_fExponent == 0 )
- throw uno::RuntimeException();
+ throw uno::RuntimeException("Divide by zero exception");
return new PowerScaling( 1.0 / m_fExponent );
}
diff --git a/chart2/source/tools/SceneProperties.cxx b/chart2/source/tools/SceneProperties.cxx
index 9d5746ef649d..eb65d81c94db 100644
--- a/chart2/source/tools/SceneProperties.cxx
+++ b/chart2/source/tools/SceneProperties.cxx
@@ -18,6 +18,7 @@
*/
#include <SceneProperties.hxx>
+#include <ChartType.hxx>
#include <ChartTypeHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/HomogenMatrix.hpp>
@@ -276,13 +277,13 @@ void SceneProperties::AddDefaultsToMap(
aMtx.Line4.Column1 = aMtx.Line4.Column2 = aMtx.Line4.Column3 = 0.0;
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_TRANSF_MATRIX, aMtx );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCENE_DISTANCE, 4200 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCENE_FOCAL_LENGTH, 8000 );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_DISTANCE, sal_Int32(4200) );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_FOCAL_LENGTH, sal_Int32(8000) );
// PROP_SCENE_SHADOW_SLANT;
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_SHADE_MODE, drawing::ShadeMode_SMOOTH );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >(
+ ::chart::PropertyHelper::setPropertyValueDefault(
rOutMap, PROP_SCENE_AMBIENT_COLOR, ChartTypeHelper::getDefaultAmbientLightColor(false,nullptr));
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_TWO_SIDED_LIGHTING, true );
diff --git a/chart2/source/tools/StatisticsHelper.cxx b/chart2/source/tools/StatisticsHelper.cxx
index 02dab3b9bd89..5f3bbdf802d6 100644
--- a/chart2/source/tools/StatisticsHelper.cxx
+++ b/chart2/source/tools/StatisticsHelper.cxx
@@ -18,20 +18,22 @@
*/
#include <StatisticsHelper.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <ErrorBar.hxx>
#include <unonames.hxx>
-#include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx>
#include <comphelper/processfactory.hxx>
-#include <com/sun/star/chart2/XDataSeries.hpp>
#include <com/sun/star/chart2/data/LabeledDataSequence.hpp>
#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
#include <com/sun/star/chart2/data/XDataSink.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+
+#include <cmath>
+#include <limits>
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
@@ -60,19 +62,14 @@ double lcl_getVariance( const Sequence< double > & rData, sal_Int32 & rOutValidC
}
}
- double fResult;
if( rOutValidCount == 0 )
- ::rtl::math::setNan( & fResult );
- else
- {
- const double fN = static_cast< double >( rOutValidCount );
- fResult = (fQuadSum - fSum*fSum/fN) / fN;
- }
+ return std::numeric_limits<double>::quiet_NaN();
- return fResult;
+ const double fN = static_cast< double >( rOutValidCount );
+ return (fQuadSum - fSum*fSum/fN) / fN;
}
-Reference< chart2::data::XLabeledDataSequence > lcl_getErrorBarLabeledSequence(
+uno::Reference< chart2::data::XLabeledDataSequence > lcl_getErrorBarLabeledSequence(
const Reference< chart2::data::XDataSource > & xDataSource,
bool bPositiveValue, bool bYError,
OUString & rOutRoleNameUsed )
@@ -84,8 +81,7 @@ Reference< chart2::data::XLabeledDataSequence > lcl_getErrorBarLabeledSequence(
aRole.append( 'x');
OUString aPlainRole = aRole.makeStringAndClear();
- aRole.append( aPlainRole );
- aRole.append( '-' );
+ aRole.append( aPlainRole + "-" );
if( bPositiveValue )
aRole.append( "positive" );
@@ -93,14 +89,14 @@ Reference< chart2::data::XLabeledDataSequence > lcl_getErrorBarLabeledSequence(
aRole.append( "negative" );
OUString aLongRole = aRole.makeStringAndClear();
- Reference< chart2::data::XLabeledDataSequence > xLSeq(
- ::chart::DataSeriesHelper::getDataSequenceByRole( xDataSource, aLongRole ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xLSeq =
+ ::chart::DataSeriesHelper::getDataSequenceByRole( xDataSource, aLongRole );
// try role without "-negative" or "-positive" postfix
if( xLSeq.is())
rOutRoleNameUsed = aLongRole;
else
{
- xLSeq.set( ::chart::DataSeriesHelper::getDataSequenceByRole( xDataSource, aPlainRole ));
+ xLSeq = ::chart::DataSeriesHelper::getDataSequenceByRole( xDataSource, aPlainRole );
if( xLSeq.is())
rOutRoleNameUsed = aPlainRole;
else
@@ -136,7 +132,8 @@ void lcl_addSequenceToDataSource(
Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
xDataSource->getDataSequences());
aSequences.realloc( aSequences.getLength() + 1 );
- aSequences[ aSequences.getLength() - 1 ] = xLSeq;
+ auto pSequences = aSequences.getArray();
+ pSequences[ aSequences.getLength() - 1 ] = xLSeq;
xSink->setData( aSequences );
}
@@ -146,7 +143,7 @@ void lcl_setXMLRangePropertyAtDataSequence(
{
try
{
- const OUString aXMLRangePropName( "CachedXMLRange");
+ static constexpr OUString aXMLRangePropName( u"CachedXMLRange"_ustr);
Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY_THROW );
Reference< beans::XPropertySetInfo > xInfo( xProp->getPropertySetInfo());
if( xInfo.is() && xInfo->hasPropertyByName( aXMLRangePropName ))
@@ -183,36 +180,27 @@ double StatisticsHelper::getStandardError( const Sequence< double > & rData )
{
sal_Int32 nValCount;
double fVar = lcl_getVariance( rData, nValCount );
- double fResult;
-
- if( nValCount == 0 ||
- std::isnan( fVar ))
- {
- ::rtl::math::setNan( & fResult );
- }
- else
- {
- // standard-deviation / sqrt(n)
- fResult = sqrt( fVar ) / sqrt( double(nValCount) );
- }
- return fResult;
+ if( nValCount == 0 || std::isnan( fVar ))
+ return std::numeric_limits<double>::quiet_NaN();
+ // standard-deviation / sqrt(n)
+ return sqrt( fVar ) / sqrt( double(nValCount) );
}
-Reference< chart2::data::XLabeledDataSequence > StatisticsHelper::getErrorLabeledDataSequenceFromDataSource(
+uno::Reference< chart2::data::XLabeledDataSequence > StatisticsHelper::getErrorLabeledDataSequenceFromDataSource(
const Reference< chart2::data::XDataSource > & xDataSource,
bool bPositiveValue,
bool bYError /* = true */ )
{
- Reference< chart2::data::XLabeledDataSequence > xResult;
+ uno::Reference< chart2::data::XLabeledDataSequence > xResult;
if( !xDataSource.is())
return xResult;
OUString aRole;
- Reference< chart2::data::XLabeledDataSequence > xLSeq(
- lcl_getErrorBarLabeledSequence( xDataSource, bPositiveValue, bYError, aRole ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xLSeq =
+ lcl_getErrorBarLabeledSequence( xDataSource, bPositiveValue, bYError, aRole );
if( xLSeq.is())
- xResult.set( xLSeq );
+ xResult = xLSeq;
return xResult;
}
@@ -222,10 +210,10 @@ Reference< chart2::data::XDataSequence > StatisticsHelper::getErrorDataSequenceF
bool bPositiveValue,
bool bYError /* = true */ )
{
- Reference< chart2::data::XLabeledDataSequence > xLSeq(
+ uno::Reference< chart2::data::XLabeledDataSequence > xLSeq =
StatisticsHelper::getErrorLabeledDataSequenceFromDataSource(
xDataSource, bPositiveValue,
- bYError ));
+ bYError );
if( !xLSeq.is())
return Reference< chart2::data::XDataSequence >();
@@ -238,8 +226,7 @@ double StatisticsHelper::getErrorFromDataSource(
bool bPositiveValue,
bool bYError /* = true */ )
{
- double fResult = 0.0;
- ::rtl::math::setNan( & fResult );
+ double fResult = std::numeric_limits<double>::quiet_NaN();
Reference< chart2::data::XDataSequence > xValues(
StatisticsHelper::getErrorDataSequenceFromDataSource( xDataSource, bPositiveValue, bYError ));
@@ -293,18 +280,17 @@ void StatisticsHelper::setErrorDataSequence(
}
Reference< beans::XPropertySet > StatisticsHelper::addErrorBars(
- const Reference< chart2::XDataSeries > & xDataSeries,
+ const rtl::Reference< DataSeries > & xDataSeries,
sal_Int32 nStyle,
bool bYError /* = true */ )
{
Reference< beans::XPropertySet > xErrorBar;
- Reference< beans::XPropertySet > xSeriesProp( xDataSeries, uno::UNO_QUERY );
- if( !xSeriesProp.is())
+ if( !xDataSeries.is())
return xErrorBar;
const OUString aPropName(
- bYError ? OUString(CHART_UNONAME_ERRORBAR_Y) : OUString(CHART_UNONAME_ERRORBAR_X));
- if( !( xSeriesProp->getPropertyValue( aPropName ) >>= xErrorBar ) ||
+ bYError ? CHART_UNONAME_ERRORBAR_Y : CHART_UNONAME_ERRORBAR_X);
+ if( !( xDataSeries->getPropertyValue( aPropName ) >>= xErrorBar ) ||
!xErrorBar.is())
{
xErrorBar.set( new ErrorBar );
@@ -316,28 +302,27 @@ Reference< beans::XPropertySet > StatisticsHelper::addErrorBars(
xErrorBar->setPropertyValue( "ErrorBarStyle", uno::Any( nStyle ));
}
- xSeriesProp->setPropertyValue( aPropName, uno::Any( xErrorBar ));
+ xDataSeries->setPropertyValue( aPropName, uno::Any( xErrorBar ));
return xErrorBar;
}
Reference< beans::XPropertySet > StatisticsHelper::getErrorBars(
- const Reference< chart2::XDataSeries > & xDataSeries,
+ const rtl::Reference< DataSeries > & xDataSeries,
bool bYError /* = true */ )
{
- Reference< beans::XPropertySet > xSeriesProp( xDataSeries, uno::UNO_QUERY );
Reference< beans::XPropertySet > xErrorBar;
const OUString aPropName(
- bYError ? OUString(CHART_UNONAME_ERRORBAR_Y) : OUString(CHART_UNONAME_ERRORBAR_X));
+ bYError ? CHART_UNONAME_ERRORBAR_Y : CHART_UNONAME_ERRORBAR_X);
- if ( xSeriesProp.is())
- xSeriesProp->getPropertyValue( aPropName ) >>= xErrorBar;
+ if ( xDataSeries.is())
+ xDataSeries->getPropertyValue( aPropName ) >>= xErrorBar;
return xErrorBar;
}
bool StatisticsHelper::hasErrorBars(
- const Reference< chart2::XDataSeries > & xDataSeries,
+ const rtl::Reference< DataSeries > & xDataSeries,
bool bYError /* = true */ )
{
Reference< beans::XPropertySet > xErrorBar( getErrorBars( xDataSeries, bYError ));
@@ -349,7 +334,7 @@ bool StatisticsHelper::hasErrorBars(
}
void StatisticsHelper::removeErrorBars(
- const Reference< chart2::XDataSeries > & xDataSeries,
+ const rtl::Reference< DataSeries > & xDataSeries,
bool bYError /* = true */ )
{
Reference< beans::XPropertySet > xErrorBar( getErrorBars( xDataSeries, bYError ));
@@ -359,7 +344,7 @@ void StatisticsHelper::removeErrorBars(
}
bool StatisticsHelper::usesErrorBarRanges(
- const Reference< chart2::XDataSeries > & xDataSeries,
+ const rtl::Reference< DataSeries > & xDataSeries,
bool bYError /* = true */ )
{
Reference< beans::XPropertySet > xErrorBar( getErrorBars( xDataSeries, bYError ));
diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx
index fe788397d40d..47fa8bb49317 100644
--- a/chart2/source/tools/ThreeDHelper.cxx
+++ b/chart2/source/tools/ThreeDHelper.cxx
@@ -17,19 +17,16 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <basegfx/numeric/ftools.hxx>
#include <ThreeDHelper.hxx>
-#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
#include <ChartTypeHelper.hxx>
-#include <BaseGFXHelper.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <defines.hxx>
-#include <editeng/unoprnms.hxx>
-#include <com/sun/star/beans/XPropertyState.hpp>
-#include <com/sun/star/chart2/XDiagram.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
-#include <com/sun/star/drawing/ShadeMode.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/helpers.hxx>
#include <rtl/math.hxx>
@@ -46,17 +43,16 @@ using ::rtl::math::tan;
namespace
{
-bool lcl_isRightAngledAxesSetAndSupported( const Reference< beans::XPropertySet >& xSceneProperties )
+bool lcl_isRightAngledAxesSetAndSupported( const rtl::Reference< Diagram >& xDiagram )
{
- if( xSceneProperties.is() )
+ if( xDiagram.is() )
{
bool bRightAngledAxes = false;
- xSceneProperties->getPropertyValue( "RightAngledAxes") >>= bRightAngledAxes;
+ xDiagram->getPropertyValue( "RightAngledAxes") >>= bRightAngledAxes;
if(bRightAngledAxes)
{
- uno::Reference< chart2::XDiagram > xDiagram( xSceneProperties, uno::UNO_QUERY );
if( ChartTypeHelper::isSupportingRightAngledAxes(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) )
+ xDiagram->getChartTypeByIndex( 0 ) ) )
{
return true;
}
@@ -65,233 +61,6 @@ bool lcl_isRightAngledAxesSetAndSupported( const Reference< beans::XPropertySet
return false;
}
-void lcl_RotateLightSource( const Reference< beans::XPropertySet >& xSceneProperties
- , const OUString& rLightSourceDirection
- , const OUString& rLightSourceOn
- , const ::basegfx::B3DHomMatrix& rRotationMatrix )
-{
- if( !xSceneProperties.is() )
- return;
-
- bool bLightOn = false;
- if( !(xSceneProperties->getPropertyValue( rLightSourceOn ) >>= bLightOn) )
- return;
-
- if( bLightOn )
- {
- drawing::Direction3D aLight;
- if( xSceneProperties->getPropertyValue( rLightSourceDirection ) >>= aLight )
- {
- ::basegfx::B3DVector aLightVector( BaseGFXHelper::Direction3DToB3DVector( aLight ) );
- aLightVector = rRotationMatrix*aLightVector;
-
- xSceneProperties->setPropertyValue( rLightSourceDirection
- , uno::Any( BaseGFXHelper::B3DVectorToDirection3D( aLightVector ) ) );
- }
- }
-}
-
-void lcl_rotateLights( const ::basegfx::B3DHomMatrix& rLightRottion, const Reference< beans::XPropertySet >& xSceneProperties )
-{
- if(!xSceneProperties.is())
- return;
-
- ::basegfx::B3DHomMatrix aLightRottion( rLightRottion );
- BaseGFXHelper::ReduceToRotationMatrix( aLightRottion );
-
- lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection1", "D3DSceneLightOn1", aLightRottion );
- lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection2", "D3DSceneLightOn2", aLightRottion );
- lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection3", "D3DSceneLightOn3", aLightRottion );
- lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection4", "D3DSceneLightOn4", aLightRottion );
- lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection5", "D3DSceneLightOn5", aLightRottion );
- lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection6", "D3DSceneLightOn6", aLightRottion );
- lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection7", "D3DSceneLightOn7", aLightRottion );
- lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection8", "D3DSceneLightOn8", aLightRottion );
-}
-
-::basegfx::B3DHomMatrix lcl_getInverseRotationMatrix( const Reference< beans::XPropertySet >& xSceneProperties )
-{
- ::basegfx::B3DHomMatrix aInverseRotation;
- double fXAngleRad=0.0;
- double fYAngleRad=0.0;
- double fZAngleRad=0.0;
- ThreeDHelper::getRotationAngleFromDiagram(
- xSceneProperties, fXAngleRad, fYAngleRad, fZAngleRad );
- aInverseRotation.rotate( 0.0, 0.0, -fZAngleRad );
- aInverseRotation.rotate( 0.0, -fYAngleRad, 0.0 );
- aInverseRotation.rotate( -fXAngleRad, 0.0, 0.0 );
- return aInverseRotation;
-}
-
-::basegfx::B3DHomMatrix lcl_getCompleteRotationMatrix( const Reference< beans::XPropertySet >& xSceneProperties )
-{
- ::basegfx::B3DHomMatrix aCompleteRotation;
- double fXAngleRad=0.0;
- double fYAngleRad=0.0;
- double fZAngleRad=0.0;
- ThreeDHelper::getRotationAngleFromDiagram(
- xSceneProperties, fXAngleRad, fYAngleRad, fZAngleRad );
- aCompleteRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad );
- return aCompleteRotation;
-}
-
-bool lcl_isEqual( const drawing::Direction3D& rA, const drawing::Direction3D& rB )
-{
- return ::rtl::math::approxEqual(rA.DirectionX, rB.DirectionX)
- && ::rtl::math::approxEqual(rA.DirectionY, rB.DirectionY)
- && ::rtl::math::approxEqual(rA.DirectionZ, rB.DirectionZ);
-}
-
-bool lcl_isLightScheme( const uno::Reference< beans::XPropertySet >& xDiagramProps, bool bRealistic )
-{
- if(!xDiagramProps.is())
- return false;
-
- bool bIsOn = false;
- xDiagramProps->getPropertyValue( UNO_NAME_3D_SCENE_LIGHTON_2 ) >>= bIsOn;
- if(!bIsOn)
- return false;
-
- uno::Reference< chart2::XDiagram > xDiagram( xDiagramProps, uno::UNO_QUERY );
- uno::Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
-
- sal_Int32 nColor = 0;
- xDiagramProps->getPropertyValue( UNO_NAME_3D_SCENE_LIGHTCOLOR_2 ) >>= nColor;
- if( nColor != ::chart::ChartTypeHelper::getDefaultDirectLightColor( !bRealistic, xChartType ) )
- return false;
-
- sal_Int32 nAmbientColor = 0;
- xDiagramProps->getPropertyValue( UNO_NAME_3D_SCENE_AMBIENTCOLOR ) >>= nAmbientColor;
- if( nAmbientColor != ::chart::ChartTypeHelper::getDefaultAmbientLightColor( !bRealistic, xChartType ) )
- return false;
-
- drawing::Direction3D aDirection(0,0,0);
- xDiagramProps->getPropertyValue( UNO_NAME_3D_SCENE_LIGHTDIRECTION_2 ) >>= aDirection;
-
- drawing::Direction3D aDefaultDirection( bRealistic
- ? ChartTypeHelper::getDefaultRealisticLightDirection(xChartType)
- : ChartTypeHelper::getDefaultSimpleLightDirection(xChartType) );
-
- //rotate default light direction when right angled axes are off but supported
- {
- bool bRightAngledAxes = false;
- xDiagramProps->getPropertyValue( "RightAngledAxes") >>= bRightAngledAxes;
- if(!bRightAngledAxes)
- {
- if( ChartTypeHelper::isSupportingRightAngledAxes(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) )
- {
- ::basegfx::B3DHomMatrix aRotation( lcl_getCompleteRotationMatrix( xDiagramProps ) );
- BaseGFXHelper::ReduceToRotationMatrix( aRotation );
- ::basegfx::B3DVector aLightVector( BaseGFXHelper::Direction3DToB3DVector( aDefaultDirection ) );
- aLightVector = aRotation*aLightVector;
- aDefaultDirection = BaseGFXHelper::B3DVectorToDirection3D( aLightVector );
- }
- }
- }
-
- return lcl_isEqual( aDirection, aDefaultDirection );
-}
-
-bool lcl_isRealisticLightScheme( const uno::Reference< beans::XPropertySet >& xDiagramProps )
-{
- return lcl_isLightScheme( xDiagramProps, true /*bRealistic*/ );
-}
-bool lcl_isSimpleLightScheme( const uno::Reference< beans::XPropertySet >& xDiagramProps )
-{
- return lcl_isLightScheme( xDiagramProps, false /*bRealistic*/ );
-}
-void lcl_setLightsForScheme( const uno::Reference< beans::XPropertySet >& xDiagramProps, const ThreeDLookScheme& rScheme )
-{
- if(!xDiagramProps.is())
- return;
- if( rScheme == ThreeDLookScheme_Unknown)
- return;
-
- xDiagramProps->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTON_2, uno::Any( true ) );
-
- uno::Reference< chart2::XDiagram > xDiagram( xDiagramProps, uno::UNO_QUERY );
- uno::Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
- uno::Any aADirection( rScheme == ThreeDLookScheme_Simple
- ? ChartTypeHelper::getDefaultSimpleLightDirection(xChartType)
- : ChartTypeHelper::getDefaultRealisticLightDirection(xChartType) );
-
- xDiagramProps->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTDIRECTION_2, aADirection );
- //rotate light direction when right angled axes are off but supported
- {
- bool bRightAngledAxes = false;
- xDiagramProps->getPropertyValue( "RightAngledAxes") >>= bRightAngledAxes;
- if(!bRightAngledAxes)
- {
- if( ChartTypeHelper::isSupportingRightAngledAxes( xChartType ) )
- {
- ::basegfx::B3DHomMatrix aRotation( lcl_getCompleteRotationMatrix( xDiagramProps ) );
- BaseGFXHelper::ReduceToRotationMatrix( aRotation );
- lcl_RotateLightSource( xDiagramProps, "D3DSceneLightDirection2", "D3DSceneLightOn2", aRotation );
- }
- }
- }
-
- sal_Int32 nColor = ::chart::ChartTypeHelper::getDefaultDirectLightColor( rScheme==ThreeDLookScheme_Simple, xChartType );
- xDiagramProps->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTCOLOR_2, uno::Any( nColor ) );
-
- sal_Int32 nAmbientColor = ::chart::ChartTypeHelper::getDefaultAmbientLightColor( rScheme==ThreeDLookScheme_Simple, xChartType );
- xDiagramProps->setPropertyValue( UNO_NAME_3D_SCENE_AMBIENTCOLOR, uno::Any( nAmbientColor ) );
-}
-
-bool lcl_isRealisticScheme( drawing::ShadeMode aShadeMode
- , sal_Int32 nRoundedEdges
- , sal_Int32 nObjectLines )
-{
- if(aShadeMode!=drawing::ShadeMode_SMOOTH)
- return false;
- if(nRoundedEdges!=5)
- return false;
- if(nObjectLines!=0)
- return false;
- return true;
-}
-
-bool lcl_isSimpleScheme( drawing::ShadeMode aShadeMode
- , sal_Int32 nRoundedEdges
- , sal_Int32 nObjectLines
- , const uno::Reference< XDiagram >& xDiagram )
-{
- if(aShadeMode!=drawing::ShadeMode_FLAT)
- return false;
- if(nRoundedEdges!=0)
- return false;
- if(nObjectLines==0)
- {
- uno::Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
- return ChartTypeHelper::noBordersForSimpleScheme( xChartType );
- }
- if(nObjectLines!=1)
- return false;
- return true;
-}
-
-void lcl_setRealisticScheme( drawing::ShadeMode& rShadeMode
- , sal_Int32& rnRoundedEdges
- , sal_Int32& rnObjectLines )
-{
- rShadeMode = drawing::ShadeMode_SMOOTH;
- rnRoundedEdges = 5;
- rnObjectLines = 0;
-}
-
-void lcl_setSimpleScheme( drawing::ShadeMode& rShadeMode
- , sal_Int32& rnRoundedEdges
- , sal_Int32& rnObjectLines
- , const uno::Reference< XDiagram >& xDiagram )
-{
- rShadeMode = drawing::ShadeMode_FLAT;
- rnRoundedEdges = 0;
-
- uno::Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
- rnObjectLines = ChartTypeHelper::noBordersForSimpleScheme( xChartType ) ? 0 : 1;
-}
-
} //end anonymous namespace
drawing::CameraGeometry ThreeDHelper::getDefaultCameraGeometry( bool bPie )
@@ -316,60 +85,6 @@ drawing::CameraGeometry ThreeDHelper::getDefaultCameraGeometry( bool bPie )
namespace
{
-::basegfx::B3DHomMatrix lcl_getCameraMatrix( const uno::Reference< beans::XPropertySet >& xSceneProperties )
-{
- drawing::HomogenMatrix aCameraMatrix;
-
- drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() );
- if( xSceneProperties.is() )
- xSceneProperties->getPropertyValue( "D3DCameraGeometry" ) >>= aCG;
-
- ::basegfx::B3DVector aVPN( BaseGFXHelper::Direction3DToB3DVector( aCG.vpn ) );
- ::basegfx::B3DVector aVUP( BaseGFXHelper::Direction3DToB3DVector( aCG.vup ) );
-
- //normalize vectors:
- aVPN.normalize();
- aVUP.normalize();
-
- ::basegfx::B3DVector aCross = ::basegfx::cross( aVUP, aVPN );
-
- //first line is VUP x VPN
- aCameraMatrix.Line1.Column1 = aCross[0];
- aCameraMatrix.Line1.Column2 = aCross[1];
- aCameraMatrix.Line1.Column3 = aCross[2];
- aCameraMatrix.Line1.Column4 = 0.0;
-
- //second line is VUP
- aCameraMatrix.Line2.Column1 = aVUP[0];
- aCameraMatrix.Line2.Column2 = aVUP[1];
- aCameraMatrix.Line2.Column3 = aVUP[2];
- aCameraMatrix.Line2.Column4 = 0.0;
-
- //third line is VPN
- aCameraMatrix.Line3.Column1 = aVPN[0];
- aCameraMatrix.Line3.Column2 = aVPN[1];
- aCameraMatrix.Line3.Column3 = aVPN[2];
- aCameraMatrix.Line3.Column4 = 0.0;
-
- //fourth line is 0 0 0 1
- aCameraMatrix.Line4.Column1 = 0.0;
- aCameraMatrix.Line4.Column2 = 0.0;
- aCameraMatrix.Line4.Column3 = 0.0;
- aCameraMatrix.Line4.Column4 = 1.0;
-
- return BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aCameraMatrix );
-}
-
-double lcl_shiftAngleToIntervalMinusPiToPi( double fAngleRad )
-{
- //valid range: ]-Pi,Pi]
- while( fAngleRad<=-F_PI )
- fAngleRad+=(2*F_PI);
- while( fAngleRad>F_PI )
- fAngleRad-=(2*F_PI);
- return fAngleRad;
-}
-
void lcl_ensureIntervalMinus1To1( double& rSinOrCos )
{
if (rSinOrCos < -1.0)
@@ -415,25 +130,25 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad(
//element 23
double f23 = cos(R)*sin(E);
if(f23>0)
- x = F_PI2;
+ x = M_PI_2;
else
- x = -F_PI2;
+ x = -M_PI_2;
y = R;
}
else if( ( nRotationDeg == 90 || nRotationDeg == 270 )
&& ( nElevationDeg == 90 || nElevationDeg == 270 ) )
{
//cR==0 && cE==0
- z = F_PI2;
+ z = M_PI_2;
if( sin(R)>0 )
- x = F_PI2;
+ x = M_PI_2;
else
- x = -F_PI2;
+ x = -M_PI_2;
if( (sin(R)*sin(E))>0 )
y = 0.0;
else
- y = F_PI;
+ y = M_PI;
}
else if( (nRotationDeg == 0 || nRotationDeg == 180 )
&& ( nElevationDeg == 0 || nElevationDeg == 180 ) )
@@ -450,14 +165,14 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad(
z = 0.0;
if( (sin(R)/cos(E))>0 )
- y = F_PI2;
+ y = M_PI_2;
else
- y = -F_PI2;
+ y = -M_PI_2;
if( (cos(E))>0 )
x = 0;
else
- x = F_PI;
+ x = M_PI;
}
else if ( nElevationDeg == 0 || nElevationDeg == 180 )
{
@@ -472,19 +187,19 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad(
else if ( nElevationDeg == 90 || nElevationDeg == 270 )
{
//sR!=0 cR!=0 cE==0
- //element 12 + 22 --> y=0 or F_PI and x=+-F_PI/2
+ //element 12 + 22 --> y=0 or M_PI and x=+-M_PI/2
//-->element 13/23:
z = atan(sin(R)/(cos(R)*sin(E)));
//use element 13 for sign for x
if( (sin(R)*sin(z))>0.0 )
- x = F_PI2;
+ x = M_PI_2;
else
- x = -F_PI2;
+ x = -M_PI_2;
//use element 21 for y
if( (sin(R)*sin(E)*sin(z))>0.0)
y = 0.0;
else
- y = F_PI;
+ y = M_PI;
}
else if ( nRotationDeg == 0 || nRotationDeg == 180 )
{
@@ -499,10 +214,10 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad(
else if (nRotationDeg == 90 || nRotationDeg == 270)
{
//sE!=0 cE!=0 cR==0
- //z = +- F_PI/2;
- //x = +- F_PI/2;
- z = F_PI2;
- x = F_PI2;
+ //z = +- M_PI/2;
+ //x = +- M_PI/2;
+ z = M_PI_2;
+ x = M_PI_2;
double sR = sin(R);
if( sR<0.0 )
x *= -1.0; //different signs for x and z
@@ -553,7 +268,7 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad(
if( (f22a*f22b)<0.0 )
{
y *= -1;
- x=(F_PI-x);
+ x=(M_PI-x);
}
}
else
@@ -565,7 +280,7 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad(
if( (f22a*f22b)<0.0 )
{
y *= -1;
- x=(F_PI-x);
+ x=(M_PI-x);
}
}
}
@@ -605,14 +320,14 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
if( f11 > 0 )
R = 0.0;
else
- R = F_PI;
+ R = M_PI;
//element 23
double f23 = cos(z)*sin(x) / cos(R);
if( f23 > 0 )
- E = F_PI2;
+ E = M_PI_2;
else
- E = -F_PI2;
+ E = -M_PI_2;
}
else if( lcl_isCosZero(z) )
{
@@ -622,16 +337,16 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
double f13 = sin(x)*sin(z);
//element 13+11
if( f13 > 0 )
- R = F_PI2;
+ R = M_PI_2;
else
- R = -F_PI2;
+ R = -M_PI_2;
//element 21
double f21 = cos(y)*sin(z) / sin(R);
if( f21 > 0 )
- E = F_PI2;
+ E = M_PI_2;
else
- E = -F_PI2;
+ E = -M_PI_2;
}
else
{
@@ -641,14 +356,14 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
R = atan( f13/f11 );
if(f11<0)
- R+=F_PI;
+ R+=M_PI;
//element 23
double f23 = cos(z)*sin(x);
if( f23/cos(R) > 0 )
- E = F_PI2;
+ E = M_PI_2;
else
- E = -F_PI2;
+ E = -M_PI_2;
}
}
else if( lcl_isSinZero(x) )
@@ -658,13 +373,13 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
if( f11 > 0 )
R = 0.0;
else
- R = F_PI;
+ R = M_PI;
double f22 = cos(x)*cos(z);
if( f22 > 0 )
E = 0.0;
else
- E = F_PI;
+ E = M_PI;
}
else if( lcl_isSinZero(z) )
{
@@ -673,14 +388,14 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
if( f11 > 0 )
R = 0.0;
else
- R = F_PI;
+ R = M_PI;
//element 22 && 23
double f22 = cos(x)*cos(z);
double f23 = cos(z)*sin(x);
E = atan( f23/(f22*cos(R)) );
if( (f22*cos(E))<0 )
- E+=F_PI;
+ E+=M_PI;
}
else if( lcl_isCosZero(z) )
{
@@ -688,16 +403,16 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
double f13 = sin(x)*sin(z);
//element 13+11
if( f13 > 0 )
- R = F_PI2;
+ R = M_PI_2;
else
- R = -F_PI2;
+ R = -M_PI_2;
//element 21+22
double f21 = cos(y)*sin(z);
if( f21/sin(R) > 0 )
- E = F_PI2;
+ E = M_PI_2;
else
- E = -F_PI2;
+ E = -M_PI_2;
}
else
{
@@ -705,7 +420,7 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
double f13 = sin(x)*sin(z);
R = atan( f13/f11 );
if( (f11*cos(R))<0.0 )
- R+=F_PI;
+ R+=M_PI;
double f22 = cos(x)*cos(z);
if( !lcl_isCosZero(R) )
@@ -713,7 +428,7 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
else
E = atan( cos(y)*sin(z) /( f22*sin(R) ) );
if( (f22*cos(E))<0 )
- E+=F_PI;
+ E+=M_PI;
}
}
else if( lcl_isCosZero(y) )
@@ -722,15 +437,15 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
double f13 = sin(x)*sin(z)+cos(x)*cos(z)*sin(y);
if( f13 >= 0 )
- R = F_PI2;
+ R = M_PI_2;
else
- R = -F_PI2;
+ R = -M_PI_2;
double f22 = cos(x)*cos(z)+sin(x)*sin(y)*sin(z);
if( f22 >= 0 )
E = 0.0;
else
- E = F_PI;
+ E = M_PI;
}
else if( lcl_isSinZero(x) )
{
@@ -742,13 +457,13 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
R = atan( f13/f11 );
//R = asin(f13);
if( f11<0 )
- R+=F_PI;
+ R+=M_PI;
double f22 = cos(x)*cos(z);
if( f22>0 )
E = 0.0;
else
- E = F_PI;
+ E = M_PI;
}
else if( lcl_isCosZero(z) )
{
@@ -770,14 +485,14 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
R = atan( f13/f11 );
if( f11<0 )
- R+=F_PI;
+ R+=M_PI;
double f21 = cos(y)*sin(z);
double f22 = cos(x)*cos(z);
E = atan(f21/(f22*sin(R)) );
if( (f22*cos(E))<0.0 )
- E+=F_PI;
+ E+=M_PI;
}
}
else if( lcl_isCosZero(x) )
@@ -787,23 +502,23 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
if( lcl_isSinZero(z) )
{
//cosY!=0 sinY!=0 cosX=0 sinZ=0
- R=0;//13 -> R=0 or F_PI
+ R=0;//13 -> R=0 or M_PI
if( f11<0.0 )
- R=F_PI;
- E=F_PI2;//22 -> E=+-F_PI/2
+ R=M_PI;
+ E=M_PI_2;//22 -> E=+-M_PI/2
//use element 11 and 23 for sign
double f23 = cos(z)*sin(x);
if( (f11*f23*sin(E))<0.0 )
- E=-F_PI2;
+ E=-M_PI_2;
}
else if( lcl_isCosZero(z) )
{
//cosY!=0 sinY!=0 cosX=0 cosZ=0
//element 11 & 13:
if( (sin(x)*sin(z))>0.0 )
- R=F_PI2;
+ R=M_PI_2;
else
- R=-F_PI2;
+ R=-M_PI_2;
//element 22:
E=acos( sin(x)*sin(y)*sin(z));
//use element 21 for sign:
@@ -817,7 +532,7 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
R = atan( sin(x)*sin(z)/(cos(y)*cos(z)) );
//use 13 for 'sign'
if( (sin(x)*sin(z))<0.0 )
- R += F_PI;
+ R += M_PI;
//element 22
E = acos(sin(x)*sin(y)*sin(z) );
//use 21 for sign
@@ -846,12 +561,12 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
R=atan(-cos(y)/(cos(x)*sin(y)));
//use element 13 for 'sign'
if( (sin(x)*sin(z)*sin(R))<0.0 )
- R+=F_PI;
+ R+=M_PI;
//element 21/22
E=atan( cos(y)*sin(z)/(sin(R)*sin(x)*sin(y)*sin(z)) );
//use element 23 for 'sign'
if( (-cos(x)*sin(y)*sin(z)*cos(R)*sin(E))<0.0 )
- E+=F_PI;
+ E+=M_PI;
}
else
{
@@ -860,13 +575,13 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
double f13 = sin(x)*sin(z)+cos(x)*cos(z)*sin(y);
R = atan( f13/ f11 );
if(f11<0.0)
- R+=F_PI;
+ R+=M_PI;
double f22 = cos(x)*cos(z)+sin(x)*sin(y)*sin(z);
double f23 = cos(x)*sin(y)*sin(z)-cos(z)*sin(x);
//23/22:
E = atan( -1.0*f23/(f22*cos(R)) );
if(f22<0.0)
- E+=F_PI;
+ E+=M_PI;
}
rnElevationDeg = basegfx::fround(basegfx::rad2deg(E));
@@ -888,172 +603,6 @@ void ThreeDHelper::adaptRadAnglesForRightAngledAxes( double& rfXAngleRad, double
rfYAngleRad = ThreeDHelper::getValueClippedToRange(rfYAngleRad, basegfx::deg2rad(ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes()) );
}
-void ThreeDHelper::getRotationAngleFromDiagram(
- const Reference< beans::XPropertySet >& xSceneProperties, double& rfXAngleRad, double& rfYAngleRad, double& rfZAngleRad )
-{
- //takes the camera and the transformation matrix into account
-
- rfXAngleRad = rfYAngleRad = rfZAngleRad = 0.0;
-
- if( !xSceneProperties.is() )
- return;
-
- //get camera rotation
- ::basegfx::B3DHomMatrix aFixCameraRotationMatrix( lcl_getCameraMatrix( xSceneProperties ) );
- BaseGFXHelper::ReduceToRotationMatrix( aFixCameraRotationMatrix );
-
- //get scene rotation
- ::basegfx::B3DHomMatrix aSceneRotation;
- {
- drawing::HomogenMatrix aHomMatrix;
- if( xSceneProperties->getPropertyValue( "D3DTransformMatrix") >>= aHomMatrix )
- {
- aSceneRotation = BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHomMatrix );
- BaseGFXHelper::ReduceToRotationMatrix( aSceneRotation );
- }
- }
-
- ::basegfx::B3DHomMatrix aResultRotation = aFixCameraRotationMatrix * aSceneRotation;
- ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix( aResultRotation ) );
-
- rfXAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getX());
- rfYAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getY());
- rfZAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getZ());
-
- if(rfZAngleRad<-F_PI2 || rfZAngleRad>F_PI2)
- {
- rfZAngleRad-=F_PI;
- rfXAngleRad-=F_PI;
- rfYAngleRad=(F_PI-rfYAngleRad);
-
- rfXAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(rfXAngleRad);
- rfYAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(rfYAngleRad);
- rfZAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(rfZAngleRad);
- }
-}
-
-void ThreeDHelper::switchRightAngledAxes( const Reference< beans::XPropertySet >& xSceneProperties, bool bRightAngledAxes )
-{
- try
- {
- if( xSceneProperties.is() )
- {
- bool bOldRightAngledAxes = false;
- xSceneProperties->getPropertyValue( "RightAngledAxes") >>= bOldRightAngledAxes;
- if( bOldRightAngledAxes!=bRightAngledAxes)
- {
- xSceneProperties->setPropertyValue( "RightAngledAxes", uno::Any( bRightAngledAxes ));
- if(bRightAngledAxes)
- {
- ::basegfx::B3DHomMatrix aInverseRotation( lcl_getInverseRotationMatrix( xSceneProperties ) );
- lcl_rotateLights( aInverseRotation, xSceneProperties );
- }
- else
- {
- ::basegfx::B3DHomMatrix aCompleteRotation( lcl_getCompleteRotationMatrix( xSceneProperties ) );
- lcl_rotateLights( aCompleteRotation, xSceneProperties );
- }
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
-void ThreeDHelper::setRotationAngleToDiagram(
- const Reference< beans::XPropertySet >& xSceneProperties
- , double fXAngleRad, double fYAngleRad, double fZAngleRad )
-{
- //the rotation of the camera is not touched but taken into account
- //the rotation difference is applied to the transformation matrix
-
- //the light sources will be adapted also
-
- if( !xSceneProperties.is() )
- return;
-
- try
- {
- //remind old rotation for adaptation of light directions
- ::basegfx::B3DHomMatrix aInverseOldRotation( lcl_getInverseRotationMatrix( xSceneProperties ) );
-
- ::basegfx::B3DHomMatrix aInverseCameraRotation;
- {
- ::basegfx::B3DTuple aR( BaseGFXHelper::GetRotationFromMatrix(
- lcl_getCameraMatrix( xSceneProperties ) ) );
- aInverseCameraRotation.rotate( 0.0, 0.0, -aR.getZ() );
- aInverseCameraRotation.rotate( 0.0, -aR.getY(), 0.0 );
- aInverseCameraRotation.rotate( -aR.getX(), 0.0, 0.0 );
- }
-
- ::basegfx::B3DHomMatrix aCumulatedRotation;
- aCumulatedRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad );
-
- //calculate new scene matrix
- ::basegfx::B3DHomMatrix aSceneRotation = aInverseCameraRotation*aCumulatedRotation;
- BaseGFXHelper::ReduceToRotationMatrix( aSceneRotation );
-
- //set new rotation to transformation matrix
- xSceneProperties->setPropertyValue(
- "D3DTransformMatrix", uno::Any( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aSceneRotation )));
-
- //rotate lights if RightAngledAxes are not set or not supported
- bool bRightAngledAxes = false;
- xSceneProperties->getPropertyValue( "RightAngledAxes") >>= bRightAngledAxes;
- uno::Reference< chart2::XDiagram > xDiagram( xSceneProperties, uno::UNO_QUERY );
- if(!bRightAngledAxes || !ChartTypeHelper::isSupportingRightAngledAxes(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) )
- {
- ::basegfx::B3DHomMatrix aNewRotation;
- aNewRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad );
- lcl_rotateLights( aNewRotation*aInverseOldRotation, xSceneProperties );
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
-void ThreeDHelper::getRotationFromDiagram( const uno::Reference< beans::XPropertySet >& xSceneProperties
- , sal_Int32& rnHorizontalAngleDegree, sal_Int32& rnVerticalAngleDegree )
-{
- double fXAngle, fYAngle, fZAngle;
- ThreeDHelper::getRotationAngleFromDiagram( xSceneProperties, fXAngle, fYAngle, fZAngle );
-
- if( !lcl_isRightAngledAxesSetAndSupported( xSceneProperties ) )
- {
- ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
- rnHorizontalAngleDegree, rnVerticalAngleDegree, fXAngle, fYAngle, fZAngle);
- rnVerticalAngleDegree*=-1;
- }
- else
- {
- rnHorizontalAngleDegree = basegfx::fround(basegfx::rad2deg(fXAngle));
- rnVerticalAngleDegree = basegfx::fround(-1.0 * basegfx::rad2deg(fYAngle));
- // nZRotation = basegfx::fround(-1.0 * basegfx::rad2deg(fZAngle));
- }
-
- rnHorizontalAngleDegree = NormAngle180(rnHorizontalAngleDegree);
- rnVerticalAngleDegree = NormAngle180(rnVerticalAngleDegree);
-}
-
-void ThreeDHelper::setRotationToDiagram( const uno::Reference< beans::XPropertySet >& xSceneProperties
- , sal_Int32 nHorizontalAngleDegree, sal_Int32 nVerticalYAngleDegree )
-{
- //todo: x and y is not equal to horz and vert in case of RightAngledAxes==false
- double fXAngle = basegfx::deg2rad(nHorizontalAngleDegree);
- double fYAngle = basegfx::deg2rad(-1 * nVerticalYAngleDegree);
- double fZAngle = 0.0;
-
- if( !lcl_isRightAngledAxesSetAndSupported( xSceneProperties ) )
- ThreeDHelper::convertElevationRotationDegToXYZAngleRad(
- nHorizontalAngleDegree, -1*nVerticalYAngleDegree, fXAngle, fYAngle, fZAngle );
-
- ThreeDHelper::setRotationAngleToDiagram( xSceneProperties, fXAngle, fYAngle, fZAngle );
-}
void ThreeDHelper::getCameraDistanceRange( double& rfMinimumDistance, double& rfMaximumDistance )
{
@@ -1071,57 +620,6 @@ void ThreeDHelper::ensureCameraDistanceRange( double& rfCameraDistance )
rfCameraDistance = fMax;
}
-double ThreeDHelper::getCameraDistance(
- const Reference< beans::XPropertySet >& xSceneProperties )
-{
- double fCameraDistance = FIXED_SIZE_FOR_3D_CHART_VOLUME;
-
- if( !xSceneProperties.is() )
- return fCameraDistance;
-
- try
- {
- drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() );
- xSceneProperties->getPropertyValue( "D3DCameraGeometry" ) >>= aCG;
- ::basegfx::B3DVector aVRP( BaseGFXHelper::Position3DToB3DVector( aCG.vrp ) );
- fCameraDistance = aVRP.getLength();
-
- ensureCameraDistanceRange( fCameraDistance );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
- return fCameraDistance;
-}
-
-void ThreeDHelper::setCameraDistance(
- const Reference< beans::XPropertySet >& xSceneProperties, double fCameraDistance )
-{
- if( !xSceneProperties.is() )
- return;
-
- try
- {
- if( fCameraDistance <= 0 )
- fCameraDistance = FIXED_SIZE_FOR_3D_CHART_VOLUME;
-
- drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() );
- xSceneProperties->getPropertyValue( "D3DCameraGeometry" ) >>= aCG;
- ::basegfx::B3DVector aVRP( BaseGFXHelper::Position3DToB3DVector( aCG.vrp ) );
- if( ::basegfx::fTools::equalZero( aVRP.getLength() ) )
- aVRP = ::basegfx::B3DVector(0,0,1);
- aVRP.setLength(fCameraDistance);
- aCG.vrp = BaseGFXHelper::B3DVectorToPosition3D( aVRP );
-
- xSceneProperties->setPropertyValue( "D3DCameraGeometry", uno::Any( aCG ));
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
double ThreeDHelper::CameraDistanceToPerspective( double fCameraDistance )
{
double fMin, fMax;
@@ -1150,140 +648,8 @@ double ThreeDHelper::PerspectiveToCameraDistance( double fPerspective )
return fRet;
}
-ThreeDLookScheme ThreeDHelper::detectScheme( const uno::Reference< XDiagram >& xDiagram )
-{
- ThreeDLookScheme aScheme = ThreeDLookScheme_Unknown;
-
- sal_Int32 nRoundedEdges;
- sal_Int32 nObjectLines;
- ThreeDHelper::getRoundedEdgesAndObjectLines( xDiagram, nRoundedEdges, nObjectLines );
-
- //get shade mode and light settings:
- drawing::ShadeMode aShadeMode( drawing::ShadeMode_SMOOTH );
- uno::Reference< beans::XPropertySet > xDiagramProps( xDiagram, uno::UNO_QUERY );
- try
- {
- if( xDiagramProps.is() )
- xDiagramProps->getPropertyValue( "D3DSceneShadeMode" )>>= aShadeMode;
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- if( lcl_isSimpleScheme( aShadeMode, nRoundedEdges, nObjectLines, xDiagram ) )
- {
- if( lcl_isSimpleLightScheme(xDiagramProps) )
- aScheme = ThreeDLookScheme_Simple;
- }
- else if( lcl_isRealisticScheme( aShadeMode, nRoundedEdges, nObjectLines ) )
- {
- if( lcl_isRealisticLightScheme(xDiagramProps) )
- aScheme = ThreeDLookScheme_Realistic;
- }
-
- return aScheme;
-}
-
-void ThreeDHelper::setScheme( const uno::Reference< XDiagram >& xDiagram, ThreeDLookScheme aScheme )
-{
- if( aScheme == ThreeDLookScheme_Unknown )
- return;
-
- drawing::ShadeMode aShadeMode;
- sal_Int32 nRoundedEdges;
- sal_Int32 nObjectLines;
-
- if( aScheme == ThreeDLookScheme_Simple )
- lcl_setSimpleScheme(aShadeMode,nRoundedEdges,nObjectLines,xDiagram);
- else
- lcl_setRealisticScheme(aShadeMode,nRoundedEdges,nObjectLines);
-
- try
- {
- ThreeDHelper::setRoundedEdgesAndObjectLines( xDiagram, nRoundedEdges, nObjectLines );
-
- uno::Reference< beans::XPropertySet > xProp( xDiagram, uno::UNO_QUERY );
- if( xProp.is() )
- {
- drawing::ShadeMode aOldShadeMode;
- if( ! ( (xProp->getPropertyValue( "D3DSceneShadeMode" )>>=aOldShadeMode) &&
- aOldShadeMode == aShadeMode ))
- {
- xProp->setPropertyValue( "D3DSceneShadeMode", uno::Any( aShadeMode ));
- }
- }
-
- lcl_setLightsForScheme( xProp, aScheme );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
-}
-
-void ThreeDHelper::set3DSettingsToDefault( const uno::Reference< beans::XPropertySet >& xSceneProperties )
-{
- Reference< beans::XPropertyState > xState( xSceneProperties, uno::UNO_QUERY );
- if(xState.is())
- {
- xState->setPropertyToDefault( "D3DSceneDistance");
- xState->setPropertyToDefault( "D3DSceneFocalLength");
- }
- ThreeDHelper::setDefaultRotation( xSceneProperties );
- ThreeDHelper::setDefaultIllumination( xSceneProperties );
-}
-
-void ThreeDHelper::setDefaultRotation( const uno::Reference< beans::XPropertySet >& xSceneProperties, bool bPieOrDonut )
-{
- if( !xSceneProperties.is() )
- return;
-
- drawing::CameraGeometry aCameraGeo( ThreeDHelper::getDefaultCameraGeometry( bPieOrDonut ) );
- xSceneProperties->setPropertyValue( "D3DCameraGeometry", uno::Any( aCameraGeo ));
-
- ::basegfx::B3DHomMatrix aSceneRotation;
- if( bPieOrDonut )
- aSceneRotation.rotate( -F_PI/3.0, 0, 0 );
- xSceneProperties->setPropertyValue( "D3DTransformMatrix",
- uno::Any( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aSceneRotation )));
-}
-
-void ThreeDHelper::setDefaultRotation( const uno::Reference< beans::XPropertySet >& xSceneProperties )
-{
- bool bPieOrDonut( DiagramHelper::isPieOrDonutChart( uno::Reference< XDiagram >(xSceneProperties, uno::UNO_QUERY) ) );
- ThreeDHelper::setDefaultRotation( xSceneProperties, bPieOrDonut );
-}
-
-void ThreeDHelper::setDefaultIllumination( const uno::Reference< beans::XPropertySet >& xSceneProperties )
-{
- if( !xSceneProperties.is() )
- return;
-
- drawing::ShadeMode aShadeMode( drawing::ShadeMode_SMOOTH );
- try
- {
- xSceneProperties->getPropertyValue( "D3DSceneShadeMode" )>>= aShadeMode;
- xSceneProperties->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTON_1, uno::Any( false ) );
- xSceneProperties->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTON_3, uno::Any( false ) );
- xSceneProperties->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTON_4, uno::Any( false ) );
- xSceneProperties->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTON_5, uno::Any( false ) );
- xSceneProperties->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTON_6, uno::Any( false ) );
- xSceneProperties->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTON_7, uno::Any( false ) );
- xSceneProperties->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTON_8, uno::Any( false ) );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- ThreeDLookScheme aScheme = (aShadeMode==drawing::ShadeMode_FLAT) ? ThreeDLookScheme_Simple : ThreeDLookScheme_Realistic;
- lcl_setLightsForScheme( xSceneProperties, aScheme );
-}
-
void ThreeDHelper::getRoundedEdgesAndObjectLines(
- const uno::Reference< XDiagram > & xDiagram
+ const rtl::Reference< Diagram > & xDiagram
, sal_Int32& rnRoundedEdges, sal_Int32& rnObjectLines )
{
rnRoundedEdges = -1;
@@ -1295,8 +661,8 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines(
drawing::LineStyle aLineStyle( drawing::LineStyle_SOLID );
- std::vector< uno::Reference< XDataSeries > > aSeriesList(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ std::vector< rtl::Reference< DataSeries > > aSeriesList =
+ xDiagram->getDataSeries();
sal_Int32 nSeriesCount = static_cast<sal_Int32>( aSeriesList.size() );
OUString aPercentDiagonalPropertyName( "PercentDiagonal" );
@@ -1304,8 +670,7 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines(
for( sal_Int32 nS = 0; nS < nSeriesCount; ++nS )
{
- uno::Reference< XDataSeries > xSeries( aSeriesList[nS] );
- uno::Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY );
+ rtl::Reference< DataSeries > xSeries( aSeriesList[nS] );
if(!nS)
{
rnRoundedEdges = 0;
@@ -1313,7 +678,7 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines(
{
sal_Int16 nPercentDiagonal = 0;
- xProp->getPropertyValue( aPercentDiagonalPropertyName ) >>= nPercentDiagonal;
+ xSeries->getPropertyValue( aPercentDiagonalPropertyName ) >>= nPercentDiagonal;
rnRoundedEdges = static_cast< sal_Int32 >( nPercentDiagonal );
if( DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries
@@ -1327,7 +692,7 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines(
}
try
{
- xProp->getPropertyValue( aBorderStylePropertyName ) >>= aLineStyle;
+ xSeries->getPropertyValue( aBorderStylePropertyName ) >>= aLineStyle;
if( DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries
, aBorderStylePropertyName, uno::Any(aLineStyle) ) )
@@ -1344,7 +709,7 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines(
if( !bDifferentRoundedEdges )
{
sal_Int16 nPercentDiagonal = 0;
- xProp->getPropertyValue( aPercentDiagonalPropertyName ) >>= nPercentDiagonal;
+ xSeries->getPropertyValue( aPercentDiagonalPropertyName ) >>= nPercentDiagonal;
sal_Int32 nCurrentRoundedEdges = static_cast< sal_Int32 >( nPercentDiagonal );
if(nCurrentRoundedEdges!=rnRoundedEdges
|| DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries
@@ -1357,7 +722,7 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines(
if( !bDifferentObjectLines )
{
drawing::LineStyle aCurrentLineStyle;
- xProp->getPropertyValue( aBorderStylePropertyName ) >>= aCurrentLineStyle;
+ xSeries->getPropertyValue( aBorderStylePropertyName ) >>= aCurrentLineStyle;
if(aCurrentLineStyle!=aLineStyle
|| DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries
, aBorderStylePropertyName, uno::Any(aLineStyle) ) )
@@ -1382,7 +747,7 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines(
}
void ThreeDHelper::setRoundedEdgesAndObjectLines(
- const uno::Reference< XDiagram > & xDiagram
+ const rtl::Reference< Diagram > & xDiagram
, sal_Int32 nRoundedEdges, sal_Int32 nObjectLines )
{
if( (nRoundedEdges<0||nRoundedEdges>100) && nObjectLines!=0 && nObjectLines!=1 )
@@ -1395,13 +760,10 @@ void ThreeDHelper::setRoundedEdgesAndObjectLines(
uno::Any aALineStyle( aLineStyle);
uno::Any aARoundedEdges( static_cast< sal_Int16 >( nRoundedEdges ));
- std::vector< uno::Reference< XDataSeries > > aSeriesList(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
- sal_Int32 nSeriesCount = static_cast<sal_Int32>( aSeriesList.size() );
- for( sal_Int32 nS = 0; nS < nSeriesCount; ++nS )
+ std::vector< rtl::Reference< DataSeries > > aSeriesList =
+ xDiagram->getDataSeries();
+ for( auto const& xSeries : aSeriesList)
{
- uno::Reference< XDataSeries > xSeries( aSeriesList[nS] );
-
if( nRoundedEdges>=0 && nRoundedEdges<=100 )
DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "PercentDiagonal", aARoundedEdges );
@@ -1410,13 +772,13 @@ void ThreeDHelper::setRoundedEdgesAndObjectLines(
}
}
-CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeftWall( const Reference< beans::XPropertySet >& xSceneProperties )
+CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeftWall( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
CuboidPlanePosition eRet(CuboidPlanePosition_Left);
double fXAngleRad=0.0; double fYAngleRad=0.0; double fZAngleRad=0.0;
- ThreeDHelper::getRotationAngleFromDiagram( xSceneProperties, fXAngleRad, fYAngleRad, fZAngleRad );
- if( lcl_isRightAngledAxesSetAndSupported( xSceneProperties ) )
+ xDiagram->getRotationAngle( fXAngleRad, fYAngleRad, fZAngleRad );
+ if( lcl_isRightAngledAxesSetAndSupported( xDiagram ) )
{
ThreeDHelper::adaptRadAnglesForRightAngledAxes( fXAngleRad, fYAngleRad );
}
@@ -1425,13 +787,13 @@ CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeft
return eRet;
}
-CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBackWall( const Reference< beans::XPropertySet >& xSceneProperties )
+CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBackWall( const rtl::Reference< Diagram >& xDiagram )
{
CuboidPlanePosition eRet(CuboidPlanePosition_Back);
double fXAngleRad=0.0; double fYAngleRad=0.0; double fZAngleRad=0.0;
- ThreeDHelper::getRotationAngleFromDiagram( xSceneProperties, fXAngleRad, fYAngleRad, fZAngleRad );
- if( lcl_isRightAngledAxesSetAndSupported( xSceneProperties ) )
+ xDiagram->getRotationAngle( fXAngleRad, fYAngleRad, fZAngleRad );
+ if( lcl_isRightAngledAxesSetAndSupported( xDiagram ) )
{
ThreeDHelper::adaptRadAnglesForRightAngledAxes( fXAngleRad, fYAngleRad );
}
@@ -1440,13 +802,13 @@ CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBack
return eRet;
}
-CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBottom( const Reference< beans::XPropertySet >& xSceneProperties )
+CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBottom( const rtl::Reference< Diagram >& xDiagram )
{
CuboidPlanePosition eRet(CuboidPlanePosition_Bottom);
double fXAngleRad=0.0; double fYAngleRad=0.0; double fZAngleRad=0.0;
- ThreeDHelper::getRotationAngleFromDiagram( xSceneProperties, fXAngleRad, fYAngleRad, fZAngleRad );
- if( lcl_isRightAngledAxesSetAndSupported( xSceneProperties ) )
+ xDiagram->getRotationAngle( fXAngleRad, fYAngleRad, fZAngleRad );
+ if( lcl_isRightAngledAxesSetAndSupported( xDiagram ) )
{
ThreeDHelper::adaptRadAnglesForRightAngledAxes( fXAngleRad, fYAngleRad );
}
diff --git a/chart2/source/tools/TitleHelper.cxx b/chart2/source/tools/TitleHelper.cxx
index 3cdddbbeeb44..e9f76c619985 100644
--- a/chart2/source/tools/TitleHelper.cxx
+++ b/chart2/source/tools/TitleHelper.cxx
@@ -18,15 +18,15 @@
*/
#include <TitleHelper.hxx>
+#include <Title.hxx>
#include <ChartModel.hxx>
-#include <ChartModelHelper.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
-#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
#include <ReferenceSizeProvider.hxx>
#include <com/sun/star/chart2/FormattedString.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
#include <rtl/ustrbuf.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
namespace chart
@@ -40,7 +40,7 @@ namespace {
uno::Reference< XTitled > lcl_getTitleParentFromDiagram(
TitleHelper::eTitleType nTitleIndex
- , const uno::Reference< XDiagram >& xDiagram )
+ , const rtl::Reference< Diagram >& xDiagram )
{
uno::Reference< XTitled > xResult;
@@ -48,7 +48,7 @@ uno::Reference< XTitled > lcl_getTitleParentFromDiagram(
nTitleIndex == TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION )
{
bool bDummy = false;
- bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy );
+ bool bIsVertical = xDiagram && xDiagram->getVertical( bDummy, bDummy );
if( nTitleIndex == TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION )
nTitleIndex = bIsVertical ? TitleHelper::X_AXIS_TITLE : TitleHelper::Y_AXIS_TITLE;
@@ -60,27 +60,27 @@ uno::Reference< XTitled > lcl_getTitleParentFromDiagram(
{
case TitleHelper::SUB_TITLE:
if( xDiagram.is())
- xResult.set( xDiagram, uno::UNO_QUERY );
+ xResult = xDiagram;
break;
case TitleHelper::X_AXIS_TITLE:
if( xDiagram.is())
- xResult.set( AxisHelper::getAxis( 0, true, xDiagram ), uno::UNO_QUERY );
+ xResult = AxisHelper::getAxis( 0, true, xDiagram );
break;
case TitleHelper::Y_AXIS_TITLE:
if( xDiagram.is())
- xResult.set( AxisHelper::getAxis( 1, true, xDiagram ), uno::UNO_QUERY );
+ xResult = AxisHelper::getAxis( 1, true, xDiagram );
break;
case TitleHelper::Z_AXIS_TITLE:
if( xDiagram.is())
- xResult.set( AxisHelper::getAxis( 2, true, xDiagram ), uno::UNO_QUERY );
+ xResult = AxisHelper::getAxis( 2, true, xDiagram );
break;
case TitleHelper::SECONDARY_X_AXIS_TITLE:
if( xDiagram.is())
- xResult.set( AxisHelper::getAxis( 0, false, xDiagram ), uno::UNO_QUERY );
+ xResult = AxisHelper::getAxis( 0, false, xDiagram );
break;
case TitleHelper::SECONDARY_Y_AXIS_TITLE:
if( xDiagram.is())
- xResult.set( AxisHelper::getAxis( 1, false, xDiagram ), uno::UNO_QUERY );
+ xResult = AxisHelper::getAxis( 1, false, xDiagram );
break;
case TitleHelper::MAIN_TITLE:
@@ -93,7 +93,7 @@ uno::Reference< XTitled > lcl_getTitleParentFromDiagram(
}
uno::Reference< XTitled > lcl_getTitleParent( TitleHelper::eTitleType nTitleIndex
- , const uno::Reference< XDiagram >& xDiagram )
+ , const rtl::Reference< Diagram >& xDiagram )
{
uno::Reference< XTitled > xResult;
switch( nTitleIndex )
@@ -120,70 +120,72 @@ uno::Reference< XTitled > lcl_getTitleParent( TitleHelper::eTitleType nTitleInde
}
uno::Reference< XTitled > lcl_getTitleParent( TitleHelper::eTitleType nTitleIndex
- , const uno::Reference< frame::XModel >& xModel )
+ , const rtl::Reference<::chart::ChartModel>& xModel )
{
if(nTitleIndex == TitleHelper::MAIN_TITLE)
{
- uno::Reference< XTitled > xTitled( xModel, uno::UNO_QUERY );
- return xTitled;
+ return xModel;
}
- uno::Reference< XChartDocument > xChartDoc( xModel, uno::UNO_QUERY );
- uno::Reference< XDiagram > xDiagram;
+ rtl::Reference< Diagram > xDiagram;
- if( xChartDoc.is())
- xDiagram.set( xChartDoc->getFirstDiagram());
+ if( xModel.is())
+ xDiagram = xModel->getFirstChartDiagram();
return lcl_getTitleParent( nTitleIndex, xDiagram );
}
}
-uno::Reference< XTitle > TitleHelper::getTitle( TitleHelper::eTitleType nTitleIndex
+rtl::Reference< Title > TitleHelper::getTitle( TitleHelper::eTitleType nTitleIndex
, ChartModel& rModel )
{
if(nTitleIndex == TitleHelper::MAIN_TITLE)
- return rModel.getTitleObject();
+ return rModel.getTitleObject2();
- uno::Reference< XDiagram > xDiagram = rModel.getFirstDiagram();
+ rtl::Reference< Diagram > xDiagram = rModel.getFirstChartDiagram();
uno::Reference< XTitled > xTitled( lcl_getTitleParent( nTitleIndex, xDiagram ) );
- if( xTitled.is())
- return xTitled->getTitleObject();
- return nullptr;
+ if( !xTitled )
+ return nullptr;
+ uno::Reference<XTitle> xTitle = xTitled->getTitleObject();
+ auto pTitle = dynamic_cast<Title*>(xTitle.get());
+ assert(!xTitle || pTitle);
+ return pTitle;
}
-uno::Reference< XTitle > TitleHelper::getTitle( TitleHelper::eTitleType nTitleIndex
- , const uno::Reference< frame::XModel >& xModel )
+rtl::Reference< Title > TitleHelper::getTitle( TitleHelper::eTitleType nTitleIndex
+ , const rtl::Reference<ChartModel>& xModel )
{
uno::Reference< XTitled > xTitled;
if(nTitleIndex == TitleHelper::MAIN_TITLE)
{
- xTitled.set( xModel, uno::UNO_QUERY );
+ xTitled = xModel;
}
else
{
- uno::Reference< XChartDocument > xChartDoc( xModel, uno::UNO_QUERY );
- uno::Reference< XDiagram > xDiagram;
- if( xChartDoc.is())
- xDiagram.set( xChartDoc->getFirstDiagram());
+ rtl::Reference< Diagram > xDiagram;
+ if( xModel.is())
+ xDiagram = xModel->getFirstChartDiagram();
xTitled = lcl_getTitleParent( nTitleIndex, xDiagram );
}
- if( xTitled.is())
- return xTitled->getTitleObject();
- return nullptr;
+ if( !xTitled )
+ return nullptr;
+ uno::Reference<XTitle> xTitle = xTitled->getTitleObject();
+ Title* pTitle = dynamic_cast<Title*>(xTitle.get());
+ assert(!xTitle || pTitle);
+ return pTitle;
}
-uno::Reference< XTitle > TitleHelper::createOrShowTitle(
+rtl::Reference< Title > TitleHelper::createOrShowTitle(
TitleHelper::eTitleType eTitleType
, const OUString& rTitleText
- , const uno::Reference< frame::XModel >& xModel
+ , const rtl::Reference<ChartModel>& xModel
, const uno::Reference< uno::XComponentContext > & xContext )
{
- uno::Reference< chart2::XTitle > xTitled( TitleHelper::getTitle( eTitleType, xModel ) );
+ rtl::Reference< Title > xTitled( TitleHelper::getTitle( eTitleType, xModel ) );
if( xTitled.is())
{
- css::uno::Reference<css::beans::XPropertySet> xProps(xTitled, css::uno::UNO_QUERY_THROW);
- xProps->setPropertyValue("Visible",css::uno::Any(true));
+ xTitled->setPropertyValue("Visible",css::uno::Any(true));
return xTitled;
}
else
@@ -192,20 +194,20 @@ uno::Reference< XTitle > TitleHelper::createOrShowTitle(
}
}
-uno::Reference< XTitle > TitleHelper::createTitle(
+rtl::Reference< Title > TitleHelper::createTitle(
TitleHelper::eTitleType eTitleType
, const OUString& rTitleText
- , const uno::Reference< frame::XModel >& xModel
+ , const rtl::Reference<ChartModel>& xModel
, const uno::Reference< uno::XComponentContext > & xContext
, ReferenceSizeProvider * pRefSizeProvider )
{
- uno::Reference< XTitle > xTitle;
+ rtl::Reference< ::chart::Title > xTitle;
uno::Reference< XTitled > xTitled( lcl_getTitleParent( eTitleType, xModel ) );
if( !xTitled.is() )
{
- uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ) );
- uno::Reference< chart2::XAxis > xAxis;
+ rtl::Reference< Diagram > xDiagram( xModel->getFirstChartDiagram() );
+ rtl::Reference< Axis > xAxis;
switch( eTitleType )
{
case TitleHelper::SECONDARY_X_AXIS_TITLE:
@@ -217,90 +219,80 @@ uno::Reference< XTitle > TitleHelper::createTitle(
default:
break;
}
- uno::Reference< beans::XPropertySet > xProps( xAxis, uno::UNO_QUERY );
- if( xProps.is() )
+ if( xAxis.is() )
{
- xProps->setPropertyValue( "Show", uno::Any( false ) );
+ xAxis->setPropertyValue( "Show", uno::Any( false ) );
xTitled = lcl_getTitleParent( eTitleType, xModel );
}
}
if(xTitled.is())
{
- uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ) );
+ rtl::Reference< Diagram > xDiagram( xModel->getFirstChartDiagram() );
- xTitle.set( xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.Title",
- xContext ), uno::UNO_QUERY );
+ xTitle = new ::chart::Title();
- if(xTitle.is())
+ // default char height (main: 13.0 == default)
+ float fDefaultCharHeightSub = 11.0;
+ float fDefaultCharHeightAxis = 9.0;
+ switch( eTitleType )
{
- // default char height (main: 13.0 == default)
- float fDefaultCharHeightSub = 11.0;
- float fDefaultCharHeightAxis = 9.0;
- switch( eTitleType )
- {
- case TitleHelper::SUB_TITLE:
- TitleHelper::setCompleteString(
- rTitleText, xTitle, xContext, & fDefaultCharHeightSub );
- break;
- case TitleHelper::X_AXIS_TITLE:
- case TitleHelper::Y_AXIS_TITLE:
- case TitleHelper::Z_AXIS_TITLE:
- case TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION:
- case TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION:
- case TitleHelper::SECONDARY_X_AXIS_TITLE:
- case TitleHelper::SECONDARY_Y_AXIS_TITLE:
- TitleHelper::setCompleteString(
- rTitleText, xTitle, xContext, & fDefaultCharHeightAxis );
- break;
- default:
- TitleHelper::setCompleteString( rTitleText, xTitle, xContext );
- break;
- }
+ case TitleHelper::SUB_TITLE:
+ TitleHelper::setCompleteString(
+ rTitleText, xTitle, xContext, & fDefaultCharHeightSub );
+ break;
+ case TitleHelper::X_AXIS_TITLE:
+ case TitleHelper::Y_AXIS_TITLE:
+ case TitleHelper::Z_AXIS_TITLE:
+ case TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION:
+ case TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION:
+ case TitleHelper::SECONDARY_X_AXIS_TITLE:
+ case TitleHelper::SECONDARY_Y_AXIS_TITLE:
+ TitleHelper::setCompleteString(
+ rTitleText, xTitle, xContext, & fDefaultCharHeightAxis );
+ break;
+ default:
+ TitleHelper::setCompleteString( rTitleText, xTitle, xContext );
+ break;
+ }
- // set/clear autoscale
- if( pRefSizeProvider )
- pRefSizeProvider->setValuesAtTitle( xTitle );
+ // set/clear autoscale
+ if( pRefSizeProvider )
+ pRefSizeProvider->setValuesAtTitle( xTitle );
- xTitled->setTitleObject( xTitle );
+ xTitled->setTitleObject( xTitle );
- //default rotation 90 degree for y axis title in normal coordinatesystems or for x axis title for swapped coordinatesystems
- if( eTitleType == TitleHelper::X_AXIS_TITLE ||
- eTitleType == TitleHelper::Y_AXIS_TITLE ||
- eTitleType == TitleHelper::SECONDARY_X_AXIS_TITLE ||
- eTitleType == TitleHelper::SECONDARY_Y_AXIS_TITLE )
+ //default rotation 90 degree for y axis title in normal coordinatesystems or for x axis title for swapped coordinatesystems
+ if( eTitleType == TitleHelper::X_AXIS_TITLE ||
+ eTitleType == TitleHelper::Y_AXIS_TITLE ||
+ eTitleType == TitleHelper::SECONDARY_X_AXIS_TITLE ||
+ eTitleType == TitleHelper::SECONDARY_Y_AXIS_TITLE )
+ {
+ try
{
- try
- {
- bool bDummy = false;
- bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy );
-
- Reference< beans::XPropertySet > xTitleProps( xTitle, uno::UNO_QUERY );
- if( xTitleProps.is() )
- {
- if( (!bIsVertical && eTitleType == TitleHelper::Y_AXIS_TITLE)
- || (bIsVertical && eTitleType == TitleHelper::X_AXIS_TITLE)
- || (!bIsVertical && eTitleType == TitleHelper::SECONDARY_Y_AXIS_TITLE)
- || (bIsVertical && eTitleType == TitleHelper::SECONDARY_X_AXIS_TITLE) )
- {
- xTitleProps->setPropertyValue( "TextRotation", uno::Any( 90.0 ));
- }
- }
- }
- catch( const uno::Exception & )
+ bool bDummy = false;
+ bool bIsVertical = xDiagram->getVertical( bDummy, bDummy );
+
+ if( (!bIsVertical && eTitleType == TitleHelper::Y_AXIS_TITLE)
+ || (bIsVertical && eTitleType == TitleHelper::X_AXIS_TITLE)
+ || (!bIsVertical && eTitleType == TitleHelper::SECONDARY_Y_AXIS_TITLE)
+ || (bIsVertical && eTitleType == TitleHelper::SECONDARY_X_AXIS_TITLE) )
{
- DBG_UNHANDLED_EXCEPTION("chart2");
+ xTitle->setPropertyValue( "TextRotation", uno::Any( 90.0 ));
}
}
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
}
}
return xTitle;
}
-OUString TitleHelper::getCompleteString( const uno::Reference< XTitle >& xTitle )
+OUString TitleHelper::getCompleteString( const rtl::Reference< Title >& xTitle )
{
if(!xTitle.is())
return OUString();
@@ -311,53 +303,89 @@ OUString TitleHelper::getCompleteString( const uno::Reference< XTitle >& xTitle
return aRet.makeStringAndClear();
}
-void TitleHelper::setCompleteString( const OUString& rNewText
- , const uno::Reference< XTitle >& xTitle
- , const uno::Reference< uno::XComponentContext > & xContext
- , const float * pDefaultCharHeight /* = 0 */ )
+OUString TitleHelper::getUnstackedStr(const OUString& rNewText)
{
- //the format of the first old text portion will be maintained if there is any
- if(!xTitle.is())
- return;
+ //#i99841# remove linebreaks that were added for vertical stacking
+ OUStringBuffer aUnstackedStr;
+ OUStringBuffer aSource(rNewText);
- OUString aNewText = rNewText;
+ bool bBreakIgnored = false;
+ sal_Int32 nLen = rNewText.getLength();
+ for (sal_Int32 nPos = 0; nPos < nLen; ++nPos)
+ {
+ sal_Unicode aChar = aSource[nPos];
+ if (aChar != '\n')
+ {
+ aUnstackedStr.append(aChar);
+ bBreakIgnored = false;
+ }
+ else if (aChar == '\n' && bBreakIgnored)
+ aUnstackedStr.append(aChar);
+ else
+ bBreakIgnored = true;
+ }
+ return aUnstackedStr.makeStringAndClear();
+}
+
+void TitleHelper::setFormattedString( const rtl::Reference< Title >& xTitle,
+ const css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& aNewFormattedTitle )
+{
+ if (!xTitle.is() || !aNewFormattedTitle.hasElements())
+ return;
bool bStacked = false;
- uno::Reference< beans::XPropertySet > xTitleProperties( xTitle, uno::UNO_QUERY );
- if( xTitleProperties.is() )
- xTitleProperties->getPropertyValue( "StackCharacters" ) >>= bStacked;
+ xTitle->getPropertyValue("StackCharacters") >>= bStacked;
- if( bStacked )
+ if (bStacked)
{
- //#i99841# remove linebreaks that were added for vertical stacking
- OUStringBuffer aUnstackedStr;
- OUStringBuffer aSource(rNewText);
-
- bool bBreakIgnored = false;
- sal_Int32 nLen = rNewText.getLength();
- for( sal_Int32 nPos = 0; nPos < nLen; ++nPos )
+ for (uno::Reference< chart2::XFormattedString >const& formattedStr : aNewFormattedTitle)
{
- sal_Unicode aChar = aSource[nPos];
- if( aChar != '\n' )
- {
- aUnstackedStr.append( aChar );
- bBreakIgnored = false;
- }
- else if( aChar == '\n' && bBreakIgnored )
- aUnstackedStr.append( aChar );
- else
- bBreakIgnored = true;
+ formattedStr->setString(TitleHelper::getUnstackedStr(formattedStr->getString()));
}
- aNewText = aUnstackedStr.makeStringAndClear();
}
- uno::Sequence< uno::Reference< XFormattedString > > aNewStringList(1);
+ xTitle->setText(aNewFormattedTitle);
+}
- uno::Sequence< uno::Reference< XFormattedString > > aOldStringList = xTitle->getText();
- if( aOldStringList.hasElements() )
+void TitleHelper::setCompleteString( const OUString& rNewText
+ , const rtl::Reference< Title >& xTitle
+ , const uno::Reference< uno::XComponentContext > & xContext
+ , const float * pDefaultCharHeight /* = 0 */
+ , bool bDialogTitle /*= false*/ )
+{
+ if (!xTitle.is())
+ return;
+
+ bool bStacked = false;
+ if( xTitle.is() )
+ xTitle->getPropertyValue( "StackCharacters" ) >>= bStacked;
+
+ OUString aNewText = rNewText;
+ if( bStacked )
{
- aNewStringList[0].set( aOldStringList[0] );
- aNewStringList[0]->setString( aNewText );
+ aNewText = getUnstackedStr(rNewText);
+ }
+
+ uno::Sequence< uno::Reference< XFormattedString > > aNewStringList;
+ uno::Sequence< uno::Reference< XFormattedString > > aOldStringList = xTitle->getText();
+ if( aOldStringList.hasElements())
+ {
+ const OUString aFullString = getCompleteString(xTitle);
+ if (bDialogTitle && aNewText.equals(getUnstackedStr(aFullString)))
+ {
+ // If the new title setted from a dialog window to a new string
+ // the first old text portion will be maintained if it's a new string,
+ // otherwise we use the original one.
+ aNewStringList = aOldStringList;
+ }
+ else
+ {
+ // If the new title setted from a dialog to a new string the first
+ // old text portion will be maintained if there was any. Also in case of ODF
+ // import which still not support non-uniform formatted titles
+ aNewStringList = { aOldStringList[0] };
+ aNewStringList[0]->setString(aNewText);
+ }
}
else
{
@@ -365,7 +393,7 @@ void TitleHelper::setCompleteString( const OUString& rNewText
chart2::FormattedString::create( xContext );
xFormattedString->setString( aNewText );
- aNewStringList[0].set( xFormattedString );
+ aNewStringList = { xFormattedString };
if( pDefaultCharHeight != nullptr )
{
try
@@ -385,7 +413,7 @@ void TitleHelper::setCompleteString( const OUString& rNewText
}
void TitleHelper::removeTitle( TitleHelper::eTitleType nTitleIndex
- , const css::uno::Reference< css::frame::XModel >& xModel )
+ , const rtl::Reference<ChartModel>& xModel )
{
uno::Reference< XTitled > xTitled( lcl_getTitleParent( nTitleIndex, xModel ) );
if( xTitled.is())
@@ -394,28 +422,17 @@ void TitleHelper::removeTitle( TitleHelper::eTitleType nTitleIndex
}
}
-void TitleHelper::hideTitle( TitleHelper::eTitleType nTitleIndex
- , const css::uno::Reference< css::frame::XModel >& xModel )
-{
- uno::Reference< chart2::XTitle > xTitled( TitleHelper::getTitle( nTitleIndex, xModel ) );
- if( xTitled.is())
- {
- css::uno::Reference<css::beans::XPropertySet> xProps(xTitled, css::uno::UNO_QUERY_THROW);
- xProps->setPropertyValue("Visible",css::uno::Any(false));
- }
-}
-
bool TitleHelper::getTitleType( eTitleType& rType
- , const css::uno::Reference< css::chart2::XTitle >& xTitle
- , ChartModel& rModel )
+ , const rtl::Reference< Title >& xTitle
+ , const rtl::Reference<ChartModel>& xModel )
{
- if( !xTitle.is() )
+ if( !xTitle.is() || !xModel.is() )
return false;
- Reference< chart2::XTitle > xCurrentTitle;
+ rtl::Reference< Title > xCurrentTitle;
for( sal_Int32 nTitleType = TITLE_BEGIN; nTitleType < NORMAL_TITLE_END; nTitleType++ )
{
- xCurrentTitle = TitleHelper::getTitle( static_cast<eTitleType>(nTitleType), rModel );
+ xCurrentTitle = TitleHelper::getTitle( static_cast<eTitleType>(nTitleType), xModel );
if( xCurrentTitle == xTitle )
{
rType = static_cast<eTitleType>(nTitleType);
@@ -426,25 +443,15 @@ bool TitleHelper::getTitleType( eTitleType& rType
return false;
}
-bool TitleHelper::getTitleType( eTitleType& rType
- , const css::uno::Reference< css::chart2::XTitle >& xTitle
- , const css::uno::Reference< css::frame::XModel >& xModel )
+void TitleHelper::hideTitle( TitleHelper::eTitleType nTitleIndex
+ , const rtl::Reference<ChartModel>& xModel)
{
- if( !xTitle.is() || !xModel.is() )
- return false;
-
- Reference< chart2::XTitle > xCurrentTitle;
- for( sal_Int32 nTitleType = TITLE_BEGIN; nTitleType < NORMAL_TITLE_END; nTitleType++ )
+ uno::Reference< chart2::XTitle > xTitled( TitleHelper::getTitle( nTitleIndex, xModel ) );
+ if( xTitled.is())
{
- xCurrentTitle = TitleHelper::getTitle( static_cast<eTitleType>(nTitleType), xModel );
- if( xCurrentTitle == xTitle )
- {
- rType = static_cast<eTitleType>(nTitleType);
- return true;
- }
+ css::uno::Reference<css::beans::XPropertySet> xProps(xTitled, css::uno::UNO_QUERY_THROW);
+ xProps->setPropertyValue("Visible",css::uno::Any(false));
}
-
- return false;
}
} //namespace chart
diff --git a/chart2/source/tools/TrueGuard.cxx b/chart2/source/tools/TrueGuard.cxx
deleted file mode 100644
index 3fca959e78c2..000000000000
--- a/chart2/source/tools/TrueGuard.cxx
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <TrueGuard.hxx>
-
-namespace chart
-{
-TrueGuard::TrueGuard(bool& rbTrueDuringGuardedTime)
- : m_rbTrueDuringGuardedTime(rbTrueDuringGuardedTime)
-{
- m_rbTrueDuringGuardedTime = true;
-}
-
-TrueGuard::~TrueGuard() { m_rbTrueDuringGuardedTime = false; }
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/tools/UncachedDataSequence.cxx b/chart2/source/tools/UncachedDataSequence.cxx
index 8851988b6d85..176eadafe8b1 100644
--- a/chart2/source/tools/UncachedDataSequence.cxx
+++ b/chart2/source/tools/UncachedDataSequence.cxx
@@ -20,13 +20,13 @@
#include <UncachedDataSequence.hxx>
#include <CommonFunctors.hxx>
#include <ModifyListenerHelper.hxx>
+#include <InternalDataProvider.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <algorithm>
#include <strings.hrc>
#include <ResId.hxx>
-#include <com/sun/star/chart2/XInternalDataProvider.hpp>
-#include <tools/diagnose_ex.h>
+#include <utility>
using namespace ::com::sun::star;
@@ -36,12 +36,11 @@ using ::com::sun::star::uno::Any;
using ::osl::MutexGuard;
// necessary for MS compiler
-using ::comphelper::OPropertyContainer;
using ::chart::impl::UncachedDataSequence_Base;
namespace
{
-const char lcl_aServiceName[] = "com.sun.star.comp.chart.UncachedDataSequence";
+constexpr OUString lcl_aServiceName = u"com.sun.star.comp.chart.UncachedDataSequence"_ustr;
enum
{
@@ -55,43 +54,36 @@ namespace chart
{
UncachedDataSequence::UncachedDataSequence(
- const Reference< chart2::XInternalDataProvider > & xIntDataProv,
- const OUString & rRangeRepresentation )
- : OPropertyContainer( GetBroadcastHelper()),
- UncachedDataSequence_Base( GetMutex()),
- m_nNumberFormatKey(0),
- m_xDataProvider( xIntDataProv ),
- m_aSourceRepresentation( rRangeRepresentation ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ rtl::Reference< InternalDataProvider > xIntDataProv,
+ OUString aRangeRepresentation )
+ : m_nNumberFormatKey(0),
+ m_xDataProvider(std::move( xIntDataProv )),
+ m_aSourceRepresentation(std::move( aRangeRepresentation )),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
registerProperties();
}
UncachedDataSequence::UncachedDataSequence(
- const Reference< chart2::XInternalDataProvider > & xIntDataProv,
- const OUString & rRangeRepresentation,
+ rtl::Reference< InternalDataProvider > xIntDataProv,
+ OUString aRangeRepresentation,
const OUString & rRole )
- : OPropertyContainer( GetBroadcastHelper()),
- UncachedDataSequence_Base( GetMutex()),
- m_nNumberFormatKey(0),
- m_xDataProvider( xIntDataProv ),
- m_aSourceRepresentation( rRangeRepresentation ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ : m_nNumberFormatKey(0),
+ m_xDataProvider(std::move( xIntDataProv )),
+ m_aSourceRepresentation(std::move( aRangeRepresentation )),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
registerProperties();
- setFastPropertyValue_NoBroadcast( PROP_PROPOSED_ROLE, uno::Any( rRole ));
+ std::unique_lock<std::mutex> aGuard;
+ setFastPropertyValue_NoBroadcast( aGuard, PROP_PROPOSED_ROLE, uno::Any( rRole ));
}
UncachedDataSequence::UncachedDataSequence( const UncachedDataSequence & rSource )
- : ::comphelper::OMutexAndBroadcastHelper(),
- OPropertyContainer( GetBroadcastHelper()),
- ::comphelper::OPropertyArrayUsageHelper< UncachedDataSequence >(),
- UncachedDataSequence_Base( GetMutex()),
- m_nNumberFormatKey( rSource.m_nNumberFormatKey ),
+ : m_nNumberFormatKey( rSource.m_nNumberFormatKey ),
m_sRole( rSource.m_sRole ),
m_xDataProvider( rSource.m_xDataProvider ),
m_aSourceRepresentation( rSource.m_aSourceRepresentation ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
registerProperties();
}
@@ -120,8 +112,8 @@ void UncachedDataSequence::registerProperties()
cppu::UnoType<decltype(m_aXMLRange)>::get() );
}
-IMPLEMENT_FORWARD_XINTERFACE2( UncachedDataSequence, UncachedDataSequence_Base, OPropertyContainer )
-IMPLEMENT_FORWARD_XTYPEPROVIDER2( UncachedDataSequence, UncachedDataSequence_Base, OPropertyContainer )
+IMPLEMENT_FORWARD_XINTERFACE2( UncachedDataSequence, UncachedDataSequence_Base, comphelper::OPropertyContainer2 )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( UncachedDataSequence, UncachedDataSequence_Base, comphelper::OPropertyContainer2 )
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL UncachedDataSequence::getPropertySetInfo()
@@ -169,10 +161,10 @@ css::uno::Sequence< OUString > SAL_CALL UncachedDataSequence::getSupportedServic
Sequence< double > SAL_CALL UncachedDataSequence::getNumericalData()
{
Sequence< double > aResult;
- MutexGuard aGuard( GetMutex() );
+ std::unique_lock<std::mutex> aGuard;
if( m_xDataProvider.is())
{
- Sequence< uno::Any > aValues( m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation ));
+ const Sequence< uno::Any > aValues( m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation ));
aResult.realloc( aValues.getLength());
std::transform( aValues.begin(), aValues.end(),
aResult.getArray(), CommonFunctors::AnyToDouble());
@@ -184,10 +176,10 @@ Sequence< double > SAL_CALL UncachedDataSequence::getNumericalData()
Sequence< OUString > SAL_CALL UncachedDataSequence::getTextualData()
{
Sequence< OUString > aResult;
- MutexGuard aGuard( GetMutex() );
+ std::unique_lock<std::mutex> aGuard;
if( m_xDataProvider.is())
{
- Sequence< uno::Any > aValues( m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation ));
+ const Sequence< uno::Any > aValues( m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation ));
aResult.realloc( aValues.getLength());
std::transform( aValues.begin(), aValues.end(),
aResult.getArray(), CommonFunctors::AnyToString());
@@ -198,7 +190,7 @@ Sequence< OUString > SAL_CALL UncachedDataSequence::getTextualData()
// ________ XDataSequence ________
Sequence< Any > SAL_CALL UncachedDataSequence::getData()
{
- MutexGuard aGuard( GetMutex() );
+ std::unique_lock<std::mutex> aGuard;
if( m_xDataProvider.is())
return m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation );
return Sequence< Any >();
@@ -214,7 +206,7 @@ Sequence< OUString > SAL_CALL UncachedDataSequence::generateLabel( chart2::data:
// auto-generated label
sal_Int32 nSeries = m_aSourceRepresentation.toInt32() + 1;
OUString aResString(::chart::SchResId(STR_DATA_UNNAMED_SERIES_WITH_INDEX));
- const OUString aReplacementStr("%NUMBER");
+ static constexpr OUString aReplacementStr(u"%NUMBER"_ustr);
sal_Int32 nIndex = aResString.indexOf(aReplacementStr);
OUString aName;
if( nIndex != -1 )
@@ -230,12 +222,12 @@ Sequence< OUString > SAL_CALL UncachedDataSequence::generateLabel( chart2::data:
// ____ XIndexReplace ____
void SAL_CALL UncachedDataSequence::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element )
{
- MutexGuard aGuard( GetMutex() );
+ std::unique_lock<std::mutex> aGuard;
Sequence< Any > aData( getData());
if( Index < aData.getLength() &&
m_xDataProvider.is() )
{
- aData[Index] = Element;
+ aData.getArray()[Index] = Element;
m_xDataProvider->setDataByRangeRepresentation( m_aSourceRepresentation, aData );
fireModifyEvent();
}
@@ -281,8 +273,7 @@ void SAL_CALL UncachedDataSequence::setName( const OUString& aName )
Reference< util::XCloneable > SAL_CALL UncachedDataSequence::createClone()
{
- UncachedDataSequence * pNewSeq = new UncachedDataSequence( *this );
- return Reference< util::XCloneable >( pNewSeq );
+ return new UncachedDataSequence( *this );
}
// ____ XModifiable ____
@@ -300,28 +291,12 @@ void SAL_CALL UncachedDataSequence::setModified( sal_Bool bModified )
// ____ XModifyBroadcaster (base of XModifiable) ____
void SAL_CALL UncachedDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL UncachedDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
void UncachedDataSequence::fireModifyEvent()
diff --git a/chart2/source/tools/WeakListenerAdapter.cxx b/chart2/source/tools/WeakListenerAdapter.cxx
index 85b2f3b39a36..16b3d815031c 100644
--- a/chart2/source/tools/WeakListenerAdapter.cxx
+++ b/chart2/source/tools/WeakListenerAdapter.cxx
@@ -26,21 +26,6 @@ using ::com::sun::star::uno::Reference;
namespace chart
{
-WeakModifyListenerAdapter::WeakModifyListenerAdapter(
- const uno::WeakReference< util::XModifyListener > & xListener ) :
- WeakListenerAdapter< css::util::XModifyListener >( xListener )
-{}
-
-WeakModifyListenerAdapter::~WeakModifyListenerAdapter()
-{}
-
-void SAL_CALL WeakModifyListenerAdapter::modified( const lang::EventObject& aEvent )
-{
- Reference< util::XModifyListener > xModListener( getListener() );
- if( xModListener.is())
- xModListener->modified( aEvent );
-}
-
WeakSelectionChangeListenerAdapter::WeakSelectionChangeListenerAdapter(
const Reference< view::XSelectionChangeListener > & xListener ) :
WeakListenerAdapter< css::view::XSelectionChangeListener >( xListener )
diff --git a/chart2/source/tools/WrappedDefaultProperty.cxx b/chart2/source/tools/WrappedDefaultProperty.cxx
index 74d2b4b0aae0..00a94493eafc 100644
--- a/chart2/source/tools/WrappedDefaultProperty.cxx
+++ b/chart2/source/tools/WrappedDefaultProperty.cxx
@@ -18,10 +18,11 @@
*/
#include <WrappedDefaultProperty.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
+#include <utility>
using namespace ::com::sun::star;
@@ -32,9 +33,9 @@ namespace chart
WrappedDefaultProperty::WrappedDefaultProperty(
const OUString& rOuterName, const OUString& rInnerName,
- const uno::Any& rNewOuterDefault ) :
+ uno::Any aNewOuterDefault ) :
WrappedProperty( rOuterName, rInnerName ),
- m_aOuterDefaultValue( rNewOuterDefault )
+ m_aOuterDefaultValue(std::move( aNewOuterDefault ))
{}
WrappedDefaultProperty::~WrappedDefaultProperty()
diff --git a/chart2/source/tools/WrappedProperty.cxx b/chart2/source/tools/WrappedProperty.cxx
index ee28aba86e68..8b0891c770f5 100644
--- a/chart2/source/tools/WrappedProperty.cxx
+++ b/chart2/source/tools/WrappedProperty.cxx
@@ -20,7 +20,8 @@
#include <WrappedProperty.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
-#include <tools/diagnose_ex.h>
+#include <utility>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using ::com::sun::star::uno::Any;
@@ -29,9 +30,9 @@ using ::com::sun::star::uno::Reference;
namespace chart
{
-WrappedProperty::WrappedProperty( const OUString& rOuterName, const OUString& rInnerName)
- : m_aOuterName( rOuterName )
- , m_aInnerName( rInnerName )
+WrappedProperty::WrappedProperty( OUString aOuterName, OUString aInnerName)
+ : m_aOuterName(std::move( aOuterName ))
+ , m_aInnerName(std::move( aInnerName ))
{
}
WrappedProperty::~WrappedProperty()
diff --git a/chart2/source/tools/WrappedPropertySet.cxx b/chart2/source/tools/WrappedPropertySet.cxx
index 483c907a81b1..9eee3f8632e8 100644
--- a/chart2/source/tools/WrappedPropertySet.cxx
+++ b/chart2/source/tools/WrappedPropertySet.cxx
@@ -20,7 +20,7 @@
#include <WrappedPropertySet.hxx>
#include <cppuhelper/propshlp.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
namespace chart
@@ -237,12 +237,13 @@ Sequence< Any > SAL_CALL WrappedPropertySet::getPropertyValues( const Sequence<
if( rNameSeq.hasElements() )
{
aRetSeq.realloc( rNameSeq.getLength() );
+ auto pRetSeq = aRetSeq.getArray();
for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
{
try
{
OUString aPropertyName( rNameSeq[nN] );
- aRetSeq[nN] = getPropertyValue( aPropertyName );
+ pRetSeq[nN] = getPropertyValue( aPropertyName );
}
catch( const beans::UnknownPropertyException& )
{
@@ -309,10 +310,11 @@ Sequence< beans::PropertyState > SAL_CALL WrappedPropertySet::getPropertyStates(
if( rNameSeq.hasElements() )
{
aRetSeq.realloc( rNameSeq.getLength() );
+ auto pRetSeq = aRetSeq.getArray();
for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
{
OUString aPropertyName( rNameSeq[nN] );
- aRetSeq[nN] = getPropertyState( aPropertyName );
+ pRetSeq[nN] = getPropertyState( aPropertyName );
}
}
return aRetSeq;
@@ -367,10 +369,11 @@ Sequence< Any > SAL_CALL WrappedPropertySet::getPropertyDefaults( const Sequence
if( rNameSeq.hasElements() )
{
aRetSeq.realloc( rNameSeq.getLength() );
+ auto pRetSeq = aRetSeq.getArray();
for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
{
OUString aPropertyName( rNameSeq[nN] );
- aRetSeq[nN] = getPropertyDefault( aPropertyName );
+ pRetSeq[nN] = getPropertyDefault( aPropertyName );
}
}
return aRetSeq;
diff --git a/chart2/source/tools/XMLRangeHelper.cxx b/chart2/source/tools/XMLRangeHelper.cxx
index cc4749deee1f..196a0396542a 100644
--- a/chart2/source/tools/XMLRangeHelper.cxx
+++ b/chart2/source/tools/XMLRangeHelper.cxx
@@ -21,6 +21,7 @@
#include <rtl/character.hxx>
#include <rtl/ustrbuf.hxx>
#include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
#include <algorithm>
@@ -103,7 +104,7 @@ void lcl_getXMLStringForCell( const ::chart::XMLRangeHelper::Cell & rCell, OUStr
}
void lcl_getSingleCellAddressFromXMLString(
- const OUString& rXMLString,
+ std::u16string_view rXMLString,
sal_Int32 nStartPos, sal_Int32 nEndPos,
::chart::XMLRangeHelper::Cell & rOutCell )
{
@@ -111,7 +112,7 @@ void lcl_getSingleCellAddressFromXMLString(
static const sal_Unicode aDollar( '$' );
static const sal_Unicode aLetterA( 'A' );
- OUString aCellStr = rXMLString.copy( nStartPos, nEndPos - nStartPos + 1 ).toAsciiUpperCase();
+ OUString aCellStr = OUString(rXMLString.substr( nStartPos, nEndPos - nStartPos + 1 )).toAsciiUpperCase();
const sal_Unicode* pStrArray = aCellStr.getStr();
sal_Int32 nLength = aCellStr.getLength();
sal_Int32 i = nLength - 1, nColumn = 0;
@@ -119,7 +120,7 @@ void lcl_getSingleCellAddressFromXMLString(
// parse number for row
while( rtl::isAsciiDigit( pStrArray[ i ] ) && i >= 0 )
i--;
- rOutCell.nRow = (aCellStr.copy( i + 1 )).toInt32() - 1;
+ rOutCell.nRow = (o3tl::toInt32(aCellStr.subView( i + 1 ))) - 1;
// a dollar in XML means absolute (whereas in UI it means relative)
if( pStrArray[ i ] == aDollar )
{