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 <sal/config.h>
12 #include <test/unoapi_test.hxx>
14 #include <string_view>
16 #include <com/sun/star/awt/FontWeight.hpp>
17 #include <com/sun/star/awt/Gradient2.hpp>
18 #include <com/sun/star/awt/Size.hpp>
19 #include <com/sun/star/awt/XBitmap.hpp>
20 #include <com/sun/star/beans/XPropertySet.hpp>
21 #include <com/sun/star/drawing/BitmapMode.hpp>
22 #include <com/sun/star/drawing/FillStyle.hpp>
23 #include <com/sun/star/drawing/LineDash.hpp>
24 #include <com/sun/star/drawing/LineJoint.hpp>
25 #include <com/sun/star/drawing/LineStyle.hpp>
26 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
27 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
28 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
29 #include <com/sun/star/graphic/XGraphic.hpp>
30 #include <com/sun/star/lang/Locale.hpp>
31 #include <com/sun/star/text/XTextFrame.hpp>
32 #include <com/sun/star/text/XTextRange.hpp>
34 #include <comphelper/sequenceashashmap.hxx>
35 #include <officecfg/Office/Common.hxx>
36 #include <rtl/math.hxx>
37 #include <svx/svdoashp.hxx>
38 #include <tools/color.hxx>
39 #include <docmodel/uno/UnoComplexColor.hxx>
40 #include <docmodel/uno/UnoGradientTools.hxx>
41 #include <basegfx/utils/gradienttools.hxx>
43 using namespace ::com::sun::star
;
47 /// Gets one child of xShape, which one is specified by nIndex.
48 uno::Reference
<drawing::XShape
> getChildShape(const uno::Reference
<drawing::XShape
>& xShape
,
51 uno::Reference
<container::XIndexAccess
> xGroup(xShape
, uno::UNO_QUERY
);
52 CPPUNIT_ASSERT(xGroup
.is());
54 CPPUNIT_ASSERT(xGroup
->getCount() > nIndex
);
56 uno::Reference
<drawing::XShape
> xRet(xGroup
->getByIndex(nIndex
), uno::UNO_QUERY
);
57 CPPUNIT_ASSERT(xRet
.is());
64 class OoxShapeTest
: public UnoApiTest
68 : UnoApiTest("/oox/qa/unit/data/")
71 uno::Reference
<drawing::XShape
> getShapeByName(std::u16string_view aName
);
74 uno::Reference
<drawing::XShape
> OoxShapeTest::getShapeByName(std::u16string_view aName
)
76 uno::Reference
<drawing::XShape
> xRet
;
78 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
79 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
81 for (sal_Int32 i
= 0; i
< xDrawPage
->getCount(); ++i
)
83 uno::Reference
<container::XNamed
> xShape(xDrawPage
->getByIndex(i
), uno::UNO_QUERY
);
84 if (xShape
->getName() == aName
)
86 xRet
.set(xShape
, uno::UNO_QUERY
);
94 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testGroupTransform
)
96 loadFromURL(u
"tdf141463_GroupTransform.pptx");
98 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
99 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
101 uno::Reference
<drawing::XShape
> xGroup(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
102 uno::Reference
<drawing::XShape
> xShape(getChildShape(xGroup
, 0), uno::UNO_QUERY
);
103 uno::Reference
<beans::XPropertySet
> xPropSet(xShape
, uno::UNO_QUERY
);
104 // Without the accompanying fix in place, this test would have failed in several properties.
107 xPropSet
->getPropertyValue("ShearAngle") >>= nAngle
;
108 // Failed with - Expected: 0
110 // i.e. the shape was sheared although shearing does not exist in oox
111 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAngle
);
113 xPropSet
->getPropertyValue("RotateAngle") >>= nAngle
;
114 // Failed with - Expected: 26000 (is in 1/100deg)
115 // - Actual : 26481 (is in 1/100deg)
116 // 100deg in PowerPoint UI = 360deg - 100deg in LO.
117 CPPUNIT_ASSERT_EQUAL(sal_Int32(26000), nAngle
);
119 sal_Int32 nActual
= xShape
->getSize().Width
;
120 // The group has ext.cy=2880000 and chExt.cy=4320000 resulting in Y-scale=2/3.
121 // The child has ext 2880000 x 1440000. Because of rotation angle 80deg, the Y-scale has to be
122 // applied to the width, resulting in 2880000 * 2/3 = 1920000EMU = 5333Hmm
123 // ToDo: Expected value currently 1 off.
124 // Failed with - Expected: 5332
126 CPPUNIT_ASSERT_EQUAL(sal_Int32(5332), nActual
);
129 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testMultipleGroupShapes
)
131 loadFromURL(u
"multiple-group-shapes.docx");
133 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
134 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
136 // Without the accompanying fix in place, this test would have failed with:
139 // i.e. the 2 group shapes from the document were imported as a single one.
140 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xDrawPage
->getCount());
143 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testCustomshapePosition
)
145 loadFromURL(u
"customshape-position.docx");
147 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
148 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
150 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
153 xShape
->getPropertyValue("VertOrientPosition") >>= nY
;
154 // <wp:posOffset>581025</wp:posOffset> in the document.
155 sal_Int32 nExpected
= rtl::math::round(581025.0 / 360);
156 // Without the accompanying fix in place, this test would have failed with:
159 // i.e. the position of the shape was lost on import due to the rounded corners.
160 CPPUNIT_ASSERT_EQUAL(nExpected
, nY
);
163 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testTdf125582_TextOnCircle
)
165 // The document contains a shape with a:prstTxWarp="textCircle" with two paragraphs.
166 // PowerPoint aligns the bottom of the text with the path, LO had aligned the middle of the
167 // text with the path, which resulted in smaller text.
168 loadFromURL(u
"tdf125582_TextOnCircle.pptx");
170 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
171 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
173 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
174 uno::Reference
<beans::XPropertySet
> xPropSet(xShape
, uno::UNO_QUERY
);
176 // BoundRect of Fontwork shape depends on dpi.
179 SdrObjCustomShape
& rSdrCustomShape(
180 static_cast<SdrObjCustomShape
&>(*SdrObject::getSdrObjectFromXShape(xShape
)));
181 // Without the fix in place width was 3639, but should be 4824 for 96dpi.
182 tools::Rectangle
aBoundRect(rSdrCustomShape
.GetCurrentBoundRect());
183 CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(4824), aBoundRect
.GetWidth(), 5);
186 drawing::TextVerticalAdjust eAdjust
;
187 xPropSet
->getPropertyValue("TextVerticalAdjust") >>= eAdjust
;
188 CPPUNIT_ASSERT_EQUAL_MESSAGE("TextVerticalAdjust", drawing::TextVerticalAdjust_BOTTOM
, eAdjust
);
191 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testTdf151008VertAnchor
)
193 // The document contains shapes with all six kind of anchor positions in pptx. The text in the
194 // shapes is larger than the shape and has no word wrap. That way anchor position is visible
195 // in case you inspect the file manually.
196 loadFromURL(u
"tdf151008_eaVertAnchor.pptx");
201 drawing::TextHorizontalAdjust eAnchorHori
;
202 drawing::TextVerticalAdjust eAnchorVert
;
204 anchorDesc aExpected
[6] = {
205 { u
"Right", drawing::TextHorizontalAdjust_RIGHT
, drawing::TextVerticalAdjust_TOP
},
206 { u
"Center", drawing::TextHorizontalAdjust_CENTER
, drawing::TextVerticalAdjust_TOP
},
207 { u
"Left", drawing::TextHorizontalAdjust_LEFT
, drawing::TextVerticalAdjust_TOP
},
208 { u
"RightMiddle", drawing::TextHorizontalAdjust_RIGHT
, drawing::TextVerticalAdjust_CENTER
},
209 { u
"CenterMiddle", drawing::TextHorizontalAdjust_CENTER
,
210 drawing::TextVerticalAdjust_CENTER
},
211 { u
"LeftMiddle", drawing::TextHorizontalAdjust_LEFT
, drawing::TextVerticalAdjust_CENTER
}
213 // without the fix horizontal and vertical anchor positions were exchanged
214 for (size_t i
= 0; i
< 6; ++i
)
216 uno::Reference
<beans::XPropertySet
> xShape(getShapeByName(aExpected
[i
].sShapeName
),
218 drawing::TextHorizontalAdjust eHori
;
219 CPPUNIT_ASSERT(xShape
->getPropertyValue("TextHorizontalAdjust") >>= eHori
);
220 drawing::TextVerticalAdjust eVert
;
221 CPPUNIT_ASSERT(xShape
->getPropertyValue("TextVerticalAdjust") >>= eVert
);
222 CPPUNIT_ASSERT_EQUAL(aExpected
[i
].eAnchorHori
, eHori
);
223 CPPUNIT_ASSERT_EQUAL(aExpected
[i
].eAnchorVert
, eVert
);
227 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testTdf151518VertAnchor
)
229 // Make sure SmartArt is loaded as group shape
230 bool bUseGroup
= officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::get();
233 std::shared_ptr
<comphelper::ConfigurationChanges
> pChange(
234 comphelper::ConfigurationChanges::create());
235 officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(true, pChange
);
239 // The document contains SmartArt with shapes with not default text area. Without fix the
240 // text was shifted up because of wrong values in TextLowerDistance and TextUpperDistance.
241 loadFromURL(u
"tdf151518_SmartArtTextLocation.docx");
246 sal_Int16 nSubShapeIndex
;
247 sal_Int32 nLowerDistance
;
248 sal_Int32 nUpperDistance
;
250 TextDistance aExpected
[4] = { { u
"Diagram Target List", 2, 2979, 201 },
251 { u
"Diagram Nested Target", 1, 3203, 127 },
252 { u
"Diagram Stacked Venn", 1, 3112, -302 },
253 { u
"Diagram Grouped List", 1, 4106, 196 } };
254 // without the fix the observed distances were
255 // {4434, -464}, {4674, -751}, {4620, -1399}, {6152, -744}
256 for (size_t i
= 0; i
< 4; ++i
)
258 uno::Reference
<drawing::XShapes
> xDiagramShape(getShapeByName(aExpected
[i
].sShapeName
),
260 uno::Reference
<beans::XPropertySet
> xShapeProps(
261 xDiagramShape
->getByIndex(aExpected
[i
].nSubShapeIndex
), uno::UNO_QUERY
);
264 CPPUNIT_ASSERT(xShapeProps
->getPropertyValue("TextLowerDistance") >>= nLower
);
265 CPPUNIT_ASSERT(xShapeProps
->getPropertyValue("TextUpperDistance") >>= nUpper
);
266 CPPUNIT_ASSERT_EQUAL(aExpected
[i
].nLowerDistance
, nLower
);
267 CPPUNIT_ASSERT_EQUAL(aExpected
[i
].nUpperDistance
, nUpper
);
272 std::shared_ptr
<comphelper::ConfigurationChanges
> pChange(
273 comphelper::ConfigurationChanges::create());
274 officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(false, pChange
);
279 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testTdf54095_SmartArtThemeTextColor
)
281 // The document contains a SmartArt where the color for the texts in the shapes is given by
283 // Error was, that the theme was not considered and therefore the text was white.
285 // Make sure it is not loaded as metafile but with single shapes.
286 bool bUseGroup
= officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::get();
289 std::shared_ptr
<comphelper::ConfigurationChanges
> pChange(
290 comphelper::ConfigurationChanges::create());
291 officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(true, pChange
);
296 loadFromURL(u
"tdf54095_SmartArtThemeTextColor.docx");
297 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
298 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
300 uno::Reference
<drawing::XShapes
> xSmartArt(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
301 // shape 0 is the background shape without text
302 uno::Reference
<text::XTextRange
> xShape(xSmartArt
->getByIndex(1), uno::UNO_QUERY
);
305 uno::Reference
<container::XEnumerationAccess
> xText(xShape
->getText(), uno::UNO_QUERY
);
306 uno::Reference
<container::XEnumerationAccess
> xPara(xText
->createEnumeration()->nextElement(),
308 uno::Reference
<beans::XPropertySet
> xPortion(xPara
->createEnumeration()->nextElement(),
310 sal_Int32 nActualColor
{ 0 };
311 xPortion
->getPropertyValue("CharColor") >>= nActualColor
;
312 // Without fix the test would have failed with:
313 // - Expected: 2050429 (0x1F497D)
314 // - Actual : 16777215 (0xFFFFFF), that is text was white
315 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x1F497D), nActualColor
);
317 // clrScheme. For map between name in docx and index from CharComplexColor see
318 // oox::drawingml::Color::getSchemeColorIndex()
319 // Without fix the color scheme was "lt1" (1) but should be "dk2" (2).
320 uno::Reference
<util::XComplexColor
> xComplexColor
;
321 xPortion
->getPropertyValue("CharComplexColor") >>= xComplexColor
;
322 CPPUNIT_ASSERT(xComplexColor
.is());
323 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
324 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Dark2
, aComplexColor
.getSchemeType());
328 std::shared_ptr
<comphelper::ConfigurationChanges
> pChange(
329 comphelper::ConfigurationChanges::create());
330 officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(false, pChange
);
335 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterFontwork
)
337 loadFromURL(u
"tdf125885_WordArt.docx");
338 // Without the patch WordArt in text document was imported as rectangular custom shape with
339 // attached frame. So there was no artistic text at all. Now it is imported as Fontwork.
340 // This test covers some basic properties.
342 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
343 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
345 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
348 bool bTextBox
= bool();
349 CPPUNIT_ASSERT(xShapeProps
->getPropertyValue(u
"TextBox") >>= bTextBox
);
350 CPPUNIT_ASSERT(!bTextBox
);
352 uno::Reference
<css::text::XTextFrame
> xTextFrame
;
353 xShapeProps
->getPropertyValue(u
"TextBoxContent") >>= xTextFrame
;
354 CPPUNIT_ASSERT(!xTextFrame
.is());
356 uno::Sequence
<beans::PropertyValue
> aGeoPropSeq
;
357 xShapeProps
->getPropertyValue(u
"CustomShapeGeometry") >>= aGeoPropSeq
;
358 CPPUNIT_ASSERT(aGeoPropSeq
.getLength() > 0);
359 comphelper::SequenceAsHashMap
aGeoPropMap(aGeoPropSeq
);
361 uno::Sequence
<beans::PropertyValue
> aTextPathSeq
;
362 aGeoPropMap
.getValue(u
"TextPath") >>= aTextPathSeq
;
363 CPPUNIT_ASSERT(aTextPathSeq
.getLength() > 0);
365 comphelper::SequenceAsHashMap
aTextPathPropMap(aTextPathSeq
);
366 bool bTextPathOn
= bool();
367 CPPUNIT_ASSERT(aTextPathPropMap
.getValue(u
"TextPath") >>= bTextPathOn
);
368 CPPUNIT_ASSERT(bTextPathOn
);
370 // Is it the correct kind of Fontwork?
371 uno::Sequence
<drawing::EnhancedCustomShapeAdjustmentValue
> aAdjustmentSeq
;
372 aGeoPropMap
.getValue(u
"AdjustmentValues") >>= aAdjustmentSeq
;
373 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aAdjustmentSeq
.getLength());
375 uno::Sequence
<uno::Sequence
<beans::PropertyValue
>> aHandleSeq
;
376 aGeoPropMap
.getValue(u
"Handles") >>= aHandleSeq
;
377 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aHandleSeq
.getLength());
379 awt::Rectangle aViewBox
;
380 aGeoPropMap
.getValue(u
"ViewBox") >>= aViewBox
;
381 CPPUNIT_ASSERT_EQUAL(sal_Int32(21600), aViewBox
.Width
);
382 CPPUNIT_ASSERT_EQUAL(sal_Int32(21600), aViewBox
.Height
);
384 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString(u
"textDoubleWave1")),
385 aGeoPropMap
.getValue(u
"PresetTextWarp"));
387 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString(u
"mso-spt158")), aGeoPropMap
.getValue(u
"Type"));
389 // Are properties correctly copied to shape?
390 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(0, 0, 255)), xShapeProps
->getPropertyValue(u
"FillColor"));
392 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_SOLID
),
393 xShapeProps
->getPropertyValue(u
"FillStyle"));
395 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString(u
"Courier New")),
396 xShapeProps
->getPropertyValue(u
"CharFontName"));
398 CPPUNIT_ASSERT_EQUAL(uno::Any(float(awt::FontWeight::BOLD
)),
399 xShapeProps
->getPropertyValue("CharWeight"));
401 lang::Locale aCharLocale
;
402 xShapeProps
->getPropertyValue(u
"CharLocale") >>= aCharLocale
;
403 CPPUNIT_ASSERT_EQUAL(OUString("en"), aCharLocale
.Language
);
404 CPPUNIT_ASSERT_EQUAL(OUString("US"), aCharLocale
.Country
);
406 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::TextHorizontalAdjust_RIGHT
),
407 xShapeProps
->getPropertyValue(u
"TextHorizontalAdjust"));
410 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterFontwork2
)
412 loadFromURL(u
"tdf125885_WordArt2.docx");
413 // Without the patch WordArt in text document was imported as rectangular custom shape with
414 // attached frame. So there was no artistic text at all. Now it is imported as Fontwork.
415 // This test covers whether theme color properties are correctly converted on import.
417 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
418 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
420 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
423 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(4000)),
424 xShapeProps
->getPropertyValue(u
"FillColorLumMod"));
425 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(6000)),
426 xShapeProps
->getPropertyValue(u
"FillColorLumOff"));
427 // ID "6" for the theme "accent3" is not yet in API, but defined in enum PredefinedClrSchemeID
428 // in drawingml/clrscheme.hxx.
429 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(6)), xShapeProps
->getPropertyValue(u
"FillColorTheme"));
430 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(215, 228, 189)),
431 xShapeProps
->getPropertyValue(u
"FillColor"));
434 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineCap_ROUND
),
435 xShapeProps
->getPropertyValue(u
"LineCap"));
436 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineStyle_DASH
),
437 xShapeProps
->getPropertyValue(u
"LineStyle"));
438 // Stroke has only the resulted color, but no reference to the used theme color "accent2".
439 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(149, 55, 53)), xShapeProps
->getPropertyValue(u
"LineColor"));
440 drawing::LineDash aLineDash
;
441 xShapeProps
->getPropertyValue(u
"LineDash") >>= aLineDash
;
442 CPPUNIT_ASSERT_EQUAL(drawing::DashStyle_ROUNDRELATIVE
, aLineDash
.Style
);
443 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aLineDash
.Dots
);
444 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aLineDash
.DotLen
);
445 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aLineDash
.Dashes
);
446 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aLineDash
.DashLen
);
447 CPPUNIT_ASSERT_EQUAL(sal_Int32(199), aLineDash
.Distance
);
448 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(635)), xShapeProps
->getPropertyValue(u
"LineWidth"));
449 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(20)),
450 xShapeProps
->getPropertyValue(u
"LineTransparence"));
451 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineJoint_BEVEL
),
452 xShapeProps
->getPropertyValue(u
"LineJoint"));
455 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterFontwork3
)
457 loadFromURL(u
"tdf125885_WordArt3.docx");
458 // Without the patch WordArt in text document was imported as rectangular custom shape with
459 // attached frame. So there was no artistic text at all. Now it is imported as Fontwork.
460 // This test covers some aspects of import of gradient fill.
462 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
463 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
466 // linear gradient, MSO UI 21deg
468 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
469 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
470 xShapeProps
->getPropertyValue(u
"FillStyle"));
471 awt::Gradient2 aGradient
;
472 xShapeProps
->getPropertyValue(u
"FillGradient") >>= aGradient
;
474 // MCGR: Use the completely imported transparency gradient to check for correctness
475 basegfx::BColorStops aColorStops
;
476 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
478 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
479 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
480 CPPUNIT_ASSERT_EQUAL(aColorStops
[0].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0));
481 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
482 CPPUNIT_ASSERT_EQUAL(
483 aColorStops
[1].getStopColor(),
484 basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865));
486 CPPUNIT_ASSERT_EQUAL(sal_Int16(690), aGradient
.Angle
);
487 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient
.XOffset
);
488 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient
.YOffset
);
489 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR
, aGradient
.Style
);
492 // radial gradient, centered
494 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
495 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
496 xShapeProps
->getPropertyValue(u
"FillStyle"));
497 awt::Gradient2 aGradient
;
498 xShapeProps
->getPropertyValue(u
"FillGradient") >>= aGradient
;
500 // MCGR: Use the completely imported transparency gradient to check for correctness
501 basegfx::BColorStops aColorStops
;
502 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
504 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
505 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.40000000000000002));
506 CPPUNIT_ASSERT_EQUAL(
507 aColorStops
[0].getStopColor(),
508 basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865));
509 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
510 CPPUNIT_ASSERT_EQUAL(aColorStops
[1].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0));
512 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aGradient
.Angle
);
513 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.XOffset
);
514 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.YOffset
);
515 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL
, aGradient
.Style
);
518 // rectangular gradient, focus right, bottom
520 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
521 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
522 xShapeProps
->getPropertyValue(u
"FillStyle"));
523 awt::Gradient2 aGradient
;
524 xShapeProps
->getPropertyValue(u
"FillGradient") >>= aGradient
;
526 // MCGR: Use the completely imported transparency gradient to check for correctness
527 basegfx::BColorStops aColorStops
;
528 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
530 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
531 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
532 CPPUNIT_ASSERT_EQUAL(
533 aColorStops
[0].getStopColor(),
534 basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865));
535 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
536 CPPUNIT_ASSERT_EQUAL(aColorStops
[1].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0));
538 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aGradient
.Angle
);
539 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient
.XOffset
);
540 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient
.YOffset
);
541 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT
, aGradient
.Style
);
545 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterFontworkNonAccentColor
)
547 loadFromURL(u
"tdf152840_WordArt_non_accent_color.docx");
548 // The file contains WordArt which uses the theme colors "Background 1", "Text 1", "Background 2"
551 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
552 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
555 // The ID for the theme colors is not yet in API, but defined in enum PredefinedClrSchemeID
556 // in drawingml/clrscheme.hxx. Without fix the ID was -1 meaning no theme is used, and the color
559 // background 1 = lt1 = ID 1
560 uno::Reference
<beans::XPropertySet
> xShape0Props(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
561 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(1)), xShape0Props
->getPropertyValue(u
"FillColorTheme"));
562 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(255, 204, 153)),
563 xShape0Props
->getPropertyValue(u
"FillColor"));
565 // text 1 = dk1 = ID 0
566 uno::Reference
<beans::XPropertySet
> xShape1Props(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
567 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(0)), xShape1Props
->getPropertyValue(u
"FillColorTheme"));
568 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(255, 0, 0)), xShape1Props
->getPropertyValue(u
"FillColor"));
570 // background 2 = lt2 = ID 3
571 uno::Reference
<beans::XPropertySet
> xShape2Props(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
572 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(3)), xShape2Props
->getPropertyValue(u
"FillColorTheme"));
573 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(235, 221, 195)),
574 xShape2Props
->getPropertyValue(u
"FillColor"));
576 // text 2 = dk2 = ID 2
577 uno::Reference
<beans::XPropertySet
> xShape3Props(xDrawPage
->getByIndex(3), uno::UNO_QUERY
);
578 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(2)), xShape3Props
->getPropertyValue(u
"FillColorTheme"));
579 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(119, 95, 85)),
580 xShape3Props
->getPropertyValue(u
"FillColor"));
583 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterShapeFillNonAccentColor
)
585 loadFromURL(u
"tdf152840_theme_color_non_accent.docx");
586 // The file contains shapes which uses the theme colors "bg2", "bg1", "tx1" and "tx2" in this
587 // order as fill color.
589 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
590 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
593 // The ID for the theme colors is not yet in API, but defined in enum PredefinedClrSchemeID
594 // in drawingml/clrscheme.hxx. Without fix the ID was -1 meaning no theme is used.
595 uno::Reference
<beans::XPropertySet
> xShape0Props(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
596 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(3)), xShape0Props
->getPropertyValue(u
"FillColorTheme"));
597 uno::Reference
<beans::XPropertySet
> xShape1Props(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
598 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(1)), xShape1Props
->getPropertyValue(u
"FillColorTheme"));
599 uno::Reference
<beans::XPropertySet
> xShape2Props(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
600 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(0)), xShape2Props
->getPropertyValue(u
"FillColorTheme"));
601 uno::Reference
<beans::XPropertySet
> xShape3Props(xDrawPage
->getByIndex(3), uno::UNO_QUERY
);
602 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(2)), xShape3Props
->getPropertyValue(u
"FillColorTheme"));
605 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterFontworkDarkenTransparency
)
607 loadFromURL(u
"tdf152896_WordArt_color_darken.docx");
608 // The file contains a WordArt shape with theme colors "Background 2", shading mode "Darken 25%"
609 // and "20% Transparency". Word writes this as w:color element with additional w14:textFill
610 // element. In such case the w14:textFill element supersedes the w:color element. Error was, that
611 // the darkening was applied twice, once from w:color and the other time from w14:textFill.
613 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
614 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
617 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
618 // Without the fix in place the test would have failed with
619 // Expected: 13676402 (= 0xD0AF72 = rgb(208, 175, 114) => luminance 63.14%)
620 // Actual: 11897660 (= 0xB58B3C = rgb(181, 139, 60) => luminance 47.25% )
621 // The original "Background 2" is 0xEBDDC3 = rgb(235, 221, 195) => luminance 84.31%
622 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(208, 175, 114)),
623 xShapeProps
->getPropertyValue(u
"FillColor"));
626 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testImportWordArtGradient
)
628 loadFromURL(u
"tdf139618_ImportWordArtGradient.pptx");
629 // Without the patch all WordArt was imported with solid color. Now gradient is imported.
630 // This test covers several aspects of import of gradient fill.
632 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
633 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
636 // linear gradient, MSO UI 21deg, solid transparency on outline
638 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
639 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
640 xShapeProps
->getPropertyValue(u
"FillStyle"));
641 awt::Gradient2 aGradient
;
642 xShapeProps
->getPropertyValue(u
"FillGradient") >>= aGradient
;
644 // MCGR: Use the completely imported transparency gradient to check for correctness
645 basegfx::BColorStops aColorStops
;
646 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
648 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
649 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
650 CPPUNIT_ASSERT_EQUAL(aColorStops
[0].getStopColor(),
651 basegfx::BColor(1.0, 0.75294117647058822, 0.0));
652 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
653 CPPUNIT_ASSERT_EQUAL(aColorStops
[1].getStopColor(),
654 basegfx::BColor(0.75294117647058822, 0.0, 0.0));
656 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR
, aGradient
.Style
);
657 CPPUNIT_ASSERT_EQUAL(sal_Int16(690), aGradient
.Angle
);
659 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineStyle_SOLID
),
660 xShapeProps
->getPropertyValue(u
"LineStyle"));
661 sal_Int32 nOutlineColor
;
662 xShapeProps
->getPropertyValue(u
"LineColor") >>= nOutlineColor
;
663 CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), nOutlineColor
);
664 sal_Int16 nLineTransparence
;
665 xShapeProps
->getPropertyValue(u
"LineTransparence") >>= nLineTransparence
;
666 CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nLineTransparence
);
669 // radial gradient, direct color with transparency, focus center, dotted outline
670 // The stop color transparency is imported as transparency gradient with same geometry.
672 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
673 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
674 xShapeProps
->getPropertyValue(u
"FillStyle"));
675 awt::Gradient2 aGradient
;
676 xShapeProps
->getPropertyValue(u
"FillGradient") >>= aGradient
;
678 // MCGR: Use the completely imported transparency gradient to check for correctness
679 basegfx::BColorStops aColorStops
;
680 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
682 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
683 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
684 CPPUNIT_ASSERT_EQUAL(aColorStops
[0].getStopColor(),
685 basegfx::BColor(0.0, 0.51372549019607838, 0.8784313725490196));
686 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
687 CPPUNIT_ASSERT_EQUAL(aColorStops
[1].getStopColor(),
688 basegfx::BColor(0.90196078431372551, 0.90196078431372551, 0.0));
690 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL
, aGradient
.Style
);
691 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.XOffset
);
692 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.YOffset
);
694 xShapeProps
->getPropertyValue(u
"FillTransparenceGradient") >>= aGradient
;
695 // MCGR: Use the completely imported transparency gradient to check for correctness
696 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
698 // Transparency is encoded in gray color.
699 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
700 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
701 CPPUNIT_ASSERT_EQUAL(
702 aColorStops
[0].getStopColor(),
703 basegfx::BColor(0.40000000000000002, 0.40000000000000002, 0.40000000000000002));
704 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
705 CPPUNIT_ASSERT_EQUAL(
706 aColorStops
[1].getStopColor(),
707 basegfx::BColor(0.29999999999999999, 0.29999999999999999, 0.29999999999999999));
709 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL
, aGradient
.Style
);
710 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.XOffset
);
711 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.YOffset
);
713 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineStyle_DASH
),
714 xShapeProps
->getPropertyValue(u
"LineStyle"));
715 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineCap_ROUND
),
716 xShapeProps
->getPropertyValue(u
"LineCap"));
717 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(7384391)),
718 xShapeProps
->getPropertyValue(u
"LineColor"));
719 drawing::LineDash aLineDash
;
720 xShapeProps
->getPropertyValue(u
"LineDash") >>= aLineDash
;
721 CPPUNIT_ASSERT_EQUAL(drawing::DashStyle_ROUNDRELATIVE
, aLineDash
.Style
);
722 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aLineDash
.Dots
);
723 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aLineDash
.Dashes
);
726 // solid theme color accent 1, rectangular transparency gradient, focus top-right, no outline
727 // FillProperties::pushToPropMap imports this currently (Mar 2023) as color gradient.
728 // Thus no theme color is tested but direct color.
730 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
731 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
732 xShapeProps
->getPropertyValue(u
"FillStyle"));
733 awt::Gradient2 aGradient
;
734 xShapeProps
->getPropertyValue(u
"FillGradient") >>= aGradient
;
736 // MCGR: Use the completely imported transparency gradient to check for correctness
737 basegfx::BColorStops aColorStops
;
738 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
740 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
741 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
742 CPPUNIT_ASSERT_EQUAL(
743 aColorStops
[0].getStopColor(),
744 basegfx::BColor(0.26666666666666666, 0.44705882352941179, 0.7686274509803922));
745 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
746 CPPUNIT_ASSERT_EQUAL(
747 aColorStops
[1].getStopColor(),
748 basegfx::BColor(0.26666666666666666, 0.44705882352941179, 0.7686274509803922));
750 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT
, aGradient
.Style
);
751 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient
.XOffset
);
752 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient
.YOffset
);
754 xShapeProps
->getPropertyValue(u
"FillTransparenceGradient") >>= aGradient
;
755 // MCGR: Use the completely imported transparency gradient to check for correctness
756 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
758 // Transparency is encoded in gray color.
759 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
760 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
761 CPPUNIT_ASSERT_EQUAL(aColorStops
[0].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
762 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
763 CPPUNIT_ASSERT_EQUAL(aColorStops
[1].getStopColor(), basegfx::BColor(1.0, 1.0, 1.0));
765 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT
, aGradient
.Style
);
766 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient
.XOffset
);
767 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient
.YOffset
);
769 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineStyle_NONE
),
770 xShapeProps
->getPropertyValue(u
"LineStyle"));
774 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWordArtBitmapFill
)
776 // The document has a WordArt shape with bitmap fill.
777 // Without fix it was imported as solid color fill.
778 loadFromURL(u
"tdf139618_WordArtBitmapFill.pptx");
780 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
781 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
783 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
784 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_BITMAP
),
785 xShapeProps
->getPropertyValue(u
"FillStyle"));
787 // Test some bitmap properties
788 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::BitmapMode_REPEAT
),
789 xShapeProps
->getPropertyValue(u
"FillBitmapMode"));
790 CPPUNIT_ASSERT_EQUAL(uno::Any(true), xShapeProps
->getPropertyValue(u
"FillBitmapTile"));
791 uno::Reference
<awt::XBitmap
> xBitmap
;
792 xShapeProps
->getPropertyValue(u
"FillBitmap") >>= xBitmap
;
794 uno::Reference
<graphic::XGraphic
> xGraphic
;
795 xGraphic
.set(xBitmap
, uno::UNO_QUERY
);
796 uno::Reference
<beans::XPropertySet
> xGraphicDescriptor(xGraphic
, uno::UNO_QUERY_THROW
);
798 CPPUNIT_ASSERT(xGraphicDescriptor
->getPropertyValue("MimeType") >>= sMimeType
);
799 CPPUNIT_ASSERT_EQUAL(OUString("image/jpeg"), sMimeType
);
800 awt::Size aSize100thMM
;
801 CPPUNIT_ASSERT(xGraphicDescriptor
->getPropertyValue("Size100thMM") >>= aSize100thMM
);
802 CPPUNIT_ASSERT_EQUAL(sal_Int32(1592), aSize100thMM
.Width
);
803 CPPUNIT_ASSERT_EQUAL(sal_Int32(1592), aSize100thMM
.Height
);
806 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWordArtDefaultColor
)
808 // The document has a WordArt shape for which the text color is not explicitly set. In such cases
809 // MS Office uses the scheme color 'tx1'. Without fix it was imported as 'fill none'. The shape
810 // existed but was not visible on screen.
811 loadFromURL(u
"tdf155327_WordArtDefaultColor.pptx");
813 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
814 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
816 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
817 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_SOLID
),
818 xShapeProps
->getPropertyValue(u
"FillStyle"));
820 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(3, 74, 144)), xShapeProps
->getPropertyValue(u
"FillColor"));
823 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testGlowOnGroup
)
825 // The document contains a group of two shapes. A glow-effect is set on the group.
826 // Without the fix, the children of the group were not imported at all.
827 loadFromURL(u
"tdf156902_GlowOnGroup.docx");
828 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
829 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
831 uno::Reference
<container::XIndexAccess
> xGroup(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
832 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroup
->getCount());
834 CPPUNIT_PLUGIN_IMPLEMENT();
836 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */