Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : */
9 :
10 : #include <sal/config.h>
11 : #include <test/bootstrapfixture.hxx>
12 :
13 : #include <xmloff/xmlexp.hxx>
14 : #include <xmloff/xmltoken.hxx>
15 : #include <xmloff/xmlaustp.hxx>
16 : #include "SchXMLExport.hxx"
17 : #include "XMLChartPropertySetMapper.hxx"
18 : #include "impastpl.hxx"
19 : #include <comphelper/processfactory.hxx>
20 : #include <com/sun/star/util/MeasureUnit.hpp>
21 :
22 : using namespace ::xmloff::token;
23 : using namespace ::com::sun::star;
24 :
25 4 : class Test : public test::BootstrapFixture {
26 : public:
27 : Test();
28 :
29 : virtual void setUp() SAL_OVERRIDE;
30 : virtual void tearDown() SAL_OVERRIDE;
31 :
32 : void testAutoStylePool();
33 :
34 4 : CPPUNIT_TEST_SUITE(Test);
35 2 : CPPUNIT_TEST(testAutoStylePool);
36 4 : CPPUNIT_TEST_SUITE_END();
37 : private:
38 : SvXMLExport *pExport;
39 : };
40 :
41 2 : Test::Test()
42 2 : : pExport( NULL )
43 : {
44 2 : }
45 :
46 2 : void Test::setUp()
47 : {
48 2 : BootstrapFixture::setUp();
49 :
50 : pExport = new SchXMLExport(
51 : comphelper::getProcessComponentContext(), "SchXMLExport.Compact",
52 2 : EXPORT_ALL);
53 2 : }
54 :
55 2 : void Test::tearDown()
56 : {
57 2 : delete pExport;
58 2 : BootstrapFixture::tearDown();
59 2 : }
60 :
61 2 : void Test::testAutoStylePool()
62 : {
63 : rtl::Reference< SvXMLAutoStylePoolP > xPool(
64 2 : new SvXMLAutoStylePoolP( *pExport ) );
65 : rtl::Reference< XMLPropertySetMapper > xSetMapper(
66 4 : new XMLChartPropertySetMapper( true) );
67 : rtl::Reference< XMLChartExportPropertyMapper > xExportPropMapper(
68 4 : new XMLChartExportPropertyMapper( xSetMapper, *pExport ) );
69 :
70 : xPool->AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
71 2 : GetXMLToken( XML_PARAGRAPH ),
72 2 : xExportPropMapper.get(),
73 4 : OUString( "Bob" ) );
74 :
75 4 : std::vector< XMLPropertyState > aProperties;
76 4 : OUString aName = xPool->Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, "", aProperties );
77 :
78 : // not that interesting but worth checking
79 2 : bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != NULL);
80 2 : if (bHack)
81 0 : CPPUNIT_ASSERT_MESSAGE( "style / naming changed", aName == "Bob" );
82 : else
83 2 : CPPUNIT_ASSERT_MESSAGE( "style / naming changed", aName == "Bob1" );
84 :
85 : // find ourselves again:
86 4 : OUString aSameName = xPool->Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, "", aProperties );
87 4 : CPPUNIT_ASSERT_MESSAGE( "same style not found", aSameName == aName );
88 2 : }
89 :
90 2 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
91 :
92 8 : CPPUNIT_PLUGIN_IMPLEMENT();
93 :
94 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|