Kaydet (Commit) c7cfe087 authored tarafından Rajashri's avatar Rajashri Kaydeden (comit) Markus Mohrhard

fdo#72217 : Fix for corruption area chart with data labels after Round Trip.

For labels under one series, there were child tags created for every
data label individually.
for example, if under one series there are five labels, then under
<dLbls> there were 5 <dLbl> tags created separately.
This issue is resolved now.

Conflicts:
	chart2/qa/extras/chart2export.cxx

Change-Id: I7ae214f413bc27728df8a3d4cb8f4d703cba2f77
üst bcf116b7
......@@ -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();
......
......@@ -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(
......
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