[Libreoffice-commits] core.git: 4 commits - chart2/qa chart2/source include/oox oox/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Sun May 10 20:20:38 PDT 2015
chart2/qa/extras/chart2export.cxx | 14 +
chart2/qa/extras/data/ods/multiple_axis.ods |binary
chart2/source/controller/dialogs/tp_SeriesToAxis.hxx | 2
include/oox/export/chartexport.hxx | 4
oox/source/export/chartexport.cxx | 220 ++++++++++++-------
5 files changed, 159 insertions(+), 81 deletions(-)
New commits:
commit 285d5c52f8dc07f15c62ca9698209f6132b91467
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon May 11 05:10:16 2015 +0200
add test for tdf#84347
Change-Id: I437801a752e2ae2fa762f46f566b761fdc02acb8
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 0dbc470..7e4491c 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -97,6 +97,7 @@ public:
void testTitleCharacterPropertiesXLSX();
void testPlotVisOnlyXLSX();
void testBarChartVaryColorsXLSX();
+ void testMultipleAxisXLSX();
CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(testErrorBarXLSX);
@@ -158,6 +159,7 @@ public:
CPPUNIT_TEST(testTitleCharacterPropertiesXLSX);
CPPUNIT_TEST(testPlotVisOnlyXLSX);
CPPUNIT_TEST(testBarChartVaryColorsXLSX);
+ CPPUNIT_TEST(testMultipleAxisXLSX);
CPPUNIT_TEST_SUITE_END();
protected:
@@ -1445,6 +1447,18 @@ void Chart2ExportTest::testBarChartVaryColorsXLSX()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", "0");
}
+void Chart2ExportTest::testMultipleAxisXLSX()
+{
+ load("/chart2/qa/extras/data/ods/", "multiple_axis.ods");
+ xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart", 2);
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart[1]/c:ser", 1);
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart[2]/c:ser", 1);
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx", 4);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/ods/multiple_axis.ods b/chart2/qa/extras/data/ods/multiple_axis.ods
new file mode 100644
index 0000000..7e2a505
Binary files /dev/null and b/chart2/qa/extras/data/ods/multiple_axis.ods differ
commit ffaa8e48b5a98bb7dd1891da09bf796467cf849f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon May 11 04:32:16 2015 +0200
fix regression from 1c4025babd7037a3292aa530c7d45ab8d6ef6dcb
Change-Id: I28543128b75315be1eda1a82f6e856778c38a33e
diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx b/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx
index 1d0b2e3..a6e7eda 100644
--- a/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx
+++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx
@@ -54,7 +54,7 @@ private: //member
VclPtr<CheckBox> m_pCBConnect;
VclPtr<CheckBox> m_pCBAxisSideBySide;
- VclPtr<VclGrid> m_pGrpPlotOptions;
+ VclPtr<VclFrame> m_pGrpPlotOptions;
VclPtr<VclGrid> m_pGridPlotOptions;
VclPtr<RadioButton> m_pRB_DontPaint;
VclPtr<RadioButton> m_pRB_AssumeZero;
commit cffa77304daf2379a056bb2d86fe041e7c98bc52
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon May 11 02:53:05 2015 +0200
only export series for same axis into same chart type element, tdf#84347
Change-Id: I2b8b962054b0e1ca98db3929c6692e7c354e6a93
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 36939af..c7d5d64 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -1662,39 +1662,90 @@ void ChartExport::exportDoughnutChart( Reference< chart2::XChartType > xChartTyp
pFS->endElement( FSNS( XML_c, XML_doughnutChart ) );
}
-void ChartExport::exportLineChart( Reference< chart2::XChartType > xChartType )
+namespace {
+
+std::vector<Sequence<Reference<chart2::XDataSeries> > > splitDataSeriesByAxis(Reference< chart2::XChartType > xChartType)
{
- FSHelperPtr pFS = GetFS();
- sal_Int32 nTypeId = XML_lineChart;
- if( mbIs3DChart )
- nTypeId = XML_line3DChart;
- pFS->startElement( FSNS( XML_c, nTypeId ),
- FSEND );
+ std::vector<Sequence<Reference<chart2::XDataSeries> > > aSplitSeries;
+ std::map<sal_Int32, size_t> aMapAxisToIndex;
- exportGrouping( );
- // TODO: show marker symbol in series?
- sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportAllSeries( xChartType, nAttachedAxis );
+ Reference< chart2::XDataSeriesContainer > xDSCnt( xChartType, uno::UNO_QUERY );
+ if(xDSCnt.is())
+ {
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
+ for (sal_Int32 nIndex = 0, nEnd = aSeriesSeq.getLength(); nIndex < nEnd; ++nIndex)
+ {
+ uno::Reference<chart2::XDataSeries> xSeries = aSeriesSeq[nIndex];
+ Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY);
+ if (!xPropSet.is())
+ continue;
- // show marker?
- sal_Int32 nSymbolType = css::chart::ChartSymbolType::NONE;
- Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
- if( GetProperty( xPropSet, "SymbolType" ) )
- mAny >>= nSymbolType;
+ sal_Int32 nAxisIndex = -1;
+ uno::Any aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
+ aAny >>= nAxisIndex;
+ size_t nVectorPos = 0;
- if( !mbIs3DChart )
+ auto it = aMapAxisToIndex.find(nAxisIndex);
+ if (it == aMapAxisToIndex.end())
+ {
+ aSplitSeries.push_back(Sequence<Reference<chart2::XDataSeries> >());
+ nVectorPos = aSplitSeries.size() - 1;
+ aMapAxisToIndex.insert(std::pair<sal_Int32, size_t>(nAxisIndex, nVectorPos));
+ }
+
+ uno::Sequence<Reference<chart2::XDataSeries> >& rAxisSeriesSeq = aSplitSeries[nVectorPos];
+ sal_Int32 nLength = rAxisSeriesSeq.getLength();
+ rAxisSeriesSeq.realloc(nLength + 1);
+ rAxisSeriesSeq[nLength] = xSeries;
+ }
+ }
+
+ return aSplitSeries;
+}
+
+}
+
+void ChartExport::exportLineChart( Reference< chart2::XChartType > xChartType )
+{
+ FSHelperPtr pFS = GetFS();
+ std::vector<Sequence<Reference<chart2::XDataSeries> > > aSplitDataSeries = splitDataSeriesByAxis(xChartType);
+ for (auto itr = aSplitDataSeries.begin(), itrEnd = aSplitDataSeries.end();
+ itr != itrEnd; ++itr)
{
- exportHiLowLines();
- exportUpDownBars(xChartType);
- const char* marker = nSymbolType == css::chart::ChartSymbolType::NONE? "0":"1";
- pFS->singleElement( FSNS( XML_c, XML_marker ),
- XML_val, marker,
+ if (itr->getLength() == 0)
+ continue;
+
+ sal_Int32 nTypeId = XML_lineChart;
+ if( mbIs3DChart )
+ nTypeId = XML_line3DChart;
+ pFS->startElement( FSNS( XML_c, nTypeId ),
FSEND );
- }
- exportAxesId( nAttachedAxis );
+ exportGrouping( );
+ // TODO: show marker symbol in series?
+ sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+ exportSeries( xChartType, *itr, nAttachedAxis );
- pFS->endElement( FSNS( XML_c, nTypeId ) );
+ // show marker?
+ sal_Int32 nSymbolType = css::chart::ChartSymbolType::NONE;
+ Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
+ if( GetProperty( xPropSet, "SymbolType" ) )
+ mAny >>= nSymbolType;
+
+ if( !mbIs3DChart )
+ {
+ exportHiLowLines();
+ exportUpDownBars(xChartType);
+ const char* marker = nSymbolType == css::chart::ChartSymbolType::NONE? "0":"1";
+ pFS->singleElement( FSNS( XML_c, XML_marker ),
+ XML_val, marker,
+ FSEND );
+ }
+
+ exportAxesId( nAttachedAxis );
+
+ pFS->endElement( FSNS( XML_c, nTypeId ) );
+ }
}
void ChartExport::exportPieChart( Reference< chart2::XChartType > xChartType )
@@ -1755,35 +1806,43 @@ void ChartExport::exportRadarChart( Reference< chart2::XChartType > xChartType)
void ChartExport::exportScatterChart( Reference< chart2::XChartType > xChartType )
{
FSHelperPtr pFS = GetFS();
- pFS->startElement( FSNS( XML_c, XML_scatterChart ),
- FSEND );
- // TODO:scatterStyle
+ std::vector<Sequence<Reference<chart2::XDataSeries> > > aSplitDataSeries = splitDataSeriesByAxis(xChartType);
+ for (auto itr = aSplitDataSeries.begin(), itrEnd = aSplitDataSeries.end();
+ itr != itrEnd; ++itr)
+ {
+ if (itr->getLength() == 0)
+ continue;
- sal_Int32 nSymbolType = css::chart::ChartSymbolType::NONE;
- Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
- if( GetProperty( xPropSet, "SymbolType" ) )
- mAny >>= nSymbolType;
+ pFS->startElement( FSNS( XML_c, XML_scatterChart ),
+ FSEND );
+ // TODO:scatterStyle
- const char* scatterStyle = "lineMarker";
- if (nSymbolType == css::chart::ChartSymbolType::NONE)
- {
- scatterStyle = "line";
- }
+ sal_Int32 nSymbolType = css::chart::ChartSymbolType::NONE;
+ Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
+ if( GetProperty( xPropSet, "SymbolType" ) )
+ mAny >>= nSymbolType;
- pFS->singleElement( FSNS( XML_c, XML_scatterStyle ),
- XML_val, scatterStyle,
- FSEND );
+ const char* scatterStyle = "lineMarker";
+ if (nSymbolType == css::chart::ChartSymbolType::NONE)
+ {
+ scatterStyle = "line";
+ }
- pFS->singleElement( FSNS( XML_c, XML_varyColors ),
- XML_val, "0",
- FSEND );
+ pFS->singleElement( FSNS( XML_c, XML_scatterStyle ),
+ XML_val, scatterStyle,
+ FSEND );
- // FIXME: should export xVal and yVal
- sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportAllSeries( xChartType, nAttachedAxis );
- exportAxesId( nAttachedAxis );
+ pFS->singleElement( FSNS( XML_c, XML_varyColors ),
+ XML_val, "0",
+ FSEND );
- pFS->endElement( FSNS( XML_c, XML_scatterChart ) );
+ // FIXME: should export xVal and yVal
+ sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+ exportSeries( xChartType, *itr, nAttachedAxis );
+ exportAxesId( nAttachedAxis );
+
+ pFS->endElement( FSNS( XML_c, XML_scatterChart ) );
+ }
}
void ChartExport::exportStockChart( Reference< chart2::XChartType > xChartType )
commit 9b884187bad58a2291928349c455150d472dff62
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun May 10 01:04:50 2015 +0200
split exportSeries function up
Change-Id: I06c09a494bdf37a87ff851a8e3cbc94b22b9a511
diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx
index 31c5234..186ea75 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -141,7 +141,9 @@ private:
void exportHiLowLines();
void exportUpDownBars(css::uno::Reference< css::chart2::XChartType > xChartType );
- void exportSeries( css::uno::Reference< css::chart2::XChartType > xChartType, sal_Int32& nAttachedAxis );
+ void exportAllSeries(css::uno::Reference<css::chart2::XChartType> xChartType, sal_Int32& nAttachedAxis);
+ void exportSeries(css::uno::Reference< css::chart2::XChartType > xChartType,
+ css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, sal_Int32& nAttachedAxis );
void exportCandleStickSeries(
const css::uno::Sequence<
css::uno::Reference<
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 79792d9..36939af 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -1523,7 +1523,7 @@ void ChartExport::exportAreaChart( Reference< chart2::XChartType > xChartType )
exportGrouping( );
sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportSeries( xChartType, nAttachedAxis );
+ exportAllSeries( xChartType, nAttachedAxis );
exportAxesId( nAttachedAxis );
pFS->endElement( FSNS( XML_c, nTypeId ) );
@@ -1556,7 +1556,7 @@ void ChartExport::exportBarChart( Reference< chart2::XChartType > xChartType )
FSEND );
sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportSeries( xChartType, nAttachedAxis );
+ exportAllSeries( xChartType, nAttachedAxis );
Reference< XPropertySet > xTypeProp( xChartType, uno::UNO_QUERY );
@@ -1632,7 +1632,7 @@ void ChartExport::exportBubbleChart( Reference< chart2::XChartType > xChartType
FSEND );
sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportSeries( xChartType, nAttachedAxis );
+ exportAllSeries( xChartType, nAttachedAxis );
pFS->singleElement(FSNS(XML_c, XML_bubble3D),
XML_val, "0",
@@ -1650,7 +1650,7 @@ void ChartExport::exportDoughnutChart( Reference< chart2::XChartType > xChartTyp
FSEND );
sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportSeries( xChartType, nAttachedAxis );
+ exportAllSeries( xChartType, nAttachedAxis );
// firstSliceAng
exportFirstSliceAng( );
//FIXME: holeSize
@@ -1674,7 +1674,7 @@ void ChartExport::exportLineChart( Reference< chart2::XChartType > xChartType )
exportGrouping( );
// TODO: show marker symbol in series?
sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportSeries( xChartType, nAttachedAxis );
+ exportAllSeries( xChartType, nAttachedAxis );
// show marker?
sal_Int32 nSymbolType = css::chart::ChartSymbolType::NONE;
@@ -1718,7 +1718,7 @@ void ChartExport::exportPieChart( Reference< chart2::XChartType > xChartType )
FSEND );
sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportSeries( xChartType, nAttachedAxis );
+ exportAllSeries( xChartType, nAttachedAxis );
if( !mbIs3DChart )
{
@@ -1746,7 +1746,7 @@ void ChartExport::exportRadarChart( Reference< chart2::XChartType > xChartType)
XML_val, radarStyle,
FSEND );
sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportSeries( xChartType, nAttachedAxis );
+ exportAllSeries( xChartType, nAttachedAxis );
exportAxesId( nAttachedAxis );
pFS->endElement( FSNS( XML_c, XML_radarChart ) );
@@ -1780,7 +1780,7 @@ void ChartExport::exportScatterChart( Reference< chart2::XChartType > xChartType
// FIXME: should export xVal and yVal
sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportSeries( xChartType, nAttachedAxis );
+ exportAllSeries( xChartType, nAttachedAxis );
exportAxesId( nAttachedAxis );
pFS->endElement( FSNS( XML_c, XML_scatterChart ) );
@@ -1793,7 +1793,17 @@ void ChartExport::exportStockChart( Reference< chart2::XChartType > xChartType )
FSEND );
sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportSeries( xChartType, nAttachedAxis );
+
+ bool bJapaneseCandleSticks = false;
+ Reference< beans::XPropertySet > xCTProp( xChartType, uno::UNO_QUERY );
+ if( xCTProp.is())
+ xCTProp->getPropertyValue("Japanese") >>= bJapaneseCandleSticks;
+
+ Reference< chart2::XDataSeriesContainer > xDSCnt( xChartType, uno::UNO_QUERY );
+ if(xDSCnt.is())
+ exportCandleStickSeries(
+ xDSCnt->getDataSeries(), bJapaneseCandleSticks, nAttachedAxis );
+
// export stock properties
Reference< css::chart::XStatisticDisplay > xStockPropProvider( mxDiagram, uno::UNO_QUERY );
if( xStockPropProvider.is())
@@ -1882,41 +1892,34 @@ void ChartExport::exportSurfaceChart( Reference< chart2::XChartType > xChartType
pFS->startElement( FSNS( XML_c, nTypeId ),
FSEND );
sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
- exportSeries( xChartType, nAttachedAxis );
+ exportAllSeries( xChartType, nAttachedAxis );
exportAxesId( nAttachedAxis );
pFS->endElement( FSNS( XML_c, nTypeId ) );
}
-void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_Int32& nAttachedAxis )
+void ChartExport::exportAllSeries(Reference<chart2::XChartType> xChartType, sal_Int32& nAttachedAxis)
{
-
- OUString aLabelRole = xChartType->getRoleOfSequenceForSeriesLabel();
Reference< chart2::XDataSeriesContainer > xDSCnt( xChartType, uno::UNO_QUERY );
if( ! xDSCnt.is())
return;
+ // export dataseries for current chart-type
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
+ exportSeries(xChartType, aSeriesSeq, nAttachedAxis);
+}
+
+void ChartExport::exportSeries( Reference<chart2::XChartType> xChartType,
+ Sequence<Reference<chart2::XDataSeries> >& rSeriesSeq, sal_Int32& nAttachedAxis )
+{
+ OUString aLabelRole = xChartType->getRoleOfSequenceForSeriesLabel();
OUString aChartType( xChartType->getChartType());
sal_Int32 eChartType = lcl_getChartType( aChartType );
- // special export for stock charts
- if( eChartType == chart::TYPEID_STOCK )
- {
- bool bJapaneseCandleSticks = false;
- Reference< beans::XPropertySet > xCTProp( xChartType, uno::UNO_QUERY );
- if( xCTProp.is())
- xCTProp->getPropertyValue("Japanese") >>= bJapaneseCandleSticks;
- exportCandleStickSeries(
- xDSCnt->getDataSeries(), bJapaneseCandleSticks, nAttachedAxis );
- return;
- }
-
- // export dataseries for current chart-type
- Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
- for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
+ for( sal_Int32 nSeriesIdx=0; nSeriesIdx<rSeriesSeq.getLength(); ++nSeriesIdx )
{
// export series
- Reference< chart2::data::XDataSource > xSource( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY );
+ Reference< chart2::data::XDataSource > xSource( rSeriesSeq[nSeriesIdx], uno::UNO_QUERY );
if( xSource.is())
{
Reference< chart2::XDataSeries > xDataSeries( xSource, uno::UNO_QUERY );
@@ -1972,7 +1975,7 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_
// export shape properties
Reference< XPropertySet > xPropSet = SchXMLSeriesHelper::createOldAPISeriesPropertySet(
- aSeriesSeq[nSeriesIdx], getModel() );
+ rSeriesSeq[nSeriesIdx], getModel() );
if( xPropSet.is() )
{
if( GetProperty( xPropSet, "Axis") )
@@ -2028,12 +2031,12 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_
}
// export data points
- exportDataPoints( uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength );
+ exportDataPoints( uno::Reference< beans::XPropertySet >( rSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength );
// export data labels
- exportDataLabels(aSeriesSeq[nSeriesIdx], nSeriesLength, eChartType);
+ exportDataLabels(rSeriesSeq[nSeriesIdx], nSeriesLength, eChartType);
- exportTrendlines( aSeriesSeq[nSeriesIdx] );
+ exportTrendlines( rSeriesSeq[nSeriesIdx] );
if( eChartType != chart::TYPEID_PIE &&
eChartType != chart::TYPEID_RADARLINE )
More information about the Libreoffice-commits
mailing list