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