update credits
[LibreOffice.git] / chart2 / qa / extras / xshape / chart2xshape.cxx
blob143fe6172404eee3e46323f0032cfb975d4cc973
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "charttest.hxx"
11 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
12 #include <com/sun/star/chart2/CurveStyle.hpp>
13 #include <com/sun/star/chart/ErrorBarStyle.hpp>
14 #include <com/sun/star/chart2/XChartDocument.hpp>
15 #include <com/sun/star/chart/XChartDocument.hpp>
16 #include <com/sun/star/chart/XChartData.hpp>
17 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
18 #include <com/sun/star/chart/XChartDataArray.hpp>
20 #include <com/sun/star/qa/XDumper.hpp>
22 #include <test/xmldiff.hxx>
24 #include <fstream>
26 class Chart2XShapeTest : public ChartTest
28 public:
30 void testFdo75075();
31 void testPropertyMappingBarChart();
33 CPPUNIT_TEST_SUITE(Chart2XShapeTest);
34 CPPUNIT_TEST(testFdo75075);
35 CPPUNIT_TEST(testPropertyMappingBarChart);
36 CPPUNIT_TEST_SUITE_END();
38 private:
40 void compareAgainstReference(const OUString& rReferenceFile, bool bCreateReference = false);
44 namespace {
46 bool checkDumpAgainstFile( const OUString& rDump, const OUString& aFilePath)
48 OString aOFile = OUStringToOString(aFilePath, RTL_TEXTENCODING_UTF8);
50 CPPUNIT_ASSERT_MESSAGE("dump is empty", !rDump.isEmpty());
52 OString aDump = OUStringToOString(rDump, RTL_TEXTENCODING_UTF8);
53 return doXMLDiff(aOFile.getStr(), aDump.getStr(),
54 static_cast<int>(rDump.getLength()), NULL);
59 void Chart2XShapeTest::compareAgainstReference(const OUString& rReferenceFile, bool bCreateReference)
61 uno::Reference< chart::XChartDocument > xChartDoc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
62 uno::Reference< qa::XDumper > xDumper( xChartDoc, UNO_QUERY_THROW );
63 OUString aDump = xDumper->dump();
64 OUString aReference = getPathFromSrc("/chart2/qa/extras/xshape/data/reference/") + rReferenceFile;
65 if(bCreateReference)
67 OString aOFile = OUStringToOString(aReference, RTL_TEXTENCODING_UTF8);
68 OString aODump = OUStringToOString(aDump, RTL_TEXTENCODING_UTF8);
69 std::ofstream aReferenceFile(aOFile.getStr());
70 aReferenceFile << aODump.getStr();
72 else
74 checkDumpAgainstFile(aDump, aReference);
78 void Chart2XShapeTest::testFdo75075()
80 load("chart2/qa/extras/xshape/data/ods/", "fdo75075.ods");
81 compareAgainstReference("fdo75075.xml");
84 void Chart2XShapeTest::testPropertyMappingBarChart()
86 load("chart2/qa/extras/xshape/data/ods/", "property-mapping-bar.ods");
87 compareAgainstReference("property-mapping-bar.xml");
90 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2XShapeTest);
92 CPPUNIT_PLUGIN_IMPLEMENT();
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */