1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/* -*- 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 <swmodeltestbase.hxx>
#include <o3tl/string_view.hxx>
#include <docmodel/uno/UnoComplexColor.hxx>
#include <docmodel/color/ComplexColor.hxx>
class Test : public SwModelTestBase
{
public:
Test()
: SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text")
{
}
};
DECLARE_SW_ROUNDTRIP_TEST(testThemePortionLevelCharColor_ODF,
"Test_ThemePortionLevel_CharColor.fodt", nullptr, Test)
{
auto xParagraph = getParagraph(1);
CPPUNIT_ASSERT(xParagraph.is());
auto xComplexColor = getProperty<uno::Reference<util::XComplexColor>>(getRun(xParagraph, 1),
"CharComplexColor");
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getThemeColorType());
auto const& rTransforms = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint, rTransforms[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTransforms[0].mnValue);
}
DECLARE_SW_ROUNDTRIP_TEST(testThemePortionLevelCharColor_DOCX,
"Test_ThemePortionLevel_CharColor.docx", nullptr, Test)
{
auto xParagraph = getParagraph(1);
CPPUNIT_ASSERT(xParagraph.is());
auto xComplexColor = getProperty<uno::Reference<util::XComplexColor>>(getRun(xParagraph, 1),
"CharComplexColor");
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getThemeColorType());
auto const& rTransforms = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint, rTransforms[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTransforms[0].mnValue);
}
DECLARE_SW_ROUNDTRIP_TEST(testThemePortionBorderColor_DOCX, "Test_ThemeBorderColor.docx", nullptr,
Test)
{
auto xParagraph = getParagraph(1);
CPPUNIT_ASSERT(xParagraph.is());
{
auto xComplexColor
= getProperty<uno::Reference<util::XComplexColor>>(xParagraph, "TopBorderComplexColor");
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getThemeColorType());
auto const& rTransforms = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint, rTransforms[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTransforms[0].mnValue);
}
{
auto xComplexColor = getProperty<uno::Reference<util::XComplexColor>>(
xParagraph, "BottomBorderComplexColor");
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent4, aComplexColor.getThemeColorType());
auto const& rTransforms = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint, rTransforms[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTransforms[0].mnValue);
}
CPPUNIT_ASSERT(isPropertyVoid(xParagraph, "LeftBorderComplexColor"));
CPPUNIT_ASSERT(isPropertyVoid(xParagraph, "RightBorderComplexColor"));
}
DECLARE_SW_ROUNDTRIP_TEST(testCharUnderlineTheme_DOCX, "Test_CharUnderlineThemeColor.docx", nullptr,
Test)
{
auto xParagraph = getParagraph(1);
CPPUNIT_ASSERT(xParagraph.is());
auto xRun = getRun(xParagraph, 1);
auto xComplexColor
= getProperty<uno::Reference<util::XComplexColor>>(xRun, "CharUnderlineComplexColor");
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getThemeColorType());
auto const& rTransforms = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::Shade, rTransforms[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(2509), rTransforms[0].mnValue);
}
DECLARE_SW_ROUNDTRIP_TEST(testParaBackgroundTheme_DOCX, "Test_ThemeTextParaBackgroundColor.docx",
nullptr, Test)
{
{
auto xParagraph = getParagraph(1);
CPPUNIT_ASSERT(xParagraph.is());
auto xComplexColor = getProperty<uno::Reference<util::XComplexColor>>(
xParagraph, "ParaBackgroundComplexColor");
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType());
auto const& rTransforms = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint, rTransforms[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTransforms[0].mnValue);
}
{
auto xParagraph = getParagraph(2);
CPPUNIT_ASSERT(xParagraph.is());
auto xComplexColor = getProperty<uno::Reference<util::XComplexColor>>(
xParagraph, "ParaBackgroundComplexColor");
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getThemeColorType());
auto const& rTransforms = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint, rTransforms[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTransforms[0].mnValue);
}
{
auto xParagraph = getParagraph(3);
CPPUNIT_ASSERT(xParagraph.is());
auto xComplexColor = getProperty<uno::Reference<util::XComplexColor>>(
xParagraph, "ParaBackgroundComplexColor");
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType());
auto const& rTransforms = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint, rTransforms[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTransforms[0].mnValue);
}
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|