[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - chart2/qa chart2/source sc/qa sw/qa

2023-02-13 Thread Gülşah Köse (via logerrit)
 chart2/qa/extras/chart2import.cxx   |  
 92 ++
 chart2/qa/extras/chart2import2.cxx  |  
 14 -
 chart2/qa/extras/charttest.hxx  |  
 38 
 chart2/qa/extras/data/pptx/PieChartWithAutomaticLayout_SizeAndPosition.pptx 
|binary
 chart2/source/view/main/ChartView.cxx   |  
 20 +-
 sc/qa/uitest/chart/chartDataLabels.py   |  
  8 
 sw/qa/extras/layout/layout2.cxx |  
  4 
 7 files changed, 159 insertions(+), 17 deletions(-)

New commits:
commit a6dbb1c765eb5f268badd8727beedfe27786bd08
Author: Gülşah Köse 
AuthorDate: Wed Nov 23 17:05:28 2022 +0300
Commit: Gülşah Köse 
CommitDate: Mon Feb 13 09:12:32 2023 +

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 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146603
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Pedro Silva 

diff --git a/chart2/qa/extras/chart2import.cxx 
b/chart2/qa/extras/chart2import.cxx
index 6710c86aba90..91abc305ebd2 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -138,6 +138,7 @@ public:
 void testFixedSizeBarChartVeryLongLabel();
 void testAutomaticSizeBarChartVeryLongLabel();
 void testTotalsRowIgnored();
+void testPieChartPlotAreaMarginWithAutomaticLayout();
 
 CPPUNIT_TEST_SUITE(Chart2ImportTest);
 CPPUNIT_TEST(Fdo60083);
@@ -224,6 +225,7 @@ public:
 CPPUNIT_TEST(testFixedSizeBarChartVeryLongLabel);
 CPPUNIT_TEST(testAutomaticSizeBarChartVeryLongLabel);
 CPPUNIT_TEST(testTotalsRowIgnored);
+CPPUNIT_TEST(testPieChartPlotAreaMarginWithAutomaticLayout);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -2283,6 +2285,96 @@ void Chart2ImportTest::testTotalsRowIgnored()
 }
 }
 
+void Chart2ImportTest::testPieChartPlotAreaMarginWithAutomaticLayout()
+{
+// tdf#91265
+// Checks the margin and calculation of the plot area for the pie chart 
inside the chart area.
+
+load(u"/chart2/qa/extras/data/pptx/", 
"PieChartWithAutomaticLayout_SizeAndPosition.pptx");
+
+OUString aCheckShapeName = "CID/D=0:CS=0:CT=0:Series=0";
+// Chart Wuse case Width == Height
+{
+// Load chart Chart_2_2 - 2cm x 2cm -
+auto xDocument = getChartDocFromDrawImpressNamed(0, u"Chart_2_2");
+CPPUNIT_ASSERT(xDocument.is());
+
+uno::ReferencexChartDocument(xDocument, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xChartDocument.is());
+
+// Get the shape of the diagram / chart
+uno::Reference 
xDrawPageSupplier(xChartDocument, uno::UNO_QUERY);
+CPPUNIT_ASSERT(xDrawPageSupplier.is());
+uno::Reference xDrawPage = 
xDrawPageSupplier->getDrawPage();
+uno::Reference xShapes(xDrawPage->getByIndex(0), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShapes.is());
+
+uno::Reference xChartDiagramShape = 
getShapeByName(xShapes, aCheckShapeName);
+CPPUNIT_ASSERT(xChartDiagramShape.is());
+
+// Size
+CPPUNIT_ASSERT_DOUBLES_EQUAL(1300, 
xChartDiagramShape->getSize().Width, 5);  // calculated chart area size - 2 * 
margin
+CPPUNIT_ASSERT_DOUBLES_EQUAL(1300, 
xChartDiagramShape->getSize().Height, 5); // calculated chart area size - 2 * 
margin
+// Position
+CPPUNIT_ASSERT_DOUBLES_EQUAL(350, xChartDiagramShape->getPosition().X, 
5); // margin
+CPPUNIT_ASSERT_DOUBLES_EQUAL(350, xChartDiagramShape->getPosition().Y, 
5); // margin
+}
+
+// Chart use case - Width < Height
+{
+// Load chart Chart_3_4 - 3cm x 4cm
+auto xDocument = getChartDocFromDrawImpressNamed(0, u"Chart_3_4");
+CPPUNIT_ASSERT(xDocument.is());
+
+uno::ReferencexChartDocument(xDocument, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xChartDocument.is());
+
+// Get the shape of the diagram / chart
+uno::Reference 
xDrawPageSupplier(xChartDocument, uno::UNO_QUERY);
+CPPUNIT_ASSERT(xDrawPageSupplier.is());
+uno::Reference xDrawPage = 
xDrawPageSupplier->getDrawPage();
+uno::Reference xShapes(xDrawPage->getByIndex(0), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShapes.is());
+
+uno::Reference xChartDiagramShape = 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - chart2/qa chart2/source

2022-08-26 Thread Tomaž Vajngerl (via logerrit)
 chart2/qa/extras/chart2import2.cxx 
 |   16 ++
 
chart2/qa/extras/data/xlsx/DataTable-MultipleLegendEntriesForOneDataSeries.xlsx 
|binary
 chart2/source/view/charttypes/VSeriesPlotter.cxx   
 |   79 --
 chart2/source/view/main/DataTableView.cxx  
 |   30 ++-
 4 files changed, 38 insertions(+), 87 deletions(-)

New commits:
commit ae60b32042f0702c98d4d34a36d8f6192deb
Author: Tomaž Vajngerl 
AuthorDate: Mon Aug 22 16:46:41 2022 +0200
Commit: Tomaž Vajngerl 
CommitDate: Fri Aug 26 12:33:52 2022 +0200

chart2: always use the series for the keys (symbols) in data table

In special case the legend keys are not series, but can be each
value of a series. This can't be done for the data table where so
this has been disabled.

This caused a crash when positioning the symbols, as in some cases
we got 0 symbols (due to another bug that didn't put the symbols
into the collection) or more symbols that there were series (and
the symbols couldn't be positioned correctly). With this change
we now get the correct number of symbols for the data table.

Also added the test document and test to open the document, to
make sure we don't crash anymore.

Change-Id: Idbebdd5295595a823b5420958e803b13258df035
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138697
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit e5583150a3953f08782865e0f90d41f5c35cc6c5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138806
Tested-by: Jenkins CollaboraOffice 

diff --git a/chart2/qa/extras/chart2import2.cxx 
b/chart2/qa/extras/chart2import2.cxx
index 95ee2428b47d..596531990e36 100644
--- a/chart2/qa/extras/chart2import2.cxx
+++ b/chart2/qa/extras/chart2import2.cxx
@@ -76,6 +76,7 @@ public:
 void testTdf121281();
 void testTdf139658();
 void testTdf146066();
+void testChartDataTableWithMultipleLegendEntriesForOneDataSeries();
 
 CPPUNIT_TEST_SUITE(Chart2ImportTest2);
 
@@ -116,6 +117,7 @@ public:
 CPPUNIT_TEST(testTdf121281);
 CPPUNIT_TEST(testTdf139658);
 CPPUNIT_TEST(testTdf146066);
+CPPUNIT_TEST(testChartDataTableWithMultipleLegendEntriesForOneDataSeries);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -922,6 +924,20 @@ void Chart2ImportTest2::testTdf146066()
 CPPUNIT_ASSERT_EQUAL(OUString("35"), xLabel7->getString());
 }
 
+void 
Chart2ImportTest2::testChartDataTableWithMultipleLegendEntriesForOneDataSeries()
+{
+load(u"/chart2/qa/extras/data/xlsx/", 
u"DataTable-MultipleLegendEntriesForOneDataSeries.xlsx");
+// Loading this file caused a crash in the data table code
+
+Reference xChartDoc(getChartDocFromSheet(0, 
mxComponent),
+   UNO_QUERY_THROW);
+Reference xDrawPageSupplier(xChartDoc, 
UNO_QUERY_THROW);
+Reference xDrawPage(xDrawPageSupplier->getDrawPage(), 
UNO_SET_THROW);
+Reference xShapes(xDrawPage->getByIndex(0), 
UNO_QUERY_THROW);
+Reference xDataTableShape = getShapeByName(xShapes, 
"CID/D=0:DataTable=");
+CPPUNIT_ASSERT(xDataTableShape.is());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git 
a/chart2/qa/extras/data/xlsx/DataTable-MultipleLegendEntriesForOneDataSeries.xlsx
 
b/chart2/qa/extras/data/xlsx/DataTable-MultipleLegendEntriesForOneDataSeries.xlsx
new file mode 100644
index ..b077fd2e0315
Binary files /dev/null and 
b/chart2/qa/extras/data/xlsx/DataTable-MultipleLegendEntriesForOneDataSeries.xlsx
 differ
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx 
b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 0cd15188e84f..3dafa94fd99d 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -2538,11 +2538,6 @@ std::vector 
VSeriesPlotter::createSymbols(const awt::Size& rEn
 if (!pSeries)
 continue;
 
-if 
(!pSeries->getPropertiesOfSeries()->getPropertyValue("ShowLegendEntry").get())
-{
-continue;
-}
-
 std::vector aSeriesSymbols = 
createSymbolsForSeries(rEntryKeyAspectRatio, *pSeries, xTarget, xShapeFactory, 
xContext);
 
 //add series entries to the result now
@@ -2924,77 +2919,15 @@ std::vector 
VSeriesPlotter::createSymbolsForSeries(
 try
 {
 ViewLegendSymbol aEntry;
-bool bVaryColorsByPoint = rSeries.isVaryColorsByPoint();
-bool bIsPie = 
m_xChartTypeModel->getChartType().equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE);
-try
-{
-if (bIsPie)
-{
-bool bDonut = false;
-if ((m_xChartTypeModelProps->getPropertyValue("UseRings") >>= 
bDonut) && bDonut)
-