chart2/source/view/main/VLegend.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
New commits: commit 258a8d133d0548c7af51f4852260e9969df288fc Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Aug 1 16:40:27 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Aug 1 19:00:10 2022 +0200 tdf#150034 very slow opening pathological chart This chart has a ridiculously long legend, which makes the loop that tries to shorten legends take an extremely long time. Make this loop faster, at the risk of sometimes getting a slightly wrong answer. Ideally we could speed up the layout down in ImpEditEngine, but that is a much bigger task. Change-Id: I7cb337c674515bac13e4b11c3b0fabb94aed6865 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137677 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index dff497af200f..7fc92b491ad2 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -418,7 +418,7 @@ awt::Size lcl_placeLegendEntries( { OUString aLabelString = rEntries[0].aLabel[0]->getString(); static const OUStringLiteral sDots = u"..."; - for (sal_Int32 nNewLen = aLabelString.getLength() - sDots.getLength(); nNewLen > 0; nNewLen--) + for (sal_Int32 nNewLen = aLabelString.getLength() - sDots.getLength(); nNewLen > 0; ) { OUString aNewLabel = aLabelString.subView(0, nNewLen) + sDots; rtl::Reference<SvxShapeText> xEntry = ShapeFactory::createText( @@ -438,6 +438,12 @@ awt::Size lcl_placeLegendEntries( } } DrawModelWrapper::removeShape(xEntry); + // The intention here is to make pathological cases with extremely large labels + // converge a little faster + if (std::abs(nRemainingSpace) > nSumHeight / 10) + nNewLen -= nNewLen / 10; + else + --nNewLen; } if (aTextShapes.size() == 0) {