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>
12 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
13 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
14 #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
15 #include <com/sun/star/drawing/FillStyle.hpp>
16 #include <com/sun/star/drawing/Hatch.hpp>
17 #include <com/sun/star/drawing/LineJoint.hpp>
18 #include <com/sun/star/drawing/LineStyle.hpp>
19 #include <com/sun/star/drawing/XShapes.hpp>
20 #include <com/sun/star/style/LineSpacing.hpp>
21 #include <com/sun/star/style/LineSpacingMode.hpp>
22 #include <com/sun/star/text/GraphicCrop.hpp>
23 #include <com/sun/star/text/VertOrientation.hpp>
24 #include <com/sun/star/text/WrapTextMode.hpp>
25 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
27 #include <comphelper/sequenceashashmap.hxx>
28 #include <comphelper/processfactory.hxx>
30 class Test
: public SwModelTestBase
33 Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
36 CPPUNIT_TEST_FIXTURE(Test
, testTdf133701
)
38 loadAndSave("tdf133701.docx");
39 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
41 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:pPr/w:framePr", "hSpace", "567");
42 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:pPr/w:framePr", "vSpace", "284");
45 DECLARE_OOXMLEXPORT_TEST(testDmlShapeTitle
, "dml-shape-title.docx")
47 CPPUNIT_ASSERT_EQUAL(OUString("Title"), getProperty
<OUString
>(getShape(1), "Title"));
48 CPPUNIT_ASSERT_EQUAL(OUString("Description"), getProperty
<OUString
>(getShape(1), "Description"));
51 CPPUNIT_TEST_FIXTURE(Test
, testDmlZorder
)
53 loadAndSave("dml-zorder.odt");
54 CPPUNIT_ASSERT_EQUAL(3, getShapes());
55 CPPUNIT_ASSERT_EQUAL(1, getPages());
56 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
57 // This was "0": causing that in Word, the second shape was on top, while in the original odt the first shape is on top.
58 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor", "relativeHeight", "2");
61 CPPUNIT_TEST_FIXTURE(Test
, testDmlShapeRelsize
)
63 loadAndSave("dml-shape-relsize.docx");
64 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
65 // Relative size wasn't exported all, then relativeFrom was "page", not "margin".
66 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp14:sizeRelH", "relativeFrom", "margin");
69 CPPUNIT_TEST_FIXTURE(Test
, testDmlPictureInTextframe
)
71 loadAndReload("dml-picture-in-textframe.docx");
72 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
73 CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess
->hasByName("word/media/image1.gif")));
74 // This was also true, image was written twice.
75 CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess
->hasByName("word/media/image2.gif")));
78 CPPUNIT_TEST_FIXTURE(Test
, testDmlGroupshapeRelsize
)
80 loadAndSave("dml-groupshape-relsize.docx");
81 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
82 // Relative size wasn't imported.
83 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp14:sizeRelH", "relativeFrom", "margin");
86 DECLARE_OOXMLEXPORT_TEST(testDmlTextshape
, "dml-textshape.docx")
88 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
89 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::TOP
, getProperty
<sal_Int16
>(xGroup
, "VertOrient"));
90 uno::Reference
<drawing::XShape
> xShape(xGroup
->getByIndex(1), uno::UNO_QUERY
);
91 // This was drawing::FillStyle_NONE.
92 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xShape
, "FillStyle"));
93 // This was drawing::LineStyle_NONE.
94 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, getProperty
<drawing::LineStyle
>(xShape
, "LineStyle"));
98 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
99 // This was wrap="none".
100 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");
102 xShape
.set(xGroup
->getByIndex(3), uno::UNO_QUERY
);
103 OUString aType
= comphelper::SequenceAsHashMap(getProperty
<beans::PropertyValues
>(xShape
, "CustomShapeGeometry"))["Type"].get
<OUString
>();
104 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-bentConnector3"), aType
);
105 // Connector was incorrectly shifted towards the top left corner, X was 552, Y was 0.
106 // It is not a DML, but a VML shape. The whole group is shifted 3mm right and 6mm up.
107 // Values are as in LO7.2, original problem is still fixed.
108 CPPUNIT_ASSERT_EQUAL(sal_Int32(4016), xShape
->getPosition().X
);
109 CPPUNIT_ASSERT_EQUAL(sal_Int32(-4485), xShape
->getPosition().Y
);
111 xShape
.set(xGroup
->getByIndex(5), uno::UNO_QUERY
);
112 // This was incorrectly shifted towards the top of the page, Y was 106.
113 CPPUNIT_ASSERT_EQUAL(sal_Int32(-4729), xShape
->getPosition().Y
);
116 // testDmlTextshapeB was only made export-only because as an import-export test it failed for an unknown reason
117 CPPUNIT_TEST_FIXTURE(Test
, testDmlTextshapeB
)
119 loadAndReload("dml-textshapeB.docx");
120 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
121 uno::Reference
<drawing::XShape
> xShape(xGroup
->getByIndex(3), uno::UNO_QUERY
);
122 // Connector was incorrectly shifted towards the top left corner, X was 192, Y was -5743.
123 CPPUNIT_ASSERT_EQUAL(sal_Int32(3896), xShape
->getPosition().X
);
124 CPPUNIT_ASSERT_EQUAL(sal_Int32(-4775), xShape
->getPosition().Y
);
125 // Values are as in LO7.3, the original problem is still fixed.
126 // FixMe: The shape is a VML group, not a DML. Connector handles are still wrong and whole group
129 xShape
.set(xGroup
->getByIndex(5), uno::UNO_QUERY
);
130 // This was incorrectly shifted towards the top of the page, Y was -5011.
131 CPPUNIT_ASSERT_EQUAL(sal_Int32(-4720), xShape
->getPosition().Y
);
134 DECLARE_OOXMLEXPORT_TEST(testDMLSolidfillAlpha
, "dml-solidfill-alpha.docx")
136 // Problem was that the transparency was not exported (a:alpha).
137 // RGB color (a:srgbClr)
138 uno::Reference
<beans::XPropertySet
> xShape(getShape(1), uno::UNO_QUERY
);
139 CPPUNIT_ASSERT_EQUAL(sal_Int16(70), getProperty
<sal_Int16
>(xShape
, "FillTransparence"));
141 // Theme color (a:schemeClr)
142 xShape
.set(getShape(2), uno::UNO_QUERY
);
143 CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty
<sal_Int16
>(xShape
, "FillTransparence"));
146 CPPUNIT_TEST_FIXTURE(Test
, testDMLTextFrameNoFill
)
148 loadAndReload("frame.fodt");
149 // Problem is that default text frame background is white in Writer and transparent in Word
150 uno::Reference
<beans::XPropertySet
> xShape1(getShape(1), uno::UNO_QUERY
);
151 // it is re-imported as solid
152 // CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xShape1, "FillStyle"));
153 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xShape1
, "FillStyle"));
154 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(xShape1
, "FillTransparence"));
155 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, getProperty
<Color
>(xShape1
, "FillColor"));
157 uno::Reference
<beans::XPropertySet
> xShape2(getShape(2), uno::UNO_QUERY
);
158 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xShape2
, "FillStyle"));
159 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(xShape2
, "FillTransparence"));
160 CPPUNIT_ASSERT_EQUAL(Color(0xE8F2A1), getProperty
<Color
>(xShape2
, "FillColor"));
162 uno::Reference
<beans::XPropertySet
> xShape3(getShape(3), uno::UNO_QUERY
);
163 // it is re-imported as solid
164 // CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xShape3, "FillStyle"));
165 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xShape3
, "FillStyle"));
166 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, getProperty
<Color
>(xShape3
, "FillColor"));
167 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(xShape3
, "FillTransparence"));
170 DECLARE_OOXMLEXPORT_TEST(testDMLCustomGeometry
, "dml-customgeometry-cubicbezier.docx")
173 // The problem was that a custom shape was not exported.
174 const uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(getShape(1), "CustomShapeGeometry");
175 uno::Sequence
<beans::PropertyValue
> aPathProps
;
176 for (beans::PropertyValue
const & rProp
: aProps
)
178 if (rProp
.Name
== "Path")
179 rProp
.Value
>>= aPathProps
;
181 uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> aPairs
;
182 uno::Sequence
<drawing::EnhancedCustomShapeSegment
> aSegments
;
183 for (beans::PropertyValue
const & rProp
: std::as_const(aPathProps
))
185 if (rProp
.Name
== "Coordinates")
186 rProp
.Value
>>= aPairs
;
187 else if (rProp
.Name
== "Segments")
188 rProp
.Value
>>= aSegments
;
192 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments
[0].Count
);
193 CPPUNIT_ASSERT_EQUAL(sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::MOVETO
), aSegments
[0].Command
);
196 CPPUNIT_ASSERT_EQUAL(sal_Int16(5), aSegments
[1].Count
);
197 CPPUNIT_ASSERT_EQUAL(sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::CURVETO
), aSegments
[1].Command
);
200 sal_Int32 nLength
= 16;
201 CPPUNIT_ASSERT_EQUAL(nLength
, aPairs
.getLength());
202 std::pair
<sal_Int32
,sal_Int32
> aCoordinates
[] =
204 std::pair
<sal_Int32
,sal_Int32
>(9084, 0),
205 std::pair
<sal_Int32
,sal_Int32
>(6734, 689),
206 std::pair
<sal_Int32
,sal_Int32
>(4489, 893),
207 std::pair
<sal_Int32
,sal_Int32
>(2633, 893),
208 std::pair
<sal_Int32
,sal_Int32
>(1631, 893),
209 std::pair
<sal_Int32
,sal_Int32
>(733, 830),
210 std::pair
<sal_Int32
,sal_Int32
>(0, 752),
211 std::pair
<sal_Int32
,sal_Int32
>(987, 908),
212 std::pair
<sal_Int32
,sal_Int32
>(2274, 1034),
213 std::pair
<sal_Int32
,sal_Int32
>(3756, 1034),
214 std::pair
<sal_Int32
,sal_Int32
>(5357, 1034),
215 std::pair
<sal_Int32
,sal_Int32
>(7183, 877),
216 std::pair
<sal_Int32
,sal_Int32
>(9084, 423),
217 std::pair
<sal_Int32
,sal_Int32
>(9084, 0),
218 std::pair
<sal_Int32
,sal_Int32
>(9084, 0),
219 std::pair
<sal_Int32
,sal_Int32
>(9084, 0)
222 for( int i
= 0; i
< nLength
; ++i
)
224 CPPUNIT_ASSERT(abs(aCoordinates
[i
].first
- aPairs
[i
].First
.Value
.get
<sal_Int32
>()) < 20);
225 CPPUNIT_ASSERT(abs(aCoordinates
[i
].second
- aPairs
[i
].Second
.Value
.get
<sal_Int32
>()) < 20);
229 DECLARE_OOXMLEXPORT_TEST(testDmlRectangleRelsize
, "dml-rectangle-relsize.docx")
231 // This was around 19560, as we did not read wp14:pctHeight for
232 // drawinglayer shapes and the fallback data was invalid.
233 OString
aMessage("Height is only " + OString::number(getShape(1)->getSize().Height
));
234 CPPUNIT_ASSERT_MESSAGE(aMessage
.getStr(), getShape(1)->getSize().Height
>= 20967);
236 // This was around 0: relative size of 0% was imported as 0, not "fall back to absolute size".
237 CPPUNIT_ASSERT(getShape(2)->getSize().Height
> 300);
240 DECLARE_OOXMLEXPORT_TEST(testDMLTextFrameVertAdjust
, "dml-textframe-vertadjust.docx")
242 // DOCX textboxes with text are imported as text frames but in Writer text frames did not have
243 // TextVerticalAdjust attribute so far.
245 // 1st frame's context is adjusted to the top
246 uno::Reference
<beans::XPropertySet
> xFrame(getShapeByName(u
"Rectangle 1"), uno::UNO_QUERY
);
247 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP
, getProperty
<drawing::TextVerticalAdjust
>(xFrame
, "TextVerticalAdjust"));
248 // 2nd frame's context is adjusted to the center
249 xFrame
.set(getShapeByName(u
"Rectangle 2"), uno::UNO_QUERY
);
250 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_CENTER
, getProperty
<drawing::TextVerticalAdjust
>(xFrame
, "TextVerticalAdjust"));
251 // 3rd frame's context is adjusted to the bottom
252 xFrame
.set(getShapeByName(u
"Rectangle 3"), uno::UNO_QUERY
);
253 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM
, getProperty
<drawing::TextVerticalAdjust
>(xFrame
, "TextVerticalAdjust"));
256 DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillBitmapCrop
, "dml-shape-fillbitmapcrop.docx")
258 // Test the new GraphicCrop property which is introduced to define
259 // cropping of shapes filled with a picture in stretch mode.
261 // 1st shape has some cropping
262 text::GraphicCrop aGraphicCropStruct
= getProperty
<text::GraphicCrop
>(getShape(1), "GraphicCrop");
263 CPPUNIT_ASSERT_EQUAL( sal_Int32( 455 ), aGraphicCropStruct
.Left
);
264 CPPUNIT_ASSERT_EQUAL( sal_Int32( 368 ), aGraphicCropStruct
.Right
);
265 CPPUNIT_ASSERT_EQUAL( sal_Int32( -455 ), aGraphicCropStruct
.Top
);
266 CPPUNIT_ASSERT_EQUAL( sal_Int32( -368 ), aGraphicCropStruct
.Bottom
);
268 // 2nd shape has no cropping
269 aGraphicCropStruct
= getProperty
<text::GraphicCrop
>(getShape(2), "GraphicCrop");
270 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct
.Left
);
271 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct
.Right
);
272 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct
.Top
);
273 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct
.Bottom
);
277 DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillPattern
, "dml-shape-fillpattern.docx")
279 // Hatching was ignored by the export.
281 // 1st shape: light horizontal pattern (ltHorz)
282 drawing::Hatch aHatch
= getProperty
<drawing::Hatch
>(getShape(1), "FillHatch");
283 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aHatch
.Angle
);
284 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
285 CPPUNIT_ASSERT_EQUAL(Color(0x99FF66), Color(ColorTransparency
, aHatch
.Color
));
286 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
288 // 2nd shape: horizontal pattern (horz)
289 aHatch
= getProperty
<drawing::Hatch
>(getShape(2), "FillHatch");
290 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aHatch
.Angle
);
291 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
292 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
294 // 3rd shape: light vertical pattern (ltVert)
295 aHatch
= getProperty
<drawing::Hatch
>(getShape(3), "FillHatch");
296 CPPUNIT_ASSERT_EQUAL(sal_Int32(900), aHatch
.Angle
);
297 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
298 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
300 // 4th shape: vertical pattern (vert)
301 aHatch
= getProperty
<drawing::Hatch
>(getShape(4), "FillHatch");
302 CPPUNIT_ASSERT_EQUAL(sal_Int32(900), aHatch
.Angle
);
303 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
304 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
306 // 5th shape: light upward diagonal pattern (ltUpDiag)
307 aHatch
= getProperty
<drawing::Hatch
>(getShape(5), "FillHatch");
308 CPPUNIT_ASSERT_EQUAL(sal_Int32(450), aHatch
.Angle
);
309 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
310 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
312 // 6th shape: wide upward diagonal pattern (wdUpDiag)
313 aHatch
= getProperty
<drawing::Hatch
>(getShape(6), "FillHatch");
314 CPPUNIT_ASSERT_EQUAL(sal_Int32(450), aHatch
.Angle
);
315 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
316 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
318 // 7th shape: light downward diagonal pattern (ltDnDiag)
319 aHatch
= getProperty
<drawing::Hatch
>(getShape(7), "FillHatch");
320 CPPUNIT_ASSERT_EQUAL(sal_Int32(1350), aHatch
.Angle
);
321 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
322 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
324 // 8th shape: wide downward diagonal pattern (wdDnDiag)
325 aHatch
= getProperty
<drawing::Hatch
>(getShape(8), "FillHatch");
326 CPPUNIT_ASSERT_EQUAL(sal_Int32(1350), aHatch
.Angle
);
327 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
328 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_SINGLE
, aHatch
.Style
);
330 // 9th shape: small grid pattern (smGrid)
331 aHatch
= getProperty
<drawing::Hatch
>(getShape(9), "FillHatch");
332 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aHatch
.Angle
);
333 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
334 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_DOUBLE
, aHatch
.Style
);
336 // 10th shape: large grid pattern (lgGrid)
337 aHatch
= getProperty
<drawing::Hatch
>(getShape(10), "FillHatch");
338 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aHatch
.Angle
);
339 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
340 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_DOUBLE
, aHatch
.Style
);
342 // 11th shape: small checker board pattern (smCheck)
343 aHatch
= getProperty
<drawing::Hatch
>(getShape(11), "FillHatch");
344 CPPUNIT_ASSERT_EQUAL(sal_Int32(450), aHatch
.Angle
);
345 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aHatch
.Distance
);
346 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_DOUBLE
, aHatch
.Style
);
348 // 12th shape: outlined diamond pattern (openDmnd)
349 aHatch
= getProperty
<drawing::Hatch
>(getShape(12), "FillHatch");
350 CPPUNIT_ASSERT_EQUAL(sal_Int32(450), aHatch
.Angle
);
351 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch
.Distance
);
352 CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_DOUBLE
, aHatch
.Style
);
355 DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition
, "dml-groupshape-childposition.docx")
357 // Problem was parent transformation was ignored fully, but translate component
358 // which specify the position must be also applied for children of the group.
360 uno::Reference
<drawing::XShapes
> xGroup(getShape(1), uno::UNO_QUERY
);
361 uno::Reference
<drawing::XShape
> xChildGroup(xGroup
->getByIndex(1), uno::UNO_QUERY
);
362 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2123), xChildGroup
->getPosition().X
);
363 CPPUNIT_ASSERT_EQUAL(sal_Int32(11331), xChildGroup
->getPosition().Y
);
365 xGroup
.set(xChildGroup
, uno::UNO_QUERY
);
366 xChildGroup
.set(xGroup
->getByIndex(0), uno::UNO_QUERY
);
367 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1859), xChildGroup
->getPosition().X
);
368 CPPUNIT_ASSERT_EQUAL(sal_Int32(11331), xChildGroup
->getPosition().Y
);
370 xChildGroup
.set(xGroup
->getByIndex(1), uno::UNO_QUERY
);
371 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2123), xChildGroup
->getPosition().X
);
372 CPPUNIT_ASSERT_EQUAL(sal_Int32(isExported() ? 14023 : 14021), xChildGroup
->getPosition().Y
);
375 CPPUNIT_TEST_FIXTURE(Test
, testDMLGradientFillTheme
)
377 loadAndSave("dml-gradientfill-theme.docx");
378 // Problem was when a fill gradient was imported from a theme, (fillRef in ooxml)
379 // not just the theme was written out but the explicit values too
380 // Besides the duplication of values it causes problems with writing out
381 // <a:schemeClr val="phClr"> into document.xml, while phClr can be used just for theme definitions.
382 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
384 // check no explicit gradFill has been exported
386 "/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",
389 // check shape style has been exported
391 "/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",
394 "/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",
398 DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeParaSpacing
, "dml-groupshape-paraspacing.docx")
400 // Paragraph spacing (top/bottom margin and line spacing) inside a group shape was not imported
401 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
402 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xGroup
->getByIndex(1), uno::UNO_QUERY_THROW
)->getText();
404 // 1st paragraph has 1.5x line spacing but it has no spacing before/after.
405 uno::Reference
<text::XTextRange
> xRun
= getRun(getParagraphOfText(1, xText
),1);
406 style::LineSpacing aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
407 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP
), aLineSpacing
.Mode
);
408 CPPUNIT_ASSERT_EQUAL(sal_Int16(150), aLineSpacing
.Height
);
409 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
410 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
412 // 2nd paragraph has double line spacing but it has no spacing before/after.
413 xRun
.set(getRun(getParagraphOfText(2, xText
),1));
414 aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
415 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP
), aLineSpacing
.Mode
);
416 CPPUNIT_ASSERT_EQUAL(sal_Int16(200), aLineSpacing
.Height
);
417 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
418 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
420 // 3rd paragraph has 24 pt line spacing but it has no spacing before/after.
421 xRun
.set(getRun(getParagraphOfText(3, xText
),1));
422 aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
423 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::MINIMUM
), aLineSpacing
.Mode
);
424 CPPUNIT_ASSERT_EQUAL(sal_Int16(847), aLineSpacing
.Height
);
425 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
426 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
428 // 4th paragraph has 1.75x line spacing but it has no spacing before/after.
429 xRun
.set(getRun(getParagraphOfText(4, xText
),1));
430 aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
431 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP
), aLineSpacing
.Mode
);
432 CPPUNIT_ASSERT_EQUAL(sal_Int16(175), aLineSpacing
.Height
);
433 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
434 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
436 // 5th paragraph has margins which are defined by w:beforeLines and w:afterLines.
437 xRun
.set(getRun(getParagraphOfText(5, xText
),1));
438 aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
439 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP
), aLineSpacing
.Mode
);
440 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aLineSpacing
.Height
);
441 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
442 CPPUNIT_ASSERT_EQUAL(sal_Int32(741), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
444 // 6th paragraph has margins which are defined by w:before and w:after.
445 xRun
.set(getRun(getParagraphOfText(6, xText
),1));
446 aLineSpacing
= getProperty
<style::LineSpacing
>(xRun
, "ParaLineSpacing");
447 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP
), aLineSpacing
.Mode
);
448 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aLineSpacing
.Height
);
449 CPPUNIT_ASSERT_EQUAL(sal_Int32(423), getProperty
<sal_Int32
>(xRun
, "ParaTopMargin"));
450 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty
<sal_Int32
>(xRun
, "ParaBottomMargin"));
453 // 7th paragraph has auto paragraph margins a:afterAutospacing and a:beforeAutospacing, which means margins must be ignored.
454 // xRun.set(getRun(getParagraphOfText(7, xText),1));
455 // CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaTopMargin"));
456 // CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaBottomMargin"));
459 DECLARE_OOXMLEXPORT_TEST(testTableFloatingMargins
, "table-floating-margins.docx")
461 // In case the table had custom left cell margin, the horizontal position was still incorrect (too small, -199).
462 uno::Reference
<beans::XPropertySet
> xFrame(getShape(1), uno::UNO_QUERY
);
463 sal_Int32 nHoriOrientPosition
= getProperty
<sal_Int32
>(xFrame
, "HoriOrientPosition");
464 CPPUNIT_ASSERT(nHoriOrientPosition
< sal_Int32(-495));
465 // These were 0 as well, due to lack of import.
466 CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), getProperty
<sal_Int32
>(xFrame
, "TopMargin"));
467 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), getProperty
<sal_Int32
>(xFrame
, "BottomMargin"));
471 // Paragraph bottom margin wasn't 0 in the A1 cell of the floating table.
472 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
473 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:spacing", "after", "0");
476 CPPUNIT_TEST_FIXTURE(Test
, testTdf127814
)
478 loadAndSave("tdf127814.docx");
479 // Paragraph top margin was 0 in a table started on a new page
480 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
481 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:spacing", "before", "0");
484 CPPUNIT_TEST_FIXTURE(Test
, testTdf128752
)
486 loadAndSave("tdf128752.docx");
487 // Paragraph bottom margin was 200, docDefault instead of table style setting
488 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
489 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr/w:spacing", "after", "0");
492 CPPUNIT_TEST_FIXTURE(Test
, testTdf119054
)
494 loadAndSave("tdf119054.docx");
495 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
496 // Don't overwrite before and after spacing of Heading2 by table style.
497 // Heading2 overrides table style's values from DocDefaults.
498 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr/w:spacing", "before", "0");
499 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr/w:spacing", "after", "360");
500 // Use table style based single line spacing instead of the docDefaults' 254
501 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr/w:spacing", "line", "240");
504 CPPUNIT_TEST_FIXTURE(Test
, testTdf131258
)
506 loadAndSave("tdf131258.docx");
507 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
508 // Use table style based bottom margin instead of the docDefaults in empty tables, too
509 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:spacing", "after", "0");
512 CPPUNIT_TEST_FIXTURE(Test
, testTdf132514
)
514 loadAndSave("tdf132514.docx");
515 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
516 // Keep table style setting, when the footer also contain a table
517 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p[2]/w:pPr/w:spacing", "before", "0");
518 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p[2]/w:pPr/w:spacing", "after", "0");
521 DECLARE_OOXMLEXPORT_TEST(testTdf153891
, "tdf153891.docx")
523 // This document simply crashed the importer.
526 CPPUNIT_TEST_FIXTURE(Test
, testFdo69636
)
528 loadAndSave("fdo69636.docx");
530 * The problem was that the exporter didn't mirror the workaround of the
531 * importer, regarding the btLr text frame direction: the
532 * mso-layout-flow-alt property was completely missing in the output.
534 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
536 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"));
538 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");
541 CPPUNIT_TEST_FIXTURE(Test
, testVMLData
)
543 loadAndSave("TestVMLData.docx");
544 // The problem was exporter was exporting vml data for shape in w:rPr element.
545 // vml data should not come under w:rPr element.
546 xmlDocUniquePtr pXmlDoc
= parseExport("word/header1.xml");
547 CPPUNIT_ASSERT(getXPath(pXmlDoc
, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape", "stroked").match("f"));
550 CPPUNIT_TEST_FIXTURE(Test
, testImageData
)
552 loadAndSave("image_data.docx");
553 // The problem was exporter was exporting v:imagedata data for shape in w:pict as v:fill w element.
555 xmlDocUniquePtr pXmlDoc
= parseExport("word/header1.xml");
556 CPPUNIT_ASSERT(getXPath(pXmlDoc
, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape/v:imagedata", "detectmouseclick").match("t"));
559 CPPUNIT_TEST_FIXTURE(Test
, testFdo70838
)
561 loadAndSave("fdo70838.docx");
562 // The problem was that VMLExport::Commit didn't save the correct width and height,
563 // and ImplEESdrWriter::ImplFlipBoundingBox made a mistake calculating the position
565 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
567 // Check DML document
569 sal_Int32 aXPos
[4], aYPos
[4];
570 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();
571 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();
572 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();
573 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();
575 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();
576 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();
577 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();
578 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();
580 // certain degree of error is tolerated due to rounding in unit conversions
581 CPPUNIT_ASSERT(abs(1239520 - aXPos
[0]) < 1000);
582 CPPUNIT_ASSERT(abs(1239520 - aXPos
[1]) < 1000);
583 CPPUNIT_ASSERT(abs(1238250 - aXPos
[2]) < 1000);
584 CPPUNIT_ASSERT(abs(1238885 - aXPos
[3]) < 1000);
586 CPPUNIT_ASSERT(abs(2095500 - aYPos
[0]) < 1000);
587 CPPUNIT_ASSERT(abs(2094865 - aYPos
[1]) < 1000);
588 CPPUNIT_ASSERT(abs(2094230 - aYPos
[2]) < 1000);
589 CPPUNIT_ASSERT(abs(2094865 - aYPos
[3]) < 1000);
591 sal_Int32 aHSize
[4], aVSize
[4];
592 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();
593 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();
594 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();
595 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();
597 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();
598 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();
599 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();
600 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();
602 // certain degree of error is tolerated due to rounding in unit conversions
603 CPPUNIT_ASSERT(abs(3599280 - aHSize
[0]) < 1000);
604 CPPUNIT_ASSERT(abs(3599280 - aHSize
[1]) < 1000);
605 CPPUNIT_ASSERT(abs(3599280 - aHSize
[2]) < 1000);
606 CPPUNIT_ASSERT(abs(3599280 - aHSize
[3]) < 1000);
608 CPPUNIT_ASSERT(abs(1799640 - aVSize
[0]) < 1000);
609 CPPUNIT_ASSERT(abs(1799640 - aVSize
[1]) < 1000);
610 CPPUNIT_ASSERT(abs(1799640 - aVSize
[2]) < 1000);
611 CPPUNIT_ASSERT(abs(1799640 - aVSize
[3]) < 1000);
613 // Check VML document
615 // get styles of the four shapes
617 aStyles
[0] = getXPath( pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:rect", "style");
618 // original is: "position:absolute;margin-left:97.6pt;margin-top:165pt;width:283.4pt;height:141.7pt;rotation:285"
619 aStyles
[1] = getXPath( pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Fallback/w:pict/v:rect", "style");
620 // original is: "position:absolute;margin-left:97.6pt;margin-top:164.95pt;width:283.4pt;height:141.7pt;rotation:255"
621 aStyles
[2] = getXPath( pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Fallback/w:pict/v:rect", "style");
622 // original is: "position:absolute;margin-left:97.5pt;margin-top:164.9pt;width:283.4pt;height:141.7pt;rotation:105"
623 aStyles
[3] = getXPath( pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[4]/mc:Fallback/w:pict/v:rect", "style");
624 // original is: "position:absolute;margin-left:97.55pt;margin-top:164.95pt;width:283.4pt;height:141.7pt;rotation:75"
626 //check the size and position of each of the shapes
627 for( int i
= 0; i
< 4; ++i
)
629 CPPUNIT_ASSERT(!aStyles
[i
].isEmpty());
631 sal_Int32 nextTokenPos
= 0;
634 OUString aStyleCommand
= aStyles
[i
].getToken( 0, ';', nextTokenPos
);
635 CPPUNIT_ASSERT(!aStyleCommand
.isEmpty());
637 OUString aStyleCommandName
= aStyleCommand
.getToken( 0, ':' );
638 OUString aStyleCommandValue
= aStyleCommand
.getToken( 1, ':' );
640 if( aStyleCommandName
== "margin-left" )
642 float fValue
= aStyleCommandValue
.getToken( 0, 'p' ).toFloat();
643 CPPUNIT_ASSERT_DOUBLES_EQUAL(97.6, fValue
, 0.1);
645 else if( aStyleCommandName
== "margin-top" )
647 float fValue
= aStyleCommandValue
.getToken( 0, 'p' ).toFloat();
648 CPPUNIT_ASSERT_DOUBLES_EQUAL(165.0, fValue
, 0.2);
650 else if( aStyleCommandName
== "width" )
652 float fValue
= aStyleCommandValue
.getToken( 0, 'p' ).toFloat();
653 CPPUNIT_ASSERT_DOUBLES_EQUAL(283.4, fValue
, 0.1);
655 else if( aStyleCommandName
== "height" )
657 float fValue
= aStyleCommandValue
.getToken( 0, 'p' ).toFloat();
658 CPPUNIT_ASSERT_DOUBLES_EQUAL(141.7, fValue
, 0.1);
661 } while( nextTokenPos
!= -1 );
664 // Check shape objects
667 aPos
[0] = getShape(1)->getPosition();
668 aPos
[1] = getShape(2)->getPosition();
669 aPos
[2] = getShape(3)->getPosition();
670 aPos
[3] = getShape(4)->getPosition();
672 // certain degree of error is tolerated due to rounding in unit conversions
673 CPPUNIT_ASSERT(abs(4734 - aPos
[0].X
) < 10);
674 CPPUNIT_ASSERT(abs(4734 - aPos
[1].X
) < 10);
675 CPPUNIT_ASSERT(abs(4731 - aPos
[2].X
) < 10);
676 CPPUNIT_ASSERT(abs(4733 - aPos
[3].X
) < 10);
678 CPPUNIT_ASSERT(abs(2845 - aPos
[0].Y
) < 10);
679 CPPUNIT_ASSERT(abs(2843 - aPos
[1].Y
) < 10);
680 CPPUNIT_ASSERT(abs(2842 - aPos
[2].Y
) < 10);
681 CPPUNIT_ASSERT(abs(2843 - aPos
[3].Y
) < 10);
684 CPPUNIT_TEST_FIXTURE(Test
, testFdo73215
)
686 loadAndSave("fdo73215.docx");
687 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
688 // 'rect' was 'pictureFrame', which isn't valid.
689 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",
691 // 'adj1' was 'adj', which is not valid for bentConnector3.
692 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",
696 CPPUNIT_TEST_FIXTURE(Test
, testBehinddoc
)
698 loadAndSave("behinddoc.docx");
699 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
700 // This was "0", shape was in the foreground.
701 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor", "behindDoc", "1");
704 CPPUNIT_TEST_FIXTURE(Test
, testSmartArtAnchoredInline
)
706 loadAndSave("fdo73227.docx");
707 /* Given file contains 3 DrawingML objects as 1Picture,1SmartArt and 1Shape.
708 * Check for SmartArt.
709 * SmartArt should get written as "Floating Object" i.e. inside <wp:anchor> tag.
710 * Also check for value of attribute "id" of <wp:docPr>. It should be unique for
711 * all 3 DrawingML objects in a document.
714 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
715 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:drawing[2]/wp:anchor/wp:docPr","id","2");
716 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:drawing[2]/wp:anchor/wp:docPr","name","Diagram2");
718 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr","id","3");
719 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");
721 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:drawing[1]/wp:anchor/wp:docPr","id","1");
722 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:drawing[1]/wp:anchor/wp:docPr","name","Picture 1");
725 CPPUNIT_TEST_FIXTURE(Test
, testFdo65833
)
727 loadAndSave("fdo65833.docx");
728 // The "editas" attribute for vml group shape was not preserved.
729 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
730 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:group", "editas", "canvas");
733 CPPUNIT_TEST_FIXTURE(Test
, testFdo73247
)
735 loadAndSave("fdo73247.docx");
736 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
738 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",
742 CPPUNIT_TEST_FIXTURE(Test
, testFdo70942
)
744 loadAndSave("fdo70942.docx");
745 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
746 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",
750 CPPUNIT_TEST_FIXTURE(Test
, testDrawinglayerPicPos
)
752 loadAndSave("drawinglayer-pic-pos.docx");
753 // The problem was that the position of the picture was incorrect, it was shifted towards the bottom right corner.
754 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
756 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");
758 assertXPath(pXmlDocument
, aXPath
, "x", "0");
760 assertXPath(pXmlDocument
, aXPath
, "y", "0");
763 CPPUNIT_TEST_FIXTURE(Test
, testShapeThemePreservation
)
765 loadAndSave("shape-theme-preservation.docx");
766 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
768 // check shape style has been preserved
769 assertXPath(pXmlDocument
,
770 "/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",
772 assertXPath(pXmlDocument
,
773 "/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",
775 assertXPath(pXmlDocument
,
776 "/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",
778 assertXPath(pXmlDocument
,
779 "/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",
781 assertXPath(pXmlDocument
,
782 "/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",
784 assertXPath(pXmlDocument
,
785 "/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",
787 assertXPath(pXmlDocument
,
788 "/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",
790 assertXPath(pXmlDocument
,
791 "/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",
793 assertXPath(pXmlDocument
,
794 "/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",
796 assertXPath(pXmlDocument
,
797 "/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",
799 assertXPath(pXmlDocument
,
800 "/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",
803 // check shape style hasn't been overwritten
804 assertXPath(pXmlDocument
,
805 "/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",
807 assertXPath(pXmlDocument
,
808 "/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",
811 // check direct theme assignments have been preserved
812 assertXPath(pXmlDocument
,
813 "/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",
815 // check whether theme color has been converted into native color
816 assertXPath(pXmlDocument
,
817 "/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:srgbClr",
820 // check color transformations applied to theme colors have been preserved
821 assertXPath(pXmlDocument
,
822 "/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",
824 assertXPath(pXmlDocument
,
825 "/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",
827 assertXPath(pXmlDocument
,
828 "/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:srgbClr/a:lumMod",
831 // check direct color assignments have been preserved
832 OUString sFillColor
= getXPath(pXmlDocument
,
833 "/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",
835 CPPUNIT_ASSERT_EQUAL(Color(0x00b050), Color(ColorTransparency
, sFillColor
.toInt32(16)));
836 sal_Int32 nLineColor
= getXPath(pXmlDocument
,
837 "/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",
839 CPPUNIT_ASSERT_EQUAL(Color(0xff0000), Color(ColorTransparency
, nLineColor
));
841 // check direct line type assignments have been preserved
842 sal_Int32 nLineWidth
= getXPath(pXmlDocument
,
843 "/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",
845 CPPUNIT_ASSERT(abs(63500 - nLineWidth
) < 1000); //some rounding errors in the conversion ooxml -> libo -> ooxml are tolerated
846 assertXPath(pXmlDocument
,
847 "/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",
849 assertXPath(pXmlDocument
,
850 "/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:prstDash",
853 uno::Reference
<drawing::XShape
> xShape1
= getShape(1);
854 uno::Reference
<drawing::XShape
> xShape2
= getShape(2);
855 uno::Reference
<drawing::XShape
> xShape3
= getShape(3);
857 // check colors are properly applied to shapes on import
858 CPPUNIT_ASSERT_EQUAL(Color(0x4f81bd), getProperty
<Color
>(xShape1
, "FillColor"));
859 CPPUNIT_ASSERT_EQUAL(Color(0xfcd5b5), getProperty
<Color
>(xShape2
, "FillColor"));
860 CPPUNIT_ASSERT_EQUAL(Color(0x00b050), getProperty
<Color
>(xShape3
, "FillColor"));
861 CPPUNIT_ASSERT_EQUAL(Color(0x3a5f8b), getProperty
<Color
>(xShape1
, "LineColor"));
862 CPPUNIT_ASSERT_EQUAL(Color(0x4f6228), getProperty
<Color
>(xShape2
, "LineColor"));
863 CPPUNIT_ASSERT_EQUAL(Color(0xff0000), getProperty
<Color
>(xShape3
, "LineColor"));
865 // check line properties are properly applied to shapes on import
866 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, getProperty
<drawing::LineStyle
>(xShape1
, "LineStyle"));
867 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, getProperty
<drawing::LineStyle
>(xShape2
, "LineStyle"));
868 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_DASH
, getProperty
<drawing::LineStyle
>(xShape3
, "LineStyle"));
869 CPPUNIT_ASSERT_EQUAL(drawing::LineJoint_ROUND
, getProperty
<drawing::LineJoint
>(xShape1
, "LineJoint"));
870 CPPUNIT_ASSERT_EQUAL(drawing::LineJoint_ROUND
, getProperty
<drawing::LineJoint
>(xShape2
, "LineJoint"));
871 CPPUNIT_ASSERT_EQUAL(drawing::LineJoint_MITER
, getProperty
<drawing::LineJoint
>(xShape3
, "LineJoint"));
874 CPPUNIT_TEST_FIXTURE(Test
, testFDO73546
)
876 loadAndSave("FDO73546.docx");
877 xmlDocUniquePtr pXmlDoc
= parseExport("word/header2.xml");
878 assertXPath(pXmlDoc
, "/w:hdr/w:p[1]/w:r[3]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor", "distL","0");
881 CPPUNIT_TEST_FIXTURE(Test
, testFdo69616
)
883 loadAndSave("fdo69616.docx");
884 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
886 // FIXME: VML needs correction, because DrawingML WPG shapes from now imported as
887 // shape+textframe pairs. VML implementation still missing.
888 // 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"));
891 CPPUNIT_TEST_FIXTURE(Test
, testAlignForShape
)
893 loadAndReload("Shape.docx");
894 //fdo73545:Shape Horizontal and vertical orientation is wrong
895 //The wp:align tag is missing after roundtrip
896 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
897 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/"
898 "wp:anchor/wp:positionH/wp:align");
901 CPPUNIT_TEST_FIXTURE(Test
, testLineStyle_DashType
)
903 loadAndSave("LineStyle_DashType.docx");
904 /* DOCX containing Shape with LineStyle as Dash Type should get preserved inside
905 * an XML tag <a:prstDash> with value "dash", "sysDot", "lgDot", etc.
907 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
909 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "lgDashDotDot");
910 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[6]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "lgDashDot");
911 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[5]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "lgDash");
912 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "dashDot");
913 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "dash");
914 assertXPath(pXmlDoc
, "/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:ln/a:prstDash", "val", "sysDash");
915 assertXPath(pXmlDoc
, "/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:ln/a:prstDash", "val", "sysDot");
918 CPPUNIT_TEST_FIXTURE(Test
, testGradientFillPreservation
)
920 loadAndSave("gradient-fill-preservation.docx");
921 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
923 // check rgb colors for every step in the gradient of the first shape
924 assertXPath(pXmlDocument
,
925 "/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",
927 assertXPath(pXmlDocument
,
928 "/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",
930 assertXPath(pXmlDocument
,
931 "/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",
934 // check theme colors for every step in the gradient of the second shape
935 assertXPath(pXmlDocument
,
936 "/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",
938 assertXPath(pXmlDocument
,
939 "/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",
941 assertXPath(pXmlDocument
,
942 "/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",
945 assertXPath(pXmlDocument
,
946 "/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",
948 assertXPath(pXmlDocument
,
949 "/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",
951 assertXPath(pXmlDocument
,
952 "/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",
956 CPPUNIT_TEST_FIXTURE(Test
, testLineStyle_DashType_VML
)
958 loadAndSave("LineStyle_DashType_VML.docx");
959 /* DOCX containing "Shape with text inside" having Line Style as "Dash Type" should get
960 * preserved inside an XML tag <v:stroke> with attribute dashstyle having value "dash".
962 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
963 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r[1]/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:stroke", "dashstyle", "dash");
966 CPPUNIT_TEST_FIXTURE(Test
, testFdo74110
)
968 loadAndReload("fdo74110.docx");
970 The File contains word art which is being exported as shape and the mapping is defaulted to
971 shape type rect since the actual shape type(s) is/are commented out for some reason.
972 The actual shape type(s) has/have adjustment value(s) where as rect does not have adjustment value.
973 Hence the following test case.
975 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
976 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]",
978 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);
981 CPPUNIT_TEST_FIXTURE(Test
, testOuterShdw
)
983 loadAndReload("testOuterShdw.docx");
984 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
985 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", "1041400");
988 CPPUNIT_TEST_FIXTURE(Test
, testExtentValue
)
990 loadAndSave("fdo74605.docx");
991 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
992 sal_Int32 nX
= getXPath(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").toInt32();
993 // This was negative.
994 CPPUNIT_ASSERT(nX
>= 0);
996 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 2, getPages() );
999 // part of tdf#93676, word gives the frame in the exported .docx a huge height,
1000 // because it's exported with 255% height percentage from a 255 HeightPercent
1001 // settings, but 255 is a special flag that the value is synced to the
1003 CPPUNIT_TEST_FIXTURE(Test
, testSyncedRelativePercent
)
1005 loadAndSave("tdf93676-1.odt");
1006 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1007 CPPUNIT_ASSERT_EQUAL(1, getPages());
1008 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1010 // check no explicit pctHeight has been exported, all we care
1011 // about at this point is that it's not 255000
1012 assertXPath(pXmlDoc
, "//wp14:pctHeight", 0);
1015 DECLARE_OOXMLEXPORT_TEST(testTdf107119
, "tdf107119.docx")
1017 uno::Reference
<beans::XPropertySet
> XPropsWrap(getShape(1), uno::UNO_QUERY
);
1018 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_PARALLEL
, getProperty
<text::WrapTextMode
>(XPropsWrap
, "Surround"));
1021 CPPUNIT_TEST_FIXTURE(Test
, testTdf133457
)
1023 loadAndSave("tdf133457.docx");
1024 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
1026 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[3]/w:pPr/w:framePr", "vAnchor", "text");
1029 CPPUNIT_TEST_FIXTURE(Test
, testTdf133924
)
1031 loadAndSave("tdf133924.docx");
1032 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
1034 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:pPr/w:framePr", "wrap", "around");
1035 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:pPr/w:framePr", "wrap", "notBeside");
1038 DECLARE_OOXMLEXPORT_TEST(testRelativeAlignmentFromTopMargin
,
1039 "tdf133045_TestShapeAlignmentRelativeFromTopMargin.docx")
1041 // tdf#133045 These shapes are relatively aligned from top margin, vertically to
1042 // top, center and bottom.
1047 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
1048 assertXPath(pXmlDoc
, "//anchored/SwAnchoredDrawObject[1]/bounds", "top", "1502"); // center
1049 assertXPath(pXmlDoc
, "//anchored/SwAnchoredDrawObject[2]/bounds", "top", "2683"); // bottom
1050 assertXPath(pXmlDoc
, "//anchored/SwAnchoredDrawObject[3]/bounds", "top", "313"); // top
1053 CPPUNIT_PLUGIN_IMPLEMENT();
1055 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */