Line data Source code
1 : /*
2 : * This file is part of the LibreOffice project.
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : */
8 :
9 : #include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
10 : #include <com/sun/star/frame/XStorable.hpp>
11 : #include <com/sun/star/drawing/XControlShape.hpp>
12 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
13 : #include <com/sun/star/beans/XPropertySet.hpp>
14 : #include <com/sun/star/view/XViewSettingsSupplier.hpp>
15 :
16 : #include <swmodeltestbase.hxx>
17 :
18 3 : class Test : public SwModelTestBase
19 : {
20 : public:
21 : void testN325936();
22 : void testFdo45724();
23 : void testFdo46020();
24 : void testFirstHeaderFooter();
25 : void testZoom();
26 : void test56513();
27 : void testNewPageStylesTable();
28 : void testFdo42144();
29 :
30 2 : CPPUNIT_TEST_SUITE(Test);
31 : #if !defined(MACOSX) && !defined(WNT)
32 1 : CPPUNIT_TEST(run);
33 : #endif
34 2 : CPPUNIT_TEST_SUITE_END();
35 :
36 : private:
37 : void run();
38 : };
39 :
40 1 : void Test::run()
41 : {
42 : MethodEntry<Test> aMethods[] = {
43 : {"n325936.doc", &Test::testN325936},
44 : {"fdo45724.odt", &Test::testFdo45724},
45 : {"fdo46020.odt", &Test::testFdo46020},
46 : {"first-header-footer.doc", &Test::testFirstHeaderFooter},
47 : {"zoom.doc", &Test::testZoom},
48 : {"fdo56513.doc", &Test::test56513},
49 : {"new-page-styles.doc", &Test::testNewPageStylesTable},
50 : {"fdo42144.odt", &Test::testFdo42144},
51 1 : };
52 1 : header();
53 9 : for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
54 : {
55 8 : MethodEntry<Test>& rEntry = aMethods[i];
56 8 : load("/sw/qa/extras/ww8export/data/", rEntry.pName);
57 : // If the testcase is stored in some other format, it's pointless to test.
58 8 : if (OString(rEntry.pName).endsWith(".doc"))
59 5 : (this->*rEntry.pMethod)();
60 8 : reload("MS Word 97");
61 8 : (this->*rEntry.pMethod)();
62 8 : finish();
63 : }
64 1 : }
65 :
66 2 : void Test::testN325936()
67 : {
68 : /*
69 : * The problem was that the transparent background of the drawing in the
70 : * header was exported as non-transparent.
71 : *
72 : * xray ThisComponent.DrawPage(0).BackColorTransparency
73 : */
74 :
75 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
76 4 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
77 4 : uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
78 2 : sal_Int32 nValue = getProperty< sal_Int32 >(xDraws->getByIndex(0), "BackColorTransparency");
79 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(100), nValue);
80 2 : }
81 :
82 1 : void Test::testFdo45724()
83 : {
84 : // The text and background color of the control shape was not correct.
85 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
86 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
87 2 : uno::Reference<drawing::XControlShape> xControlShape(xDraws->getByIndex(0), uno::UNO_QUERY);
88 2 : uno::Reference<form::validation::XValidatableFormComponent> xComponent(xControlShape->getControl(), uno::UNO_QUERY);
89 1 : CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<sal_uInt32>(xComponent, "BackgroundColor"));
90 2 : CPPUNIT_ASSERT_EQUAL(OUString("xxx"), xComponent->getCurrentValue().get<OUString>());
91 1 : }
92 :
93 1 : void Test::testFdo46020()
94 : {
95 : // The footnote in that document wasn't exported, check that it is actually exported
96 1 : uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
97 2 : uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
98 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
99 1 : }
100 :
101 2 : void Test::testFirstHeaderFooter()
102 : {
103 : // Test import and export of a section's headerf/footerf properties.
104 :
105 : // The document has 6 pages. Note that we don't test if 4 or just 2 page
106 : // styles are created, the point is that layout should be correct.
107 2 : CPPUNIT_ASSERT_EQUAL(OUString("First page header"), parseDump("/root/page[1]/header/txt/text()"));
108 2 : CPPUNIT_ASSERT_EQUAL(OUString("First page footer"), parseDump("/root/page[1]/footer/txt/text()"));
109 2 : CPPUNIT_ASSERT_EQUAL(OUString("Even page header"), parseDump("/root/page[2]/header/txt/text()"));
110 2 : CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"), parseDump("/root/page[2]/footer/txt/text()"));
111 2 : CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"), parseDump("/root/page[3]/header/txt/text()"));
112 2 : CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"), parseDump("/root/page[3]/footer/txt/text()"));
113 2 : CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), parseDump("/root/page[4]/header/txt/text()"));
114 2 : CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), parseDump("/root/page[4]/footer/txt/text()"));
115 2 : CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), parseDump("/root/page[5]/header/txt/text()"));
116 2 : CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), parseDump("/root/page[5]/footer/txt/text()"));
117 2 : CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"), parseDump("/root/page[6]/header/txt/text()"));
118 2 : CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"), parseDump("/root/page[6]/footer/txt/text()"));
119 2 : }
120 :
121 2 : void Test::testZoom()
122 : {
123 2 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
124 4 : uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
125 4 : uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings());
126 2 : sal_Int16 nValue = 0;
127 2 : xPropertySet->getPropertyValue("ZoomValue") >>= nValue;
128 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue);
129 2 : }
130 :
131 2 : void Test::test56513()
132 : {
133 2 : CPPUNIT_ASSERT_EQUAL(OUString("This is the header of the first section"), parseDump("/root/page[1]/header/txt/text()"));
134 2 : CPPUNIT_ASSERT_EQUAL(OUString("This is the first page header of the second section"), parseDump("/root/page[2]/header/txt/text()"));
135 2 : CPPUNIT_ASSERT_EQUAL(OUString("This is the non-first-page header of the second section"), parseDump("/root/page[3]/header/txt/text()"));
136 2 : }
137 :
138 2 : void Test::testNewPageStylesTable()
139 : {
140 2 : CPPUNIT_ASSERT_EQUAL(OUString("Sigma Space Performance Goals and Results (Page 1)*"), parseDump("/root/page[1]/header/txt/text()"));
141 2 : CPPUNIT_ASSERT_EQUAL(OUString("Sigma Space Performance Assessment (Page 2)****"), parseDump("/root/page[2]/header/txt/text()"));
142 2 : CPPUNIT_ASSERT_EQUAL(OUString("Sigma Space Performance Goals: Next Year (Page 3)*******"), parseDump("/root/page[3]/header/txt/text()"));
143 2 : }
144 :
145 1 : void Test::testFdo42144()
146 : {
147 : // Footer wasn't disabled -- instead empty footer was exported.
148 1 : uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
149 1 : CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(xStyle, "FooterIsOn")));
150 1 : }
151 :
152 1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
153 :
154 4 : CPPUNIT_PLUGIN_IMPLEMENT();
155 :
156 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|