Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / extras / ooxmlexport / ooxmlexport7.cxx
blobd1a4378b1b717a1bac6ba049fa4ce232d98ec48b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <swmodeltestbase.hxx>
12 #include <com/sun/star/drawing/Hatch.hpp>
13 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
14 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
15 #include <com/sun/star/text/XTextTable.hpp>
17 #include <config_fonts.h>
18 #include <comphelper/sequenceashashmap.hxx>
19 #include <comphelper/processfactory.hxx>
21 #include <unotxdoc.hxx>
22 #include <docsh.hxx>
24 class Test : public SwModelTestBase
26 public:
27 Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
29 protected:
30 // We import OOXML's EMUs into integral mm100 internal representation, then export back into
31 // EMUs. This results in inaccuracies.
32 void assertXPathHasApproxEMU(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath,
33 const OString& rAttribute, sal_Int64 nAttributeVal)
35 OUString val = getXPath(pXmlDoc, rXPath, rAttribute);
36 // Use precision of 1/2 of 100th of mm, which is 180 EMU
37 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
38 OString("XPath: " + rXPath + "\nAttribute: " + rAttribute).getStr(), nAttributeVal,
39 val.toInt64(), 180);
43 CPPUNIT_TEST_FIXTURE(Test, testChildNodesOfCubicBezierTo)
45 loadAndSave("FDO74774.docx");
46 /* Number of children required by cubicBexTo is 3 of type "pt".
47 While exporting, sometimes the child nodes are less than 3.
48 The test case ensures that there are 3 child nodes of type "pt"
49 for cubicBexTo
51 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
53 assertXPath( pXmlDoc,
54 "/w:document/w:body/w:p[2]/w:r[1]/mc:AlternateContent[1]/mc:Choice/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wpg:wgp[1]/wps:wsp[3]/wps:spPr[1]/a:custGeom[1]/a:pathLst[1]/a:path[1]/a:cubicBezTo[2]/a:pt[3]");
57 CPPUNIT_TEST_FIXTURE(Test, testMSwordHang)
59 loadAndSave("test_msword_hang.docx");
60 // fdo#74771:
61 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
62 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:txbx/w:txbxContent/w:p/w:r[2]/w:drawing/wp:inline", "distT", "0");
65 DECLARE_OOXMLEXPORT_TEST(testGroupshapeThemeFont, "groupshape-theme-font.docx")
67 // Font was specified using a theme reference, which wasn't handled.
68 uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
69 uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY_THROW)->getText();
70 uno::Reference<text::XTextRange> xRun = getRun(getParagraphOfText(1, xText),1);
71 // This was Calibri.
72 CPPUNIT_ASSERT_EQUAL(OUString("Cambria"), getProperty<OUString>(xRun, "CharFontName"));
75 CPPUNIT_TEST_FIXTURE(Test, testAnchorIdForWP14AndW14)
77 loadAndSave("AnchorId.docx");
78 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
80 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[3]/mc:AlternateContent/mc:Choice/w:drawing/wp:inline", "anchorId", "78735EFD");
81 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "anchorId", "78735EFD");
84 DECLARE_OOXMLEXPORT_TEST(testDkVert, "dkvert.docx")
86 // <a:pattFill prst="dkVert"> was exported as ltVert.
87 uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
88 uno::Reference<beans::XPropertySet> xShape(xGroup->getByIndex(0), uno::UNO_QUERY);
89 // This was 50.
90 CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty<drawing::Hatch>(xShape, "FillHatch").Distance);
93 CPPUNIT_TEST_FIXTURE(Test, testTextWatermark)
95 loadAndSave("textWatermark.docx");
96 //The problem was that the watermark ID was not preserved,
97 //and Word uses the object ID to identify if it is a watermark.
98 //It has to have the 'PowerPlusWaterMarkObject' string in it
99 xmlDocUniquePtr pXmlHeader2 = parseExport("word/header2.xml");
101 assertXPath(pXmlHeader2, "/w:hdr[1]/w:p[1]/w:r[1]/w:pict[1]/v:shape[1]","id","PowerPlusWaterMarkObject93701316");
103 //The second problem was that Word uses also "o:spid"
104 const OUString& sSpid = getXPath(pXmlHeader2, "/w:hdr[1]/w:p[1]/w:r[1]/w:pict[1]/v:shape[1]","spid");
105 CPPUNIT_ASSERT(!sSpid.isEmpty());
108 CPPUNIT_TEST_FIXTURE(Test, testPictureWatermark)
110 loadAndSave("pictureWatermark.docx");
111 //The problem was that the watermark ID was not preserved,
112 //and Word uses the object ID to identify if it is a watermark.
113 //It has to have the 'WordPictureWaterMarkObject' string in it
115 xmlDocUniquePtr pXmlHeader2 = parseExport("word/header2.xml");
117 // Check the watermark ID
118 assertXPath(pXmlHeader2, "/w:hdr[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Fallback[1]/w:pict[1]/v:shape[1]","id","WordPictureWatermark11962361");
122 CPPUNIT_TEST_FIXTURE(Test, testFdo76249)
124 loadAndSave("fdo76249.docx");
126 * The Locked Canvas is imported correctly, but while exporting
127 * the drawing element is exported inside a textbox. However the drawing has to exported
128 * as a Locked Canvas inside a text-box for the RT file to work in MS Word, as drawing elements
129 * are not allowed inside the textboxes.
131 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
132 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Fallback[1]/w:pict[1]/v:rect[1]/v:textbox[1]/w:txbxContent[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/lc:lockedCanvas[1]",1);
135 CPPUNIT_TEST_FIXTURE(Test, testFdo76979)
137 loadAndSave("fdo76979.docx");
138 // The problem was that black was exported as "auto" fill color, resulting in well-formed, but invalid XML.
139 xmlDocUniquePtr pXmlDoc = parseExport("word/header2.xml");
140 // This was "auto", not "FFFFFF".
141 assertXPath(pXmlDoc, "//wps:spPr/a:solidFill/a:srgbClr", "val", "FFFFFF");
144 CPPUNIT_TEST_FIXTURE(Test, testTdf104539)
146 loadAndSave("tdf104539.odt");
147 CPPUNIT_ASSERT_EQUAL(1, getShapes());
148 CPPUNIT_ASSERT_EQUAL(1, getPages());
149 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
150 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
151 "wp:inline/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
152 "dir", "13500000");
155 DECLARE_OOXMLEXPORT_TEST(testTdf57155, "tdf57155.docx")
157 CPPUNIT_ASSERT_EQUAL(2, getPages());
158 // Without the fix in place, the image in the header of page 2 wouldn't exist
159 CPPUNIT_ASSERT_EQUAL(4, getShapes());
162 DECLARE_OOXMLEXPORT_TEST(testTdf129582, "tdf129582.docx")
164 CPPUNIT_ASSERT_EQUAL(2, getPages());
165 // Without the fix in place, the image in the footer of page 2 wouldn't exist
166 CPPUNIT_ASSERT_EQUAL(2, getShapes());
169 CPPUNIT_TEST_FIXTURE(Test, testShapeEffectPreservation)
171 loadAndSave("shape-effect-preservation.docx");
172 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
174 // first shape with outer shadow, rgb color
175 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
176 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
177 "algn", "tl");
178 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
179 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
180 "blurRad", "50760"); // because convertEMUtoHmm rounds fractions into nearest integer 50800 will be 50760
181 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
182 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
183 "dir", "2700000");
184 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
185 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
186 "dist", "37674");
187 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
188 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
189 "rotWithShape", "0");
190 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
191 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw/a:srgbClr",
192 "val", "000000");
193 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
194 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw/a:srgbClr/a:alpha",
195 "val", "40000");
197 // second shape with outer shadow, scheme color
198 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
199 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
200 "algn", "tl");
201 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
202 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
203 "blurRad", "114480"); // because convertEMUtoHmm rounds fractions into nearest integer 114300 will be 114480
204 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
205 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
206 "dir", "2700000");
207 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
208 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
209 "dist", "203137");
210 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
211 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
212 "rotWithShape", "0");
213 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
214 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw/a:schemeClr",
215 "val", "accent1");
216 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
217 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw/a:schemeClr/a:lumMod",
218 "val", "40000");
219 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
220 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw/a:schemeClr/a:lumOff",
221 "val", "60000");
222 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
223 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw/a:schemeClr/a:alpha",
224 "val", "40000");
226 // third shape with inner shadow, rgb color
227 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
228 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw",
229 "blurRad", "63500");
230 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
231 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw",
232 "dir", "16200000");
233 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
234 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw",
235 "dist", "50800");
236 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
237 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw/a:srgbClr",
238 "val", "ffff00");
239 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
240 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw/a:srgbClr/a:alpha",
241 "val", "50000");
243 // 4th shape with soft edge
244 assertXPathHasApproxEMU(
245 pXmlDoc,
246 "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
247 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:softEdge",
248 "rad", 127000); // actually, it returns 127080
249 assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
250 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:softEdge/*",
251 0 ); // should not be present
253 // 5th shape with glow effect, scheme color
254 assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
255 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:glow/a:srgbClr",
256 "val", "eb2722");
258 // 6th shape with reflection
259 assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
260 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:reflection",
261 "blurRad", "6350");
262 assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
263 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:reflection",
264 "stA", "50000");
265 assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
266 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:reflection",
267 "endA", "300");
268 assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
269 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:reflection",
270 "endPos", "55500");
271 assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
272 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:reflection/*",
273 0 ); // should not be present
275 // 7th shape with several effects: glow, inner shadow and reflection
276 assertXPathHasApproxEMU(pXmlDoc,
277 "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
278 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:glow",
279 "rad", 63500); // actually, it returns 63360
280 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
281 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:glow/a:srgbClr",
282 "val", "eb2722");
283 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
284 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw",
285 "blurRad", "63500");
286 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
287 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw",
288 "dir", "2700000");
289 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
290 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw/a:srgbClr",
291 "val", "000000");
292 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
293 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw/a:srgbClr/a:alpha",
294 "val", "50000");
295 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
296 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:reflection",
297 "blurRad", "6350");
298 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
299 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:reflection",
300 "stA", "52000");
304 CPPUNIT_TEST_FIXTURE(Test, testShape3DEffectPreservation)
306 loadAndSave("shape-3d-effect-preservation.docx");
307 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
309 // first shape: extrusion and shift on z, rotated camera with zoom, rotated light rig
310 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
311 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:camera",
312 "prst", "perspectiveRelaxedModerately");
313 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
314 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:camera",
315 "zoom", "150000");
316 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
317 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:camera/a:rot",
318 "lat", "19490639");
319 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
320 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:camera/a:rot",
321 "lon", "0");
322 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
323 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:camera/a:rot",
324 "rev", "12900001");
326 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
327 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:lightRig",
328 "rig", "threePt");
329 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
330 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:lightRig",
331 "dir", "t");
332 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
333 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:lightRig/a:rot",
334 "lat", "0");
335 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
336 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:lightRig/a:rot",
337 "lon", "0");
338 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
339 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:lightRig/a:rot",
340 "rev", "4800000");
342 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
343 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d",
344 "extrusionH", "63500");
345 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
346 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d",
347 "z", "488950");
349 // second shape: extrusion with theme color, no camera or light rotation, metal material
350 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
351 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:camera",
352 "prst", "isometricLeftDown");
353 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
354 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:camera/a:rot",
356 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
357 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:lightRig",
358 "rig", "threePt");
359 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
360 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:lightRig",
361 "dir", "t");
362 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
363 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:scene3d/a:lightRig/a:rot",
366 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
367 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d",
368 "extrusionH", "25400");
369 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
370 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d",
371 "prstMaterial", "metal");
372 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
373 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d/a:extrusionClr/a:schemeClr",
374 "val", "accent5");
375 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
376 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d/a:extrusionClr/a:schemeClr/a:lumMod",
377 "val", "40000");
378 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
379 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d/a:extrusionClr/a:schemeClr/a:lumOff",
380 "val", "60000");
382 // third shape: colored contour and top and bottom bevel, plastic material
383 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
384 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d",
385 "contourW", "50800");
386 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
387 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d",
388 "prstMaterial", "plastic");
389 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
390 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d/a:bevelT",
391 "w", "139700");
392 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
393 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d/a:bevelT",
394 "h", "88900");
395 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
396 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d/a:bevelT",
397 "prst", "cross");
398 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
399 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d/a:bevelB",
400 "h", "88900");
401 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
402 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d/a:bevelB",
403 "prst", "relaxedInset");
404 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
405 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d/a:contourClr/a:srgbClr",
406 "val", "3333ff");
408 // fourth shape: wireframe
409 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
410 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:sp3d",
411 "prstMaterial", "legacyWireframe");
414 CPPUNIT_TEST_FIXTURE(Test, testPictureEffectPreservation)
416 loadAndSave("picture-effects-preservation.docx");
417 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
419 // first picture: glow effect with theme color and transformations, 3d rotation and extrusion
420 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
421 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:glow",
422 "rad", "228600");
423 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
424 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:glow/a:srgbClr",
425 "val", "267de6");
426 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
427 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:glow/a:srgbClr/a:alpha",
428 "val", "40000");
431 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
432 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:scene3d/a:camera",
433 "prst", "isometricRightUp");
434 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
435 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:scene3d/a:lightRig",
436 "rig", "threePt");
437 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
438 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:sp3d",
439 "extrusionH", "76200");
440 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
441 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:sp3d/a:extrusionClr/a:srgbClr",
442 "val", "92d050");
444 // second picture: shadow and reflection effects
445 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
446 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:outerShdw",
447 "dir", "8100000");
448 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
449 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:outerShdw/a:srgbClr",
450 "val", "000000");
451 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
452 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:outerShdw/a:srgbClr/a:alpha",
453 "val", "40000");
454 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
455 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:reflection",
456 "dir", "5400000");
457 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
458 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:reflection/*",
459 0 ); // should not be present
461 // third picture: soft edge effect
462 assertXPathHasApproxEMU(
463 pXmlDoc,
464 "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
465 "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:softEdge",
466 "rad", 63500); // actually, it returns 63360
469 CPPUNIT_TEST_FIXTURE(Test, testPictureArtisticEffectPreservation)
471 loadAndSave("picture-artistic-effects-preservation.docx");
472 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
473 xmlDocUniquePtr pRelsDoc = parseExport("word/_rels/document.xml.rels");
475 uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(
476 comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL());
478 // 1st picture: marker effect
479 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
480 "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/"
481 "a14:artisticMarker",
482 "trans", "14000");
483 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
484 "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/"
485 "a14:artisticMarker",
486 "size", "80");
488 OUString sEmbedId1 = getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
489 "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer",
490 "embed");
491 OUString sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId1 + "']";
492 OUString sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target");
493 CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile)));
495 // 2nd picture: pencil grayscale
496 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
497 "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/"
498 "a14:artisticPencilGrayscale",
499 "trans", "15000");
500 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
501 "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/"
502 "a14:artisticPencilGrayscale",
503 "pencilSize", "66");
505 OUString sEmbedId2 = getXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
506 "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer",
507 "embed");
508 CPPUNIT_ASSERT_EQUAL(sEmbedId1, sEmbedId2);
510 // 3rd picture: pencil sketch
511 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
512 "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/"
513 "a14:artisticPencilSketch",
514 "trans", "7000");
515 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
516 "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/"
517 "a14:artisticPencilSketch",
518 "pressure", "17");
520 OUString sEmbedId3 = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
521 "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer",
522 "embed");
523 CPPUNIT_ASSERT_EQUAL(sEmbedId1, sEmbedId3);
525 // 4th picture: light screen
526 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
527 "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/"
528 "a14:artisticLightScreen",
529 "trans", "13000");
530 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
531 "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/"
532 "a14:artisticLightScreen",
533 "gridSize", "1");
535 OUString sEmbedId4 = getXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
536 "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer",
537 "embed");
538 sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId4 + "']";
539 sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target");
540 CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile)));
542 // 5th picture: watercolor sponge
543 assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
544 "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/"
545 "a14:artisticWatercolorSponge",
546 "brushSize", "4");
548 OUString sEmbedId5 = getXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
549 "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer",
550 "embed");
551 CPPUNIT_ASSERT_EQUAL(sEmbedId1, sEmbedId5);
553 // 6th picture: photocopy (no attributes)
554 assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
555 "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/"
556 "a14:artisticPhotocopy", 1);
558 OUString sEmbedId6 = getXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
559 "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer",
560 "embed");
561 CPPUNIT_ASSERT_EQUAL(sEmbedId1, sEmbedId6);
563 // no redundant wdp files saved
564 CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess->hasByName("word/media/hdphoto3.wdp")));
567 CPPUNIT_TEST_FIXTURE(Test, fdo77719)
569 loadAndSave("fdo77719.docx");
570 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
571 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/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:custGeom[1]", 1);
574 CPPUNIT_TEST_FIXTURE(Test, testNestedAlternateContent)
576 loadAndSave("nestedAlternateContent.docx");
577 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
578 // We check alternateContent could not contains alternateContent (i.e. nested alternateContent)
579 assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wpg:wgp[1]/wps:wsp[2]/wps:txbx[1]/w:txbxContent[1]/w:p[1]/w:r[2]/mc:AlternateContent[1]",0);
582 #if 0
583 // Currently LibreOffice exports custom geometry for this hexagon, not preset shape.
584 // When LibreOffice can export preset shapes with correct modifiers, then this test can be re-enabled.
586 CPPUNIT_TEST_FIXTURE(Test, test76317)
588 loadAndSave("test76317.docx");
589 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
590 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/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:prstGeom[1]", "prst", "hexagon");
593 #endif
595 CPPUNIT_TEST_FIXTURE(Test, fdo76591)
597 loadAndSave("fdo76591.docx");
598 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
599 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[3]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]", "relativeHeight", "3");
602 CPPUNIT_TEST_FIXTURE(Test, test76317_2K10)
604 loadAndSave("test76317_2K10.docx");
605 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
606 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/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:prstGeom[1]/a:avLst[1]/a:gd[1]", "name", "adj");
609 CPPUNIT_TEST_FIXTURE(Test, testFDO77122)
611 loadAndSave("LinkedTextBoxes.docx");
612 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
613 //ensure that the text box links are preserved.
614 assertXPath(pXmlDoc, "//wps:txbx[1]", "id", "1");
615 assertXPath(pXmlDoc, "//wps:linkedTxbx[1]", "id", "1");
618 CPPUNIT_TEST_FIXTURE(Test, test76734_2K7)
620 loadAndSave("test76734_2K7.docx");
621 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
622 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[3]/mc:AlternateContent[1]/mc:Choice[1]", "Requires", "wps");
625 CPPUNIT_TEST_FIXTURE(Test, test77219)
627 loadAndSave("test77219.docx");
628 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
629 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[6]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]", "behindDoc", "1");
632 DECLARE_OOXMLEXPORT_TEST(testTdf77219_backgroundShape, "tdf77219_backgroundShape.docx")
634 CPPUNIT_ASSERT_EQUAL_MESSAGE("Shape is in front of the paragraph", false, getProperty<bool>(getShape(1), "Opaque"));
637 DECLARE_OOXMLEXPORT_TEST(testTdf77219_foregroundShape, "tdf77219_foregroundShape.docx")
639 CPPUNIT_ASSERT_EQUAL_MESSAGE("Shape is in front of the paragraph", true, getProperty<bool>(getShape(1), "Opaque"));
642 DECLARE_OOXMLEXPORT_TEST(testTdf108973_backgroundTextbox, "tdf108973_backgroundTextbox.docx")
644 CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox is in front of the paragraph", false, getProperty<bool>(getShape(1), "Opaque"));
647 DECLARE_OOXMLEXPORT_TEST(testTdf108973_foregroundTextbox, "tdf108973_foregroundTextbox.docx")
649 CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox is in front of the paragraph", true, getProperty<bool>(getShape(1), "Opaque"));
652 DECLARE_OOXMLEXPORT_TEST(testPresetShape, "preset-shape.docx")
654 // Document contains a flowChartMultidocument preset shape, our date for that shape wasn't correct.
655 uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
656 comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry"));
657 comphelper::SequenceAsHashMap aPath(aCustomShapeGeometry["Path"]);
658 uno::Sequence<awt::Size> aSubViewSize((aPath["SubViewSize"]).get<uno::Sequence<awt::Size> >() );
660 // This was 0.
661 CPPUNIT_ASSERT_EQUAL(sal_Int32(21600), aSubViewSize[0].Height);
664 CPPUNIT_TEST_FIXTURE(Test, testFdo76101)
666 loadAndSave("fdo76101.docx");
667 xmlDocUniquePtr pXmlDoc = parseExport("word/styles.xml");
668 xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "/w:styles/w:style");
669 xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
670 CPPUNIT_ASSERT(4091 >= xmlXPathNodeSetGetLength(pXmlNodes));
671 xmlXPathFreeObject(pXmlObj);
674 CPPUNIT_TEST_FIXTURE(Test, testSdtAndShapeOverlapping)
676 loadAndSave("ShapeOverlappingWithSdt.docx");
677 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
678 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[1]/mc:AlternateContent");
679 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt[1]/w:sdtContent[1]/w:r[1]");
682 CPPUNIT_TEST_FIXTURE(Test, testLockedCanvas)
684 loadAndSave("fdo78658.docx");
685 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
686 // Checking for lockedCanvas tag
687 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/lc:lockedCanvas", 1);
690 CPPUNIT_TEST_FIXTURE(Test, fdo78474)
692 loadAndSave("fdo78474.docx");
693 xmlDocUniquePtr pXmlDoc1 = parseExport("word/document.xml");
694 //docx file after RT is getting corrupted.
695 assertXPath(pXmlDoc1, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]/w:p[1]/w:r[1]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/pic:pic[1]/pic:blipFill[1]/a:blip[1]", "embed", "rId2");
697 xmlDocUniquePtr pXmlDoc2 = parseExport("word/_rels/document.xml.rels");
698 assertXPath(pXmlDoc2,"/rels:Relationships/rels:Relationship[2]","Id","rId2");
701 CPPUNIT_TEST_FIXTURE(Test, testAbsolutePositionOffsetValue)
703 loadAndSave("fdo78432.docx");
704 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
706 xmlXPathObjectPtr pXmlObjs[6];
707 pXmlObjs[0] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionH[1]/wp:posOffset[1]");
708 pXmlObjs[1] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionV[1]/wp:posOffset[1]");
710 pXmlObjs[2] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[2]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionH[1]/wp:posOffset[1]");
711 pXmlObjs[3] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[2]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionV[1]/wp:posOffset[1]");
713 pXmlObjs[4] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[3]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionH[1]/wp:posOffset[1]");
714 pXmlObjs[5] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[3]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionV[1]/wp:posOffset[1]");
716 for(sal_Int32 index = 0; index<6; ++index)
718 CPPUNIT_ASSERT(pXmlObjs[index]->nodesetval != nullptr);
719 xmlNodePtr pXmlNode = pXmlObjs[index]->nodesetval->nodeTab[0];
720 OUString contents = OUString::createFromAscii(reinterpret_cast<const char*>((pXmlNode->children[0]).content));
721 CPPUNIT_ASSERT( contents.toInt64() <= SAL_MAX_INT32 );
722 xmlXPathFreeObject(pXmlObjs[index]);
726 CPPUNIT_TEST_FIXTURE(Test, testRubyHyperlink)
728 loadAndReload("rubyhyperlink.fodt");
729 // test that export doesn't assert with overlapping ruby / hyperlink attr
732 CPPUNIT_TEST_FIXTURE(Test, testfdo78300)
734 loadAndSave("fdo78300.docx");
735 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
736 assertXPath(pXmlDoc,
737 "/w:document/w:body/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing[1]/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p[1]/w:r[1]/w:drawing[1]",
741 CPPUNIT_TEST_FIXTURE(Test, testWordArtWithinDraingtool)
743 loadAndSave("testWordArtWithinDraingtool.docx");
744 /* * Within a file, there is a 2007 wordArt enclosed in a drawing tool
745 * LO was exporting it as below:
746 * Sample XML as in Original file:
747 * <p> <r> <ac> <drawing> <txbx> <txbxContent> .. <pict> </pict> </txbxContent></txbx> </drawing> </ac> </r> </p>
748 * After RT :
749 * <p> <r> <ac> <drawing> <txbx> <txbxContent> .. <drawing> <txbx> <txbxContent> .. </txbxContent></txbx> </drawing> .. </txbxContent></txbx> </drawing> </ac> </r> </p>
750 * Expected : as there is nesting of a 2007 Word Art within a drawing tool, then can be separated in two different runs.
751 * */
753 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
754 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:txbx/w:txbxContent",1);
755 assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:textbox/w:txbxContent/w:p/w:r/w:pict/v:shape",1);
756 // Make sure that the shape inside a shape is exported as VML-only, no embedded mc:AlternateContent before w:pict.
757 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:txbx/w:txbxContent/w:p/w:r/w:pict",1);
760 CPPUNIT_TEST_FIXTURE(Test, testfdo78663)
762 loadAndSave("fdo78663.docx");
763 /* * A 2007 word art tool is enclosed in a 2010 drawing toolWithin a file,
764 * Originally the file has the following xml tag hierarchy.
766 * <p> <r> <ac> <drawing> <txbx> <txbxContent> <pict><shapetype> <shape> ...</shape></shapetype> </pict> </txbxContent></txbx> </drawing> </ac> </r> </p>
767 * After RT :
768 * <p> <r> <ac> <drawing> <txbx> <txbxContent> <pict><shapetype> <shape> <textbox><txbxContent> ... </txbxContent></textbox></shape></shapetype> </pict> </txbxContent></txbx> </drawing> </ac> </r> </p>
769 * MSO doesn't allow nesting of txbxContent tags.
770 * As the text of the wordart tool is written in the tag <v:textpath string="Welcome to... "History is fun and informative"/>
771 * We shouldn't repeat it again in <shapetype><shape> <textbox><txbxContent>
772 * */
774 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
775 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:txbx/w:txbxContent/w:p/w:r/w:pict/v:shape/v:path",1);
776 assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:textbox/w:txbxContent/w:p/w:r/w:pict/v:shape/v:path",1);
777 // Make sure that the shape inside a shape is exported as VML-only, no embedded mc:AlternateContent before w:pict.
778 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:txbx/w:txbxContent/w:p/w:r/w:pict",1);
781 CPPUNIT_TEST_FIXTURE(Test, testFdo78957)
783 loadAndSave("fdo78957.docx");
784 xmlDocUniquePtr pXmlHeader = parseExport("word/header2.xml");
786 const sal_Int64 IntMax = SAL_MAX_INT32;
787 sal_Int64 cx = 0, cy = 0;
788 cx = getXPath(pXmlHeader,"/w:hdr[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:extent[1]","cx").toInt64();
789 cy = getXPath(pXmlHeader,"/w:hdr[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:extent[1]","cy").toInt64();
790 // Here we check the values of extent width & height
791 CPPUNIT_ASSERT(cx <= IntMax );
792 CPPUNIT_ASSERT(cy >= 0 );
795 CPPUNIT_TEST_FIXTURE(Test, testfdo79256)
797 loadAndSave("fdo79256.docx");
798 /* corruption issue also solved by fixing tdf#108064:
799 * since that LO keeps MSO preset dash styles during OOXML export
801 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
803 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[1]/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:ln/a:prstDash", "val", "lgDash");
806 CPPUNIT_TEST_FIXTURE(Test, testDashedLine_CustDash1000thOfPercent)
808 loadAndSave("dashed_line_custdash_1000th_of_percent.docx");
809 /* Make sure that preset line is exported correctly as "1000th of a percent".
810 * This test-file has a CUSTOM dash-line that is defined as '1000th of a percent'.
811 * This should be imported by LO as-is, and exported back with the same values.
813 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
815 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[1]", "d" , "800000");
816 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[1]", "sp", "300000");
818 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[2]", "d" , "100000");
819 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[2]", "sp", "300000");
821 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[3]", "d" , "100000");
822 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[3]", "sp", "300000");
825 CPPUNIT_TEST_FIXTURE(Test, testDashedLine_CustDashPercentage)
827 loadAndSave("dashed_line_custdash_percentage.docx");
828 /* Make sure that preset line is exported correctly as "1000th of a percent".
829 * This test-file has a CUSTOM dash-line that is defined as percentages.
830 * This should be imported by LO as '1000th of a percent', and exported back
831 * as '1000th of a percent'.
833 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
835 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[1]", "d" , "800000");
836 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[1]", "sp", "300000");
838 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[2]", "d" , "100000");
839 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[2]", "sp", "300000");
841 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[3]", "d" , "100000");
842 assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/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:ln[1]/a:custDash[1]/a:ds[3]", "sp", "300000");
845 CPPUNIT_TEST_FIXTURE(Test, testCommentInitials)
847 loadAndSave("comment_initials.odt");
848 CPPUNIT_ASSERT_EQUAL(1, getPages());
849 xmlDocUniquePtr pXmlDoc = parseExport("word/comments.xml");
851 assertXPath(pXmlDoc,"/w:comments/w:comment[1]", "initials", "initials");
854 DECLARE_OOXMLEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.docx")
856 uno::Reference<drawing::XShape> xShape = getShape(1);
857 comphelper::SequenceAsHashMap aCustomShapeGeometry(getProperty< uno::Sequence<beans::PropertyValue> >(xShape, "CustomShapeGeometry"));
859 // Test that the shape is a rounded rectangle.
860 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-roundRect"), aCustomShapeGeometry["Type"].get<OUString>());
862 // The shape text should start with a table, with "a" in its A1 cell.
863 uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
864 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY);
865 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
866 CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell->getString());
869 CPPUNIT_TEST_FIXTURE(Test, testfdo79591)
871 loadAndSave("fdo79591.docx");
872 /* Values set for docPr name and shape ID attributes
873 * in RT file were not valid as per UTF-8 encoding format
874 * and hence was showing RT document as corrupt with error
875 * message "invalid character"
877 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
879 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr", "name", "_x0000_t0");
880 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape", "ID", "_x0000_t0");
883 DECLARE_OOXMLEXPORT_TEST(testBnc884615, "bnc884615.docx")
885 // The problem was that the shape in the header wasn't in the background.
886 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getShape(1), "Opaque"));
889 CPPUNIT_TEST_FIXTURE(Test, testFdo80894)
891 loadAndSave("TextFrameRotation.docx");
892 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
894 // Rotation value was not roundtripped for textframe.
895 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:xfrm",
896 "rot","16200000");
898 // w:enforcement defaults to off if not explicitly specified, so DocProtect forms should not be enabled.
899 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
900 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
901 CPPUNIT_ASSERT_EQUAL_MESSAGE("No protected sections", sal_Int32(0), xSections->getCount());
904 CPPUNIT_TEST_FIXTURE(Test, testfdo80895)
906 loadAndSave("fdo80895.docx");
907 // DML shapes in header and footer were not getting rendered in LO and the same were not preserved after RT.
908 // In actual there was a shape but because of fetching wrong theme for header.xml or footer.xml
909 // resultant shape was with <a:noFill/> prop in <wps:spPr> hence was not visible.
910 // Checking there is a shape in header without <a:noFill/> element.
912 xmlDocUniquePtr pXmlDoc = parseExport("word/header2.xml");
913 assertXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:noFill",0);
914 assertXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:noFill",0);
916 // Check for fallback (required for MSO-2007)
917 assertXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "fillcolor", "#4f81bd");
918 assertXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:fill", "type", "solid");
921 CPPUNIT_TEST_FIXTURE(Test, testTdf118242)
923 loadAndSave("tdf118242.odt");
924 CPPUNIT_ASSERT_EQUAL(3, getShapes());
925 CPPUNIT_ASSERT_EQUAL(1, getPages());
926 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
928 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
929 "/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p[2]/w:pPr/w:pStyle", "val", "HeaderRight");
931 // w:sectPr is not exported
932 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
933 "/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p[2]/w:pPr/w:sectPr", 0);
935 // and drawing is no longer in the document
936 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:r[3]", 0);
938 //but it's in the header
939 pXmlDocument = parseExport("word/header1.xml");
941 assertXPath(pXmlDocument, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData"
942 "/wps:wsp/wps:txbx/w:txbxContent/w:p[1]/w:r/w:drawing", 1);
946 CPPUNIT_TEST_FIXTURE(Test, testWrapTightThrough)
948 loadAndSave("wrap-tight-through.docx");
949 // These were wrapSquare without a wrap polygon before.
950 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
951 // The first shape should be wrapThrough with a wrap polygon (was wrapSquare).
952 assertXPath(pXmlDoc, "//w:drawing/wp:anchor[1]/wp:wrapThrough/wp:wrapPolygon/wp:start", "x", "-1104");
953 // The second shape should be wrapTight with a wrap polygon (was wrapSquare).
954 assertXPath(pXmlDoc, "//w:drawing/wp:anchor[1]/wp:wrapTight/wp:wrapPolygon/wp:start", "y", "792");
957 DECLARE_OOXMLEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.docx")
959 // The problem was that the wrap polygon was ignored during export.
960 drawing::PointSequenceSequence aSeqSeq = getProperty<drawing::PointSequenceSequence>(getShape(1), "ContourPolyPolygon");
961 // This was 0: the polygon list was empty.
962 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeqSeq.getLength());
964 drawing::PointSequence aSeq = aSeqSeq[0];
965 CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aSeq.getLength());
968 CPPUNIT_TEST_FIXTURE(Test, testPictureColormodeGrayscale)
970 loadAndSave("picture_colormode_grayscale.docx");
971 // The problem was that the grayscale was not exported
972 xmlDocUniquePtr pXmlDoc = parseExport ("word/document.xml");
974 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing/wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:grayscl", 1);
977 CPPUNIT_TEST_FIXTURE(Test, testPictureColormodeBlackWhite)
979 loadAndSave("picture_colormode_black_white.odt");
980 CPPUNIT_ASSERT_EQUAL(1, getShapes());
981 CPPUNIT_ASSERT_EQUAL(1, getPages());
982 xmlDocUniquePtr pXmlDoc = parseExport ("word/document.xml");
984 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:biLevel", "thresh", "50000");
987 CPPUNIT_TEST_FIXTURE(Test, testPictureColormodeWatermark)
989 loadAndSave("picture_colormode_watermark.odt");
990 CPPUNIT_ASSERT_EQUAL(1, getShapes());
991 CPPUNIT_ASSERT_EQUAL(1, getPages());
992 xmlDocUniquePtr pXmlDoc = parseExport ("word/document.xml");
993 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:lum", "bright", "70000");
994 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:lum", "contrast", "-70000");
998 CPPUNIT_TEST_FIXTURE(Test, testExportShadow)
1000 loadAndSave("bnc637947.odt");
1001 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1002 CPPUNIT_ASSERT_EQUAL(1, getPages());
1003 // The problem was that shadows of shapes from non-OOXML origin were not exported to DrawingML
1004 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1006 assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:spPr/a:effectLst/a:outerShdw", "dist" , "109865");
1007 assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:spPr/a:effectLst/a:outerShdw", "dir" , "634411");
1008 assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:spPr/a:effectLst/a:outerShdw/a:srgbClr", "val" , "000000");
1009 assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:spPr/a:effectLst/a:outerShdw/a:srgbClr/a:alpha", "val" , "38000");
1012 CPPUNIT_TEST_FIXTURE(Test, testExportAdjustmentValue)
1014 loadAndSave("tdf91429.docx");
1015 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1017 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:prstGeom/a:avLst/a:gd", "fmla", "val 50000");
1020 DECLARE_OOXMLEXPORT_TEST(testTextVerticalAdjustment, "tdf36117_verticalAdjustment.docx")
1022 //Preserve the page vertical alignment setting for .docx
1023 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
1024 CPPUNIT_ASSERT(pTextDoc);
1025 SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
1026 CPPUNIT_ASSERT(pDoc);
1028 SwPageDesc* pDesc = &pDoc->GetPageDesc( 0 );
1029 drawing::TextVerticalAdjust nVA = pDesc->GetVerticalAdjustment();
1030 CPPUNIT_ASSERT_EQUAL( drawing::TextVerticalAdjust_CENTER, nVA );
1032 pDesc = &pDoc->GetPageDesc( 1 );
1033 nVA = pDesc->GetVerticalAdjustment();
1034 CPPUNIT_ASSERT_EQUAL( drawing::TextVerticalAdjust_TOP, nVA );
1036 pDesc = &pDoc->GetPageDesc( 2 );
1037 nVA = pDesc->GetVerticalAdjustment();
1038 CPPUNIT_ASSERT_EQUAL( drawing::TextVerticalAdjust_BOTTOM, nVA );
1040 pDesc = &pDoc->GetPageDesc( 3 );
1041 nVA = pDesc->GetVerticalAdjustment();
1042 CPPUNIT_ASSERT_EQUAL( drawing::TextVerticalAdjust_BLOCK, nVA );
1045 #if HAVE_MORE_FONTS
1046 DECLARE_OOXMLEXPORT_TEST(testTDF87348, "tdf87348_linkedTextboxes.docx")
1048 int followCount=0;
1049 int precedeCount=0;
1050 if( !parseDump("/root/page/body/txt/anchored/fly[1]/txt","follow").isEmpty() )
1051 followCount++;
1052 if( !parseDump("/root/page/body/txt/anchored/fly[1]/txt","precede").isEmpty() )
1053 precedeCount++;
1054 if( !parseDump("/root/page/body/txt/anchored/fly[2]/txt","follow").isEmpty() )
1055 followCount++;
1056 if( !parseDump("/root/page/body/txt/anchored/fly[2]/txt","precede").isEmpty() )
1057 precedeCount++;
1058 if( !parseDump("/root/page/body/txt/anchored/fly[3]/txt","follow").isEmpty() )
1059 followCount++;
1060 if( !parseDump("/root/page/body/txt/anchored/fly[3]/txt","precede").isEmpty() )
1061 precedeCount++;
1062 if( !parseDump("/root/page/body/txt/anchored/fly[4]/txt","follow").isEmpty() )
1063 followCount++;
1064 if( !parseDump("/root/page/body/txt/anchored/fly[4]/txt","precede").isEmpty() )
1065 precedeCount++;
1066 if( !parseDump("/root/page/body/txt/anchored/fly[5]/txt","follow").isEmpty() )
1067 followCount++;
1068 if( !parseDump("/root/page/body/txt/anchored/fly[5]/txt","precede").isEmpty() )
1069 precedeCount++;
1070 if( !parseDump("/root/page/body/txt/anchored/fly[6]/txt","follow").isEmpty() )
1071 followCount++;
1072 if( !parseDump("/root/page/body/txt/anchored/fly[6]/txt","precede").isEmpty() )
1073 precedeCount++;
1074 if( !parseDump("/root/page/body/txt/anchored/fly[7]/txt","follow").isEmpty() )
1075 followCount++;
1076 if( !parseDump("/root/page/body/txt/anchored/fly[7]/txt","precede").isEmpty() )
1077 precedeCount++;
1078 if( !parseDump("/root/page/body/txt/anchored/fly[8]/txt","follow").isEmpty() )
1079 followCount++;
1080 if( !parseDump("/root/page/body/txt/anchored/fly[8]/txt","precede").isEmpty() )
1081 precedeCount++;
1082 if( !parseDump("/root/page/body/txt/anchored/fly[9]/txt","follow").isEmpty() )
1083 followCount++;
1084 if( !parseDump("/root/page/body/txt/anchored/fly[9]/txt","precede").isEmpty() )
1085 precedeCount++;
1086 if( !parseDump("/root/page/body/txt/anchored/fly[10]/txt","follow").isEmpty() )
1087 followCount++;
1088 if( !parseDump("/root/page/body/txt/anchored/fly[10]/txt","precede").isEmpty() )
1089 precedeCount++;
1090 if( !parseDump("/root/page/body/txt/anchored/fly[11]/txt","follow").isEmpty() )
1091 followCount++;
1092 if( !parseDump("/root/page/body/txt/anchored/fly[11]/txt","precede").isEmpty() )
1093 precedeCount++;
1094 if( !parseDump("/root/page/body/txt/anchored/fly[12]/txt","follow").isEmpty() )
1095 followCount++;
1096 if( !parseDump("/root/page/body/txt/anchored/fly[12]/txt","precede").isEmpty() )
1097 precedeCount++;
1098 if( !parseDump("/root/page/body/txt/anchored/fly[13]/txt","follow").isEmpty() )
1099 followCount++;
1100 if( !parseDump("/root/page/body/txt/anchored/fly[13]/txt","precede").isEmpty() )
1101 precedeCount++;
1102 //there should be 4 chains/13 linked textboxes (set of 5, set of 3, set of 3, set of 2)
1103 //that means 9 NEXT links and 9 PREV links.
1104 //however, the current implementation adds leftover shapes, so can't go on exact numbers
1105 // (unknown number of flys, unknown order of leftovers)
1106 CPPUNIT_ASSERT ( (followCount >= 6) );
1107 CPPUNIT_ASSERT ( (precedeCount >= 6) );
1109 #endif
1111 CPPUNIT_TEST_FIXTURE(Test, testTDF93675)
1113 loadAndSave("no-numlevel-but-indented.odt");
1114 CPPUNIT_ASSERT_EQUAL(1, getPages());
1115 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1116 assertXPath(pXmlDoc, "//w:ind", "start", "1418");
1121 CPPUNIT_TEST_FIXTURE(Test, testFlipAndRotateCustomShape)
1123 loadAndSave("flip_and_rotate.odt");
1124 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1125 CPPUNIT_ASSERT_EQUAL(1, getPages());
1126 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1127 // there should be no flipH
1128 assertXPathNoAttribute(pXmlDoc, "//a:xfrm", "flipH");
1129 // flipV should be there
1130 assertXPath(pXmlDoc, "//a:xfrm", "flipV", "1");
1131 // check rotation angle
1132 assertXPath(pXmlDoc, "//a:xfrm", "rot", "8100000");
1133 // point values depend on path size, values as of March 2022
1134 assertXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path", "w", "21600");
1135 assertXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path", "h", "21600");
1136 // check the first few coordinates of the polygon
1137 CPPUNIT_ASSERT_DOUBLES_EQUAL(
1138 0, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:moveTo/a:pt", "x").toInt32(), 1);
1139 CPPUNIT_ASSERT_DOUBLES_EQUAL(
1140 15831, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:moveTo/a:pt", "y").toInt32(), 1);
1141 CPPUNIT_ASSERT_DOUBLES_EQUAL(
1142 6098, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", "x").toInt32(), 1);
1143 CPPUNIT_ASSERT_DOUBLES_EQUAL(
1144 10062, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", "y").toInt32(), 1);
1145 CPPUNIT_ASSERT_DOUBLES_EQUAL(
1146 13284, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[4]/a:pt", "x").toInt32(), 1);
1147 CPPUNIT_ASSERT_DOUBLES_EQUAL(
1148 6098, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[4]/a:pt", "y").toInt32(), 1);
1149 // check path is closed
1150 assertXPath(pXmlDoc, "//a:close", 1);
1153 CPPUNIT_TEST_FIXTURE(Test, testTdf92335)
1155 loadAndSave("tdf92335.docx");
1156 // Don't export redundant ListLabel character styles
1157 xmlDocUniquePtr pXmlStyles = parseExport("word/styles.xml");
1159 assertXPath(pXmlStyles, "//w:style[@w:styleId='ListLabel1']", 0);
1162 CPPUNIT_PLUGIN_IMPLEMENT();
1164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */