[Libreoffice-commits] core.git: chart2/qa chart2/source oox/source
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Thu Feb 20 10:19:13 UTC 2020
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 <balazs.varga991 at gmail.com>
AuthorDate: Wed Feb 12 13:47:50 2020 +0100
Commit: László Németh <nemeth at numbertext.org>
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 <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
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 000000000000..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 <memory>
#include <VSeriesPlotter.hxx>
+#include <BaseGFXHelper.hxx>
#include <VLineProperties.hxx>
#include <ShapeFactory.hxx>
@@ -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;
+ sal_Int32 nX2 = nX1;
+ sal_Int32 nY2 = nY1;
+ ::basegfx::B2IRectangle aRect(BaseGFXHelper::makeRectangle(aRelPos, xTextShape->getSize()));
+ if (nX1 < aRelPos.X)
+ nX2 = aRelPos.X;
+ else if (nX1 > aRect.getMaxX())
+ nX2 = aRect.getMaxX();
+
+ if (nY1 < aRect.getMinY())
+ nY2 = aRect.getMinY();
+ else if (nY1 > aRect.getMaxY())
+ nY2 = aRect.getMaxY();
+
+ //when the line is very short compared to the page size don't create one
+ ::basegfx::B2DVector aLength(nX1 - nX2, nY1 - nY2);
+ double fPageDiagonaleLength = sqrt(double(m_aPageReferenceSize.Width)*double(m_aPageReferenceSize.Width) + double(m_aPageReferenceSize.Height)*double(m_aPageReferenceSize.Height));
+ if ((aLength.getLength() / fPageDiagonaleLength) >= 0.01)
+ {
+ drawing::PointSequenceSequence aPoints(1);
+ aPoints[0].realloc(2);
+ aPoints[0][0].X = nX1;
+ aPoints[0][0].Y = nY1;
+ aPoints[0][1].X = nX2;
+ aPoints[0][1].Y = nY2;
+
+ m_pShapeFactory->createLine2D(xTarget, aPoints, new VLineProperties);
+ }
+ }
+ }
}
// in case legend symbol has to be displayed, text shape position is
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 3957f51cca1f..c6e9173ce53f 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -151,6 +151,8 @@ struct NamespaceIds: public rtl::StaticWithInit<
NMSP_p15},
{"http://schemas.microsoft.com/office/spreadsheetml/2011/1/ac",
NMSP_x12ac},
+ {"http://schemas.microsoft.com/office/drawing/2012/chart",
+ NMSP_c15},
};
}
};
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index c190fa6a1b6d..61ee198d006f 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -340,6 +340,9 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa
// Import baseline border properties for these data labels.
importBorderProperties(aPropSet, *mrModel.mxShapeProp, getFilter().getGraphicHelper());
}
+ // import leaderline of data labels
+ if( !mrModel.mbShowLeaderLines )
+ aPropSet.setProperty( PROP_ShowLeaderLines, false );
// data point label settings
for (auto const& pointLabel : mrModel.maPointLabels)
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index ae33fdcdd222..fbeb2a892672 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -3464,6 +3464,15 @@ void ChartExport::exportDataLabels(
pFS->singleElement(FSNS(XML_c, XML_showLeaderLines), XML_val, "0");
+ // Export leader line
+ if( eChartType != chart::TYPEID_PIE )
+ {
+ pFS->startElement(FSNS(XML_c, XML_extLst));
+ pFS->startElement(FSNS(XML_c, XML_ext), XML_uri, "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}", FSNS(XML_xmlns, XML_c15), GetFB()->getNamespaceURL(OOX_NS(c15)).toUtf8());
+ pFS->singleElement(FSNS(XML_c15, XML_showLeaderLines), XML_val, "1");
+ pFS->endElement(FSNS(XML_c, XML_ext));
+ pFS->endElement(FSNS(XML_c, XML_extLst));
+ }
pFS->endElement(FSNS(XML_c, XML_dLbls));
}
diff --git a/oox/source/token/namespaces-strict.txt b/oox/source/token/namespaces-strict.txt
index d6990e5bdf91..9a62a301a513 100644
--- a/oox/source/token/namespaces-strict.txt
+++ b/oox/source/token/namespaces-strict.txt
@@ -86,6 +86,7 @@ p14 http://schemas.microsoft.com/office/powerpoint/2010/main
p15 http://schemas.microsoft.com/office/powerpoint/2012/main
x12ac http://schemas.microsoft.com/office/spreadsheetml/2011/1/ac
+c15 http://schemas.microsoft.com/office/drawing/2012/chart
# extlst namespaces
diff --git a/oox/source/token/namespaces.hxx.tail b/oox/source/token/namespaces.hxx.tail
index 991527f1d5d6..fdea5b96f1b4 100644
--- a/oox/source/token/namespaces.hxx.tail
+++ b/oox/source/token/namespaces.hxx.tail
@@ -43,6 +43,7 @@ inline sal_Int32 getNamespace( sal_Int32 nToken ) { return nToken & NMSP_MASK; }
#define PPT_TOKEN( token ) OOX_TOKEN( ppt, token )
#define P14_TOKEN( token ) OOX_TOKEN( p14, token )
#define P15_TOKEN( token ) OOX_TOKEN( p15, token )
+#define C15_TOKEN( token ) OOX_TOKEN( c15, token )
#define PR_TOKEN( token ) OOX_TOKEN( packageRel, token )
#define R_TOKEN( token ) OOX_TOKEN( officeRel, token )
#define VML_TOKEN( token ) OOX_TOKEN( vml, token )
diff --git a/oox/source/token/namespaces.txt b/oox/source/token/namespaces.txt
index 604541129469..82bec7274c32 100644
--- a/oox/source/token/namespaces.txt
+++ b/oox/source/token/namespaces.txt
@@ -86,6 +86,7 @@ p14 http://schemas.microsoft.com/office/powerpoint/2010/main
p15 http://schemas.microsoft.com/office/powerpoint/2012/main
x12ac http://schemas.microsoft.com/office/spreadsheetml/2011/1/ac
+c15 http://schemas.microsoft.com/office/drawing/2012/chart
# extlst namespaces
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index de9cd886643a..4fc0c5b47c57 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -464,6 +464,7 @@ ShowFormulas
ShowGrid
ShowHighLow
ShowInputMessage
+ShowLeaderLines
ShowLegendEntry
ShowList
ShowNegativeError
diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt
index 3929d8c93808..27396f5b8dfa 100644
--- a/oox/source/token/tokens.txt
+++ b/oox/source/token/tokens.txt
@@ -1022,6 +1022,7 @@ by
byPosition
byte
c
+c15
cBhvr
cGp
cGpRule
More information about the Libreoffice-commits
mailing list