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>
42 #include <editeng/unoprnms.hxx>
44 using namespace ::com::sun::star
;
48 /// Gets one child of xShape, which one is specified by nIndex.
49 uno::Reference
<drawing::XShape
> getChildShape(const uno::Reference
<drawing::XShape
>& xShape
,
52 uno::Reference
<container::XIndexAccess
> xGroup(xShape
, uno::UNO_QUERY
);
53 CPPUNIT_ASSERT(xGroup
.is());
55 CPPUNIT_ASSERT(xGroup
->getCount() > nIndex
);
57 uno::Reference
<drawing::XShape
> xRet(xGroup
->getByIndex(nIndex
), uno::UNO_QUERY
);
58 CPPUNIT_ASSERT(xRet
.is());
65 class OoxShapeTest
: public UnoApiTest
69 : UnoApiTest(u
"/oox/qa/unit/data/"_ustr
)
72 uno::Reference
<drawing::XShape
> getShapeByName(std::u16string_view aName
);
75 uno::Reference
<drawing::XShape
> OoxShapeTest::getShapeByName(std::u16string_view aName
)
77 uno::Reference
<drawing::XShape
> xRet
;
79 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
80 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
82 for (sal_Int32 i
= 0; i
< xDrawPage
->getCount(); ++i
)
84 uno::Reference
<container::XNamed
> xShape(xDrawPage
->getByIndex(i
), uno::UNO_QUERY
);
85 if (xShape
->getName() == aName
)
87 xRet
.set(xShape
, uno::UNO_QUERY
);
95 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testConnectorConnection
)
97 loadFromFile(u
"connectorConnection.pptx");
99 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
100 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
103 uno::Reference
<drawing::XShape
> xConnector(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
104 uno::Reference
<beans::XPropertySet
> xConnectorProps(xConnector
, uno::UNO_QUERY
);
106 // Without the accompanying fix in place, this test would have failed with:
109 // i.e. the connector shape is not attaching to the shape
110 sal_Int32 nStartGlueId
;
111 xConnectorProps
->getPropertyValue("StartGluePointIndex") >>= nStartGlueId
;
112 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nStartGlueId
);
114 // Without the accompanying fix in place, this test would have failed with:
117 // i.e. the connector shape is not attaching to the shape
118 sal_Int32 nEndGlueId
;
119 xConnectorProps
->getPropertyValue("EndGluePointIndex") >>= nEndGlueId
;
120 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nEndGlueId
);
123 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testElbowConnectors
)
125 loadFromFile(u
"elbowConnectors.pptx");
127 sal_Int32 nEdgeLineDelta
;
128 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
129 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
132 uno::Reference
<drawing::XShape
> xShape1(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
133 uno::Reference
<beans::XPropertySet
> xShapeProps1(xShape1
, uno::UNO_QUERY
);
134 xShapeProps1
->getPropertyValue(UNO_NAME_EDGELINE1DELTA
) >>= nEdgeLineDelta
;
135 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2756), nEdgeLineDelta
);
137 uno::Reference
<drawing::XShape
> xShape2(xDrawPage
->getByIndex(5), uno::UNO_QUERY
);
138 uno::Reference
<beans::XPropertySet
> xShapeProps2(xShape2
, uno::UNO_QUERY
);
139 xShapeProps2
->getPropertyValue(UNO_NAME_EDGELINE1DELTA
) >>= nEdgeLineDelta
;
140 CPPUNIT_ASSERT_EQUAL(sal_Int32(-805), nEdgeLineDelta
);
143 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testCurvedConnectors
)
145 loadFromFile(u
"curvedConnectors.pptx");
147 sal_Int32 nEdgeLineDelta
;
148 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
149 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
152 uno::Reference
<drawing::XShape
> xShape1(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
153 uno::Reference
<beans::XPropertySet
> xShapeProps1(xShape1
, uno::UNO_QUERY
);
154 xShapeProps1
->getPropertyValue(UNO_NAME_EDGELINE1DELTA
) >>= nEdgeLineDelta
;
155 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2364), nEdgeLineDelta
);
156 xShapeProps1
->getPropertyValue(UNO_NAME_EDGELINE2DELTA
) >>= nEdgeLineDelta
;
157 CPPUNIT_ASSERT_EQUAL(sal_Int32(4250), nEdgeLineDelta
);
158 xShapeProps1
->getPropertyValue(UNO_NAME_EDGELINE3DELTA
) >>= nEdgeLineDelta
;
159 CPPUNIT_ASSERT_EQUAL(sal_Int32(2051), nEdgeLineDelta
);
161 uno::Reference
<drawing::XShape
> xShape2(xDrawPage
->getByIndex(5), uno::UNO_QUERY
);
162 uno::Reference
<beans::XPropertySet
> xShapeProps2(xShape2
, uno::UNO_QUERY
);
163 xShapeProps2
->getPropertyValue(UNO_NAME_EDGELINE1DELTA
) >>= nEdgeLineDelta
;
164 CPPUNIT_ASSERT_EQUAL(sal_Int32(3019), nEdgeLineDelta
);
167 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testStandardConnectors
)
169 loadFromFile(u
"standardConnectors.pptx");
171 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
172 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
175 sal_Int32 aEdgeValue
[] = { -1352, -2457, 2402, // bentConnector5
176 3977, 0, 0, // bentConnector3
177 -2899, 0, 0, // bentConnector3
178 -1260, 4612, 0, // bentConnector4
179 -1431, -2642, 0, // bentConnector4
180 3831, 3438, -1578 }; // bentConnector5
181 sal_Int32 nCount
= 0;
182 sal_Int32 nEdgeLineDelta
;
183 for (size_t i
= 0; i
< 10; i
++)
185 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(i
), uno::UNO_QUERY
);
186 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
187 bool bConnector
= xShapeProps
->getPropertySetInfo()->hasPropertyByName(u
"EdgeKind"_ustr
);
190 xShapeProps
->getPropertyValue(UNO_NAME_EDGELINE1DELTA
) >>= nEdgeLineDelta
;
191 CPPUNIT_ASSERT_EQUAL(aEdgeValue
[nCount
], nEdgeLineDelta
);
193 xShapeProps
->getPropertyValue(UNO_NAME_EDGELINE2DELTA
) >>= nEdgeLineDelta
;
194 CPPUNIT_ASSERT_EQUAL(aEdgeValue
[nCount
], nEdgeLineDelta
);
196 xShapeProps
->getPropertyValue(UNO_NAME_EDGELINE3DELTA
) >>= nEdgeLineDelta
;
197 CPPUNIT_ASSERT_EQUAL(aEdgeValue
[nCount
], nEdgeLineDelta
);
203 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testGroupTransform
)
205 loadFromFile(u
"tdf141463_GroupTransform.pptx");
207 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
208 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
210 uno::Reference
<drawing::XShape
> xGroup(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
211 uno::Reference
<drawing::XShape
> xShape(getChildShape(xGroup
, 0), uno::UNO_QUERY
);
212 uno::Reference
<beans::XPropertySet
> xPropSet(xShape
, uno::UNO_QUERY
);
213 // Without the accompanying fix in place, this test would have failed in several properties.
216 xPropSet
->getPropertyValue(u
"ShearAngle"_ustr
) >>= nAngle
;
217 // Failed with - Expected: 0
219 // i.e. the shape was sheared although shearing does not exist in oox
220 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAngle
);
222 xPropSet
->getPropertyValue(u
"RotateAngle"_ustr
) >>= nAngle
;
223 // Failed with - Expected: 26000 (is in 1/100deg)
224 // - Actual : 26481 (is in 1/100deg)
225 // 100deg in PowerPoint UI = 360deg - 100deg in LO.
226 CPPUNIT_ASSERT_EQUAL(sal_Int32(26000), nAngle
);
228 sal_Int32 nActual
= xShape
->getSize().Width
;
229 // The group has ext.cy=2880000 and chExt.cy=4320000 resulting in Y-scale=2/3.
230 // The child has ext 2880000 x 1440000. Because of rotation angle 80deg, the Y-scale has to be
231 // applied to the width, resulting in 2880000 * 2/3 = 1920000EMU = 5333Hmm
232 // ToDo: Expected value currently 1 off.
233 // Failed with - Expected: 5332
235 CPPUNIT_ASSERT_EQUAL(sal_Int32(5332), nActual
);
238 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testMultipleGroupShapes
)
240 loadFromFile(u
"multiple-group-shapes.docx");
242 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
243 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
245 // Without the accompanying fix in place, this test would have failed with:
248 // i.e. the 2 group shapes from the document were imported as a single one.
249 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xDrawPage
->getCount());
252 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testCustomshapePosition
)
254 loadFromFile(u
"customshape-position.docx");
256 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
257 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
259 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
262 xShape
->getPropertyValue(u
"VertOrientPosition"_ustr
) >>= nY
;
263 // <wp:posOffset>581025</wp:posOffset> in the document.
264 sal_Int32 nExpected
= rtl::math::round(581025.0 / 360);
265 // Without the accompanying fix in place, this test would have failed with:
268 // i.e. the position of the shape was lost on import due to the rounded corners.
269 CPPUNIT_ASSERT_EQUAL(nExpected
, nY
);
272 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testTdf125582_TextOnCircle
)
274 // The document contains a shape with a:prstTxWarp="textCircle" with two paragraphs.
275 // PowerPoint aligns the bottom of the text with the path, LO had aligned the middle of the
276 // text with the path, which resulted in smaller text.
277 loadFromFile(u
"tdf125582_TextOnCircle.pptx");
279 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
280 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
282 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
283 uno::Reference
<beans::XPropertySet
> xPropSet(xShape
, uno::UNO_QUERY
);
285 // BoundRect of Fontwork shape depends on dpi.
288 SdrObjCustomShape
& rSdrCustomShape(
289 static_cast<SdrObjCustomShape
&>(*SdrObject::getSdrObjectFromXShape(xShape
)));
290 // Without the fix in place width was 3639, but should be 4784 for 96dpi.
291 tools::Rectangle
aBoundRect(rSdrCustomShape
.GetCurrentBoundRect());
292 CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(4784), aBoundRect
.GetWidth(), 5);
295 drawing::TextVerticalAdjust eAdjust
;
296 xPropSet
->getPropertyValue(u
"TextVerticalAdjust"_ustr
) >>= eAdjust
;
297 CPPUNIT_ASSERT_EQUAL_MESSAGE("TextVerticalAdjust", drawing::TextVerticalAdjust_BOTTOM
, eAdjust
);
300 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testTdf151008VertAnchor
)
302 // The document contains shapes with all six kind of anchor positions in pptx. The text in the
303 // shapes is larger than the shape and has no word wrap. That way anchor position is visible
304 // in case you inspect the file manually.
305 loadFromFile(u
"tdf151008_eaVertAnchor.pptx");
310 drawing::TextHorizontalAdjust eAnchorHori
;
311 drawing::TextVerticalAdjust eAnchorVert
;
313 anchorDesc aExpected
[6]
314 = { { u
"Right"_ustr
, drawing::TextHorizontalAdjust_RIGHT
, drawing::TextVerticalAdjust_TOP
},
315 { u
"Center"_ustr
, drawing::TextHorizontalAdjust_CENTER
,
316 drawing::TextVerticalAdjust_TOP
},
317 { u
"Left"_ustr
, drawing::TextHorizontalAdjust_LEFT
, drawing::TextVerticalAdjust_TOP
},
318 { u
"RightMiddle"_ustr
, drawing::TextHorizontalAdjust_RIGHT
,
319 drawing::TextVerticalAdjust_CENTER
},
320 { u
"CenterMiddle"_ustr
, drawing::TextHorizontalAdjust_CENTER
,
321 drawing::TextVerticalAdjust_CENTER
},
322 { u
"LeftMiddle"_ustr
, drawing::TextHorizontalAdjust_LEFT
,
323 drawing::TextVerticalAdjust_CENTER
} };
324 // without the fix horizontal and vertical anchor positions were exchanged
325 for (size_t i
= 0; i
< 6; ++i
)
327 uno::Reference
<beans::XPropertySet
> xShape(getShapeByName(aExpected
[i
].sShapeName
),
329 drawing::TextHorizontalAdjust eHori
;
330 CPPUNIT_ASSERT(xShape
->getPropertyValue(u
"TextHorizontalAdjust"_ustr
) >>= eHori
);
331 drawing::TextVerticalAdjust eVert
;
332 CPPUNIT_ASSERT(xShape
->getPropertyValue(u
"TextVerticalAdjust"_ustr
) >>= eVert
);
333 CPPUNIT_ASSERT_EQUAL(aExpected
[i
].eAnchorHori
, eHori
);
334 CPPUNIT_ASSERT_EQUAL(aExpected
[i
].eAnchorVert
, eVert
);
338 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testTdf151518VertAnchor
)
340 // Make sure SmartArt is loaded as group shape
341 bool bUseGroup
= officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::get();
344 std::shared_ptr
<comphelper::ConfigurationChanges
> pChange(
345 comphelper::ConfigurationChanges::create());
346 officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(true, pChange
);
350 // The document contains SmartArt with shapes with not default text area. Without fix the
351 // text was shifted up because of wrong values in TextLowerDistance and TextUpperDistance.
352 loadFromFile(u
"tdf151518_SmartArtTextLocation.docx");
357 sal_Int16 nSubShapeIndex
;
358 sal_Int32 nLowerDistance
;
359 sal_Int32 nUpperDistance
;
361 TextDistance aExpected
[4] = { { u
"Diagram Target List"_ustr
, 2, 2979, 201 },
362 { u
"Diagram Nested Target"_ustr
, 1, 3203, 127 },
363 { u
"Diagram Stacked Venn"_ustr
, 1, 3112, -302 },
364 { u
"Diagram Grouped List"_ustr
, 1, 4106, 196 } };
365 // without the fix the observed distances were
366 // {4434, -464}, {4674, -751}, {4620, -1399}, {6152, -744}
367 for (size_t i
= 0; i
< 4; ++i
)
369 uno::Reference
<drawing::XShapes
> xDiagramShape(getShapeByName(aExpected
[i
].sShapeName
),
371 uno::Reference
<beans::XPropertySet
> xShapeProps(
372 xDiagramShape
->getByIndex(aExpected
[i
].nSubShapeIndex
), uno::UNO_QUERY
);
375 CPPUNIT_ASSERT(xShapeProps
->getPropertyValue(u
"TextLowerDistance"_ustr
) >>= nLower
);
376 CPPUNIT_ASSERT(xShapeProps
->getPropertyValue(u
"TextUpperDistance"_ustr
) >>= nUpper
);
377 CPPUNIT_ASSERT_EQUAL(aExpected
[i
].nLowerDistance
, nLower
);
378 CPPUNIT_ASSERT_EQUAL(aExpected
[i
].nUpperDistance
, nUpper
);
383 std::shared_ptr
<comphelper::ConfigurationChanges
> pChange(
384 comphelper::ConfigurationChanges::create());
385 officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(false, pChange
);
390 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testTdf54095_SmartArtThemeTextColor
)
392 // The document contains a SmartArt where the color for the texts in the shapes is given by
394 // Error was, that the theme was not considered and therefore the text was white.
396 // Make sure it is not loaded as metafile but with single shapes.
397 bool bUseGroup
= officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::get();
400 std::shared_ptr
<comphelper::ConfigurationChanges
> pChange(
401 comphelper::ConfigurationChanges::create());
402 officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(true, pChange
);
407 loadFromFile(u
"tdf54095_SmartArtThemeTextColor.docx");
408 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
409 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
411 uno::Reference
<drawing::XShapes
> xSmartArt(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
412 // shape 0 is the background shape without text
413 uno::Reference
<text::XTextRange
> xShape(xSmartArt
->getByIndex(1), uno::UNO_QUERY
);
416 uno::Reference
<container::XEnumerationAccess
> xText(xShape
->getText(), uno::UNO_QUERY
);
417 uno::Reference
<container::XEnumerationAccess
> xPara(xText
->createEnumeration()->nextElement(),
419 uno::Reference
<beans::XPropertySet
> xPortion(xPara
->createEnumeration()->nextElement(),
421 Color nActualColor
{ 0 };
422 xPortion
->getPropertyValue(u
"CharColor"_ustr
) >>= nActualColor
;
423 // Without fix the test would have failed with:
424 // - Expected: rgba[1f497dff]
425 // - Actual : rgba[ffffffff], that is text was white
426 CPPUNIT_ASSERT_EQUAL(Color(0x1F497D), nActualColor
);
428 // clrScheme. For map between name in docx and index from CharComplexColor see
429 // oox::drawingml::Color::getSchemeColorIndex()
430 // Without fix the color scheme was "lt1" (1) but should be "dk2" (2).
431 uno::Reference
<util::XComplexColor
> xComplexColor
;
432 xPortion
->getPropertyValue(u
"CharComplexColor"_ustr
) >>= xComplexColor
;
433 CPPUNIT_ASSERT(xComplexColor
.is());
434 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
435 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Dark2
, aComplexColor
.getThemeColorType());
439 std::shared_ptr
<comphelper::ConfigurationChanges
> pChange(
440 comphelper::ConfigurationChanges::create());
441 officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(false, pChange
);
446 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterFontwork
)
448 loadFromFile(u
"tdf125885_WordArt.docx");
449 // Without the patch WordArt in text document was imported as rectangular custom shape with
450 // attached frame. So there was no artistic text at all. Now it is imported as Fontwork.
451 // This test covers some basic properties.
453 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
454 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
456 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
459 bool bTextBox
= bool();
460 CPPUNIT_ASSERT(xShapeProps
->getPropertyValue(u
"TextBox"_ustr
) >>= bTextBox
);
461 CPPUNIT_ASSERT(!bTextBox
);
463 uno::Reference
<css::text::XTextFrame
> xTextFrame
;
464 xShapeProps
->getPropertyValue(u
"TextBoxContent"_ustr
) >>= xTextFrame
;
465 CPPUNIT_ASSERT(!xTextFrame
.is());
467 uno::Sequence
<beans::PropertyValue
> aGeoPropSeq
;
468 xShapeProps
->getPropertyValue(u
"CustomShapeGeometry"_ustr
) >>= aGeoPropSeq
;
469 CPPUNIT_ASSERT(aGeoPropSeq
.getLength() > 0);
470 comphelper::SequenceAsHashMap
aGeoPropMap(aGeoPropSeq
);
472 uno::Sequence
<beans::PropertyValue
> aTextPathSeq
;
473 aGeoPropMap
.getValue(u
"TextPath"_ustr
) >>= aTextPathSeq
;
474 CPPUNIT_ASSERT(aTextPathSeq
.getLength() > 0);
476 comphelper::SequenceAsHashMap
aTextPathPropMap(aTextPathSeq
);
477 bool bTextPathOn
= bool();
478 CPPUNIT_ASSERT(aTextPathPropMap
.getValue(u
"TextPath"_ustr
) >>= bTextPathOn
);
479 CPPUNIT_ASSERT(bTextPathOn
);
481 // Is it the correct kind of Fontwork?
482 uno::Sequence
<drawing::EnhancedCustomShapeAdjustmentValue
> aAdjustmentSeq
;
483 aGeoPropMap
.getValue(u
"AdjustmentValues"_ustr
) >>= aAdjustmentSeq
;
484 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aAdjustmentSeq
.getLength());
486 uno::Sequence
<uno::Sequence
<beans::PropertyValue
>> aHandleSeq
;
487 aGeoPropMap
.getValue(u
"Handles"_ustr
) >>= aHandleSeq
;
488 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aHandleSeq
.getLength());
490 awt::Rectangle aViewBox
;
491 aGeoPropMap
.getValue(u
"ViewBox"_ustr
) >>= aViewBox
;
492 CPPUNIT_ASSERT_EQUAL(sal_Int32(21600), aViewBox
.Width
);
493 CPPUNIT_ASSERT_EQUAL(sal_Int32(21600), aViewBox
.Height
);
495 CPPUNIT_ASSERT_EQUAL(uno::Any(u
"textDoubleWave1"_ustr
),
496 aGeoPropMap
.getValue(u
"PresetTextWarp"_ustr
));
498 CPPUNIT_ASSERT_EQUAL(uno::Any(u
"mso-spt158"_ustr
), aGeoPropMap
.getValue(u
"Type"_ustr
));
500 // Are properties correctly copied to shape?
501 CPPUNIT_ASSERT_EQUAL(uno::Any(COL_LIGHTBLUE
), xShapeProps
->getPropertyValue(u
"FillColor"_ustr
));
503 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_SOLID
),
504 xShapeProps
->getPropertyValue(u
"FillStyle"_ustr
));
506 CPPUNIT_ASSERT_EQUAL(uno::Any(u
"Courier New"_ustr
),
507 xShapeProps
->getPropertyValue(u
"CharFontName"_ustr
));
509 CPPUNIT_ASSERT_EQUAL(uno::Any(float(awt::FontWeight::BOLD
)),
510 xShapeProps
->getPropertyValue(u
"CharWeight"_ustr
));
512 lang::Locale aCharLocale
;
513 xShapeProps
->getPropertyValue(u
"CharLocale"_ustr
) >>= aCharLocale
;
514 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, aCharLocale
.Language
);
515 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, aCharLocale
.Country
);
517 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::TextHorizontalAdjust_RIGHT
),
518 xShapeProps
->getPropertyValue(u
"TextHorizontalAdjust"_ustr
));
521 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterFontwork2
)
523 loadFromFile(u
"tdf125885_WordArt2.docx");
524 // Without the patch WordArt in text document was imported as rectangular custom shape with
525 // attached frame. So there was no artistic text at all. Now it is imported as Fontwork.
526 // This test covers whether theme color properties are correctly converted on import.
528 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
529 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
531 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
534 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(4000)),
535 xShapeProps
->getPropertyValue(u
"FillColorLumMod"_ustr
));
536 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(6000)),
537 xShapeProps
->getPropertyValue(u
"FillColorLumOff"_ustr
));
538 // ID "6" for the theme "accent3" is not yet in API, but defined in enum PredefinedClrSchemeID
539 // in drawingml/clrscheme.hxx.
540 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(6)),
541 xShapeProps
->getPropertyValue(u
"FillColorTheme"_ustr
));
542 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(215, 228, 189)),
543 xShapeProps
->getPropertyValue(u
"FillColor"_ustr
));
546 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineCap_ROUND
),
547 xShapeProps
->getPropertyValue(u
"LineCap"_ustr
));
548 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineStyle_DASH
),
549 xShapeProps
->getPropertyValue(u
"LineStyle"_ustr
));
550 // Stroke has only the resulted color, but no reference to the used theme color "accent2".
551 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(149, 55, 53)),
552 xShapeProps
->getPropertyValue(u
"LineColor"_ustr
));
553 drawing::LineDash aLineDash
;
554 xShapeProps
->getPropertyValue(u
"LineDash"_ustr
) >>= aLineDash
;
555 CPPUNIT_ASSERT_EQUAL(drawing::DashStyle_ROUNDRELATIVE
, aLineDash
.Style
);
556 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aLineDash
.Dots
);
557 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aLineDash
.DotLen
);
558 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aLineDash
.Dashes
);
559 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aLineDash
.DashLen
);
560 CPPUNIT_ASSERT_EQUAL(sal_Int32(199), aLineDash
.Distance
);
561 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(635)),
562 xShapeProps
->getPropertyValue(u
"LineWidth"_ustr
));
563 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(20)),
564 xShapeProps
->getPropertyValue(u
"LineTransparence"_ustr
));
565 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineJoint_BEVEL
),
566 xShapeProps
->getPropertyValue(u
"LineJoint"_ustr
));
569 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterFontwork3
)
571 loadFromFile(u
"tdf125885_WordArt3.docx");
572 // Without the patch WordArt in text document was imported as rectangular custom shape with
573 // attached frame. So there was no artistic text at all. Now it is imported as Fontwork.
574 // This test covers some aspects of import of gradient fill.
576 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
577 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
580 // linear gradient, MSO UI 21deg
582 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
583 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
584 xShapeProps
->getPropertyValue(u
"FillStyle"_ustr
));
585 awt::Gradient2 aGradient
;
586 xShapeProps
->getPropertyValue(u
"FillGradient"_ustr
) >>= aGradient
;
588 // MCGR: Use the completely imported transparency gradient to check for correctness
589 basegfx::BColorStops aColorStops
;
590 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
592 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
593 CPPUNIT_ASSERT_EQUAL(0.0, aColorStops
[0].getStopOffset());
594 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE
, Color(aColorStops
[0].getStopColor()));
595 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
596 CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops
[1].getStopColor()));
598 CPPUNIT_ASSERT_EQUAL(sal_Int16(690), aGradient
.Angle
);
599 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient
.XOffset
);
600 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient
.YOffset
);
601 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR
, aGradient
.Style
);
604 // radial gradient, centered
606 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
607 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
608 xShapeProps
->getPropertyValue(u
"FillStyle"_ustr
));
609 awt::Gradient2 aGradient
;
610 xShapeProps
->getPropertyValue(u
"FillGradient"_ustr
) >>= aGradient
;
612 // MCGR: Use the completely imported transparency gradient to check for correctness
613 basegfx::BColorStops aColorStops
;
614 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
616 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
617 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.40000000000000002));
618 CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops
[0].getStopColor()));
619 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
620 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE
, Color(aColorStops
[1].getStopColor()));
622 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aGradient
.Angle
);
623 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.XOffset
);
624 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.YOffset
);
625 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL
, aGradient
.Style
);
628 // rectangular gradient, focus right, bottom
630 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
631 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
632 xShapeProps
->getPropertyValue(u
"FillStyle"_ustr
));
633 awt::Gradient2 aGradient
;
634 xShapeProps
->getPropertyValue(u
"FillGradient"_ustr
) >>= aGradient
;
636 // MCGR: Use the completely imported transparency gradient to check for correctness
637 basegfx::BColorStops aColorStops
;
638 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
640 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
641 CPPUNIT_ASSERT_EQUAL(0.0, aColorStops
[0].getStopOffset());
642 CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops
[0].getStopColor()));
643 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
644 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE
, Color(aColorStops
[1].getStopColor()));
646 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aGradient
.Angle
);
647 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient
.XOffset
);
648 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient
.YOffset
);
649 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT
, aGradient
.Style
);
653 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterFontworkNonAccentColor
)
655 loadFromFile(u
"tdf152840_WordArt_non_accent_color.docx");
656 // The file contains WordArt which uses the theme colors "Background 1", "Text 1", "Background 2"
659 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
660 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
663 // The ID for the theme colors is not yet in API, but defined in enum PredefinedClrSchemeID
664 // in drawingml/clrscheme.hxx. Without fix the ID was -1 meaning no theme is used, and the color
667 // background 1 = lt1 = ID 1
668 uno::Reference
<beans::XPropertySet
> xShape0Props(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
669 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(1)),
670 xShape0Props
->getPropertyValue(u
"FillColorTheme"_ustr
));
671 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(255, 204, 153)),
672 xShape0Props
->getPropertyValue(u
"FillColor"_ustr
));
674 // text 1 = dk1 = ID 0
675 uno::Reference
<beans::XPropertySet
> xShape1Props(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
676 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(0)),
677 xShape1Props
->getPropertyValue(u
"FillColorTheme"_ustr
));
678 CPPUNIT_ASSERT_EQUAL(uno::Any(COL_LIGHTRED
), xShape1Props
->getPropertyValue(u
"FillColor"_ustr
));
680 // background 2 = lt2 = ID 3
681 uno::Reference
<beans::XPropertySet
> xShape2Props(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
682 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(3)),
683 xShape2Props
->getPropertyValue(u
"FillColorTheme"_ustr
));
684 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(235, 221, 195)),
685 xShape2Props
->getPropertyValue(u
"FillColor"_ustr
));
687 // text 2 = dk2 = ID 2
688 uno::Reference
<beans::XPropertySet
> xShape3Props(xDrawPage
->getByIndex(3), uno::UNO_QUERY
);
689 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(2)),
690 xShape3Props
->getPropertyValue(u
"FillColorTheme"_ustr
));
691 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(119, 95, 85)),
692 xShape3Props
->getPropertyValue(u
"FillColor"_ustr
));
695 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterShapeFillNonAccentColor
)
697 loadFromFile(u
"tdf152840_theme_color_non_accent.docx");
698 // The file contains shapes which uses the theme colors "bg2", "bg1", "tx1" and "tx2" in this
699 // order as fill color.
701 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
702 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
705 // The ID for the theme colors is not yet in API, but defined in enum PredefinedClrSchemeID
706 // in drawingml/clrscheme.hxx. Without fix the ID was -1 meaning no theme is used.
707 uno::Reference
<beans::XPropertySet
> xShape0Props(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
708 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(3)),
709 xShape0Props
->getPropertyValue(u
"FillColorTheme"_ustr
));
710 uno::Reference
<beans::XPropertySet
> xShape1Props(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
711 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(1)),
712 xShape1Props
->getPropertyValue(u
"FillColorTheme"_ustr
));
713 uno::Reference
<beans::XPropertySet
> xShape2Props(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
714 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(0)),
715 xShape2Props
->getPropertyValue(u
"FillColorTheme"_ustr
));
716 uno::Reference
<beans::XPropertySet
> xShape3Props(xDrawPage
->getByIndex(3), uno::UNO_QUERY
);
717 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(2)),
718 xShape3Props
->getPropertyValue(u
"FillColorTheme"_ustr
));
721 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWriterFontworkDarkenTransparency
)
723 loadFromFile(u
"tdf152896_WordArt_color_darken.docx");
724 // The file contains a WordArt shape with theme colors "Background 2", shading mode "Darken 25%"
725 // and "20% Transparency". Word writes this as w:color element with additional w14:textFill
726 // element. In such case the w14:textFill element supersedes the w:color element. Error was, that
727 // the darkening was applied twice, once from w:color and the other time from w14:textFill.
729 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
730 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
733 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
734 // Without the fix in place the test would have failed with
735 // Expected: 13676402 (= 0xD0AF72 = rgb(208, 175, 114) => luminance 63.14%)
736 // Actual: 11897660 (= 0xB58B3C = rgb(181, 139, 60) => luminance 47.25% )
737 // The original "Background 2" is 0xEBDDC3 = rgb(235, 221, 195) => luminance 84.31%
738 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(208, 175, 114)),
739 xShapeProps
->getPropertyValue(u
"FillColor"_ustr
));
742 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testImportWordArtGradient
)
744 loadFromFile(u
"tdf139618_ImportWordArtGradient.pptx");
745 // Without the patch all WordArt was imported with solid color. Now gradient is imported.
746 // This test covers several aspects of import of gradient fill.
748 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
749 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
752 // linear gradient, MSO UI 21deg, solid transparency on outline
754 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
755 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
756 xShapeProps
->getPropertyValue(u
"FillStyle"_ustr
));
757 awt::Gradient2 aGradient
;
758 xShapeProps
->getPropertyValue(u
"FillGradient"_ustr
) >>= aGradient
;
760 // MCGR: Use the completely imported transparency gradient to check for correctness
761 basegfx::BColorStops aColorStops
;
762 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
764 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
765 CPPUNIT_ASSERT_EQUAL(0.0, aColorStops
[0].getStopOffset());
766 CPPUNIT_ASSERT_EQUAL(Color(0xffc000), Color(aColorStops
[0].getStopColor()));
767 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
768 CPPUNIT_ASSERT_EQUAL(Color(0xc00000), Color(aColorStops
[1].getStopColor()));
770 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR
, aGradient
.Style
);
771 CPPUNIT_ASSERT_EQUAL(sal_Int16(690), aGradient
.Angle
);
773 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineStyle_SOLID
),
774 xShapeProps
->getPropertyValue(u
"LineStyle"_ustr
));
775 sal_Int32 nOutlineColor
;
776 xShapeProps
->getPropertyValue(u
"LineColor"_ustr
) >>= nOutlineColor
;
777 CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), nOutlineColor
);
778 sal_Int16 nLineTransparence
;
779 xShapeProps
->getPropertyValue(u
"LineTransparence"_ustr
) >>= nLineTransparence
;
780 CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nLineTransparence
);
783 // radial gradient, direct color with transparency, focus center, dotted outline
784 // The stop color transparency is imported as transparency gradient with same geometry.
786 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
787 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
788 xShapeProps
->getPropertyValue(u
"FillStyle"_ustr
));
789 awt::Gradient2 aGradient
;
790 xShapeProps
->getPropertyValue(u
"FillGradient"_ustr
) >>= aGradient
;
792 // MCGR: Use the completely imported transparency gradient to check for correctness
793 basegfx::BColorStops aColorStops
;
794 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
796 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
797 CPPUNIT_ASSERT_EQUAL(0.0, aColorStops
[0].getStopOffset());
798 CPPUNIT_ASSERT_EQUAL(Color(0x0083e0), Color(aColorStops
[0].getStopColor()));
799 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
800 CPPUNIT_ASSERT_EQUAL(Color(0xe6e600), Color(aColorStops
[1].getStopColor()));
802 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL
, aGradient
.Style
);
803 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.XOffset
);
804 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.YOffset
);
806 xShapeProps
->getPropertyValue(u
"FillTransparenceGradient"_ustr
) >>= aGradient
;
807 // MCGR: Use the completely imported transparency gradient to check for correctness
808 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
810 // Transparency is encoded in gray color.
811 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
812 CPPUNIT_ASSERT_EQUAL(0.0, aColorStops
[0].getStopOffset());
813 CPPUNIT_ASSERT_EQUAL(COL_GRAY7
, Color(aColorStops
[0].getStopColor()));
814 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
815 CPPUNIT_ASSERT_EQUAL(Color(0x4d4d4d), Color(aColorStops
[1].getStopColor()));
817 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL
, aGradient
.Style
);
818 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.XOffset
);
819 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient
.YOffset
);
821 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineStyle_DASH
),
822 xShapeProps
->getPropertyValue(u
"LineStyle"_ustr
));
823 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineCap_ROUND
),
824 xShapeProps
->getPropertyValue(u
"LineCap"_ustr
));
825 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(7384391)),
826 xShapeProps
->getPropertyValue(u
"LineColor"_ustr
));
827 drawing::LineDash aLineDash
;
828 xShapeProps
->getPropertyValue(u
"LineDash"_ustr
) >>= aLineDash
;
829 CPPUNIT_ASSERT_EQUAL(drawing::DashStyle_ROUNDRELATIVE
, aLineDash
.Style
);
830 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aLineDash
.Dots
);
831 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aLineDash
.Dashes
);
834 // solid theme color accent 1, rectangular transparency gradient, focus top-right, no outline
835 // FillProperties::pushToPropMap imports this currently (Mar 2023) as color gradient.
836 // Thus no theme color is tested but direct color.
838 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
839 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT
),
840 xShapeProps
->getPropertyValue(u
"FillStyle"_ustr
));
841 awt::Gradient2 aGradient
;
842 xShapeProps
->getPropertyValue(u
"FillGradient"_ustr
) >>= aGradient
;
844 // MCGR: Use the completely imported transparency gradient to check for correctness
845 basegfx::BColorStops aColorStops
;
846 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
848 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
849 CPPUNIT_ASSERT_EQUAL(0.0, aColorStops
[0].getStopOffset());
850 CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), Color(aColorStops
[0].getStopColor()));
851 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
852 CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), Color(aColorStops
[1].getStopColor()));
854 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT
, aGradient
.Style
);
855 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient
.XOffset
);
856 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient
.YOffset
);
858 xShapeProps
->getPropertyValue(u
"FillTransparenceGradient"_ustr
) >>= aGradient
;
859 // MCGR: Use the completely imported transparency gradient to check for correctness
860 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
862 // Transparency is encoded in gray color.
863 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
864 CPPUNIT_ASSERT_EQUAL(0.0, aColorStops
[0].getStopOffset());
865 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, Color(aColorStops
[0].getStopColor()));
866 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
867 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, Color(aColorStops
[1].getStopColor()));
869 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT
, aGradient
.Style
);
870 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient
.XOffset
);
871 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient
.YOffset
);
873 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineStyle_NONE
),
874 xShapeProps
->getPropertyValue(u
"LineStyle"_ustr
));
878 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWordArtBitmapFill
)
880 // The document has a WordArt shape with bitmap fill.
881 // Without fix it was imported as solid color fill.
882 loadFromFile(u
"tdf139618_WordArtBitmapFill.pptx");
884 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
885 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
887 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
888 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_BITMAP
),
889 xShapeProps
->getPropertyValue(u
"FillStyle"_ustr
));
891 // Test some bitmap properties
892 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::BitmapMode_REPEAT
),
893 xShapeProps
->getPropertyValue(u
"FillBitmapMode"_ustr
));
894 CPPUNIT_ASSERT_EQUAL(uno::Any(true), xShapeProps
->getPropertyValue(u
"FillBitmapTile"_ustr
));
895 uno::Reference
<awt::XBitmap
> xBitmap
;
896 xShapeProps
->getPropertyValue(u
"FillBitmap"_ustr
) >>= xBitmap
;
898 uno::Reference
<graphic::XGraphic
> xGraphic
;
899 xGraphic
.set(xBitmap
, uno::UNO_QUERY
);
900 uno::Reference
<beans::XPropertySet
> xGraphicDescriptor(xGraphic
, uno::UNO_QUERY_THROW
);
902 CPPUNIT_ASSERT(xGraphicDescriptor
->getPropertyValue(u
"MimeType"_ustr
) >>= sMimeType
);
903 CPPUNIT_ASSERT_EQUAL(u
"image/jpeg"_ustr
, sMimeType
);
904 awt::Size aSize100thMM
;
905 CPPUNIT_ASSERT(xGraphicDescriptor
->getPropertyValue(u
"Size100thMM"_ustr
) >>= aSize100thMM
);
906 CPPUNIT_ASSERT_EQUAL(sal_Int32(1592), aSize100thMM
.Width
);
907 CPPUNIT_ASSERT_EQUAL(sal_Int32(1592), aSize100thMM
.Height
);
910 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testWordArtDefaultColor
)
912 // The document has a WordArt shape for which the text color is not explicitly set. In such cases
913 // MS Office uses the scheme color 'tx1'. Without fix it was imported as 'fill none'. The shape
914 // existed but was not visible on screen.
915 loadFromFile(u
"tdf155327_WordArtDefaultColor.pptx");
917 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
918 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
920 uno::Reference
<beans::XPropertySet
> xShapeProps(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
921 CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_SOLID
),
922 xShapeProps
->getPropertyValue(u
"FillStyle"_ustr
));
924 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(3, 74, 144)),
925 xShapeProps
->getPropertyValue(u
"FillColor"_ustr
));
928 CPPUNIT_TEST_FIXTURE(OoxShapeTest
, testGlowOnGroup
)
930 // The document contains a group of two shapes. A glow-effect is set on the group.
931 // Without the fix, the children of the group were not imported at all.
932 loadFromFile(u
"tdf156902_GlowOnGroup.docx");
933 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
934 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
936 uno::Reference
<container::XIndexAccess
> xGroup(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
937 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroup
->getCount());
939 CPPUNIT_PLUGIN_IMPLEMENT();
941 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */