summaryrefslogtreecommitdiff
path: root/chart2/source/view/main
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2024-01-25 11:57:40 -0500
committerMiklos Vajna <vmiklos@collabora.com>2024-01-30 10:40:43 +0100
commita77403d11a60ebe6aeb33d9b6ae611412d9ab1cc (patch)
treeeccb24a43aad7df75620a7b49b2d7e2a4b3a2db7 /chart2/source/view/main
parent2048db4dc8ee6edb231a9109257846975a6f7834 (diff)
tdf#146756 pie chart2 import: use manualLayout Width for pie chart labels
... and use a compatible 1/5 width if not specified. This patch depends on the previous oox patch (commit 301e27cbebf7d6e4c9b82290d7cd555c43f0c999) which actually reads the width into the model. Fixes a 7.2 regression from commit b0068342398786ca50304260434a18880dddf74d author Tünde Tóth on Wed Dec 16 18:26:26 2020 +0100 tdf#138777 pie chart: improve long data label width and is basically a re-write of 7.1's commit 20da1a5dd37c7edac620566c992d5a53b23a5f12 author Tünde Tóth <toth.tunde@nisz.hu> on Fri Oct 09 09:24:18 2020 +0200 tdf#134978 Chart OOXML Import: fix pie chart label custom position This is very risky, but then ANYTHING changing chart2 is risky. There were a lot of changes made in 7.1, and they all invited regressions. However, our chart implementation is not in a good state, and certainly is not very interoperable, so it is worth taking the risk. Anything dealing with manualLayout at this point should have originated as a pptx, so forcing a compatible max width should be fairly safe. It probably isn't actually all that risky after all. largely copied code from commit 4223ff2be69f03e571464b0b09ad0d278918631b Author: Balazs Varga on Wed Jan 15 16:31:35 2020 +0100 tdf#48436 Chart: add CustomLabelPosition UNO API property Fortunately this all goes away after a round-trip since custom label placement is lost on export to OOXML, and that really helps to reduce the risk. make CppunitTest_chart2_import CPPUNIT_TEST_NAME=testTdf146487 Change-Id: I9722fc6c759c15ac3924780e6fc124f02fba07e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162590 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'chart2/source/view/main')
-rw-r--r--chart2/source/view/main/VDataSeries.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index 845e6d6ef0db..455c991b9f89 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -36,6 +36,7 @@
#include <com/sun/star/chart2/Symbol.hpp>
#include <com/sun/star/chart2/XRegressionCurveCalculator.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
+#include <com/sun/star/chart2/RelativeSize.hpp>
#include <osl/diagnose.h>
#include <tools/color.hxx>
@@ -645,6 +646,26 @@ bool VDataSeries::isLabelCustomPos(sal_Int32 nPointIndex) const
return bCustom;
}
+awt::Size VDataSeries::getLabelCustomSize(sal_Int32 nPointIndex) const
+{
+ awt::Size aSize(-1, -1);
+ try
+ {
+ RelativeSize aCustomLabelSize;
+ const uno::Reference<beans::XPropertySet> xPointProps(getPropertiesOfPoint(nPointIndex));
+ if (xPointProps.is() && (xPointProps->getPropertyValue("CustomLabelSize") >>= aCustomLabelSize))
+ {
+ aSize.Width = static_cast<sal_Int32>(aCustomLabelSize.Primary * m_aReferenceSize.Width);
+ aSize.Height = static_cast<sal_Int32>(aCustomLabelSize.Secondary * m_aReferenceSize.Height);
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return aSize;
+}
+
double VDataSeries::getMinimumofAllDifferentYValues( sal_Int32 index ) const
{
double fMin = std::numeric_limits<double>::infinity();