chart2/source/inc/FormattedStringHelper.hxx | 7 +-- chart2/source/inc/RegressionCurveCalculator.hxx | 44 +++++++++++------------ chart2/source/inc/RegressionCurveHelper.hxx | 3 + chart2/source/tools/FormattedStringHelper.cxx | 6 +-- chart2/source/tools/RegressionCurveHelper.cxx | 4 +- chart2/source/tools/RegressionCurveModel.cxx | 1 chart2/source/view/charttypes/VSeriesPlotter.cxx | 6 +-- chart2/source/view/inc/LegendEntryProvider.hxx | 2 - chart2/source/view/main/VDataSeries.cxx | 5 +- chart2/source/view/main/VLegend.cxx | 21 ++++------ 10 files changed, 48 insertions(+), 51 deletions(-)
New commits: commit c00cd73f15606d4e0fc942ddbb1ab734b83fc8c7 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 22 10:38:50 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Mar 22 19:58:09 2023 +0000 use more concrete type in chart2 Change-Id: I92e0cb707b0fdd8e82ba350919294584904f2c68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149333 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/inc/RegressionCurveCalculator.hxx b/chart2/source/inc/RegressionCurveCalculator.hxx index 6cf1f2914d5b..ebb3ad40f616 100644 --- a/chart2/source/inc/RegressionCurveCalculator.hxx +++ b/chart2/source/inc/RegressionCurveCalculator.hxx @@ -42,28 +42,6 @@ public: static bool isLogarithmicScaling( const css::uno::Reference< css::chart2::XScaling >& xScaling ); -protected: - virtual OUString ImplGetRepresentation( - const css::uno::Reference< css::util::XNumberFormatter >& xNumFormatter, - sal_Int32 nNumberFormatKey, sal_Int32* pFormulaLength = nullptr ) const = 0; - - static OUString getFormattedString( - const css::uno::Reference< css::util::XNumberFormatter >& xNumFormatter, - sal_Int32 nNumberFormatKey, - double fNumber, - const sal_Int32* pStringLength ); - - static void addStringToEquation( OUStringBuffer& aStrEquation, sal_Int32& nLineLength, OUStringBuffer const & aAddString, const sal_Int32* pMaxLength ); - - double m_fCorrelationCoefficient; - - sal_Int32 mDegree; - bool mForceIntercept; - double mInterceptValue; - sal_Int32 mPeriod; - OUString mXName, mYName; - sal_Int32 mnMovingType; - // ____ XRegressionCurveCalculator ____ virtual void SAL_CALL setRegressionProperties( sal_Int32 aDegree, @@ -96,6 +74,28 @@ protected: virtual void SAL_CALL setXYNames( const OUString& aXName, const OUString& aYName ) override; + +protected: + virtual OUString ImplGetRepresentation( + const css::uno::Reference< css::util::XNumberFormatter >& xNumFormatter, + sal_Int32 nNumberFormatKey, sal_Int32* pFormulaLength = nullptr ) const = 0; + + static OUString getFormattedString( + const css::uno::Reference< css::util::XNumberFormatter >& xNumFormatter, + sal_Int32 nNumberFormatKey, + double fNumber, + const sal_Int32* pStringLength ); + + static void addStringToEquation( OUStringBuffer& aStrEquation, sal_Int32& nLineLength, OUStringBuffer const & aAddString, const sal_Int32* pMaxLength ); + + double m_fCorrelationCoefficient; + + sal_Int32 mDegree; + bool mForceIntercept; + double mInterceptValue; + sal_Int32 mPeriod; + OUString mXName, mYName; + sal_Int32 mnMovingType; }; } // namespace chart diff --git a/chart2/source/inc/RegressionCurveHelper.hxx b/chart2/source/inc/RegressionCurveHelper.hxx index d8e35a25f089..9f1b935c0d01 100644 --- a/chart2/source/inc/RegressionCurveHelper.hxx +++ b/chart2/source/inc/RegressionCurveHelper.hxx @@ -35,6 +35,7 @@ namespace com::sun::star::frame { class XModel; } namespace chart { class ChartModel; } namespace chart { class DataSeries; } namespace chart { class RegressionCurveModel; } +namespace chart { class RegressionCurveCalculator; } namespace chart::RegressionCurveHelper { @@ -140,7 +141,7 @@ namespace chart::RegressionCurveHelper css::uno::Reference<css::chart2::XRegressionCurve> const & xRegressionCurve ); /// returns a calculator object for regression curves (used by the view) - OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference<css::chart2::XRegressionCurveCalculator> + OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveCalculator> createRegressionCurveCalculatorByServiceName( std::u16string_view aServiceName ); /** recalculates the regression parameters according to the data given in diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index 50da3958d959..0bed3ca19e16 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -135,10 +135,10 @@ rtl::Reference< RegressionCurveModel > RegressionCurveHelper::createRegressionCu 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" ) diff --git a/chart2/source/tools/RegressionCurveModel.cxx b/chart2/source/tools/RegressionCurveModel.cxx index d4e8d3839b95..66bd21aa84d4 100644 --- a/chart2/source/tools/RegressionCurveModel.cxx +++ b/chart2/source/tools/RegressionCurveModel.cxx @@ -19,6 +19,7 @@ #include <RegressionCurveModel.hxx> #include <LinePropertiesHelper.hxx> +#include <RegressionCurveCalculator.hxx> #include <RegressionCurveHelper.hxx> #include "RegressionEquation.hxx" #include <CloneHelper.hxx> diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index d1dc3db8a09c..6b6df81dde54 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -26,6 +26,7 @@ #include <LabelPositionHelper.hxx> #include <ChartType.hxx> #include <ChartTypeHelper.hxx> +#include <RegressionCurveCalculator.hxx> #include <RegressionCurveHelper.hxx> #include <unonames.hxx> @@ -744,7 +745,7 @@ double VDataSeries::getXMeanValue() const { if( std::isnan( m_fXMeanValue ) ) { - uno::Reference< XRegressionCurveCalculator > xCalculator( RegressionCurveHelper::createRegressionCurveCalculatorByServiceName( u"com.sun.star.chart2.MeanValueRegressionCurve" ) ); + rtl::Reference< RegressionCurveCalculator > xCalculator( RegressionCurveHelper::createRegressionCurveCalculatorByServiceName( u"com.sun.star.chart2.MeanValueRegressionCurve" ) ); uno::Sequence< double > aXValuesDummy; xCalculator->recalculateRegression( aXValuesDummy, getAllX() ); m_fXMeanValue = xCalculator->getCurveValue( 1.0 ); @@ -756,7 +757,7 @@ double VDataSeries::getYMeanValue() const { if( std::isnan( m_fYMeanValue ) ) { - uno::Reference< XRegressionCurveCalculator > xCalculator( + rtl::Reference< RegressionCurveCalculator > xCalculator( RegressionCurveHelper::createRegressionCurveCalculatorByServiceName(u"com.sun.star.chart2.MeanValueRegressionCurve")); uno::Sequence< double > aXValuesDummy; xCalculator->recalculateRegression( aXValuesDummy, getAllY() ); commit 88047257087350497009e418850a90f1cd34310a Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 22 10:25:47 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Mar 22 19:58:00 2023 +0000 simplify ViewLegendEntry we never have more than one FormattedString Change-Id: Id61a2a89a053f49da758a2bb888cef189515458f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149332 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/inc/FormattedStringHelper.hxx b/chart2/source/inc/FormattedStringHelper.hxx index ef2077c40f69..9e4d33b6af67 100644 --- a/chart2/source/inc/FormattedStringHelper.hxx +++ b/chart2/source/inc/FormattedStringHelper.hxx @@ -18,9 +18,9 @@ */ #pragma once -#include <vector> #include <rtl/ref.hxx> #include <rtl/ustring.hxx> +#include <vector> namespace com::sun::star::beans { class XPropertySet; } namespace com::sun::star::chart2 { class XFormattedString2; } @@ -33,9 +33,8 @@ class FormattedString; class FormattedStringHelper { public: - static std::vector< - rtl::Reference< ::chart::FormattedString > > - createFormattedStringSequence( + static rtl::Reference< ::chart::FormattedString > + createFormattedString( const OUString & rString , const css::uno::Reference< css::beans::XPropertySet > & xTextProperties ) noexcept; }; diff --git a/chart2/source/tools/FormattedStringHelper.cxx b/chart2/source/tools/FormattedStringHelper.cxx index 3cfc04c34dcc..0197d281d5b1 100644 --- a/chart2/source/tools/FormattedStringHelper.cxx +++ b/chart2/source/tools/FormattedStringHelper.cxx @@ -31,8 +31,8 @@ using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -std::vector< rtl::Reference< ::chart::FormattedString > > - FormattedStringHelper::createFormattedStringSequence( +rtl::Reference< ::chart::FormattedString > + FormattedStringHelper::createFormattedString( const OUString & rString , const Reference< beans::XPropertySet > & xTextProperties ) noexcept { @@ -52,7 +52,7 @@ std::vector< rtl::Reference< ::chart::FormattedString > > DBG_UNHANDLED_EXCEPTION("chart2"); } - return { xFormStr }; + return xFormStr; } } //namespace chart diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 77b3ecdfedd2..2b3cebbd59ce 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -2788,7 +2788,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( aLabelText = aCategoryNames[nIdx]; if( xShape.is() || !aLabelText.isEmpty() ) { - aEntry.aLabel = FormattedStringHelper::createFormattedStringSequence( aLabelText, xTextProperties ); + aEntry.xLabel = FormattedStringHelper::createFormattedString( aLabelText, xTextProperties ); aResult.push_back(aEntry); } } @@ -2814,7 +2814,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( // label aLabelText = rSeries.getModel()->getLabelForRole( m_xChartTypeModel.is() ? m_xChartTypeModel->getRoleOfSequenceForSeriesLabel() : "values-y"); - aEntry.aLabel = FormattedStringHelper::createFormattedStringSequence( aLabelText, xTextProperties ); + aEntry.xLabel = FormattedStringHelper::createFormattedString( aLabelText, xTextProperties ); aResult.push_back(aEntry); } @@ -2834,7 +2834,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( //label OUString aResStr( RegressionCurveHelper::getUINameForRegressionCurve( aCurves[i] ) ); replaceParamterInString( aResStr, u"%SERIESNAME", aLabelText ); - aEntry.aLabel = FormattedStringHelper::createFormattedStringSequence( aResStr, xTextProperties ); + aEntry.xLabel = FormattedStringHelper::createFormattedString( aResStr, xTextProperties ); // symbol rtl::Reference<SvxShapeGroup> xSymbolGroup(ShapeFactory::createGroup2D( xTarget )); diff --git a/chart2/source/view/inc/LegendEntryProvider.hxx b/chart2/source/view/inc/LegendEntryProvider.hxx index d78a367b1c58..ce7722b0edfd 100644 --- a/chart2/source/view/inc/LegendEntryProvider.hxx +++ b/chart2/source/view/inc/LegendEntryProvider.hxx @@ -63,7 +63,7 @@ struct ViewLegendEntry /** The descriptive text for a legend entry. */ - std::vector< rtl::Reference< ::chart::FormattedString > > aLabel; + rtl::Reference< ::chart::FormattedString > xLabel; }; diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 27bf869b8663..dab52a407e19 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -161,22 +161,17 @@ awt::Size lcl_createTextShapes( try { OUString aLabelString; - const std::vector< rtl::Reference< ::chart::FormattedString > > & rLabelSeq = rEntry.aLabel; - for( size_t i = 0; i < rLabelSeq.size(); ++i ) + if (rEntry.xLabel) { - // todo: support more than one text range - if( i == 1 ) - break; - // tdf#150034 limit legend label text - if (rLabelSeq[i]->getString().getLength() > 520) + if (rEntry.xLabel->getString().getLength() > 520) { - sal_Int32 nIndex = rLabelSeq[i]->getString().indexOf(' ', 500); - rLabelSeq[i]->setString( - rLabelSeq[i]->getString().copy(0, nIndex > 500 ? nIndex : 500)); + sal_Int32 nIndex = rEntry.xLabel->getString().indexOf(' ', 500); + rEntry.xLabel->setString( + rEntry.xLabel->getString().copy(0, nIndex > 500 ? nIndex : 500)); } - aLabelString += rLabelSeq[i]->getString(); + aLabelString += rEntry.xLabel->getString(); // workaround for Issue #i67540# if( aLabelString.isEmpty()) aLabelString = " "; @@ -425,7 +420,7 @@ awt::Size lcl_placeLegendEntries( { try { - OUString aLabelString = rEntries[0].aLabel[0]->getString(); + OUString aLabelString = rEntries[0].xLabel->getString(); static const OUStringLiteral sDots = u"..."; for (sal_Int32 nNewLen = aLabelString.getLength() - sDots.getLength(); nNewLen > 0; ) { @@ -440,7 +435,7 @@ awt::Size lcl_placeLegendEntries( if (rRemainingSpace.Width - nWidth >= 0) { aTextShapes.push_back(xEntry); - rEntries[0].aLabel[0]->setString(aNewLabel); + rEntries[0].xLabel->setString(aNewLabel); aRowHeights[0] = nSumHeight; aColumnWidths[0] = nWidth; break;