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 <test/unoapi_test.hxx>
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/text/XTextDocument.hpp>
15 using namespace ::com::sun::star
;
19 /// Tests for writerfilter/source/dmapper/TextEffectsHandler.cxx.
20 class Test
: public UnoApiTest
24 : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
29 CPPUNIT_TEST_FIXTURE(Test
, testSemiTransparentText
)
31 // Load a document with a single paragraph: second text portion has semi-transparent text.
32 loadFromFile(u
"semi-transparent-text.docx");
33 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
34 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(),
36 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
37 uno::Reference
<container::XEnumerationAccess
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
38 uno::Reference
<container::XEnumeration
> xPortionEnum
= xPara
->createEnumeration();
39 xPortionEnum
->nextElement();
40 uno::Reference
<beans::XPropertySet
> xPortion(xPortionEnum
->nextElement(), uno::UNO_QUERY
);
41 sal_Int16 nCharTransparence
= 0;
42 xPortion
->getPropertyValue("CharTransparence") >>= nCharTransparence
;
44 // Without the accompanying fix in place, this test would have failed with:
47 // i.e. text was imported as regular text with solid color only.
48 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(74), nCharTransparence
);
51 CPPUNIT_TEST_FIXTURE(Test
, testThemeColorTransparency
)
53 // Load a document with a single paragraph. It has semi-transparent text and the color is
54 // determined by a w14:schemeClr element.
55 loadFromFile(u
"tdf152884_Char_Transparency.docx");
56 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
57 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(),
59 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
60 uno::Reference
<container::XEnumerationAccess
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
61 uno::Reference
<container::XEnumeration
> xPortionEnum
= xPara
->createEnumeration();
62 sal_Int16 nCharTransparence
= 0;
63 uno::Reference
<beans::XPropertySet
> xPortion(xPortionEnum
->nextElement(), uno::UNO_QUERY
);
64 xPortion
->getPropertyValue("CharTransparence") >>= nCharTransparence
;
65 // Without the fix this test would have failed with: Expected 74, Actual 0
66 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(74), nCharTransparence
);
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */