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 <test/unoapi_test.hxx>
12 #include <com/sun/star/awt/Gradient2.hpp>
13 #include <com/sun/star/awt/Rectangle.hpp>
14 #include <com/sun/star/beans/XPropertySet.hpp>
15 #include <com/sun/star/container/XNamed.hpp>
16 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
17 #include <com/sun/star/drawing/FillStyle.hpp>
18 #include <com/sun/star/drawing/XShape.hpp>
19 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
20 #include <com/sun/star/chart2/XChartDocument.hpp>
21 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
22 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
23 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
24 #include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
25 #include <com/sun/star/style/ParagraphAdjust.hpp>
26 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
27 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
28 #include <com/sun/star/lang/Locale.hpp>
29 #include <com/sun/star/text/XTextRange.hpp>
30 #include <com/sun/star/table/XCellRange.hpp>
31 #include <com/sun/star/util/XTheme.hpp>
33 #include <docmodel/uno/UnoGradientTools.hxx>
34 #include <docmodel/uno/UnoComplexColor.hxx>
35 #include <docmodel/uno/UnoTheme.hxx>
36 #include <docmodel/theme/Theme.hxx>
38 #include <comphelper/sequenceashashmap.hxx>
39 #include <basegfx/utils/gradienttools.hxx>
41 using namespace ::com::sun::star
;
45 /// Gets one child of xShape, which one is specified by nIndex.
46 uno::Reference
<drawing::XShape
> getChildShape(const uno::Reference
<drawing::XShape
>& xShape
,
49 uno::Reference
<container::XIndexAccess
> xGroup(xShape
, uno::UNO_QUERY
);
50 CPPUNIT_ASSERT(xGroup
.is());
52 CPPUNIT_ASSERT(xGroup
->getCount() > nIndex
);
54 uno::Reference
<drawing::XShape
> xRet(xGroup
->getByIndex(nIndex
), uno::UNO_QUERY
);
55 CPPUNIT_ASSERT(xRet
.is());
61 /// oox drawingml tests.
62 class OoxDrawingmlTest
: public UnoApiTest
66 : UnoApiTest("/oox/qa/unit/data/")
71 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testTransparentText
)
73 loadFromURL(u
"transparent-text.pptx");
74 saveAndReload("Impress Office Open XML");
76 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
77 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
79 uno::Reference
<container::XEnumerationAccess
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
80 uno::Reference
<container::XEnumerationAccess
> xParagraph(
81 xShape
->createEnumeration()->nextElement(), uno::UNO_QUERY
);
82 uno::Reference
<beans::XPropertySet
> xPortion(xParagraph
->createEnumeration()->nextElement(),
85 sal_Int16 nTransparency
= 0;
86 xPortion
->getPropertyValue("CharTransparence") >>= nTransparency
;
88 // Without the accompanying fix in place, this test would have failed with:
91 // i.e. the transparency of the character color was lost on import/export.
92 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(75), nTransparency
);
95 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testTdf131082
)
97 loadFromURL(u
"tdf131082.pptx");
98 saveAndReload("Impress Office Open XML");
100 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
101 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
104 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
105 uno::Reference
<beans::XPropertySet
> XPropSet(getChildShape(getChildShape(xShape
, 0), 0),
108 drawing::FillStyle eFillStyle
= drawing::FillStyle_NONE
;
109 XPropSet
->getPropertyValue("FillStyle") >>= eFillStyle
;
111 // Without the accompanying fix in place, this test would have failed with:
112 // with drawing::FillStyle_NONE - 0
113 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, eFillStyle
);
116 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testPresetAdjustValue
)
118 loadFromURL(u
"preset-adjust-value.pptx");
120 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
121 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
123 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
124 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
125 uno::Sequence
<beans::PropertyValue
> aGeoPropSeq
;
126 xShapeProps
->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq
;
127 comphelper::SequenceAsHashMap
aGeoPropMap(aGeoPropSeq
);
128 uno::Sequence
<drawing::EnhancedCustomShapeAdjustmentValue
> aAdjustmentSeq
;
129 aGeoPropMap
.getValue("AdjustmentValues") >>= aAdjustmentSeq
;
130 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), aAdjustmentSeq
.getLength());
131 // Without the accompanying fix in place, this test would have failed with:
134 // i.e. the adjust value was set from the placeholder, not from the shape.
135 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(11587), aAdjustmentSeq
[0].Value
.get
<sal_Int32
>());
138 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testChartDataLabelCharColor
)
140 loadFromURL(u
"chart-data-label-char-color.docx");
142 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
143 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
145 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
146 uno::Reference
<chart2::XChartDocument
> xModel(xShape
->getPropertyValue("Model"),
148 uno::Reference
<chart2::XCoordinateSystemContainer
> xDiagram(xModel
->getFirstDiagram(),
151 uno::Reference
<chart2::XChartTypeContainer
> xCoordinateSystem(
152 xDiagram
->getCoordinateSystems()[0], uno::UNO_QUERY
);
154 uno::Reference
<chart2::XDataSeriesContainer
> xChartType(xCoordinateSystem
->getChartTypes()[0],
157 uno::Reference
<chart2::XDataSeries
> xDataSeries
= xChartType
->getDataSeries()[0];
159 uno::Reference
<beans::XPropertySet
> xDataPoint
= xDataSeries
->getDataPointByIndex(0);
161 uno::Sequence
<uno::Reference
<chart2::XDataPointCustomLabelField
>> aLabels
;
162 xDataPoint
->getPropertyValue("CustomLabelFields") >>= aLabels
;
163 uno::Reference
<beans::XPropertySet
> xLabel
= aLabels
[0];
166 xLabel
->getPropertyValue("CharColor") >>= nCharColor
;
167 // Without the accompanying fix in place, this test would have failed with:
168 // - Expected: 16777215
170 // i.e. the data label had no explicit (white) color.
171 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nCharColor
);
174 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testGradientMultiStepTransparency
)
176 // Load a document with a multi-step gradient.
177 loadFromURL(u
"gradient-multistep-transparency.pptx");
179 // Check the end transparency of the gradient.
180 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
181 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
183 uno::Reference
<container::XNamed
> xShape(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
184 CPPUNIT_ASSERT_EQUAL(OUString("Rectangle 4"), xShape
->getName());
185 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
186 awt::Gradient2 aTransparence
;
187 xShapeProps
->getPropertyValue("FillTransparenceGradient") >>= aTransparence
;
189 // Without the accompanying fix in place, this test would have failed with:
190 // - Expected: 16777215 (COL_WHITE)
191 // - Actual : 3487029 (0x353535)
192 // i.e. the end transparency was not 100%, but was 21%, leading to an unexpected visible line on
193 // the right of this shape.
194 // MCGR: Use the completely imported transparency gradient to check for correctness
195 const basegfx::BColorStops aColorStops
196 = model::gradient::getColorStopsFromUno(aTransparence
.ColorStops
);
198 CPPUNIT_ASSERT_EQUAL(size_t(5), aColorStops
.size());
199 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[4].getStopOffset(), 1.0));
200 CPPUNIT_ASSERT_EQUAL(aColorStops
[4].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
203 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testShapeTextAlignment
)
205 loadFromURL(u
"shape-text-alignment.pptx");
207 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
208 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
210 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
211 sal_Int16 nParaAdjust
= -1;
212 CPPUNIT_ASSERT(xShape
->getPropertyValue("ParaAdjust") >>= nParaAdjust
);
213 // Without the accompanying fix in place, this test would have failed with:
216 // i.e. text which is meant to be left-aligned was centered at a paragraph level.
217 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT
,
218 static_cast<style::ParagraphAdjust
>(nParaAdjust
));
221 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testShapeTextAdjustLeft
)
223 loadFromURL(u
"shape-text-adjust-left.pptx");
225 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
226 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
228 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
229 drawing::TextHorizontalAdjust eAdjust
;
230 // Without the accompanying fix in place, this test would have failed with:
231 // - Expected: 3 (center)
232 // - Actual : 1 (block)
233 // i.e. text was center-adjusted, not default-adjusted (~left).
234 CPPUNIT_ASSERT(xShape
->getPropertyValue("TextHorizontalAdjust") >>= eAdjust
);
235 CPPUNIT_ASSERT_EQUAL(drawing::TextHorizontalAdjust_BLOCK
, eAdjust
);
238 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testCameraRotationRevolution
)
240 loadFromURL(u
"camera-rotation-revolution.docx");
242 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
243 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
245 uno::Reference
<container::XNamed
> xShape0(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
246 uno::Reference
<container::XNamed
> xShape1(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
247 uno::Reference
<beans::XPropertySet
> xShapeProps0(xShape0
, uno::UNO_QUERY
);
248 uno::Reference
<beans::XPropertySet
> xShapeProps1(xShape1
, uno::UNO_QUERY
);
249 sal_Int32 nRotateAngle0
;
250 sal_Int32 nRotateAngle1
;
251 xShapeProps0
->getPropertyValue("RotateAngle") >>= nRotateAngle0
;
252 xShapeProps1
->getPropertyValue("RotateAngle") >>= nRotateAngle1
;
254 // Without the accompanying fix in place, this test would have failed with:
257 // so the camera rotation would not have been factored into how the shape is displayed
258 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(8000), nRotateAngle0
);
259 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(27000), nRotateAngle1
);
262 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testTdf146534_CameraRotationRevolutionNonWpsShapes
)
264 loadFromURL(u
"camera-rotation-revolution-nonwps.pptx");
266 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
267 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
269 uno::Reference
<container::XNamed
> xShape0(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
270 uno::Reference
<container::XNamed
> xShape1(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
271 uno::Reference
<beans::XPropertySet
> xShapeProps0(xShape0
, uno::UNO_QUERY
);
272 uno::Reference
<beans::XPropertySet
> xShapeProps1(xShape1
, uno::UNO_QUERY
);
273 sal_Int32 nRotateAngle0
;
274 sal_Int32 nRotateAngle1
;
275 xShapeProps0
->getPropertyValue("RotateAngle") >>= nRotateAngle0
;
276 xShapeProps1
->getPropertyValue("RotateAngle") >>= nRotateAngle1
;
278 // Without the accompanying fix in place, this test would have failed with:
281 // so the camera rotation would not have been factored into how the shape is displayed
282 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(9000), nRotateAngle0
);
283 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(30500), nRotateAngle1
);
286 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testTableShadow
)
288 auto verify
= [](const uno::Reference
<lang::XComponent
>& xComponent
) {
289 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(xComponent
, uno::UNO_QUERY
);
290 uno::Reference
<drawing::XDrawPage
> xDrawPage(
291 xDrawPagesSupplier
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
292 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
293 bool bShadow
= false;
294 CPPUNIT_ASSERT(xShape
->getPropertyValue("Shadow") >>= bShadow
);
296 CPPUNIT_ASSERT(bShadow
);
298 CPPUNIT_ASSERT(xShape
->getPropertyValue("ShadowColor") >>= nColor
);
299 CPPUNIT_ASSERT_EQUAL(Color(0xff0000), nColor
);
301 loadFromURL(u
"table-shadow.pptx");
302 // Without the accompanying fix in place, this test would have failed, because shadow on a table
303 // was lost on import.
306 saveAndReload("Impress Office Open XML");
308 // Without the accompanying fix in place, this test would have failed, because shadow on a table
309 // was lost on export.
313 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testGroupShapeSmartArt
)
315 // Given a file with a smartart inside a group shape:
316 loadFromURL(u
"smartart-groupshape.pptx");
318 // Then make sure that the smartart is not just an empty group shape:
319 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
320 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
322 uno::Reference
<drawing::XShapes
> xGroup(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
323 uno::Reference
<drawing::XShapes
> xSmartArt(xGroup
->getByIndex(0), uno::UNO_QUERY
);
324 // Without the accompanying fix in place, this test would have failed, because we lost all
325 // children of the group shape representing the smartart.
326 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(0), xSmartArt
->getCount());
329 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testTdf142605_CurveSize
)
331 // The document contains a Bezier curve, where the control points are outside the bounding
332 // rectangle of the shape. Error was, that the export uses a path size which included the
334 loadFromURL(u
"tdf142605_CurveSize.odp");
335 saveAndReload("Impress Office Open XML");
337 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
338 auto xPage
= xDrawPagesSupplier
->getDrawPages()->getByIndex(0);
339 uno::Reference
<drawing::XDrawPage
> xDrawPage(xPage
, uno::UNO_QUERY
);
340 uno::Reference
<container::XEnumerationAccess
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
341 CPPUNIT_ASSERT(xShape
.is());
342 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
343 CPPUNIT_ASSERT(xShapeProps
.is());
344 uno::Reference
<container::XNamed
> xShapeNamed(xShape
, uno::UNO_QUERY
);
345 CPPUNIT_ASSERT(xShapeNamed
.is());
346 CPPUNIT_ASSERT_EQUAL(OUString(u
"Bézier curve 1"), xShapeNamed
->getName());
348 css::awt::Rectangle aBoundRect
;
349 xShapeProps
->getPropertyValue("BoundRect") >>= aBoundRect
;
350 // Without fix, size was 6262 x 3509, and position was 10037|6790.
351 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(8601), aBoundRect
.Width
, 1);
352 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4601), aBoundRect
.Height
, 1);
353 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7699), aBoundRect
.X
, 1);
354 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5699), aBoundRect
.Y
, 1);
357 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testChartThemeOverride
)
359 // Given a document with 2 slides, slide1 has a chart with a theme override and slide2 has a
361 loadFromURL(u
"chart-theme-override.pptx");
363 // Then make sure that the slide 2 shape's text color is blue, not red:
364 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
365 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(1),
367 uno::Reference
<text::XTextRange
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
368 uno::Reference
<container::XEnumerationAccess
> xText(xShape
->getText(), uno::UNO_QUERY
);
369 uno::Reference
<container::XEnumerationAccess
> xPara(xText
->createEnumeration()->nextElement(),
371 uno::Reference
<beans::XPropertySet
> xPortion(xPara
->createEnumeration()->nextElement(),
373 sal_Int32 nActual
{ 0 };
374 xPortion
->getPropertyValue("CharColor") >>= nActual
;
375 // Without the accompanying fix in place, this test would have failed with:
376 // - Expected: 4485828 (0x4472c4)
377 // - Actual : 16711680 (0xff0000)
378 // i.e. the text color was red, not blue.
379 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0x4472C4), nActual
);
382 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testPptxTheme
)
384 // Given a PPTX file with a slide -> master slide -> theme:
385 loadFromURL(u
"theme.pptx");
387 // Then make sure the theme + referring to that theme is imported:
388 // Check the imported theme of the master page:
389 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
390 uno::Reference
<drawing::XMasterPageTarget
> xDrawPage(
391 xDrawPagesSupplier
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
392 uno::Reference
<beans::XPropertySet
> xMasterpage(xDrawPage
->getMasterPage(), uno::UNO_QUERY
);
394 uno::Reference
<util::XTheme
> xTheme
;
395 xMasterpage
->getPropertyValue("Theme") >>= xTheme
;
397 // We expect the theme to be set on the master page
398 CPPUNIT_ASSERT(xTheme
.is());
399 auto* pUnoTheme
= dynamic_cast<UnoTheme
*>(xTheme
.get());
400 CPPUNIT_ASSERT(pUnoTheme
);
401 auto pTheme
= pUnoTheme
->getTheme();
403 CPPUNIT_ASSERT_EQUAL(OUString("Office Theme"), pTheme
->GetName());
404 CPPUNIT_ASSERT_EQUAL(OUString("Office"), pTheme
->getColorSet()->getName());
406 CPPUNIT_ASSERT_EQUAL(Color(0x954F72),
407 pTheme
->getColorSet()->getColor(model::ThemeColorType::FollowedHyperlink
));
409 // Check the reference to that theme:
410 uno::Reference
<drawing::XShapes
> xDrawPageShapes(xDrawPage
, uno::UNO_QUERY
);
411 uno::Reference
<text::XTextRange
> xShape(xDrawPageShapes
->getByIndex(0), uno::UNO_QUERY
);
412 uno::Reference
<container::XEnumerationAccess
> xText(xShape
->getText(), uno::UNO_QUERY
);
413 uno::Reference
<container::XEnumerationAccess
> xPara(xText
->createEnumeration()->nextElement(),
415 uno::Reference
<beans::XPropertySet
> xPortion(xPara
->createEnumeration()->nextElement(),
418 // Check the theme colors are as expected
420 uno::Reference
<util::XComplexColor
> xComplexColor
;
421 CPPUNIT_ASSERT(xPortion
->getPropertyValue("CharComplexColor") >>= xComplexColor
);
422 CPPUNIT_ASSERT(xComplexColor
.is());
423 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
424 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1
, aComplexColor
.getSchemeType());
425 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod
,
426 aComplexColor
.getTransformations()[0].meType
);
427 CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), aComplexColor
.getTransformations()[0].mnValue
);
428 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff
,
429 aComplexColor
.getTransformations()[1].meType
);
430 CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), aComplexColor
.getTransformations()[1].mnValue
);
434 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testTdf132557_footerCustomShapes
)
436 // slide with date, footer, slide number with custom shapes
437 loadFromURL(u
"testTdf132557_footerCustomShapes.pptx");
439 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
440 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
443 // Test if we were able to import the footer shapes with CustomShape service.
444 uno::Reference
<drawing::XShape
> xShapeDateTime(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
445 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"),
446 xShapeDateTime
->getShapeType());
447 // Without the accompanying fix in place, this test would have failed with:
448 // An uncaught exception of type com.sun.star.lang.IndexOutOfBoundsException
449 // i.e. the shape wasn't on the slide there since it was imported as a property, not a shape.
451 uno::Reference
<drawing::XShape
> xShapeFooter(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
452 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"),
453 xShapeFooter
->getShapeType());
455 uno::Reference
<drawing::XShape
> xShapeSlideNum(xDrawPage
->getByIndex(2), uno::UNO_QUERY
);
456 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"),
457 xShapeSlideNum
->getShapeType());
460 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testThemeColorTint_Table
)
462 // Given a document with a table style, using theme color with tinting in the A2 cell:
463 loadFromURL(u
"theme-tint.pptx");
465 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
466 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
468 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
469 uno::Reference
<table::XCellRange
> xTable
;
470 CPPUNIT_ASSERT(xShape
->getPropertyValue("Model") >>= xTable
);
471 uno::Reference
<beans::XPropertySet
> xA1(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY
);
475 uno::Reference
<util::XComplexColor
> xComplexColor
;
476 CPPUNIT_ASSERT(xA1
->getPropertyValue("FillComplexColor") >>= xComplexColor
);
477 CPPUNIT_ASSERT(xComplexColor
.is());
478 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
479 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1
, aComplexColor
.getSchemeType());
481 auto const& rTrans
= aComplexColor
.getTransformations();
482 CPPUNIT_ASSERT_EQUAL(size_t(0), rTrans
.size());
487 uno::Reference
<beans::XPropertySet
> xA2(xTable
->getCellByPosition(0, 1), uno::UNO_QUERY
);
488 uno::Reference
<util::XComplexColor
> xComplexColor
;
489 CPPUNIT_ASSERT(xA2
->getPropertyValue("FillComplexColor") >>= xComplexColor
);
490 CPPUNIT_ASSERT(xComplexColor
.is());
491 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
492 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1
, aComplexColor
.getSchemeType());
494 auto const& rTrans
= aComplexColor
.getTransformations();
495 CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans
.size());
496 CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint
, rTrans
[0].meType
);
497 CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans
[0].mnValue
);
502 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testThemeColor_Shape
)
504 // Given a document with a table style, using theme color with tinting in the A2 cell:
505 loadFromURL(u
"ThemeShapesReference.pptx");
507 // Then make sure that we only import theming info to the doc model if the effects are limited
508 // to lum mod / off that we can handle (i.e. no tint/shade):
509 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
510 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
513 // check line and fill theme color of shape1
515 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
516 uno::Reference
<util::XComplexColor
> xComplexColor
;
517 CPPUNIT_ASSERT(xShape
->getPropertyValue("FillComplexColor") >>= xComplexColor
);
518 CPPUNIT_ASSERT(xComplexColor
.is());
520 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
521 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6
, aComplexColor
.getSchemeType());
523 auto const& rTrans
= aComplexColor
.getTransformations();
524 CPPUNIT_ASSERT_EQUAL(size_t(2), rTrans
.size());
525 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod
, rTrans
[0].meType
);
526 CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans
[0].mnValue
);
527 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff
, rTrans
[1].meType
);
528 CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans
[1].mnValue
);
531 CPPUNIT_ASSERT(xShape
->getPropertyValue("LineComplexColor") >>= xComplexColor
);
532 CPPUNIT_ASSERT(xComplexColor
.is());
534 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
535 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6
, aComplexColor
.getSchemeType());
537 auto const& rTrans
= aComplexColor
.getTransformations();
538 CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans
.size());
539 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod
, rTrans
[0].meType
);
540 CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTrans
[0].mnValue
);
543 // check line and fill theme color of shape2
545 uno::Reference
<util::XComplexColor
> xComplexColor
;
546 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
547 CPPUNIT_ASSERT(xShape
->getPropertyValue("FillComplexColor") >>= xComplexColor
);
548 CPPUNIT_ASSERT(xComplexColor
.is());
550 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
551 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1
, aComplexColor
.getSchemeType());
553 auto const& rTrans
= aComplexColor
.getTransformations();
554 CPPUNIT_ASSERT_EQUAL(size_t(0), rTrans
.size());
557 CPPUNIT_ASSERT(xShape
->getPropertyValue("LineComplexColor") >>= xComplexColor
);
558 CPPUNIT_ASSERT(xComplexColor
.is());
560 auto aComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
561 CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1
, aComplexColor
.getSchemeType());
563 auto const& rTrans
= aComplexColor
.getTransformations();
564 CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans
.size());
565 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod
, rTrans
[0].meType
);
566 CPPUNIT_ASSERT_EQUAL(sal_Int16(7500), rTrans
[0].mnValue
);
571 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testVert270AndTextRot
)
573 // tdf##149551. The document contains a shape with attributes 'rot="720000"' and 'vert="vert270"'
574 // of the <bodyPr> element. Without the fix the simulation of vert270 had overwritten the text
575 // rotation angle and thus 'rot'="720000" was lost.
576 loadFromURL(u
"tdf149551_vert270AndTextRot.pptx");
578 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
579 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
581 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
582 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
583 uno::Sequence
<beans::PropertyValue
> aGeoPropSeq
;
584 xShapeProps
->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq
;
585 comphelper::SequenceAsHashMap
aGeoPropMap(aGeoPropSeq
);
587 // Without the fix the property "TextRotateAngle" does not exist.
588 comphelper::SequenceAsHashMap::iterator it
= aGeoPropMap
.find("TextRotateAngle");
589 CPPUNIT_ASSERT(it
!= aGeoPropMap
.end());
591 // MS 720000 clockwise -> ODF -12deg counter-clockwise
592 it
->second
>>= nAngle
;
593 CPPUNIT_ASSERT_EQUAL(sal_Int32(-12), nAngle
);
596 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testTextRot
)
598 // tdf#149551 The document contains a shape with attribute 'rot="720000"' of the <bodyPr> element.
599 // Without fix, the text rotation angle was saved in "TextPreRotateAngle" instead of
600 // "TextRotateAngle". That resulted in unrotated but sheared text.
601 loadFromURL(u
"tdf149551_TextRot.pptx");
603 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
604 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
606 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
607 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
608 uno::Sequence
<beans::PropertyValue
> aGeoPropSeq
;
609 xShapeProps
->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq
;
610 comphelper::SequenceAsHashMap
aGeoPropMap(aGeoPropSeq
);
612 // Without the fix the property "TextRotateAngle" does not exist.
613 comphelper::SequenceAsHashMap::iterator it
= aGeoPropMap
.find("TextRotateAngle");
614 CPPUNIT_ASSERT(it
!= aGeoPropMap
.end());
616 // MS 720000 clockwise -> ODF -12deg counter-clockwise
617 it
->second
>>= nAngle
;
618 CPPUNIT_ASSERT_EQUAL(sal_Int32(-12), nAngle
);
620 // Because writing mode is LR_TB, the property "TextPreRotateAngle" may missing, or in case it
621 // exists, its value must be 0. Without fix it had value -12.
622 it
= aGeoPropMap
.find("TextPreRotateAngle");
623 if (it
!= aGeoPropMap
.end())
625 it
->second
>>= nAngle
;
626 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAngle
);
630 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testTdf113187ConstantArcTo
)
632 loadFromURL(u
"tdf113187_arcTo_withoutReferences.pptx");
634 // Get ViewBox of shape
635 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
636 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
638 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
639 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
640 uno::Sequence
<beans::PropertyValue
> aGeoPropSeq
;
641 xShapeProps
->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq
;
642 comphelper::SequenceAsHashMap
aGeoPropMap(aGeoPropSeq
);
644 // Without the fix width and height of the ViewBox were 0 and thus the shape was not shown.
645 auto aViewBox
= aGeoPropMap
["ViewBox"].get
<css::awt::Rectangle
>();
646 CPPUNIT_ASSERT_EQUAL(sal_Int32(3600000), aViewBox
.Width
);
647 CPPUNIT_ASSERT_EQUAL(sal_Int32(3600000), aViewBox
.Height
);
650 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testTdf125085WordArtFontTheme
)
652 // The font info for the shape is in the theme, the text run has no font settings.
653 loadFromURL(u
"tdf125085_WordArtFontTheme.pptx");
655 // Get shape and its properties
656 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
657 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
659 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
660 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
662 // Make sure shape has correct font and local.
663 // Without the fix some application defaults were used.
665 xShapeProps
->getPropertyValue("CharFontNameComplex") >>= sFontName
;
666 CPPUNIT_ASSERT_EQUAL(OUString(u
"Noto Serif Hebrew"), sFontName
);
667 css::lang::Locale aLocal
;
668 xShapeProps
->getPropertyValue("CharLocaleComplex") >>= aLocal
;
669 CPPUNIT_ASSERT_EQUAL(OUString(u
"IL"), aLocal
.Country
);
670 CPPUNIT_ASSERT_EQUAL(OUString(u
"he"), aLocal
.Language
);
673 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest
, testTdf125085WordArtFontText
)
675 // The font info for the shape is in the text run inside the shape.
676 loadFromURL(u
"tdf125085_WordArtFontText.pptx");
678 // Get shape and its properties
679 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
680 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
682 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
683 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
685 // Make sure shape has correct font and local.
686 // Without the fix some application defaults were used.
688 xShapeProps
->getPropertyValue("CharFontNameComplex") >>= sFontName
;
689 CPPUNIT_ASSERT_EQUAL(OUString(u
"Noto Serif Hebrew"), sFontName
);
690 css::lang::Locale aLocal
;
691 xShapeProps
->getPropertyValue("CharLocaleComplex") >>= aLocal
;
692 CPPUNIT_ASSERT_EQUAL(OUString(u
"IL"), aLocal
.Country
);
693 CPPUNIT_ASSERT_EQUAL(OUString(u
"he"), aLocal
.Language
);
696 CPPUNIT_PLUGIN_IMPLEMENT();
698 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */