LCOV - code coverage report
Current view: top level - sw/qa/extras/ww8export - ww8export.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 42 42 100.0 %
Date: 2012-08-25 Functions: 13 14 92.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 110 224 49.1 %

           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 <com/sun/star/form/validation/XValidatableFormComponent.hpp>
      31                 :            : #include <com/sun/star/frame/XStorable.hpp>
      32                 :            : #include <com/sun/star/drawing/XControlShape.hpp>
      33                 :            : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      34                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      35                 :            : 
      36                 :            : #include <unotools/tempfile.hxx>
      37                 :            : 
      38                 :            : using rtl::OUString;
      39                 :            : 
      40         [ -  + ]:         27 : class Test : public SwModelTestBase
      41                 :            : {
      42                 :            : public:
      43                 :            :     void testN325936();
      44                 :            :     void testFdo45724();
      45                 :            :     void testFdo46020();
      46                 :            : 
      47 [ +  - ][ +  - ]:          6 :     CPPUNIT_TEST_SUITE(Test);
         [ +  - ][ +  - ]
                 [ #  # ]
      48                 :            : #if !defined(MACOSX) && !defined(WNT)
      49 [ +  - ][ +  - ]:          3 :     CPPUNIT_TEST(testN325936);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      50 [ +  - ][ +  - ]:          3 :     CPPUNIT_TEST(testFdo45724);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      51 [ +  - ][ +  - ]:          3 :     CPPUNIT_TEST(testFdo46020);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      52                 :            : #endif
      53 [ +  - ][ +  - ]:          6 :     CPPUNIT_TEST_SUITE_END();
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      54                 :            : 
      55                 :            : private:
      56                 :            :     void roundtrip(const OUString& rURL);
      57                 :            : };
      58                 :            : 
      59                 :          9 : void Test::roundtrip(const OUString& rFilename)
      60                 :            : {
      61 [ +  - ][ +  - ]:          9 :     uno::Reference<lang::XComponent> xImported = loadFromDesktop(getURLFromSrc("/sw/qa/extras/ww8export/data/") + rFilename);
      62         [ +  - ]:          9 :     uno::Reference<frame::XStorable> xStorable(xImported, uno::UNO_QUERY);
      63         [ +  - ]:          9 :     uno::Sequence<beans::PropertyValue> aArgs(1);
      64         [ +  - ]:          9 :     aArgs[0].Name = "FilterName";
      65 [ +  - ][ +  - ]:          9 :     aArgs[0].Value <<= OUString("MS Word 97");
      66         [ +  - ]:          9 :     utl::TempFile aTempFile;
      67                 :          9 :     aTempFile.EnableKillingFile();
      68 [ +  - ][ +  - ]:          9 :     xStorable->storeToURL(aTempFile.GetURL(), aArgs);
         [ +  - ][ +  - ]
                 [ +  - ]
      69 [ +  - ][ +  - ]:          9 :     mxComponent = loadFromDesktop(aTempFile.GetURL());
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      70                 :          9 : }
      71                 :            : 
      72                 :          3 : void Test::testN325936()
      73                 :            : {
      74                 :            :     /*
      75                 :            :      * The problem was that the transparent background of the drawing in the
      76                 :            :      * header was exported as non-transparent.
      77                 :            :      *
      78                 :            :      * xray ThisComponent.DrawPage(0).BackColorTransparency
      79                 :            :      */
      80                 :            : 
      81         [ +  - ]:          3 :     roundtrip("n325936.doc");
      82         [ +  - ]:          3 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
      83 [ +  - ][ +  - ]:          3 :     uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
                 [ +  - ]
      84 [ +  - ][ +  - ]:          3 :     uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
                 [ +  - ]
      85 [ +  - ][ +  - ]:          3 :     sal_Int32 nValue = getProperty< sal_Int32 >(xDraws->getByIndex(0), "BackColorTransparency");
                 [ +  - ]
      86 [ +  - ][ +  - ]:          3 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(100), nValue);
         [ +  - ][ +  - ]
                 [ +  - ]
      87                 :          3 : }
      88                 :            : 
      89                 :          3 : void Test::testFdo45724()
      90                 :            : {
      91         [ +  - ]:          3 :     roundtrip("fdo45724.odt");
      92         [ +  - ]:          3 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
      93 [ +  - ][ +  - ]:          3 :     uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
                 [ +  - ]
      94 [ +  - ][ +  - ]:          3 :     uno::Reference<drawing::XControlShape> xControlShape(xDraws->getByIndex(0), uno::UNO_QUERY);
                 [ +  - ]
      95 [ +  - ][ +  - ]:          3 :     uno::Reference<form::validation::XValidatableFormComponent> xComponent(xControlShape->getControl(), uno::UNO_QUERY);
                 [ +  - ]
      96 [ +  - ][ +  - ]:          3 :     CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<sal_uInt32>(xComponent, "BackgroundColor"));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      97 [ +  - ][ +  - ]:          3 :     CPPUNIT_ASSERT_EQUAL(OUString("xxx"), xComponent->getCurrentValue().get<OUString>());
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      98                 :          3 : }
      99                 :            : 
     100                 :          3 : void Test::testFdo46020()
     101                 :            : {
     102                 :            :     // The footnote in that document wasn't exported, check that it is actually exported
     103         [ +  - ]:          3 :     roundtrip("fdo46020.odt");
     104         [ +  - ]:          3 :     uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
     105 [ +  - ][ +  - ]:          3 :     uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
                 [ +  - ]
     106 [ +  - ][ +  - ]:          3 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     107                 :          3 : }
     108                 :            : 
     109                 :          3 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
     110                 :            : 
     111 [ +  - ][ +  - ]:         12 : CPPUNIT_PLUGIN_IMPLEMENT();
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
     112                 :            : 
     113                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10