summaryrefslogtreecommitdiff
path: root/chart2/qa/extras/chart2geometry.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/qa/extras/chart2geometry.cxx')
-rw-r--r--chart2/qa/extras/chart2geometry.cxx180
1 files changed, 105 insertions, 75 deletions
diff --git a/chart2/qa/extras/chart2geometry.cxx b/chart2/qa/extras/chart2geometry.cxx
index f460ac467621..c554fc950c61 100644
--- a/chart2/qa/extras/chart2geometry.cxx
+++ b/chart2/qa/extras/chart2geometry.cxx
@@ -9,8 +9,6 @@
#include "charttest.hxx"
-#include <test/xmltesttools.hxx>
-
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XDataSeries.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
@@ -25,12 +23,9 @@ using beans::XPropertySet;
class Chart2GeometryTest : public ChartTest
{
-protected:
- virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override;
-
public:
Chart2GeometryTest()
- : ChartTest()
+ : ChartTest("/chart2/qa/extras/data/")
{
}
// Mostly tests for line and fill properties
@@ -68,12 +63,6 @@ public:
CPPUNIT_TEST_SUITE_END();
};
-void Chart2GeometryTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx)
-{
- XmlTestTools::registerOOXMLNamespaces(pXmlXPathCtx);
- XmlTestTools::registerODFNamespaces(pXmlXPathCtx);
-}
-
static OString OU2O(std::u16string_view sOUSource)
{
return rtl::OUStringToOString(sOUSource, RTL_TEXTENCODING_UTF8);
@@ -84,13 +73,15 @@ static OString OU2O(std::u16string_view sOUSource)
void Chart2GeometryTest::testTdf135184RoundLineCap()
{
// It tests chart area, data series line and regression-curve line.
- load(u"/chart2/qa/extras/data/xlsx/", "tdf135184RoundLineCap.xlsx");
- xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "calc8");
+ loadFromFile(u"xlsx/tdf135184RoundLineCap.xlsx");
+ save("calc8");
+ xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
CPPUNIT_ASSERT(pXmlDoc);
- const OString sStyleStart("/office:document-content/office:automatic-styles");
- const OString sCap("/style:graphic-properties[@svg:stroke-linecap='round']");
- const OString sChartStart("/office:document-content/office:body/office:chart/chart:chart");
+ static constexpr OString sStyleStart("/office:document-content/office:automatic-styles"_ostr);
+ static constexpr OString sCap("/style:graphic-properties[@svg:stroke-linecap='round']"_ostr);
+ static constexpr OString sChartStart(
+ "/office:document-content/office:body/office:chart/chart:chart"_ostr);
OString sPredicate;
// chart area
const OUString sOUAreaStyleName = getXPathContent(pXmlDoc, sChartStart + "/@chart:style-name");
@@ -111,13 +102,15 @@ void Chart2GeometryTest::testTdf135184RoundLineCap()
void Chart2GeometryTest::testTdf135184RoundLineCap2()
{
// It tests legend, data series sector and title.
- load(u"/chart2/qa/extras/data/xlsx/", "tdf135184RoundLineCap2.xlsx");
- xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "calc8");
+ loadFromFile(u"xlsx/tdf135184RoundLineCap2.xlsx");
+ save("calc8");
+ xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
CPPUNIT_ASSERT(pXmlDoc);
- const OString sStyleStart("/office:document-content/office:automatic-styles");
- const OString sCap("/style:graphic-properties[@svg:stroke-linecap='round']");
- const OString sChartStart("/office:document-content/office:body/office:chart/chart:chart");
+ static constexpr OString sStyleStart("/office:document-content/office:automatic-styles"_ostr);
+ static constexpr OString sCap("/style:graphic-properties[@svg:stroke-linecap='round']"_ostr);
+ static constexpr OString sChartStart(
+ "/office:document-content/office:body/office:chart/chart:chart"_ostr);
OString sPredicate;
// legend
const OString sLegend(sChartStart + "/chart:legend");
@@ -140,49 +133,58 @@ void Chart2GeometryTest::testTdf135184RoundLineCap2()
void Chart2GeometryTest::testTdf135184RoundLineCap3()
{
// It tests chart area, data series line and regression-curve line.
- load(u"/chart2/qa/extras/data/xlsx/", "tdf135184RoundLineCap.xlsx");
- xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+ loadFromFile(u"xlsx/tdf135184RoundLineCap.xlsx");
+ save("Calc Office Open XML");
+ xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
CPPUNIT_ASSERT(pXmlDoc);
- const OString sDash("/c:spPr/a:ln/a:prstDash");
+ static constexpr OString sDash("/c:spPr/a:ln/a:prstDash"_ostr);
// chart area
- assertXPath(pXmlDoc, "/c:chartSpace" + sDash, "val", "dashDot");
+ assertXPath(pXmlDoc, "/c:chartSpace" + sDash, "val"_ostr, "dashDot");
// data series line
- const OString sStart("/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser");
- assertXPath(pXmlDoc, sStart + sDash, "val", "dash");
+ static constexpr OString sStart("/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser"_ostr);
+ assertXPath(pXmlDoc, sStart + sDash, "val"_ostr, "dash");
// regression-curve (trendline)
- assertXPath(pXmlDoc, sStart + "/c:trendline" + sDash, "val", "sysDot");
+ assertXPath(pXmlDoc, sStart + "/c:trendline" + sDash, "val"_ostr, "sysDot");
}
void Chart2GeometryTest::testTdf135184RoundLineCap4()
{
// It tests legend, data series sector and title.
- load(u"/chart2/qa/extras/data/xlsx/", "tdf135184RoundLineCap2.xlsx");
- xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+ loadFromFile(u"xlsx/tdf135184RoundLineCap2.xlsx");
+ save("Calc Office Open XML");
+ xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
CPPUNIT_ASSERT(pXmlDoc);
- const OString sChartStart("/c:chartSpace/c:chart");
- const OString sDash("/c:spPr/a:ln/a:prstDash");
- assertXPath(pXmlDoc, sChartStart + "/c:legend" + sDash, "val", "sysDot");
+ static constexpr OString sChartStart("/c:chartSpace/c:chart"_ostr);
+ static constexpr OString sDash("/c:spPr/a:ln/a:prstDash"_ostr);
+ assertXPath(pXmlDoc, sChartStart + "/c:legend" + sDash, "val"_ostr, "sysDot");
const OString sSeries(sChartStart + "/c:plotArea/c:pieChart/c:ser/c:dPt[3]");
- assertXPath(pXmlDoc, sSeries + sDash, "val", "dash");
- assertXPath(pXmlDoc, sChartStart + "/c:title" + sDash, "val", "dashDot");
+ assertXPath(pXmlDoc, sSeries + sDash, "val"_ostr, "dash");
+ assertXPath(pXmlDoc, sChartStart + "/c:title" + sDash, "val"_ostr, "dashDot");
}
void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_export()
{
// chart area with color gradient and solid transparency
// Without the patch the transparency was lost in saved pptx file.
- load(u"/chart2/qa/extras/data/odp/", "tdf128345_ChartArea_CG_TS.odp");
+ loadFromFile(u"odp/tdf128345_ChartArea_CG_TS.odp");
+
+ // MCGR: Similar to testTdf128345Legend_CS_TG_axial_export:
+ // Checked that it works with the existing import file,
+ // but will change with ODF MCGR im/export again.
+ // Adapting for now, but need to re-check values after
+ // ODF im/export for MCGR is integrated
// Make sure the chart area has a transparency in gradient stops in saved pptx file.
- xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+ save("Impress MS PowerPoint 2007 XML");
+ xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart1.xml");
CPPUNIT_ASSERT(pXmlDoc);
- OString sPathStart("//c:chartSpace/c:spPr/a:gradFill");
+ OString sPathStart("//c:chartSpace/c:spPr/a:gradFill"_ostr);
assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 2);
- assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "30000");
- assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "30000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val"_ostr, "30000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val"_ostr, "30000");
}
void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_import()
@@ -192,14 +194,21 @@ void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_import()
// Make sure chart area has transparency when pptx document is opened and resaved as odp.
// As of Aug 2020, the import generates a transparency gradient. When import is changed to
// generate solid transparency, the test needs to be adapted.
- load(u"/chart2/qa/extras/data/pptx/", "tdf128345_ChartArea_CG_TS.pptx");
+
+ // MCGR: Similar to testTdf128345Legend_CS_TG_axial_export:
+ // Checked that it works with the existing import file,
+ // but will change with ODF MCGR im/export again. We will need to
+ // update the *.odp input file. Disable unclear values for now and
+ // adapt when ODF im/export for MCGR is integrated
+ loadFromFile(u"pptx/tdf128345_ChartArea_CG_TS.pptx");
// Find transparency gradient name
- xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
+ save("impress8");
+ xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
CPPUNIT_ASSERT(pXmlDoc);
const OUString sOUChartStyleName = getXPathContent(
pXmlDoc,
- "//office:document-content/office:body/office:chart/chart:chart/@chart:style-name");
+ "//office:document-content/office:body/office:chart/chart:chart/@chart:style-name"_ostr);
const OString sStylePath(
"//office:document-content/office:automatic-styles/style:style[@style:name='"
+ OU2O(sOUChartStyleName) + "']");
@@ -209,7 +218,8 @@ void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_import()
= getXPathContent(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name");
// Verify the content of the opacity definition
- xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml", "impress8");
+ save("impress8");
+ xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml");
CPPUNIT_ASSERT(pXmlDoc2);
const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
@@ -218,23 +228,24 @@ void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_import()
assertXPath(pXmlDoc2, sStart + " and @draw:start='30%']");
assertXPath(pXmlDoc2, sStart + " and @draw:end='30%']");
assertXPath(pXmlDoc2, sStart + " and @draw:angle='30deg']");
- assertXPath(pXmlDoc2, sStart + " and @draw:border='20%']");
+ assertXPath(pXmlDoc2, sStart + " and @draw:border='0%']"); // MCGR: no border anymore 20% -> 0%
}
void Chart2GeometryTest::testTdf128345ChartWall_CS_TG_export()
{
// chart wall with solid color and transparency gradient
// Without the patch the transparency was lost.
- load(u"/chart2/qa/extras/data/odp/", "tdf128345_ChartWall_CS_TG.odp");
+ loadFromFile(u"odp/tdf128345_ChartWall_CS_TG.odp");
// Make sure the chart has a gradient with transparency in gradient stops in saved pptx file.
- xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+ save("Impress MS PowerPoint 2007 XML");
+ xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart1.xml");
CPPUNIT_ASSERT(pXmlDoc);
- OString sPathStart("//c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill");
+ OString sPathStart("//c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill"_ostr);
assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 2); //linear
// MS Office has opacity, so 100% transparency is val="0"
- assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "0");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val"_ostr, "0");
// no element for 0% transparent
assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", 0);
}
@@ -243,14 +254,15 @@ void Chart2GeometryTest::testTdf128345ChartWall_CS_TG_import()
{
// This works on the file, which was exported from file tdf128345_ChartWall_CS_TG.odp to pptx.
// Make sure chart wall has transparency when pptx document is resaved as odp.
- load(u"/chart2/qa/extras/data/pptx/", "tdf128345_ChartWall_CS_TG.pptx");
+ loadFromFile(u"pptx/tdf128345_ChartWall_CS_TG.pptx");
// Find transparency gradient name
- xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
+ save("impress8");
+ xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
CPPUNIT_ASSERT(pXmlDoc);
const OUString sOUChartStyleName
= getXPathContent(pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/"
- "chart:plot-area/chart:wall/@chart:style-name");
+ "chart:plot-area/chart:wall/@chart:style-name"_ostr);
const OString sStylePath(
"//office:document-content/office:automatic-styles/style:style[@style:name='"
+ OU2O(sOUChartStyleName) + "']");
@@ -260,7 +272,8 @@ void Chart2GeometryTest::testTdf128345ChartWall_CS_TG_import()
= getXPathContent(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name");
// Verify content of the opacity definition
- xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml", "impress8");
+ save("impress8");
+ xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml");
CPPUNIT_ASSERT(pXmlDoc2);
const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
@@ -274,34 +287,44 @@ void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_export()
{
// legend with solid color and transparency gradient
// Without the patch the transparency was lost.
- load(u"/chart2/qa/extras/data/odp/", "tdf128345_Legend_CS_TG_axial.odp");
+ loadFromFile(u"odp/tdf128345_Legend_CS_TG_axial.odp");
// Make sure the chart has a gradient with transparency in gradient stops in saved pptx file.
- xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+ save("Impress MS PowerPoint 2007 XML");
+ xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart1.xml");
CPPUNIT_ASSERT(pXmlDoc);
- OString sPathStart("//c:chartSpace/c:chart/c:legend/c:spPr/a:gradFill");
- assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 3); // axial
- // no element for 0% transparent
+ OString sPathStart("//c:chartSpace/c:chart/c:legend/c:spPr/a:gradFill"_ostr);
+
+ // MCGR: three entries due to axial being mirrored+expanded to linear
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 3);
+
+ // MCGR: start entry, no transparence, pos zero
assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", 0);
- // 100% transparent = opacity 0. It comes from "axial", therefore it is in the middle.
- assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "0");
- assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]", "pos", "50000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]", "pos"_ostr, "0");
+
+ // MCGR: middle entry, 100% transparence, pos 0.5
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val"_ostr, "0");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]", "pos"_ostr, "50000");
+
+ // MCGR: end entry, no transparence, pos 1.0
assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[3]/a:srgbClr/a:alpha", 0);
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[3]", "pos"_ostr, "100000");
}
void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_import()
{
// This works on the file, which was exported from file tdf128345_Legend_CS_TG_axial.odp to pptx.
// Error was, that in case of axial not the middle value was taken but start and end value.
- load(u"/chart2/qa/extras/data/pptx/", "tdf128345_Legend_CS_TG_axial.pptx");
+ loadFromFile(u"pptx/tdf128345_Legend_CS_TG_axial.pptx");
// Find transparency gradient name
- xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
+ save("impress8");
+ xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
CPPUNIT_ASSERT(pXmlDoc);
const OUString sOUChartStyleName
= getXPathContent(pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/"
- "chart:legend/@chart:style-name");
+ "chart:legend/@chart:style-name"_ostr);
const OString sStylePath(
"//office:document-content/office:automatic-styles/style:style[@style:name='"
+ OU2O(sOUChartStyleName) + "']");
@@ -311,7 +334,8 @@ void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_import()
= getXPathContent(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name");
// Verify content of the opacity definition
- xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml", "impress8");
+ save("impress8");
+ xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml");
CPPUNIT_ASSERT(pXmlDoc2);
const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
@@ -325,7 +349,7 @@ void Chart2GeometryTest::testTdf135366LabelOnSeries()
{
// Error was, that the fill and line properties of a <chart:data-label> were not
// imported at all. Here they should be at the series.
- load(u"/chart2/qa/extras/data/ods/", "tdf135366_data_label_series.ods");
+ loadFromFile(u"ods/tdf135366_data_label_series.ods");
uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
@@ -363,7 +387,7 @@ void Chart2GeometryTest::testTdf135366LabelOnPoint()
{
// Error was, that the fill and line properties of a <chart:data-label> were not
// imported at all. Here they should be at point 2.
- load(u"/chart2/qa/extras/data/odt/", "tdf135366_data_label_point.odt");
+ loadFromFile(u"odt/tdf135366_data_label_point.odt");
uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
@@ -410,14 +434,19 @@ void Chart2GeometryTest::testTdf135366LabelExport()
// Error was, that line and fill properties were not exported as
// graphic-properties of a <chart:data-label> element, but only
// as loext chart-properties of the <chart:data-point> element.
- load(u"/chart2/qa/extras/data/odt/", "tdf135366_data_label_export.odt");
- xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "writer8");
+ loadFromFile(u"odt/tdf135366_data_label_export.odt");
+
+ // FIXME: Error: unexpected attribute "loext:label-stroke-color"
+ skipValidation();
+
+ save("writer8");
+ xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
CPPUNIT_ASSERT(pXmlDoc);
// Find label style
const OUString sOULabelStyleName = getXPathContent(
pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/chart:plot-area"
- "/chart:series/chart:data-point[1]/chart:data-label/@chart:style-name");
+ "/chart:series/chart:data-point[1]/chart:data-label/@chart:style-name"_ostr);
// Verify content of graphic properties of label style
const OString sStylePath(
@@ -437,14 +466,15 @@ void Chart2GeometryTest::testTdf135366_CustomLabelText()
// although the used <chart:data-label> element exists since ODF 1.2.
const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion());
SetODFDefaultVersion(SvtSaveOptions::ODFVER_012);
- load(u"/chart2/qa/extras/data/pptx/", "tdf135366_CustomLabelText.pptx");
- xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
+ loadFromFile(u"pptx/tdf135366_CustomLabelText.pptx");
+ save("impress8");
+ xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
CPPUNIT_ASSERT(pXmlDoc);
// Find custom text. As of version 7.0 it is in a <text:span> element.
- const OString sCustomTextPath(
+ static constexpr OString sCustomTextPath(
"//office:document-content/office:body/office:chart/chart:chart/chart:plot-area"
- "/chart:series/chart:data-point[2]/chart:data-label/text:p/text:span");
+ "/chart:series/chart:data-point[2]/chart:data-label/text:p/text:span"_ostr);
assertXPath(pXmlDoc, sCustomTextPath, 1);
// Verify text content