summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-08-01 16:40:27 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-01 19:00:10 +0200
commit258a8d133d0548c7af51f4852260e9969df288fc (patch)
tree237bc1df32b42a055507718dea9b5abcc1980ffa /chart2
parent0185ddd6d5f0324ba57b3fa36229103a6b27138e (diff)
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.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/main/VLegend.cxx8
1 files changed, 7 insertions, 1 deletions
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)
{