[Libreoffice-commits] core.git: chart2/qa chart2/source oox/source

2020-11-24 Thread Tünde Tóth (via logerrit)
 chart2/qa/extras/chart2dump/chart2dump.cxx   |   23 
 chart2/qa/extras/chart2export.cxx|   29 ++-
 chart2/qa/extras/chart2import.cxx|   26 -
 chart2/qa/extras/charttest.hxx   |   26 +
 chart2/qa/extras/data/xlsx/piechart_deleted_legendentry.xlsx |binary
 chart2/source/view/charttypes/VSeriesPlotter.cxx |   19 ++-
 oox/source/drawingml/chart/titleconverter.cxx|9 +++
 oox/source/export/chartexport.cxx|9 +++
 8 files changed, 86 insertions(+), 55 deletions(-)

New commits:
commit 3be5e428d669accd841949662d601a6f6e1cdb3f
Author: Tünde Tóth 
AuthorDate: Mon Nov 16 15:12:43 2020 +0100
Commit: László Németh 
CommitDate: Tue Nov 24 10:34:19 2020 +0100

tdf#138181 Chart OOXML: fix deleted legend entries of pie charts

The legend of the pie chart showed deleted legend entries too
when VaryColorsByPoint was false.

Change-Id: I6fc978af0db6e2d39d7f451e765d7ef81c73a05c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105943
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/chart2/qa/extras/chart2dump/chart2dump.cxx 
b/chart2/qa/extras/chart2dump/chart2dump.cxx
index 544eec6b5373..7fd7c4a8da61 100644
--- a/chart2/qa/extras/chart2dump/chart2dump.cxx
+++ b/chart2/qa/extras/chart2dump/chart2dump.cxx
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -252,28 +251,6 @@ protected:
 OUString::number(rTransform.Line3.Column1) + ";" + 
OUString::number(rTransform.Line3.Column2) + ";" + 
OUString::number(rTransform.Line3.Column3);
 }
 
-uno::Reference getShapeByName(const 
uno::Reference& rShapes, const OUString& rName, bool 
(*pCondition)(const uno::Reference&) = nullptr)
-{
-for (sal_Int32 i = 0; i < rShapes->getCount(); ++i)
-{
-uno::Reference xShapes(rShapes->getByIndex(i), 
uno::UNO_QUERY);
-if (xShapes.is())
-{
-uno::Reference xRet = getShapeByName(xShapes, 
rName, pCondition);
-if (xRet.is())
-return xRet;
-}
-uno::Reference 
xNamedShape(rShapes->getByIndex(i), uno::UNO_QUERY);
-if (xNamedShape->getName() == rName)
-{
-uno::Reference xShape(xNamedShape, 
uno::UNO_QUERY);
-if (pCondition == nullptr || (*pCondition)(xShape))
-return xShape;
-}
-}
-return uno::Reference();
-}
-
 private:
 OUString m_sTestFileName;
 bool m_bDumpMode;
diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index 9637aebd4e53..a39b36234862 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -183,6 +183,7 @@ public:
 void testDataLabelPlacementPieChart();
 void testTdf137917();
 void testTdf138204();
+void testTdf138181();
 
 CPPUNIT_TEST_SUITE(Chart2ExportTest);
 CPPUNIT_TEST(testErrorBarXLSX);
@@ -328,6 +329,7 @@ public:
 CPPUNIT_TEST(testDataLabelPlacementPieChart);
 CPPUNIT_TEST(testTdf137917);
 CPPUNIT_TEST(testTdf138204);
+CPPUNIT_TEST(testTdf138181);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -2970,7 +2972,6 @@ void Chart2ExportTest::testDataLabelPlacementPieChart()
 sal_Int32 nLabelPlacement = 0;
 CPPUNIT_ASSERT(aAny >>= nLabelPlacement);
 CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::OUTSIDE, nLabelPlacement);
-
 }
 
 void Chart2ExportTest::testTdf137917()
@@ -3011,6 +3012,32 @@ void Chart2ExportTest::testTdf138204()
 //CPPUNIT_ASSERT_EQUAL(OUString("67.5%"), aFields[0]->getString()); TODO: 
Not implemented yet
 }
 
+void Chart2ExportTest::testTdf138181()
+{
+load("/chart2/qa/extras/data/xlsx/", "piechart_deleted_legendentry.xlsx");
+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 xLegendEntry1, xLegendEntry2, xLegendEntry3;
+
+// first legend entry is visible
+xLegendEntry1
+= getShapeByName(xShapes, 
"CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=0:LegendEntry=0");
+CPPUNIT_ASSERT(xLegendEntry1.is());
+
+// second legend entry is not visible
+xLegendEntry2
+= getShapeByName(xShapes, 
"CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=1:LegendEntry=0");
+CPPUNIT_ASSERT(!xLegendEntry2.is());
+
+// third legend entry is visible
+xLegendEntry3
+= getShapeByName(xShapes, 
"CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=2:LegendEntry=0");
+

[Libreoffice-commits] core.git: chart2/qa chart2/source oox/source

2020-10-09 Thread Tünde Tóth (via logerrit)
 chart2/qa/extras/chart2import.cxx  |   23 ++-
 chart2/qa/extras/data/xlsx/tdf134978.xlsx  |binary
 chart2/source/tools/ChartTypeHelper.cxx|3 ++-
 chart2/source/view/charttypes/PieChart.cxx |7 +--
 oox/source/drawingml/chart/seriesconverter.cxx |6 +-
 oox/source/export/chartexport.cxx  |1 +
 6 files changed, 35 insertions(+), 5 deletions(-)

New commits:
commit 20da1a5dd37c7edac620566c992d5a53b23a5f12
Author: Tünde Tóth 
AuthorDate: Thu Sep 17 16:49:02 2020 +0200
Commit: László Németh 
CommitDate: Fri Oct 9 09:24:18 2020 +0200

tdf#134978 Chart OOXML Import: fix pie chart label custom position

Follow-up of commit dff7a46fb46d1fa2a3ad674ee493ae2d59150fe3
(tdf#130032 Chart OOXML Import: fix data label custom position).

Change-Id: Iaaf4ae654ac0c1b4896a53be6034e6c027412df0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102981
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/chart2/qa/extras/chart2import.cxx 
b/chart2/qa/extras/chart2import.cxx
index dadc782c0af6..d901f879ea18 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -158,6 +158,7 @@ public:
 void testTdf125444PercentageCustomLabel();
 void testDataPointLabelCustomPos();
 void testTdf130032();
+void testTdf134978();
 void testTdf119138MissingAutoTitleDeleted();
 void testStockChartShiftedCategoryPosition();
 void testTdf133376();
@@ -272,6 +273,7 @@ public:
 CPPUNIT_TEST(testTdf125444PercentageCustomLabel);
 CPPUNIT_TEST(testDataPointLabelCustomPos);
 CPPUNIT_TEST(testTdf130032);
+CPPUNIT_TEST(testTdf134978);
 CPPUNIT_TEST(testTdf119138MissingAutoTitleDeleted);
 CPPUNIT_TEST(testStockChartShiftedCategoryPosition);
 CPPUNIT_TEST(testTdf133376);
@@ -1783,7 +1785,7 @@ void Chart2ImportTest::testTdf109858()
 CPPUNIT_ASSERT( aAny.hasValue() );
 sal_Int32 nLabelPlacement = 0;
 CPPUNIT_ASSERT( aAny >>= nLabelPlacement );
-CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data point label should be placed bestFit", 
chart::DataLabelPlacement::AVOID_OVERLAP, nLabelPlacement );
+CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data point label should be placed bestfit", 
chart::DataLabelPlacement::CUSTOM, nLabelPlacement );
 
 // test data series label position
 Reference 
xSeriesPropSet(xChart1Doc->getDiagram()->getDataRowProperties(0), 
uno::UNO_SET_THROW);
@@ -2511,6 +2513,25 @@ void Chart2ImportTest::testTdf130032()
 CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::RIGHT, aPlacement);
 }
 
+void Chart2ImportTest::testTdf134978()
+{
+// test CustomLabelPosition on Pie chart
+load("/chart2/qa/extras/data/xlsx/", "tdf134978.xlsx");
+uno::Reference xChartDoc = getChartDocFromSheet(0, 
mxComponent);
+CPPUNIT_ASSERT(xChartDoc.is());
+uno::Reference 
xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
+CPPUNIT_ASSERT(xDataSeries.is());
+
+uno::Reference 
xPropertySet(xDataSeries->getDataPointByIndex(2),
+ uno::UNO_SET_THROW);
+CPPUNIT_ASSERT(xPropertySet.is());
+
+chart2::RelativePosition aCustomLabelPosition;
+xPropertySet->getPropertyValue("CustomLabelPosition") >>= 
aCustomLabelPosition;
+CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.040273622047244093, 
aCustomLabelPosition.Primary, 1e-7);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.25635352872557599, 
aCustomLabelPosition.Secondary, 1e-7);
+}
+
 void Chart2ImportTest::testTdf119138MissingAutoTitleDeleted()
 {
 load("/chart2/qa/extras/data/xlsx/", 
"tdf119138-missing-autotitledeleted.xlsx");
diff --git a/chart2/qa/extras/data/xlsx/tdf134978.xlsx 
b/chart2/qa/extras/data/xlsx/tdf134978.xlsx
new file mode 100644
index ..ad5522a9144d
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/tdf134978.xlsx differ
diff --git a/chart2/source/tools/ChartTypeHelper.cxx 
b/chart2/source/tools/ChartTypeHelper.cxx
index 236d066f77d3..a4b8059ffb19 100644
--- a/chart2/source/tools/ChartTypeHelper.cxx
+++ b/chart2/source/tools/ChartTypeHelper.cxx
@@ -252,12 +252,13 @@ uno::Sequence < sal_Int32 > 
ChartTypeHelper::getSupportedLabelPlacements( const
 
 if(!bDonut)
 {
-aRet.realloc(4);
+aRet.realloc(5);
 sal_Int32* pSeq = aRet.getArray();
 *pSeq++ = css::chart::DataLabelPlacement::AVOID_OVERLAP;
 *pSeq++ = css::chart::DataLabelPlacement::OUTSIDE;
 *pSeq++ = css::chart::DataLabelPlacement::INSIDE;
 *pSeq++ = css::chart::DataLabelPlacement::CENTER;
+*pSeq++ = css::chart::DataLabelPlacement::CUSTOM;
 }
 else
 {
diff --git a/chart2/source/view/charttypes/PieChart.cxx 
b/chart2/source/view/charttypes/PieChart.cxx
index 6042b0d0dbe4..55eb67037b9a 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ 

[Libreoffice-commits] core.git: chart2/qa chart2/source oox/source

2020-02-20 Thread Balazs Varga (via logerrit)
 chart2/qa/extras/chart2export.cxx|   14 
 chart2/qa/extras/data/xlsx/testTdf90749.xlsx |binary
 chart2/source/view/charttypes/VSeriesPlotter.cxx |   36 +++
 oox/source/core/xmlfilterbase.cxx|2 +
 oox/source/drawingml/chart/seriesconverter.cxx   |3 +
 oox/source/export/chartexport.cxx|9 +
 oox/source/token/namespaces-strict.txt   |1 
 oox/source/token/namespaces.hxx.tail |1 
 oox/source/token/namespaces.txt  |1 
 oox/source/token/properties.txt  |1 
 oox/source/token/tokens.txt  |1 
 11 files changed, 68 insertions(+), 1 deletion(-)

New commits:
commit 769433ad93040bc81f06672c8a2c01e2b76fece3
Author: Balazs Varga 
AuthorDate: Wed Feb 12 13:47:50 2020 +0100
Commit: László Németh 
CommitDate: Thu Feb 20 11:18:40 2020 +0100

tdf#90749 chart: add leader lines to custom data label positions

also export them as CustomXML extension for MSO interoperability.

Note: pie chart is not yet supported.

See commit 4223ff2be69f03e571464b0b09ad0d278918631b
( tdf#48436 Chart: add CustomLabelPosition UNO API property)

Change-Id: Ia8142408414d4ad8f689d789386db50038ed13f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88531
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index b9d5873052ba..88c7d154d170 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -136,6 +136,7 @@ public:
 void testCustomDataLabel();
 void testCustomPositionofDataLabel();
 void testCustomDataLabelMultipleSeries();
+void testLeaderLines();
 void testNumberFormatExportPPTX();
 void testLabelSeparatorExportDOCX();
 void testChartTitlePropertiesColorFillPPTX();
@@ -254,6 +255,7 @@ public:
 CPPUNIT_TEST(testCustomDataLabel);
 CPPUNIT_TEST(testCustomPositionofDataLabel);
 CPPUNIT_TEST(testCustomDataLabelMultipleSeries);
+CPPUNIT_TEST(testLeaderLines);
 CPPUNIT_TEST(testNumberFormatExportPPTX);
 CPPUNIT_TEST(testLabelSeparatorExportDOCX);
 CPPUNIT_TEST(testChartTitlePropertiesColorFillPPTX);
@@ -349,7 +351,8 @@ void 
Chart2ExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx)
 { "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" },
 { "table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0" },
 { "text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0" },
-{ "xlink", "http://www.w3c.org/1999/xlink; }
+{ "xlink", "http://www.w3c.org/1999/xlink; },
+{ "c15", "http://schemas.microsoft.com/office/drawing/2012/chart; }
 };
 for(size_t i = 0; i < SAL_N_ELEMENTS(aNamespaces); ++i)
 {
@@ -2246,6 +2249,15 @@ void 
Chart2ExportTest::testCustomDataLabelMultipleSeries()
 
 }
 
+void Chart2ExportTest::testLeaderLines()
+{
+load("/chart2/qa/extras/data/xlsx/", "testTdf90749.xlsx");
+xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+CPPUNIT_ASSERT(pXmlDoc);
+assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines",
 "val", "1");
+assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines",
 "val", "1");
+}
+
 void Chart2ExportTest::testNumberFormatExportPPTX()
 {
 load("/chart2/qa/extras/data/pptx/", "tdf115859.pptx");
diff --git a/chart2/qa/extras/data/xlsx/testTdf90749.xlsx 
b/chart2/qa/extras/data/xlsx/testTdf90749.xlsx
new file mode 100644
index ..ca3bc806c03c
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/testTdf90749.xlsx differ
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx 
b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index b6382943b418..2c46743696f6 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -86,6 +87,7 @@
 namespace chart {
 
 using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart;
 using namespace ::com::sun::star::chart2;
 using ::com::sun::star::uno::Reference;
 using ::com::sun::star::uno::Sequence;
@@ -721,7 +723,41 @@ uno::Reference< drawing::XShape > 
VSeriesPlotter::createDataLabel( const uno::Re
 {
 awt::Point aRelPos = rDataSeries.getLabelPosition(aTextShapePos, 
nPointIndex);
 if( aRelPos.X != -1 )
+{
 xTextShape->setPosition(aRelPos);
+if( 
!m_xChartTypeModel->getChartType().equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE)
 )
+{
+sal_Int32 nX1 = rScreenPosition2D.X;
+sal_Int32 nY1 = rScreenPosition2D.Y;
+   

[Libreoffice-commits] core.git: chart2/qa chart2/source oox/source

2019-11-21 Thread Balazs Varga (via logerrit)
 chart2/qa/extras/chart2export.cxx  |   14 
++
 chart2/qa/extras/data/ods/tdf123774.ods|binary
 chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx |1 
 chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx |1 
 oox/source/export/chartexport.cxx  |   14 
--
 5 files changed, 28 insertions(+), 2 deletions(-)

New commits:
commit a59eb39c6ec01ae2a9d8ddbb61a9c27f527c9caa
Author: Balazs Varga 
AuthorDate: Thu Nov 14 15:02:35 2019 +0100
Commit: László Németh 
CommitDate: Thu Nov 21 17:31:17 2019 +0100

tdf#123774 OOXML chart export: keep digits of percentages of data points

by exporting PercentageNumberFormat, checking the "Label" format
directly and taking the respective number format based on that.

Note: also fix the "LinkNumberFormatToSource" property. If we create a
pie chart with data labels and set the "Show value as number" or
"Show value as percentage" and check on/off "Source format", this move
is not set the property in the XPropertySet.

Because of this, it fixes also the export of correct value of
"link-data-style-to-source" property into ODS files.
But this patch doesn't fix the export of old ODS files to OOXML,
because they contain wrong (always true) "link-data-style-to-source"
value.

Change-Id: I4098a245dec5bf35cde20c9ccb79aca726230118
Reviewed-on: https://gerrit.libreoffice.org/82703
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index 694e814250bd..8d42c8ac93ac 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -99,6 +99,7 @@ public:
 void testMarkerColorXLSX();
 void testRoundedCornersXLSX();
 void testAxisNumberFormatXLSX();
+void testDataPointLabelNumberFormatXLSX();
 void testDataLabelDefaultValuesXLSX();
 void testTitleOverlayXLSX();
 void testInvertIfNegativeXLSX();
@@ -210,6 +211,7 @@ public:
 CPPUNIT_TEST(testMarkerColorXLSX);
 CPPUNIT_TEST(testRoundedCornersXLSX);
 CPPUNIT_TEST(testAxisNumberFormatXLSX);
+CPPUNIT_TEST(testDataPointLabelNumberFormatXLSX);
 CPPUNIT_TEST(testDataLabelDefaultValuesXLSX);
 CPPUNIT_TEST(testTitleOverlayXLSX);
 CPPUNIT_TEST(testInvertIfNegativeXLSX);
@@ -1584,6 +1586,18 @@ void Chart2ExportTest::testAxisNumberFormatXLSX()
 assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:numFmt", "sourceLinked", "1");
 }
 
+void Chart2ExportTest::testDataPointLabelNumberFormatXLSX()
+{
+load("/chart2/qa/extras/data/ods/", "tdf123774.ods");
+xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+CPPUNIT_ASSERT(pXmlDoc);
+assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt", 
"formatCode", "[$-40E]0.00%");
+assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt", 
"sourceLinked", "0");
+
+assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:numFmt", 
"formatCode", "[$-40E]0.00%");
+assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:numFmt", 
"sourceLinked", "0");
+}
+
 void Chart2ExportTest::testDataLabelDefaultValuesXLSX()
 {
 load("/chart2/qa/extras/data/xlsx/", "data_label.xlsx");
diff --git a/chart2/qa/extras/data/ods/tdf123774.ods 
b/chart2/qa/extras/data/ods/tdf123774.ods
new file mode 100644
index ..5c422b58c357
Binary files /dev/null and b/chart2/qa/extras/data/ods/tdf123774.ods differ
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index 39babb82a09c..0d592f4733a8 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -153,6 +153,7 @@ bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 
nWhichId, const SfxIte
 uno::Any aNewValue;
 bool bUseSourceFormat = static_cast< const SfxBoolItem & >(
 rItemSet.Get( nWhichId )).GetValue();
+xPropertySet->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, 
uno::Any(bUseSourceFormat));
 if( !bUseSourceFormat )
 {
 SfxItemState aState = rItemSet.GetItemState( nFormatWhich );
diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
index 86f5891bbad9..81c7c8fcd9a0 100644
--- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
@@ -150,6 +150,7 @@ bool useSourceFormatFromItemToPropertySet(
 uno::Any aNewValue;
 bool bUseSourceFormat = 

[Libreoffice-commits] core.git: chart2/qa chart2/source oox/source

2019-10-07 Thread Balazs Varga (via logerrit)
 chart2/qa/extras/chart2export.cxx  |   11 +++
 chart2/qa/extras/data/ods/test_CrossBetween.ods|binary
 chart2/source/model/template/ChartTypeTemplate.cxx |7 +--
 chart2/source/tools/AxisHelper.cxx |2 +-
 chart2/source/view/main/ChartView.cxx  |   17 +
 oox/source/drawingml/chart/axisconverter.cxx   |2 --
 oox/source/export/chartexport.cxx  |2 +-
 7 files changed, 23 insertions(+), 18 deletions(-)

New commits:
commit 111c260ab2883b7906f1a66e222dbf4dc3c58c4f
Author: Balazs Varga 
AuthorDate: Thu Oct 3 20:31:44 2019 +0200
Commit: László Németh 
CommitDate: Mon Oct 7 12:36:28 2019 +0200

tdf#12 OOXML chart export: fix "CrossBetween" for not imported charts

Newly created or ODF charts were still exported incorrectly, because
ShiftedCategoryPosition was stored in the view code. Now it is removed
to the model using ChartTypeTemplate::adaptScales.

See also commit 6027ec08fd5df2e09e34ff61b3777ad2cc8304b3 'tdf#12
OOXML chart export: fix X axis position setting "CrossBetween"'

Change-Id: I7cd69e311833bf9f24f3a600ee7c6312285a7738
Reviewed-on: https://gerrit.libreoffice.org/80160
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index 2589428831bc..8a0705f7d140 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -121,6 +121,7 @@ public:
 void testCombinedChartSecondaryAxisXLSX();
 void testCombinedChartSecondaryAxisODS();
 void testCrossBetweenXLSX();
+void testCrossBetweenODS();
 void testAxisTitleRotationXLSX();
 void testAxisCrossBetweenXSLX();
 void testPieChartDataPointExplosionXLSX();
@@ -225,6 +226,7 @@ public:
 CPPUNIT_TEST(testCombinedChartSecondaryAxisXLSX);
 CPPUNIT_TEST(testCombinedChartSecondaryAxisODS);
 CPPUNIT_TEST(testCrossBetweenXLSX);
+CPPUNIT_TEST(testCrossBetweenODS);
 CPPUNIT_TEST(testAxisTitleRotationXLSX);
 CPPUNIT_TEST(testAxisCrossBetweenXSLX);
 CPPUNIT_TEST(testPieChartDataPointExplosionXLSX);
@@ -1912,6 +1914,15 @@ void Chart2ExportTest::testCrossBetweenXLSX()
 assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between");
 }
 
+void Chart2ExportTest::testCrossBetweenODS()
+{
+// Original file was created with LibreOffice
+load("/chart2/qa/extras/data/ods/", "test_CrossBetween.ods");
+xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+CPPUNIT_ASSERT(pXmlDoc);
+assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between");
+}
+
 void Chart2ExportTest::testAxisTitleRotationXLSX()
 {
 load("/chart2/qa/extras/data/xlsx/", "axis_title_rotation.xlsx");
diff --git a/chart2/qa/extras/data/ods/test_CrossBetween.ods 
b/chart2/qa/extras/data/ods/test_CrossBetween.ods
new file mode 100644
index ..e59546b3d0cd
Binary files /dev/null and b/chart2/qa/extras/data/ods/test_CrossBetween.ods 
differ
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx 
b/chart2/source/model/template/ChartTypeTemplate.cxx
index c3710e45d7d4..c18851796ada 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -623,8 +623,11 @@ void ChartTypeTemplate::adaptScales(
 aData.Categories = xCategories;
 if(bSupportsCategories)
 {
-
-Reference< XChartType > xChartType( 
getChartTypeForNewSeries(Sequence< Reference< XChartType > >() ));
+Reference< XChartType > 
xChartType(getChartTypeForNewSeries(Sequence< Reference< XChartType > >()));
+if( aData.AxisType == AxisType::CATEGORY )
+{
+aData.ShiftedCategoryPosition = 
::chart::ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault(xChartType);
+}
 bool bSupportsDates = 
::chart::ChartTypeHelper::isSupportingDateAxis( xChartType, nDimensionX );
 if( aData.AxisType != AxisType::CATEGORY && ( 
aData.AxisType != AxisType::DATE || !bSupportsDates) )
 {
diff --git a/chart2/source/tools/AxisHelper.cxx 
b/chart2/source/tools/AxisHelper.cxx
index 25d481bff352..6ec3d44f48d4 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -73,7 +73,7 @@ ScaleData AxisHelper::createDefaultScale()
 ScaleData aScaleData;
 aScaleData.AxisType = chart2::AxisType::REALNUMBER;
 aScaleData.AutoDateAxis = true;
-aScaleData.ShiftedCategoryPosition = false;//this is adapted in the view 
code currently
+aScaleData.ShiftedCategoryPosition = false;
 Sequence< 

[Libreoffice-commits] core.git: chart2/qa chart2/source oox/source

2019-09-23 Thread Balazs Varga (via logerrit)
 chart2/qa/extras/chart2import.cxx|   29 +++
 chart2/qa/extras/data/pptx/tdf127393.pptx|binary
 chart2/source/view/main/ChartView.cxx|   12 ++-
 oox/source/drawingml/chart/axiscontext.cxx   |2 -
 oox/source/drawingml/chart/axisconverter.cxx |1 
 oox/source/drawingml/chart/axismodel.cxx |2 -
 6 files changed, 39 insertions(+), 7 deletions(-)

New commits:
commit 830e539547c463b932ce643517f880789185032d
Author: Balazs Varga 
AuthorDate: Thu Sep 19 15:15:58 2019 +0200
Commit: László Németh 
CommitDate: Mon Sep 23 15:53:14 2019 +0200

tdf#127393 OOXML chart import: fix X axis position setting "CrossBetween"

Set ShiftedCategoryPosition according to OOXML value CrossBetween.

Change-Id: I6445c94507de83f84b08fd3380cbbf03886b5aa3
Reviewed-on: https://gerrit.libreoffice.org/79142
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/chart2/qa/extras/chart2import.cxx 
b/chart2/qa/extras/chart2import.cxx
index 53f4a2d30e19..c0850820acc3 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -129,6 +129,7 @@ public:
 
 void testTdf114179();
 void testTdf124243();
+void testTdf127393();
 void testDeletedDataLabel();
 void testDataPointInheritedColorDOCX();
 void testExternalStrRefsXLSX();
@@ -218,6 +219,7 @@ public:
 
 CPPUNIT_TEST(testTdf114179);
 CPPUNIT_TEST(testTdf124243);
+CPPUNIT_TEST(testTdf127393);
 CPPUNIT_TEST(testDeletedDataLabel);
 CPPUNIT_TEST(testDataPointInheritedColorDOCX);
 CPPUNIT_TEST(testExternalStrRefsXLSX);
@@ -1929,6 +1931,33 @@ void Chart2ImportTest::testTdf124243()
 CPPUNIT_ASSERT(!bShow);
 }
 
+void Chart2ImportTest::testTdf127393()
+{
+load("/chart2/qa/extras/data/pptx/", "tdf127393.pptx");
+
+// 1st chart
+Reference xChartDoc(getChartDocFromDrawImpress(0, 
0), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xChartDoc.is());
+
+Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
+CPPUNIT_ASSERT(xAxis.is());
+
+chart2::ScaleData aScaleData1 = xAxis->getScaleData();
+CPPUNIT_ASSERT(aScaleData1.Categories.is());
+CPPUNIT_ASSERT(aScaleData1.ShiftedCategoryPosition);
+
+// 2nd chart
+xChartDoc.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xChartDoc.is());
+
+xAxis.set(getAxisFromDoc(xChartDoc, 0, 0, 0));
+CPPUNIT_ASSERT(xAxis.is());
+
+chart2::ScaleData aScaleData2 = xAxis->getScaleData();
+CPPUNIT_ASSERT(aScaleData2.Categories.is());
+CPPUNIT_ASSERT(!aScaleData2.ShiftedCategoryPosition);
+}
+
 namespace {
 
 void checkDataLabelProperties(const Reference& 
xDataSeries, sal_Int32 nDataPointIndex, bool bValueVisible)
diff --git a/chart2/qa/extras/data/pptx/tdf127393.pptx 
b/chart2/qa/extras/data/pptx/tdf127393.pptx
new file mode 100644
index ..7c4047817a2f
Binary files /dev/null and b/chart2/qa/extras/data/pptx/tdf127393.pptx differ
diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index 200b4b4e9823..238069cdf2e1 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -325,7 +325,7 @@ public:
 void AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel& rModel );
 
 bool isCategoryPositionShifted(
-const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ) 
const;
+const chart2::ScaleData& rSourceScale, bool bHasComplexCategories, 
bool bShiftedCategoryPosition) const;
 
 private:
 /** A vector of series plotters.
@@ -631,12 +631,12 @@ void 
SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
 }
 
 bool SeriesPlotterContainer::isCategoryPositionShifted(
-const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ) const
+const chart2::ScaleData& rSourceScale, bool bHasComplexCategories, bool 
bShiftedCategoryPosition) const
 {
-if (rSourceScale.AxisType == AxisType::CATEGORY && 
m_bChartTypeUsesShiftedCategoryPositionPerDefault)
+if (rSourceScale.AxisType == AxisType::CATEGORY && 
(m_bChartTypeUsesShiftedCategoryPositionPerDefault || bShiftedCategoryPosition))
 return true;
 
-if (rSourceScale.AxisType==AxisType::CATEGORY && bHasComplexCategories)
+if (rSourceScale.AxisType == AxisType::CATEGORY && bHasComplexCategories)
 return true;
 
 if (rSourceScale.AxisType == AxisType::DATE)
@@ -683,7 +683,9 @@ void SeriesPlotterContainer::initAxisUsageList(const Date& 
rNullDate)
 AxisHelper::checkDateAxis( aSourceScale, pCatProvider, 
bDateAxisAllowed );
 
 bool bHasComplexCat = pCatProvider && 
pCatProvider->hasComplexCategories();
-aSourceScale.ShiftedCategoryPosition = 
isCategoryPositionShifted(aSourceScale, bHasComplexCat);
+// Come from CrossBetween OOXML tag
+bool bShiftedCategoryPosition =