[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - chart2/qa
Szymon Kłos
szymon.klos at collabora.com
Thu Mar 15 15:59:55 UTC 2018
chart2/qa/extras/chart2import.cxx | 97 ++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
New commits:
commit 5c9cd49df8e806d1f0bfd62f62ba057d54186ee8
Author: Szymon Kłos <szymon.klos at collabora.com>
Date: Tue Mar 6 11:33:16 2018 +0100
tdf#116163 import test
Change-Id: Ie4fd1142e1111e4968941a639a265d169aaa6413
Reviewed-on: https://gerrit.libreoffice.org/50814
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/50831
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index a49e80e1b867..8a67b4e4349b 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -23,6 +23,9 @@
#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include <com/sun/star/chart2/TickmarkStyle.hpp>
#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <iterator>
#include <com/sun/star/util/Color.hpp>
@@ -98,6 +101,7 @@ public:
void testTdf109858(); // Pie chart label placement settings(XLSX)
void testTdf111173();
+ void testTdf116163();
void testInternalDataProvider();
@@ -157,6 +161,7 @@ public:
CPPUNIT_TEST(testTdf90510);
CPPUNIT_TEST(testTdf109858);
CPPUNIT_TEST(testTdf111173);
+ CPPUNIT_TEST(testTdf116163);
CPPUNIT_TEST(testInternalDataProvider);
@@ -166,6 +171,31 @@ private:
};
+uno::Reference<drawing::XShape> getShapeByName(const uno::Reference<drawing::XShapes>& rShapes,
+ const OUString& rName,
+ std::function<bool(const uno::Reference<drawing::XShape>&)> pCondition = nullptr)
+{
+ uno::Reference<container::XIndexAccess> XIndexAccess(rShapes, uno::UNO_QUERY);
+ for (sal_Int32 i = 0; i < XIndexAccess->getCount(); ++i)
+ {
+ uno::Reference<drawing::XShapes> xShapes(XIndexAccess->getByIndex(i), uno::UNO_QUERY);
+ if (xShapes.is())
+ {
+ uno::Reference<drawing::XShape> xRet = getShapeByName(xShapes, rName, pCondition);
+ if (xRet.is())
+ return xRet;
+ }
+ uno::Reference<container::XNamed> xNamedShape(XIndexAccess->getByIndex(i), uno::UNO_QUERY);
+ if (xNamedShape->getName() == rName)
+ {
+ uno::Reference<drawing::XShape> xShape(xNamedShape, uno::UNO_QUERY);
+ if (pCondition == nullptr || pCondition(xShape))
+ return xShape;
+ }
+ }
+ return uno::Reference<drawing::XShape>();
+}
+
// error bar import
// split method up into smaller chunks for more detailed tests
void Chart2ImportTest::Fdo60083()
@@ -1317,6 +1347,73 @@ void Chart2ImportTest::testTdf111173()
CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart1Doc.is() );
}
+void Chart2ImportTest::testTdf116163()
+{
+ load("/chart2/qa/extras/data/pptx/", "tdf116163.pptx");
+
+ Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ Reference<chart2::XAxis> xHAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
+ CPPUNIT_ASSERT(xHAxis.is());
+
+ chart2::ScaleData aScaleData = xHAxis->getScaleData();
+ CPPUNIT_ASSERT(aScaleData.Categories.is());
+
+ Reference<chart2::data::XLabeledDataSequence> xLabeledDataSequence = aScaleData.Categories;
+ CPPUNIT_ASSERT(xLabeledDataSequence.is());
+
+ Reference<chart2::data::XDataSequence> xDataSequence = xLabeledDataSequence->getValues();
+ CPPUNIT_ASSERT(xDataSequence.is());
+
+ Reference<chart2::data::XTextualDataSequence> xTextualDataSequence(xDataSequence, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xTextualDataSequence.is());
+
+ std::vector<OUString> aCategories;
+ Sequence<OUString> aTextData(xTextualDataSequence->getTextualData());
+ ::std::copy(aTextData.begin(), aTextData.end(),
+ ::std::back_inserter(aCategories));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Aaaa"), aCategories[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Bbbbbbb"), aCategories[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Ccc"), aCategories[2]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Ddddddddddddd"), aCategories[3]);
+
+ // Check visible text
+
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xShapes.is());
+
+ const OUString sXAxisName = "CID/D=0:CS=0:Axis=0,0";
+ uno::Reference<drawing::XShape> xXAxis = getShapeByName(xShapes, sXAxisName,
+ // Axis occurs twice in chart xshape representation so need to get the one related to labels
+ [](const uno::Reference<drawing::XShape>& rXShape) -> bool
+ {
+ uno::Reference<drawing::XShapes> xAxisShapes(rXShape, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xAxisShapes.is());
+ uno::Reference<drawing::XShape> xChildShape(xAxisShapes->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xChildShape, uno::UNO_QUERY_THROW);
+ return (xShapeDescriptor->getShapeType() == "com.sun.star.drawing.TextShape");
+ });
+ CPPUNIT_ASSERT(xXAxis.is());
+
+ uno::Reference<container::XIndexAccess> xIndexAccess(xXAxis, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xIndexAccess.is());
+
+ // Check text
+ uno::Reference<text::XTextRange> xLabel0(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Aaaa"), xLabel0->getString());
+ uno::Reference<text::XTextRange> xLabel1(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
+ // If there is space for 3 chars only then don't show "..."
+ CPPUNIT_ASSERT_EQUAL(OUString("Bbb"), xLabel1->getString());
+ uno::Reference<text::XTextRange> xLabel2(xIndexAccess->getByIndex(2), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Ccc"), xLabel2->getString());
+ uno::Reference<text::XTextRange> xLabel3(xIndexAccess->getByIndex(3), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Dddd..."), xLabel3->getString());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list