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/.
11 #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
13 #include <AppKit/AppKit.h>
17 #include <swmodeltestbase.hxx>
19 #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
20 #include <com/sun/star/embed/Aspects.hpp>
21 #include <com/sun/star/text/WritingMode2.hpp>
22 #include <com/sun/star/style/BreakType.hpp>
23 #include <com/sun/star/text/XTextDocument.hpp>
24 #include <com/sun/star/text/XTextTable.hpp>
26 #include <comphelper/propertysequence.hxx>
27 #include <vcl/BitmapReadAccess.hxx>
28 #include <vcl/graphicfilter.hxx>
29 #include <xmloff/odffields.hxx>
32 #include <IDocumentMarkAccess.hxx>
33 #include <IDocumentLayoutAccess.hxx>
35 #include <sortedobjs.hxx>
36 #include <anchoredobject.hxx>
39 #include <unotxdoc.hxx>
41 #include <rootfrm.hxx>
43 #include <pagefrm.hxx>
45 #include <flyfrms.hxx>
50 class Test
: public SwModelTestBase
54 : SwModelTestBase(u
"/sw/qa/extras/ooxmlimport/data/"_ustr
, u
"Office Open XML Text"_ustr
)
59 CPPUNIT_TEST_FIXTURE(Test
, testTdf159897Broken_link
)
61 createSwDoc("tdf159897_broken_link.docx");
63 for (size_t i
= 1; i
< 10; ++i
)
65 auto xPara(getParagraph(i
));
66 auto xRun
= getRun(xPara
, 0);
67 OUString sURL
= getProperty
<OUString
>(xRun
, u
"HyperLinkURL"_ustr
);
68 CPPUNIT_ASSERT_EQUAL(u
"https://libreoffice.org/"_ustr
, sURL
);
74 sText
= "Zeroth link";
77 sText
= "First \"link\"";
80 sText
= "Second \" link \"";
83 sText
= "Third \"\"\"link\"\"\"";
86 sText
= "\"Fourth\" link";
89 sText
= "Fifth \"5\" link";
92 sText
= "Sixth \"6\" link";
95 sText
= "Seventh \"link\"";
98 sText
= "\"Eighth\" link";
102 OUString sScreenTip
= getProperty
<OUString
>(xRun
, u
"HyperLinkName"_ustr
);
103 CPPUNIT_ASSERT_EQUAL(sText
, sScreenTip
);
107 CPPUNIT_TEST_FIXTURE(Test
, testTdf143476LockedCanvas_twoShapes
)
109 // Given a lockedCanvas in a docx document with compatibility to Word version 12 (2007).
110 // It contains two shapes. Error was, that the lockedCanvas was not imported as group at all,
111 // and only one shape was imported and that one was scaled to lockedCanvas area.
112 createSwDoc("tdf143476_lockedCanvas_twoShapes.docx");
113 // The group shape corresponds to the lockedCanvas.
114 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
115 CPPUNIT_ASSERT(xGroup
.is());
116 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xGroup
->getCount());
117 uno::Reference
<drawing::XShape
> xShape(xGroup
->getByIndex(1), uno::UNO_QUERY
);
118 CPPUNIT_ASSERT_EQUAL(sal_Int32(14200), xShape
->getPosition().X
);
119 CPPUNIT_ASSERT_EQUAL(sal_Int32(1120), xShape
->getPosition().Y
);
120 CPPUNIT_ASSERT_EQUAL(sal_Int32(1928), xShape
->getSize().Width
);
121 CPPUNIT_ASSERT_EQUAL(sal_Int32(1593), xShape
->getSize().Height
);
124 CPPUNIT_TEST_FIXTURE(Test
, testTdf143476LockedCanvas_position
)
126 // Given a lockedCanvas in a docx document with compatibility to Word version 12 (2007).
127 // Tests fix for regression introduced by 3262fc5ef3bde5b158909d11ccb008161ea95519
128 // Error was, that the imported shape had wrong position.
129 createSwDoc("tdf143476_lockedCanvas_position.docx");
130 // The group shape corresponds to the lockedCanvas.
131 uno::Reference
<drawing::XShape
> xGroupShape(getShape(1), uno::UNO_QUERY
);
132 // Without fix in place the test failed with position 185|947.
133 CPPUNIT_ASSERT_EQUAL(sal_Int32(2351), xGroupShape
->getPosition().X
);
134 CPPUNIT_ASSERT_EQUAL(sal_Int32(26), xGroupShape
->getPosition().Y
);
137 CPPUNIT_TEST_FIXTURE(Test
, testTdf143476LockedCanvas_image_line
)
139 // Given a lockedCanvas in a docx document with compatibility to Word version 12 (2007).
140 // It contains an image and a line. Error was, that both were not imported.
141 createSwDoc("tdf143476_lockedCanvas_image_line.docx");
142 CPPUNIT_ASSERT_MESSAGE("No shapes imported", getShapes() > 0);
145 CPPUNIT_TEST_FIXTURE(Test
, testTdf143475rotatedWord2007imageInline
)
147 // Given a docx document with compatibility to Word version 12 (2007), which has a shape
148 // rotated by 75deg. Similar to testTdf143475rotatedWord2007image but with inline anchored
149 // shape, as in bug report.
150 createSwDoc("tdf143475_rotatedWord2007imageInline.docx");
152 // Word 2007 does not swap width and height for rotated images as done in later versions.
153 // This was not considered and lead to wrong distance to text on import and wrong effectExtent
155 // Import fails without fix with left: expected 1258 actual -743 ; right expected 1256 actual -743;
156 // top: expected 14 actual 2013; bottom: expected 0 actual 1960;
157 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1258),
158 getProperty
<sal_Int32
>(getShape(1), u
"LeftMargin"_ustr
), 1);
159 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1256),
160 getProperty
<sal_Int32
>(getShape(1), u
"RightMargin"_ustr
), 1);
161 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(14),
162 getProperty
<sal_Int32
>(getShape(1), u
"TopMargin"_ustr
), 1);
163 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(0),
164 getProperty
<sal_Int32
>(getShape(1), u
"BottomMargin"_ustr
), 1);
166 // Because LO made the same error on export, which inverts the import error, import-export-cycle
167 // does not fail without the patch. Therefore no export test.
170 CPPUNIT_TEST_FIXTURE(Test
, testTdf143475rotatedWord2007image
)
172 // Given a docx document with compatibility to Word version 12 (2007), which has a shape
174 createSwDoc("tdf143475_rotatedWord2007image.docx");
176 // Word 2007 does not swap width and height for rotated images as done in later versions.
177 // This was not considered and lead to wrong distance to text on import and wrong effectExtent
179 // Import fails without fix with left: expected 1252 actual -746 ; right expected 1256 actual -743;
180 // top: expected 12 actual 2013; bottom: expected 0 actual 1960;
181 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1252),
182 getProperty
<sal_Int32
>(getShape(1), u
"LeftMargin"_ustr
), 1);
183 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1256),
184 getProperty
<sal_Int32
>(getShape(1), u
"RightMargin"_ustr
), 1);
185 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(12),
186 getProperty
<sal_Int32
>(getShape(1), u
"TopMargin"_ustr
), 1);
187 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(0),
188 getProperty
<sal_Int32
>(getShape(1), u
"BottomMargin"_ustr
), 1);
190 // Because LO made the same error on export, which inverts the import error, import-export-cycle
191 // does not fail without the patch. Therefore no export test.
194 CPPUNIT_TEST_FIXTURE(Test
, testTdf143219ContourWrapRotate
)
196 createSwDoc("tdf143219_ContourWrap_rotate.docx");
197 const uno::Reference
<drawing::XShape
> xShape
= getShape(1);
198 const uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY_THROW
);
199 sal_Int32 nWrapDistanceLeft
= -1;
200 sal_Int32 nWrapDistanceRight
= -1;
201 sal_Int32 nWrapDistanceTop
= -1;
202 sal_Int32 nWrapDistanceBottom
= -1;
203 xShapeProps
->getPropertyValue(u
"LeftMargin"_ustr
) >>= nWrapDistanceLeft
;
204 xShapeProps
->getPropertyValue(u
"RightMargin"_ustr
) >>= nWrapDistanceRight
;
205 xShapeProps
->getPropertyValue(u
"TopMargin"_ustr
) >>= nWrapDistanceTop
;
206 xShapeProps
->getPropertyValue(u
"BottomMargin"_ustr
) >>= nWrapDistanceBottom
;
207 // Word and Writer use different concepts for contour wrap. LO needs wrap margins to
208 // approximate Word's rendering.
209 // Without the fix in place left and right margin were too large, top and bottom margin too
210 // small. The test would have failed
211 // ... with expected 182 actual 1005.
212 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("LeftMargin", 182, nWrapDistanceLeft
, 1);
213 // ... with expected 183 actual 1005
214 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("RightMargin", 183, nWrapDistanceRight
, 1);
215 // ... with expected 42 actual 0
216 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("TopMargin", 42, nWrapDistanceTop
, 1);
217 // ... with expected 41 actual 0
218 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("BottomMargin", 41, nWrapDistanceBottom
, 1);
221 CPPUNIT_TEST_FIXTURE(Test
, testTdf108545_embeddedDocxIcon
)
223 createSwDoc("tdf108545_embeddedDocxIcon.docx");
224 uno::Reference
<document::XEmbeddedObjectSupplier2
> xSupplier(getShape(1), uno::UNO_QUERY
);
225 CPPUNIT_ASSERT_EQUAL(embed::Aspects::MSOLE_ICON
, xSupplier
->getAspect());
228 CPPUNIT_TEST_FIXTURE(Test
, testTdf121203
)
230 createSwDoc("tdf121203.docx");
231 // We imported the date field
232 uno::Reference
<beans::XPropertySet
> xTextPortion(getRun(getParagraph(1), 1), uno::UNO_QUERY
);
233 OUString aPortionType
;
234 xTextPortion
->getPropertyValue(u
"TextPortionType"_ustr
) >>= aPortionType
;
235 CPPUNIT_ASSERT_EQUAL(u
"ContentControl"_ustr
, aPortionType
);
237 // Custom sdt date content is imported correctly
238 uno::Reference
<text::XTextContent
> xContentControl
;
239 xTextPortion
->getPropertyValue(u
"ContentControl"_ustr
) >>= xContentControl
;
240 uno::Reference
<beans::XPropertySet
> xContentControlProps(xContentControl
, uno::UNO_QUERY
);
242 xContentControlProps
->getPropertyValue(u
"Date"_ustr
) >>= bDate
;
243 CPPUNIT_ASSERT(bDate
);
245 OUString sDateFormat
;
246 xContentControlProps
->getPropertyValue(u
"DateFormat"_ustr
) >>= sDateFormat
;
249 xContentControlProps
->getPropertyValue(u
"DateLanguage"_ustr
) >>= sLang
;
251 uno::Reference
<container::XEnumerationAccess
> xContentControlEnumAccess(xContentControl
,
253 uno::Reference
<container::XEnumeration
> xContentControlEnum
254 = xContentControlEnumAccess
->createEnumeration();
255 uno::Reference
<text::XTextRange
> xTextPortionRange(xContentControlEnum
->nextElement(),
257 OUString sCurrentDate
= xTextPortionRange
->getString();
258 CPPUNIT_ASSERT_EQUAL(u
"dd-MMM-yy"_ustr
, sDateFormat
);
259 CPPUNIT_ASSERT_EQUAL(u
"en-GB"_ustr
, sLang
);
260 CPPUNIT_ASSERT_EQUAL(u
"17-Oct-2018 09:00"_ustr
, sCurrentDate
);
263 CPPUNIT_TEST_FIXTURE(Test
, testTdf109053
)
265 createSwDoc("tdf109053.docx");
266 // Table was imported into a text frame which led to a one page document
267 // Originally the table takes two pages, so Writer should import it accordingly.
268 CPPUNIT_ASSERT_EQUAL(2, getPages());
271 CPPUNIT_TEST_FIXTURE(Test
, testTdf121664
)
273 createSwDoc("tdf121664.docx");
274 uno::Reference
<text::XLineNumberingProperties
> xLineNumbering(mxComponent
, uno::UNO_QUERY
);
275 CPPUNIT_ASSERT(xLineNumbering
.is());
276 // Without the accompanying fix in place, numbering did not restart on the
279 getProperty
<bool>(xLineNumbering
->getLineNumberingProperties(), u
"RestartAtEachPage"_ustr
));
282 CPPUNIT_TEST_FIXTURE(Test
, testTdf108849
)
284 createSwDoc("tdf108849.docx");
285 // sectPr element that is child element of body must be the last child. However, Word accepts it
286 // in wrong places, and we should do the same (bug-to-bug compatibility) without creating extra sections.
287 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
288 CPPUNIT_ASSERT_EQUAL_MESSAGE("Misplaced body-level sectPr's create extra sections!", 2,
292 CPPUNIT_TEST_FIXTURE(Test
, testTdf97038
)
294 createSwDoc("tdf97038.docx");
295 // Without the accompanying fix in place, this test would have failed, as the importer lost the
296 // fLayoutInCell shape property for wrap-though shapes.
297 CPPUNIT_ASSERT(getProperty
<bool>(getShapeByName(u
"Kep2"), u
"IsFollowingTextFlow"_ustr
));
300 CPPUNIT_TEST_FIXTURE(Test
, testTdf114212
)
302 createSwDoc("tdf114212.docx");
303 // Without the accompanying fix in place, this test would have failed with:
306 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
307 OUString aTop
= getXPath(pXmlDoc
, "//anchored/fly[1]/infos/bounds", "top");
308 CPPUNIT_ASSERT_EQUAL(u
"1428"_ustr
, aTop
);
311 CPPUNIT_TEST_FIXTURE(Test
, testTdf109524
)
313 createSwDoc("tdf109524.docx");
314 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
315 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(),
317 // The table should have a small width (just to hold the short text in its single cell).
318 // Until it's correctly implemented, we assign it 100% relative width.
319 // Previously, the table (without explicitly set width) had huge actual width
320 // and extended far outside of page's right border.
321 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xTables
->getByIndex(0), u
"IsWidthRelative"_ustr
));
322 CPPUNIT_ASSERT_EQUAL(sal_Int16(100),
323 getProperty
<sal_Int16
>(xTables
->getByIndex(0), u
"RelativeWidth"_ustr
));
326 CPPUNIT_TEST_FIXTURE(Test
, testTdf120547
)
328 createSwDoc("tdf120547.docx");
329 uno::Reference
<drawing::XShape
> xGroupShape
= getShape(1);
330 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
331 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xGroup
->getCount());
333 awt::Point aPosGroup
= xGroupShape
->getPosition();
334 awt::Size aSizeGroup
= xGroupShape
->getSize();
336 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosGroup
.X
);
337 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosGroup
.Y
);
338 CPPUNIT_ASSERT_EQUAL(sal_Int32(9091), aSizeGroup
.Width
);
339 CPPUNIT_ASSERT_EQUAL(sal_Int32(27940), aSizeGroup
.Height
);
341 // Without the fix in place, this test would have failed at many places
342 // as the three shapes in the group would have had an incorrect position,
343 // an incorrect width or an incorrect height.
345 uno::Reference
<drawing::XShape
> xShape1(xGroup
->getByIndex(0), uno::UNO_QUERY_THROW
);
346 awt::Point aPosShape1
= xShape1
->getPosition();
347 awt::Size aSizeShape1
= xShape1
->getSize();
349 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosShape1
.X
);
350 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosShape1
.Y
);
351 CPPUNIT_ASSERT_EQUAL(sal_Int32(9066), aSizeShape1
.Width
);
352 CPPUNIT_ASSERT_EQUAL(sal_Int32(27905), aSizeShape1
.Height
);
354 uno::Reference
<drawing::XShape
> xShape2(xGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
355 awt::Point aPosShape2
= xShape2
->getPosition();
356 awt::Size aSizeShape2
= xShape2
->getSize();
358 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosShape2
.X
);
359 CPPUNIT_ASSERT_EQUAL(sal_Int32(20745), aPosShape2
.Y
);
360 CPPUNIT_ASSERT_EQUAL(sal_Int32(9066), aSizeShape2
.Width
);
361 CPPUNIT_ASSERT_EQUAL(sal_Int32(7195), aSizeShape2
.Height
);
363 // The second shape is a group of 3 shapes
364 uno::Reference
<container::XIndexAccess
> xGroup2(xGroup
->getByIndex(1), uno::UNO_QUERY
);
365 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xGroup2
->getCount());
367 uno::Reference
<drawing::XShape
> xShape3(xGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
368 awt::Point aPosShape3
= xShape3
->getPosition();
369 awt::Size aSizeShape3
= xShape3
->getSize();
371 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosShape3
.X
);
372 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosShape3
.Y
);
373 CPPUNIT_ASSERT_EQUAL(sal_Int32(9091), aSizeShape3
.Width
);
374 CPPUNIT_ASSERT_EQUAL(sal_Int32(8073), aSizeShape3
.Height
);
377 CPPUNIT_TEST_FIXTURE(Test
, testTdf118693
)
379 createSwDoc("tdf118693.docx");
380 uno::Reference
<drawing::XShape
> xGroupShape
= getShape(1);
381 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
382 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xGroup
->getCount());
384 awt::Point aPosGroup
= xGroupShape
->getPosition();
385 awt::Size aSizeGroup
= xGroupShape
->getSize();
387 // ToDo: width and height are inaccurate for unknown reason.
388 // Allow some tolerance
389 CPPUNIT_ASSERT_EQUAL(sal_Int32(10162), aPosGroup
.X
);
390 CPPUNIT_ASSERT_EQUAL(sal_Int32(118), aPosGroup
.Y
);
391 // width 2292840 EMU = 6369, height 1793875 EMU = 4982.98
392 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(6369), aSizeGroup
.Width
, 2);
393 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4983), aSizeGroup
.Height
, 2);
395 // Without the fix in place, this test would have failed at many places
396 // as the first shape in the group would have had an incorrect position,
397 // an incorrect width or an incorrect height.
399 uno::Reference
<drawing::XShape
> xShape1(xGroup
->getByIndex(0), uno::UNO_QUERY_THROW
);
400 awt::Point aPosShape1
= xShape1
->getPosition();
401 awt::Size aSizeShape1
= xShape1
->getSize();
403 CPPUNIT_ASSERT_EQUAL(sal_Int32(12861), aPosShape1
.X
);
404 CPPUNIT_ASSERT_EQUAL(sal_Int32(146), aPosShape1
.Y
);
405 // width 2292840/2293461*1321179 EMU = 3668.94, height 1767845 EMU = 4910.68
406 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(3671), aSizeShape1
.Width
, 2);
407 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4914), aSizeShape1
.Height
, 2);
409 uno::Reference
<drawing::XShape
> xShape2(xGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
410 awt::Point aPosShape2
= xShape2
->getPosition();
411 awt::Size aSizeShape2
= xShape2
->getSize();
413 CPPUNIT_ASSERT_EQUAL(sal_Int32(10162), aPosShape2
.X
);
414 CPPUNIT_ASSERT_EQUAL(sal_Int32(118), aPosShape2
.Y
);
415 // width 2292840/2293461*1654824 EMU = 4595.48, height 1793875 EMU = 4982.98
416 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4597), aSizeShape2
.Width
, 2);
417 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4983), aSizeShape2
.Height
, 2);
420 CPPUNIT_TEST_FIXTURE(Test
, testGroupShapeFontName
)
422 createSwDoc("groupshape-fontname.docx");
423 // Font names inside a group shape were not imported
424 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
425 uno::Reference
<text::XText
> xText
426 = uno::Reference
<text::XTextRange
>(xGroup
->getByIndex(1), uno::UNO_QUERY_THROW
)->getText();
428 CPPUNIT_ASSERT_EQUAL(
430 getProperty
<OUString
>(getRun(getParagraphOfText(1, xText
), 1), u
"CharFontName"_ustr
));
431 CPPUNIT_ASSERT_EQUAL(u
"Calibri"_ustr
,
432 getProperty
<OUString
>(getRun(getParagraphOfText(1, xText
), 1),
433 u
"CharFontNameComplex"_ustr
));
434 CPPUNIT_ASSERT_EQUAL(
436 getProperty
<OUString
>(getRun(getParagraphOfText(1, xText
), 1), u
"CharFontNameAsian"_ustr
));
439 CPPUNIT_TEST_FIXTURE(Test
, testTdf124600
)
441 createSwDoc("tdf124600.docx");
442 // uno::Reference<drawing::XShape> xShape = getShape(1);
443 // Without the accompanying fix in place, this test would have failed with:
446 // i.e. the shape had an unexpected left margin, but not in Word.
447 // Regina: LO needs a left margin to get the same rendering as Word, because Word aligns the
448 // shape with the outer edge of the border, but LibreOffice aligns with the snap rectangle.
449 // Expected: 0 is wrong. ToDo: The current margin is wrong and needs to be fixed. Then activate
450 // the test again with the correct margin.
451 // CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
452 // getProperty<sal_Int32>(xShape, "HoriOrientPosition"));
454 // Make sure that "Shape 1 text" (anchored in the header) has the same left margin as the body
456 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
457 OUString aShapeTextLeft
458 = getXPath(pXmlDoc
, "/root/page/header/txt/anchored/fly/infos/bounds", "left");
459 OUString aBodyTextLeft
= getXPath(pXmlDoc
, "/root/page/body/txt/infos/bounds", "left");
460 // Without the accompanying fix in place, this test would have failed with:
463 // i.e. there was a >0 left margin on the text of the shape, resulting in incorrect horizontal
465 CPPUNIT_ASSERT_DOUBLES_EQUAL(aBodyTextLeft
.toDouble(), aShapeTextLeft
.toDouble(), 1.0);
468 CPPUNIT_TEST_FIXTURE(Test
, testTdf120548
)
470 createSwDoc("tdf120548.docx");
471 // Without the accompanying fix in place, this test would have failed with 'Expected: 00ff0000;
472 // Actual: ffffffff', i.e. the numbering portion was black, not red.
473 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
474 assertXPath(pXmlDoc
, "//SwFieldPortion[@type='PortionType::Number']/SwFont", "color",
478 CPPUNIT_TEST_FIXTURE(Test
, test120551
)
480 createSwDoc("tdf120551.docx");
481 auto nHoriOrientPosition
= getProperty
<sal_Int32
>(getShape(1), u
"HoriOrientPosition"_ustr
);
482 // Without the accompanying fix in place, this test would have failed with
483 // 'Expected: 430, Actual : -2542'.
484 // CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(430), nHoriOrientPosition);
485 // File 140335EMU = 389,8Hmm
486 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(390), nHoriOrientPosition
);
489 CPPUNIT_TEST_FIXTURE(Test
, testTdf111550
)
491 createSwDoc("tdf111550.docx");
492 // The test document has following ill-formed structure:
500 // <w:t>[outer:A2]</w:t>
501 // <w:br w:type="textWrapping"/>
508 // <w:t>[inner:A1]</w:t>
519 // i.e., a <w:tbl> as direct child of <w:p> inside another table.
520 // Word accepts that illegal OOXML, and treats it as equal to
531 // <w:t>[outer:A2]</w:t>
532 // <w:br w:type="textWrapping"/>
535 // <w:t>[inner:A1]</w:t>
545 // i.e., moves all contents of the outer paragraph into the inner table's first paragraph.
547 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
549 uno::Reference
<text::XTextContent
> outerTable
= getParagraphOrTable(1);
550 getCell(outerTable
, u
"A1"_ustr
, u
"[outer:A1]"_ustr
);
551 uno::Reference
<text::XText
> cellA2(getCell(outerTable
, u
"A2"_ustr
), uno::UNO_QUERY_THROW
);
552 uno::Reference
<text::XTextContent
> innerTable
= getParagraphOrTable(1, cellA2
);
553 getCell(innerTable
, u
"A1"_ustr
, u
"[outer:A2]\n[inner:A1]"_ustr
);
556 CPPUNIT_TEST_FIXTURE(Test
, testTdf117843
)
558 createSwDoc("tdf117843.docx");
559 uno::Reference
<container::XNameAccess
> xPageStyles
= getStyles(u
"PageStyles"_ustr
);
560 uno::Reference
<style::XStyle
> xPageStyle(xPageStyles
->getByName(u
"Standard"_ustr
),
562 uno::Reference
<text::XText
> xHeaderText
563 = getProperty
<uno::Reference
<text::XText
>>(xPageStyle
, u
"HeaderText"_ustr
);
564 // This was 4025, increased top paragraph margin was unexpected.
565 CPPUNIT_ASSERT_EQUAL(
566 static_cast<sal_Int32
>(0),
567 getProperty
<sal_Int32
>(getParagraphOfText(1, xHeaderText
), u
"ParaTopMargin"_ustr
));
570 // related tdf#124754
571 CPPUNIT_TEST_FIXTURE(Test
, testTdf43017
)
573 createSwDoc("tdf43017.docx");
574 uno::Reference
<text::XTextRange
> xParagraph
= getParagraph(1);
575 uno::Reference
<text::XTextRange
> xText
= getRun(xParagraph
, 2, u
"kick the bucket"_ustr
);
577 // Ensure that hyperlink text color is not blue (0x0000ff), but default (-1)
578 CPPUNIT_ASSERT_EQUAL_MESSAGE("Hyperlink color should be black!", sal_Int32(-1),
579 getProperty
<sal_Int32
>(xText
, u
"CharColor"_ustr
));
583 CPPUNIT_TEST_FIXTURE(Test
, testTdf124754
)
585 createSwDoc("tdf124754.docx");
586 uno::Reference
<text::XText
> textbox(getShape(1), uno::UNO_QUERY
);
587 CPPUNIT_ASSERT_EQUAL(1, getParagraphs(textbox
));
589 uno::Reference
<text::XTextRange
> xParagraph
= getParagraphOfText(1, textbox
);
590 uno::Reference
<text::XTextRange
> xText
= getRun(xParagraph
, 2);
592 // Ensure that hyperlink text color is not black
593 CPPUNIT_ASSERT_EQUAL_MESSAGE("Hyperlink color should be not black!", sal_Int32(353217),
594 getProperty
<sal_Int32
>(xText
, u
"CharColor"_ustr
));
597 CPPUNIT_TEST_FIXTURE(Test
, testTextCopy
)
599 createSwDoc("text-copy.docx");
600 // The document has a header on the second page that is copied as part of the import process.
601 // The header has a single paragraph: make sure shapes anchored to it are not lost.
602 // Note that the single paragraph itself has no text portions.
603 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
604 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(),
606 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
607 uno::Reference
<beans::XPropertySet
> xPara
;
608 while (xParaEnum
->hasMoreElements())
610 xPara
.set(xParaEnum
->nextElement(), uno::UNO_QUERY
);
612 auto aPageStyleName
= getProperty
<OUString
>(xPara
, u
"PageStyleName"_ustr
);
613 uno::Reference
<beans::XPropertySet
> xPageStyle(
614 getStyles(u
"PageStyles"_ustr
)->getByName(aPageStyleName
), uno::UNO_QUERY
);
615 auto xHeaderText
= getProperty
<uno::Reference
<text::XText
>>(xPageStyle
, u
"HeaderText"_ustr
);
616 uno::Reference
<text::XTextRange
> xHeaderPara
= getParagraphOfText(1, xHeaderText
);
617 auto aTextPortionType
= getProperty
<OUString
>(getRun(xHeaderPara
, 1), u
"TextPortionType"_ustr
);
618 // Without the accompanying fix in place, this test would have failed with:
621 // i.e. the second page's header had no anchored shapes.
622 CPPUNIT_ASSERT_EQUAL(u
"Frame"_ustr
, aTextPortionType
);
625 CPPUNIT_TEST_FIXTURE(Test
, testTdf112443
)
627 createSwDoc("tdf112443.docx");
628 // the position of the flying text frame should be off page
629 // 30624 below its anchor
630 SwDoc
* pDoc
= getSwDoc();
631 SwRootFrame
* pRootFrame
= pDoc
->getIDocumentLayoutAccess().GetCurrentLayout();
632 const SwRect aPageRect
= pRootFrame
->getFrameArea();
633 const SwRect
aShapeRect(getShape(1)->getPosition().X
, getShape(1)->getPosition().Y
,
634 getShape(1)->getSize().Width
, getShape(1)->getSize().Height
);
635 CPPUNIT_ASSERT_MESSAGE("The textframe must be off-page!", !aPageRect
.Contains(aShapeRect
));
637 //OUString aTop = getXPath(pXmlDoc, "//anchored/fly[1]/infos/bounds", "top");
638 //CPPUNIT_ASSERT_EQUAL(sal_Int32(30624), aTop.toInt32() );
641 // DOCX: Textbox wrap differs in MSO and LO
642 // Both should layout text regardless of existing text box
643 // and as result only one page should be generated.
644 CPPUNIT_TEST_FIXTURE(Test
, testTdf113182
)
646 createSwDoc("tdf113182.docx");
647 CPPUNIT_ASSERT_EQUAL(1, getPages());
650 CPPUNIT_TEST_FIXTURE(Test
, testBtlrFrameVml
)
652 createSwDoc("btlr-frame-vml.docx");
653 uno::Reference
<beans::XPropertySet
> xTextFrame(getShape(1), uno::UNO_QUERY
);
654 CPPUNIT_ASSERT(xTextFrame
.is());
656 auto nActual
= getProperty
<sal_Int16
>(xTextFrame
, u
"WritingMode"_ustr
);
657 // Without the accompanying fix in place, this test would have failed with 'Expected: 5; Actual:
658 // 4', i.e. writing direction was inherited from page, instead of explicit btlr.
659 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR
, nActual
);
662 CPPUNIT_TEST_FIXTURE(Test
, testTdf124398
)
664 createSwDoc("tdf124398.docx");
665 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
666 CPPUNIT_ASSERT(xGroup
.is());
667 // Without the accompanying fix in place, this test would have failed with 'Expected: 2; Actual:
668 // 1', i.e. the chart children of the group shape was lost.
669 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xGroup
->getCount());
671 uno::Reference
<drawing::XShapeDescriptor
> xShape(xGroup
->getByIndex(1), uno::UNO_QUERY
);
672 CPPUNIT_ASSERT_EQUAL(u
"com.sun.star.drawing.OLE2Shape"_ustr
, xShape
->getShapeType());
675 CPPUNIT_TEST_FIXTURE(Test
, testTdf104167
)
677 createSwDoc("tdf104167.docx");
678 // Make sure that heading 1 paragraphs start on a new page.
679 uno::Any xStyle
= getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Heading 1"_ustr
);
680 // Without the accompanying fix in place, this test would have failed with:
683 // i.e. the <w:pageBreakBefore/> was lost on import.
684 CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE
,
685 getProperty
<style::BreakType
>(xStyle
, u
"BreakType"_ustr
));
688 CPPUNIT_TEST_FIXTURE(Test
, testTdf113946
)
690 createSwDoc("tdf113946.docx");
691 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
693 = getXPath(pXmlDoc
, "/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds", "top");
694 // tdf#106792 Checked loading of tdf113946.docx. Before the change, the expected
695 // value of this test was "1696". Opening the file shows a single short line anchored
696 // at the doc start. Only diff is that in 'old' version it is slightly rotated, in 'new'
697 // version line is strict horizontal. Checked against MSWord2013, there the line
698 // is also not rotated -> the change is to the better, correct the expected result here.
699 CPPUNIT_ASSERT_EQUAL(u
"1695"_ustr
, aTop
);
702 CPPUNIT_TEST_FIXTURE(Test
, testTdf121804
)
704 createSwDoc("tdf121804.docx");
705 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
706 uno::Reference
<text::XTextRange
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
707 uno::Reference
<text::XTextRange
> xFirstPara
= getParagraphOfText(1, xShape
->getText());
708 uno::Reference
<text::XTextRange
> xFirstRun
= getRun(xFirstPara
, 1);
709 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0),
710 getProperty
<sal_Int32
>(xFirstRun
, u
"CharEscapement"_ustr
));
711 // This failed with a NoSuchElementException, super/subscript property was
712 // lost on import, so the whole paragraph was a single run.
713 uno::Reference
<text::XTextRange
> xSecondRun
= getRun(xFirstPara
, 2);
714 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(14000),
715 getProperty
<sal_Int32
>(xSecondRun
, u
"CharEscapement"_ustr
));
716 uno::Reference
<text::XTextRange
> xThirdRun
= getRun(xFirstPara
, 3);
717 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-14000),
718 getProperty
<sal_Int32
>(xThirdRun
, u
"CharEscapement"_ustr
));
721 CPPUNIT_TEST_FIXTURE(Test
, testTdf114217
)
723 // The floating table was not split between page 1 and page 2.
724 createSwDoc("tdf114217.docx");
725 SwDoc
* pDoc
= getSwDoc();
726 SwRootFrame
* pLayout
= pDoc
->getIDocumentLayoutAccess().GetCurrentLayout();
727 auto pPage1
= dynamic_cast<SwPageFrame
*>(pLayout
->Lower());
728 CPPUNIT_ASSERT(pPage1
);
729 const SwSortedObjs
& rPage1Objs
= *pPage1
->GetSortedObjs();
730 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage1Objs
.size());
731 auto pPage1Fly
= dynamic_cast<SwFlyAtContentFrame
*>(rPage1Objs
[0]);
732 CPPUNIT_ASSERT(pPage1Fly
);
733 auto pTab1
= dynamic_cast<SwTabFrame
*>(pPage1Fly
->GetLower());
734 CPPUNIT_ASSERT(pTab1
);
735 CPPUNIT_ASSERT(pTab1
->HasFollow());
738 CPPUNIT_TEST_FIXTURE(Test
, testTdf119200
)
740 createSwDoc("tdf119200.docx");
741 auto xPara
= getParagraph(1);
742 // Check that we import MathType functional symbols as symbols, not functions with missing args
743 CPPUNIT_ASSERT_EQUAL(u
" size 12{ func \u2208 } {}"_ustr
, getFormula(getRun(xPara
, 1)));
744 CPPUNIT_ASSERT_EQUAL(u
" size 12{ func \u2209 } {}"_ustr
, getFormula(getRun(xPara
, 2)));
745 CPPUNIT_ASSERT_EQUAL(u
" size 12{ func \u2282 } {}"_ustr
, getFormula(getRun(xPara
, 3)));
746 CPPUNIT_ASSERT_EQUAL(u
" size 12{ func \u2283 } {}"_ustr
, getFormula(getRun(xPara
, 4)));
747 CPPUNIT_ASSERT_EQUAL(u
" size 12{ func \u2284 } {}"_ustr
, getFormula(getRun(xPara
, 5)));
748 CPPUNIT_ASSERT_EQUAL(u
" size 12{ func \u2286 } {}"_ustr
, getFormula(getRun(xPara
, 6)));
749 CPPUNIT_ASSERT_EQUAL(u
" size 12{ func \u2287 } {}"_ustr
, getFormula(getRun(xPara
, 7)));
752 // Checking a formula where the closing brackets
753 // come first, and then the opening ones
754 CPPUNIT_TEST_FIXTURE(Test
, testTdf158023Import
)
756 auto verify
= [this]() {
757 auto xPara
= getParagraph(1);
758 CPPUNIT_ASSERT_EQUAL(u
"\\) sqrt {\\)2\\(} \\("_ustr
, getFormula(getRun(xPara
, 1)));
760 auto verifyReload
= [this]() {
761 auto xPara
= getParagraph(1);
762 CPPUNIT_ASSERT_EQUAL(u
"\\) sqrt {\\) 2 \\(} \\("_ustr
, getFormula(getRun(xPara
, 1)));
765 createSwDoc("tdf158023_import.docx");
768 saveAndReload(u
"Office Open XML Text"_ustr
);
772 CPPUNIT_TEST_FIXTURE(Test
, testTdf115094
)
774 createSwDoc("tdf115094.docx");
775 // anchor of graphic has to be the text in the text frame
776 // xray ThisComponent.DrawPage(1).Anchor.Text
777 uno::Reference
<text::XTextContent
> xShape(getShape(2), uno::UNO_QUERY
);
778 uno::Reference
<text::XTextRange
> xText1
= xShape
->getAnchor()->getText();
780 // xray ThisComponent.TextTables(0).getCellByName("A1")
781 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
782 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(),
784 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
785 uno::Reference
<text::XTextRange
> xText2(xTable
->getCellByName(u
"A1"_ustr
), uno::UNO_QUERY
);
787 CPPUNIT_ASSERT_EQUAL(xText1
.get(), xText2
.get());
790 CPPUNIT_TEST_FIXTURE(Test
, testTdf115094v2
)
792 createSwDoc("tdf115094v2.docx");
793 // layoutInCell="1" combined with <wp:wrapNone/>
795 CPPUNIT_ASSERT(getProperty
<bool>(getShapeByName(u
"Grafik 18"), u
"IsFollowingTextFlow"_ustr
));
796 CPPUNIT_ASSERT(getProperty
<bool>(getShapeByName(u
"Grafik 19"), u
"IsFollowingTextFlow"_ustr
));
799 CPPUNIT_TEST_FIXTURE(Test
, testTdf122224
)
801 createSwDoc("tdf122224.docx");
802 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
803 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
805 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
806 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName(u
"A2"_ustr
), uno::UNO_QUERY_THROW
);
807 // This was "** Expression is faulty **", because of the unnecessary DOCX number format string
808 CPPUNIT_ASSERT_EQUAL(u
"2000"_ustr
, xCell
->getString());
811 CPPUNIT_TEST_FIXTURE(Test
, testTdf121440
)
813 createSwDoc("tdf121440.docx");
814 // Insert some text in front of footnote
815 SwWrtShell
* pWrtShell
= getSwDocShell()->GetWrtShell();
816 SwRootFrame
* pLayout(pWrtShell
->GetLayout());
817 CPPUNIT_ASSERT(!pLayout
->IsHideRedlines());
818 pWrtShell
->Insert(u
"test"_ustr
);
820 // Ensure that inserted text is not superscripted
821 CPPUNIT_ASSERT_EQUAL_MESSAGE(
822 "Inserted text should be not a superscript!", static_cast<sal_Int32
>(0),
823 getProperty
<sal_Int32
>(getRun(getParagraph(1), 1), u
"CharEscapement"_ustr
));
826 CPPUNIT_TEST_FIXTURE(Test
, testTdf124670
)
828 createSwDoc("tdf124670.docx");
829 CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
830 // We need to take xml:space attribute into account, even in w:document element
831 uno::Reference
<text::XTextRange
> paragraph
= getParagraph(1);
832 CPPUNIT_ASSERT_EQUAL(
833 u
"You won't believe, but that's how it was in markup of original bugdoc!"_ustr
,
834 paragraph
->getString());
837 CPPUNIT_TEST_FIXTURE(Test
, testTdf126114
)
839 createSwDoc("tdf126114.docx");
840 // The problem was that after the drop-down form field, also the placeholder string
841 // was imported as text. Beside the duplication of the field, it also caused a crash.
842 // the word is from replacement of the drop-down field in ModelToViewHelper
843 CPPUNIT_ASSERT_EQUAL(u
"gehuwd\n"_ustr
, getBodyText());
846 CPPUNIT_TEST_FIXTURE(Test
, testTdf127825
)
848 createSwDoc("tdf127825.docx");
849 // The document has a shape with Japanese-style text in it. The shape has relative size and also
850 // has automatic height.
851 SwWrtShell
* pWrtShell
= getSwDocShell()->GetWrtShell();
852 CPPUNIT_ASSERT(pWrtShell
);
853 SwRootFrame
* pLayout
= pWrtShell
->GetLayout();
854 CPPUNIT_ASSERT(pLayout
);
855 SwFrame
* pPage
= pLayout
->GetLower();
856 CPPUNIT_ASSERT(pPage
);
857 SwFrame
* pBody
= pPage
->GetLower();
858 CPPUNIT_ASSERT(pBody
);
859 SwFrame
* pText
= pBody
->GetLower();
860 CPPUNIT_ASSERT(pText
);
861 CPPUNIT_ASSERT(pText
->GetDrawObjs());
862 const SwSortedObjs
& rDrawObjs
= *pText
->GetDrawObjs();
863 CPPUNIT_ASSERT(rDrawObjs
.size());
865 // Without the accompanying fix in place, this overlapped the footer area, not the body area.
866 CPPUNIT_ASSERT(rDrawObjs
[0]->GetObjRect().Overlaps(pBody
->getFrameArea()));
869 CPPUNIT_TEST_FIXTURE(Test
, testTdf103345
)
871 createSwDoc("numbering-circle.docx");
872 uno::Reference
<beans::XPropertySet
> xPropertySet(
873 getStyles(u
"NumberingStyles"_ustr
)->getByName(u
"WWNum1"_ustr
), uno::UNO_QUERY
);
874 uno::Reference
<container::XIndexAccess
> xLevels(
875 xPropertySet
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
876 uno::Sequence
<beans::PropertyValue
> aProps
;
877 xLevels
->getByIndex(0) >>= aProps
; // 1st level
879 for (beans::PropertyValue
const& prop
: aProps
)
881 if (prop
.Name
== "NumberingType")
883 CPPUNIT_ASSERT_EQUAL(style::NumberingType::CIRCLE_NUMBER
, prop
.Value
.get
<sal_Int16
>());
889 CPPUNIT_TEST_FIXTURE(Test
, testTdf125038
)
891 createSwDoc("tdf125038.docx");
892 OUString aActual
= getParagraph(1)->getString();
893 // Without the accompanying fix in place, this test would have failed with:
894 // - Expected: phone:...
895 // - Actual : result1result2phone:...
896 // i.e. the result if the inner MERGEFIELD fields ended up in the body text.
897 CPPUNIT_ASSERT_EQUAL(u
"phone: \t1234567890"_ustr
, aActual
);
900 CPPUNIT_TEST_FIXTURE(Test
, testTdf125038b
)
902 createSwDoc("tdf125038b.docx");
903 // Load a document with an IF field, where the IF field command contains a paragraph break.
904 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
905 uno::Reference
<container::XEnumerationAccess
> xParagraphAccess(xTextDocument
->getText(),
907 uno::Reference
<container::XEnumeration
> xParagraphs
= xParagraphAccess
->createEnumeration();
908 CPPUNIT_ASSERT(xParagraphs
->hasMoreElements());
909 uno::Reference
<text::XTextRange
> xParagraph(xParagraphs
->nextElement(), uno::UNO_QUERY
);
911 // Without the accompanying fix in place, this test would have failed with:
912 // - Expected: phone: 1234
914 // i.e. the first paragraph was empty and the second paragraph had the content.
915 CPPUNIT_ASSERT_EQUAL(u
"phone: 1234"_ustr
, xParagraph
->getString());
916 CPPUNIT_ASSERT(xParagraphs
->hasMoreElements());
917 xParagraphs
->nextElement();
919 // Without the accompanying fix in place, this test would have failed with:
920 // - Expression: !xParagraphs->hasMoreElements()
921 // i.e. the document had 3 paragraphs, while only 2 was expected.
922 CPPUNIT_ASSERT(!xParagraphs
->hasMoreElements());
925 CPPUNIT_TEST_FIXTURE(Test
, testTdf125038c
)
927 createSwDoc("tdf125038c.docx");
928 OUString aActual
= getParagraph(1)->getString();
929 // Without the accompanying fix in place, this test would have failed with:
930 // - Expected: email: test@test.test
932 // I.e. the result of the MERGEFIELD field inside an IF field was lost.
933 CPPUNIT_ASSERT_EQUAL(u
"email: test@test.test"_ustr
, aActual
);
936 CPPUNIT_TEST_FIXTURE(Test
, testTdf130214
)
938 createSwDoc("tdf130214.docx");
939 // Currently this file imports with errors because of tdf#126435; it must not segfault on load
942 CPPUNIT_TEST_FIXTURE(Test
, testTdf129659
)
944 createSwDoc("tdf129659.docx");
945 // don't crash on footnote with page break
948 CPPUNIT_TEST_FIXTURE(Test
, testTdf129912
)
950 createSwDoc("tdf129912.docx");
951 SwWrtShell
* pWrtShell
= getSwDocShell()->GetWrtShell();
952 CPPUNIT_ASSERT(pWrtShell
);
954 // Goto*FootnoteAnchor iterates the footnotes in a ring, so we need the amount of footnotes to stop the loop
955 sal_Int32 nCount
= pWrtShell
->GetDoc()->GetFootnoteIdxs().size();
956 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), nCount
);
958 // the expected footnote labels
959 // TODO: the 5th label is actually wrong (missing the "PR" after the symbol part), but the "b" is there?!
960 static constexpr OUString pLabel5
= u
"\uF0D1\uF031\uF032b"_ustr
;
961 const OUString sFootnoteLabels
[]
962 = { OUString(u
'\xF0A7'), u
"1"_ustr
, u
"2"_ustr
, OUString(u
'\xF020'), pLabel5
};
963 CPPUNIT_ASSERT_EQUAL(sal_Int32(SAL_N_ELEMENTS(sFootnoteLabels
)), nCount
);
965 pWrtShell
->GotoPrevFootnoteAnchor();
969 SwFormatFootnote aFootnoteNote
;
970 CPPUNIT_ASSERT(pWrtShell
->GetCurFootnote(&aFootnoteNote
));
971 OUString sNumStr
= aFootnoteNote
.GetNumStr();
972 if (sNumStr
.isEmpty())
973 sNumStr
= OUString::number(aFootnoteNote
.GetNumber());
974 CPPUNIT_ASSERT_EQUAL(sFootnoteLabels
[nCount
], sNumStr
);
975 pWrtShell
->GotoPrevFootnoteAnchor();
980 CPPUNIT_TEST_FIXTURE(Test
, testTdf126426
)
982 createSwDoc("tdf126426.docx");
984 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY_THROW
);
985 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroup
->getCount());
987 // get second shape in group
988 uno::Reference
<text::XTextRange
> xRange(xGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
989 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xRange
, uno::UNO_QUERY_THROW
);
990 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
992 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY_THROW
);
993 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xPara
, uno::UNO_QUERY_THROW
);
995 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
997 // Text before: was before this bugfix
998 uno::Reference
<text::XTextRange
> xRun(xRunEnum
->nextElement(), uno::UNO_QUERY_THROW
);
999 CPPUNIT_ASSERT_EQUAL(u
"Some text "_ustr
, xRun
->getString());
1002 // Link and this content was completely missing before
1003 uno::Reference
<text::XTextRange
> xRun(xRunEnum
->nextElement(), uno::UNO_QUERY_THROW
);
1004 CPPUNIT_ASSERT_EQUAL(u
"Link"_ustr
, xRun
->getString());
1005 auto aURL
= getProperty
<OUString
>(xRun
, u
"HyperLinkURL"_ustr
);
1006 CPPUNIT_ASSERT_EQUAL(u
"http://libreoffice.org/"_ustr
, aURL
);
1009 // Need to ensure that text following hyperlink is still default color (-1)
1010 uno::Reference
<text::XTextRange
> xRun(xRunEnum
->nextElement(), uno::UNO_QUERY_THROW
);
1011 CPPUNIT_ASSERT_EQUAL(u
" and something more."_ustr
, xRun
->getString());
1012 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(xRun
, u
"CharColor"_ustr
));
1016 CPPUNIT_TEST_FIXTURE(Test
, testTdf119039
)
1018 createSwDoc("tdf119039_bad_embedded_compound.docx");
1019 // Should not crash/hang because of problematic embedded compound
1022 CPPUNIT_TEST_FIXTURE(Test
, testTdf152200
)
1024 createSwDoc("tdf152200-bad_fldChar_end.docx");
1025 // Should not crash/hang because of wrong placement of ending fldChar
1028 CPPUNIT_TEST_FIXTURE(Test
, testTdf153791
)
1030 createSwDoc("tdf153791-shd_overrides_fontRef.docx");
1032 // the first shape (a paragraph with no background)
1033 auto xTextBox(getShape(1));
1034 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED
, getProperty
<Color
>(xTextBox
, u
"CharColor"_ustr
));
1035 uno::Reference
<text::XTextRange
> xRange(xTextBox
, uno::UNO_QUERY_THROW
);
1036 CPPUNIT_ASSERT_EQUAL(u
"Lorem ipsum"_ustr
, xRange
->getString());
1038 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xRange
, uno::UNO_QUERY_THROW
);
1039 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1041 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY_THROW
);
1042 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, getProperty
<Color
>(xPara
, u
"ParaBackColor"_ustr
));
1044 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xPara
, uno::UNO_QUERY_THROW
);
1045 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
1047 uno::Reference
<text::XTextRange
> xRun(xRunEnum
->nextElement(), uno::UNO_QUERY_THROW
);
1048 CPPUNIT_ASSERT_EQUAL(u
"Lorem ipsum"_ustr
, xRun
->getString());
1049 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, getProperty
<Color
>(xRun
, u
"CharBackColor"_ustr
));
1050 // In the absence of paragraph/character background, the whole paragraph is red.
1051 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED
, getProperty
<Color
>(xRun
, u
"CharColor"_ustr
));
1053 // the second shape: two paragraphs
1054 xTextBox
.set(getShape(2));
1055 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED
, getProperty
<Color
>(xTextBox
, u
"CharColor"_ustr
));
1056 xRange
.set(xTextBox
, uno::UNO_QUERY_THROW
);
1057 CPPUNIT_ASSERT_EQUAL(u
"Lorem ipsum" SAL_NEWLINE_STRING
"Lorem ipsum"_ustr
, xRange
->getString());
1059 xParaEnumAccess
.set(xRange
, uno::UNO_QUERY_THROW
);
1060 xParaEnum
= xParaEnumAccess
->createEnumeration();
1062 // the first one has paragraph background
1063 xPara
.set(xParaEnum
->nextElement(), uno::UNO_QUERY_THROW
);
1064 CPPUNIT_ASSERT_EQUAL(Color(0xF0F0F0), getProperty
<Color
>(xPara
, u
"ParaBackColor"_ustr
));
1066 xRunEnumAccess
.set(xPara
, uno::UNO_QUERY_THROW
);
1067 xRunEnum
= xRunEnumAccess
->createEnumeration();
1069 xRun
.set(xRunEnum
->nextElement(), uno::UNO_QUERY_THROW
);
1070 CPPUNIT_ASSERT_EQUAL(u
"Lorem ipsum"_ustr
, xRun
->getString());
1071 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, getProperty
<Color
>(xRun
, u
"CharBackColor"_ustr
));
1072 // With paragraph background, the whole paragraph is auto.
1073 // Without the fix, this would fail with:
1074 // - Expected: rgba[ffffff00]
1075 // - Actual : rgba[ff0000ff]
1076 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, getProperty
<Color
>(xRun
, u
"CharColor"_ustr
));
1078 // the second paragraph has two runs, the last one with character background
1079 xPara
.set(xParaEnum
->nextElement(), uno::UNO_QUERY_THROW
);
1080 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, getProperty
<Color
>(xPara
, u
"ParaBackColor"_ustr
));
1082 xRunEnumAccess
.set(xPara
, uno::UNO_QUERY_THROW
);
1083 xRunEnum
= xRunEnumAccess
->createEnumeration();
1085 xRun
.set(xRunEnum
->nextElement(), uno::UNO_QUERY_THROW
);
1086 CPPUNIT_ASSERT_EQUAL(u
"Lorem "_ustr
, xRun
->getString());
1087 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, getProperty
<Color
>(xRun
, u
"CharBackColor"_ustr
));
1088 // In the absence of paragraph/character background, the run is red
1089 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED
, getProperty
<Color
>(xRun
, u
"CharColor"_ustr
));
1091 xRun
.set(xRunEnum
->nextElement(), uno::UNO_QUERY_THROW
);
1092 CPPUNIT_ASSERT_EQUAL(u
"ipsum"_ustr
, xRun
->getString());
1093 CPPUNIT_ASSERT_EQUAL(Color(0xF0F0F0), getProperty
<Color
>(xRun
, u
"CharBackColor"_ustr
));
1094 // With character background, the run is auto.
1095 // Without the fix, this would fail with:
1096 // - Expected: rgba[ffffff00]
1097 // - Actual : rgba[ff0000ff]
1098 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, getProperty
<Color
>(xRun
, u
"CharColor"_ustr
));
1101 CPPUNIT_TEST_FIXTURE(Test
, testTdf154319
)
1103 createSwDoc("tdf154319-ToC_with_s_and_d.docx");
1105 auto xSupplier(mxComponent
.queryThrow
<css::text::XDocumentIndexesSupplier
>());
1106 auto xIndexes
= xSupplier
->getDocumentIndexes();
1107 auto xTOCIndex(xIndexes
->getByIndex(0).queryThrow
<css::beans::XPropertySet
>());
1108 css::uno::Reference
<css::container::XIndexReplace
> xLevelFormats
;
1109 CPPUNIT_ASSERT(xTOCIndex
->getPropertyValue(u
"LevelFormat"_ustr
) >>= xLevelFormats
);
1110 CPPUNIT_ASSERT_EQUAL(sal_Int32(11), xLevelFormats
->getCount());
1112 const auto checkPropVal
= [](const auto& expected
, const css::beans::PropertyValues
& entry
,
1113 const OUString
& name
, sal_Int32 level
) {
1115 = std::find_if(entry
.begin(), entry
.end(),
1116 [&name
](const css::beans::PropertyValue
& p
) { return p
.Name
== name
; });
1117 OString msg
= "Property: " + name
.toUtf8() + ", level: " + OString::number(level
);
1118 CPPUNIT_ASSERT_MESSAGE(msg
.getStr(), it
!= entry
.end());
1119 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg
.getStr(), css::uno::Any(expected
), it
->Value
);
1122 // tdf#154360: check tab stops between the number and the entry text
1123 // The last (10th) level does not correspond to any MS level (only 9 levels there)
1124 static constexpr sal_Int32 levelTabStops
[]
1125 = { 776, 1552, 2328, 3104, 3881, 4657, 5433, 6209, 6985, -1 };
1127 //start with level 1, 0 is the header level
1128 for (sal_Int32 nLevel
= 1; nLevel
< xLevelFormats
->getCount(); ++nLevel
)
1130 css::uno::Sequence
<css::beans::PropertyValues
> aLevel
;
1131 xLevelFormats
->getByIndex(nLevel
) >>= aLevel
;
1133 sal_Int32 nTabStop
= levelTabStops
[nLevel
- 1];
1134 sal_Int32 nExpectedTokens
= nTabStop
< 0 ? 8 : 9;
1135 CPPUNIT_ASSERT_EQUAL(nExpectedTokens
, aLevel
.getLength());
1136 sal_Int32 nIndex
= 0;
1138 checkPropVal(u
"TokenHyperlinkStart"_ustr
, aLevel
[nIndex
++], u
"TokenType"_ustr
, nLevel
);
1140 checkPropVal(u
"TokenEntryNumber"_ustr
, aLevel
[nIndex
++], u
"TokenType"_ustr
, nLevel
);
1144 checkPropVal(u
"TokenTabStop"_ustr
, aLevel
[nIndex
], u
"TokenType"_ustr
, nLevel
);
1145 checkPropVal(levelTabStops
[nLevel
- 1], aLevel
[nIndex
++], u
"TabStopPosition"_ustr
,
1149 checkPropVal(u
"TokenEntryText"_ustr
, aLevel
[nIndex
++], u
"TokenType"_ustr
, nLevel
);
1151 checkPropVal(u
"TokenTabStop"_ustr
, aLevel
[nIndex
++], u
"TokenType"_ustr
, nLevel
);
1153 checkPropVal(u
"TokenChapterInfo"_ustr
, aLevel
[nIndex
++], u
"TokenType"_ustr
, nLevel
);
1155 checkPropVal(u
"TokenText"_ustr
, aLevel
[nIndex
], u
"TokenType"_ustr
, nLevel
);
1156 checkPropVal(u
"\""_ustr
, aLevel
[nIndex
++], u
"Text"_ustr
, nLevel
);
1158 checkPropVal(u
"TokenPageNumber"_ustr
, aLevel
[nIndex
++], u
"TokenType"_ustr
, nLevel
);
1160 checkPropVal(u
"TokenHyperlinkEnd"_ustr
, aLevel
[nIndex
++], u
"TokenType"_ustr
, nLevel
);
1164 CPPUNIT_TEST_FIXTURE(Test
, testTdf154695
)
1166 createSwDoc("tdf154695-ToC_no_numbers.docx");
1168 auto xSupplier(mxComponent
.queryThrow
<css::text::XDocumentIndexesSupplier
>());
1169 auto xIndexes
= xSupplier
->getDocumentIndexes();
1170 auto xTOCIndex(xIndexes
->getByIndex(0).queryThrow
<css::beans::XPropertySet
>());
1171 css::uno::Reference
<css::container::XIndexReplace
> xLevelFormats
;
1172 CPPUNIT_ASSERT(xTOCIndex
->getPropertyValue(u
"LevelFormat"_ustr
) >>= xLevelFormats
);
1173 CPPUNIT_ASSERT_EQUAL(sal_Int32(11), xLevelFormats
->getCount());
1175 const auto checkPropVal
= [](const auto& expected
, const css::beans::PropertyValues
& entry
,
1176 const OUString
& name
, sal_Int32 level
) {
1178 = std::find_if(entry
.begin(), entry
.end(),
1179 [&name
](const css::beans::PropertyValue
& p
) { return p
.Name
== name
; });
1180 OString msg
= "Property: " + name
.toUtf8() + ", level: " + OString::number(level
);
1181 CPPUNIT_ASSERT_MESSAGE(msg
.getStr(), it
!= entry
.end());
1182 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg
.getStr(), css::uno::Any(expected
), it
->Value
);
1185 //start with level 1, 0 is the header level
1186 for (sal_Int32 nLevel
= 1; nLevel
< xLevelFormats
->getCount(); ++nLevel
)
1188 css::uno::Sequence
<css::beans::PropertyValues
> aLevel
;
1189 xLevelFormats
->getByIndex(nLevel
) >>= aLevel
;
1191 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), aLevel
.getLength());
1193 checkPropVal(u
"TokenHyperlinkStart"_ustr
, aLevel
[0], u
"TokenType"_ustr
, nLevel
);
1195 checkPropVal(u
"TokenEntryNumber"_ustr
, aLevel
[1], u
"TokenType"_ustr
, nLevel
);
1197 // There's no tab stop between [#E] and [E]!
1199 checkPropVal(u
"TokenEntryText"_ustr
, aLevel
[2], u
"TokenType"_ustr
, nLevel
);
1201 checkPropVal(u
"TokenTabStop"_ustr
, aLevel
[3], u
"TokenType"_ustr
, nLevel
);
1203 checkPropVal(u
"TokenPageNumber"_ustr
, aLevel
[4], u
"TokenType"_ustr
, nLevel
);
1205 checkPropVal(u
"TokenHyperlinkEnd"_ustr
, aLevel
[5], u
"TokenType"_ustr
, nLevel
);
1209 CPPUNIT_TEST_FIXTURE(Test
, testTdf156078
)
1211 // Given a DOCX with compat level 15, and a tab stop outside of paragraph right indent
1212 createSwDoc("tdf156078_rightTabOutsideParaRightIndent.docx");
1214 // Export it to a PNG (96 ppi)
1215 uno::Sequence
<beans::PropertyValue
> aFilterData(
1216 comphelper::InitPropertySequence({ { "PixelWidth", uno::Any(sal_Int32(816)) },
1217 { "PixelHeight", uno::Any(sal_Int32(1056)) } }));
1218 uno::Sequence
<beans::PropertyValue
> aDescriptor(
1219 comphelper::InitPropertySequence({ { "FilterName", uno::Any(u
"writer_png_Export"_ustr
) },
1220 { "FilterData", uno::Any(aFilterData
) } }));
1221 uno::Reference
<frame::XStorable
> xStorable(mxComponent
, uno::UNO_QUERY
);
1222 xStorable
->storeToURL(maTempFile
.GetURL(), aDescriptor
);
1223 CPPUNIT_ASSERT(maTempFile
.IsValid());
1226 GraphicFilter::LoadGraphic(maTempFile
.GetURL(), {}, exported
);
1227 Bitmap bmp
= exported
.GetBitmapEx().GetBitmap();
1228 BitmapScopedReadAccess
pAccess(bmp
);
1230 // "1" must export to the top right corner; check its pixels
1231 bool numberPixelsFound
= false;
1232 for (tools::Long y
= 90; y
< 130; ++y
)
1233 for (tools::Long x
= 680; x
< 720; ++x
)
1234 if (Color(pAccess
->GetPixel(y
, x
)).IsDark())
1235 numberPixelsFound
= true;
1237 CPPUNIT_ASSERT(numberPixelsFound
);
1240 CPPUNIT_TEST_FIXTURE(Test
, testTdf141969
)
1242 // Given a file with a table with a style setting font height, and a text re-defining the height
1243 createSwDoc("tdf141969-font_in_table_with_style.docx");
1245 auto xTable
= getParagraphOrTable(2);
1246 uno::Reference
<text::XText
> xCell(getCell(xTable
, u
"A1"_ustr
), uno::UNO_QUERY_THROW
);
1247 auto xParaOfCell
= getParagraphOfText(1, xCell
);
1248 auto xRun
= getRun(xParaOfCell
, 1);
1250 CPPUNIT_ASSERT_EQUAL(u
"<<link:website>>"_ustr
, xRun
->getString());
1251 // Without a fix, this would fail with
1254 CPPUNIT_ASSERT_EQUAL(8.0f
, getProperty
<float>(xRun
, u
"CharHeight"_ustr
));
1257 CPPUNIT_TEST_FIXTURE(Test
, testTdf154370
)
1259 // Import a file with paragraph and character styles containing toggle properties applied to the end of
1260 // the paragraphs. Should result in hard attributes resetting the properties
1261 createSwDoc("tdf154370.docx");
1263 auto xPara(getParagraph(2));
1264 auto xRun
= getRun(xPara
, 2);
1266 OUString rangeText
= xRun
->getString();
1267 CPPUNIT_ASSERT_EQUAL(u
"CharStyle BoldItalicCapsEmbossedStrike"_ustr
, rangeText
);
1269 const uno::Reference
<beans::XPropertyState
> xRangePropState(xRun
, uno::UNO_QUERY_THROW
);
1270 beans::PropertyState ePropertyState
= xRangePropState
->getPropertyState(u
"CharWeight"_ustr
);
1271 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1273 ePropertyState
= xRangePropState
->getPropertyState(u
"CharWeightComplex"_ustr
);
1274 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1276 ePropertyState
= xRangePropState
->getPropertyState(u
"CharWeightAsian"_ustr
);
1277 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1279 ePropertyState
= xRangePropState
->getPropertyState(u
"CharPosture"_ustr
);
1280 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1282 ePropertyState
= xRangePropState
->getPropertyState(u
"CharPostureAsian"_ustr
);
1283 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1285 ePropertyState
= xRangePropState
->getPropertyState(u
"CharCaseMap"_ustr
);
1286 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1288 ePropertyState
= xRangePropState
->getPropertyState(u
"CharRelief"_ustr
);
1289 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1291 ePropertyState
= xRangePropState
->getPropertyState(u
"CharStrikeout"_ustr
);
1292 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1295 auto xPara(getParagraph(3));
1296 auto xRun
= getRun(xPara
, 2);
1298 OUString rangeText
= xRun
->getString();
1299 CPPUNIT_ASSERT_EQUAL(u
"CharStyle SmallcapsImprint"_ustr
, rangeText
);
1301 const uno::Reference
<beans::XPropertyState
> xRangePropState(xRun
, uno::UNO_QUERY_THROW
);
1302 beans::PropertyState ePropertyState
1303 = xRangePropState
->getPropertyState(u
"CharCaseMap"_ustr
);
1304 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1306 ePropertyState
= xRangePropState
->getPropertyState(u
"CharRelief"_ustr
);
1307 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1310 auto xPara(getParagraph(5));
1311 auto xRun
= getRun(xPara
, 2);
1313 OUString rangeText
= xRun
->getString();
1314 CPPUNIT_ASSERT_EQUAL(u
"CharStyle Hidden"_ustr
, rangeText
);
1316 const uno::Reference
<beans::XPropertyState
> xRangePropState(xRun
, uno::UNO_QUERY_THROW
);
1317 beans::PropertyState ePropertyState
= xRangePropState
->getPropertyState(u
"CharHidden"_ustr
);
1318 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1321 auto xPara(getParagraph(7));
1322 auto xRun
= getRun(xPara
, 2);
1324 OUString rangeText
= xRun
->getString();
1325 CPPUNIT_ASSERT_EQUAL(u
"OutlineShadow"_ustr
, rangeText
);
1327 const uno::Reference
<beans::XPropertyState
> xRangePropState(xRun
, uno::UNO_QUERY_THROW
);
1328 beans::PropertyState ePropertyState
1329 = xRangePropState
->getPropertyState(u
"CharContoured"_ustr
);
1330 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1332 ePropertyState
= xRangePropState
->getPropertyState(u
"CharShadowed"_ustr
);
1333 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1336 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
1338 } // end of anonymous namespace
1339 CPPUNIT_PLUGIN_IMPLEMENT();
1341 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */