fdo#83058 File corrupt due to data label position is invalid in chart.xml
- File getting corrupted after RT due to data label position is invalid in chart.xml - LO must not export invalid label position property if chart type doesn't support that positioning in MS Office. - For clusterd bar chart XML Difference chart1.xml Original file <c:barChart> <c:grouping val="clustered" /> <c:ser> <c:dLbls> ... <c:dLbl> <c:dLblPos val="outEnd" /> </c:dLbl> ... </c:dLbls> </c:ser> </c:barChart> Roundtrip file <c:barChart> <c:grouping val="clustered" /> <c:ser> <c:dLbls> ... <c:dLbl> <c:dLblPos val="r" /> </c:dLbl> ... </c:dLbls> </c:ser> </c:barChart> Change-Id: I9cae11b8d198aaa70fb05cb3bf329cd898519170 Reviewed-on: https://gerrit.libreoffice.org/11141 Reviewed-by: Kohei Yoshida <libreoffice@kohei.us> Tested-by: Kohei Yoshida <libreoffice@kohei.us>
This commit is contained in:
committed by
Kohei Yoshida
parent
31e82d9f6f
commit
a7052b906d
@@ -79,6 +79,7 @@ public:
|
||||
void testDataLabelDoughnutChartDOCX();
|
||||
void testDataLabelAreaChartDOCX();
|
||||
void testDataLabelDefaultLineChartDOCX();
|
||||
void testFdo83058dlblPos();
|
||||
|
||||
CPPUNIT_TEST_SUITE(Chart2ExportTest);
|
||||
CPPUNIT_TEST(test);
|
||||
@@ -123,6 +124,7 @@ public:
|
||||
CPPUNIT_TEST(testDataLabelDoughnutChartDOCX);
|
||||
CPPUNIT_TEST(testDataLabelAreaChartDOCX);
|
||||
CPPUNIT_TEST(testDataLabelDefaultLineChartDOCX);
|
||||
CPPUNIT_TEST(testFdo83058dlblPos);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
protected:
|
||||
@@ -867,7 +869,7 @@ void Chart2ExportTest::testDataLabelClusteredBarChartDOCX()
|
||||
CPPUNIT_ASSERT(pXmlDoc);
|
||||
|
||||
// This was "t", should be one of the allowed values.
|
||||
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLbl[2]/c:dLblPos", "val", "ctr");
|
||||
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLbl[2]/c:dLblPos", "val", "outEnd");
|
||||
}
|
||||
|
||||
void Chart2ExportTest::testDataLabelRadarChartDOCX()
|
||||
@@ -1186,6 +1188,17 @@ void Chart2ExportTest::testLabelStringODS()
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("\"LabelName\""), aLabelString);
|
||||
}
|
||||
|
||||
void Chart2ExportTest::testFdo83058dlblPos()
|
||||
{
|
||||
load ("/chart2/qa/extras/data/docx/", "fdo83058_dlblPos.docx");
|
||||
xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
|
||||
CPPUNIT_ASSERT(pXmlDoc);
|
||||
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[2]/c:dLblPos", "val", "outEnd");
|
||||
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[3]/c:dLblPos", "val", "outEnd");
|
||||
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[4]/c:dLblPos", "val", "outEnd");
|
||||
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[5]/c:dLblPos", "val", "outEnd");
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
BIN
chart2/qa/extras/data/docx/fdo83058_dlblPos.docx
Normal file
BIN
chart2/qa/extras/data/docx/fdo83058_dlblPos.docx
Normal file
Binary file not shown.
@@ -99,7 +99,6 @@ private:
|
||||
bool mbIs3DChart;
|
||||
bool mbStacked;
|
||||
bool mbPercent;
|
||||
bool mbClustered;
|
||||
|
||||
private:
|
||||
sal_Int32 getChartType();
|
||||
|
@@ -446,7 +446,6 @@ ChartExport::ChartExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, Reference< f
|
||||
, mbIs3DChart( false )
|
||||
, mbStacked(false)
|
||||
, mbPercent(false)
|
||||
, mbClustered(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2656,13 +2655,15 @@ void ChartExport::exportDataLabels(
|
||||
aParam.mbExport = !mbIs3DChart;
|
||||
aParam.meDefault = rInfo.mnDefLabelPos;
|
||||
aParam.allowAll();
|
||||
switch (getChartType()) // diagram chart type
|
||||
switch (eChartType) // diagram chart type
|
||||
{
|
||||
case chart::TYPEID_PIE:
|
||||
if(getChartType() == chart::TYPEID_DOUGHNUT)
|
||||
aParam.mbExport = false;
|
||||
else
|
||||
// All pie charts support label placement.
|
||||
aParam.mbExport = true;
|
||||
break;
|
||||
case chart::TYPEID_DOUGHNUT:
|
||||
case chart::TYPEID_AREA:
|
||||
case chart::TYPEID_RADARLINE:
|
||||
case chart::TYPEID_RADARAREA:
|
||||
@@ -2670,7 +2671,7 @@ void ChartExport::exportDataLabels(
|
||||
aParam.mbExport = false;
|
||||
break;
|
||||
case chart::TYPEID_BAR:
|
||||
if (mbStacked || mbPercent || mbClustered)
|
||||
if (mbStacked || mbPercent)
|
||||
{
|
||||
aParam.maAllowedValues.clear();
|
||||
aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::CENTER);
|
||||
@@ -2678,6 +2679,15 @@ void ChartExport::exportDataLabels(
|
||||
aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::NEAR_ORIGIN);
|
||||
aParam.meDefault = css::chart::DataLabelPlacement::CENTER;
|
||||
}
|
||||
else // Clustered bar chart
|
||||
{
|
||||
aParam.maAllowedValues.clear();
|
||||
aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::CENTER);
|
||||
aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::INSIDE);
|
||||
aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::OUTSIDE);
|
||||
aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::NEAR_ORIGIN);
|
||||
aParam.meDefault = css::chart::DataLabelPlacement::OUTSIDE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
@@ -2818,7 +2828,6 @@ void ChartExport::exportGrouping( bool isBar )
|
||||
if( isBar && !isDeep3dChart() )
|
||||
{
|
||||
grouping = "clustered";
|
||||
mbClustered = true;
|
||||
}
|
||||
else
|
||||
grouping = "standard";
|
||||
|
Reference in New Issue
Block a user