| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 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/. |
| 8 |
*/ |
| 9 |
|
| 10 |
#include <test/unoapi_test.hxx> |
| 11 |
|
| 12 |
#include <com/sun/star/beans/XPropertySet.hpp> |
| 13 |
#include <com/sun/star/text/XTextDocument.hpp> |
| 14 |
|
| 15 |
using namespace ::com::sun::star; |
| 16 |
|
| 17 |
namespace |
| 18 |
{ |
| 19 |
/// Tests for sw/source/writerfilter/dmapper/TextEffectsHandler.cxx. |
| 20 |
class Test : public UnoApiTest |
| 21 |
{ |
| 22 |
public: |
| 23 |
Test() |
| 24 |
: UnoApiTest(u"/sw/qa/writerfilter/dmapper/data/"_ustr) |
| 25 |
{ |
| 26 |
} |
| 27 |
}; |
| 28 |
|
| 29 |
CPPUNIT_TEST_FIXTURE(Test, testSemiTransparentText) |
| 30 |
{ |
| 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(), |
| 35 |
uno::UNO_QUERY); |
| 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(u"CharTransparence"_ustr) >>= nCharTransparence; |
| 43 |
|
| 44 |
// Without the accompanying fix in place, this test would have failed with: |
| 45 |
// - Expected: 74 |
| 46 |
// - Actual : 0 |
| 47 |
// i.e. text was imported as regular text with solid color only. |
| 48 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(74), nCharTransparence); |
| 49 |
} |
| 50 |
|
| 51 |
CPPUNIT_TEST_FIXTURE(Test, testThemeColorTransparency) |
| 52 |
{ |
| 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(), |
| 58 |
uno::UNO_QUERY); |
| 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(u"CharTransparence"_ustr) >>= 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); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |