summaryrefslogtreecommitdiff
path: root/chart2/source/view/main/ChartView.cxx
diff options
context:
space:
mode:
authorGülşah Köse <gulsah.kose@collabora.com>2022-11-23 17:05:28 +0300
committerTomaž Vajngerl <quikee@gmail.com>2023-01-17 07:19:32 +0000
commit959fbfc000d2e3167b2b57b6d11bea231993b4f0 (patch)
tree123040e8b4835b408a4e39254a1b39ceffb7d707 /chart2/source/view/main/ChartView.cxx
parent92931e1162134cb88a5f413b1a317fc9fdd3579c (diff)
tdf#91265 Use same plot area distance as used in MSO
Changes the postion calculation for pie charts, where the margin min distance is now constant for pie charts, but unchanged for other chart types. This changes the positions of various pie charts used in tests, which have been changed to the new value after the cases have been checked. Added a new test with all 3 use cases (chart area width equals height, width is greater than height, width is less than height). Change-Id: I51f98f336a7c64a3e6762144fc7dc8d9df80f696 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143179 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'chart2/source/view/main/ChartView.cxx')
-rw-r--r--chart2/source/view/main/ChartView.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 2de5611c5ed0..37d237e7ee7a 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -925,15 +925,27 @@ namespace
{
constexpr double constPageLayoutDistancePercentage = 0.02;
+constexpr sal_Int32 constPageLayoutFixedDistance = 350;
bool getAvailablePosAndSizeForDiagram(
- CreateShapeParam2D& rParam, const awt::Size & rPageSize, const uno::Reference< beans::XPropertySet >& xProp)
+ CreateShapeParam2D& rParam, const awt::Size & rPageSize, rtl::Reference<Diagram> const& xDiagram)
{
+ uno::Reference<beans::XPropertySet> const& xProp(xDiagram);
rParam.mbUseFixedInnerSize = false;
//@todo: we need a size dependent on the axis labels
- sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height * constPageLayoutDistancePercentage);
- sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width * constPageLayoutDistancePercentage);
+ rtl::Reference<ChartType> xChartType(DiagramHelper::getChartTypeByIndex(xDiagram, 0));
+
+ sal_Int32 nXDistance = sal_Int32(rPageSize.Width * constPageLayoutDistancePercentage);
+ sal_Int32 nYDistance = sal_Int32(rPageSize.Height * constPageLayoutDistancePercentage);
+
+ // Only pie chart uses fixed size margins
+ if (xChartType.is() && xChartType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_PIE)
+ {
+ nXDistance = constPageLayoutFixedDistance;
+ nYDistance = constPageLayoutFixedDistance;
+ }
+
rParam.maRemainingSpace.X += nXDistance;
rParam.maRemainingSpace.Width -= 2*nXDistance;
rParam.maRemainingSpace.Y += nYDistance;