LCOV - code coverage report
Current view: top level - libreoffice/sw/qa/extras/ww8export - ww8export.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 54 54 100.0 %
Date: 2012-12-27 Functions: 14 15 93.3 %
Legend: Lines: hit not hit

          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 <com/sun/star/form/validation/XValidatableFormComponent.hpp>
      29             : #include <com/sun/star/frame/XStorable.hpp>
      30             : #include <com/sun/star/drawing/XControlShape.hpp>
      31             : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      32             : #include <com/sun/star/beans/XPropertySet.hpp>
      33             : 
      34             : #include <swmodeltestbase.hxx>
      35             : 
      36           3 : class Test : public SwModelTestBase
      37             : {
      38             : public:
      39             :     void testN325936();
      40             :     void testFdo45724();
      41             :     void testFdo46020();
      42             :     void testFirstHeaderFooter();
      43             : 
      44           2 :     CPPUNIT_TEST_SUITE(Test);
      45             : #if !defined(MACOSX) && !defined(WNT)
      46           1 :     CPPUNIT_TEST(run);
      47             : #endif
      48           2 :     CPPUNIT_TEST_SUITE_END();
      49             : 
      50             : private:
      51             :     void run();
      52             : };
      53             : 
      54           1 : void Test::run()
      55             : {
      56             :     MethodEntry<Test> aMethods[] = {
      57             :         {"n325936.doc", &Test::testN325936},
      58             :         {"fdo45724.odt", &Test::testFdo45724},
      59             :         {"fdo46020.odt", &Test::testFdo46020},
      60             :         {"first-header-footer.doc", &Test::testFirstHeaderFooter},
      61           1 :     };
      62           1 :     header();
      63           5 :     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
      64             :     {
      65           4 :         MethodEntry<Test>& rEntry = aMethods[i];
      66           4 :         load("/sw/qa/extras/ww8export/data/", rEntry.pName);
      67             :         // If the testcase is stored in some other format, it's pointless to test.
      68           4 :         if (OString(rEntry.pName).endsWith(".doc"))
      69           2 :             (this->*rEntry.pMethod)();
      70           4 :         reload("MS Word 97");
      71           4 :         (this->*rEntry.pMethod)();
      72           4 :         finish();
      73             :     }
      74           1 : }
      75             : 
      76           2 : void Test::testN325936()
      77             : {
      78             :     /*
      79             :      * The problem was that the transparent background of the drawing in the
      80             :      * header was exported as non-transparent.
      81             :      *
      82             :      * xray ThisComponent.DrawPage(0).BackColorTransparency
      83             :      */
      84             : 
      85           2 :     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<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
      88           2 :     sal_Int32 nValue = getProperty< sal_Int32 >(xDraws->getByIndex(0), "BackColorTransparency");
      89           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(100), nValue);
      90           2 : }
      91             : 
      92           1 : void Test::testFdo45724()
      93             : {
      94             :     // The text and background color of the control shape was not correct.
      95           1 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
      96           1 :     uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
      97           1 :     uno::Reference<drawing::XControlShape> xControlShape(xDraws->getByIndex(0), uno::UNO_QUERY);
      98             :     // This should not happen (the shape was there before the fix as well), but let's avoid a segfault in some random cases...
      99           1 :     if (xControlShape.is())
     100             :     {
     101           1 :         uno::Reference<form::validation::XValidatableFormComponent> xComponent(xControlShape->getControl(), uno::UNO_QUERY);
     102           1 :         CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<sal_uInt32>(xComponent, "BackgroundColor"));
     103           1 :         CPPUNIT_ASSERT_EQUAL(OUString("xxx"), xComponent->getCurrentValue().get<OUString>());
     104           1 :     }
     105           1 : }
     106             : 
     107           1 : void Test::testFdo46020()
     108             : {
     109             :     // The footnote in that document wasn't exported, check that it is actually exported
     110           1 :     uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
     111           1 :     uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
     112           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
     113           1 : }
     114             : 
     115           2 : void Test::testFirstHeaderFooter()
     116             : {
     117             :     // Test import and export of a section's headerf/footerf properties.
     118             : 
     119             :     // The document has 6 pages. Note that we don't test if 4 or just 2 page
     120             :     // styles are created, the point is that layout should be correct.
     121           2 :     CPPUNIT_ASSERT_EQUAL(OUString("First page header"),  parseDump("/root/page[1]/header/txt/text()"));
     122           2 :     CPPUNIT_ASSERT_EQUAL(OUString("First page footer"),  parseDump("/root/page[1]/footer/txt/text()"));
     123           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Even page header"),   parseDump("/root/page[2]/header/txt/text()"));
     124           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"),   parseDump("/root/page[2]/footer/txt/text()"));
     125           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"),  parseDump("/root/page[3]/header/txt/text()"));
     126           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"),  parseDump("/root/page[3]/footer/txt/text()"));
     127           2 :     CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), parseDump("/root/page[4]/header/txt/text()"));
     128           2 :     CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), parseDump("/root/page[4]/footer/txt/text()"));
     129           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), parseDump("/root/page[5]/header/txt/text()"));
     130           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), parseDump("/root/page[5]/footer/txt/text()"));
     131           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"),  parseDump("/root/page[6]/header/txt/text()"));
     132           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"),  parseDump("/root/page[6]/footer/txt/text()"));
     133           2 : }
     134             : 
     135           1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
     136             : 
     137           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10