Kaydet (Commit) ff22a222 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

better varyColors export for charts, related tdf#103943

Change-Id: I4280e708c854c687b6281c56d5bccdb514afd81e
Reviewed-on: https://gerrit.libreoffice.org/31252Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst f45af7c8
...@@ -159,6 +159,8 @@ private: ...@@ -159,6 +159,8 @@ private:
void exportAllSeries(const css::uno::Reference<css::chart2::XChartType>& xChartType, bool& rPrimaryAxes); void exportAllSeries(const css::uno::Reference<css::chart2::XChartType>& xChartType, bool& rPrimaryAxes);
void exportSeries(const css::uno::Reference< css::chart2::XChartType >& xChartType, void exportSeries(const css::uno::Reference< css::chart2::XChartType >& xChartType,
css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes); css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes);
void exportVaryColors(const css::uno::Reference<css::chart2::XChartType>& xChartType);
void exportCandleStickSeries( void exportCandleStickSeries(
const css::uno::Sequence< const css::uno::Sequence<
css::uno::Reference< css::uno::Reference<
......
...@@ -1541,10 +1541,7 @@ void ChartExport::exportBarChart( const Reference< chart2::XChartType >& xChartT ...@@ -1541,10 +1541,7 @@ void ChartExport::exportBarChart( const Reference< chart2::XChartType >& xChartT
exportGrouping( true ); exportGrouping( true );
const char* varyColors = "0"; exportVaryColors(xChartType);
pFS->singleElement( FSNS( XML_c, XML_varyColors ),
XML_val, varyColors,
FSEND );
bool bPrimaryAxes = true; bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes); exportAllSeries(xChartType, bPrimaryAxes);
...@@ -1617,10 +1614,7 @@ void ChartExport::exportBubbleChart( const Reference< chart2::XChartType >& xCha ...@@ -1617,10 +1614,7 @@ void ChartExport::exportBubbleChart( const Reference< chart2::XChartType >& xCha
pFS->startElement( FSNS( XML_c, XML_bubbleChart ), pFS->startElement( FSNS( XML_c, XML_bubbleChart ),
FSEND ); FSEND );
const char* varyColors = "0"; exportVaryColors(xChartType);
pFS->singleElement( FSNS( XML_c, XML_varyColors ),
XML_val, varyColors,
FSEND );
bool bPrimaryAxes = true; bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes); exportAllSeries(xChartType, bPrimaryAxes);
...@@ -1640,6 +1634,8 @@ void ChartExport::exportDoughnutChart( const Reference< chart2::XChartType >& xC ...@@ -1640,6 +1634,8 @@ void ChartExport::exportDoughnutChart( const Reference< chart2::XChartType >& xC
pFS->startElement( FSNS( XML_c, XML_doughnutChart ), pFS->startElement( FSNS( XML_c, XML_doughnutChart ),
FSEND ); FSEND );
exportVaryColors(xChartType);
bool bPrimaryAxes = true; bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes); exportAllSeries(xChartType, bPrimaryAxes);
// firstSliceAng // firstSliceAng
...@@ -1712,9 +1708,9 @@ void ChartExport::exportLineChart( const Reference< chart2::XChartType >& xChart ...@@ -1712,9 +1708,9 @@ void ChartExport::exportLineChart( const Reference< chart2::XChartType >& xChart
pFS->startElement( FSNS( XML_c, nTypeId ), pFS->startElement( FSNS( XML_c, nTypeId ),
FSEND ); FSEND );
exportVaryColors(xChartType);
exportGrouping( ); exportGrouping( );
pFS->singleElement(FSNS(XML_c, XML_varyColors),
XML_val, "0", FSEND);
// TODO: show marker symbol in series? // TODO: show marker symbol in series?
bool bPrimaryAxes = true; bool bPrimaryAxes = true;
exportSeries(xChartType, *itr, bPrimaryAxes); exportSeries(xChartType, *itr, bPrimaryAxes);
...@@ -1755,11 +1751,8 @@ void ChartExport::exportPieChart( const Reference< chart2::XChartType >& xChartT ...@@ -1755,11 +1751,8 @@ void ChartExport::exportPieChart( const Reference< chart2::XChartType >& xChartT
nTypeId = XML_pie3DChart; nTypeId = XML_pie3DChart;
pFS->startElement( FSNS( XML_c, nTypeId ), pFS->startElement( FSNS( XML_c, nTypeId ),
FSEND ); FSEND );
// TODO: varyColors
const char* varyColors = "1"; exportVaryColors(xChartType);
pFS->singleElement( FSNS( XML_c, XML_varyColors ),
XML_val, varyColors,
FSEND );
bool bPrimaryAxes = true; bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes); exportAllSeries(xChartType, bPrimaryAxes);
...@@ -1789,6 +1782,8 @@ void ChartExport::exportRadarChart( const Reference< chart2::XChartType >& xChar ...@@ -1789,6 +1782,8 @@ void ChartExport::exportRadarChart( const Reference< chart2::XChartType >& xChar
pFS->singleElement( FSNS( XML_c, XML_radarStyle ), pFS->singleElement( FSNS( XML_c, XML_radarStyle ),
XML_val, radarStyle, XML_val, radarStyle,
FSEND ); FSEND );
exportVaryColors(xChartType);
bool bPrimaryAxes = true; bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes); exportAllSeries(xChartType, bPrimaryAxes);
exportAxesId(bPrimaryAxes); exportAxesId(bPrimaryAxes);
...@@ -1825,10 +1820,7 @@ void ChartExport::exportScatterChart( const Reference< chart2::XChartType >& xCh ...@@ -1825,10 +1820,7 @@ void ChartExport::exportScatterChart( const Reference< chart2::XChartType >& xCh
XML_val, scatterStyle, XML_val, scatterStyle,
FSEND ); FSEND );
pFS->singleElement( FSNS( XML_c, XML_varyColors ), exportVaryColors(xChartType);
XML_val, "0",
FSEND );
// FIXME: should export xVal and yVal // FIXME: should export xVal and yVal
bool bPrimaryAxes = true; bool bPrimaryAxes = true;
exportSeries(xChartType, *itr, bPrimaryAxes); exportSeries(xChartType, *itr, bPrimaryAxes);
...@@ -1942,6 +1934,7 @@ void ChartExport::exportSurfaceChart( const Reference< chart2::XChartType >& xCh ...@@ -1942,6 +1934,7 @@ void ChartExport::exportSurfaceChart( const Reference< chart2::XChartType >& xCh
nTypeId = XML_surface3DChart; nTypeId = XML_surface3DChart;
pFS->startElement( FSNS( XML_c, nTypeId ), pFS->startElement( FSNS( XML_c, nTypeId ),
FSEND ); FSEND );
exportVaryColors(xChartType);
bool bPrimaryAxes = true; bool bPrimaryAxes = true;
exportAllSeries(xChartType, bPrimaryAxes); exportAllSeries(xChartType, bPrimaryAxes);
exportAxesId(bPrimaryAxes); exportAxesId(bPrimaryAxes);
...@@ -1960,6 +1953,48 @@ void ChartExport::exportAllSeries(const Reference<chart2::XChartType>& xChartTyp ...@@ -1960,6 +1953,48 @@ void ChartExport::exportAllSeries(const Reference<chart2::XChartType>& xChartTyp
exportSeries(xChartType, aSeriesSeq, rPrimaryAxes); 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, void ChartExport::exportSeries( const Reference<chart2::XChartType>& xChartType,
Sequence<Reference<chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes ) Sequence<Reference<chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes )
{ {
...@@ -2009,6 +2044,7 @@ void ChartExport::exportSeries( const Reference<chart2::XChartType>& xChartType, ...@@ -2009,6 +2044,7 @@ void ChartExport::exportSeries( const Reference<chart2::XChartType>& xChartType,
// xLabelSeq contain those. Otherwise both are empty // xLabelSeq contain those. Otherwise both are empty
{ {
FSHelperPtr pFS = GetFS(); FSHelperPtr pFS = GetFS();
pFS->startElement( FSNS( XML_c, XML_ser ), pFS->startElement( FSNS( XML_c, XML_ser ),
FSEND ); FSEND );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment