diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-01-15 21:24:17 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-02-24 09:15:07 +0100 |
commit | dbb0567d3211ae0e9e046c3d107f37480953b373 (patch) | |
tree | fd8aa117c72cc2cdcdb7ec8b51ce0e178e36c9d3 /writerfilter/qa | |
parent | ebb62117e62d332fa9900b1adcc1a313f12df3e3 (diff) |
sw: add DOCX import for semi-transparent text
This is one of the text effects properties, which is already
grab-bagged. That is done in a generic way, so the easiest is to just
read the value from the grab-bag, rather than from the dmapper tokens
directly.
(cherry picked from commit 3a749d7278bbe65cfc063e64460df8af6bc2af47)
Conflicts:
writerfilter/CppunitTest_writerfilter_dmapper.mk
writerfilter/source/dmapper/PropertyIds.cxx
writerfilter/source/dmapper/PropertyIds.hxx
Change-Id: Id74a3eb0abddf745a9e4e59625bf9345f7df9dfe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89220
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter/qa')
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx | 78 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/data/semi-transparent-text.docx | bin | 0 -> 12738 bytes |
2 files changed, 78 insertions, 0 deletions
diff --git a/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx b/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx new file mode 100644 index 000000000000..1678aac52773 --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <test/bootstrapfixture.hxx> +#include <unotest/macros_test.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/text/XTextDocument.hpp> + +#include <comphelper/processfactory.hxx> + +using namespace ::com::sun::star; + +namespace +{ +/// Tests for writerfilter/source/dmapper/TextEffectsHandler.cxx. +class Test : public test::BootstrapFixture, public unotest::MacrosTest +{ +private: + uno::Reference<uno::XComponentContext> mxComponentContext; + uno::Reference<lang::XComponent> mxComponent; + +public: + void setUp() override; + void tearDown() override; + uno::Reference<lang::XComponent>& getComponent() { return mxComponent; } +}; + +void Test::setUp() +{ + test::BootstrapFixture::setUp(); + + mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory())); + mxDesktop.set(frame::Desktop::create(mxComponentContext)); +} + +void Test::tearDown() +{ + if (mxComponent.is()) + mxComponent->dispose(); + + test::BootstrapFixture::tearDown(); +} + +char const DATA_DIRECTORY[] = "/writerfilter/qa/cppunittests/dmapper/data/"; + +CPPUNIT_TEST_FIXTURE(Test, testSemiTransparentText) +{ + // Load a document with a single paragraph: second text portion has semi-transparent text. + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "semi-transparent-text.docx"; + getComponent() = loadFromDesktop(aURL); + uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<container::XEnumerationAccess> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xPortionEnum = xPara->createEnumeration(); + xPortionEnum->nextElement(); + uno::Reference<beans::XPropertySet> xPortion(xPortionEnum->nextElement(), uno::UNO_QUERY); + sal_Int16 nCharTransparence = 0; + xPortion->getPropertyValue("CharTransparence") >>= nCharTransparence; + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 74 + // - Actual : 0 + // i.e. text was imported as regular text with solid color only. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(74), nCharTransparence); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/qa/cppunittests/dmapper/data/semi-transparent-text.docx b/writerfilter/qa/cppunittests/dmapper/data/semi-transparent-text.docx Binary files differnew file mode 100644 index 000000000000..6c0f8a79cbb4 --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/data/semi-transparent-text.docx |