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/unoapixml_test.hxx>
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
14 #include <com/sun/star/drawing/EnhancedCustomShapeMetalType.hpp>
15 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
16 #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
17 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
18 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
19 #include <com/sun/star/util/Color.hpp>
20 #include <com/sun/star/text/XTextRange.hpp>
21 #include <com/sun/star/text/XTextTable.hpp>
22 #include <com/sun/star/text/GraphicCrop.hpp>
24 #include <comphelper/propertyvalue.hxx>
25 #include <comphelper/sequence.hxx>
26 #include <comphelper/sequenceashashmap.hxx>
27 #include <unotools/tempfile.hxx>
28 #include <unotools/saveopt.hxx>
29 #include <svx/unopage.hxx>
30 #include <svx/svdpage.hxx>
31 #include <svx/svdomedia.hxx>
33 using namespace ::com::sun::star
;
35 /// Covers xmloff/source/draw/ fixes.
36 class XmloffDrawTest
: public UnoApiXmlTest
40 void registerNamespaces(xmlXPathContextPtr
& pXmlXpathCtx
) override
;
41 uno::Reference
<drawing::XShape
> getShape(sal_uInt8 nShapeIndex
);
44 XmloffDrawTest::XmloffDrawTest()
45 : UnoApiXmlTest("/xmloff/qa/unit/data/")
49 void XmloffDrawTest::registerNamespaces(xmlXPathContextPtr
& pXmlXpathCtx
)
51 XmlTestTools::registerODFNamespaces(pXmlXpathCtx
);
54 uno::Reference
<drawing::XShape
> XmloffDrawTest::getShape(sal_uInt8 nShapeIndex
)
56 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
,
57 uno::UNO_QUERY_THROW
);
58 uno::Reference
<drawing::XDrawPages
> xDrawPages(xDrawPagesSupplier
->getDrawPages());
59 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPages
->getByIndex(0), uno::UNO_QUERY_THROW
);
60 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(nShapeIndex
),
61 uno::UNO_QUERY_THROW
);
65 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testTextBoxLoss
)
67 // Load a document that has a shape with a textbox in it. Save it to ODF and reload.
68 loadFromURL(u
"textbox-loss.docx");
69 saveAndReload("impress8");
71 // Make sure that the shape is still a textbox.
72 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
73 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
74 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
75 bool bTextBox
= false;
76 xShape
->getPropertyValue("TextBox") >>= bTextBox
;
78 // Without the accompanying fix in place, this test would have failed, as the shape only had
79 // editeng text, losing the image part of the shape text.
80 CPPUNIT_ASSERT(bTextBox
);
83 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testTdf141301_Extrusion_Angle
)
85 // Load a document that has a custom shape with extrusion direction as set by LO as its default.
86 loadFromURL(u
"tdf141301_Extrusion_Skew.odg");
88 // Prepare use of XPath
90 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
92 // Without fix draw:extrusion-skew="50 -135" was not written to file although "50 -135" is not
93 // default in ODF, but only default inside LO.
94 assertXPath(pXmlDoc
, "//draw:enhanced-geometry", "extrusion-skew", "50 -135");
97 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testThemeExport
)
99 // Create an Impress document which has a master page which has a theme associated with it.
100 mxComponent
= loadFromDesktop("private:factory/simpress");
101 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
102 uno::Reference
<drawing::XMasterPageTarget
> xDrawPage(
103 xDrawPagesSupplier
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
104 uno::Reference
<beans::XPropertySet
> xMasterPage(xDrawPage
->getMasterPage(), uno::UNO_QUERY
);
105 comphelper::SequenceAsHashMap aMap
;
106 aMap
["Name"] <<= OUString("mytheme");
107 aMap
["ColorSchemeName"] <<= OUString("mycolorscheme");
108 uno::Sequence
<util::Color
> aColorScheme
109 = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb };
110 aMap
["ColorScheme"] <<= aColorScheme
;
111 uno::Any
aTheme(aMap
.getAsConstPropertyValueList());
112 xMasterPage
->setPropertyValue("Theme", aTheme
);
117 // Check if the 12 colors are written in the XML:
118 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
119 // Without the accompanying fix in place, this test would have failed with:
122 // - XPath '//style:master-page/loext:theme/loext:color-table/loext:color' number of nodes is incorrect
123 // i.e. the theme was lost on exporting to ODF.
124 assertXPath(pXmlDoc
, "//style:master-page/loext:theme/loext:color-table/loext:color", 12);
127 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testVideoSnapshot
)
129 // Execute ODP import:
130 loadFromURL(u
"video-snapshot.odp");
131 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
,
132 uno::UNO_QUERY_THROW
);
133 CPPUNIT_ASSERT(xDrawPagesSupplier
.is());
134 uno::Reference
<drawing::XDrawPages
> xDrawPages(xDrawPagesSupplier
->getDrawPages());
135 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPages
->getByIndex(0), uno::UNO_QUERY_THROW
);
136 CPPUNIT_ASSERT(xDrawPage
.is());
137 auto pUnoPage
= dynamic_cast<SvxDrawPage
*>(xDrawPage
.get());
138 SdrPage
* pSdrPage
= pUnoPage
->GetSdrPage();
139 auto pMedia
= dynamic_cast<SdrMediaObj
*>(pSdrPage
->GetObj(0));
141 // Check that the preview was imported:
142 const avmedia::MediaItem
& rItem
= pMedia
->getMediaProperties();
143 const Graphic
& rGraphic
= rItem
.getGraphic();
144 CPPUNIT_ASSERT(!rGraphic
.IsNone());
146 // Check that the crop was imported:
147 const text::GraphicCrop
& rCrop
= rItem
.getCrop();
148 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0), rCrop
.Top
);
149 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0), rCrop
.Bottom
);
150 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1356), rCrop
.Left
);
151 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1356), rCrop
.Right
);
153 // Execute ODP export:
156 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
157 // Check that the preview was exported:
158 // Without the accompanying fix in place, this test would have failed with:
161 // - XPath '//draw:frame[@draw:style-name='gr1']/draw:image' number of nodes is incorrect
162 // i.e. the preview wasn't exported to ODP.
163 assertXPath(pXmlDoc
, "//draw:frame[@draw:style-name='gr1']/draw:image", "href",
164 "Pictures/MediaPreview1.png");
165 // Check that the crop was exported:
166 assertXPath(pXmlDoc
, "//style:style[@style:name='gr1']/style:graphic-properties", "clip",
167 "rect(0cm, 1.356cm, 0cm, 1.356cm)");
170 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testThemeImport
)
172 // Given a document that has a master page with a theme associated:
173 loadFromURL(u
"theme.odp");
175 // Then make sure the doc model has a master page with a theme:
176 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
, uno::UNO_QUERY
);
177 uno::Reference
<drawing::XMasterPageTarget
> xDrawPage(
178 xDrawPagesSupplier
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
179 uno::Reference
<beans::XPropertySet
> xMasterpage(xDrawPage
->getMasterPage(), uno::UNO_QUERY
);
180 comphelper::SequenceAsHashMap
aMap(xMasterpage
->getPropertyValue("Theme"));
181 // Without the accompanying fix in place, this test would have failed with:
182 // Cannot extract an Any(void) to string!
183 // i.e. the master page had no theme.
184 CPPUNIT_ASSERT_EQUAL(OUString("Office Theme"), aMap
["Name"].get
<OUString
>());
185 CPPUNIT_ASSERT_EQUAL(OUString("Office"), aMap
["ColorSchemeName"].get
<OUString
>());
186 auto aColorScheme
= aMap
["ColorScheme"].get
<uno::Sequence
<util::Color
>>();
187 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(12), aColorScheme
.getLength());
188 CPPUNIT_ASSERT_EQUAL(static_cast<util::Color
>(0x954F72), aColorScheme
[11]);
191 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testReferToTheme
)
193 // Given a document that refers to a theme color:
194 loadFromURL(u
"refer-to-theme.odp");
197 // Make sure the export result has the theme reference:
198 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
199 // Without the accompanying fix in place, this test would have failed with:
200 // - XPath '//style:style[@style:name='T1']/style:text-properties' no attribute 'theme-color' exist
201 // i.e. only the direct color was written, but not the theme reference.
202 assertXPath(pXmlDoc
, "//style:style[@style:name='T1']/style:text-properties", "theme-color",
204 assertXPathNoAttribute(pXmlDoc
, "//style:style[@style:name='T1']/style:text-properties",
206 assertXPathNoAttribute(pXmlDoc
, "//style:style[@style:name='T1']/style:text-properties",
209 assertXPath(pXmlDoc
, "//style:style[@style:name='T2']/style:text-properties", "theme-color",
211 // Without the accompanying fix in place, this test would have failed with:
212 // - XPath '//style:style[@style:name='T2']/style:text-properties' no attribute 'color-lum-mod' exist
213 // i.e. effects on a referenced theme color were lost.
214 assertXPath(pXmlDoc
, "//style:style[@style:name='T2']/style:text-properties", "color-lum-mod",
216 assertXPath(pXmlDoc
, "//style:style[@style:name='T2']/style:text-properties", "color-lum-off",
219 assertXPath(pXmlDoc
, "//style:style[@style:name='T3']/style:text-properties", "theme-color",
221 assertXPath(pXmlDoc
, "//style:style[@style:name='T3']/style:text-properties", "color-lum-mod",
223 assertXPathNoAttribute(pXmlDoc
, "//style:style[@style:name='T3']/style:text-properties",
226 // Without the accompanying fix in place, this test would have failed with:
227 // - XPath '//style:style[@style:name='gr2']/style:graphic-properties' no attribute 'fill-theme-color' exist
228 // i.e. only the direct color was written, but not the theme reference.
229 assertXPath(pXmlDoc
, "//style:style[@style:name='gr2']/style:graphic-properties",
230 "fill-theme-color", "accent1");
232 // Shape fill, 60% lighter.
233 assertXPath(pXmlDoc
, "//style:style[@style:name='gr3']/style:graphic-properties",
234 "fill-theme-color", "accent1");
235 // Without the accompanying fix in place, this test would have failed with:
236 // - XPath '//style:style[@style:name='gr3']/style:graphic-properties' no attribute 'fill-color-lum-mod' exist
237 // i.e. the themed color was fine, but its effects were lost.
238 assertXPath(pXmlDoc
, "//style:style[@style:name='gr3']/style:graphic-properties",
239 "fill-color-lum-mod", "40%");
240 assertXPath(pXmlDoc
, "//style:style[@style:name='gr3']/style:graphic-properties",
241 "fill-color-lum-off", "60%");
243 // Shape fill, 25% darker.
244 assertXPath(pXmlDoc
, "//style:style[@style:name='gr4']/style:graphic-properties",
245 "fill-theme-color", "accent1");
246 assertXPath(pXmlDoc
, "//style:style[@style:name='gr4']/style:graphic-properties",
247 "fill-color-lum-mod", "75%");
248 assertXPathNoAttribute(pXmlDoc
, "//style:style[@style:name='gr4']/style:graphic-properties",
249 "fill-color-lum-off");
252 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testTableInShape
)
254 // Given a document with a shape with a "FrameX" parent style (starts with Frame, but is not
256 loadFromURL(u
"table-in-shape.fodt");
258 // Then make sure the table inside the shape is not lost:
259 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
260 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
261 uno::Reference
<text::XTextRange
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
262 uno::Reference
<container::XEnumerationAccess
> xText(xShape
->getText(), uno::UNO_QUERY
);
263 uno::Reference
<container::XEnumeration
> xEnum
= xText
->createEnumeration();
264 uno::Reference
<text::XTextTable
> xTable(xEnum
->nextElement(), uno::UNO_QUERY
);
265 // Without the accompanying fix in place, this test would have crashed, as xTable was an empty
266 // reference, i.e. the table inside the shape was lost.
267 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
268 CPPUNIT_ASSERT_EQUAL(OUString("A1"), xCell
->getString());
271 // Tests for save/load of new (LO 7.4) attribute loext:extrusion-metal-type
274 void lcl_assertMetalProperties(std::string_view sInfo
, uno::Reference
<drawing::XShape
>& rxShape
)
276 uno::Reference
<beans::XPropertySet
> xShapeProps(rxShape
, uno::UNO_QUERY
);
277 uno::Sequence
<beans::PropertyValue
> aGeoPropSeq
;
278 xShapeProps
->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq
;
279 comphelper::SequenceAsHashMap
aGeoPropMap(aGeoPropSeq
);
280 uno::Sequence
<beans::PropertyValue
> aExtrusionSeq
;
281 aGeoPropMap
.getValue("Extrusion") >>= aExtrusionSeq
;
282 comphelper::SequenceAsHashMap
aExtrusionPropMap(aExtrusionSeq
);
284 bool bIsMetal(false);
285 aExtrusionPropMap
.getValue("Metal") >>= bIsMetal
;
286 OString sMsg
= OString::Concat(sInfo
) + " Metal";
287 CPPUNIT_ASSERT_MESSAGE(sMsg
.getStr(), bIsMetal
);
289 sal_Int16
nMetalType(-1);
290 aExtrusionPropMap
.getValue("MetalType") >>= nMetalType
;
291 sMsg
= OString::Concat(sInfo
) + " MetalType";
292 CPPUNIT_ASSERT_EQUAL_MESSAGE(
293 sMsg
.getStr(), css::drawing::EnhancedCustomShapeMetalType::MetalMSCompatible
, nMetalType
);
297 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testExtrusionMetalTypeExtended
)
299 loadFromURL(u
"tdf145700_3D_metal_type_MSCompatible.doc");
301 uno::Reference
<drawing::XShape
> xShape(getShape(0));
302 lcl_assertMetalProperties("from doc", xShape
);
304 // Test, that new attribute is written with loext namespace. Adapt when attribute is added to ODF.
308 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
309 assertXPath(pXmlDoc
, "//draw:enhanced-geometry", "extrusion-metal", "true");
311 "//draw:enhanced-geometry[@loext:extrusion-metal-type='loext:MetalMSCompatible']");
314 mxComponent
= loadFromDesktop(maTempFile
.GetURL(), "com.sun.star.text.TextDocument");
316 uno::Reference
<drawing::XShape
> xShapeReload(getShape(0));
317 lcl_assertMetalProperties("from ODF 1.3 extended", xShapeReload
);
320 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testExtrusionMetalTypeStrict
)
322 loadFromURL(u
"tdf145700_3D_metal_type_MSCompatible.doc");
324 // save ODF 1.3 strict and test, that new attribute is not written. Adapt when attribute is
326 const SvtSaveOptions::ODFDefaultVersion
nCurrentODFVersion(GetODFDefaultVersion());
327 SetODFDefaultVersion(SvtSaveOptions::ODFVER_013
);
331 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
332 assertXPath(pXmlDoc
, "//draw:enhanced-geometry", "extrusion-metal", "true");
333 assertXPath(pXmlDoc
, "//draw:enhanced-geometry[@loext:extrusion-metal-type]", 0);
335 SetODFDefaultVersion(nCurrentODFVersion
);
340 void lcl_assertSpecularityProperty(std::string_view sInfo
, uno::Reference
<drawing::XShape
>& rxShape
)
342 uno::Reference
<beans::XPropertySet
> xShapeProps(rxShape
, uno::UNO_QUERY
);
343 uno::Sequence
<beans::PropertyValue
> aGeoPropSeq
;
344 xShapeProps
->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq
;
345 comphelper::SequenceAsHashMap
aGeoPropMap(aGeoPropSeq
);
346 uno::Sequence
<beans::PropertyValue
> aExtrusionSeq
;
347 aGeoPropMap
.getValue("Extrusion") >>= aExtrusionSeq
;
348 comphelper::SequenceAsHashMap
aExtrusionPropMap(aExtrusionSeq
);
350 double fSpecularity(-1.0);
351 aExtrusionPropMap
.getValue("Specularity") >>= fSpecularity
;
352 OString sMsg
= OString::Concat(sInfo
) + "Specularity";
353 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMsg
.getStr(), 122.0703125, fSpecularity
);
357 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testExtrusionSpecularityExtended
)
359 loadFromURL(u
"tdf147580_extrusion-specularity.doc");
361 uno::Reference
<drawing::XShape
> xShape(getShape(0));
362 lcl_assertSpecularityProperty("from doc", xShape
);
364 // Test, that attribute is written in draw namespace with value 100% and in loext namespace with
365 // value 122.0703125%.
369 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
370 assertXPath(pXmlDoc
, "//draw:enhanced-geometry[@draw:extrusion-specularity='100%']");
372 "//draw:enhanced-geometry[@loext:extrusion-specularity-loext='122.0703125%']");
374 // reload and verify, that the loext value is used
375 mxComponent
= loadFromDesktop(maTempFile
.GetURL(), "com.sun.star.text.TextDocument");
377 uno::Reference
<drawing::XShape
> xShapeReload(getShape(0));
378 lcl_assertSpecularityProperty("from ODF 1.3 extended", xShapeReload
);
381 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testExtrusionSpecularity
)
383 loadFromURL(u
"tdf147580_extrusion-specularity.doc");
385 // The file has c3DSpecularAmt="80000" which results internally in specularity=122%.
386 // Save to ODF 1.3 strict and make sure it does not produce a validation error.
387 const SvtSaveOptions::ODFDefaultVersion
nCurrentODFVersion(GetODFDefaultVersion());
388 SetODFDefaultVersion(SvtSaveOptions::ODFVER_013
);
391 SetODFDefaultVersion(nCurrentODFVersion
);
396 bool lcl_getShapeSegments(uno::Sequence
<drawing::EnhancedCustomShapeSegment
>& rSegments
,
397 const uno::Reference
<drawing::XShape
>& xShape
)
399 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY_THROW
);
400 uno::Any anotherAny
= xShapeProps
->getPropertyValue("CustomShapeGeometry");
401 uno::Sequence
<beans::PropertyValue
> aCustomShapeGeometry
;
402 if (!(anotherAny
>>= aCustomShapeGeometry
))
404 uno::Sequence
<beans::PropertyValue
> aPathProps
;
405 for (beans::PropertyValue
const& rProp
: std::as_const(aCustomShapeGeometry
))
407 if (rProp
.Name
== "Path")
409 rProp
.Value
>>= aPathProps
;
414 for (beans::PropertyValue
const& rProp
: std::as_const(aPathProps
))
416 if (rProp
.Name
== "Segments")
418 rProp
.Value
>>= rSegments
;
422 if (rSegments
.getLength() > 2)
429 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testTdf148714_CurvedArrowsOld
)
431 // Load a document with CurveArrow shapes with faulty path as written by older LO versions.
432 loadFromURL(u
"tdf148714_CurvedArrowsOld.odp");
434 // Make sure, that the error has been corrected on opening.
435 for (sal_Int32 nShapeIndex
= 0; nShapeIndex
< 4; nShapeIndex
++)
437 uno::Reference
<drawing::XShape
> xShape(getShape(nShapeIndex
));
438 uno::Sequence
<drawing::EnhancedCustomShapeSegment
> aSegments
;
439 CPPUNIT_ASSERT(lcl_getShapeSegments(aSegments
, xShape
));
441 if (nShapeIndex
== 0 || nShapeIndex
== 3)
443 // curvedDownArrow or curvedLeftArrow. Segments should start with VW. Without fix it was
444 // V with count 2, which means VV.
445 CPPUNIT_ASSERT_EQUAL(
446 sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC
),
447 aSegments
[0].Command
);
448 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments
[0].Count
);
449 CPPUNIT_ASSERT_EQUAL(
450 sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO
),
451 aSegments
[1].Command
);
452 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments
[1].Count
);
456 // curvedUpArrow or curvedRightArrow. Segments should start with BA. Without fix is was
457 // B with count 2, which means BB.
458 CPPUNIT_ASSERT_EQUAL(sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::ARC
),
459 aSegments
[0].Command
);
460 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments
[0].Count
);
461 CPPUNIT_ASSERT_EQUAL(sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::ARCTO
),
462 aSegments
[1].Command
);
463 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments
[1].Count
);
468 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testTextRotationPlusPre
)
470 loadFromURL(u
"tdf149551_verticalText.pptx");
471 // The file has a shape with attribute vert="vert" in <bodyPr> element. That generates a
472 // TextPreRotateAngle attribute in CustomShapeGeometry.
474 // Add a TextRotateAngle attribute.
475 uno::Reference
<drawing::XShape
> xShape(getShape(0));
476 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
477 uno::Sequence
<beans::PropertyValue
> aGeomSeq
;
478 xShapeProps
->getPropertyValue("CustomShapeGeometry") >>= aGeomSeq
;
479 auto aGeomVec(comphelper::sequenceToContainer
<std::vector
<beans::PropertyValue
>>(aGeomSeq
));
480 aGeomVec
.push_back(comphelper::makePropertyValue("TextRotateAngle", sal_Int32(45)));
481 aGeomSeq
= comphelper::containerToSequence(aGeomVec
);
482 xShapeProps
->setPropertyValue("CustomShapeGeometry", uno::Any(aGeomSeq
));
484 // Save to ODF. Without the fix, a file format error was produced, because attribute
485 // draw:text-rotate-angle was written twice, one from TextPreRotateAngle and the other from
487 // This should already catch the format error, but does not, see tdf#149567
488 // But reload catches it.
489 saveAndReload("writer8");
491 CPPUNIT_PLUGIN_IMPLEMENT();
493 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */