[Libreoffice-commits] core.git: include/oox oox/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Wed Nov 30 22:34:22 UTC 2016
include/oox/export/chartexport.hxx | 2 +
oox/source/export/chartexport.cxx | 74 +++++++++++++++++++++++++++----------
2 files changed, 57 insertions(+), 19 deletions(-)
New commits:
commit ff22a22286bb4c17c3affc89d31a6c10447481c5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 18 11:44:03 2016 +0100
better varyColors export for charts, related tdf#103943
Change-Id: I4280e708c854c687b6281c56d5bccdb514afd81e
Reviewed-on: https://gerrit.libreoffice.org/31252
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx
index 7f2cb59..8efc626 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -159,6 +159,8 @@ private:
void exportAllSeries(const css::uno::Reference<css::chart2::XChartType>& xChartType, bool& rPrimaryAxes);
void exportSeries(const css::uno::Reference< css::chart2::XChartType >& xChartType,
css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes);
+
+ void exportVaryColors(const css::uno::Reference<css::chart2::XChartType>& xChartType);
void exportCandleStickSeries(
const css::uno::Sequence<
css::uno::Reference<
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index ccfc244..8bfc596 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -1541,10 +1541,7 @@ void ChartExport::exportBarChart( const Reference< chart2::XChartType >& xChartT
exportGrouping( true );
- const char* varyColors = "0";
- pFS->singleElement( FSNS( XML_c, XML_varyColors ),
- XML_val, varyColors,
- FSEND );
+ exportVaryColors(xChartType);
bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes);
@@ -1617,10 +1614,7 @@ void ChartExport::exportBubbleChart( const Reference< chart2::XChartType >& xCha
pFS->startElement( FSNS( XML_c, XML_bubbleChart ),
FSEND );
- const char* varyColors = "0";
- pFS->singleElement( FSNS( XML_c, XML_varyColors ),
- XML_val, varyColors,
- FSEND );
+ exportVaryColors(xChartType);
bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes);
@@ -1640,6 +1634,8 @@ void ChartExport::exportDoughnutChart( const Reference< chart2::XChartType >& xC
pFS->startElement( FSNS( XML_c, XML_doughnutChart ),
FSEND );
+ exportVaryColors(xChartType);
+
bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes);
// firstSliceAng
@@ -1712,9 +1708,9 @@ void ChartExport::exportLineChart( const Reference< chart2::XChartType >& xChart
pFS->startElement( FSNS( XML_c, nTypeId ),
FSEND );
+ exportVaryColors(xChartType);
+
exportGrouping( );
- pFS->singleElement(FSNS(XML_c, XML_varyColors),
- XML_val, "0", FSEND);
// TODO: show marker symbol in series?
bool bPrimaryAxes = true;
exportSeries(xChartType, *itr, bPrimaryAxes);
@@ -1755,11 +1751,8 @@ void ChartExport::exportPieChart( const Reference< chart2::XChartType >& xChartT
nTypeId = XML_pie3DChart;
pFS->startElement( FSNS( XML_c, nTypeId ),
FSEND );
- // TODO: varyColors
- const char* varyColors = "1";
- pFS->singleElement( FSNS( XML_c, XML_varyColors ),
- XML_val, varyColors,
- FSEND );
+
+ exportVaryColors(xChartType);
bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes);
@@ -1789,6 +1782,8 @@ void ChartExport::exportRadarChart( const Reference< chart2::XChartType >& xChar
pFS->singleElement( FSNS( XML_c, XML_radarStyle ),
XML_val, radarStyle,
FSEND );
+
+ exportVaryColors(xChartType);
bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes);
exportAxesId(bPrimaryAxes);
@@ -1825,10 +1820,7 @@ void ChartExport::exportScatterChart( const Reference< chart2::XChartType >& xCh
XML_val, scatterStyle,
FSEND );
- pFS->singleElement( FSNS( XML_c, XML_varyColors ),
- XML_val, "0",
- FSEND );
-
+ exportVaryColors(xChartType);
// FIXME: should export xVal and yVal
bool bPrimaryAxes = true;
exportSeries(xChartType, *itr, bPrimaryAxes);
@@ -1942,6 +1934,7 @@ void ChartExport::exportSurfaceChart( const Reference< chart2::XChartType >& xCh
nTypeId = XML_surface3DChart;
pFS->startElement( FSNS( XML_c, nTypeId ),
FSEND );
+ exportVaryColors(xChartType);
bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes);
exportAxesId(bPrimaryAxes);
@@ -1960,6 +1953,48 @@ void ChartExport::exportAllSeries(const Reference<chart2::XChartType>& xChartTyp
exportSeries(xChartType, aSeriesSeq, rPrimaryAxes);
}
+namespace {
+
+Reference<chart2::XDataSeries> getPrimaryDataSeries(const Reference<chart2::XChartType>& xChartType)
+{
+ Reference< chart2::XDataSeriesContainer > xDSCnt(xChartType, uno::UNO_QUERY_THROW);
+
+ // export dataseries for current chart-type
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq(xDSCnt->getDataSeries());
+ for (sal_Int32 nSeriesIdx=0; nSeriesIdx < aSeriesSeq.getLength(); ++nSeriesIdx)
+ {
+ Reference<chart2::XDataSeries> xSource(aSeriesSeq[nSeriesIdx], uno::UNO_QUERY);
+ if (xSource.is())
+ return xSource;
+ }
+
+ return Reference<chart2::XDataSeries>();
+}
+
+}
+
+void ChartExport::exportVaryColors(const Reference<chart2::XChartType>& xChartType)
+{
+ FSHelperPtr pFS = GetFS();
+ try
+ {
+ Reference<chart2::XDataSeries> xDataSeries = getPrimaryDataSeries(xChartType);
+ Reference<beans::XPropertySet> xDataSeriesProps(xDataSeries, uno::UNO_QUERY_THROW);
+ Any aAnyVaryColors = xDataSeriesProps->getPropertyValue("VaryColorsByPoint");
+ bool bVaryColors = false;
+ aAnyVaryColors >>= bVaryColors;
+ pFS->singleElement(FSNS(XML_c, XML_varyColors),
+ XML_val, bVaryColors ? "1": "0",
+ FSEND);
+ }
+ catch (...)
+ {
+ pFS->singleElement(FSNS(XML_c, XML_varyColors),
+ XML_val, "0",
+ FSEND);
+ }
+}
+
void ChartExport::exportSeries( const Reference<chart2::XChartType>& xChartType,
Sequence<Reference<chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes )
{
@@ -2009,6 +2044,7 @@ void ChartExport::exportSeries( const Reference<chart2::XChartType>& xChartType,
// xLabelSeq contain those. Otherwise both are empty
{
FSHelperPtr pFS = GetFS();
+
pFS->startElement( FSNS( XML_c, XML_ser ),
FSEND );
More information about the Libreoffice-commits
mailing list