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/awt/XBitmap.hpp>
13 #include <com/sun/star/drawing/FillStyle.hpp>
14 #include <com/sun/star/drawing/XControlShape.hpp>
15 #include <com/sun/star/text/RelOrientation.hpp>
16 #include <com/sun/star/text/XTextField.hpp>
17 #include <com/sun/star/text/XTextTable.hpp>
18 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
19 #include <com/sun/star/text/XTextColumns.hpp>
20 #include <com/sun/star/text/XPageCursor.hpp>
21 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
22 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
23 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
24 #include <com/sun/star/text/XTextTablesSupplier.hpp>
26 #include <config_fonts.h>
27 #include <officecfg/Office/Writer.hxx>
28 #include <vcl/svapp.hxx>
30 class Test
: public SwModelTestBase
33 Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
36 virtual std::unique_ptr
<Resetter
> preTest(const char* filename
) override
38 if (filename
== std::string_view("combobox-control.docx") )
40 std::shared_ptr
< comphelper::ConfigurationChanges
> batch(comphelper::ConfigurationChanges::create());
41 officecfg::Office::Writer::Filter::Import::DOCX::ImportComboBoxAsDropDown::set(true, batch
);
47 void verifyComboBoxExport(bool aComboBoxAsDropDown
);
50 DECLARE_OOXMLEXPORT_TEST(testRelorientation
, "relorientation.docx")
52 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
53 // This was text::RelOrientation::FRAME, when handling relativeFrom=page, align=right
54 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xShape
, "HoriOrientRelation"));
56 uno::Reference
<drawing::XShapes
> xGroup(xShape
, uno::UNO_QUERY
);
57 // This resulted in lang::IndexOutOfBoundsException, as nested groupshapes weren't handled.
58 uno::Reference
<drawing::XShapeDescriptor
> xShapeDescriptor(xGroup
->getByIndex(0), uno::UNO_QUERY
);
59 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), xShapeDescriptor
->getShapeType());
61 // 'actual child size' = 'group ext' * 'child ext' / 'chExt from group', see section 'chExt' in
62 // [MS-OI29500]. Here for width from file 3108960 * 4896 / 4911 = 3099464 EMU. That corresponds to
63 // width 8.61cm and 325px in UI in Word and rounds down to 8609 Hmm. Considering scaling of the
64 // parent group to the anchor extent (* 3118485 / 3108960) we get a display width of 3108960 EMU
65 // = 8636Hmm. FIXME: Expected value is as in LO 7.2. Reason for difference is yet unknown.
68 uno::Reference
<drawing::XShape
> xYear(xGroup
->getByIndex(1), uno::UNO_QUERY
);
69 // This was 2, due to incorrect handling of parent transformations inside DML groupshapes.
70 CPPUNIT_ASSERT_EQUAL(sal_Int32(8662), xYear
->getSize().Width
);
74 CPPUNIT_TEST_FIXTURE(Test
, testBezier
)
76 loadAndReload("bezier.odt");
77 CPPUNIT_ASSERT_EQUAL(1, getPages());
78 // Check that no shape got lost: a bezier, a line and a text shape.
79 CPPUNIT_ASSERT_EQUAL(3, getShapes());
82 DECLARE_OOXMLEXPORT_TEST(testGroupshapeTextbox
, "groupshape-textbox.docx")
84 uno::Reference
<drawing::XShapes
> xGroup(getShape(1), uno::UNO_QUERY
);
85 uno::Reference
<text::XTextRange
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
86 // The VML export lost text on textboxes inside groupshapes.
87 // The DML export does not, make sure it stays that way.
88 CPPUNIT_ASSERT_EQUAL(OUString("first"), xShape
->getString());
89 // This was 16, i.e. inheriting doc default char height didn't work.
90 CPPUNIT_ASSERT_EQUAL(11.f
, getProperty
<float>(getParagraphOfText(1, xShape
->getText()), "CharHeight"));
93 DECLARE_OOXMLEXPORT_TEST(testGroupshapePicture
, "groupshape-picture.docx")
95 // Picture in the groupshape got lost, groupshape had only one child.
96 uno::Reference
<drawing::XShapes
> xGroup(getShape(1), uno::UNO_QUERY
);
97 uno::Reference
<drawing::XShapeDescriptor
> xShapeDescriptor(xGroup
->getByIndex(1), uno::UNO_QUERY
);
98 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GraphicObjectShape"), xShapeDescriptor
->getShapeType());
101 DECLARE_OOXMLEXPORT_TEST(testAutofit
, "autofit.docx")
103 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getShape(1), "TextAutoGrowHeight"));
104 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(getShape(2), "TextAutoGrowHeight"));
107 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesDeletedParagraphMark
)
109 loadAndSave("testTrackChangesDeletedParagraphMark.docx");
110 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
111 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:del");
114 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesInsertedParagraphMark
)
116 loadAndSave("testTrackChangesInsertedParagraphMark.docx");
117 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
118 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:ins");
121 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesDeletedTableRow
)
123 loadAndSave("testTrackChangesDeletedTableRow.docx");
124 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
125 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:del");
128 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesInsertedTableRow
)
130 loadAndSave("testTrackChangesInsertedTableRow.docx");
131 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
132 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:ins");
135 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesDeletedTableCell
)
137 loadAndSave("testTrackChangesDeletedTableCell.docx");
138 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
139 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellDel");
142 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesInsertedTableCell
)
144 loadAndSave("testTrackChangesInsertedTableCell.docx");
145 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
146 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellIns");
149 DECLARE_OOXMLEXPORT_TEST(testTextBoxPictureFill
, "textbox_picturefill.docx")
151 uno::Reference
<beans::XPropertySet
> xFrame(getShape(1), uno::UNO_QUERY
);
152 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, getProperty
<drawing::FillStyle
>(xFrame
, "FillStyle"));
153 auto xBitmap
= getProperty
<uno::Reference
<awt::XBitmap
>>(xFrame
, "FillBitmap");
154 CPPUNIT_ASSERT(xBitmap
.is());
155 uno::Reference
<graphic::XGraphic
> xGraphic(xBitmap
, uno::UNO_QUERY
);
156 CPPUNIT_ASSERT(xGraphic
.is());
157 Graphic
aGraphic(xGraphic
);
158 CPPUNIT_ASSERT(!aGraphic
.IsNone());
159 CPPUNIT_ASSERT(aGraphic
.GetSizeBytes() > 0L);
160 CPPUNIT_ASSERT_EQUAL(tools::Long(447), aGraphic
.GetSizePixel().Width());
161 CPPUNIT_ASSERT_EQUAL(tools::Long(528), aGraphic
.GetSizePixel().Height());
164 CPPUNIT_TEST_FIXTURE(Test
, testFDO73034
)
166 loadAndSave("FDO73034.docx");
167 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
168 CPPUNIT_ASSERT(getXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:u", "val").match("single"));
171 CPPUNIT_TEST_FIXTURE(Test
, testFDO71834
)
173 loadAndSave("fdo71834.docx");
174 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
175 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr[2]/w:tc[1]/w:tcPr[1]/w:tcW[1]","type", "dxa");
178 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesParagraphProperties
)
180 loadAndSave("testTrackChangesParagraphProperties.docx");
181 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
182 assertXPathChildren(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:pPrChange", 0);
185 CPPUNIT_TEST_FIXTURE(Test
, testMsoSpt180
)
187 loadAndReload("mso-spt180.docx");
188 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
189 const uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(xGroup
->getByIndex(0), "CustomShapeGeometry");
191 for (beans::PropertyValue
const & prop
: aProps
)
192 if (prop
.Name
== "Type")
193 aType
= prop
.Value
.get
<OUString
>();
194 // This was exported as borderCallout90, which is an invalid drawingML preset shape string.
195 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-borderCallout1"), aType
);
198 CPPUNIT_TEST_FIXTURE(Test
, testFdo73550
)
200 loadAndSave("fdo73550.docx");
201 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
202 // This was wrap="none".
203 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:rFonts");
206 DECLARE_OOXMLEXPORT_TEST(testPageRelSize
, "pagerelsize.docx")
208 // First shape: width is relative from page, but not height.
209 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
210 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xShape
, "RelativeWidthRelation"));
211 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME
, getProperty
<sal_Int16
>(xShape
, "RelativeHeightRelation"));
213 // Second shape: height is relative from page, but not height.
214 xShape
= getShape(2);
215 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xShape
, "RelativeHeightRelation"));
216 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME
, getProperty
<sal_Int16
>(xShape
, "RelativeWidthRelation"));
219 DECLARE_OOXMLEXPORT_TEST(testRelSizeRound
, "rel-size-round.docx")
221 // This was 9: 9.8 was imported as 9 instead of being rounded to 10.
222 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty
<sal_Int16
>(getShape(1), "RelativeHeight"));
225 DECLARE_OOXMLEXPORT_TEST(testTestTitlePage
, "testTitlePage.docx")
227 // this has 2 pages in Word
228 CPPUNIT_ASSERT_EQUAL(OUString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), parseDump("/root/page[2]/footer/txt/text()"));
231 DECLARE_OOXMLEXPORT_TEST(testTableRowDataDisplayedTwice
, "table-row-data-displayed-twice.docx")
233 // fdo#73534: There was a problem for some documents during export.Invalid sectPr getting added
234 // because of wrong condition in code.
235 // This was the reason for increasing number of pages after RT
236 CPPUNIT_ASSERT_EQUAL(2, getPages());
239 CPPUNIT_TEST_FIXTURE(Test
, testFdo73556
)
241 loadAndSave("fdo73556.docx");
243 * The file contains a table with 3 columns
244 * the gridcols are as follows: {1210, 1331, 1210}
245 * whereas the individual cells have {1210, 400, 1210}
246 * The table column separators were taken from the Grid, while
247 * the table width was calculated as 2820 from cells instead
248 * of 3751 from the Grid.
250 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
251 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol", 3);
252 sal_Int32 tableWidth
= 0;
253 tableWidth
+= getXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[1]", "w").toInt32();
254 tableWidth
+= getXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32();
255 tableWidth
+= getXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[3]", "w").toInt32();
256 CPPUNIT_ASSERT_EQUAL(sal_Int32(3751), tableWidth
);
259 CPPUNIT_TEST_FIXTURE(Test
, testSegFaultWhileSave
)
261 loadAndSave("test_segfault_while_save.docx");
263 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
264 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(6137), getXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32());
267 CPPUNIT_TEST_FIXTURE(Test
, fdo69656
)
269 loadAndSave("Table_cell_auto_width_fdo69656.docx");
270 // Changed the UT to check "dxa" instead of "auto"
271 // For this particular issue file few cells have width type "auto"
272 // LO supports VARIABLE and FIXED width type.
273 // If type is VARIABLE LO calculates width as percent of PageSize
274 // Else if the width is fixed it uses the width value.
275 // After changes for fdo76741 the fixed width is exported as "dxa" for DOCX
277 // Check for the width type of table and its cells.
278 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
279 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblPr/w:tblW","type","dxa");
282 CPPUNIT_TEST_FIXTURE(Test
, testFdo76741
)
284 loadAndSave("fdo76741.docx");
286 // There are two issue related to table in the saved(exported) file
287 // - the table alignment in saved file is "left" instead of "center"
288 // - the table width type in properties is "auto" instead of "dxa"
290 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
292 assertXPath(pXmlDoc
, "//w:jc", "val", "center");
293 assertXPath(pXmlDoc
, "//w:tblW", "w", "10081");
294 assertXPath(pXmlDoc
, "//w:tblW", "type", "dxa");
297 CPPUNIT_TEST_FIXTURE(Test
, testFdo73541
)
299 loadAndSave("fdo73541.docx");
300 // fdo#73541: The mirrored margins were not imported and mapped correctly in Page Layout
301 // Hence <w:mirrorMargins /> tag was not exported back in settings.xml
302 xmlDocUniquePtr pXmlDoc
= parseExport("word/settings.xml");
303 assertXPath(pXmlDoc
, "/w:settings/w:mirrorMargins");
306 CPPUNIT_TEST_FIXTURE(Test
, testFdo106029
)
308 loadAndSave("fdo106029.docx");
309 xmlDocUniquePtr pXmlDoc
= parseExport("word/settings.xml");
310 assertXPath(pXmlDoc
, "/w:settings/w:compat/w:doNotExpandShiftReturn");
313 CPPUNIT_TEST_FIXTURE(Test
, testTdf146515
)
315 loadAndSave("tdf146515.odt");
316 xmlDocUniquePtr pXmlDoc
= parseExport("word/settings.xml");
317 assertXPath(pXmlDoc
, "/w:settings/w:compat/w:usePrinterMetrics");
320 CPPUNIT_TEST_FIXTURE(Test
, testFDO74106
)
322 loadAndSave("FDO74106.docx");
323 xmlDocUniquePtr pXmlDoc
= parseExport("word/numbering.xml");
324 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:numFmt", "val","hebrew1");
327 CPPUNIT_TEST_FIXTURE(Test
, testFDO74215
)
329 loadAndSave("FDO74215.docx");
330 xmlDocUniquePtr pXmlDoc
= parseExport("word/numbering.xml");
331 // tdf#106849 NumPicBullet xShape should not be resized.
333 // This is dependent on the running system: see MSWordExportBase::BulletDefinitions
334 // FIXME: the size of a bullet is defined by GraphicSize property
335 // (stored in SvxNumberFormat::aGraphicSize) so use that for the size
336 // (properly convert from 100mm to pt (1 inch is 72 pt, 1 pt is 20 twips).
338 // On 96 DPI "width:11.25pt;height:11.25pt"; on 120 DPI "width:9pt;height:9pt"
339 const OUString sStyle
340 = getXPath(pXmlDoc
, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style");
342 OUString sWidth
= sStyle
.getToken(0, ';');
343 CPPUNIT_ASSERT(sWidth
.startsWith("width:", &sWidth
));
344 CPPUNIT_ASSERT(sWidth
.endsWith("pt", &sWidth
));
345 const double fWidth
= sWidth
.toDouble();
346 const double fXScaleFactor
= 96.0 / Application::GetDefaultDevice()->GetDPIX();
347 // note: used to fail on Mac with 14.7945205479452 vs. 14.8
348 // note: used to fail on another Mac with 12.1348314606742 vs 12.15
349 CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25 * fXScaleFactor
, fWidth
, 0.1);
352 OUString sHeight
= sStyle
.getToken(1, ';');
353 CPPUNIT_ASSERT(sHeight
.startsWith("height:", &sHeight
));
354 CPPUNIT_ASSERT(sHeight
.endsWith("pt", &sHeight
));
355 const double fHeight
= sHeight
.toDouble();
356 const double fYScaleFactor
= 96.0 / Application::GetDefaultDevice()->GetDPIY();
357 CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25 * fYScaleFactor
, fHeight
, 0.1);
361 DECLARE_OOXMLEXPORT_TEST(testColumnBreak_ColumnCountIsZero
,"fdo74153.docx")
363 /* fdo73545: Column Break with Column_count = 0 was not getting preserved.
364 * The <w:br w:type="column" /> was missing after roundtrip
368 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
369 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:r[1]/w:br","type","column");
372 //tdf76349 match Word's behavior of treating breaks in single columns as page breaks.
373 CPPUNIT_ASSERT_EQUAL(2, getPages());
376 DECLARE_OOXMLEXPORT_TEST(testTdf90697_complexBreaksHeaders
,"tdf90697_complexBreaksHeaders.docx")
378 // This is a complex document using many types of section breaks and re-defined headers.
379 // Paragraphs 44-47 were in two columns
380 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
< uno::Reference
<beans::XPropertySet
> >(getParagraph(45), "TextSection");
381 CPPUNIT_ASSERT(xTextSection
.is());
382 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
< uno::Reference
<text::XTextColumns
> >(xTextSection
, "TextColumns");
383 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns
->getColumnCount());
385 // after that, the section break should switch things back to one column.
386 xTextSection
= getProperty
< uno::Reference
<beans::XPropertySet
> >(getParagraph(50), "TextSection");
387 CPPUNIT_ASSERT(xTextSection
.is());
388 xTextColumns
= getProperty
< uno::Reference
<text::XTextColumns
> >(xTextSection
, "TextColumns");
389 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns
->getColumnCount());
392 CPPUNIT_TEST_FIXTURE(Test
, testIndentation
)
394 loadAndSave("test_indentation.docx");
395 // fdo#74141 :There was a problem that in style.xml and document.xml in <w:ind> tag "right" & "left" margin
396 // attributes gets added(w:right=0 & w:left=0) if these attributes are not set in original document.
397 // This test is to verify <w:ind> does not contain w:right attribute.
398 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
399 assertXPathNoAttribute(pXmlDoc
, "/w:document/w:body/w:p/w:pPr/w:ind", "end");
402 CPPUNIT_TEST_FIXTURE(Test
, testChartInFooter
)
404 loadAndSave("chart-in-footer.docx");
405 // fdo#73872: document contains chart in footer.
406 // The problem was that footer1.xml.rels files for footer1.xml
407 // files were missing from docx file after roundtrip.
408 xmlDocUniquePtr pXmlDoc
= parseExport("word/_rels/footer2.xml.rels");
410 // Check footer2.xml.rels contains in doc after roundtrip.
411 // Check Id = rId1 in footer2.xml.rels
412 assertXPath(pXmlDoc
,"/rels:Relationships/rels:Relationship","Id","rId1");
414 "/rels:Relationships/rels:Relationship[@Id='rId1']",
416 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart");
418 xmlDocUniquePtr pXmlDocCT
= parseExport("[Content_Types].xml");
419 assertXPath(pXmlDocCT
,
420 "/ContentType:Types/ContentType:Override[@PartName='/word/charts/chart1.xml']",
422 "application/vnd.openxmlformats-officedocument.drawingml.chart+xml");
424 // check the content too
425 xmlDocUniquePtr pXmlDocFooter2
= parseExport("word/footer2.xml");
426 assertXPath(pXmlDocFooter2
,
427 "/w:ftr/w:p[1]/w:r/w:drawing/wp:inline/a:graphic/a:graphicData",
429 "http://schemas.openxmlformats.org/drawingml/2006/chart");
430 assertXPath(pXmlDocFooter2
,
431 "/w:ftr/w:p[1]/w:r/w:drawing/wp:inline/a:graphic/a:graphicData/c:chart",
435 CPPUNIT_ASSERT_EQUAL(1, getShapes());
438 CPPUNIT_TEST_FIXTURE(Test
, testNestedTextFrames
)
440 loadAndReload("nested-text-frames.odt");
441 CPPUNIT_ASSERT_EQUAL(3, getShapes());
442 CPPUNIT_ASSERT_EQUAL(1, getPages());
443 // First problem was LO crashed during export (crash test)
445 // Second problem was LO made file corruption, writing out nested text boxes, which can't be handled by Word.
446 // Test that all three exported text boxes are anchored to the same paragraph and not each other.
447 uno::Reference
<text::XTextContent
> xTextContent(getShape(1), uno::UNO_QUERY
);
448 uno::Reference
<text::XTextRange
> xRange
= xTextContent
->getAnchor();
449 uno::Reference
<text::XText
> xText
= xRange
->getText();
450 CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText
->getString());
452 xTextContent
.set(getShape(2), uno::UNO_QUERY
);
453 xRange
= xTextContent
->getAnchor();
454 xText
= xRange
->getText();
455 CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText
->getString());
457 xTextContent
.set(getShape(3), uno::UNO_QUERY
);
458 xRange
= xTextContent
->getAnchor();
459 xText
= xRange
->getText();
460 CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText
->getString());
463 DECLARE_OOXMLEXPORT_TEST(testFloatingTablePosition
, "floating-table-position.docx")
465 // Position of shape was wrong, because some conversion was missing.
466 uno::Reference
<beans::XPropertySet
> xShape(getShape(1), uno::UNO_QUERY
);
468 CPPUNIT_ASSERT_EQUAL(sal_Int32(5964), getProperty
<sal_Int32
>(xShape
, "HoriOrientPosition"));
470 CPPUNIT_ASSERT_EQUAL(sal_Int32(8133), getProperty
<sal_Int32
>(xShape
, "VertOrientPosition"));
473 CPPUNIT_TEST_FIXTURE(Test
, testAbi11739
)
475 loadAndSave("abi11739.docx");
476 // Validation test: order of elements were wrong.
477 xmlDocUniquePtr pXmlDoc
= parseExport("word/styles.xml");
478 // Order was: uiPriority, link, basedOn.
479 CPPUNIT_ASSERT(getXPathPosition(pXmlDoc
, "/w:styles/w:style[3]", "basedOn") < getXPathPosition(pXmlDoc
, "/w:styles/w:style[3]", "link"));
480 CPPUNIT_ASSERT(getXPathPosition(pXmlDoc
, "/w:styles/w:style[3]", "link") < getXPathPosition(pXmlDoc
, "/w:styles/w:style[3]", "uiPriority"));
481 // Order was: qFormat, unhideWhenUsed.
482 CPPUNIT_ASSERT(getXPathPosition(pXmlDoc
, "/w:styles/w:style[11]", "unhideWhenUsed") < getXPathPosition(pXmlDoc
, "/w:styles/w:style[11]", "qFormat"));
485 DECLARE_OOXMLEXPORT_TEST(testEmbeddedXlsx
, "embedded-xlsx.docx")
487 // check there are two objects and they are FrameShapes
488 CPPUNIT_ASSERT_EQUAL(2, getShapes());
489 CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(1)->getShapeType());
490 CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(2)->getShapeType());
492 // check the objects are present in the exported document.xml
495 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
496 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/w:object", 2);
498 // finally check the embedded files are present in the zipped document
499 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
500 const uno::Sequence
<OUString
> names
= xNameAccess
->getElementNames();
503 for (OUString
const & n
: names
)
505 if(n
.startsWith("word/embeddings/oleObject"))
507 if(n
.startsWith("word/media/image"))
510 CPPUNIT_ASSERT_EQUAL(2, nSheetFiles
);
511 CPPUNIT_ASSERT_EQUAL(2, nImageFiles
);
514 CPPUNIT_TEST_FIXTURE(Test
, testNumberedLists_StartingWithZero
)
516 loadAndSave("FDO74105.docx");
517 /* Issue : Numbered lists Starting with value '0' is not preserved after RT.
518 * In numbering.xml, an XML tag <w:start> is optional. If not mentioned,
519 * the Numbered list should start from 0.
520 * Problem was LO was writing <w:start> for all levels 0-8 with default value "1".
522 xmlDocUniquePtr pXmlDoc
= parseExport("word/numbering.xml");
524 // Check that we do _not_ export w:start for <w:lvl w:ilvl="0">.
525 assertXPath(pXmlDoc
, "w:numbering/w:abstractNum[1]/w:lvl[1]/w:start", 0);
528 CPPUNIT_TEST_FIXTURE(Test
, testPageBreak
)
530 loadAndReload("fdo74566.docx");
531 /* Break to next page was written into wrong paragraph as <w:pageBreakBefore />.
532 * LO was not preserving Page Break as <w:br w:type="page" />.
533 * Now after fix , LO writes Page Break as the new paragraph and also
534 * preserves the xml tag <w:br>.
536 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
538 uno::Reference
<text::XTextRange
> xParagraph2
= getParagraph(2);
539 uno::Reference
<text::XTextRange
> xParagraph4
= getParagraph(4);
541 getRun(xParagraph2
, 1, "First Page Second Line");
542 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:r[2]/w:br","type","page");
543 getRun(xParagraph4
, 1, "Second Page First line after Page Break");
546 CPPUNIT_TEST_FIXTURE(Test
, testOleObject
)
548 loadAndSave("test_ole_object.docx");
549 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
551 assertXPathNoAttribute(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata",
554 "/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject",
557 // TODO: ProgID="Package" - what is this? Zip with 10k extra header?
559 // check the rels too
560 xmlDocUniquePtr pXmlDocRels
= parseExport("word/_rels/document.xml.rels");
561 assertXPath(pXmlDocRels
,
562 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.bin']",
564 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject");
565 // check the media type too
566 xmlDocUniquePtr pXmlDocCT
= parseExport("[Content_Types].xml");
567 assertXPath(pXmlDocCT
,
568 "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.bin']",
570 "application/vnd.openxmlformats-officedocument.oleObject");
574 CPPUNIT_TEST_FIXTURE(Test
, testFdo74792
)
576 loadAndSave("fdo74792.docx");
578 * fdo#74792 : The images associated with smart-art data[i].xml
579 * were not preserved on exporting to DOCX format
580 * Added support to grabbag the rels, with associated images.
582 xmlDocUniquePtr pXmlDoc
= parseExport("word/diagrams/_rels/data1.xml.rels");
583 assertXPath(pXmlDoc
,"/rels:Relationships/rels:Relationship", 4);
584 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(
585 comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
587 //check that images are also saved
588 uno::Reference
<io::XInputStream
> xInputStream(xNameAccess
->getByName( "word/media/OOXDiagramDataRels1_0.jpeg" /*added anchor id to form a unique name*/ ), uno::UNO_QUERY
);
589 CPPUNIT_ASSERT( xInputStream
.is() );
592 CPPUNIT_TEST_FIXTURE(Test
, testFdo77718
)
594 loadAndSave("fdo77718.docx");
595 //in case of multiple smart arts the names for images were getting
596 //repeated and thereby causing a data loss as the binary stream was
597 //getting over written. This test case ensures that unique names are
598 //given for images in different smart arts.
599 xmlDocUniquePtr pXmlDataRels1
= parseExport("word/diagrams/_rels/data1.xml.rels");
600 xmlDocUniquePtr pXmlDataRels2
= parseExport("word/diagrams/_rels/data2.xml.rels");
602 //ensure that the rels file is present.
603 assertXPath(pXmlDataRels1
,"/rels:Relationships/rels:Relationship", 4);
604 assertXPath(pXmlDataRels2
,"/rels:Relationships/rels:Relationship", 4);
606 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(
607 comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
609 //check that images are also saved
610 uno::Reference
<io::XInputStream
> xInputStream1(xNameAccess
->getByName( "word/media/OOXDiagramDataRels1_0.jpeg" /*added anchor id to form a unique name*/ ), uno::UNO_QUERY
);
611 CPPUNIT_ASSERT( xInputStream1
.is() );
613 //check that images are saved for other smart-arts as well.
614 uno::Reference
<io::XInputStream
> xInputStream2(xNameAccess
->getByName( "word/media/OOXDiagramDataRels2_0.jpeg" /*added anchor id to form a unique name*/ ), uno::UNO_QUERY
);
615 CPPUNIT_ASSERT( xInputStream2
.is() );
618 CPPUNIT_TEST_FIXTURE(Test
, testTableCurruption
)
620 loadAndSave("tableCurrupt.docx");
621 xmlDocUniquePtr pXmlDoc
= parseExport("word/header2.xml");
622 CPPUNIT_ASSERT(pXmlDoc
) ;
623 assertXPath(pXmlDoc
, "/w:hdr/w:tbl[1]/w:tr[1]/w:tc[1]",1);
625 // tdf#116549: header paragraph should not have a bottom border.
626 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName("First Page"), "HeaderText");
627 table::BorderLine2 aHeaderBottomBorder
= getProperty
<table::BorderLine2
>( getParagraphOfText( 1, xHeaderText
), "BottomBorder");
628 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), aHeaderBottomBorder
.LineWidth
);
631 CPPUNIT_TEST_FIXTURE(Test
, testDateControl
)
633 loadAndSave("date-control.docx");
635 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
636 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date", "fullDate", "2014-03-05T00:00:00Z");
637 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:dateFormat", "val", "dddd, dd' de 'MMMM' de 'yyyy");
638 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:lid", "val", "es-ES");
639 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", u
"mi\u00E9rcoles, 05 de marzo de 2014");
642 CPPUNIT_TEST_FIXTURE(Test
, test_Tdf115030
)
644 loadAndSave("tdf115030.docx");
645 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
646 sal_Unicode aDot
= {0x02D9};
647 sal_Unicode aDobleDot
= {0x00A8};
648 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/m:oMath[1]/m:acc/m:accPr/m:chr", "val", OUString(aDot
));
649 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/m:oMath[2]/m:acc/m:accPr/m:chr", "val", OUString(aDobleDot
));
650 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/m:oMathPara/m:oMath[1]/m:acc/m:accPr/m:chr", "val", OUString(aDot
));
653 CPPUNIT_TEST_FIXTURE(Test
, test_OpeningBrace
)
655 loadAndSave("2120112713_OpenBrace.docx");
656 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
657 // Checking for OpeningBrace tag
658 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[1]/m:dPr[1]/m:begChr[1]","val","");
661 CPPUNIT_TEST_FIXTURE(Test
, test_Tdf132305
)
663 loadAndSave("tdf132305.docx");
664 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
665 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/m:oMath[1]/m:bar/m:barPr/m:pos","val","top");
668 // Checks that all runs of the field have text properties.
669 // Old behaviour: only first run has text properties of the field
671 // There are several runs are used in fields:
674 // <!-- properties written with DocxAttributeOutput::StartRunProperties() / DocxAttributeOutput::EndRunProperties().
676 // <w:fldChar w:fldCharType="begin" />
680 // <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
682 // <w:instrText>TIME \@"HH:mm:ss"</w:instrText>
686 // <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
688 // <w:fldChar w:fldCharType="separate" />
692 // <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
694 // <w:t>14:01:13</w:t>
698 // <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
700 // <w:fldChar w:fldCharType="end" />
703 CPPUNIT_TEST_FIXTURE(Test
, testTdf38778
)
705 loadAndSave("tdf38778_properties_in_run_for_field.doc");
706 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
708 static const OUStringLiteral
psz(u
"20");
709 static const OUStringLiteral
pszCs(u
"20");
711 // w:fldCharType="begin"
712 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[3]/w:rPr/w:sz", "val", psz
);
713 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[3]/w:rPr/w:szCs", "val", pszCs
);
716 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[4]/w:rPr/w:sz", "val", psz
);
717 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[4]/w:rPr/w:szCs", "val", pszCs
);
718 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[4]/w:instrText", " PAGE ");
720 // w:fldCharType="separate"
721 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[5]/w:rPr/w:sz", "val", psz
);
722 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[5]/w:rPr/w:szCs", "val", pszCs
);
725 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[6]/w:rPr/w:sz", "val", psz
);
726 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[6]/w:rPr/w:szCs", "val", pszCs
);
727 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[6]/w:t", "1"); // field result
729 // w:fldCharType="end"
730 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[7]/w:rPr/w:sz", "val", psz
);
731 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[7]/w:rPr/w:szCs", "val", pszCs
);
733 // tdf#127862: page fill color (in this case white) was lost
734 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY
);
735 CPPUNIT_ASSERT(drawing::FillStyle_NONE
!= getProperty
<drawing::FillStyle
>(xStyle
, "FillStyle"));
738 CPPUNIT_TEST_FIXTURE(Test
, testFDO76312
)
740 loadAndSave("FDO76312.docx");
741 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
743 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]");
746 void Test::verifyComboBoxExport(bool aComboBoxAsDropDown
)
748 if (aComboBoxAsDropDown
)
750 // ComboBox was imported as DropDown text field
751 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
752 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
753 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
754 CPPUNIT_ASSERT(xFields
->hasMoreElements());
755 uno::Any aField
= xFields
->nextElement();
756 uno::Reference
<lang::XServiceInfo
> xServiceInfo(aField
, uno::UNO_QUERY
);
757 CPPUNIT_ASSERT(xServiceInfo
->supportsService("com.sun.star.text.textfield.DropDown"));
759 uno::Sequence
<OUString
> aItems
= getProperty
< uno::Sequence
<OUString
> >(aField
, "Items");
760 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aItems
.getLength());
761 CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems
[0]);
762 CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems
[1]);
763 CPPUNIT_ASSERT_EQUAL(OUString("Manolo"), aItems
[2]);
767 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
768 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
769 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
770 uno::Reference
<drawing::XControlShape
> xControl(xShape
, uno::UNO_QUERY
);
772 CPPUNIT_ASSERT_EQUAL(OUString("Manolo"), getProperty
<OUString
>(xControl
->getControl(), "Text"));
774 uno::Sequence
<OUString
> aItems
= getProperty
< uno::Sequence
<OUString
> >(xControl
->getControl(), "StringItemList");
775 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aItems
.getLength());
776 CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems
[0]);
777 CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems
[1]);
781 CPPUNIT_TEST_FIXTURE(Test
, testComboBoxControl
)
783 loadAndSave("combobox-control.docx");
785 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
786 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[1]", "value", "manolo");
787 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[2]", "value", "pepito");
788 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "Manolo");
790 // check imported control
791 verifyComboBoxExport(getShapes() == 0);
794 CPPUNIT_TEST_FIXTURE(Test
, tdf134043_ImportComboBoxAsDropDown_true
)
796 std::shared_ptr
< comphelper::ConfigurationChanges
> batch(comphelper::ConfigurationChanges::create());
797 officecfg::Office::Writer::Filter::Import::DOCX::ImportComboBoxAsDropDown::set(true, batch
);
800 createSwDoc("combobox-control.docx");
801 verifyComboBoxExport(true);
804 CPPUNIT_TEST_FIXTURE(Test
, tdf134043_ImportComboBoxAsDropDown_false
)
806 std::shared_ptr
< comphelper::ConfigurationChanges
> batch(comphelper::ConfigurationChanges::create());
807 officecfg::Office::Writer::Filter::Import::DOCX::ImportComboBoxAsDropDown::set(false, batch
);
810 createSwDoc("combobox-control.docx");
811 verifyComboBoxExport(false);
814 CPPUNIT_TEST_FIXTURE(Test
, testCheckBoxControl
)
816 loadAndSave("checkbox-control.docx");
818 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
819 assertXPath(pXmlDoc
, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:checked", "val", "1");
820 assertXPath(pXmlDoc
, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:checkedState", "val", "2612");
821 assertXPath(pXmlDoc
, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:uncheckedState", "val", "2610");
823 // TODO: import control and add a check here
826 CPPUNIT_TEST_FIXTURE(Test
, testParagraphWithComments
)
828 loadAndSave("paragraphWithComments.docx");
829 /* Comment id's were getting overwritten for annotation mark(s),
830 which was causing a mismatch in the relationship for comment id's
831 in document.xml and comment.xml
833 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
834 xmlDocUniquePtr pXmlComm
= parseExport("word/comments.xml");
836 sal_Int32 idInDocXml
= getXPath(pXmlDoc
,"/w:document/w:body/w:p[3]/w:commentRangeEnd[1]","id").toInt32();
837 sal_Int32 idInCommentXml
= getXPath(pXmlComm
,"/w:comments/w:comment[1]","id").toInt32();
838 CPPUNIT_ASSERT_EQUAL( idInDocXml
, idInCommentXml
);
841 CPPUNIT_TEST_FIXTURE(Test
, testTdf104707_urlComment
)
843 loadAndReload("tdf104707_urlComment.odt");
844 CPPUNIT_ASSERT_EQUAL(1, getPages());
845 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
846 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
847 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
848 auto aField1
= xFields
->nextElement();
849 // the comment/annotation/postit text
850 auto xText
= getProperty
< uno::Reference
<text::XText
> >(aField1
, "TextRange");
851 // the hyperlink within the comment text
852 auto xURLField
= getProperty
< uno::Reference
<text::XTextField
> >(xText
, "TextField");
853 auto aURL
= getProperty
< OUString
>(xURLField
, "URL");
854 CPPUNIT_ASSERT_EQUAL(OUString("https://bugs.documentfoundation.org/show_bug.cgi?id=104707"), aURL
);
857 CPPUNIT_TEST_FIXTURE(Test
, testOLEObjectinHeader
)
859 loadAndSave("2129393649.docx");
860 // fdo#76015 : Document contains oleobject in header xml.
861 // Problem was relationship entry for oleobject from header was
862 // exported into document.xml.rels file because of this rels file
863 // for headers were missing from document/word/rels.
864 xmlDocUniquePtr pXmlDoc
= parseExport("word/_rels/header2.xml.rels");
866 assertXPath(pXmlDoc
,"/rels:Relationships/rels:Relationship[1]","Id","rId1");
868 xmlDocUniquePtr pXmlDocCT
= parseExport("[Content_Types].xml");
870 // check the media type too
871 assertXPath(pXmlDocCT
,
872 "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.bin']",
874 "application/vnd.openxmlformats-officedocument.oleObject");
876 // check the content too
877 xmlDocUniquePtr pXmlDocHeader2
= parseExport("word/header2.xml");
878 assertXPath(pXmlDocHeader2
,
879 "/w:hdr/w:tbl/w:tr[1]/w:tc[2]/w:p[1]/w:r/w:object/o:OLEObject",
882 xmlDocUniquePtr pXmlDocHeader3
= parseExport("word/header3.xml");
883 assertXPath(pXmlDocHeader2
,
884 "/w:hdr/w:tbl/w:tr[1]/w:tc[2]/w:p[1]/w:r/w:object/o:OLEObject",
889 CPPUNIT_TEST_FIXTURE(Test
, test_ClosingBrace
)
891 loadAndSave("2120112713.docx");
892 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
893 // Checking for ClosingBrace tag
894 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[2]/m:dPr[1]/m:endChr[1]","val","");
897 CPPUNIT_TEST_FIXTURE(Test
, testlvlPicBulletId
)
899 loadAndSave("lvlPicBulletId.docx");
900 xmlDocUniquePtr pXmlDoc
= parseExport("word/numbering.xml");
901 assertXPath(pXmlDoc
, "/w:numbering[1]/w:abstractNum[1]/w:lvl[1]/w:lvlPicBulletId[1]", 0);
904 CPPUNIT_TEST_FIXTURE(Test
, testSdtContent
)
906 loadAndSave("SdtContent.docx");
907 xmlDocUniquePtr pXmlDoc
= parseExport("word/header1.xml");
908 // assertXPath(pXmlDoc, "/w:hdr[1]/w:p[1]/w:sdt/w:sdtContent[1]/w:del[1]");
912 // Currently LibreOffice exports custom geometry for this up arrow, not preset shape.
913 // When LibreOffice can export preset shape with correct modifiers, then this test can be re-enabled.
915 CPPUNIT_TEST_FIXTURE(Test
, testFdo76016
)
917 loadAndSave("fdo76016.docx");
919 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
920 assertXPath(pXmlDoc
, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]", "name", "adj1");
921 assertXPath(pXmlDoc
, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]", "name", "adj2");
925 CPPUNIT_TEST_FIXTURE(Test
, testFileWithInvalidImageLink
)
927 loadAndSave("FileWithInvalidImageLink.docx");
928 /* In case if the original file has an image whose link is
929 invalid, then the RT file used to result in corruption
930 since the exported image would be an empty image.
932 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
934 assertXPathNoAttribute(pXmlDoc
,
935 "/w:document/w:body/w:p[2]/w:r[2]/w:drawing[1]/wp:inline[1]/"
936 "a:graphic[1]/a:graphicData[1]/pic:pic[1]/pic:blipFill[1]/a:blip[1]",
940 CPPUNIT_TEST_FIXTURE(Test
, testContentTypeDOCX
)
942 loadAndSave("fdo80410.docx");
943 xmlDocUniquePtr pXmlDoc
= parseExport("[Content_Types].xml");
946 "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.docx']",
948 "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
949 // check the rels too
950 xmlDocUniquePtr pXmlDocRels
= parseExport("word/_rels/document.xml.rels");
951 assertXPath(pXmlDocRels
,
952 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.docx']",
954 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
955 // check the content too
956 xmlDocUniquePtr pXmlDocContent
= parseExport("word/document.xml");
957 assertXPath(pXmlDocContent
,
958 "/w:document/w:body/w:p[6]/w:r/w:object/o:OLEObject",
963 CPPUNIT_TEST_FIXTURE(Test
, testContentTypeXLSM
)
965 loadAndSave("fdo76098.docx");
966 xmlDocUniquePtr pXmlDoc
= parseExport("[Content_Types].xml");
968 assertXPath(pXmlDoc
, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "ContentType", "application/vnd.ms-excel.sheet.macroEnabled.12");
970 // check the rels too
971 xmlDocUniquePtr pXmlDocRels
= parseExport("word/charts/_rels/chart1.xml.rels");
972 assertXPath(pXmlDocRels
,
973 "/rels:Relationships/rels:Relationship[@Target='../embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']",
975 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
976 // check the content too
977 xmlDocUniquePtr pXmlDocChart1
= parseExport("word/charts/chart1.xml");
978 assertXPath(pXmlDocChart1
,
979 "/c:chartSpace/c:externalData",
984 CPPUNIT_TEST_FIXTURE(Test
, test76108
)
986 loadAndSave("test76108.docx");
987 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
988 //docx file after RT is getting corrupted.
989 assertXPath(pXmlDoc
, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:fldChar[1]", "fldCharType", "begin");
992 CPPUNIT_TEST_FIXTURE(Test
, testTCTagMisMatch
)
994 loadAndSave("TCTagMisMatch.docx");
995 // TCTagMisMatch.docx : This document contains an empty table with borders.
996 // there was a TC tag mismatch which resulted into a crash.
998 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
999 assertXPath(pXmlDoc
,"/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl[1]/w:tr[1]/w:tc[1]",0);
1000 assertXPath(pXmlDoc
,"/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]", 1);
1003 CPPUNIT_TEST_FIXTURE(Test
, testFDO78292
)
1005 loadAndSave("FDO78292.docx");
1006 //text node is a leaf node, it should not have any children
1007 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1008 assertXPath(pXmlDoc
,"/w:document/w:body/w:p[14]/w:sdt[3]/w:sdtPr[1]/w:text/w14:checked",0);
1011 CPPUNIT_TEST_FIXTURE(Test
, testSimpleSdts
)
1013 loadAndSave("simple-sdts.docx");
1014 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1016 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:sdt/w:sdtPr/w:text", 1);
1017 assertXPath(pXmlDoc
, "//*/w:sdt/w:sdtPr/w:id", 5);
1018 assertXPath(pXmlDoc
, "//w:sdt/w:sdtPr/w:lock", 1);
1019 assertXPath(pXmlDoc
, "/w:document/w:body/w:sdt[1]/w:sdtPr/w:picture", 1);
1020 assertXPath(pXmlDoc
, "/w:document/w:body/w:sdt[2]/w:sdtPr/w:group", 1);
1021 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/w:sdt/w:sdtPr/w:citation", 1);
1024 CPPUNIT_TEST_FIXTURE(Test
, testEmbeddedExcelChart
)
1026 loadAndSave("EmbeddedExcelChart.docx");
1027 xmlDocUniquePtr pXmlDoc
= parseExport("[Content_Types].xml");
1029 assertXPath(pXmlDoc
,
1030 "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.xls']",
1032 "application/vnd.ms-excel");
1034 // check the rels too
1035 xmlDocUniquePtr pXmlDocRels
= parseExport("word/_rels/document.xml.rels");
1036 assertXPath(pXmlDocRels
,
1037 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xls']",
1039 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject");
1041 // check the content too
1042 xmlDocUniquePtr pXmlDocContent
= parseExport("word/document.xml");
1043 assertXPath(pXmlDocContent
,
1044 "/w:document/w:body/w:p/w:r/w:object/o:OLEObject",
1049 CPPUNIT_TEST_FIXTURE(Test
, testTdf83227
)
1051 loadAndReload("tdf83227.docx");
1052 // Bug document contains a rotated image, which is handled as a draw shape (not as a Writer image) on export.
1053 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
1054 CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess
->hasByName("word/media/image1.png")));
1055 // This was also true, image was written twice.
1056 CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess
->hasByName("word/media/image2.png")));
1059 CPPUNIT_TEST_FIXTURE(Test
, testTdf103001
)
1061 loadAndReload("tdf103001.docx");
1062 // The same image is featured in the header and in the body text, make sure
1063 // the header relation is still written, even when caching is enabled.
1064 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
1065 // This failed: header reused the RelId of the body text, even if RelIds
1066 // are local to their stream.
1067 CPPUNIT_ASSERT(xNameAccess
->hasByName("word/_rels/header2.xml.rels"));
1070 CPPUNIT_TEST_FIXTURE(Test
, testTdf92521
)
1072 loadAndSave("tdf92521.odt");
1073 CPPUNIT_ASSERT_EQUAL(2, getPages());
1074 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1075 // There should be a section break that's in the middle of the document: right after the table.
1076 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:pPr/w:sectPr", 1);
1079 DECLARE_OOXMLEXPORT_TEST(testTdf102466
, "tdf102466.docx")
1081 // the problem was: file is truncated: the first page is missing.
1082 // More precisely, the table in the first page was clipped.
1084 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
1085 sal_Int32 nFlyPrtHeight
= getXPath(pXmlDoc
, "(/root/page[1]//anchored/fly)[1]/infos/prtBounds", "height").toInt32();
1086 sal_Int32 nTableHeight
= getXPath(pXmlDoc
, "(/root/page[1]//anchored/fly)[1]/tab/infos/bounds", "height").toInt32();
1087 CPPUNIT_ASSERT_MESSAGE("The table is clipped in a fly frame.", nFlyPrtHeight
>= nTableHeight
);
1090 // check how much pages we have: it should match the Word layout result
1091 CPPUNIT_ASSERT_EQUAL(11, getPages());
1093 // check content of the first page
1095 uno::Reference
<beans::XPropertySet
> xFrame(getShapeByName(u
"Marco1"), uno::UNO_QUERY
);
1098 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xFrame
, "LineWidth"));
1101 // Make sure we have 19 tables created
1103 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1104 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables( ), uno::UNO_QUERY
);
1105 CPPUNIT_ASSERT_EQUAL(sal_Int32(19), xTables
->getCount( ));
1107 // check the text inside first cell of the first table
1108 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1109 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1111 const OUString aActualText
= xCell
->getString();
1113 CPPUNIT_ASSERT(aActualText
.indexOf("Requerimientos del Cliente") > 0);
1117 CPPUNIT_TEST_FIXTURE(Test
, testTdf99090_pgbrkAfterTable
)
1119 loadAndSave("tdf99090_pgbrkAfterTable.docx");
1120 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1121 // There should be a regular page break that's in the middle of the document: right after the table.
1122 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:br", 1);
1125 DECLARE_OOXMLEXPORT_TEST(testTdf96750_landscapeFollow
, "tdf96750_landscapeFollow.docx")
1127 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY
);
1128 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStyle
, "IsLandscape"));
1131 DECLARE_OOXMLEXPORT_TEST(testTdf86926_A3
, "tdf86926_A3.docx")
1133 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY
);
1134 CPPUNIT_ASSERT_EQUAL(sal_Int32(42000), getProperty
<sal_Int32
>(xStyle
, "Height"));
1135 CPPUNIT_ASSERT_EQUAL(sal_Int32(29700), getProperty
<sal_Int32
>(xStyle
, "Width"));
1138 DECLARE_OOXMLEXPORT_TEST(testTdf64372_continuousBreaks
,"tdf64372_continuousBreaks.docx")
1140 //There are no page breaks, so everything should be on the first page.
1141 CPPUNIT_ASSERT_EQUAL(1, getPages());
1144 DECLARE_OOXMLEXPORT_TEST(testTdf92724_continuousBreaksComplex
,"tdf92724_continuousBreaksComplex.docx")
1146 //There are 2 page breaks, so there should be 3 pages.
1147 CPPUNIT_ASSERT_EQUAL(3, getPages());
1150 DECLARE_OOXMLEXPORT_TEST(testTdf90697_continuousBreaksComplex2
,"tdf92724_continuousBreaksComplex2.docx")
1152 // Continuous section breaks with new headers/footers should not immediately switch to a new page style.
1153 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
1154 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
1155 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(), uno::UNO_QUERY
);
1156 xCursor
->jumpToLastPage();
1158 sal_Int16 nPages
= xCursor
->getPage();
1161 OUString sPageStyleName
= getProperty
<OUString
>( xCursor
, "PageStyleName" );
1162 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName(sPageStyleName
), "HeaderText");
1163 // Specific case to avoid. Testing separately (even though redundant).
1164 // The first header (defined on page 3) ONLY is shown IF the section happens to start on a new page (which it doesn't in this document).
1165 CPPUNIT_ASSERT( xHeaderText
->getString() != "Third section - First page header. No follow defined" );
1166 // Same test stated differently: Pages 4 and 5 OUGHT to use "Second section header", but currently don't. Page 6 does.
1168 CPPUNIT_ASSERT_EQUAL( OUString("First section header"), xHeaderText
->getString() );
1170 CPPUNIT_ASSERT( xHeaderText
->getString() == "First section header" || xHeaderText
->getString() == "Second section header" );
1172 xCursor
->jumpToPage( --nPages
);
1176 DECLARE_OOXMLEXPORT_TEST(testTdf95367_inheritFollowStyle
, "tdf95367_inheritFollowStyle.docx")
1178 CPPUNIT_ASSERT_EQUAL(OUString("header"), parseDump("/root/page[2]/header/txt/text()"));
1181 DECLARE_OOXMLEXPORT_TEST(testInheritFirstHeader
,"inheritFirstHeader.docx")
1183 // First page headers always link to last used first header, never to a follow header
1184 CPPUNIT_ASSERT_EQUAL(OUString("First Header"), parseDump("/root/page[1]/header/txt/text()"));
1185 CPPUNIT_ASSERT_EQUAL(OUString("Follow Header"), parseDump("/root/page[2]/header/txt/text()"));
1186 CPPUNIT_ASSERT_EQUAL(OUString("Follow Header"), parseDump("/root/page[3]/header/txt/text()"));
1187 CPPUNIT_ASSERT_EQUAL(OUString("First Header"), parseDump("/root/page[4]/header/txt/text()"));
1188 CPPUNIT_ASSERT_EQUAL(OUString("Last Header"), parseDump("/root/page[5]/header/txt/text()"));
1192 DECLARE_OOXMLEXPORT_TEST(testTdf81345_045Original
, "tdf81345.docx")
1194 //Header wasn't replaced and columns were missing because no new style was created.
1195 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
1196 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
1197 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(), uno::UNO_QUERY
);
1199 xCursor
->jumpToLastPage();
1200 OUString pageStyleName
= getProperty
<OUString
>(xCursor
, "PageStyleName");
1201 CPPUNIT_ASSERT(pageStyleName
!= "Standard");
1203 // tdf89297 Styles were being added before their base/parent/inherited-from style existed, and so were using default settings.
1204 uno::Reference
<container::XNameAccess
> xParaStyles(getStyles("ParagraphStyles"));
1205 uno::Reference
<beans::XPropertySet
> xStyle(xParaStyles
->getByName("Pull quote"), uno::UNO_QUERY
);
1206 CPPUNIT_ASSERT_EQUAL(sal_Int32(6736947), getProperty
<sal_Int32
>(xStyle
, "CharColor"));
1210 CPPUNIT_TEST_FIXTURE(Test
, testDocxTablePosition
)
1212 loadAndSave("floating-table-position.docx");
1213 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1215 // the exported positions were wrong due to some missing shifting in the export code
1216 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpX", "3494");
1217 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpY", "4611");
1221 CPPUNIT_TEST_FIXTURE(Test
, testUnderlineGroupShapeText
)
1223 loadAndSave("tdf123351_UnderlineGroupSapeText.docx");
1224 // tdf#123351: Check if correct underline is used.
1225 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
1227 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
1228 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "single");
1229 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
1230 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "double");
1232 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor"
1233 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "thick");
1234 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor"
1235 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dotted");
1237 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor"
1238 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dottedHeavy");
1239 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor"
1240 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dash");
1242 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor"
1243 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dashedHeavy");
1245 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[5]/mc:Choice/w:drawing/wp:anchor"
1246 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r[1]/w:rPr/w:u", "val", "dashLongHeavy");
1247 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[5]/mc:Choice/w:drawing/wp:anchor"
1248 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dotDash");
1250 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[6]/mc:Choice/w:drawing/wp:anchor"
1251 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dashDotHeavy");
1252 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[6]/mc:Choice/w:drawing/wp:anchor"
1253 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dotDotDash");
1255 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor"
1256 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dashDotDotHeavy");
1257 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor"
1258 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "wave");
1260 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[8]/mc:Choice/w:drawing/wp:anchor"
1261 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "wavyHeavy");
1262 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[8]/mc:Choice/w:drawing/wp:anchor"
1263 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "wavyDouble");
1265 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[32]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
1266 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "none");
1268 // TODO: Import of "words".
1269 // This must fail when import of "words" is implemented. This is a temporary solution, we read "words" as "single".
1270 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[32]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
1271 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "single");
1274 CPPUNIT_TEST_FIXTURE(Test
, testUnderlineColorGroupedShapes
)
1276 loadAndSave("tdf132491_UnderlineColorGroupedShapes.docx");
1277 // tdf#132491 : Check if correct color is used for underline.
1278 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
1279 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
1280 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "color", "FF0000");
1281 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
1282 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "color", "00B050");
1283 assertXPathNoAttribute(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
1284 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[3]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "color");
1287 CPPUNIT_TEST_FIXTURE(Test
, testRelativeAnchorWidthFromRightMargin
)
1289 loadAndSave("tdf133670_testRelativeAnchorWidthFromRightMargin.docx");
1290 // tdf#133670 The width was set relative from right margin, but this was handled relative from page width.
1291 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
1292 auto nWidth
= getXPath(pXmlDoc
, "//anchored/SwAnchoredDrawObject/bounds", "width").toInt32();
1293 CPPUNIT_ASSERT_DOUBLES_EQUAL(2408, nWidth
, 1);
1296 CPPUNIT_TEST_FIXTURE(Test
, testAutoFitForLegacyShapes
)
1298 loadAndSave("tdf112312_AutoFitForLegacyShapes.odt");
1299 // tdf#112312: check if noAutoFit is used instead of spAutoFit even if the TextAutoGrowHeight is set
1300 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
1301 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
1302 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr/a:noAutofit");
1303 assertXPathNoAttribute(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
1304 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr", "a:spAutofit");
1307 CPPUNIT_PLUGIN_IMPLEMENT();
1309 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */