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>
29 #include <comphelper/scopeguard.hxx>
31 class Test
: public SwModelTestBase
34 Test() : SwModelTestBase(u
"/sw/qa/extras/ooxmlexport/data/"_ustr
, u
"Office Open XML Text"_ustr
) {}
37 void verifyComboBoxExport(bool aComboBoxAsDropDown
);
40 CPPUNIT_TEST_FIXTURE(Test
, testRelorientation
)
42 auto verify
= [this](bool bIsExport
= false) {
43 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
44 // This was text::RelOrientation::FRAME, when handling relativeFrom=page, align=right
45 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xShape
, u
"HoriOrientRelation"_ustr
));
47 uno::Reference
<drawing::XShapes
> xGroup(xShape
, uno::UNO_QUERY
);
48 // This resulted in lang::IndexOutOfBoundsException, as nested groupshapes weren't handled.
49 uno::Reference
<drawing::XShapeDescriptor
> xShapeDescriptor(xGroup
->getByIndex(0), uno::UNO_QUERY
);
50 CPPUNIT_ASSERT_EQUAL(u
"com.sun.star.drawing.GroupShape"_ustr
, xShapeDescriptor
->getShapeType());
52 // 'actual child size' = 'group ext' * 'child ext' / 'chExt from group', see section 'chExt' in
53 // [MS-OI29500]. Here for width from file 3108960 * 4896 / 4911 = 3099464 EMU. That corresponds to
54 // width 8.61cm and 325px in UI in Word and rounds down to 8609 Hmm. Considering scaling of the
55 // parent group to the anchor extent (* 3118485 / 3108960) we get a display width of 3108960 EMU
56 // = 8636Hmm. FIXME: Expected value is as in LO 7.2. Reason for difference is yet unknown.
59 uno::Reference
<drawing::XShape
> xYear(xGroup
->getByIndex(1), uno::UNO_QUERY
);
60 // This was 2, due to incorrect handling of parent transformations inside DML groupshapes.
61 CPPUNIT_ASSERT_EQUAL(sal_Int32(8662), xYear
->getSize().Width
);
65 createSwDoc("relorientation.docx");
67 saveAndReload(mpFilter
);
68 verify(/*bIsExport*/ true);
71 CPPUNIT_TEST_FIXTURE(Test
, testBezier
)
73 loadAndReload("bezier.odt");
74 CPPUNIT_ASSERT_EQUAL(1, getPages());
75 // Check that no shape got lost: a bezier, a line and a text shape.
76 CPPUNIT_ASSERT_EQUAL(3, getShapes());
79 DECLARE_OOXMLEXPORT_TEST(testGroupshapeTextbox
, "groupshape-textbox.docx")
81 uno::Reference
<drawing::XShapes
> xGroup(getShape(1), uno::UNO_QUERY
);
82 uno::Reference
<text::XTextRange
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
83 // The VML export lost text on textboxes inside groupshapes.
84 // The DML export does not, make sure it stays that way.
85 CPPUNIT_ASSERT_EQUAL(u
"first"_ustr
, xShape
->getString());
86 // This was 16, i.e. inheriting doc default char height didn't work.
87 CPPUNIT_ASSERT_EQUAL(11.f
, getProperty
<float>(getParagraphOfText(1, xShape
->getText()), u
"CharHeight"_ustr
));
90 DECLARE_OOXMLEXPORT_TEST(testGroupshapePicture
, "groupshape-picture.docx")
92 // Picture in the groupshape got lost, groupshape had only one child.
93 uno::Reference
<drawing::XShapes
> xGroup(getShape(1), uno::UNO_QUERY
);
94 uno::Reference
<drawing::XShapeDescriptor
> xShapeDescriptor(xGroup
->getByIndex(1), uno::UNO_QUERY
);
95 CPPUNIT_ASSERT_EQUAL(u
"com.sun.star.drawing.GraphicObjectShape"_ustr
, xShapeDescriptor
->getShapeType());
98 DECLARE_OOXMLEXPORT_TEST(testAutofit
, "autofit.docx")
100 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getShape(1), u
"TextAutoGrowHeight"_ustr
));
101 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(getShape(2), u
"TextAutoGrowHeight"_ustr
));
104 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesDeletedParagraphMark
)
106 loadAndSave("testTrackChangesDeletedParagraphMark.docx");
107 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
108 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:del");
111 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesInsertedParagraphMark
)
113 loadAndSave("testTrackChangesInsertedParagraphMark.docx");
114 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
115 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:ins");
118 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesDeletedTableRow
)
120 loadAndSave("testTrackChangesDeletedTableRow.docx");
121 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
122 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:del");
125 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesInsertedTableRow
)
127 loadAndSave("testTrackChangesInsertedTableRow.docx");
128 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
129 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:ins");
132 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesDeletedTableCell
)
134 loadAndSave("testTrackChangesDeletedTableCell.docx");
135 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
136 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellDel");
139 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesInsertedTableCell
)
141 loadAndSave("testTrackChangesInsertedTableCell.docx");
142 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
143 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellIns");
146 DECLARE_OOXMLEXPORT_TEST(testTextBoxPictureFill
, "textbox_picturefill.docx")
148 uno::Reference
<beans::XPropertySet
> xFrame(getShape(1), uno::UNO_QUERY
);
149 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, getProperty
<drawing::FillStyle
>(xFrame
, u
"FillStyle"_ustr
));
150 auto xBitmap
= getProperty
<uno::Reference
<awt::XBitmap
>>(xFrame
, u
"FillBitmap"_ustr
);
151 CPPUNIT_ASSERT(xBitmap
.is());
152 uno::Reference
<graphic::XGraphic
> xGraphic(xBitmap
, uno::UNO_QUERY
);
153 CPPUNIT_ASSERT(xGraphic
.is());
154 Graphic
aGraphic(xGraphic
);
155 CPPUNIT_ASSERT(!aGraphic
.IsNone());
156 CPPUNIT_ASSERT(aGraphic
.GetSizeBytes() > 0L);
157 CPPUNIT_ASSERT_EQUAL(tools::Long(447), aGraphic
.GetSizePixel().Width());
158 CPPUNIT_ASSERT_EQUAL(tools::Long(528), aGraphic
.GetSizePixel().Height());
161 CPPUNIT_TEST_FIXTURE(Test
, testFDO73034
)
163 loadAndSave("FDO73034.docx");
164 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
165 CPPUNIT_ASSERT(getXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:u", "val").match("single"));
168 CPPUNIT_TEST_FIXTURE(Test
, testFDO71834
)
170 loadAndSave("fdo71834.docx");
171 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
172 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr[2]/w:tc[1]/w:tcPr[1]/w:tcW[1]","type", u
"dxa");
175 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesParagraphProperties
)
177 loadAndSave("testTrackChangesParagraphProperties.docx");
178 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
179 assertXPathChildren(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:pPrChange", 0);
182 CPPUNIT_TEST_FIXTURE(Test
, testMsoSpt180
)
184 loadAndReload("mso-spt180.docx");
185 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
186 const uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(xGroup
->getByIndex(0), u
"CustomShapeGeometry"_ustr
);
188 for (beans::PropertyValue
const & prop
: aProps
)
189 if (prop
.Name
== "Type")
190 aType
= prop
.Value
.get
<OUString
>();
191 // This was exported as borderCallout90, which is an invalid drawingML preset shape string.
192 CPPUNIT_ASSERT_EQUAL(u
"ooxml-borderCallout1"_ustr
, aType
);
195 CPPUNIT_TEST_FIXTURE(Test
, testFdo73550
)
197 loadAndSave("fdo73550.docx");
198 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
199 // This was wrap="none".
200 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:rFonts");
203 DECLARE_OOXMLEXPORT_TEST(testPageRelSize
, "pagerelsize.docx")
205 // First shape: width is relative from page, but not height.
206 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
207 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xShape
, u
"RelativeWidthRelation"_ustr
));
208 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME
, getProperty
<sal_Int16
>(xShape
, u
"RelativeHeightRelation"_ustr
));
210 // Second shape: height is relative from page, but not height.
211 xShape
= getShape(2);
212 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xShape
, u
"RelativeHeightRelation"_ustr
));
213 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME
, getProperty
<sal_Int16
>(xShape
, u
"RelativeWidthRelation"_ustr
));
216 DECLARE_OOXMLEXPORT_TEST(testRelSizeRound
, "rel-size-round.docx")
218 // This was 9: 9.8 was imported as 9 instead of being rounded to 10.
219 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty
<sal_Int16
>(getShape(1), u
"RelativeHeight"_ustr
));
222 DECLARE_OOXMLEXPORT_TEST(testTestTitlePage
, "testTitlePage.docx")
224 // this has 2 pages in Word
225 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
226 assertXPathContent(pXmlDoc
, "/root/page[2]/footer/txt/text()", u
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
229 DECLARE_OOXMLEXPORT_TEST(testTableRowDataDisplayedTwice
, "table-row-data-displayed-twice.docx")
231 // fdo#73534: There was a problem for some documents during export.Invalid sectPr getting added
232 // because of wrong condition in code.
233 // This was the reason for increasing number of pages after RT
234 CPPUNIT_ASSERT_EQUAL(2, getPages());
237 CPPUNIT_TEST_FIXTURE(Test
, testFdo73556
)
239 loadAndSave("fdo73556.docx");
241 * The file contains a table with 3 columns
242 * the gridcols are as follows: {1210, 1331, 1210}
243 * whereas the individual cells have {1210, 400, 1210}
244 * The table column separators were taken from the Grid, while
245 * the table width was calculated as 2820 from cells instead
246 * of 3751 from the Grid.
248 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
249 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol", 3);
250 sal_Int32 tableWidth
= 0;
251 tableWidth
+= getXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[1]", "w").toInt32();
252 tableWidth
+= getXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32();
253 tableWidth
+= getXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[3]", "w").toInt32();
254 CPPUNIT_ASSERT_EQUAL(sal_Int32(3751), tableWidth
);
257 CPPUNIT_TEST_FIXTURE(Test
, testSegFaultWhileSave
)
259 loadAndSave("test_segfault_while_save.docx");
261 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
262 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(6137), getXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32());
265 CPPUNIT_TEST_FIXTURE(Test
, fdo69656
)
267 loadAndSave("Table_cell_auto_width_fdo69656.docx");
268 // Changed the UT to check "dxa" instead of "auto"
269 // For this particular issue file few cells have width type "auto"
270 // LO supports VARIABLE and FIXED width type.
271 // If type is VARIABLE LO calculates width as percent of PageSize
272 // Else if the width is fixed it uses the width value.
273 // After changes for fdo76741 the fixed width is exported as "dxa" for DOCX
275 // Check for the width type of table and its cells.
276 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
277 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblPr/w:tblW","type",u
"dxa");
280 CPPUNIT_TEST_FIXTURE(Test
, testFdo76741
)
282 loadAndSave("fdo76741.docx");
284 // There are two issue related to table in the saved(exported) file
285 // - the table alignment in saved file is "left" instead of "center"
286 // - the table width type in properties is "auto" instead of "dxa"
288 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
290 assertXPath(pXmlDoc
, "//w:jc", "val", u
"center");
291 assertXPath(pXmlDoc
, "//w:tblW", "w", u
"10081");
292 assertXPath(pXmlDoc
, "//w:tblW", "type", u
"dxa");
295 CPPUNIT_TEST_FIXTURE(Test
, testFdo73541
)
297 loadAndSave("fdo73541.docx");
298 // fdo#73541: The mirrored margins were not imported and mapped correctly in Page Layout
299 // Hence <w:mirrorMargins /> tag was not exported back in settings.xml
300 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/settings.xml"_ustr
);
301 assertXPath(pXmlDoc
, "/w:settings/w:mirrorMargins");
304 CPPUNIT_TEST_FIXTURE(Test
, testFdo106029
)
306 loadAndSave("fdo106029.docx");
307 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/settings.xml"_ustr
);
308 assertXPath(pXmlDoc
, "/w:settings/w:compat/w:doNotExpandShiftReturn");
311 CPPUNIT_TEST_FIXTURE(Test
, testTdf146515
)
313 loadAndSave("tdf146515.odt");
314 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/settings.xml"_ustr
);
315 assertXPath(pXmlDoc
, "/w:settings/w:compat/w:usePrinterMetrics");
318 CPPUNIT_TEST_FIXTURE(Test
, testFDO74106
)
320 loadAndSave("FDO74106.docx");
321 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/numbering.xml"_ustr
);
322 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:numFmt", "val",u
"hebrew1");
325 CPPUNIT_TEST_FIXTURE(Test
, testFDO74215
)
327 loadAndSave("FDO74215.docx");
328 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/numbering.xml"_ustr
);
329 // tdf#106849 NumPicBullet xShape should not be resized.
331 // This is dependent on the running system: see MSWordExportBase::BulletDefinitions
332 // FIXME: the size of a bullet is defined by GraphicSize property
333 // (stored in SvxNumberFormat::aGraphicSize) so use that for the size
334 // (properly convert from 100mm to pt (1 inch is 72 pt, 1 pt is 20 twips).
336 // On 96 DPI "width:11.25pt;height:11.25pt"; on 120 DPI "width:9pt;height:9pt"
337 const OUString sStyle
338 = getXPath(pXmlDoc
, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style");
340 OUString sWidth
= sStyle
.getToken(0, ';');
341 CPPUNIT_ASSERT(sWidth
.startsWith("width:", &sWidth
));
342 CPPUNIT_ASSERT(sWidth
.endsWith("pt", &sWidth
));
343 const double fWidth
= sWidth
.toDouble();
344 const double fXScaleFactor
= 96.0 / Application::GetDefaultDevice()->GetDPIX();
345 // note: used to fail on Mac with 14.7945205479452 vs. 14.8
346 // note: used to fail on another Mac with 12.1348314606742 vs 12.15
347 CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25 * fXScaleFactor
, fWidth
, 0.1);
350 OUString sHeight
= sStyle
.getToken(1, ';');
351 CPPUNIT_ASSERT(sHeight
.startsWith("height:", &sHeight
));
352 CPPUNIT_ASSERT(sHeight
.endsWith("pt", &sHeight
));
353 const double fHeight
= sHeight
.toDouble();
354 const double fYScaleFactor
= 96.0 / Application::GetDefaultDevice()->GetDPIY();
355 CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25 * fYScaleFactor
, fHeight
, 0.1);
359 CPPUNIT_TEST_FIXTURE(Test
, testColumnBreak_ColumnCountIsZero
)
361 /* fdo73545: Column Break with Column_count = 0 was not getting preserved.
362 * The <w:br w:type="column" /> was missing after roundtrip
364 loadAndSave("fdo74153.docx");
365 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
366 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:r[1]/w:br", "type", u
"column");
368 //tdf76349 match Word's behavior of treating breaks in single columns as page breaks.
369 CPPUNIT_ASSERT_EQUAL(2, getPages());
372 DECLARE_OOXMLEXPORT_TEST(testTdf90697_complexBreaksHeaders
,"tdf90697_complexBreaksHeaders.docx")
374 // This is a complex document using many types of section breaks and re-defined headers.
375 // Paragraphs 44-47 were in two columns
376 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
< uno::Reference
<beans::XPropertySet
> >(getParagraph(45), u
"TextSection"_ustr
);
377 CPPUNIT_ASSERT(xTextSection
.is());
378 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
< uno::Reference
<text::XTextColumns
> >(xTextSection
, u
"TextColumns"_ustr
);
379 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns
->getColumnCount());
381 // after that, the section break should switch things back to one column.
382 xTextSection
= getProperty
< uno::Reference
<beans::XPropertySet
> >(getParagraph(50), u
"TextSection"_ustr
);
383 CPPUNIT_ASSERT(xTextSection
.is());
384 xTextColumns
= getProperty
< uno::Reference
<text::XTextColumns
> >(xTextSection
, u
"TextColumns"_ustr
);
385 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns
->getColumnCount());
388 CPPUNIT_TEST_FIXTURE(Test
, testIndentation
)
390 loadAndSave("test_indentation.docx");
391 // fdo#74141 :There was a problem that in style.xml and document.xml in <w:ind> tag "right" & "left" margin
392 // attributes gets added(w:right=0 & w:left=0) if these attributes are not set in original document.
393 // This test is to verify <w:ind> does not contain w:right attribute.
394 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
395 assertXPathNoAttribute(pXmlDoc
, "/w:document/w:body/w:p/w:pPr/w:ind", "end");
398 CPPUNIT_TEST_FIXTURE(Test
, testChartInFooter
)
400 loadAndSave("chart-in-footer.docx");
401 // fdo#73872: document contains chart in footer.
402 // The problem was that footer1.xml.rels files for footer1.xml
403 // files were missing from docx file after roundtrip.
404 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/_rels/footer2.xml.rels"_ustr
);
406 // Check footer2.xml.rels contains in doc after roundtrip.
407 // Check Id = rId1 in footer2.xml.rels
408 assertXPath(pXmlDoc
,"/rels:Relationships/rels:Relationship","Id",u
"rId1");
410 "/rels:Relationships/rels:Relationship[@Id='rId1']",
412 u
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart");
414 xmlDocUniquePtr pXmlDocCT
= parseExport(u
"[Content_Types].xml"_ustr
);
415 assertXPath(pXmlDocCT
,
416 "/ContentType:Types/ContentType:Override[@PartName='/word/charts/chart1.xml']",
418 u
"application/vnd.openxmlformats-officedocument.drawingml.chart+xml");
420 // check the content too
421 xmlDocUniquePtr pXmlDocFooter2
= parseExport(u
"word/footer2.xml"_ustr
);
422 assertXPath(pXmlDocFooter2
,
423 "/w:ftr/w:p[1]/w:r/w:drawing/wp:inline/a:graphic/a:graphicData",
425 u
"http://schemas.openxmlformats.org/drawingml/2006/chart");
426 assertXPath(pXmlDocFooter2
,
427 "/w:ftr/w:p[1]/w:r/w:drawing/wp:inline/a:graphic/a:graphicData/c:chart",
431 CPPUNIT_ASSERT_EQUAL(1, getShapes());
434 CPPUNIT_TEST_FIXTURE(Test
, testNestedTextFrames
)
436 loadAndReload("nested-text-frames.odt");
437 CPPUNIT_ASSERT_EQUAL(3, getShapes());
438 CPPUNIT_ASSERT_EQUAL(1, getPages());
439 // First problem was LO crashed during export (crash test)
441 // Second problem was LO made file corruption, writing out nested text boxes, which can't be handled by Word.
442 // Test that all three exported text boxes are anchored to the same paragraph and not each other.
443 uno::Reference
<text::XTextContent
> xTextContent(getShape(1), uno::UNO_QUERY
);
444 uno::Reference
<text::XTextRange
> xRange
= xTextContent
->getAnchor();
445 uno::Reference
<text::XText
> xText
= xRange
->getText();
446 CPPUNIT_ASSERT_EQUAL(u
"Anchor point"_ustr
, xText
->getString());
448 xTextContent
.set(getShape(2), uno::UNO_QUERY
);
449 xRange
= xTextContent
->getAnchor();
450 xText
= xRange
->getText();
451 CPPUNIT_ASSERT_EQUAL(u
"Anchor point"_ustr
, xText
->getString());
453 xTextContent
.set(getShape(3), uno::UNO_QUERY
);
454 xRange
= xTextContent
->getAnchor();
455 xText
= xRange
->getText();
456 CPPUNIT_ASSERT_EQUAL(u
"Anchor point"_ustr
, xText
->getString());
459 DECLARE_OOXMLEXPORT_TEST(testFloatingTablePosition
, "floating-table-position.docx")
461 // Position of shape was wrong, because some conversion was missing.
462 uno::Reference
<beans::XPropertySet
> xShape(getShape(1), uno::UNO_QUERY
);
464 CPPUNIT_ASSERT_EQUAL(sal_Int32(5964), getProperty
<sal_Int32
>(xShape
, u
"HoriOrientPosition"_ustr
));
466 CPPUNIT_ASSERT_EQUAL(sal_Int32(8133), getProperty
<sal_Int32
>(xShape
, u
"VertOrientPosition"_ustr
));
469 CPPUNIT_TEST_FIXTURE(Test
, testAbi11739
)
471 loadAndSave("abi11739.docx");
472 // Validation test: order of elements were wrong.
473 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/styles.xml"_ustr
);
474 // Order was: uiPriority, link, basedOn.
475 CPPUNIT_ASSERT(getXPathPosition(pXmlDoc
, "/w:styles/w:style[3]", "basedOn") < getXPathPosition(pXmlDoc
, "/w:styles/w:style[3]", "link"));
476 CPPUNIT_ASSERT(getXPathPosition(pXmlDoc
, "/w:styles/w:style[3]", "link") < getXPathPosition(pXmlDoc
, "/w:styles/w:style[3]", "uiPriority"));
477 // Order was: qFormat, unhideWhenUsed.
478 CPPUNIT_ASSERT(getXPathPosition(pXmlDoc
, "/w:styles/w:style[11]", "unhideWhenUsed") < getXPathPosition(pXmlDoc
, "/w:styles/w:style[11]", "qFormat"));
481 CPPUNIT_TEST_FIXTURE(Test
, testEmbeddedXlsx
)
483 auto verify
= [this]() {
484 // check there are two objects and they are FrameShapes
485 CPPUNIT_ASSERT_EQUAL(2, getShapes());
486 CPPUNIT_ASSERT_EQUAL(u
"FrameShape"_ustr
, getShape(1)->getShapeType());
487 CPPUNIT_ASSERT_EQUAL(u
"FrameShape"_ustr
, getShape(2)->getShapeType());
490 createSwDoc("embedded-xlsx.docx");
492 saveAndReload(mpFilter
);
495 // check the objects are present in the exported document.xml
496 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
497 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/w:object", 2);
499 // finally check the embedded files are present in the zipped document
500 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
501 const uno::Sequence
<OUString
> names
= xNameAccess
->getElementNames();
504 for (OUString
const & n
: names
)
506 if(n
.startsWith("word/embeddings/oleObject"))
508 if(n
.startsWith("word/media/image"))
511 CPPUNIT_ASSERT_EQUAL(2, nSheetFiles
);
512 CPPUNIT_ASSERT_EQUAL(2, nImageFiles
);
515 CPPUNIT_TEST_FIXTURE(Test
, testNumberedLists_StartingWithZero
)
517 loadAndSave("FDO74105.docx");
518 /* Issue : Numbered lists Starting with value '0' is not preserved after RT.
519 * In numbering.xml, an XML tag <w:start> is optional. If not mentioned,
520 * the Numbered list should start from 0.
521 * Problem was LO was writing <w:start> for all levels 0-8 with default value "1".
523 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/numbering.xml"_ustr
);
525 // Check that we do _not_ export w:start for <w:lvl w:ilvl="0">.
526 assertXPath(pXmlDoc
, "w:numbering/w:abstractNum[1]/w:lvl[1]/w:start", 0);
529 CPPUNIT_TEST_FIXTURE(Test
, testPageBreak
)
531 loadAndReload("fdo74566.docx");
532 /* Break to next page was written into wrong paragraph as <w:pageBreakBefore />.
533 * LO was not preserving Page Break as <w:br w:type="page" />.
534 * Now after fix , LO writes Page Break as the new paragraph and also
535 * preserves the xml tag <w:br>.
537 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
539 uno::Reference
<text::XTextRange
> xParagraph2
= getParagraph(2);
540 uno::Reference
<text::XTextRange
> xParagraph4
= getParagraph(4);
542 getRun(xParagraph2
, 1, u
"First Page Second Line"_ustr
);
543 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:r[2]/w:br","type",u
"page");
544 getRun(xParagraph4
, 1, u
"Second Page First line after Page Break"_ustr
);
547 CPPUNIT_TEST_FIXTURE(Test
, testOleObject
)
549 loadAndSave("test_ole_object.docx");
550 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
552 assertXPathNoAttribute(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata",
555 "/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject",
558 // TODO: ProgID="Package" - what is this? Zip with 10k extra header?
560 // check the rels too
561 xmlDocUniquePtr pXmlDocRels
= parseExport(u
"word/_rels/document.xml.rels"_ustr
);
562 assertXPath(pXmlDocRels
,
563 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.bin']",
565 u
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject");
566 // check the media type too
567 xmlDocUniquePtr pXmlDocCT
= parseExport(u
"[Content_Types].xml"_ustr
);
568 assertXPath(pXmlDocCT
,
569 "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.bin']",
571 u
"application/vnd.openxmlformats-officedocument.oleObject");
575 CPPUNIT_TEST_FIXTURE(Test
, testFdo74792
)
577 loadAndSave("fdo74792.docx");
579 * fdo#74792 : The images associated with smart-art data[i].xml
580 * were not preserved on exporting to DOCX format
581 * Added support to grabbag the rels, with associated images.
583 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/diagrams/_rels/data1.xml.rels"_ustr
);
584 assertXPath(pXmlDoc
,"/rels:Relationships/rels:Relationship", 4);
585 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(
586 comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
588 //check that images are also saved
589 uno::Reference
<io::XInputStream
> xInputStream(xNameAccess
->getByName( u
"word/media/OOXDiagramDataRels1_0.jpeg"_ustr
/*added anchor id to form a unique name*/ ), uno::UNO_QUERY
);
590 CPPUNIT_ASSERT( xInputStream
.is() );
593 CPPUNIT_TEST_FIXTURE(Test
, testFdo77718
)
595 loadAndSave("fdo77718.docx");
596 //in case of multiple smart arts the names for images were getting
597 //repeated and thereby causing a data loss as the binary stream was
598 //getting over written. This test case ensures that unique names are
599 //given for images in different smart arts.
600 xmlDocUniquePtr pXmlDataRels1
= parseExport(u
"word/diagrams/_rels/data1.xml.rels"_ustr
);
601 xmlDocUniquePtr pXmlDataRels2
= parseExport(u
"word/diagrams/_rels/data2.xml.rels"_ustr
);
603 //ensure that the rels file is present.
604 assertXPath(pXmlDataRels1
,"/rels:Relationships/rels:Relationship", 4);
605 assertXPath(pXmlDataRels2
,"/rels:Relationships/rels:Relationship", 4);
607 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(
608 comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
610 //check that images are also saved
611 uno::Reference
<io::XInputStream
> xInputStream1(xNameAccess
->getByName( u
"word/media/OOXDiagramDataRels1_0.jpeg"_ustr
/*added anchor id to form a unique name*/ ), uno::UNO_QUERY
);
612 CPPUNIT_ASSERT( xInputStream1
.is() );
614 //check that images are saved for other smart-arts as well.
615 uno::Reference
<io::XInputStream
> xInputStream2(xNameAccess
->getByName( u
"word/media/OOXDiagramDataRels2_0.jpeg"_ustr
/*added anchor id to form a unique name*/ ), uno::UNO_QUERY
);
616 CPPUNIT_ASSERT( xInputStream2
.is() );
619 CPPUNIT_TEST_FIXTURE(Test
, testTableCurruption
)
621 loadAndSave("tableCurrupt.docx");
622 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/header2.xml"_ustr
);
623 CPPUNIT_ASSERT(pXmlDoc
) ;
624 assertXPath(pXmlDoc
, "/w:hdr/w:tbl[1]/w:tr[1]/w:tc[1]",1);
626 // tdf#116549: header paragraph should not have a bottom border.
627 uno::Reference
<beans::XPropertySet
> xStyle(getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), uno::UNO_QUERY
);
628 CPPUNIT_ASSERT(xStyle
.is());
629 uno::Reference
<text::XText
> xHeaderText
= getProperty
<uno::Reference
<text::XText
>>(xStyle
, u
"HeaderTextFirst"_ustr
);
630 CPPUNIT_ASSERT(xHeaderText
.is());
631 auto xParagraph
= getParagraphOfText(1, xHeaderText
);
632 CPPUNIT_ASSERT(xParagraph
.is());
633 table::BorderLine2 aHeaderBottomBorder
= getProperty
<table::BorderLine2
>(xParagraph
, u
"BottomBorder"_ustr
);
634 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), aHeaderBottomBorder
.LineWidth
);
637 CPPUNIT_TEST_FIXTURE(Test
, testDateControl
)
639 loadAndSave("date-control.docx");
641 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
642 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date", "fullDate", u
"2014-03-05T00:00:00Z");
643 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:dateFormat", "val", u
"dddd, dd' de 'MMMM' de 'yyyy");
644 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:lid", "val", u
"es-ES");
645 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", u
"mi\u00E9rcoles, 05 de marzo de 2014");
648 CPPUNIT_TEST_FIXTURE(Test
, test_Tdf115030
)
650 loadAndSave("tdf115030.docx");
651 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
652 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/m:oMath[1]/m:acc/m:accPr/m:chr", "val", u
"\u02D9");
653 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/m:oMath[2]/m:acc/m:accPr/m:chr", "val", u
"\u00A8");
654 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/m:oMathPara/m:oMath[1]/m:acc/m:accPr/m:chr", "val", u
"\u02D9");
657 CPPUNIT_TEST_FIXTURE(Test
, test_OpeningBrace
)
659 loadAndSave("2120112713_OpenBrace.docx");
660 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
661 // Checking for OpeningBrace tag
662 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[1]/m:dPr[1]/m:begChr[1]","val",u
"");
665 CPPUNIT_TEST_FIXTURE(Test
, test_Tdf132305
)
667 loadAndSave("tdf132305.docx");
668 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
669 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/m:oMath[1]/m:bar/m:barPr/m:pos","val",u
"top");
672 // Checks that all runs of the field have text properties.
673 // Old behaviour: only first run has text properties of the field
675 // There are several runs are used in fields:
678 // <!-- properties written with DocxAttributeOutput::StartRunProperties() / DocxAttributeOutput::EndRunProperties().
680 // <w:fldChar w:fldCharType="begin" />
684 // <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
686 // <w:instrText>TIME \@"HH:mm:ss"</w:instrText>
690 // <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
692 // <w:fldChar w:fldCharType="separate" />
696 // <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
698 // <w:t>14:01:13</w:t>
702 // <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
704 // <w:fldChar w:fldCharType="end" />
707 CPPUNIT_TEST_FIXTURE(Test
, testTdf38778
)
709 loadAndSave("tdf38778_properties_in_run_for_field.doc");
710 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
712 static constexpr std::u16string_view
psz(u
"20");
713 static constexpr std::u16string_view
pszCs(u
"20");
715 // w:fldCharType="begin"
716 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[3]/w:rPr/w:sz", "val", psz
);
717 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[3]/w:rPr/w:szCs", "val", pszCs
);
720 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[4]/w:rPr/w:sz", "val", psz
);
721 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[4]/w:rPr/w:szCs", "val", pszCs
);
722 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[4]/w:instrText", u
" PAGE ");
724 // w:fldCharType="separate"
725 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[5]/w:rPr/w:sz", "val", psz
);
726 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[5]/w:rPr/w:szCs", "val", pszCs
);
729 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[6]/w:rPr/w:sz", "val", psz
);
730 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[6]/w:rPr/w:szCs", "val", pszCs
);
731 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[6]/w:t", u
"1"); // field result
733 // w:fldCharType="end"
734 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[7]/w:rPr/w:sz", "val", psz
);
735 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[7]/w:rPr/w:szCs", "val", pszCs
);
737 // tdf#127862: page fill color (in this case white) was lost
738 uno::Reference
<beans::XPropertySet
> xStyle(getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), uno::UNO_QUERY
);
739 CPPUNIT_ASSERT(drawing::FillStyle_NONE
!= getProperty
<drawing::FillStyle
>(xStyle
, u
"FillStyle"_ustr
));
742 CPPUNIT_TEST_FIXTURE(Test
, testFDO76312
)
744 loadAndSave("FDO76312.docx");
745 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
747 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]");
750 void Test::verifyComboBoxExport(bool aComboBoxAsDropDown
)
752 if (aComboBoxAsDropDown
)
754 // ComboBox was imported as DropDown text field
755 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
756 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
757 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
758 CPPUNIT_ASSERT(xFields
->hasMoreElements());
759 uno::Any aField
= xFields
->nextElement();
760 uno::Reference
<lang::XServiceInfo
> xServiceInfo(aField
, uno::UNO_QUERY
);
761 CPPUNIT_ASSERT(xServiceInfo
->supportsService(u
"com.sun.star.text.textfield.DropDown"_ustr
));
763 uno::Sequence
<OUString
> aItems
= getProperty
< uno::Sequence
<OUString
> >(aField
, u
"Items"_ustr
);
764 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aItems
.getLength());
765 CPPUNIT_ASSERT_EQUAL(u
"manolo"_ustr
, aItems
[0]);
766 CPPUNIT_ASSERT_EQUAL(u
"pepito"_ustr
, aItems
[1]);
767 CPPUNIT_ASSERT_EQUAL(u
"Manolo"_ustr
, aItems
[2]);
771 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
772 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
773 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
774 uno::Reference
<drawing::XControlShape
> xControl(xShape
, uno::UNO_QUERY
);
776 CPPUNIT_ASSERT_EQUAL(u
"Manolo"_ustr
, getProperty
<OUString
>(xControl
->getControl(), u
"Text"_ustr
));
778 uno::Sequence
<OUString
> aItems
= getProperty
< uno::Sequence
<OUString
> >(xControl
->getControl(), u
"StringItemList"_ustr
);
779 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aItems
.getLength());
780 CPPUNIT_ASSERT_EQUAL(u
"manolo"_ustr
, aItems
[0]);
781 CPPUNIT_ASSERT_EQUAL(u
"pepito"_ustr
, aItems
[1]);
785 CPPUNIT_TEST_FIXTURE(Test
, testComboBoxControl
)
787 loadAndSave("combobox-control.docx");
789 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
790 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[1]", "value", u
"manolo");
791 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[2]", "value", u
"pepito");
792 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", u
"Manolo");
794 // check imported control
795 verifyComboBoxExport(getShapes() == 0);
798 CPPUNIT_TEST_FIXTURE(Test
, tdf134043_ImportComboBoxAsDropDown_true
)
800 createSwDoc("combobox-control.docx");
801 verifyComboBoxExport(true);
804 CPPUNIT_TEST_FIXTURE(Test
, tdf134043_ImportComboBoxAsDropDown_false
)
806 std::shared_ptr
<comphelper::ConfigurationChanges
> batch(
807 comphelper::ConfigurationChanges::create());
808 officecfg::Office::Writer::Filter::Import::DOCX::ImportComboBoxAsDropDown::set(false, batch
);
810 comphelper::ScopeGuard
g(
813 officecfg::Office::Writer::Filter::Import::DOCX::ImportComboBoxAsDropDown::set(true,
818 createSwDoc("combobox-control.docx");
819 verifyComboBoxExport(false);
822 CPPUNIT_TEST_FIXTURE(Test
, testCheckBoxControl
)
824 loadAndSave("checkbox-control.docx");
826 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
827 assertXPath(pXmlDoc
, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:checked", "val", u
"1");
828 assertXPath(pXmlDoc
, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:checkedState", "val", u
"2612");
829 assertXPath(pXmlDoc
, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:uncheckedState", "val", u
"2610");
831 // TODO: import control and add a check here
834 CPPUNIT_TEST_FIXTURE(Test
, testParagraphWithComments
)
836 loadAndSave("paragraphWithComments.docx");
837 /* Comment id's were getting overwritten for annotation mark(s),
838 which was causing a mismatch in the relationship for comment id's
839 in document.xml and comment.xml
841 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
842 xmlDocUniquePtr pXmlComm
= parseExport(u
"word/comments.xml"_ustr
);
844 sal_Int32 idInDocXml
= getXPath(pXmlDoc
,"/w:document/w:body/w:p[3]/w:commentRangeEnd[1]","id").toInt32();
845 sal_Int32 idInCommentXml
= getXPath(pXmlComm
,"/w:comments/w:comment[1]","id").toInt32();
846 CPPUNIT_ASSERT_EQUAL( idInDocXml
, idInCommentXml
);
849 CPPUNIT_TEST_FIXTURE(Test
, testTdf104707_urlComment
)
851 loadAndReload("tdf104707_urlComment.odt");
852 CPPUNIT_ASSERT_EQUAL(1, getPages());
853 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
854 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
855 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
856 auto aField1
= xFields
->nextElement();
857 // the comment/annotation/postit text
858 auto xText
= getProperty
< uno::Reference
<text::XText
> >(aField1
, u
"TextRange"_ustr
);
859 // the hyperlink within the comment text
860 auto xURLField
= getProperty
< uno::Reference
<text::XTextField
> >(xText
, u
"TextField"_ustr
);
861 auto aURL
= getProperty
< OUString
>(xURLField
, u
"URL"_ustr
);
862 CPPUNIT_ASSERT_EQUAL(u
"https://bugs.documentfoundation.org/show_bug.cgi?id=104707"_ustr
, aURL
);
865 CPPUNIT_TEST_FIXTURE(Test
, testOLEObjectinHeader
)
867 loadAndSave("2129393649.docx");
868 // fdo#76015 : Document contains oleobject in header xml.
869 // Problem was relationship entry for oleobject from header was
870 // exported into document.xml.rels file because of this rels file
871 // for headers were missing from document/word/rels.
872 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/_rels/header2.xml.rels"_ustr
);
874 assertXPath(pXmlDoc
,"/rels:Relationships/rels:Relationship[1]","Id",u
"rId1");
876 xmlDocUniquePtr pXmlDocCT
= parseExport(u
"[Content_Types].xml"_ustr
);
878 // check the media type too
879 assertXPath(pXmlDocCT
,
880 "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.bin']",
882 u
"application/vnd.openxmlformats-officedocument.oleObject");
884 // check the content too
885 xmlDocUniquePtr pXmlDocHeader2
= parseExport(u
"word/header2.xml"_ustr
);
886 assertXPath(pXmlDocHeader2
,
887 "/w:hdr/w:tbl/w:tr[1]/w:tc[2]/w:p[1]/w:r/w:object/o:OLEObject",
890 xmlDocUniquePtr pXmlDocHeader3
= parseExport(u
"word/header3.xml"_ustr
);
891 assertXPath(pXmlDocHeader2
,
892 "/w:hdr/w:tbl/w:tr[1]/w:tc[2]/w:p[1]/w:r/w:object/o:OLEObject",
897 CPPUNIT_TEST_FIXTURE(Test
, test_ClosingBrace
)
899 loadAndSave("2120112713.docx");
900 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
901 // Checking for ClosingBrace tag
902 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[2]/m:dPr[1]/m:endChr[1]","val",u
"");
904 // tdf#154371 paragraph style Подзаголовок ур3 inherits from Heading 3 (includes list level and list id)
905 uno::Reference
<beans::XPropertySet
> xParaStyle(getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Подзаголовок ур3"_ustr
), uno::UNO_QUERY
);
906 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(2), getProperty
<sal_Int16
>(xParaStyle
, u
"NumberingLevel"_ustr
));
907 CPPUNIT_ASSERT(!getProperty
<OUString
>(xParaStyle
, u
"NumberingStyleName"_ustr
).isEmpty());
910 CPPUNIT_TEST_FIXTURE(Test
, testlvlPicBulletId
)
912 loadAndSave("lvlPicBulletId.docx");
913 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/numbering.xml"_ustr
);
914 assertXPath(pXmlDoc
, "/w:numbering[1]/w:abstractNum[1]/w:lvl[1]/w:lvlPicBulletId[1]", 0);
917 CPPUNIT_TEST_FIXTURE(Test
, testSdtContent
)
919 loadAndSave("SdtContent.docx");
920 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/header1.xml"_ustr
);
921 // assertXPath(pXmlDoc, "/w:hdr[1]/w:p[1]/w:sdt/w:sdtContent[1]/w:del[1]");
925 // Currently LibreOffice exports custom geometry for this up arrow, not preset shape.
926 // When LibreOffice can export preset shape with correct modifiers, then this test can be re-enabled.
928 CPPUNIT_TEST_FIXTURE(Test
, testFdo76016
)
930 loadAndSave("fdo76016.docx");
932 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
933 assertXPath(pXmlDoc
, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]", "name", "adj1");
934 assertXPath(pXmlDoc
, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]", "name", "adj2");
938 CPPUNIT_TEST_FIXTURE(Test
, testFileWithInvalidImageLink
)
940 loadAndSave("FileWithInvalidImageLink.docx");
941 /* In case if the original file has an image whose link is
942 invalid, then the RT file used to result in corruption
943 since the exported image would be an empty image.
945 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
947 assertXPathNoAttribute(pXmlDoc
,
948 "/w:document/w:body/w:p[2]/w:r[2]/w:drawing[1]/wp:inline[1]/"
949 "a:graphic[1]/a:graphicData[1]/pic:pic[1]/pic:blipFill[1]/a:blip[1]",
953 CPPUNIT_TEST_FIXTURE(Test
, testContentTypeDOCX
)
955 loadAndSave("fdo80410.docx");
956 xmlDocUniquePtr pXmlDoc
= parseExport(u
"[Content_Types].xml"_ustr
);
959 "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.docx']",
961 u
"application/vnd.openxmlformats-officedocument.wordprocessingml.document");
962 // check the rels too
963 xmlDocUniquePtr pXmlDocRels
= parseExport(u
"word/_rels/document.xml.rels"_ustr
);
964 assertXPath(pXmlDocRels
,
965 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.docx']",
967 u
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
968 // check the content too
969 xmlDocUniquePtr pXmlDocContent
= parseExport(u
"word/document.xml"_ustr
);
970 assertXPath(pXmlDocContent
,
971 "/w:document/w:body/w:p[6]/w:r/w:object/o:OLEObject",
973 u
"Word.Document.12");
976 CPPUNIT_TEST_FIXTURE(Test
, testContentTypeXLSM
)
978 loadAndSave("fdo76098.docx");
979 xmlDocUniquePtr pXmlDoc
= parseExport(u
"[Content_Types].xml"_ustr
);
981 assertXPath(pXmlDoc
, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "ContentType", u
"application/vnd.ms-excel.sheet.macroEnabled.12");
983 // check the rels too
984 xmlDocUniquePtr pXmlDocRels
= parseExport(u
"word/charts/_rels/chart1.xml.rels"_ustr
);
985 assertXPath(pXmlDocRels
,
986 "/rels:Relationships/rels:Relationship[@Target='../embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']",
988 u
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
989 // check the content too
990 xmlDocUniquePtr pXmlDocChart1
= parseExport(u
"word/charts/chart1.xml"_ustr
);
991 assertXPath(pXmlDocChart1
,
992 "/c:chartSpace/c:externalData",
997 CPPUNIT_TEST_FIXTURE(Test
, test76108
)
999 loadAndSave("test76108.docx");
1000 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
1001 //docx file after RT is getting corrupted.
1002 assertXPath(pXmlDoc
, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:fldChar[1]", "fldCharType", u
"begin");
1005 CPPUNIT_TEST_FIXTURE(Test
, testTCTagMisMatch
)
1007 loadAndSave("TCTagMisMatch.docx");
1008 // TCTagMisMatch.docx : This document contains an empty table with borders.
1009 // there was a TC tag mismatch which resulted into a crash.
1011 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
1012 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);
1013 assertXPath(pXmlDoc
,"/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]", 1);
1016 CPPUNIT_TEST_FIXTURE(Test
, testFDO78292
)
1018 loadAndSave("FDO78292.docx");
1019 //text node is a leaf node, it should not have any children
1020 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
1021 assertXPath(pXmlDoc
,"/w:document/w:body/w:p[14]/w:sdt[3]/w:sdtPr[1]/w:text/w14:checked",0);
1024 CPPUNIT_TEST_FIXTURE(Test
, testSimpleSdts
)
1026 loadAndSave("simple-sdts.docx");
1027 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
1029 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:sdt/w:sdtPr/w:text", 1);
1030 assertXPath(pXmlDoc
, "//*/w:sdt/w:sdtPr/w:id", 5);
1031 assertXPath(pXmlDoc
, "//w:sdt/w:sdtPr/w:lock", 1);
1032 assertXPath(pXmlDoc
, "/w:document/w:body/w:sdt[1]/w:sdtPr/w:picture", 1);
1033 assertXPath(pXmlDoc
, "/w:document/w:body/w:sdt[2]/w:sdtPr/w:group", 1);
1034 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/w:sdt/w:sdtPr/w:citation", 1);
1037 CPPUNIT_TEST_FIXTURE(Test
, testEmbeddedExcelChart
)
1039 loadAndSave("EmbeddedExcelChart.docx");
1040 xmlDocUniquePtr pXmlDoc
= parseExport(u
"[Content_Types].xml"_ustr
);
1042 assertXPath(pXmlDoc
,
1043 "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.xls']",
1045 u
"application/vnd.ms-excel");
1047 // check the rels too
1048 xmlDocUniquePtr pXmlDocRels
= parseExport(u
"word/_rels/document.xml.rels"_ustr
);
1049 assertXPath(pXmlDocRels
,
1050 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xls']",
1052 u
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject");
1054 // check the content too
1055 xmlDocUniquePtr pXmlDocContent
= parseExport(u
"word/document.xml"_ustr
);
1056 assertXPath(pXmlDocContent
,
1057 "/w:document/w:body/w:p/w:r/w:object/o:OLEObject",
1062 CPPUNIT_TEST_FIXTURE(Test
, testTdf83227
)
1064 loadAndReload("tdf83227.docx");
1065 // Bug document contains a rotated image, which is handled as a draw shape (not as a Writer image) on export.
1066 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
1067 CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess
->hasByName(u
"word/media/image1.png"_ustr
)));
1068 // This was also true, image was written twice.
1069 CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess
->hasByName(u
"word/media/image2.png"_ustr
)));
1072 CPPUNIT_TEST_FIXTURE(Test
, testTdf103001
)
1074 loadAndReload("tdf103001.docx");
1075 // The same image is featured in the header and in the body text, make sure
1076 // the header relation is still written, even when caching is enabled.
1077 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
1078 // This failed: header reused the RelId of the body text, even if RelIds
1079 // are local to their stream.
1080 CPPUNIT_ASSERT(xNameAccess
->hasByName(u
"word/_rels/header2.xml.rels"_ustr
));
1083 CPPUNIT_TEST_FIXTURE(Test
, testTdf92521
)
1085 loadAndSave("tdf92521.odt");
1086 CPPUNIT_ASSERT_EQUAL(2, getPages());
1087 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
1088 // There should be a section break that's in the middle of the document: right after the table.
1089 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:pPr/w:sectPr", 1);
1092 DECLARE_OOXMLEXPORT_TEST(testTdf102466
, "tdf102466.docx")
1094 // the problem was: file is truncated: the first page is missing.
1095 // More precisely, the table in the first page was clipped.
1097 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
1098 sal_Int32 nFlyPrtHeight
= getXPath(pXmlDoc
, "(/root/page[1]//anchored/fly)[1]/infos/prtBounds", "height").toInt32();
1099 sal_Int32 nTableHeight
= getXPath(pXmlDoc
, "(/root/page[1]//anchored/fly)[1]/tab/infos/bounds", "height").toInt32();
1100 CPPUNIT_ASSERT_MESSAGE("The table is clipped in a fly frame.", nFlyPrtHeight
>= nTableHeight
);
1103 // check how much pages we have: it should match the Word layout result
1104 CPPUNIT_ASSERT_EQUAL(11, getPages());
1106 // check content of the first page
1108 uno::Reference
<beans::XPropertySet
> xFrame(getShapeByName(u
"Marco1"), uno::UNO_QUERY
);
1111 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xFrame
, u
"LineWidth"_ustr
));
1114 // Make sure we have 19 tables created
1116 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1117 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables( ), uno::UNO_QUERY
);
1118 CPPUNIT_ASSERT(xTables
->getCount() >= sal_Int32(19)); // TODO
1120 // check the text inside first cell of the first table
1121 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1122 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName(u
"A1"_ustr
), uno::UNO_QUERY
);
1124 const OUString aActualText
= xCell
->getString();
1126 CPPUNIT_ASSERT(aActualText
.indexOf("Requerimientos del Cliente") > 0);
1130 CPPUNIT_TEST_FIXTURE(Test
, testTdf99090_pgbrkAfterTable
)
1132 loadAndSave("tdf99090_pgbrkAfterTable.docx");
1133 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
1134 // There should be a regular page break that's in the middle of the document: right after the table.
1135 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:br", 1);
1138 DECLARE_OOXMLEXPORT_TEST(testTdf96750_landscapeFollow
, "tdf96750_landscapeFollow.docx")
1140 uno::Reference
<beans::XPropertySet
> xStyle(getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), uno::UNO_QUERY
);
1141 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStyle
, u
"IsLandscape"_ustr
));
1144 DECLARE_OOXMLEXPORT_TEST(testTdf86926_A3
, "tdf86926_A3.docx")
1146 uno::Reference
<beans::XPropertySet
> xStyle(getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), uno::UNO_QUERY
);
1147 CPPUNIT_ASSERT_EQUAL(sal_Int32(42000), getProperty
<sal_Int32
>(xStyle
, u
"Height"_ustr
));
1148 CPPUNIT_ASSERT_EQUAL(sal_Int32(29700), getProperty
<sal_Int32
>(xStyle
, u
"Width"_ustr
));
1151 DECLARE_OOXMLEXPORT_TEST(testTdf64372_continuousBreaks
,"tdf64372_continuousBreaks.docx")
1153 //There are no page breaks, so everything should be on the first page.
1154 CPPUNIT_ASSERT_EQUAL(1, getPages());
1157 DECLARE_OOXMLEXPORT_TEST(testTdf92724_continuousBreaksComplex
,"tdf92724_continuousBreaksComplex.docx")
1159 //There are 2 page breaks, so there should be 3 pages.
1160 CPPUNIT_ASSERT_EQUAL(3, getPages());
1163 DECLARE_OOXMLEXPORT_TEST(testTdf90697_continuousBreaksComplex2
,"tdf92724_continuousBreaksComplex2.docx")
1165 // Continuous section breaks with new headers/footers should not immediately switch to a new page style.
1166 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
1167 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
1168 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(), uno::UNO_QUERY
);
1169 xCursor
->jumpToLastPage();
1171 sal_Int16 nPages
= xCursor
->getPage();
1174 OUString sPageStyleName
= getProperty
<OUString
>( xCursor
, u
"PageStyleName"_ustr
);
1175 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles(u
"PageStyles"_ustr
)->getByName(sPageStyleName
), u
"HeaderText"_ustr
);
1176 // Specific case to avoid. Testing separately (even though redundant).
1177 // 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).
1178 CPPUNIT_ASSERT( xHeaderText
->getString() != "Third section - First page header. No follow defined" );
1179 // Same test stated differently: Pages 4 and 5 OUGHT to use "Second section header", but currently don't. Page 6 does.
1181 CPPUNIT_ASSERT_EQUAL( u
"First section header"_ustr
, xHeaderText
->getString() );
1183 CPPUNIT_ASSERT( xHeaderText
->getString() == "First section header" || xHeaderText
->getString() == "Second section header" );
1185 xCursor
->jumpToPage( --nPages
);
1189 DECLARE_OOXMLEXPORT_TEST(testTdf95367_inheritFollowStyle
, "tdf95367_inheritFollowStyle.docx")
1191 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
1192 assertXPathContent(pXmlDoc
, "/root/page[2]/header/txt/text()", u
"header");
1195 DECLARE_OOXMLEXPORT_TEST(testInheritFirstHeader
,"inheritFirstHeader.docx")
1197 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
1198 assertXPathContent(pXmlDoc
, "/root/page[1]/header/txt/text()", u
"First Header");
1199 assertXPathContent(pXmlDoc
, "/root/page[2]/header/txt/text()", u
"Follow Header");
1200 assertXPathContent(pXmlDoc
, "/root/page[3]/header/txt/text()", u
"Follow Header");
1201 assertXPathContent(pXmlDoc
, "/root/page[4]/header/txt/text()", u
"First Header");
1202 assertXPathContent(pXmlDoc
, "/root/page[5]/header/txt/text()", u
"Last Header");
1206 DECLARE_OOXMLEXPORT_TEST(testTdf81345_045Original
, "tdf81345.docx")
1208 //Header wasn't replaced and columns were missing because no new style was created.
1209 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
1210 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
1211 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(), uno::UNO_QUERY
);
1213 xCursor
->jumpToLastPage();
1214 OUString pageStyleName
= getProperty
<OUString
>(xCursor
, u
"PageStyleName"_ustr
);
1215 CPPUNIT_ASSERT(pageStyleName
!= "Standard");
1217 // tdf89297 Styles were being added before their base/parent/inherited-from style existed, and so were using default settings.
1218 uno::Reference
<container::XNameAccess
> xParaStyles(getStyles(u
"ParagraphStyles"_ustr
));
1219 uno::Reference
<beans::XPropertySet
> xStyle(xParaStyles
->getByName(u
"Pull quote"_ustr
), uno::UNO_QUERY
);
1220 CPPUNIT_ASSERT_EQUAL(sal_Int32(6736947), getProperty
<sal_Int32
>(xStyle
, u
"CharColor"_ustr
));
1224 CPPUNIT_TEST_FIXTURE(Test
, testDocxTablePosition
)
1226 loadAndSave("floating-table-position.docx");
1227 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
1229 // the exported positions were wrong due to some missing shifting in the export code
1230 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpX", u
"3494");
1231 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpY", u
"4611");
1235 CPPUNIT_TEST_FIXTURE(Test
, testUnderlineGroupShapeText
)
1237 loadAndSave("tdf123351_UnderlineGroupSapeText.docx");
1238 // tdf#123351: Check if correct underline is used.
1239 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
1241 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
1242 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "single");
1243 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
1244 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "double");
1246 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor"
1247 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "thick");
1248 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor"
1249 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dotted");
1251 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor"
1252 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dottedHeavy");
1253 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor"
1254 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dash");
1256 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor"
1257 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dashedHeavy");
1259 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[5]/mc:Choice/w:drawing/wp:anchor"
1260 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r[1]/w:rPr/w:u", "val", "dashLongHeavy");
1261 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[5]/mc:Choice/w:drawing/wp:anchor"
1262 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dotDash");
1264 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[6]/mc:Choice/w:drawing/wp:anchor"
1265 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dashDotHeavy");
1266 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[6]/mc:Choice/w:drawing/wp:anchor"
1267 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dotDotDash");
1269 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor"
1270 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "dashDotDotHeavy");
1271 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor"
1272 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "wave");
1274 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[8]/mc:Choice/w:drawing/wp:anchor"
1275 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "wavyHeavy");
1276 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent[8]/mc:Choice/w:drawing/wp:anchor"
1277 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "wavyDouble");
1279 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[32]/w:r/mc:AlternateContent[1]/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", "val", "none");
1282 // TODO: Import of "words".
1283 // This must fail when import of "words" is implemented. This is a temporary solution, we read "words" as "single".
1284 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[32]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
1285 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "val", "single");
1288 CPPUNIT_TEST_FIXTURE(Test
, testUnderlineColorGroupedShapes
)
1290 loadAndSave("tdf132491_UnderlineColorGroupedShapes.docx");
1291 // tdf#132491 : Check if correct color is used for underline.
1292 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
1293 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
1294 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "color", u
"FF0000");
1295 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
1296 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "color", u
"00B050");
1297 assertXPathNoAttribute(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
1298 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[3]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "color");
1301 CPPUNIT_TEST_FIXTURE(Test
, testRelativeAnchorWidthFromRightMargin
)
1303 loadAndSave("tdf133670_testRelativeAnchorWidthFromRightMargin.docx");
1304 // tdf#133670 The width was set relative from right margin, but this was handled relative from page width.
1305 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
1306 auto nWidth
= getXPath(pXmlDoc
, "//anchored/SwAnchoredDrawObject/bounds", "width").toInt32();
1307 CPPUNIT_ASSERT_DOUBLES_EQUAL(2408, nWidth
, 1);
1310 CPPUNIT_TEST_FIXTURE(Test
, testAutoFitForLegacyShapes
)
1312 loadAndSave("tdf112312_AutoFitForLegacyShapes.odt");
1313 // tdf#112312: check if noAutoFit is used instead of spAutoFit even if the TextAutoGrowHeight is set
1314 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
1315 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
1316 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr/a:noAutofit");
1317 assertXPathNoAttribute(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
1318 "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr", "a:spAutofit");
1321 CPPUNIT_PLUGIN_IMPLEMENT();
1323 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */