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>
14 #include <unotxdoc.hxx>
16 #include <drawdoc.hxx>
17 #include <IDocumentDrawModelAccess.hxx>
18 #include <svx/svdpage.hxx>
19 #include <docmodel/uno/UnoComplexColor.hxx>
20 #include <docmodel/theme/Theme.hxx>
21 #include <ThemeColorChanger.hxx>
22 #include <svx/ColorSets.hxx>
28 class SwCoreThemeTest
: public SwModelTestBase
32 : SwModelTestBase("/sw/qa/core/theme/data/")
37 CPPUNIT_TEST_FIXTURE(SwCoreThemeTest
, testThemeColorInHeading
)
39 createSwDoc("ThemeColorInHeading.docx");
40 SwDoc
* pDoc
= getSwDoc();
44 = getProperty
<uno::Reference
<util::XComplexColor
>>(getParagraph(1), "CharComplexColor");
45 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
46 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1
, aComplexColor
.getSchemeType());
49 CPPUNIT_TEST_FIXTURE(SwCoreThemeTest
, testThemeColorInHeadingODT
)
51 createSwDoc("ThemeColorInHeading.fodt");
52 SwDoc
* pDoc
= getSwDoc();
56 = getProperty
<uno::Reference
<util::XComplexColor
>>(getParagraph(1), "CharComplexColor");
57 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
58 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1
, aComplexColor
.getSchemeType());
61 void checkFillStyles(std::vector
<model::FillStyle
> const& rStyleList
)
63 CPPUNIT_ASSERT_EQUAL(size_t(3), rStyleList
.size());
66 model::FillStyle
const& rFillStyle
= rStyleList
.at(0);
67 CPPUNIT_ASSERT(rFillStyle
.mpFill
);
68 CPPUNIT_ASSERT_EQUAL(model::FillType::Solid
, rFillStyle
.mpFill
->meType
);
69 auto* pSolidFill
= static_cast<model::SolidFill
*>(rFillStyle
.mpFill
.get());
70 CPPUNIT_ASSERT_EQUAL(model::ColorType::Placeholder
, pSolidFill
->maColor
.meType
);
71 CPPUNIT_ASSERT_EQUAL(size_t(0), pSolidFill
->maColor
.maTransformations
.size());
76 model::FillStyle
const& rFillStyle
= rStyleList
.at(1);
77 CPPUNIT_ASSERT(rFillStyle
.mpFill
);
78 CPPUNIT_ASSERT_EQUAL(model::FillType::Gradient
, rFillStyle
.mpFill
->meType
);
79 auto* pGradientFill
= static_cast<model::GradientFill
*>(rFillStyle
.mpFill
.get());
81 // Gradient Properties
82 CPPUNIT_ASSERT_EQUAL(model::GradientType::Linear
, pGradientFill
->meGradientType
);
83 CPPUNIT_ASSERT_EQUAL(sal_Int32(5400000), pGradientFill
->maLinearGradient
.mnAngle
);
84 CPPUNIT_ASSERT_EQUAL(false, pGradientFill
->maLinearGradient
.mbScaled
);
87 CPPUNIT_ASSERT_EQUAL(size_t(3), pGradientFill
->maGradientStops
.size());
89 auto const& rGradientStop
= pGradientFill
->maGradientStops
[0];
90 CPPUNIT_ASSERT_EQUAL(0.0, rGradientStop
.mfPosition
);
91 CPPUNIT_ASSERT_EQUAL(model::ColorType::Placeholder
, rGradientStop
.maColor
.meType
);
92 CPPUNIT_ASSERT_EQUAL(size_t(3), rGradientStop
.maColor
.maTransformations
.size());
95 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[0];
96 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod
, rTrasnsformation
.meType
);
97 CPPUNIT_ASSERT_EQUAL(sal_Int16(11000), rTrasnsformation
.mnValue
);
100 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[1];
101 CPPUNIT_ASSERT_EQUAL(model::TransformationType::SatMod
, rTrasnsformation
.meType
);
102 CPPUNIT_ASSERT_EQUAL(sal_Int16(10500), rTrasnsformation
.mnValue
);
105 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[2];
106 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTrasnsformation
.meType
);
107 CPPUNIT_ASSERT_EQUAL(sal_Int16(6700), rTrasnsformation
.mnValue
);
111 auto const& rGradientStop
= pGradientFill
->maGradientStops
[1];
112 CPPUNIT_ASSERT_EQUAL(0.5, rGradientStop
.mfPosition
);
113 CPPUNIT_ASSERT_EQUAL(model::ColorType::Placeholder
, rGradientStop
.maColor
.meType
);
114 CPPUNIT_ASSERT_EQUAL(size_t(3), rGradientStop
.maColor
.maTransformations
.size());
117 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[0];
118 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod
, rTrasnsformation
.meType
);
119 CPPUNIT_ASSERT_EQUAL(sal_Int16(10500), rTrasnsformation
.mnValue
);
122 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[1];
123 CPPUNIT_ASSERT_EQUAL(model::TransformationType::SatMod
, rTrasnsformation
.meType
);
124 CPPUNIT_ASSERT_EQUAL(sal_Int16(10300), rTrasnsformation
.mnValue
);
127 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[2];
128 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTrasnsformation
.meType
);
129 CPPUNIT_ASSERT_EQUAL(sal_Int16(7300), rTrasnsformation
.mnValue
);
133 auto const& rGradientStop
= pGradientFill
->maGradientStops
[2];
134 CPPUNIT_ASSERT_EQUAL(1.0, rGradientStop
.mfPosition
);
135 CPPUNIT_ASSERT_EQUAL(model::ColorType::Placeholder
, rGradientStop
.maColor
.meType
);
136 CPPUNIT_ASSERT_EQUAL(size_t(3), rGradientStop
.maColor
.maTransformations
.size());
139 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[0];
140 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod
, rTrasnsformation
.meType
);
141 CPPUNIT_ASSERT_EQUAL(sal_Int16(10500), rTrasnsformation
.mnValue
);
144 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[1];
145 CPPUNIT_ASSERT_EQUAL(model::TransformationType::SatMod
, rTrasnsformation
.meType
);
146 CPPUNIT_ASSERT_EQUAL(sal_Int16(10900), rTrasnsformation
.mnValue
);
149 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[2];
150 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTrasnsformation
.meType
);
151 CPPUNIT_ASSERT_EQUAL(sal_Int16(8100), rTrasnsformation
.mnValue
);
158 model::FillStyle
const& rFillStyle
= rStyleList
.at(2);
159 CPPUNIT_ASSERT(rFillStyle
.mpFill
);
160 CPPUNIT_ASSERT_EQUAL(model::FillType::Gradient
, rFillStyle
.mpFill
->meType
);
161 auto* pGradientFill
= static_cast<model::GradientFill
*>(rFillStyle
.mpFill
.get());
163 // Gradient Properties
164 CPPUNIT_ASSERT_EQUAL(model::GradientType::Linear
, pGradientFill
->meGradientType
);
165 CPPUNIT_ASSERT_EQUAL(sal_Int32(5400000), pGradientFill
->maLinearGradient
.mnAngle
);
166 CPPUNIT_ASSERT_EQUAL(false, pGradientFill
->maLinearGradient
.mbScaled
);
169 CPPUNIT_ASSERT_EQUAL(size_t(3), pGradientFill
->maGradientStops
.size());
171 auto const& rGradientStop
= pGradientFill
->maGradientStops
[0];
172 CPPUNIT_ASSERT_EQUAL(0.0, rGradientStop
.mfPosition
);
173 CPPUNIT_ASSERT_EQUAL(model::ColorType::Placeholder
, rGradientStop
.maColor
.meType
);
174 CPPUNIT_ASSERT_EQUAL(size_t(3), rGradientStop
.maColor
.maTransformations
.size());
176 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[0];
177 CPPUNIT_ASSERT_EQUAL(model::TransformationType::SatMod
, rTrasnsformation
.meType
);
178 CPPUNIT_ASSERT_EQUAL(sal_Int16(10300), rTrasnsformation
.mnValue
);
181 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[1];
182 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod
, rTrasnsformation
.meType
);
183 CPPUNIT_ASSERT_EQUAL(sal_Int16(10200), rTrasnsformation
.mnValue
);
186 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[2];
187 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTrasnsformation
.meType
);
188 CPPUNIT_ASSERT_EQUAL(sal_Int16(9400), rTrasnsformation
.mnValue
);
192 auto const& rGradientStop
= pGradientFill
->maGradientStops
[1];
193 CPPUNIT_ASSERT_EQUAL(0.5, rGradientStop
.mfPosition
);
194 CPPUNIT_ASSERT_EQUAL(model::ColorType::Placeholder
, rGradientStop
.maColor
.meType
);
195 CPPUNIT_ASSERT_EQUAL(size_t(3), rGradientStop
.maColor
.maTransformations
.size());
197 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[0];
198 CPPUNIT_ASSERT_EQUAL(model::TransformationType::SatMod
, rTrasnsformation
.meType
);
199 CPPUNIT_ASSERT_EQUAL(sal_Int16(11000), rTrasnsformation
.mnValue
);
202 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[1];
203 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod
, rTrasnsformation
.meType
);
204 CPPUNIT_ASSERT_EQUAL(sal_Int16(10000), rTrasnsformation
.mnValue
);
207 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[2];
208 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Shade
, rTrasnsformation
.meType
);
209 CPPUNIT_ASSERT_EQUAL(sal_Int16(10000), rTrasnsformation
.mnValue
);
213 auto const& rGradientStop
= pGradientFill
->maGradientStops
[2];
214 CPPUNIT_ASSERT_EQUAL(1.0, rGradientStop
.mfPosition
);
215 CPPUNIT_ASSERT_EQUAL(model::ColorType::Placeholder
, rGradientStop
.maColor
.meType
);
216 CPPUNIT_ASSERT_EQUAL(size_t(3), rGradientStop
.maColor
.maTransformations
.size());
218 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[0];
219 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod
, rTrasnsformation
.meType
);
220 CPPUNIT_ASSERT_EQUAL(sal_Int16(9900), rTrasnsformation
.mnValue
);
223 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[1];
224 CPPUNIT_ASSERT_EQUAL(model::TransformationType::SatMod
, rTrasnsformation
.meType
);
225 CPPUNIT_ASSERT_EQUAL(sal_Int16(12000), rTrasnsformation
.mnValue
);
228 auto const& rTrasnsformation
= rGradientStop
.maColor
.maTransformations
[2];
229 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Shade
, rTrasnsformation
.meType
);
230 CPPUNIT_ASSERT_EQUAL(sal_Int16(7800), rTrasnsformation
.mnValue
);
236 void checkLineStyles(std::vector
<model::LineStyle
> const& rStyleList
)
238 CPPUNIT_ASSERT_EQUAL(size_t(3), rStyleList
.size());
241 model::LineStyle
const& rLineStyle
= rStyleList
.at(0);
242 CPPUNIT_ASSERT_EQUAL(sal_Int32(6350), rLineStyle
.mnWidth
);
243 CPPUNIT_ASSERT_EQUAL(model::CapType::Flat
, rLineStyle
.meCapType
);
244 CPPUNIT_ASSERT_EQUAL(model::PenAlignmentType::Center
, rLineStyle
.mePenAlignment
);
245 CPPUNIT_ASSERT_EQUAL(model::CompoundLineType::Single
, rLineStyle
.meCompoundLineType
);
246 CPPUNIT_ASSERT_EQUAL(model::PresetDashType::Solid
, rLineStyle
.maLineDash
.mePresetType
);
247 CPPUNIT_ASSERT_EQUAL(model::LineJoinType::Miter
, rLineStyle
.maLineJoin
.meType
);
248 CPPUNIT_ASSERT_EQUAL(sal_Int32(800000), rLineStyle
.maLineJoin
.mnMiterLimit
);
250 model::FillStyle
const& rFillStyle
= rLineStyle
.maLineFillStyle
;
251 CPPUNIT_ASSERT(rFillStyle
.mpFill
);
252 CPPUNIT_ASSERT_EQUAL(model::FillType::Solid
, rFillStyle
.mpFill
->meType
);
253 auto* pSolidFill
= static_cast<model::SolidFill
*>(rFillStyle
.mpFill
.get());
254 CPPUNIT_ASSERT_EQUAL(model::ColorType::Placeholder
, pSolidFill
->maColor
.meType
);
255 CPPUNIT_ASSERT_EQUAL(size_t(0), pSolidFill
->maColor
.maTransformations
.size());
260 model::LineStyle
const& rLineStyle
= rStyleList
.at(1);
261 CPPUNIT_ASSERT_EQUAL(sal_Int32(12700), rLineStyle
.mnWidth
);
262 CPPUNIT_ASSERT_EQUAL(model::CapType::Flat
, rLineStyle
.meCapType
);
263 CPPUNIT_ASSERT_EQUAL(model::PenAlignmentType::Center
, rLineStyle
.mePenAlignment
);
264 CPPUNIT_ASSERT_EQUAL(model::CompoundLineType::Single
, rLineStyle
.meCompoundLineType
);
265 CPPUNIT_ASSERT_EQUAL(model::PresetDashType::Solid
, rLineStyle
.maLineDash
.mePresetType
);
266 CPPUNIT_ASSERT_EQUAL(model::LineJoinType::Miter
, rLineStyle
.maLineJoin
.meType
);
267 CPPUNIT_ASSERT_EQUAL(sal_Int32(800000), rLineStyle
.maLineJoin
.mnMiterLimit
);
269 model::FillStyle
const& rFillStyle
= rLineStyle
.maLineFillStyle
;
270 CPPUNIT_ASSERT(rFillStyle
.mpFill
);
271 CPPUNIT_ASSERT_EQUAL(model::FillType::Solid
, rFillStyle
.mpFill
->meType
);
272 auto* pSolidFill
= static_cast<model::SolidFill
*>(rFillStyle
.mpFill
.get());
273 CPPUNIT_ASSERT_EQUAL(model::ColorType::Placeholder
, pSolidFill
->maColor
.meType
);
274 CPPUNIT_ASSERT_EQUAL(size_t(0), pSolidFill
->maColor
.maTransformations
.size());
279 model::LineStyle
const& rLineStyle
= rStyleList
.at(2);
280 CPPUNIT_ASSERT_EQUAL(sal_Int32(19050), rLineStyle
.mnWidth
);
281 CPPUNIT_ASSERT_EQUAL(model::CapType::Flat
, rLineStyle
.meCapType
);
282 CPPUNIT_ASSERT_EQUAL(model::PenAlignmentType::Center
, rLineStyle
.mePenAlignment
);
283 CPPUNIT_ASSERT_EQUAL(model::CompoundLineType::Single
, rLineStyle
.meCompoundLineType
);
284 CPPUNIT_ASSERT_EQUAL(model::PresetDashType::Solid
, rLineStyle
.maLineDash
.mePresetType
);
285 CPPUNIT_ASSERT_EQUAL(model::LineJoinType::Miter
, rLineStyle
.maLineJoin
.meType
);
286 CPPUNIT_ASSERT_EQUAL(sal_Int32(800000), rLineStyle
.maLineJoin
.mnMiterLimit
);
288 model::FillStyle
const& rFillStyle
= rLineStyle
.maLineFillStyle
;
289 CPPUNIT_ASSERT(rFillStyle
.mpFill
);
290 CPPUNIT_ASSERT_EQUAL(model::FillType::Solid
, rFillStyle
.mpFill
->meType
);
291 auto* pSolidFill
= static_cast<model::SolidFill
*>(rFillStyle
.mpFill
.get());
292 CPPUNIT_ASSERT_EQUAL(model::ColorType::Placeholder
, pSolidFill
->maColor
.meType
);
293 CPPUNIT_ASSERT_EQUAL(size_t(0), pSolidFill
->maColor
.maTransformations
.size());
297 void checkEffects(std::vector
<model::EffectStyle
> const& rEffectStyleList
)
299 CPPUNIT_ASSERT_EQUAL(size_t(3), rEffectStyleList
.size());
301 model::EffectStyle rEffectStyle
= rEffectStyleList
[0];
302 CPPUNIT_ASSERT_EQUAL(size_t(0), rEffectStyle
.maEffectList
.size());
306 model::EffectStyle rEffectStyle
= rEffectStyleList
[1];
307 CPPUNIT_ASSERT_EQUAL(size_t(0), rEffectStyle
.maEffectList
.size());
311 model::EffectStyle rEffectStyle
= rEffectStyleList
[2];
312 CPPUNIT_ASSERT_EQUAL(size_t(1), rEffectStyle
.maEffectList
.size());
313 model::Effect
const& rEffect
= rEffectStyle
.maEffectList
[0];
315 CPPUNIT_ASSERT_EQUAL(model::EffectType::OuterShadow
, rEffect
.meType
);
316 CPPUNIT_ASSERT_EQUAL(sal_Int32(57150), rEffect
.mnBlurRadius
);
317 CPPUNIT_ASSERT_EQUAL(sal_Int32(19050), rEffect
.mnDistance
);
318 CPPUNIT_ASSERT_EQUAL(sal_Int32(5400000), rEffect
.mnDirection
);
319 CPPUNIT_ASSERT_EQUAL(model::RectangleAlignment::Center
, rEffect
.meAlignment
);
320 CPPUNIT_ASSERT_EQUAL(false, rEffect
.mbRotateWithShape
);
322 CPPUNIT_ASSERT_EQUAL(model::ColorType::RGB
, rEffect
.maColor
.meType
);
323 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rEffect
.maColor
.mnComponent1
);
324 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rEffect
.maColor
.mnComponent2
);
325 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rEffect
.maColor
.mnComponent3
);
327 CPPUNIT_ASSERT_EQUAL(size_t(1), rEffect
.maColor
.maTransformations
.size());
328 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Alpha
,
329 rEffect
.maColor
.maTransformations
[0].meType
);
330 CPPUNIT_ASSERT_EQUAL(sal_Int16(6300), rEffect
.maColor
.maTransformations
[0].mnValue
);
334 CPPUNIT_TEST_FIXTURE(SwCoreThemeTest
, testDrawPageThemeExistsDOCX
)
336 createSwDoc("ThemeColorInHeading.docx");
337 SwDoc
* pDoc
= getSwDoc();
338 CPPUNIT_ASSERT(pDoc
);
340 SdrPage
* pPage
= pDoc
->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
341 auto const& pTheme
= pPage
->getSdrPageProperties().GetTheme();
342 CPPUNIT_ASSERT(pTheme
);
343 CPPUNIT_ASSERT_EQUAL(OUString(u
"Office Theme"), pTheme
->GetName());
345 auto pColorSet
= pTheme
->getColorSet();
346 CPPUNIT_ASSERT(pColorSet
);
347 CPPUNIT_ASSERT_EQUAL(OUString(u
"Orange"), pColorSet
->getName());
349 CPPUNIT_ASSERT_EQUAL(Color(0xE48312), pTheme
->GetColor(model::ThemeColorType::Accent1
));
350 CPPUNIT_ASSERT_EQUAL(Color(0xBD582C), pTheme
->GetColor(model::ThemeColorType::Accent2
));
351 CPPUNIT_ASSERT_EQUAL(Color(0x865640), pTheme
->GetColor(model::ThemeColorType::Accent3
));
352 CPPUNIT_ASSERT_EQUAL(Color(0x9B8357), pTheme
->GetColor(model::ThemeColorType::Accent4
));
353 CPPUNIT_ASSERT_EQUAL(Color(0xC2BC80), pTheme
->GetColor(model::ThemeColorType::Accent5
));
354 CPPUNIT_ASSERT_EQUAL(Color(0x94A088), pTheme
->GetColor(model::ThemeColorType::Accent6
));
355 CPPUNIT_ASSERT_EQUAL(Color(0x000000), pTheme
->GetColor(model::ThemeColorType::Dark1
));
356 CPPUNIT_ASSERT_EQUAL(Color(0x637052), pTheme
->GetColor(model::ThemeColorType::Dark2
));
357 CPPUNIT_ASSERT_EQUAL(Color(0xFFFFFF), pTheme
->GetColor(model::ThemeColorType::Light1
));
358 CPPUNIT_ASSERT_EQUAL(Color(0xCCDDEA), pTheme
->GetColor(model::ThemeColorType::Light2
));
360 model::FontScheme
const& rFontScheme
= pTheme
->getFontScheme();
361 CPPUNIT_ASSERT_EQUAL(OUString(u
"Calibri Light"), rFontScheme
.getMajorLatin().maTypeface
);
362 CPPUNIT_ASSERT_EQUAL(OUString(u
"Calibri"), rFontScheme
.getMinorLatin().maTypeface
);
363 CPPUNIT_ASSERT_EQUAL(true, rFontScheme
.getMajorAsian().maTypeface
.isEmpty());
364 CPPUNIT_ASSERT_EQUAL(true, rFontScheme
.getMinorAsian().maTypeface
.isEmpty());
365 CPPUNIT_ASSERT_EQUAL(true, rFontScheme
.getMajorComplex().maTypeface
.isEmpty());
366 CPPUNIT_ASSERT_EQUAL(true, rFontScheme
.getMinorComplex().maTypeface
.isEmpty());
367 CPPUNIT_ASSERT_EQUAL(size_t(47), rFontScheme
.getMajorSupplementalFontList().size());
368 CPPUNIT_ASSERT_EQUAL(size_t(47), rFontScheme
.getMinorSupplementalFontList().size());
369 CPPUNIT_ASSERT_EQUAL(OUString(u
"Angsana New"),
370 rFontScheme
.findMajorSupplementalTypeface(u
"Thai"));
371 CPPUNIT_ASSERT_EQUAL(OUString(u
"Cordia New"),
372 rFontScheme
.findMinorSupplementalTypeface(u
"Thai"));
374 model::FormatScheme
const& rFormatScheme
= pTheme
->getFormatScheme();
375 checkFillStyles(rFormatScheme
.getFillStyleList());
376 checkLineStyles(rFormatScheme
.getLineStyleList());
377 checkEffects(rFormatScheme
.getEffectStyleList());
378 CPPUNIT_ASSERT_EQUAL(size_t(3), rFormatScheme
.getBackgroundFillStyleList().size());
381 CPPUNIT_TEST_FIXTURE(SwCoreThemeTest
, testDrawPageThemeExistsODT
)
383 createSwDoc("ThemeColorInHeading.fodt");
384 SwDoc
* pDoc
= getSwDoc();
385 CPPUNIT_ASSERT(pDoc
);
387 SdrPage
* pPage
= pDoc
->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
388 auto const& pTheme
= pPage
->getSdrPageProperties().GetTheme();
389 CPPUNIT_ASSERT(pTheme
);
390 CPPUNIT_ASSERT_EQUAL(OUString(u
"Office Theme"), pTheme
->GetName());
392 auto pColorSet
= pTheme
->getColorSet();
393 CPPUNIT_ASSERT(pColorSet
);
394 CPPUNIT_ASSERT_EQUAL(OUString(u
"Orange"), pColorSet
->getName());
396 CPPUNIT_ASSERT_EQUAL(Color(0xE48312), pTheme
->GetColor(model::ThemeColorType::Accent1
));
397 CPPUNIT_ASSERT_EQUAL(Color(0xBD582C), pTheme
->GetColor(model::ThemeColorType::Accent2
));
398 CPPUNIT_ASSERT_EQUAL(Color(0x865640), pTheme
->GetColor(model::ThemeColorType::Accent3
));
399 CPPUNIT_ASSERT_EQUAL(Color(0x9B8357), pTheme
->GetColor(model::ThemeColorType::Accent4
));
400 CPPUNIT_ASSERT_EQUAL(Color(0xC2BC80), pTheme
->GetColor(model::ThemeColorType::Accent5
));
401 CPPUNIT_ASSERT_EQUAL(Color(0x94A088), pTheme
->GetColor(model::ThemeColorType::Accent6
));
402 CPPUNIT_ASSERT_EQUAL(Color(0x000000), pTheme
->GetColor(model::ThemeColorType::Dark1
));
403 CPPUNIT_ASSERT_EQUAL(Color(0x637052), pTheme
->GetColor(model::ThemeColorType::Dark2
));
404 CPPUNIT_ASSERT_EQUAL(Color(0xFFFFFF), pTheme
->GetColor(model::ThemeColorType::Light1
));
405 CPPUNIT_ASSERT_EQUAL(Color(0xCCDDEA), pTheme
->GetColor(model::ThemeColorType::Light2
));
408 CPPUNIT_TEST_FIXTURE(SwCoreThemeTest
, testThemeChanging
)
410 createSwDoc("ThemeColorInHeading.docx");
411 SwDoc
* pDoc
= getSwDoc();
412 CPPUNIT_ASSERT(pDoc
);
413 SwWrtShell
* pWrtShell
= pDoc
->GetDocShell()->GetWrtShell();
414 CPPUNIT_ASSERT(pWrtShell
);
415 SdrPage
* pPage
= pDoc
->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
416 CPPUNIT_ASSERT(pPage
);
418 // Check current theme colors
420 auto const& pTheme
= pPage
->getSdrPageProperties().GetTheme();
421 CPPUNIT_ASSERT(pTheme
);
422 CPPUNIT_ASSERT_EQUAL(OUString(u
"Office Theme"), pTheme
->GetName());
424 auto pColorSet
= pTheme
->getColorSet();
425 CPPUNIT_ASSERT(pColorSet
);
426 CPPUNIT_ASSERT_EQUAL(OUString(u
"Orange"), pColorSet
->getName());
427 CPPUNIT_ASSERT_EQUAL(Color(0xE48312), pTheme
->GetColor(model::ThemeColorType::Accent1
));
430 // Change theme colors
432 auto const& rColorSets
= svx::ColorSets::get();
433 auto pNewColorSet
= std::make_shared
<model::ColorSet
>(rColorSets
.getColorSet(0));
434 // check that the theme colors are as expected
435 CPPUNIT_ASSERT_EQUAL(OUString(u
"LibreOffice"), pNewColorSet
->getName());
437 sw::ThemeColorChanger
aChanger(pDoc
->GetDocShell());
438 aChanger
.apply(pNewColorSet
);
441 // Check new theme colors
443 auto const& pTheme
= pPage
->getSdrPageProperties().GetTheme();
444 CPPUNIT_ASSERT(pTheme
);
445 CPPUNIT_ASSERT_EQUAL(OUString(u
"Office Theme"), pTheme
->GetName());
447 auto pColorSet
= pTheme
->getColorSet();
448 CPPUNIT_ASSERT(pColorSet
);
449 CPPUNIT_ASSERT_EQUAL(OUString(u
"LibreOffice"), pColorSet
->getName());
450 CPPUNIT_ASSERT_EQUAL(Color(0x18A303), pTheme
->GetColor(model::ThemeColorType::Accent1
));
456 // Check theme colors have been reverted
458 auto const& pTheme
= pPage
->getSdrPageProperties().GetTheme();
459 CPPUNIT_ASSERT(pTheme
);
460 CPPUNIT_ASSERT_EQUAL(OUString(u
"Office Theme"), pTheme
->GetName());
462 auto pColorSet
= pTheme
->getColorSet();
463 CPPUNIT_ASSERT(pColorSet
);
464 CPPUNIT_ASSERT_EQUAL(OUString(u
"Orange"), pColorSet
->getName());
465 CPPUNIT_ASSERT_EQUAL(Color(0xE48312), pTheme
->GetColor(model::ThemeColorType::Accent1
));
471 // Check theme colors have been applied again
473 auto const& pTheme
= pPage
->getSdrPageProperties().GetTheme();
474 CPPUNIT_ASSERT(pTheme
);
475 CPPUNIT_ASSERT_EQUAL(OUString(u
"Office Theme"), pTheme
->GetName());
477 auto pColorSet
= pTheme
->getColorSet();
478 CPPUNIT_ASSERT(pColorSet
);
479 CPPUNIT_ASSERT_EQUAL(OUString(u
"LibreOffice"), pColorSet
->getName());
480 CPPUNIT_ASSERT_EQUAL(Color(0x18A303), pTheme
->GetColor(model::ThemeColorType::Accent1
));
484 } // end anonymous namnespace
486 CPPUNIT_PLUGIN_IMPLEMENT();
488 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */