| 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/drawing/XDrawPageSupplier.hpp> |
| 14 |
#include <com/sun/star/drawing/ColorMode.hpp> |
| 15 |
#include <com/sun/star/text/TextContentAnchorType.hpp> |
| 16 |
|
| 17 |
using namespace ::com::sun::star; |
| 18 |
|
| 19 |
namespace |
| 20 |
{ |
| 21 |
/// Tests for sw/source/writerfilter/rtftok/rtfsdrimport.cxx. |
| 22 |
class Test : public UnoApiTest |
| 23 |
{ |
| 24 |
public: |
| 25 |
Test() |
| 26 |
: UnoApiTest(u"/sw/qa/writerfilter/rtftok/data/"_ustr) |
| 27 |
{ |
| 28 |
} |
| 29 |
}; |
| 30 |
|
| 31 |
CPPUNIT_TEST_FIXTURE(Test, testPictureInTextframe) |
| 32 |
{ |
| 33 |
loadFromFile(u"picture-in-textframe.rtf"); |
| 34 |
uno::Reference<drawing::XDrawPageSupplier> xTextDocument(mxComponent, uno::UNO_QUERY); |
| 35 |
uno::Reference<drawing::XDrawPage> xDrawPage = xTextDocument->getDrawPage(); |
| 36 |
uno::Reference<beans::XPropertySet> xInnerShape(xDrawPage->getByIndex(1), uno::UNO_QUERY); |
| 37 |
text::TextContentAnchorType eAnchorType = text::TextContentAnchorType_AT_PARAGRAPH; |
| 38 |
xInnerShape->getPropertyValue(u"AnchorType"_ustr) >>= eAnchorType; |
| 39 |
// Without the accompanying fix in place, this test would have failed with: |
| 40 |
// - Expected: 1 |
| 41 |
// - Actual : 4 |
| 42 |
// i.e. the properties of the inner shape (including its anchor type and bitmap fill) were lost |
| 43 |
// on import. |
| 44 |
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, eAnchorType); |
| 45 |
} |
| 46 |
|
| 47 |
CPPUNIT_TEST_FIXTURE(Test, testWatermark) |
| 48 |
{ |
| 49 |
// Given a document with a picture watermark, and the "washout" checkbox is ticked on the Word |
| 50 |
// UI: |
| 51 |
loadFromFile(u"watermark.rtf"); |
| 52 |
|
| 53 |
// Then make sure the watermark effect is not lost on import: |
| 54 |
uno::Reference<drawing::XDrawPageSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); |
| 55 |
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPagesSupplier->getDrawPage(); |
| 56 |
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); |
| 57 |
drawing::ColorMode eMode{}; |
| 58 |
xShape->getPropertyValue(u"GraphicColorMode"_ustr) >>= eMode; |
| 59 |
// Without the accompanying fix in place, this test would have failed with: |
| 60 |
// - Expected: 3 |
| 61 |
// - Actual : 0 |
| 62 |
// i.e. the color mode was STANDARD, not WATERMARK. |
| 63 |
CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_WATERMARK, eMode); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
CPPUNIT_PLUGIN_IMPLEMENT(); |
| 68 |
|
| 69 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |