summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga.extern@allotropia.de>2024-03-07 14:32:44 +0100
committerThorsten Behrens <thorsten.behrens@allotropia.de>2024-04-30 15:10:43 +0200
commitac24baf03121deae3558a2c0b37738f4412cdbe9 (patch)
tree21b90ee4894d26ad7d95a31d475789ad49a65f7d
parenttdf#159422 - chart view: fix symbols position of data table legend (diff)
downloadcore-ac24baf03121deae3558a2c0b37738f4412cdbe9.tar.gz
core-ac24baf03121deae3558a2c0b37738f4412cdbe9.zip
tdf#159456 - chart view: fix wrongly shifted value Y axis
We only have to shift the category axis only, and not the value axis, if we have a chart data table. Change-Id: Ie77ea829e8f8987702dce7d17cb3e20054f3d8cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164539 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
-rw-r--r--chart2/source/view/main/SeriesPlotterContainer.cxx7
-rw-r--r--chart2/source/view/main/SeriesPlotterContainer.hxx2
-rw-r--r--sw/qa/extras/layout/layout3.cxx25
3 files changed, 28 insertions, 6 deletions
diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx b/chart2/source/view/main/SeriesPlotterContainer.cxx
index bcc5b0f482a3..7623992a3e08 100644
--- a/chart2/source/view/main/SeriesPlotterContainer.cxx
+++ b/chart2/source/view/main/SeriesPlotterContainer.cxx
@@ -171,7 +171,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart
}
if (xDiagram->getDataTable().is())
- m_bForceShiftPosition = true;
+ m_bTableShiftPosition = true;
//prepare for autoscaling and shape creation
// - create plotter for charttypes (for each first scale group at each plotter, as they are independent)
@@ -340,12 +340,9 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart
bool SeriesPlotterContainer::isCategoryPositionShifted(const chart2::ScaleData& rSourceScale,
bool bHasComplexCategories)
{
- if (m_bForceShiftPosition)
- return true;
-
if (rSourceScale.AxisType == AxisType::CATEGORY)
return bHasComplexCategories || rSourceScale.ShiftedCategoryPosition
- || m_bChartTypeUsesShiftedCategoryPositionPerDefault;
+ || m_bTableShiftPosition || m_bChartTypeUsesShiftedCategoryPositionPerDefault;
if (rSourceScale.AxisType == AxisType::DATE)
return rSourceScale.ShiftedCategoryPosition;
diff --git a/chart2/source/view/main/SeriesPlotterContainer.hxx b/chart2/source/view/main/SeriesPlotterContainer.hxx
index 578f2ba2760c..38f3c8b909c8 100644
--- a/chart2/source/view/main/SeriesPlotterContainer.hxx
+++ b/chart2/source/view/main/SeriesPlotterContainer.hxx
@@ -151,7 +151,7 @@ private:
sal_Int32 m_nMaxAxisIndex;
bool m_bChartTypeUsesShiftedCategoryPositionPerDefault;
- bool m_bForceShiftPosition = false;
+ bool m_bTableShiftPosition = false;
sal_Int32 m_nDefaultDateNumberFormat;
};
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 04bf1fc6c318..ccc69ab1b2bc 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -2440,6 +2440,31 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf159422)
CPPUNIT_ASSERT_DOUBLES_EQUAL(6573, nYSymbol3, 20);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf159456)
+{
+ // Given a document with chart, which have a datatable
+ createSwDoc("charttable.odt");
+ SwDoc* pDoc = getSwDoc();
+ SwDocShell* pShell = pDoc->GetDocShell();
+
+ // Dump the rendering of the first page as an XML file.
+ std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+ xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+ //// Without the fix, this would fail:
+ //// - Expected: 1
+ //// - Actual : 1.5
+ //// - In <>, XPath contents of child does not match
+ assertXPathContent(pXmlDoc,
+ "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/"
+ "push[103]/textarray/text",
+ "1");
+ assertXPathContent(pXmlDoc,
+ "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/"
+ "push[104]/textarray/text",
+ "2");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */