Branch data Line data Source code
1 : : /*
2 : : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
3 : : *
4 : : * The contents of this file are subject to the Mozilla Public License Version
5 : : * 1.1 (the "License"); you may not use this file except in compliance with
6 : : * the License. You may obtain a copy of the License at
7 : : * http://www.mozilla.org/MPL/
8 : : *
9 : : * Software distributed under the License is distributed on an "AS IS" basis,
10 : : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 : : * for the specific language governing rights and limitations under the
12 : : * License.
13 : : *
14 : : * The Initial Developer of the Original Code is
15 : : * Miklos Vajna <vmiklos@suse.cz> (SUSE, Inc.)
16 : : * Portions created by the Initial Developer are Copyright (C) 2012 the
17 : : * Initial Developer. All Rights Reserved.
18 : : *
19 : : * Contributor(s):
20 : : *
21 : : * Alternatively, the contents of this file may be used under the terms of
22 : : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
23 : : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
24 : : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
25 : : * instead of those above.
26 : : */
27 : :
28 : : #include "../swmodeltestbase.hxx"
29 : :
30 : : #include <unotools/tempfile.hxx>
31 : :
32 : : using rtl::OUString;
33 : :
34 [ - + ]: 9 : class Test : public SwModelTestBase
35 : : {
36 : : public:
37 : : void testFdo38244();
38 : :
39 [ + - ][ + - ]: 6 : CPPUNIT_TEST_SUITE(Test);
[ + - ][ + - ]
[ # # ]
40 : : #if !defined(MACOSX) && !defined(WNT)
41 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testFdo38244);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
42 : : #endif
43 [ + - ][ + - ]: 6 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
44 : :
45 : : private:
46 : : void roundtrip(const OUString& rURL);
47 : : };
48 : :
49 : 3 : void Test::roundtrip(const OUString& rFilename)
50 : : {
51 [ + - ][ + - ]: 3 : uno::Reference<lang::XComponent> xImported = loadFromDesktop(getURLFromSrc("/sw/qa/extras/odfexport/data/") + rFilename);
52 [ + - ]: 3 : uno::Reference<frame::XStorable> xStorable(xImported, uno::UNO_QUERY);
53 [ + - ]: 3 : uno::Sequence<beans::PropertyValue> aArgs(1);
54 [ + - ]: 3 : aArgs[0].Name = "FilterName";
55 [ + - ][ + - ]: 3 : aArgs[0].Value <<= OUString("writer8");
56 [ + - ]: 3 : utl::TempFile aTempFile;
57 : 3 : aTempFile.EnableKillingFile();
58 [ + - ][ + - ]: 3 : xStorable->storeToURL(aTempFile.GetURL(), aArgs);
[ + - ][ + - ]
[ + - ]
59 [ + - ]: 3 : uno::Reference<lang::XComponent> xComponent(xStorable, uno::UNO_QUERY);
60 [ + - ][ + - ]: 3 : xComponent->dispose();
61 [ + - ][ + - ]: 3 : mxComponent = loadFromDesktop(aTempFile.GetURL());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
62 : 3 : }
63 : :
64 : 3 : void Test::testFdo38244()
65 : : {
66 : : // See ooxmlexport's testFdo38244().
67 [ + - ]: 3 : roundtrip("fdo38244.odt");
68 : :
69 : : // Test comment range feature.
70 [ + - ]: 3 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
71 [ + - ][ + - ]: 3 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
[ + - ]
72 [ + - ][ + - ]: 3 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
73 [ + - ][ + - ]: 3 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
[ + - ]
74 [ + - ][ + - ]: 3 : uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
75 [ + - ][ + - ]: 3 : xRunEnum->nextElement();
76 [ + - ][ + - ]: 3 : uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
[ + - ]
77 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
[ + - ][ + - ]
[ + - ][ + - ]
78 [ + - ][ + - ]: 3 : xRunEnum->nextElement();
79 [ + - ][ + - ]: 3 : xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
[ + - ]
80 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
[ + - ][ + - ]
[ + - ][ + - ]
81 : :
82 : : // Test properties
83 [ + - ]: 3 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
84 [ + - ][ + - ]: 3 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
85 [ + - ][ + - ]: 3 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
86 [ + - ][ + - ]: 3 : xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
[ + - ]
87 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL(OUString("__Fieldmark__4_1833023242"), getProperty<OUString>(xPropertySet, "Name"));
[ + - ][ + - ]
[ + - ][ + - ]
88 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
[ + - ][ + - ]
[ + - ][ + - ]
89 : 3 : }
90 : :
91 : 3 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
92 : :
93 [ + - ][ + - ]: 12 : CPPUNIT_PLUGIN_IMPLEMENT();
[ + - ][ + - ]
[ + - ][ # # ]
94 : :
95 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|