1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <swmodeltestbase.hxx>
14 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
15 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
16 #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
17 #include <com/sun/star/drawing/FillStyle.hpp>
18 #include <com/sun/star/drawing/Hatch.hpp>
19 #include <com/sun/star/drawing/LineJoint.hpp>
20 #include <com/sun/star/drawing/LineStyle.hpp>
21 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
22 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
23 #include <com/sun/star/style/LineSpacing.hpp>
24 #include <com/sun/star/style/LineSpacingMode.hpp>
25 #include <com/sun/star/text/GraphicCrop.hpp>
27 #include <comphelper/sequenceashashmap.hxx>
29 class Test
: public SwModelTestBase
32 Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
38 bool mustTestImportOf(const char* filename
) const SAL_OVERRIDE
{
39 // If the testcase is stored in some other format, it's pointless to test.
40 return (OString(filename
).endsWith(".docx"));
44 DECLARE_OOXMLEXPORT_TEST(testDmlShapeTitle
, "dml-shape-title.docx")
46 CPPUNIT_ASSERT_EQUAL(OUString("Title"), getProperty
<OUString
>(getShape(1), "Title"));
47 CPPUNIT_ASSERT_EQUAL(OUString("Description"), getProperty
<OUString
>(getShape(1), "Description"));
50 DECLARE_OOXMLEXPORT_TEST(testDmlZorder
, "dml-zorder.odt")
52 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
55 // This was "0": causing that in Word, the second shape was on top, while in the original odt the first shape is on top.
56 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor", "relativeHeight", "2");
59 DECLARE_OOXMLEXPORT_TEST(testDmlShapeRelsize
, "dml-shape-relsize.docx")
61 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
64 // Relative size wasn't exported all, then relativeFrom was "page", not "margin".
65 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp14:sizeRelH", "relativeFrom", "margin");
68 DECLARE_OOXMLEXPORT_TEST(testDmlPictureInTextframe
, "dml-picture-in-textframe.docx")
73 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
74 CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess
->hasByName("word/media/image1.gif")));
75 // This was also true, image was written twice.
76 CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess
->hasByName("word/media/image2.gif")));
79 DECLARE_OOXMLEXPORT_TEST(testDmlGroupshapeRelsize
, "dml-groupshape-relsize.docx")
81 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
84 // Relative size wasn't imported.
85 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp14:sizeRelH", "relativeFrom", "margin");
88 DECLARE_OOXMLEXPORT_TEST(testDmlTextshape
, "dml-textshape.docx")
90 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
91 uno::Reference
<drawing::XShape
> xShape(xGroup
->getByIndex(1), uno::UNO_QUERY
);
92 // This was drawing::FillStyle_NONE.
93 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xShape
, "FillStyle"));
94 // This was drawing::LineStyle_NONE.
95 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, getProperty
<drawing::LineStyle
>(xShape
, "LineStyle"));
97 xmlDocPtr pXmlDocument
= parseExport("word/document.xml");
100 // This was wrap="none".
101 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:bodyPr", "wrap", "square");
103 xShape
.set(xGroup
->getByIndex(3), uno::UNO_QUERY
);
104 OUString aType
= comphelper::SequenceAsHashMap(getProperty
<beans::PropertyValues
>(xShape
, "CustomShapeGeometry"))["Type"].get
<OUString
>();
105 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-bentConnector3"), aType
);
106 // Connector was incorrectly shifted towards the top left corner, X was 552, Y was 0.
107 CPPUNIT_ASSERT_EQUAL(sal_Int32(4018), xShape
->getPosition().X
);
108 CPPUNIT_ASSERT_EQUAL(sal_Int32(1256), xShape
->getPosition().Y
);
110 xShape
.set(xGroup
->getByIndex(5), uno::UNO_QUERY
);
111 // This was incorrectly shifted towards the top of the page, Y was 106.
112 CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape
->getPosition().Y
);
115 DECLARE_OOXMLEXPORT_TEST(testDMLSolidfillAlpha
, "dml-solidfill-alpha.docx")
117 // Problem was that the transparency was not exported (a:alpha).
118 // RGB color (a:srgbClr)
119 uno::Reference
<beans::XPropertySet
> xShape(getShape(1), uno::UNO_QUERY
);;
120 CPPUNIT_ASSERT_EQUAL(sal_Int16(70), getProperty
<sal_Int16
>(xShape
, "FillTransparence"));
122 // Theme color (a:schemeClr)
123 xShape
.set(getShape(2), uno::UNO_QUERY
);
124 CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty
<sal_Int16
>(xShape
, "FillTransparence"));
127 DECLARE_OOXMLEXPORT_TEST(testDMLCustomGeometry
, "dml-customgeometry-cubicbezier.docx")
130 // The problem was that a custom shape was not exported.
131 uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(getShape(1), "CustomShapeGeometry");
132 uno::Sequence
<beans::PropertyValue
> aPathProps
;
133 for (int i
= 0; i
< aProps
.getLength(); ++i
)
135 const beans::PropertyValue
& rProp
= aProps
[i
];
136 if (rProp
.Name
== "Path")
137 rProp
.Value
>>= aPathProps
;
139 uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> aPairs
;
140 uno::Sequence
<drawing::EnhancedCustomShapeSegment
> aSegments
;
141 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
143 const beans::PropertyValue
& rProp
= aPathProps
[i
];
144 if (rProp
.Name
== "Coordinates")
145 rProp
.Value
>>= aPairs
;
146 else if (rProp
.Name
== "Segments")
147 rProp
.Value
>>= aSegments
;
151 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments
[0].Count
);
152 CPPUNIT_ASSERT_EQUAL(sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::MOVETO
), aSegments
[0].Command
);
155 CPPUNIT_ASSERT_EQUAL(sal_Int16(5), aSegments
[1].Count
);
156 CPPUNIT_ASSERT_EQUAL(sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::CURVETO
), aSegments
[1].Command
);
159 sal_Int32 nLength
= 16;
160 CPPUNIT_ASSERT_EQUAL(nLength
, aPairs
.getLength());
161 std::pair
<sal_Int32
,sal_Int32
> aCoordinates
[] =
163 std::pair
<sal_Int32
,sal_Int32
>(9084, 0),
164 std::pair
<sal_Int32
,sal_Int32
>(6734, 689),
165 std::pair
<sal_Int32
,sal_Int32
>(4489, 893),
166 std::pair
<sal_Int32
,sal_Int32
>(2633, 893),
167 std::pair
<sal_Int32
,sal_Int32
>(1631, 893),
168 std::pair
<sal_Int32
,sal_Int32
>(733, 830),
169 std::pair
<sal_Int32
,sal_Int32
>(0, 752),
170 std::pair
<sal_Int32
,sal_Int32
>(987, 908),
171 std::pair
<sal_Int32
,sal_Int32
>(2274, 1034),
172 std::pair
<sal_Int32
,sal_Int32
>(3756, 1034),
173 std::pair
<sal_Int32
,sal_Int32
>(5357, 1034),
174 std::pair
<sal_Int32
,sal_Int32
>(7183, 877),
175 std::pair
<sal_Int32
,sal_Int32
>(9084, 423),
176 std::pair
<sal_Int32
,sal_Int32
>(9084, 0),
177 std::pair
<sal_Int32
,sal_Int32
>(9084, 0),
178 std::pair
<sal_Int32
,sal_Int32
>(9084, 0)
181 for( int i
= 0; i
< nLength
; ++i
)
183 CPPUNIT_ASSERT(abs(aCoordinates
[i
].first
- aPairs
[i
].First
.Value
.get
<sal_Int32
>()) < 20);
184 CPPUNIT_ASSERT(abs(aCoordinates
[i
].second
- aPairs
[i
].Second
.Value
.get
<sal_Int32
>()) < 20);
188 DECLARE_OOXMLEXPORT_TEST(testDmlRectangleRelsize
, "dml-rectangle-relsize.docx")
190 // This was around 19560, as we did not read wp14:pctHeight for
191 // drawinglayer shapes and the fallback data was invalid.
192 OString
aMessage("Height is only " + OString::number(getShape(1)->getSize().Height
));
193 CPPUNIT_ASSERT_MESSAGE(aMessage
.getStr(), getShape(1)->getSize().Height
>= 20967);
195 // This was around 0: relative size of 0% was imported as 0, not "fall back to absolute size".
196 CPPUNIT_ASSERT(getShape(2)->getSize().Height
> 300);
199 DECLARE_OOXMLEXPORT_TEST(testDMLTextFrameVertAdjust
, "dml-textframe-vertadjust.docx")
201 // DOCX textboxes with text are imported as text frames but in Writer text frames did not have
202 // TextVerticalAdjust attribute so far.
204 // 1st frame's context is adjusted to the top
205 uno::Reference
<beans::XPropertySet
> xFrame(getShapeByName("Rectangle 1"), uno::UNO_QUERY
);
206 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP
, getProperty
<drawing::TextVerticalAdjust
>(xFrame
, "TextVerticalAdjust"));
207 // 2nd frame's context is adjusted to the center
208 xFrame
.set(getShapeByName("Rectangle 2"), uno::UNO_QUERY
);
209 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_CENTER
, getProperty
<drawing::TextVerticalAdjust
>(xFrame
, "TextVerticalAdjust"));
210 // 3rd frame's context is adjusted to the bottom
211 xFrame
.set(getShapeByName("Rectangle 3"), uno::UNO_QUERY
);
212 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM
, getProperty
<drawing::TextVerticalAdjust
>(xFrame
, "TextVerticalAdjust"));
215 DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillBitmapCrop
, "dml-shape-fillbitmapcrop.docx")
217 // Test the new GraphicCrop property which is introduced to define
218 // cropping of shapes filled with a picture in stretch mode.
220 // 1st shape has some cropping
221 text::GraphicCrop aGraphicCropStruct
= getProperty
<text::GraphicCrop
>(getShape(1), "GraphicCrop");
222 CPPUNIT_ASSERT_EQUAL( sal_Int32(mbExported
? 454 : 455 ), aGraphicCropStruct
.Left
);
223 CPPUNIT_ASSERT_EQUAL( sal_Int32(mbExported
? 367 : 368 ), aGraphicCropStruct
.Right
);
224 CPPUNIT_ASSERT_EQUAL( sal_Int32(mbExported
? -454 : -455 ), aGraphicCropStruct
.Top
);
225 CPPUNIT_ASSERT_EQUAL( sal_Int32(mbExported
? -367 : -368 ), aGraphicCropStruct
.Bottom
);
227 // 2nd shape has no cropping
228 aGraphicCropStruct
= getProperty
<text::GraphicCrop
>(getShape(2), "GraphicCrop");
229 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct
.Left
);
230 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct
.Right
);
231 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct
.Top
);
232 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct
.Bottom
);
236 DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillPattern
, "dml-shape-fillpattern.docx")
238 // Hatching was ignored by the export.
240 // 1st shape: light horizontal pattern (ltHorz)
241 drawing::Hatch aHatch
= getProperty
<drawing::Hatch
>(getShape(1), "FillHatch");
242 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aHatch
.Angle
);
243 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
244 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x99FF66), aHatch
.Color
);
245 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
247 // 2nd shape: horizontal pattern (horz)
248 aHatch
= getProperty
<drawing::Hatch
>(getShape(2), "FillHatch");
249 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aHatch
.Angle
);
250 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
251 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
253 // 3rd shape: light vertical pattern (ltVert)
254 aHatch
= getProperty
<drawing::Hatch
>(getShape(3), "FillHatch");
255 CPPUNIT_ASSERT_EQUAL(sal_Int32(900), aHatch
.Angle
);
256 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
257 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
259 // 4th shape: vertical pattern (vert)
260 aHatch
= getProperty
<drawing::Hatch
>(getShape(4), "FillHatch");
261 CPPUNIT_ASSERT_EQUAL(sal_Int32(900), aHatch
.Angle
);
262 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
263 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
265 // 5th shape: light upward diagonal pattern (ltUpDiag)
266 aHatch
= getProperty
<drawing::Hatch
>(getShape(5), "FillHatch");
267 CPPUNIT_ASSERT_EQUAL(sal_Int32(450), aHatch
.Angle
);
268 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
269 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
271 // 6th shape: wide upward diagonal pattern (wdUpDiag)
272 aHatch
= getProperty
<drawing::Hatch
>(getShape(6), "FillHatch");
273 CPPUNIT_ASSERT_EQUAL(sal_Int32(450), aHatch
.Angle
);
274 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
275 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
277 // 7th shape: light downward diagonal pattern (ltDnDiag)
278 aHatch
= getProperty
<drawing::Hatch
>(getShape(7), "FillHatch");
279 CPPUNIT_ASSERT_EQUAL(sal_Int32(1350), aHatch
.Angle
);
280 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
281 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
283 // 8th shape: wide downward diagonal pattern (wdDnDiag)
284 aHatch
= getProperty
<drawing::Hatch
>(getShape(8), "FillHatch");
285 CPPUNIT_ASSERT_EQUAL(sal_Int32(1350), aHatch
.Angle
);
286 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
287 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
289 // 9th shape: small grid pattern (smGrid)
290 aHatch
= getProperty
<drawing::Hatch
>(getShape(9), "FillHatch");
291 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aHatch
.Angle
);
292 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
293 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_DOUBLE
, aHatch
.Style
);
295 // 10th shape: large grid pattern (lgGrid)
296 aHatch
= getProperty
<drawing::Hatch
>(getShape(10), "FillHatch");
297 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aHatch
.Angle
);
298 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
299 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_DOUBLE
, aHatch
.Style
);
301 // 11th shape: small checker board pattern (smCheck)
302 aHatch
= getProperty
<drawing::Hatch
>(getShape(11), "FillHatch");
303 CPPUNIT_ASSERT_EQUAL(sal_Int32(450), aHatch
.Angle
);
304 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
305 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_DOUBLE
, aHatch
.Style
);
307 // 12th shape: outlined diamond pattern (openDmnd)
308 aHatch
= getProperty
<drawing::Hatch
>(getShape(12), "FillHatch");
309 CPPUNIT_ASSERT_EQUAL(sal_Int32(450), aHatch
.Angle
);
310 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
311 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_DOUBLE
, aHatch
.Style
);
314 DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition
, "dml-groupshape-childposition.docx")
316 // Problem was parent transformation was ignored fully, but translate component
317 // which specify the position must be also applied for children of the group.
319 uno::Reference
<drawing::XShapes
> xGroup(getShape(1), uno::UNO_QUERY
);
320 uno::Reference
<drawing::XShape
> xChildGroup(xGroup
->getByIndex(1), uno::UNO_QUERY
);
321 CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported
? -2120 : -2122), xChildGroup
->getPosition().X
);
322 CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported
? 11336 : 11333), xChildGroup
->getPosition().Y
);
324 xGroup
.set(xChildGroup
, uno::UNO_QUERY
);
325 xChildGroup
.set(xGroup
->getByIndex(0), uno::UNO_QUERY
);
326 CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported
? -1856 : -1858), xChildGroup
->getPosition().X
);
327 CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported
? 11336 : 11333), xChildGroup
->getPosition().Y
);
329 xChildGroup
.set(xGroup
->getByIndex(1), uno::UNO_QUERY
);
330 CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported
? -2120 : -2122), xChildGroup
->getPosition().X
);
331 CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported
? 14026 : 14023), xChildGroup
->getPosition().Y
);
334 DECLARE_OOXMLEXPORT_TEST(testDMLGradientFillTheme
, "dml-gradientfill-theme.docx")
336 // Problem was when a fill gradient was imported from a theme, (fillRef in ooxml)
337 // not just the theme was written out but the explicit values too
338 // Besides the duplication of values it causes problems with writing out
339 // <a:schemeClr val="phClr"> into document.xml, while phClr can be used just for theme definitions.
340 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
344 // check no explicit gradFill has been exported
346 "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill",
349 // check shape style has been exported
351 "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef",
354 "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef/a:schemeClr",
358 DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeParaSpacing
, "dml-groupshape-paraspacing.docx")
360 // Paragraph spacing (top/bottom margin and line spacing) inside a group shape was not imported
361 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
362 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xGroup
->getByIndex(1), uno::UNO_QUERY
)->getText();
364 // 1st paragraph has 1.5x line spacing but it has no spacing before/after.
365 uno::Reference
<text::XTextRange
> xRun
= getRun(getParagraphOfText(1, xText
),1);
366 style::LineSpacing aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
367 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP
), aLineSpacing
.Mode
);
368 CPPUNIT_ASSERT_EQUAL(sal_Int16(150), aLineSpacing
.Height
);
369 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
370 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
372 // 2nd paragraph has double line spacing but it has no spacing before/after.
373 xRun
.set(getRun(getParagraphOfText(2, xText
),1));
374 aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
375 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP
), aLineSpacing
.Mode
);
376 CPPUNIT_ASSERT_EQUAL(sal_Int16(200), aLineSpacing
.Height
);
377 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
378 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
380 // 3rd paragraph has 24 pt line spacing but it has no spacing before/after.
381 xRun
.set(getRun(getParagraphOfText(3, xText
),1));
382 aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
383 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::MINIMUM
), aLineSpacing
.Mode
);
384 CPPUNIT_ASSERT_EQUAL(sal_Int16(847), aLineSpacing
.Height
);
385 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
386 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
388 // 4th paragraph has 1.75x line spacing but it has no spacing before/after.
389 xRun
.set(getRun(getParagraphOfText(4, xText
),1));
390 aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
391 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP
), aLineSpacing
.Mode
);
392 CPPUNIT_ASSERT_EQUAL(sal_Int16(175), aLineSpacing
.Height
);
393 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
394 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
396 // 5th paragraph has margins which are defined by w:beforeLines and w:afterLines.
397 xRun
.set(getRun(getParagraphOfText(5, xText
),1));
398 aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
399 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP
), aLineSpacing
.Mode
);
400 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aLineSpacing
.Height
);
401 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
402 CPPUNIT_ASSERT_EQUAL(sal_Int32(741), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
404 // 6th paragraph has margins which are defined by w:before and w:after.
405 xRun
.set(getRun(getParagraphOfText(6, xText
),1));
406 aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
407 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP
), aLineSpacing
.Mode
);
408 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aLineSpacing
.Height
);
409 CPPUNIT_ASSERT_EQUAL(sal_Int32(423), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
410 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
412 // 7th paragraph has auto paragraph margins a:afterAutospacing and a:beforeAutospacing, which means margins must be ignored.
413 xRun
.set(getRun(getParagraphOfText(7, xText
),1));
414 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
415 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
418 DECLARE_OOXMLEXPORT_TEST(testTableFloatingMargins
, "table-floating-margins.docx")
420 // In case the table had custom left cell margin, the horizontal position was still incorrect (too small, -199).
421 uno::Reference
<beans::XPropertySet
> xFrame(getShape(1), uno::UNO_QUERY
);
422 sal_Int32 nHoriOrientPosition
= getProperty
<sal_Int32
>(xFrame
, "HoriOrientPosition");
423 CPPUNIT_ASSERT(nHoriOrientPosition
< sal_Int32(-495));
424 // These were 0 as well, due to lack of import.
425 CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), getProperty
<sal_Int32
>(xFrame
, "TopMargin"));
426 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), getProperty
<sal_Int32
>(xFrame
, "BottomMargin"));
428 // Paragraph bottom margin wasn't 0 in the A1 cell of the floating table.
429 xmlDocPtr pXmlDoc
= parseExport();
432 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:textbox/w:txbxContent/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:spacing", "after", "0");
435 DECLARE_OOXMLEXPORT_TEST(testFdo69636
, "fdo69636.docx")
438 * The problem was that the exporter didn't mirror the workaround of the
439 * importer, regarding the btLr text frame direction: the
440 * mso-layout-flow-alt property was completely missing in the output.
442 xmlDocPtr pXmlDoc
= parseExport();
446 CPPUNIT_ASSERT(getXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:textbox", "style").match("mso-layout-flow-alt:bottom-to-top"));
448 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr", "vert", "vert270");
451 DECLARE_OOXMLEXPORT_TEST(testVMLData
, "TestVMLData.docx")
453 // The problem was exporter was exporting vml data for shape in w:rPr element.
454 // vml data should not come under w:rPr element.
455 xmlDocPtr pXmlDoc
= parseExport("word/header2.xml");
458 CPPUNIT_ASSERT(getXPath(pXmlDoc
, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "stroked").match("f"));
461 DECLARE_OOXMLEXPORT_TEST(testImageData
, "image_data.docx")
463 // The problem was exporter was exporting v:imagedata data for shape in w:pict as v:fill w element.
465 xmlDocPtr pXmlDoc
= parseExport("word/header2.xml");
468 CPPUNIT_ASSERT(getXPath(pXmlDoc
, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:imagedata", "detectmouseclick").match("t"));
471 DECLARE_OOXMLEXPORT_TEST(testFdo70838
, "fdo70838.docx")
473 // The problem was that VMLExport::Commit didn't save the correct width and height,
474 // and ImplEESdrWriter::ImplFlipBoundingBox made a mistake calculating the position
476 xmlDocPtr pXmlDocument
= parseExport("word/document.xml");
480 // Check DML document
482 sal_Int32 aXPos
[4], aYPos
[4];
483 aXPos
[0] = getXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/wp:positionH/wp:posOffset").toInt32();
484 aXPos
[1] = getXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/wp:positionH/wp:posOffset").toInt32();
485 aXPos
[2] = getXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/wp:positionH/wp:posOffset").toInt32();
486 aXPos
[3] = getXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/wp:positionH/wp:posOffset").toInt32();
488 aYPos
[0] = getXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/wp:positionV/wp:posOffset").toInt32();
489 aYPos
[1] = getXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/wp:positionV/wp:posOffset").toInt32();
490 aYPos
[2] = getXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/wp:positionV/wp:posOffset").toInt32();
491 aYPos
[3] = getXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/wp:positionV/wp:posOffset").toInt32();
493 // certain degree of error is tolerated due to rounding in unit conversions
494 CPPUNIT_ASSERT(abs(1239520 - aXPos
[0]) < 1000);
495 CPPUNIT_ASSERT(abs(1239520 - aXPos
[1]) < 1000);
496 CPPUNIT_ASSERT(abs(1238250 - aXPos
[2]) < 1000);
497 CPPUNIT_ASSERT(abs(1238885 - aXPos
[3]) < 1000);
499 CPPUNIT_ASSERT(abs(2095500 - aYPos
[0]) < 1000);
500 CPPUNIT_ASSERT(abs(2094865 - aYPos
[1]) < 1000);
501 CPPUNIT_ASSERT(abs(2094230 - aYPos
[2]) < 1000);
502 CPPUNIT_ASSERT(abs(2094865 - aYPos
[3]) < 1000);
504 sal_Int32 aHSize
[4], aVSize
[4];
505 aHSize
[0] = getXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/wp:extent", "cx").toInt32();
506 aHSize
[1] = getXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/wp:extent", "cx").toInt32();
507 aHSize
[2] = getXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/wp:extent", "cx").toInt32();
508 aHSize
[3] = getXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/wp:extent", "cx").toInt32();
510 aVSize
[0] = getXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/wp:extent", "cy").toInt32();
511 aVSize
[1] = getXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/wp:extent", "cy").toInt32();
512 aVSize
[2] = getXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/wp:extent", "cy").toInt32();
513 aVSize
[3] = getXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/wp:extent", "cy").toInt32();
515 // certain degree of error is tolerated due to rounding in unit conversions
516 CPPUNIT_ASSERT(abs(3599280 - aHSize
[0]) < 1000);
517 CPPUNIT_ASSERT(abs(3599280 - aHSize
[1]) < 1000);
518 CPPUNIT_ASSERT(abs(3599280 - aHSize
[2]) < 1000);
519 CPPUNIT_ASSERT(abs(3599280 - aHSize
[3]) < 1000);
521 CPPUNIT_ASSERT(abs(1799640 - aVSize
[0]) < 1000);
522 CPPUNIT_ASSERT(abs(1799640 - aVSize
[1]) < 1000);
523 CPPUNIT_ASSERT(abs(1799640 - aVSize
[2]) < 1000);
524 CPPUNIT_ASSERT(abs(1799640 - aVSize
[3]) < 1000);
526 // Check VML document
528 // get styles of the four shapes
530 aStyles
[0] = getXPath( pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:rect", "style");
531 // original is: "position:absolute;margin-left:97.6pt;margin-top:165pt;width:283.4pt;height:141.7pt;rotation:285"
532 aStyles
[1] = getXPath( pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Fallback/w:pict/v:rect", "style");
533 // original is: "position:absolute;margin-left:97.6pt;margin-top:164.95pt;width:283.4pt;height:141.7pt;rotation:255"
534 aStyles
[2] = getXPath( pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Fallback/w:pict/v:rect", "style");
535 // original is: "position:absolute;margin-left:97.5pt;margin-top:164.9pt;width:283.4pt;height:141.7pt;rotation:105"
536 aStyles
[3] = getXPath( pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[4]/mc:Fallback/w:pict/v:rect", "style");
537 // original is: "position:absolute;margin-left:97.55pt;margin-top:164.95pt;width:283.4pt;height:141.7pt;rotation:75"
539 //check the size and position of each of the shapes
540 for( int i
= 0; i
< 4; ++i
)
542 CPPUNIT_ASSERT(!aStyles
[i
].isEmpty());
544 sal_Int32 nextTokenPos
= 0;
547 OUString aStyleCommand
= aStyles
[i
].getToken( 0, ';', nextTokenPos
);
548 CPPUNIT_ASSERT(!aStyleCommand
.isEmpty());
550 OUString aStyleCommandName
= aStyleCommand
.getToken( 0, ':' );
551 OUString aStyleCommandValue
= aStyleCommand
.getToken( 1, ':' );
553 if( aStyleCommandName
== "margin-left" )
555 float fValue
= aStyleCommandValue
.getToken( 0, 'p' ).toFloat();
556 CPPUNIT_ASSERT_DOUBLES_EQUAL(97.6, fValue
, 0.1);
558 else if( aStyleCommandName
== "margin-top" )
560 float fValue
= aStyleCommandValue
.getToken( 0, 'p' ).toFloat();
561 CPPUNIT_ASSERT_DOUBLES_EQUAL(165.0, fValue
, 0.2);
563 else if( aStyleCommandName
== "width" )
565 float fValue
= aStyleCommandValue
.getToken( 0, 'p' ).toFloat();
566 CPPUNIT_ASSERT_DOUBLES_EQUAL(283.4, fValue
, 0.1);
568 else if( aStyleCommandName
== "height" )
570 float fValue
= aStyleCommandValue
.getToken( 0, 'p' ).toFloat();
571 CPPUNIT_ASSERT_DOUBLES_EQUAL(141.7, fValue
, 0.1);
574 } while( nextTokenPos
!= -1 );
577 // Check shape objects
580 aPos
[0] = getShape(1)->getPosition();
581 aPos
[1] = getShape(2)->getPosition();
582 aPos
[2] = getShape(3)->getPosition();
583 aPos
[3] = getShape(4)->getPosition();
585 // certain degree of error is tolerated due to rounding in unit conversions
586 CPPUNIT_ASSERT(abs(4734 - aPos
[0].X
) < 10);
587 CPPUNIT_ASSERT(abs(4734 - aPos
[1].X
) < 10);
588 CPPUNIT_ASSERT(abs(4731 - aPos
[2].X
) < 10);
589 CPPUNIT_ASSERT(abs(4733 - aPos
[3].X
) < 10);
591 CPPUNIT_ASSERT(abs(2845 - aPos
[0].Y
) < 10);
592 CPPUNIT_ASSERT(abs(2843 - aPos
[1].Y
) < 10);
593 CPPUNIT_ASSERT(abs(2842 - aPos
[2].Y
) < 10);
594 CPPUNIT_ASSERT(abs(2843 - aPos
[3].Y
) < 10);
597 DECLARE_OOXMLEXPORT_TEST(testFdo73215
, "fdo73215.docx")
599 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
602 // 'rect' was 'pictureFrame', which isn't valid.
603 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:spPr/a:prstGeom",
605 // 'adj1' was 'adj', which is not valid for bentConnector3.
606 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wpg:wgp/wps:wsp[9]/wps:spPr/a:prstGeom/a:avLst/a:gd",
610 DECLARE_OOXMLEXPORT_TEST(testBehinddoc
, "behinddoc.docx")
612 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
615 // This was "0", shape was in the foreground.
616 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor", "behindDoc", "1");
619 DECLARE_OOXMLEXPORT_TEST(testSmartArtAnchoredInline
, "fdo73227.docx")
621 /* Given file conatins 3 DrawingML objects as 1Picture,1SmartArt and 1Shape.
622 * Check for SmartArt.
623 * SmartArt shoould get written as "Floating Object" i.e. inside <wp:anchor> tag.
624 * Also check for value of attribute "id" of <wp:docPr> . It should be unique for
625 * all 3 DrawingML objects in a document.
628 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
631 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:drawing[1]/wp:anchor/wp:docPr","id","1");
632 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:drawing[1]/wp:anchor/wp:docPr","name","Diagram1");
634 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr","id","2");
635 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr","name","10-Point Star 3");
637 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:drawing[2]/wp:anchor/wp:docPr","id","3");
638 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:drawing[2]/wp:anchor/wp:docPr","name","Picture 1");
641 DECLARE_OOXMLEXPORT_TEST(testFdo65833
, "fdo65833.docx")
643 // The "editas" attribute for vml group shape was not preserved.
644 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
647 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:group", "editas", "canvas");
650 DECLARE_OOXMLEXPORT_TEST(testFdo73247
, "fdo73247.docx")
652 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
656 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:xfrm",
660 DECLARE_OOXMLEXPORT_TEST(testFdo70942
, "fdo70942.docx")
662 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
665 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom",
669 DECLARE_OOXMLEXPORT_TEST(testDrawinglayerPicPos
, "drawinglayer-pic-pos.docx")
671 // The problem was that the position of the picture was incorrect, it was shifted towards the bottom right corner.
672 xmlDocPtr pXmlDocument
= parseExport("word/document.xml");
676 OString
aXPath("/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:xfrm/a:off");
678 assertXPath(pXmlDocument
, aXPath
, "x", "0");
680 assertXPath(pXmlDocument
, aXPath
, "y", "0");
683 DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation
, "shape-theme-preservation.docx")
685 xmlDocPtr pXmlDocument
= parseExport("word/document.xml");
689 // check shape style has been preserved
690 assertXPath(pXmlDocument
,
691 "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef",
693 assertXPath(pXmlDocument
,
694 "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef/a:schemeClr",
696 assertXPath(pXmlDocument
,
697 "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef",
699 assertXPath(pXmlDocument
,
700 "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef/a:schemeClr",
702 assertXPath(pXmlDocument
,
703 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef",
705 assertXPath(pXmlDocument
,
706 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef/a:schemeClr",
708 assertXPath(pXmlDocument
,
709 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:lnRef",
711 assertXPath(pXmlDocument
,
712 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:lnRef/a:schemeClr",
714 assertXPath(pXmlDocument
,
715 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:lnRef/a:schemeClr/a:shade",
717 assertXPath(pXmlDocument
,
718 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:effectRef",
720 assertXPath(pXmlDocument
,
721 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:effectRef/a:schemeClr",
724 // check shape style hasn't been overwritten
725 assertXPath(pXmlDocument
,
726 "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:solidFill",
728 assertXPath(pXmlDocument
,
729 "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill",
732 // check direct theme assignments have been preserved
733 assertXPath(pXmlDocument
,
734 "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:solidFill/a:schemeClr",
736 assertXPath(pXmlDocument
,
737 "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill/a:schemeClr",
740 // check color transformations applied to theme colors have been preserved
741 assertXPath(pXmlDocument
,
742 "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:solidFill/a:schemeClr/a:lumMod",
744 assertXPath(pXmlDocument
,
745 "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:solidFill/a:schemeClr/a:lumOff",
747 assertXPath(pXmlDocument
,
748 "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill/a:schemeClr/a:lumMod",
751 // check direct color assignments have been preserved
752 OUString sFillColor
= getXPath(pXmlDocument
,
753 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:solidFill/a:srgbClr",
755 CPPUNIT_ASSERT_EQUAL(sFillColor
.toInt32(16), sal_Int32(0x00b050));
756 sal_Int32 nLineColor
= getXPath(pXmlDocument
,
757 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill/a:srgbClr",
759 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), nLineColor
);
761 // check direct line type assignments have been preserved
762 sal_Int32 nLineWidth
= getXPath(pXmlDocument
,
763 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln",
765 CPPUNIT_ASSERT(abs(63500 - nLineWidth
) < 1000); //some rounding errors in the conversion ooxml -> libo -> ooxml are tolerated
766 assertXPath(pXmlDocument
,
767 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:miter",
769 assertXPath(pXmlDocument
,
770 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:custDash",
773 uno::Reference
<drawing::XShape
> xShape1
= getShape(1);
774 uno::Reference
<drawing::XShape
> xShape2
= getShape(2);
775 uno::Reference
<drawing::XShape
> xShape3
= getShape(3);
777 // check colors are properly applied to shapes on import
778 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), getProperty
<sal_Int32
>(xShape1
, "FillColor"));
779 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xfcd5b5), getProperty
<sal_Int32
>(xShape2
, "FillColor"));
780 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00b050), getProperty
<sal_Int32
>(xShape3
, "FillColor"));
781 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x3a5f8b), getProperty
<sal_Int32
>(xShape1
, "LineColor"));
782 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f6228), getProperty
<sal_Int32
>(xShape2
, "LineColor"));
783 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), getProperty
<sal_Int32
>(xShape3
, "LineColor"));
785 // check line properties are properly applied to shapes on import
786 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, getProperty
<drawing::LineStyle
>(xShape1
, "LineStyle"));
787 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, getProperty
<drawing::LineStyle
>(xShape2
, "LineStyle"));
788 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_DASH
, getProperty
<drawing::LineStyle
>(xShape3
, "LineStyle"));
789 CPPUNIT_ASSERT_EQUAL(drawing::LineJoint_ROUND
, getProperty
<drawing::LineJoint
>(xShape1
, "LineJoint"));
790 CPPUNIT_ASSERT_EQUAL(drawing::LineJoint_ROUND
, getProperty
<drawing::LineJoint
>(xShape2
, "LineJoint"));
791 CPPUNIT_ASSERT_EQUAL(drawing::LineJoint_MITER
, getProperty
<drawing::LineJoint
>(xShape3
, "LineJoint"));
794 DECLARE_OOXMLEXPORT_TEST(testFDO73546
, "FDO73546.docx")
796 xmlDocPtr pXmlDoc
= parseExport("word/header1.xml");
799 assertXPath(pXmlDoc
, "/w:hdr/w:p[1]/w:r[3]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor", "distL","0");
802 DECLARE_OOXMLEXPORT_TEST(testFdo69616
, "fdo69616.docx")
804 xmlDocPtr pXmlDoc
= parseExport();
808 CPPUNIT_ASSERT(getXPath(pXmlDoc
, "/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[1]/mc:AlternateContent/mc:Fallback/w:pict/v:group", "coordorigin").match("696,725"));
811 DECLARE_OOXMLEXPORT_TEST(testAlignForShape
,"Shape.docx")
813 //fdo73545:Shape Horizontal and vertical orientation is wrong
814 //The wp:align tag is missing after roundtrip
815 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
818 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:positionH/wp:align","1");
821 DECLARE_OOXMLEXPORT_TEST(testLineStyle_DashType
, "LineStyle_DashType.docx")
823 /* DOCX contatining Shape with LineStyle as Dash Type should get preserved inside
824 * an XMl tag <a:prstDash> with value "dash".
826 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
830 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "dash");
833 DECLARE_OOXMLEXPORT_TEST(testGradientFillPreservation
, "gradient-fill-preservation.docx")
835 xmlDocPtr pXmlDocument
= parseExport("word/document.xml");
839 // check rgb colors for every step in the gradient of the first shape
840 assertXPath(pXmlDocument
,
841 "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr",
843 assertXPath(pXmlDocument
,
844 "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr",
846 assertXPath(pXmlDocument
,
847 "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill/a:gsLst/a:gs[3]/a:srgbClr",
850 // check theme colors for every step in the gradient of the second shape
851 assertXPath(pXmlDocument
,
852 "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill/a:gsLst/a:gs[@pos='0']/a:schemeClr",
854 assertXPath(pXmlDocument
,
855 "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill/a:gsLst/a:gs[@pos='50000']/a:schemeClr",
857 assertXPath(pXmlDocument
,
858 "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill/a:gsLst/a:gs[@pos='100000']/a:schemeClr",
861 assertXPath(pXmlDocument
,
862 "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill/a:gsLst/a:gs[@pos='50000']/a:srgbClr/a:alpha",
864 assertXPath(pXmlDocument
,
865 "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill/a:gsLst/a:gs[@pos='50000']/a:schemeClr/a:tint",
867 assertXPath(pXmlDocument
,
868 "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill/a:gsLst/a:gs[@pos='50000']/a:schemeClr/a:satMod",
872 DECLARE_OOXMLEXPORT_TEST(testLineStyle_DashType_VML
, "LineStyle_DashType_VML.docx")
874 /* DOCX contatining "Shape with text inside" having Line Style as "Dash Type" should get
875 * preserved inside an XML tag <v:stroke> with attribute dashstyle having value "dash".
877 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
880 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r[1]/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:stroke", "dashstyle", "dash");
883 DECLARE_OOXMLEXPORT_TEST(testFdo74110
,"fdo74110.docx")
886 The File contains word art which is being exported as shape and the mapping is defaulted to
887 shape type rect since the actual shape type(s) is/are commented out for some reason.
888 The actual shape type(s) has/have adjustment value(s) where as rect does not have adjustment value.
889 Hence the following test case.
891 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
894 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:prstGeom[1]",
896 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:prstGeom[1]/a:avLst[1]/a:gd[1]",0);
899 DECLARE_OOXMLEXPORT_TEST(testOuterShdw
,"testOuterShdw.docx")
901 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
904 assertXPath(pXmlDoc
, "//mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:effectLst[1]/a:outerShdw[1]", "dist", "57811035");
907 DECLARE_OOXMLEXPORT_TEST(testExtentValue
, "fdo74605.docx")
909 xmlDocPtr pXmlDoc
= parseExport();
912 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:extent","cx","0");
915 // part of tdf#93676, word gives the frame in the exported .docx a huge height,
916 // because its exported with 255% height percentage from a 255 HeightPercent
917 // settings, but 255 is a special flag that the value is synced to the
919 DECLARE_OOXMLEXPORT_TEST(testSyncedRelativePercent
, "tdf93676-1.odt")
921 xmlDocPtr pXmlDoc
= parseExport("word/document.xml");
925 // check no explicit pctHeight has been exported, all we care
926 // about at this point is that its not 255000
927 assertXPath(pXmlDoc
, "//wp14:pctHeight", 0);
932 CPPUNIT_PLUGIN_IMPLEMENT();
934 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */