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 <swmodeltestbase.hxx>
11 #include <o3tl/string_view.hxx>
12 #include <docmodel/uno/UnoComplexColor.hxx>
13 #include <docmodel/color/ComplexColor.hxx>
15 class Test
: public SwModelTestBase
19 : SwModelTestBase(u
"/sw/qa/extras/ooxmlexport/data/"_ustr
, u
"Office Open XML Text"_ustr
)
24 DECLARE_OOXMLEXPORT_TEST(testThemePortionLevelCharColor_ODF
,
25 "Test_ThemePortionLevel_CharColor.fodt")
27 auto xParagraph
= getParagraph(1);
28 CPPUNIT_ASSERT(xParagraph
.is());
29 auto xComplexColor
= getProperty
<uno::Reference
<util::XComplexColor
>>(getRun(xParagraph
, 1),
30 u
"CharComplexColor"_ustr
);
31 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
32 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2
, aComplexColor
.getThemeColorType());
33 auto const& rTransforms
= aComplexColor
.getTransformations();
34 CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms
.size());
35 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTransforms
[0].meType
);
36 CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTransforms
[0].mnValue
);
39 DECLARE_OOXMLEXPORT_TEST(testThemePortionLevelCharColor_DOCX
,
40 "Test_ThemePortionLevel_CharColor.docx")
42 auto xParagraph
= getParagraph(1);
43 CPPUNIT_ASSERT(xParagraph
.is());
44 auto xComplexColor
= getProperty
<uno::Reference
<util::XComplexColor
>>(getRun(xParagraph
, 1),
45 u
"CharComplexColor"_ustr
);
46 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
47 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2
, aComplexColor
.getThemeColorType());
48 auto const& rTransforms
= aComplexColor
.getTransformations();
49 CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms
.size());
50 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTransforms
[0].meType
);
51 CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTransforms
[0].mnValue
);
54 DECLARE_OOXMLEXPORT_TEST(testThemePortionBorderColor_DOCX
, "Test_ThemeBorderColor.docx")
56 auto xParagraph
= getParagraph(1);
57 CPPUNIT_ASSERT(xParagraph
.is());
59 auto xComplexColor
= getProperty
<uno::Reference
<util::XComplexColor
>>(
60 xParagraph
, u
"TopBorderComplexColor"_ustr
);
61 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
62 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2
, aComplexColor
.getThemeColorType());
63 auto const& rTransforms
= aComplexColor
.getTransformations();
64 CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms
.size());
65 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTransforms
[0].meType
);
66 CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTransforms
[0].mnValue
);
69 auto xComplexColor
= getProperty
<uno::Reference
<util::XComplexColor
>>(
70 xParagraph
, u
"BottomBorderComplexColor"_ustr
);
71 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
72 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent4
, aComplexColor
.getThemeColorType());
73 auto const& rTransforms
= aComplexColor
.getTransformations();
74 CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms
.size());
75 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTransforms
[0].meType
);
76 CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTransforms
[0].mnValue
);
79 CPPUNIT_ASSERT(isPropertyVoid(xParagraph
, u
"LeftBorderComplexColor"_ustr
));
80 CPPUNIT_ASSERT(isPropertyVoid(xParagraph
, u
"RightBorderComplexColor"_ustr
));
83 DECLARE_OOXMLEXPORT_TEST(testCharUnderlineTheme_DOCX
, "Test_CharUnderlineThemeColor.docx")
85 auto xParagraph
= getParagraph(1);
86 CPPUNIT_ASSERT(xParagraph
.is());
87 auto xRun
= getRun(xParagraph
, 1);
89 = getProperty
<uno::Reference
<util::XComplexColor
>>(xRun
, u
"CharUnderlineComplexColor"_ustr
);
90 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
91 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1
, aComplexColor
.getThemeColorType());
92 auto const& rTransforms
= aComplexColor
.getTransformations();
93 CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms
.size());
94 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Shade
, rTransforms
[0].meType
);
95 CPPUNIT_ASSERT_EQUAL(sal_Int16(2509), rTransforms
[0].mnValue
);
98 DECLARE_OOXMLEXPORT_TEST(testParaBackgroundTheme_DOCX
, "Test_ThemeTextParaBackgroundColor.docx")
101 auto xParagraph
= getParagraph(1);
102 CPPUNIT_ASSERT(xParagraph
.is());
103 auto xComplexColor
= getProperty
<uno::Reference
<util::XComplexColor
>>(
104 xParagraph
, u
"ParaBackgroundComplexColor"_ustr
);
105 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
106 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3
, aComplexColor
.getThemeColorType());
107 auto const& rTransforms
= aComplexColor
.getTransformations();
108 CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms
.size());
109 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTransforms
[0].meType
);
110 CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTransforms
[0].mnValue
);
114 auto xParagraph
= getParagraph(2);
115 CPPUNIT_ASSERT(xParagraph
.is());
116 auto xComplexColor
= getProperty
<uno::Reference
<util::XComplexColor
>>(
117 xParagraph
, u
"ParaBackgroundComplexColor"_ustr
);
118 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
119 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6
, aComplexColor
.getThemeColorType());
120 auto const& rTransforms
= aComplexColor
.getTransformations();
121 CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms
.size());
122 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTransforms
[0].meType
);
123 CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTransforms
[0].mnValue
);
127 auto xParagraph
= getParagraph(3);
128 CPPUNIT_ASSERT(xParagraph
.is());
129 auto xComplexColor
= getProperty
<uno::Reference
<util::XComplexColor
>>(
130 xParagraph
, u
"ParaBackgroundComplexColor"_ustr
);
131 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
132 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3
, aComplexColor
.getThemeColorType());
133 auto const& rTransforms
= aComplexColor
.getTransformations();
134 CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms
.size());
135 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTransforms
[0].meType
);
136 CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTransforms
[0].mnValue
);
140 CPPUNIT_PLUGIN_IMPLEMENT();
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */