1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <sal/config.h>
11 #include <test/bootstrapfixture.hxx>
13 #include <com/sun/star/beans/PropertyAttribute.hpp>
14 #include <com/sun/star/beans/XPropertySet.hpp>
16 #include <comphelper/genericpropertyset.hxx>
17 #include <comphelper/propertysetinfo.hxx>
19 #include <xmloff/maptype.hxx>
20 #include <xmloff/xmlimp.hxx>
21 #include <xmloff/xmlmetai.hxx>
22 #include <xmloff/xmlexp.hxx>
23 #include <xmloff/xmltoken.hxx>
24 #include <xmloff/xmlaustp.hxx>
25 #include <SchXMLExport.hxx>
26 #include <XMLChartPropertySetMapper.hxx>
27 #include <comphelper/processfactory.hxx>
29 using namespace ::xmloff::token
;
30 using namespace ::com::sun::star
;
32 class Test
: public test::BootstrapFixture
{
36 virtual void setUp() override
;
37 virtual void tearDown() override
;
39 void testAutoStylePool();
40 void testMetaGenerator();
42 CPPUNIT_TEST_SUITE(Test
);
43 CPPUNIT_TEST(testAutoStylePool
);
44 CPPUNIT_TEST(testMetaGenerator
);
45 CPPUNIT_TEST_SUITE_END();
47 rtl::Reference
<SvXMLExport
> pExport
;
56 BootstrapFixture::setUp();
58 pExport
= new SchXMLExport(
59 comphelper::getProcessComponentContext(), u
"SchXMLExport.Compact"_ustr
,
60 SvXMLExportFlags::ALL
);
66 BootstrapFixture::tearDown();
69 void Test::testAutoStylePool()
71 rtl::Reference
< SvXMLAutoStylePoolP
> xPool(
72 new SvXMLAutoStylePoolP( *pExport
) );
73 rtl::Reference
< XMLPropertySetMapper
> xSetMapper(
74 new XMLChartPropertySetMapper(pExport
.get()) );
75 rtl::Reference
< XMLChartExportPropertyMapper
> xExportPropMapper(
76 new XMLChartExportPropertyMapper( xSetMapper
, *pExport
) );
78 xPool
->AddFamily( XmlStyleFamily::TEXT_PARAGRAPH
,
79 GetXMLToken( XML_PARAGRAPH
),
80 xExportPropMapper
.get(),
83 OUString aName
= xPool
->Add( XmlStyleFamily::TEXT_PARAGRAPH
, u
""_ustr
, {} );
85 // not that interesting but worth checking
86 bool bHack
= (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != nullptr);
88 CPPUNIT_ASSERT_EQUAL_MESSAGE( "style / naming changed", u
"Bob"_ustr
, aName
);
90 CPPUNIT_ASSERT_EQUAL_MESSAGE( "style / naming changed", u
"Bob1"_ustr
, aName
);
92 // find ourselves again:
93 OUString aSameName
= xPool
->Find( XmlStyleFamily::TEXT_PARAGRAPH
, u
""_ustr
, {} );
94 CPPUNIT_ASSERT_EQUAL_MESSAGE( "same style not found", aName
, aSameName
);
97 void Test::testMetaGenerator()
99 comphelper::PropertyMapEntry
const aInfoMap
[] = {
100 { u
"BuildId"_ustr
, 0, ::cppu::UnoType
<OUString
>::get(), beans::PropertyAttribute::MAYBEVOID
, 0 },
102 uno::Reference
<beans::XPropertySet
> const xInfoSet(
103 comphelper::GenericPropertySet_CreateInstance(
104 new comphelper::PropertySetInfo(aInfoMap
)));
107 char const*const generator
;
108 char const*const buildId
;
109 sal_uInt16
const result
;
112 { "AbiWord/2.8.6 (unix, gtk)", "", SvXMLImport::ProductVersionUnknown
},
113 { "Aspose.Words for Java 13.10.0.0", "", SvXMLImport::ProductVersionUnknown
},
114 { "CIB jsmerge 1.0.0", "", SvXMLImport::ProductVersionUnknown
},
115 { "Calligra/2.4.3", "", SvXMLImport::ProductVersionUnknown
},
116 { "CocoaODFWriter/1339", "", SvXMLImport::ProductVersionUnknown
},
117 { "KOffice/1.4.1", "", SvXMLImport::ProductVersionUnknown
},
118 { "KPresenter 1.3", "", SvXMLImport::ProductVersionUnknown
},
119 { "KSpread 1.3.2", "", SvXMLImport::ProductVersionUnknown
},
120 { "Lotus Symphony/1.2.0_20081023.1730/Win32", "", SvXMLImport::ProductVersionUnknown
},
121 { "Microsoft Excel Online", "", SvXMLImport::ProductVersionUnknown
},
122 { "MicrosoftOffice/12.0 MicrosoftExcel/CalculationVersion-4518", "", SvXMLImport::ProductVersionUnknown
},
123 { "MicrosoftOffice/15.0 MicrosoftWord", "", SvXMLImport::ProductVersionUnknown
},
124 { "ODF Converter v1.0.0", "", SvXMLImport::ProductVersionUnknown
},
125 { "ODF::lpOD 1.121", "", SvXMLImport::ProductVersionUnknown
},
126 { "ODFDOM/0.6.1$Build-1", "", SvXMLImport::ProductVersionUnknown
},
127 { "ODFPY/0.9.6", "", SvXMLImport::ProductVersionUnknown
},
128 { "OpenXML/ODF Translator Command Line Tool 3.0 2.0.0", "", SvXMLImport::ProductVersionUnknown
},
129 { "Org-7.8.03/Emacs-24.0.93.1", "", SvXMLImport::ProductVersionUnknown
},
130 { "TeX4ht from eqns_long.tex, options: xhtml,ooffice,refcaption", "", SvXMLImport::ProductVersionUnknown
},
131 { "TextMaker", "", SvXMLImport::ProductVersionUnknown
},
132 { "docbook2odf generator (http://open.comsultia.com/docbook2odf/)", "", SvXMLImport::ProductVersionUnknown
},
133 { "fig2sxd", "", SvXMLImport::ProductVersionUnknown
},
134 { "gnumeric/1.10.9", "", SvXMLImport::ProductVersionUnknown
},
135 { "libodfgen/0.1.6", "", SvXMLImport::ProductVersionUnknown
},
138 { "StarSuite 6.0 (Linux)", "645$8687", SvXMLImport::OOo_1x
},
139 { "StarOffice 6.1 (Win32)", "645$8687", SvXMLImport::OOo_1x
},
140 { "OpenOffice.org 1.1.2RC3.DE (Win32)", "645$8687", SvXMLImport::OOo_1x
},
141 { "OpenOffice.org 1.1.5 (Win32)", "645$8687", SvXMLImport::OOo_1x
},
142 { "StarOffice 7 (Win32)", "645$8687", SvXMLImport::OOo_1x
},
145 { "Sun_ODF_Plugin_for_Microsoft_Office/1.1$Win32 OpenOffice.org_project/680m5$Build-9221", "680$9221", SvXMLImport::OOo_2x
},
146 { "StarSuite/8$Win32 OpenOffice.org_project/680m6$Build-9095", "680$9095", SvXMLImport::OOo_2x
},
147 { "StarOffice/8$Win32 OpenOffice.org_project/680m93$Build-8897", "680$8897", SvXMLImport::OOo_2x
},
148 { "OpenOffice.org/2.0$Linux OpenOffice.org_project/680m3$Build-8968", "680$8968", SvXMLImport::OOo_2x
},
149 { "OpenOffice.org/2.1$Win32 OpenOffice.org_project/680m6$Build-9095", "680$9095", SvXMLImport::OOo_2x
},
150 { "OpenOffice.org/2.4$Win32 OpenOffice.org_project/680m248$Build-9274", "680$9274", SvXMLImport::OOo_2x
},
153 { "OpenOffice.org/3.0$Solaris_Sparc OpenOffice.org_project/300m9$Build-9358", "300$9358", SvXMLImport::OOo_30x
},
154 { "StarSuite/9$Unix OpenOffice.org_project/300m9$Build-9358", "300$9358", SvXMLImport::OOo_30x
},
155 { "StarOffice/9$Win32 OpenOffice.org_project/300m14$Build-9376", "300$9376", SvXMLImport::OOo_30x
},
156 { "OpenOffice.org/3.1$Solaris_x86 OpenOffice.org_project/310m11$Build-9399", "310$9399", SvXMLImport::OOo_31x
},
157 { "IBM_Lotus_Symphony/2.0$Win32 OpenOffice.org_project/310m11$Build-9399", "310$9399", SvXMLImport::OOo_31x
},
158 { "BrOffice.org/3.1$Linux OpenOffice.org_project/310m11$Build-9399", "310$9399", SvXMLImport::OOo_31x
},
159 { "StarOffice/9$Solaris_Sparc OpenOffice.org_project/310m19$Build-9420", "310$9420", SvXMLImport::OOo_31x
},
160 { "OpenOffice.org/3.2$Linux OpenOffice.org_project/320m12$Build-9483", "320$9483", SvXMLImport::OOo_32x
},
161 { "StarOffice/9$Win32 OpenOffice.org_project/320m12$Build-9483", "320$9483", SvXMLImport::OOo_32x
},
162 { "OpenOffice.org/3.3$Linux OpenOffice.org_project/330m20$Build-9567", "330$9567", SvXMLImport::OOo_33x
},
163 { "Oracle_Open_Office/3.3$Win32 OpenOffice.org_project/330m7$Build-9552", "330$9552", SvXMLImport::OOo_33x
},
164 { "OpenOffice.org/3.4$Unix OpenOffice.org_project/340m1$Build-9590", "340$9590", SvXMLImport::OOo_34x
},
167 { "OpenOffice/4.0.0$Win32 OpenOffice.org_project/400m3$Build-9702", "400$9702", SvXMLImport::AOO_40x
},
168 { "OpenOffice/4.0.1$Linux OpenOffice.org_project/401m4$Build-9713", "401$9713", SvXMLImport::AOO_40x
},
169 { "OpenOffice/4.1.1$FreeBSD/amd64 OpenOffice.org_project/411m6$Build-9775", "411$9775", SvXMLImport::AOO_4x
},
170 { "OpenOffice/4.1.2$OS/2 OpenOffice.org_project/412m3$Build-9782-bww", "412$9782-bww", SvXMLImport::AOO_4x
},
171 { "OpenOffice/4.1.4$Unix OpenOffice.org_project/414m2$Build-9785", "414$9785", SvXMLImport::AOO_4x
},
174 { "LibreOffice/3.3$Linux LibreOffice_project/330m17$Build-3", "330$3;3.3", SvXMLImport::LO_3x
},
175 { "BrOffice/3.3$Win32 LibreOffice_project/330m19$Build-8", "330$8;3.3", SvXMLImport::LO_3x
},
176 { "LibreOffice/3.4$Linux LibreOffice_project/340m1$Build-1206", "340$1206;3.4", SvXMLImport::LO_3x
},
177 { "LibreOffice/3.5$Linux_X86_64 LibreOffice_project/3fa2330-e49ffd2-90d118b-705e248-051e21c", ";3.5", SvXMLImport::LO_3x
},
178 { "LibreOffice/3.6$Windows_x86 LibreOffice_project/a9a0717-273e462-768e6e3-978247f-65e65f", ";3.6", SvXMLImport::LO_3x
},
179 { "LibreOffice/4.0.2.2$Windows_x86 LibreOffice_project/4c82dcdd6efcd48b1d8bba66bfe1989deee49c3", ";4.0.2.2", SvXMLImport::LO_41x
},
180 { "LibreOffice/4.1.2.3$MacOSX_x86 LibreOffice_project/40b2d7fde7e8d2d7bc5a449dc65df4d08a7dd38", ";4.1.2.3", SvXMLImport::LO_41x
},
181 { "LibreOffice/4.2.8.2$Windows_x86 LibreOffice_project/48d50dbfc06349262c9d50868e5c1f630a573ebd", ";4.2.8.2", SvXMLImport::LO_42x
},
182 { "LibreOffice_from_Collabora_4.2-8/4.2.10.8$Linux_x86 LibreOffice_project/84584cc237b2eb93f7684d8fcd063bb37e87b5fb", ";4.2.10.8", SvXMLImport::LO_42x
},
183 { "LibreOffice/4.3.3.2$Linux_x86 LibreOffice_project/9bb7eadab57b6755b1265afa86e04bf45fbfc644", ";4.3.3.2", SvXMLImport::LO_43x
},
184 { "LibreOffice_from_Collabora_4.4-10/4.4.10.9$Linux_x86 LibreOffice_project/5600b19b88a01bbb669b0900100760758dff8c26", ";4.4.10.9", SvXMLImport::LO_44x
},
185 { "LibreOffice/4.3.3.2$Linux_X86_64 LibreOffice_project/430m0$Build-2", "430$2;4.3.3.2", SvXMLImport::LO_43x
},
186 { "LibreOffice/4.4.3.2$Linux_x86 LibreOffice_project/88805f81e9fe61362df02b9941de8e38a9b5fd16", ";4.4.3.2", SvXMLImport::LO_44x
},
187 { "LibreOffice/5.0.1.1$Linux_x86 LibreOffice_project/00m0$Build-1", "00$1;5.0.1.1", SvXMLImport::LO_5x
},
188 { "LibreOffice/5.0.3.2$Windows_X86_64 LibreOffice_project/e5f16313668ac592c1bfb310f4390624e3dbfb75", ";5.0.3.2", SvXMLImport::LO_5x
},
189 { "Collabora_Office/5.0.10.19$Linux_X86_64 LibreOffice_project/95060d44300d8866fa81c16fc8fe2afe22d63777", ";5.0.10.19", SvXMLImport::LO_5x
},
190 { "LibreOffice/5.1.6.2.0$Linux_X86_64 LibreOffice_project/10$Build-2", ";5.1.6.2.0", SvXMLImport::LO_5x
},
191 { "Collabora_Office/5.1.10.17$Linux_X86_64 LibreOffice_project/a104cbe76eefca3cf23973da68893d2225fd718b", ";5.1.10.17", SvXMLImport::LO_5x
},
192 { "LibreOffice/5.2.1.2$Windows_X86_64 LibreOffice_project/31dd62db80d4e60af04904455ec9c9219178d620", ";5.2.1.2", SvXMLImport::LO_5x
},
193 { "LibreOffice_Vanilla/5.2.3.5$MacOSX_X86_64 LibreOffice_project/83adc9c35c74e0badc710d981405858b1179a327", ";5.2.3.5", SvXMLImport::LO_5x
},
194 { "LibreOffice/5.3.4.2$Windows_X86_64 LibreOffice_project/f82d347ccc0be322489bf7da61d7e4ad13fe2ff3", ";5.3.4.2", SvXMLImport::LO_5x
},
195 { "Collabora_Office/5.3.10.27$Linux_X86_64 LibreOffice_project/7a5a5378661e338a44666c08773cc796b8d1c84a", ";5.3.10.27", SvXMLImport::LO_5x
},
196 { "LibreOfficeDev/5.4.7.0.0$Linux_X86_64 LibreOffice_project/ba7461fc88c08e75e315f786020a2946e56166c9", ";5.4.7.0.0", SvXMLImport::LO_5x
},
197 { "LibreOfficeDev/6.0.3.0.0$Linux_X86_64 LibreOffice_project/34442b85bfb0c451738b4db023345a7484463321", ";6.0.3.0.0", SvXMLImport::LO_6x
},
198 { "LibreOffice_powered_by_CIBDev/6.3.9.0.0$Linux_X86_64 LibreOffice_project/c87f331d2900eab70ac3021cbe530926efa6499f", ";6.3.9.0.0", SvXMLImport::LO_63x
},
199 { "LibreOffice_powered_by_CIBDev/6.4.0.0.0$Linux_X86_64 LibreOffice_project/e29e100174c133d27e953934311d68602c4515b7", ";6.4.0.0.0", SvXMLImport::LO_63x
},
200 { "LibreOfficeDev/7.0.6.0.0$Linux_X86_64 LibreOffice_project/dfc40e2292c6e19e285c10ed8c8044d9454107d0", ";7.0.6.0.0", SvXMLImport::LO_7x
},
201 { "CIB_OfficeDev/6.4.0.19$Linux_X86_64 LibreOffice_project/2e04f804b5f82770435f250873f07b3384d95504", ";6.4.0.19", SvXMLImport::LO_63x
},
202 { "LibreOfficeDev/24.2.0.0.alpha0$Linux_X86_64 LibreOffice_project/b81e7b6f3c71fb3ade1cb665444ac730dac0a9a9", ";24.2.0.0.", SvXMLImport::LO_New
},
205 for (auto const[pGenerator
, pBuildId
, nResult
] : tests
)
207 // the DocumentInfo instance is cached so need fresh SvXMLImport
208 rtl::Reference
<SvXMLImport
> const pImport(new SvXMLImport(
209 comphelper::getProcessComponentContext(), u
"testdummy"_ustr
,
210 SvXMLImportFlags::ALL
));
212 pImport
->initialize(uno::Sequence
<uno::Any
>{ uno::Any(xInfoSet
) });
214 SvXMLMetaDocumentContext::setBuildId(OUString::createFromAscii(pGenerator
), xInfoSet
);
215 if (pBuildId
[0] != '\0')
217 CPPUNIT_ASSERT_EQUAL_MESSAGE(pGenerator
,
218 OUString::createFromAscii(pBuildId
),
219 xInfoSet
->getPropertyValue(u
"BuildId"_ustr
).get
<OUString
>());
223 CPPUNIT_ASSERT_MESSAGE(pGenerator
, !xInfoSet
->getPropertyValue(u
"BuildId"_ustr
).hasValue());
225 CPPUNIT_ASSERT_EQUAL_MESSAGE(pGenerator
, nResult
, pImport
->getGeneratorVersion());
229 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
231 CPPUNIT_PLUGIN_IMPLEMENT();
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */