summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/qa/extras/chart2export.cxx12
-rw-r--r--chart2/qa/extras/data/docx/testAreaChartLoad.docxbin0 -> 23962 bytes
-rw-r--r--oox/source/export/chartexport.cxx73
3 files changed, 63 insertions, 22 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 6cef73b26831..7b1629af69d2 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -39,6 +39,7 @@ public:
void testChartDataTable();
void testChartExternalData();
void testEmbeddingsGrabBag();
+ void testAreaChartLoad();
CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(test);
@@ -50,6 +51,7 @@ public:
CPPUNIT_TEST(testChartDataTable);
CPPUNIT_TEST(testChartExternalData);
CPPUNIT_TEST(testEmbeddingsGrabBag);
+ CPPUNIT_TEST(testAreaChartLoad);
CPPUNIT_TEST_SUITE_END();
protected:
@@ -440,6 +442,7 @@ void Chart2ExportTest::testCrosses()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:crosses", "val", "autoZero");
}
+
void Chart2ExportTest::testChartDataTable()
{
load("/chart2/qa/extras/data/docx/", "testChartDataTable.docx");
@@ -500,6 +503,15 @@ void Chart2ExportTest::testEmbeddingsGrabBag()
CPPUNIT_ASSERT(bEmbeddings); // Grab Bag has all the expected elements
}
+void Chart2ExportTest::testAreaChartLoad()
+{
+ load ("/chart2/qa/extras/data/docx/", "testAreaChartLoad.docx");
+ xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+ CPPUNIT_ASSERT(pXmlDoc);
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:showVal", "val", "1");
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:dLbl", 0);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/docx/testAreaChartLoad.docx b/chart2/qa/extras/data/docx/testAreaChartLoad.docx
new file mode 100644
index 000000000000..9383f75cde34
--- /dev/null
+++ b/chart2/qa/extras/data/docx/testAreaChartLoad.docx
Binary files differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 8bbf222ed5c6..a795aacda9ff 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2410,15 +2410,38 @@ void ChartExport::exportDataLabels(
bool showCategoryName = false;
bool showNumberInPercent = false;
- sal_Int32 nElem;
- for( nElem = 0; nElem < nSeriesLength; ++nElem)
+ sal_Int32 nElem = 0;
+
+
+ uno::Reference< beans::XPropertySet > xPropSet;
+ if(nSeriesLength != 0)
{
- uno::Reference< beans::XPropertySet > xPropSet;
+ try
+ {
+ xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet(
+ xSeries, nElem, getModel() );
+ }
+ catch( const uno::Exception & rEx )
+ {
+ SAL_WARN("oox", "Exception caught during Export of data label: " << rEx.Message );
+ }
+ }
+ namespace cssc2 = ::com::sun::star::chart2;
+ cssc2::DataPointLabel aTempLabel;
+ if( xPropSet.is() )
+ {
+ if (GetProperty( xPropSet, "Label"))
+ mAny >>= aTempLabel;
+
+
+
+ for( nElem = 1; nElem < nSeriesLength; ++nElem)
+ {
try
{
xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet(
- xSeries, nElem, getModel() );
+ xSeries, nElem, getModel() );
}
catch( const uno::Exception & rEx )
{
@@ -2454,39 +2477,45 @@ void ChartExport::exportDataLabels(
case csscd::AVOID_OVERLAP: aPlacement = "bestFit"; break;
}
- if(aLabel.ShowLegendSymbol || aLabel.ShowNumber || aLabel.ShowCategoryName || aLabel.ShowNumberInPercent)
- {
+ if (aLabel.ShowLegendSymbol)
+ showLegendSymbol = true;
+ if(aLabel.ShowNumber)
+ showNumber = true;
+ if(aLabel.ShowCategoryName)
+ showCategoryName = true;
+ if(aLabel.ShowNumberInPercent)
+ showNumberInPercent = true;
+
+ if(aTempLabel.ShowLegendSymbol != aLabel.ShowLegendSymbol || aTempLabel.ShowNumber!= aLabel.ShowNumber ||
+ aTempLabel.ShowCategoryName != aLabel.ShowCategoryName || aTempLabel.ShowNumberInPercent != aLabel.ShowNumberInPercent)
+ {
pFS->startElement( FSNS( XML_c, XML_dLbl ), FSEND);
pFS->singleElement( FSNS( XML_c, XML_idx), XML_val, I32S(nElem), FSEND);
pFS->singleElement( FSNS( XML_c, XML_dLblPos), XML_val, aPlacement, FSEND);
- pFS->singleElement( FSNS( XML_c, XML_showLegendKey), XML_val, aLabel.ShowLegendSymbol ? "1": "0", FSEND);
- if (aLabel.ShowLegendSymbol)
+ if(aTempLabel.ShowLegendSymbol != aLabel.ShowLegendSymbol)
{
- showLegendSymbol = true;
+ pFS->singleElement( FSNS( XML_c, XML_showLegendKey), XML_val, aLabel.ShowLegendSymbol ? "1": "0", FSEND);
}
- pFS->singleElement( FSNS( XML_c, XML_showVal), XML_val,aLabel.ShowNumber ? "1": "0", FSEND);
- if(aLabel.ShowNumber)
+ if (aTempLabel.ShowNumber!= aLabel.ShowNumber)
{
- showNumber = true;
+ pFS->singleElement( FSNS( XML_c, XML_showVal), XML_val,aLabel.ShowNumber ? "1": "0", FSEND);
}
- pFS->singleElement( FSNS( XML_c, XML_showCatName), XML_val, aLabel.ShowCategoryName ? "1": "0", FSEND);
- if(aLabel.ShowCategoryName)
+
+ if(aTempLabel.ShowCategoryName != aLabel.ShowCategoryName)
{
- showCategoryName = true;
+ pFS->singleElement( FSNS( XML_c, XML_showCatName), XML_val, aLabel.ShowCategoryName ? "1": "0", FSEND);
}
-
// MSO somehow assumes series name to be on (=displayed) by default.
// Let's put false here and switch it off then, since we have no UI means
// in LibO to toggle it on anyway
pFS->singleElement( FSNS( XML_c, XML_showSerName), XML_val, "0", FSEND);
- pFS->singleElement( FSNS( XML_c, XML_showPercent), XML_val,aLabel.ShowNumberInPercent ? "1": "0", FSEND);
- if(aLabel.ShowNumberInPercent)
+ if(aTempLabel.ShowNumberInPercent != aLabel.ShowNumberInPercent)
{
- showNumberInPercent = true;
+ pFS->singleElement( FSNS( XML_c, XML_showPercent), XML_val,aLabel.ShowNumberInPercent ? "1": "0", FSEND);
}
if (GetProperty( xPropSet, "LabelSeparator"))
@@ -2497,9 +2526,8 @@ void ChartExport::exportDataLabels(
pFS->endElement( FSNS( XML_c, XML_separator) );
}
pFS->endElement( FSNS( XML_c, XML_dLbl ));
- }
-
- }
+ }
+ }
}
}
@@ -2513,6 +2541,7 @@ void ChartExport::exportDataLabels(
pFS->endElement( FSNS( XML_c, XML_dLbls ) );
}
+ }
}
void ChartExport::exportDataPoints(