tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sw / qa / extras / ww8export / ww8export3.cxx
blob3e1c5497b25fc0859c1b62bcadc15d5a6661ff50
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <swmodeltestbase.hxx>
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/container/XIndexAccess.hpp>
14 #include <com/sun/star/drawing/BitmapMode.hpp>
15 #include <com/sun/star/drawing/FillStyle.hpp>
16 #include <com/sun/star/drawing/LineDash.hpp>
17 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
18 #include <com/sun/star/graphic/XGraphic.hpp>
19 #include <com/sun/star/table/ShadowFormat.hpp>
20 #include <com/sun/star/text/XFormField.hpp>
21 #include <com/sun/star/text/XTextField.hpp>
22 #include <com/sun/star/text/XTextTable.hpp>
23 #include <com/sun/star/text/XTextTablesSupplier.hpp>
24 #include <com/sun/star/text/WritingMode2.hpp>
25 #include <com/sun/star/text/XTextContentAppend.hpp>
26 #include <com/sun/star/frame/XStorable.hpp>
27 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
28 #include <com/sun/star/text/XFootnotesSupplier.hpp>
29 #include <com/sun/star/text/XTextDocument.hpp>
30 #include <com/sun/star/text/XLineNumberingProperties.hpp>
31 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
33 #include <comphelper/sequenceashashmap.hxx>
35 #include <IDocumentSettingAccess.hxx>
36 #include <docsh.hxx>
37 #include <unotxdoc.hxx>
38 #include <formatlinebreak.hxx>
39 #include <o3tl/string_view.hxx>
41 class Test : public SwModelTestBase
43 public:
44 Test()
45 : SwModelTestBase(u"/sw/qa/extras/ww8export/data/"_ustr, u"MS Word 97"_ustr)
50 DECLARE_WW8EXPORT_TEST(testTdf37778_readonlySection, "tdf37778_readonlySection.doc")
52 uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
53 CPPUNIT_ASSERT( xStorable->isReadonly() );
55 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
56 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
57 // The problem was that section protection was being enabled in addition to being read-only.
58 // This created an explicit section with protection. There should be just the default, non-explicit section.
59 CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of Sections", sal_Int32(0), xSections->getCount());
61 // tdf#127862: page fill color (in this case white) was lost
62 uno::Reference<beans::XPropertySet> xStyle(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
63 CPPUNIT_ASSERT(drawing::FillStyle_NONE != getProperty<drawing::FillStyle>(xStyle, u"FillStyle"_ustr));
65 // tdf#136983
66 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(mxComponent, uno::UNO_QUERY);
67 CPPUNIT_ASSERT_EQUAL_MESSAGE("Last printed date", sal_Int16(2009), xDPS->getDocumentProperties()->getPrintDate().Year);
70 DECLARE_WW8EXPORT_TEST(testTdf100961_fixedDateTime, "tdf100961_fixedDateTime.doc")
72 // This should be a fixed date/time field, not the current time.
73 getParagraph(1, u"05.01.19 04:06:08"_ustr);
75 css::uno::Reference<css::text::XTextFieldsSupplier> xSupplier(mxComponent,
76 css::uno::UNO_QUERY_THROW);
77 auto xFieldsAccess(xSupplier->getTextFields());
78 auto xFields(xFieldsAccess->createEnumeration());
80 css::uno::Reference<css::uno::XInterface> xField(xFields->nextElement(), css::uno::UNO_QUERY);
81 // Check fixed property was imported and date value was parsed correctly
82 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xField, u"IsFixed"_ustr));
83 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xField, u"IsDate"_ustr));
84 auto datetime = getProperty<css::util::DateTime>(xField, u"DateTimeValue"_ustr);
85 CPPUNIT_ASSERT_EQUAL(sal_uInt16(5), datetime.Day);
86 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), datetime.Month);
87 CPPUNIT_ASSERT_EQUAL(sal_Int16(2019), datetime.Year);
89 xField.set(xFields->nextElement(), css::uno::UNO_QUERY);
90 // Check fixed property was imported and time value was parsed correctly
91 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xField, u"IsFixed"_ustr));
92 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xField, u"IsDate"_ustr));
93 datetime = getProperty<css::util::DateTime>(xField, u"DateTimeValue"_ustr);
94 CPPUNIT_ASSERT_EQUAL(sal_uInt16(4), datetime.Hours);
95 CPPUNIT_ASSERT_EQUAL(sal_uInt16(6), datetime.Minutes);
96 CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), datetime.Seconds);
99 DECLARE_WW8EXPORT_TEST(testTdf147861_customField, "tdf147861_customField.doc")
101 // These should each be specific values, not a shared DocProperty
102 getParagraph(1, u"CustomEditedTitle"_ustr); // edited
103 // A couple of \x0\x0 at the end of the import variable thwart an equality comparison
104 CPPUNIT_ASSERT(getParagraph(2)->getString().startsWith(" INSERT Custom Title here"));
105 getParagraph(3, u"My Title"_ustr); // edited
107 // Verify that these are fields, and not just plain text
108 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
109 auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
110 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
111 uno::Reference<text::XTextField> xField(xFields->nextElement(), uno::UNO_QUERY);
112 CPPUNIT_ASSERT_EQUAL(u"CustomEditedTitle"_ustr, xField->getPresentation(false));
113 // The " (fixed)" part is unnecessary, but it must be consistent across a round-trip
114 CPPUNIT_ASSERT_EQUAL(u"DocInformation:Title (fixed)"_ustr, xField->getPresentation(true));
117 DECLARE_WW8EXPORT_TEST(testTdf148380_createField, "tdf148380_createField.doc")
119 // Verify that these are fields, and not just plain text
120 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
121 auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
122 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
123 uno::Reference<text::XTextField> xField(xFields->nextElement(), uno::UNO_QUERY);
124 // This should NOT be "Lorenzo Chavez", or a real date since the user hand-modified the result.
125 CPPUNIT_ASSERT_EQUAL(u"Myself - that's who"_ustr, xField->getPresentation(false));
126 xField.set(xFields->nextElement(), uno::UNO_QUERY);
127 CPPUNIT_ASSERT_EQUAL(u"yesterday at noon"_ustr, xField->getPresentation(false));
130 CPPUNIT_TEST_FIXTURE(Test, testTdf148380_fldLocked)
132 createSwDoc("tdf148380_fldLocked.doc");
133 getParagraph(2, u"4/5/2022 4:29:00 PM"_ustr);
134 getParagraph(4, u"1/23/4567 8:9:10 PM"_ustr);
136 // Verify that these are fields, and not just plain text
137 // (import only, since export thankfully just dumps these fixed fields as plain text
138 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
139 auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
140 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
141 uno::Reference<text::XTextField> xField(xFields->nextElement(), uno::UNO_QUERY);
142 // This should NOT be updated at FILEOPEN to match the last modified time - it is locked.
143 CPPUNIT_ASSERT_EQUAL(u"4/5/2022 4:29:00 PM"_ustr, xField->getPresentation(false));
144 CPPUNIT_ASSERT_EQUAL(u"DocInformation:Modified (fixed)"_ustr, xField->getPresentation(true));
145 xField.set(xFields->nextElement(), uno::UNO_QUERY);
146 CPPUNIT_ASSERT_EQUAL(u"1/23/4567 8:9:10 PM"_ustr, xField->getPresentation(false));
147 CPPUNIT_ASSERT_EQUAL(u"DocInformation:Last printed (fixed)"_ustr, xField->getPresentation(true));
150 DECLARE_WW8EXPORT_TEST(testTdf138345_paraCharHighlight, "tdf138345_paraCharHighlight.doc")
152 uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(9), 1, u"A side benefit is that "_ustr), uno::UNO_QUERY_THROW);
153 // Paragraph style paraNoCharBackground cancel paraCharBackground using COL_TRANSPARENT.
154 // Before this fix, the paragraph was by default covered with a yellow CharHighlight.
155 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, u"CharHighlight"_ustr));
156 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, u"CharBackColor"_ustr));
158 xRun.set(getRun(getParagraph(9), 2), uno::UNO_QUERY_THROW);
159 // Character style formatting must not contain a highlight setting at all.
160 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, u"CharHighlight"_ustr));
161 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, u"CharBackColor"_ustr));
163 //tdf#118711 - don't explicitly specify the default page style at the beginning of the document
164 uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY_THROW);
165 CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara->getPropertyValue(u"PageDescName"_ustr));
168 DECLARE_WW8EXPORT_TEST(testTdf104596_wrapInHeaderTable, "tdf104596_wrapInHeaderTable.doc")
170 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
172 sal_Int32 nRowHeight = getXPath(pXmlDoc, "//header/tab/row[1]/infos/bounds", "height").toInt32();
173 // The fly is supposed to be no-wrap, so the text should come underneath it, not wrap-through,
174 // thus making the row much higher. Before, height was 706. Now it is 1067.
175 CPPUNIT_ASSERT_MESSAGE("Text must wrap under green box", nRowHeight > 1000);
178 DECLARE_WW8EXPORT_TEST(testGutterLeft, "gutter-left.doc")
180 uno::Reference<beans::XPropertySet> xPageStyle;
181 getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr) >>= xPageStyle;
182 sal_Int32 nGutterMargin{};
183 xPageStyle->getPropertyValue(u"GutterMargin"_ustr) >>= nGutterMargin;
184 // Without the accompanying fix in place, this test would have failed with:
185 // - Expected: 1270
186 // - Actual : 0
187 // i.e. gutter margin was lost.
188 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), nGutterMargin);
191 CPPUNIT_TEST_FIXTURE(Test, testGutterTop)
193 createSwDoc("gutter-top.doc");
194 saveAndReload(u"MS Word 97"_ustr);
195 uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
196 uno::Reference<beans::XPropertySet> xSettings(
197 xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY);
198 bool bGutterAtTop{};
199 xSettings->getPropertyValue(u"GutterAtTop"_ustr) >>= bGutterAtTop;
200 // Without the accompanying fix in place, this test would have failed, because the gutter was
201 // at the left.
202 CPPUNIT_ASSERT(bGutterAtTop);
205 DECLARE_WW8EXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.doc")
207 auto xNumberingRules
208 = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), u"NumberingRules"_ustr);
209 comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
210 // Without the accompanying fix in place, this test would have failed with:
211 // - Expected: 64
212 // - Actual : 4
213 // i.e. numbering type was ARABIC, not ARABIC_ZERO.
214 CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO),
215 aMap[u"NumberingType"_ustr].get<sal_uInt16>());
218 CPPUNIT_TEST_FIXTURE(Test, testTdf128501)
220 createSwDoc("tdf128501.doc");
221 uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor = getShape(1);
222 CPPUNIT_ASSERT_EQUAL(u"com.sun.star.drawing.CustomShape"_ustr, xShapeDescriptor->getShapeType());
224 saveAndReload(mpFilter);
225 xShapeDescriptor = getShape(1);
226 // Without the fix in place, this test would have failed with
227 // - Expected: FrameShape
228 // - Actual : com.sun.star.drawing.CustomShape
229 CPPUNIT_ASSERT_EQUAL(u"FrameShape"_ustr, xShapeDescriptor->getShapeType());
232 CPPUNIT_TEST_FIXTURE(Test, testArabicZeroNumberingFootnote)
234 // Create a document, set footnote numbering type to ARABIC_ZERO.
235 createSwDoc();
236 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
237 uno::Reference<beans::XPropertySet> xFootnoteSettings
238 = xFootnotesSupplier->getFootnoteSettings();
239 sal_uInt16 nNumberingType = style::NumberingType::ARABIC_ZERO;
240 xFootnoteSettings->setPropertyValue(u"NumberingType"_ustr, uno::Any(nNumberingType));
242 // Insert a footnote.
243 uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
244 uno::Reference<text::XTextContent> xFootnote(
245 xFactory->createInstance(u"com.sun.star.text.Footnote"_ustr), uno::UNO_QUERY);
246 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
247 uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(),
248 uno::UNO_QUERY);
249 xTextContentAppend->appendTextContent(xFootnote, {});
251 saveAndReload(u"MS Word 97"_ustr);
252 xFootnotesSupplier.set(mxComponent, uno::UNO_QUERY);
253 sal_uInt16 nExpected = style::NumberingType::ARABIC_ZERO;
254 auto nActual = getProperty<sal_uInt16>(xFootnotesSupplier->getFootnoteSettings(), u"NumberingType"_ustr);
255 // Without the accompanying fix in place, this test would have failed with:
256 // - Expected: 64
257 // - Actual : 4
258 // i.e. the numbering type was ARABIC, not ARABIC_ZERO.
259 CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
262 CPPUNIT_TEST_FIXTURE(Test, testChicagoNumberingFootnote)
264 // Create a document, set footnote numbering type to SYMBOL_CHICAGO.
265 createSwDoc();
266 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
267 uno::Reference<beans::XPropertySet> xFootnoteSettings
268 = xFootnotesSupplier->getFootnoteSettings();
269 sal_uInt16 nNumberingType = style::NumberingType::SYMBOL_CHICAGO;
270 xFootnoteSettings->setPropertyValue(u"NumberingType"_ustr, uno::Any(nNumberingType));
272 // Insert a footnote.
273 uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
274 uno::Reference<text::XTextContent> xFootnote(
275 xFactory->createInstance(u"com.sun.star.text.Footnote"_ustr), uno::UNO_QUERY);
276 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
277 uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(),
278 uno::UNO_QUERY);
279 xTextContentAppend->appendTextContent(xFootnote, {});
281 saveAndReload(u"MS Word 97"_ustr);
282 xFootnotesSupplier.set(mxComponent, uno::UNO_QUERY);
283 sal_uInt16 nExpected = style::NumberingType::SYMBOL_CHICAGO;
284 auto nActual = getProperty<sal_uInt16>(xFootnotesSupplier->getFootnoteSettings(), u"NumberingType"_ustr);
285 // Without the accompanying fix in place, this test would have failed with:
286 // - Expected: 63
287 // - Actual : 4
288 // i.e. the numbering type was ARABIC, not SYMBOL_CHICAGO.
289 CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
292 DECLARE_WW8EXPORT_TEST(testHyperLinkURLSaving, "tdf120003.doc")
294 OUString URL = getProperty<OUString>(getShape(1), u"HyperLinkURL"_ustr);
295 // Without the fix in place, this test would have failed with
296 // - Expected: https://www.libreoffice.org/
297 // - Actual : tps://www.libreoffice.org/
298 CPPUNIT_ASSERT_EQUAL(u"https://www.libreoffice.org/"_ustr, URL);
301 DECLARE_WW8EXPORT_TEST(testdf79553_lineNumbers, "tdf79553_lineNumbers.doc")
303 bool bValue = false;
304 sal_Int32 nValue = -1;
306 uno::Reference< text::XTextDocument > xtextDocument(mxComponent, uno::UNO_QUERY);
307 uno::Reference< text::XLineNumberingProperties > xLineProperties( xtextDocument, uno::UNO_QUERY_THROW );
308 uno::Reference< beans::XPropertySet > xPropertySet = xLineProperties->getLineNumberingProperties();
310 xPropertySet->getPropertyValue(u"IsOn"_ustr) >>= bValue;
311 CPPUNIT_ASSERT_EQUAL(true, bValue);
313 xPropertySet->getPropertyValue(u"Distance"_ustr) >>= nValue;
314 CPPUNIT_ASSERT_MESSAGE("automatic distance", nValue > 0);
317 CPPUNIT_TEST_FIXTURE(Test, testTdf138302_restartNumbering)
319 loadAndReload("tdf138302_restartNumbering.odt");
320 CPPUNIT_ASSERT_EQUAL(1, getPages());
321 uno::Reference<beans::XPropertySet> xPara(getParagraph(8), uno::UNO_QUERY);
322 CPPUNIT_ASSERT_EQUAL(u"1."_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
325 // tdf#143982: automatic tables should export as something better than just left-and-size
326 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
327 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
328 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
330 CPPUNIT_ASSERT(getProperty<bool>(xTable, u"IsWidthRelative"_ustr));
331 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xTable, u"RelativeWidth"_ustr));
334 DECLARE_WW8EXPORT_TEST(testTdf122429_header, "tdf122429_header.doc")
336 uno::Reference<container::XNameAccess> pageStyles = getStyles(u"PageStyles"_ustr);
337 uno::Reference<style::XStyle> pageStyle(pageStyles->getByName(u"Standard"_ustr), uno::UNO_QUERY);
338 bool headerIsOn = getProperty<bool>(pageStyle, u"HeaderIsOn"_ustr);
339 CPPUNIT_ASSERT(headerIsOn);
342 CPPUNIT_TEST_FIXTURE(Test, testTdf122460_header)
344 loadAndReload("tdf122460_header.odt");
345 CPPUNIT_ASSERT_EQUAL(1, getPages());
346 uno::Reference<container::XNameAccess> pageStyles = getStyles(u"PageStyles"_ustr);
347 uno::Reference<style::XStyle> pageStyle(pageStyles->getByName(u"Standard"_ustr), uno::UNO_QUERY);
348 bool headerIsOn = getProperty<bool>(pageStyle, u"HeaderIsOn"_ustr);
349 CPPUNIT_ASSERT(headerIsOn);
352 DECLARE_WW8EXPORT_TEST(testTdf139495_tinyHeader, "tdf139495_tinyHeader.doc")
354 // In Word 2003, this is one page, but definitely not six pages.
355 CPPUNIT_ASSERT(getPages() < 3);
358 DECLARE_WW8EXPORT_TEST(testTdf124937, "tdf124937.doc")
360 // Check it doesn't crash at import time
361 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
362 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
363 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
364 CPPUNIT_ASSERT_EQUAL(1, getPages());
367 DECLARE_WW8EXPORT_TEST(testFdo53985, "fdo53985.doc")
369 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
370 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
371 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xTables->getCount()); // Only 4 tables were imported.
373 SwDoc* pDoc = getSwDoc();
374 CPPUNIT_ASSERT_EQUAL_MESSAGE("Compatibility: Protect form", true, pDoc->getIDocumentSettingAccess().get( DocumentSettingId::PROTECT_FORM ) );
376 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
377 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
378 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xSections->getCount()); // The first paragraph wasn't counted as a section.
380 uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY);
381 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section1 is protected", true, getProperty<bool>(xSect, u"IsProtected"_ustr));
382 xSect.set(xSections->getByIndex(3), uno::UNO_QUERY);
383 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section4 is protected", false, getProperty<bool>(xSect, u"IsProtected"_ustr));
386 DECLARE_WW8EXPORT_TEST(testTdf73056_cellMargins, "tdf73056_cellMargins.doc")
388 uno::Reference< text::XTextTablesSupplier > xTablesSupplier( mxComponent, uno::UNO_QUERY );
389 uno::Reference< container::XIndexAccess > xTables( xTablesSupplier->getTextTables(), uno::UNO_QUERY );
390 uno::Reference< text::XTextTable > xTable1( xTables->getByIndex( 0 ), uno::UNO_QUERY );
391 uno::Reference< table::XCell > xCell = xTable1->getCellByName( u"B4"_ustr );
393 // only the first cell with specific margins was processed, leaving the rest at table defaults. Was 0.
394 uno::Reference< beans::XPropertySet > xPropSet( xCell, uno::UNO_QUERY_THROW );
395 CPPUNIT_ASSERT_EQUAL_MESSAGE( "bottom cell spacing to contents",
396 sal_Int32(101), getProperty<sal_Int32>(xPropSet, u"BottomBorderDistance"_ustr ) );
399 DECLARE_WW8EXPORT_TEST(testTdf135672_tableGrows, "tdf135672_tableGrows.doc")
401 auto const xTable(getParagraphOrTable(1));
402 // This would shift left every round-trip. First time was -259, next -418.
403 CPPUNIT_ASSERT_EQUAL(sal_Int32(-101), getProperty<sal_Int32>(xTable, u"LeftMargin"_ustr));
405 // This would grow every round-trip. First time was 11118, next 11435
406 CPPUNIT_ASSERT_EQUAL(sal_Int32(10800), getProperty<sal_Int32>(xTable, u"Width"_ustr));
409 CPPUNIT_TEST_FIXTURE(Test, testTdf79435_legacyInputFields)
411 loadAndReload("tdf79435_legacyInputFields.docx");
412 //using .docx input file to verify cross-format compatibility.
413 uno::Reference<text::XFormField> xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(5), 4), u"Bookmark"_ustr);
414 uno::Reference<container::XNameContainer> xParameters(xFormField->getParameters());
416 OUString sTmp;
417 // Too often the string reader can fail during import - fix that first to prevent round-tripping garbage.
418 // (for example BR-1010B.doc from tdf#48097)
419 //xParameters->getByName("EntryMacro") >>= sTmp;
420 //CPPUNIT_ASSERT_EQUAL(OUString("test"), sTmp);
421 //xParameters->getByName("Help") >>= sTmp;
422 //CPPUNIT_ASSERT_EQUAL(OUString("F1Help"), sTmp);
423 //xParameters->getByName("ExitMacro") >>= sTmp;
424 //CPPUNIT_ASSERT_EQUAL(OUString("test"), sTmp);
425 xParameters->getByName(u"Description"_ustr) >>= sTmp;
426 CPPUNIT_ASSERT_EQUAL(u"StatusHelp"_ustr, sTmp);
427 //xParameters->getByName("Content") >>= sTmp;
428 //CPPUNIT_ASSERT_EQUAL(OUString("Camelcase"), sTmp);
429 //xParameters->getByName("Format") >>= sTmp;
430 //CPPUNIT_ASSERT_EQUAL(OUString("TITLE CASE"), sTmp);
432 sal_uInt16 nMaxLength = 0;
433 xParameters->getByName(u"MaxLength"_ustr) >>= nMaxLength;
434 CPPUNIT_ASSERT_EQUAL_MESSAGE("Max Length", sal_uInt16(10), nMaxLength);
436 // too bad this is based on character runs - just found try trial and error.
437 xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(6), 3), u"Bookmark"_ustr);
438 xParameters.set(xFormField->getParameters());
439 xParameters->getByName(u"Type"_ustr) >>= sTmp;
440 CPPUNIT_ASSERT_EQUAL(u"calculated"_ustr, sTmp);
442 xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(7), 3), u"Bookmark"_ustr);
443 xParameters.set(xFormField->getParameters());
444 xParameters->getByName(u"Type"_ustr) >>= sTmp;
445 CPPUNIT_ASSERT_EQUAL(u"currentDate"_ustr, sTmp);
447 xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(7), 10), u"Bookmark"_ustr);
448 xParameters.set(xFormField->getParameters());
449 xParameters->getByName(u"Type"_ustr) >>= sTmp;
450 CPPUNIT_ASSERT_EQUAL(u"currentTime"_ustr, sTmp);
452 xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(8), 3), u"Bookmark"_ustr);
453 xParameters.set(xFormField->getParameters());
454 xParameters->getByName(u"Type"_ustr) >>= sTmp;
455 CPPUNIT_ASSERT_EQUAL(u"number"_ustr, sTmp);
457 xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(8), 10), u"Bookmark"_ustr);
458 xParameters.set(xFormField->getParameters());
459 xParameters->getByName(u"Type"_ustr) >>= sTmp;
460 CPPUNIT_ASSERT_EQUAL(u"date"_ustr, sTmp);
463 CPPUNIT_TEST_FIXTURE(Test, testTdf134264)
465 loadAndReload("tdf134264.docx");
466 // Without the fix in place, ADDRESSBLOCK fields would have been lost after RT
467 CPPUNIT_ASSERT_EQUAL(u"MF"_ustr, getParagraph(1)->getString());
468 CPPUNIT_ASSERT_EQUAL(u"M19"_ustr, getParagraph(2)->getString());
469 CPPUNIT_ASSERT_EQUAL(u"1815"_ustr, getParagraph(3)->getString());
472 DECLARE_WW8EXPORT_TEST(testTdf120225_textControlCrossRef, "tdf120225_textControlCrossRef.doc")
474 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
475 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
476 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
477 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
478 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
479 xRunEnum->nextElement();
480 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
482 CPPUNIT_ASSERT_EQUAL(u"TextFieldStart"_ustr, getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr));
483 uno::Reference<container::XNamed> xBookmark(getProperty< uno::Reference<beans::XPropertySet> >(xPropertySet, u"Bookmark"_ustr), uno::UNO_QUERY_THROW);
485 // Critical test: does TextField's bookmark name match cross-reference?
486 const OUString sTextFieldName( xBookmark->getName() );
487 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
488 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
489 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
490 CPPUNIT_ASSERT(xFields->hasMoreElements());
491 xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
492 CPPUNIT_ASSERT_EQUAL(sTextFieldName, getProperty<OUString>(xPropertySet, u"SourceName"_ustr));
494 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
495 uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
496 uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
497 // TextFields should not be turned into real bookmarks.
498 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xBookmarksByIdx->getCount());
500 // The actual name isn't critical, but if it fails, it is worth asking why.
501 CPPUNIT_ASSERT_EQUAL(u"Text1"_ustr, sTextFieldName);
504 CPPUNIT_TEST_FIXTURE(Test, testTdf134948)
506 loadAndReload("tdf134948.odt");
507 CPPUNIT_ASSERT_EQUAL(1, getShapes());
508 CPPUNIT_ASSERT_EQUAL(1, getPages());
509 CPPUNIT_ASSERT_EQUAL_MESSAGE("Only 1 paragraph", 1, getParagraphs());
512 CPPUNIT_TEST_FIXTURE(Test, testTdf132726)
514 loadAndReload("tdf132726.odt");
515 CPPUNIT_ASSERT_EQUAL(1, getShapes());
516 CPPUNIT_ASSERT_EQUAL(1, getPages());
517 uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 1, u"What sentence has a yellow background? "_ustr);
518 CPPUNIT_ASSERT_EQUAL( COL_AUTO, getProperty<Color>(xRun, u"CharBackColor"_ustr));
520 xRun = getRun(getParagraph(1), 2, u"Why, this sentence of course"_ustr);
521 CPPUNIT_ASSERT_EQUAL( COL_YELLOW, getProperty<Color>(xRun, u"CharBackColor"_ustr));
524 CPPUNIT_TEST_FIXTURE(Test, testTdf127316_autoEscapement)
526 loadAndReload("tdf127316_autoEscapement.odt");
527 CPPUNIT_ASSERT_EQUAL(1, getPages());
528 uno::Reference<text::XTextRange> xPara = getParagraph(2);
529 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.f, getProperty<float>(getRun(xPara, 1, u"Normal text "_ustr), u"CharEscapement"_ustr), 0);
530 // Negative escapements (subscripts) were decreasing by 1% every round-trip due to bad manual rounding.
531 // This should be roughly .2*35% of the ORIGINAL (non-reduced) size. However, during export the
532 // proportional height has to be changed into direct formatting, which then changes the relative percent.
533 // In this case, a 24pt font, proportional at 65% becomes roughly a 16pt font.
534 // Thus an escapement of 7% (1.68pt) becomes roughly 10.5% for the 16pt font.
535 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Subscript", -10.f, getProperty<float>(getRun(xPara, 2), u"CharEscapement"_ustr), 1);
538 CPPUNIT_TEST_FIXTURE(Test, testTdf127316_autoEscapement2)
540 loadAndReload("tdf127316_autoEscapement2.odt");
541 CPPUNIT_ASSERT_EQUAL(2, getPages());
542 uno::Reference<text::XTextRange> xPara = getParagraph(1);
543 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.f, getProperty<float>(getRun(xPara, 1, u"Base1"_ustr), u"CharEscapement"_ustr), 0);
544 // Font is 80% of 40pt or 32pt, original escapement is 6.4pt, so round-trip escapement is 20%.
545 CPPUNIT_ASSERT_DOUBLES_EQUAL(20.f, getProperty<float>(getRun(xPara, 2,u"AutoSuperscript"_ustr), u"CharEscapement"_ustr), 1);
546 xPara.set( getParagraph(3) );
547 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.f, getProperty<float>(getRun(xPara, 1, u"Base3"_ustr), u"CharEscapement"_ustr), 0);
548 // font is 20% of 40pt or 8pt, original escapement is 25.6pt, so round-trip escapement is 320%.
549 CPPUNIT_ASSERT_DOUBLES_EQUAL(320.f, getProperty<float>(getRun(xPara, 2,u"AutoSuperscript"_ustr), u"CharEscapement"_ustr), 3);
552 CPPUNIT_TEST_FIXTURE(Test, testTdf120412_proportionalEscapement)
554 loadAndReload("tdf120412_proportionalEscapement.odt");
555 uno::Reference<text::XTextRange> xPara = getParagraph(2);
556 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.f, getProperty<float>(getRun(xPara, 2, u"Base"_ustr), u"CharEscapement"_ustr), 0);
557 // Import was limiting to 100%. And export based the position on the original height, not the proportional height.
558 CPPUNIT_ASSERT_DOUBLES_EQUAL( 150.f, getProperty<float>(getRun(xPara, 3,u"Super"_ustr), u"CharEscapement"_ustr), 2);
559 CPPUNIT_ASSERT_EQUAL(2, getPages());
562 DECLARE_WW8EXPORT_TEST(testTdf133453_realFontSize, "tdf133453_realFontSize.doc")
564 CPPUNIT_ASSERT_EQUAL( -95.f, getProperty<float>(getRun(getParagraph(1), 2, u"2"_ustr), u"CharEscapement"_ustr) );
567 DECLARE_WW8EXPORT_TEST(testTdf116194, "tdf116194.doc")
569 CPPUNIT_ASSERT_EQUAL( Color(0xc00000), getProperty<Color>(getRun(getParagraph(1), 1), u"CharColor"_ustr));
572 CPPUNIT_TEST_FIXTURE(Test, testTdf121111_fillStyleNone)
574 loadAndReload("tdf121111_fillStyleNone.docx");
575 uno::Reference<beans::XPropertySet> xStyle(getStyles(u"ParagraphStyles"_ustr)->getByName(u"Numbering - First level"_ustr),
576 uno::UNO_QUERY);
577 CPPUNIT_ASSERT_EQUAL(Color(0xb8cce4), getProperty<Color>(xStyle, u"ParaBackColor"_ustr));//R:184 G:204 B:228
578 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xStyle, u"FillStyle"_ustr));
580 uno::Reference<text::XTextRange> xText(getParagraph(12));
581 CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xText, u"ParaBackColor"_ustr));
582 CPPUNIT_ASSERT_EQUAL_MESSAGE("No fill", drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xText, u"FillStyle"_ustr));
585 CPPUNIT_TEST_FIXTURE(Test, testTdf128608_fillStyleNoneB)
587 loadAndReload("tdf128608_fillStyleNoneB.odt");
588 CPPUNIT_ASSERT_EQUAL(1, getPages());
589 uno::Reference<text::XTextRange> xText(getParagraph(1));
590 CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xText, u"ParaBackColor"_ustr));
591 CPPUNIT_ASSERT_EQUAL_MESSAGE("No fill", drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xText, u"FillStyle"_ustr));
594 DECLARE_WW8EXPORT_TEST(testTdf132094_transparentPageImage, "tdf132094_transparentPageImage.doc")
596 uno::Reference<drawing::XShape> image (getShape(1), uno::UNO_QUERY);
597 // Don't add fillstyle when none is set.
598 // Well, ok, at least make it transparent if you do uselessly set a solid color...
599 const bool bFillNone = drawing::FillStyle_NONE == getProperty<drawing::FillStyle>(image, u"FillStyle"_ustr);
600 const bool bTransparent = sal_Int16(0) != getProperty<sal_Int16>(image, u"FillTransparence"_ustr);
601 CPPUNIT_ASSERT_MESSAGE("no background fill", bTransparent || bFillNone);
604 DECLARE_WW8EXPORT_TEST(testTdf112618_textbox_no_bg, "tdf112618_textbox_no_bg.doc")
606 Color nTransparence = getProperty<Color>(getShape(2), u"FillTransparence"_ustr);
607 CPPUNIT_ASSERT_EQUAL(Color(0x000064), nTransparence);
608 CPPUNIT_ASSERT_EQUAL(nTransparence, getProperty<Color>(getShape(2), u"BackColorTransparency"_ustr));
611 DECLARE_WW8EXPORT_TEST(testTdf101826_xattrTextBoxFill, "tdf101826_xattrTextBoxFill.doc")
613 //Basic 1 Color Fill: gradient from yellow(FFFF00) to brown(767600) currently saves as mid-color
614 CPPUNIT_ASSERT_MESSAGE("background color", Color(0xFF, 0xFF, 0x00) != getProperty<Color>(getShape(1), u"BackColor"_ustr));
615 //Basic 2 Color Fill: gradient from yellow(FFFF00) to green(00B050) currently saves as mid-color
616 CPPUNIT_ASSERT_MESSAGE("background color", Color(0xFF, 0xFF, 0x00) != getProperty<Color>(getShape(4), u"BackColor"_ustr));
617 //Basic Picture Fill: Tux image
618 CPPUNIT_ASSERT_EQUAL_MESSAGE("background image", drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(getShape(5), u"FillStyle"_ustr));
619 // Basic Pattern fill: many thin, green, vertical stripes on yellow background
620 auto eMode = getProperty<drawing::BitmapMode>(getShapeByName(u"Frame2"), u"FillBitmapMode"_ustr);
621 CPPUNIT_ASSERT_EQUAL_MESSAGE("tiled pattern", drawing::BitmapMode_REPEAT, eMode);
622 // Basic Texture fill: tiled blue denim texture
623 eMode = getProperty<drawing::BitmapMode>(getShapeByName(u"Frame6"), u"FillBitmapMode"_ustr);
624 CPPUNIT_ASSERT_EQUAL_MESSAGE("tiled texture", drawing::BitmapMode_REPEAT, eMode);
627 DECLARE_WW8EXPORT_TEST(testTdf123433_fillStyleStop, "tdf123433_fillStyleStop.doc")
629 uno::Reference<text::XTextRange> xText(getParagraph(12));
630 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xText, u"FillStyle"_ustr));
631 CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xText, u"ParaBackColor"_ustr));
634 CPPUNIT_TEST_FIXTURE(Test, testTdf127862_pageFillStyle)
636 loadAndReload("tdf127862_pageFillStyle.odt");
637 CPPUNIT_ASSERT_EQUAL(6, getPages());
638 uno::Reference<beans::XPropertySet> xStyle(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
639 CPPUNIT_ASSERT(drawing::FillStyle_NONE != getProperty<drawing::FillStyle>(xStyle, u"FillStyle"_ustr));
642 DECLARE_WW8EXPORT_TEST(testTdf128608_tableParaBackColor, "tdf128608_tableParaBackColor.doc")
644 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
645 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
646 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
647 uno::Reference<text::XTextRange> xCell(xTable->getCellByName(u"A4"_ustr), uno::UNO_QUERY);
649 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
650 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
651 uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
652 // ParaBackColor doesn't seem to be used in this case, but keep it here to make sure it stays as AUTO.
653 CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xPara, u"ParaBackColor"_ustr));
654 // No paragraph background colour/fill. (The cell background colour should be used.)
655 CPPUNIT_ASSERT_EQUAL_MESSAGE("No fillstyle", drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xPara, u"FillStyle"_ustr));
658 CPPUNIT_TEST_FIXTURE(Test, testTdf117217_largeTableBackgrounds)
660 loadAndReload("tdf117217_largeTableBackgrounds.odt");
661 CPPUNIT_ASSERT_EQUAL(1, getPages());
662 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
663 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
664 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
665 // Cell 22: light-red == 16711680
666 uno::Reference<text::XTextRange> xCell(xTable->getCellByName(u"V1"_ustr), uno::UNO_QUERY_THROW);
667 CPPUNIT_ASSERT_EQUAL_MESSAGE("light red", Color(0xE0C2CD), getProperty<Color>(xCell, u"BackColor"_ustr));
668 xCell.set(xTable->getCellByName(u"Z1"_ustr), uno::UNO_QUERY_THROW);
669 CPPUNIT_ASSERT_EQUAL_MESSAGE("light red", Color(0xE0C2CD), getProperty<Color>(xCell, u"BackColor"_ustr));
672 CPPUNIT_TEST_FIXTURE(Test, testTdf94009_zeroPgMargin)
674 loadAndReload("tdf94009_zeroPgMargin.odt");
675 CPPUNIT_ASSERT_EQUAL(1, getPages());
676 uno::Reference<beans::XPropertySet> defaultStyle(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr),
677 uno::UNO_QUERY);
678 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(defaultStyle, u"TopMargin"_ustr));
681 DECLARE_WW8EXPORT_TEST(testTdf108518_CRnumformatting, "tdf108518_CRnumformatting.doc")
683 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
684 assertXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", "expand", u"6.2.3.");
685 //Without this fix in place, it would become 200 (and non-bold).
686 assertXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']/SwFont", "height", u"220");
689 DECLARE_WW8EXPORT_TEST(testTdf120711_joinedParagraphWithChangeTracking, "tdf120711.doc")
691 sal_Int16 numFormat = getNumberingTypeOfParagraph(5);
692 // last paragraph is not a list item
693 CPPUNIT_ASSERT(style::NumberingType::CHAR_SPECIAL != numFormat);
696 CPPUNIT_TEST_FIXTURE(Test, testTdf129522_removeShadowStyle)
698 loadAndReload("tdf129522_removeShadowStyle.odt");
699 CPPUNIT_ASSERT_EQUAL(1, getPages());
700 uno::Reference< container::XNameAccess > paragraphStyles = getStyles(u"ParagraphStyles"_ustr);
701 uno::Reference< beans::XPropertySet > xStyleProps(paragraphStyles->getByName(u"Shadow"_ustr), uno::UNO_QUERY_THROW);
702 table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xStyleProps, u"ParaShadowFormat"_ustr);
703 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
705 // Shadows were inherited regardless of whether the style disabled them.
706 xStyleProps.set(paragraphStyles->getByName(u"Shadow-removed"_ustr), uno::UNO_QUERY_THROW);
707 aShadow = getProperty<table::ShadowFormat>(xStyleProps, u"ParaShadowFormat"_ustr);
708 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
710 uno::Reference< container::XNameAccess > characterStyles = getStyles(u"CharacterStyles"_ustr);
711 xStyleProps.set(characterStyles->getByName(u"CharShadow"_ustr), uno::UNO_QUERY_THROW);
712 aShadow = getProperty<table::ShadowFormat>(xStyleProps, u"CharShadowFormat"_ustr);
713 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
715 xStyleProps.set(characterStyles->getByName(u"CharShadow-removed"_ustr), uno::UNO_QUERY_THROW);
716 aShadow = getProperty<table::ShadowFormat>(xStyleProps, u"CharShadowFormat"_ustr);
717 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
720 DECLARE_WW8EXPORT_TEST(testTdf81705_outlineLevel, "tdf81705_outlineLevel.doc")
722 // direct formatting resets outline level to body text (0)
723 CPPUNIT_ASSERT_EQUAL_MESSAGE("Paragraph C", sal_uInt16(0), getProperty<sal_uInt16>(getParagraph(3), u"OutlineLevel"_ustr));
724 // myStyle sets outline level to 1.
725 CPPUNIT_ASSERT_EQUAL_MESSAGE("Paragraph D", sal_uInt16(1), getProperty<sal_uInt16>(getParagraph(4), u"OutlineLevel"_ustr));
728 DECLARE_WW8EXPORT_TEST(testBtlrCell, "btlr-cell.doc")
730 // Without the accompanying fix in place, this test would have failed, as
731 // the btlr text direction in the A1 cell was lost on DOC import and
732 // export.
733 uno::Reference<text::XTextTablesSupplier> xSupplier(mxComponent, uno::UNO_QUERY);
734 uno::Reference<container::XNameAccess> xTables = xSupplier->getTextTables();
735 uno::Reference<text::XTextTable> xTable(xTables->getByName(u"Table1"_ustr), uno::UNO_QUERY);
736 uno::Reference<beans::XPropertySet> xA1(xTable->getCellByName(u"A1"_ustr), uno::UNO_QUERY);
737 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, getProperty<sal_Int16>(xA1, u"WritingMode"_ustr));
739 uno::Reference<beans::XPropertySet> xB1(xTable->getCellByName(u"B1"_ustr), uno::UNO_QUERY);
740 auto nActual = getProperty<sal_Int16>(xB1, u"WritingMode"_ustr);
741 CPPUNIT_ASSERT(nActual == text::WritingMode2::LR_TB || nActual == text::WritingMode2::CONTEXT);
743 uno::Reference<beans::XPropertySet> xC1(xTable->getCellByName(u"C1"_ustr), uno::UNO_QUERY);
744 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty<sal_Int16>(xC1, u"WritingMode"_ustr));
747 DECLARE_WW8EXPORT_TEST(testTdf118375export, "tdf118375_240degClockwise.doc")
749 // The input document has one custom shape, which is rotated 240deg. Check
750 // that it has the same position as in Word.
751 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
752 uno::UNO_QUERY_THROW);
753 CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
754 uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
755 uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
756 CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage.is());
757 uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
758 CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape.is());
759 uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
760 CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps.is());
761 sal_Int32 nPosX = {}, nPosY = {};
762 CPPUNIT_ASSERT(xShapeProps->getPropertyValue(u"HoriOrientPosition"_ustr) >>= nPosX);
763 CPPUNIT_ASSERT(xShapeProps->getPropertyValue(u"VertOrientPosition"_ustr) >>= nPosY);
764 // Allow some tolerance because rounding errors through integer arithmetic
765 // in rotation.
766 CPPUNIT_ASSERT_DOUBLES_EQUAL(5200.0, static_cast<double>(nPosX), 1.0);
767 CPPUNIT_ASSERT_DOUBLES_EQUAL(1152.0, static_cast<double>(nPosY), 1.0);
770 DECLARE_WW8EXPORT_TEST(testImageCommentAtChar, "image-comment-at-char.doc")
772 uno::Reference<text::XTextRange> xPara = getParagraph(1);
773 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr,
774 getProperty<OUString>(getRun(xPara, 1), u"TextPortionType"_ustr));
775 // Without the accompanying fix in place, this test would have failed with 'Expected:
776 // Annotation; Actual: Frame', i.e. the comment start before the image was lost.
777 CPPUNIT_ASSERT_EQUAL(u"Annotation"_ustr,
778 getProperty<OUString>(getRun(xPara, 2), u"TextPortionType"_ustr));
779 CPPUNIT_ASSERT_EQUAL(u"Frame"_ustr,
780 getProperty<OUString>(getRun(xPara, 3), u"TextPortionType"_ustr));
781 CPPUNIT_ASSERT_EQUAL(u"AnnotationEnd"_ustr,
782 getProperty<OUString>(getRun(xPara, 4), u"TextPortionType"_ustr));
783 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr,
784 getProperty<OUString>(getRun(xPara, 5), u"TextPortionType"_ustr));
787 CPPUNIT_TEST_FIXTURE(Test, testTdf126708emf)
789 loadAndReload("tdf126708_containsemf.odt");
790 CPPUNIT_ASSERT_EQUAL(1, getShapes());
791 CPPUNIT_ASSERT_EQUAL(1, getPages());
792 auto xShape = getShape(1);
793 // First check the size of the EMF graphic contained in the shape.
794 auto xGraphic = getProperty< uno::Reference<graphic::XGraphic> >(
795 xShape, u"Graphic"_ustr);
796 auto xSize = getProperty<awt::Size>(xGraphic, u"Size100thMM"_ustr);
797 CPPUNIT_ASSERT_EQUAL(sal_Int32(8501), xSize.Height);
798 CPPUNIT_ASSERT_EQUAL(sal_Int32(18939), xSize.Width);
800 // Now check that the shape itself has a decent size.
801 // This size varies slightly when round tripping through doc format.
802 xSize = getProperty<awt::Size>(xShape, u"Size"_ustr);
803 CPPUNIT_ASSERT(abs(xSize.Height - 7629) <= 6);
804 CPPUNIT_ASSERT(abs(xSize.Width - 17000) <= 6);
807 CPPUNIT_TEST_FIXTURE(Test, testBtlrFrame)
809 loadAndReload("btlr-frame.odt");
810 CPPUNIT_ASSERT_EQUAL(1, getShapes());
811 CPPUNIT_ASSERT_EQUAL(1, getPages());
813 // Without the accompanying fix in place, this test would have failed with a
814 // beans.UnknownPropertyException, as the writing direction was lost, so the default direction
815 // resulted in a conversion to a Writer text frame.
816 uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY);
817 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(9000), getProperty<sal_Int32>(xFrame, u"RotateAngle"_ustr));
820 DECLARE_WW8EXPORT_TEST(testPresetDash, "tdf127166_prstDash_Word97.doc")
822 // Error was, that the 'sys' preset dash styles were neither imported not
823 // exported, the mixed styles had wrong dash-dot order, they were imported
824 // with absolute values.
825 const drawing::LineDash dashParams[] =
827 {drawing::DashStyle_RECTRELATIVE, 1, 400, 0, 0, 300}, // dash
828 {drawing::DashStyle_RECTRELATIVE, 1, 400, 1, 100, 300}, // dashDot
829 {drawing::DashStyle_RECTRELATIVE, 1, 100, 0, 0, 300}, // dot
830 {drawing::DashStyle_RECTRELATIVE, 1, 800, 0, 0, 300}, // lgDash
831 {drawing::DashStyle_RECTRELATIVE, 1, 800, 1, 100, 300}, // lgDashDot
832 {drawing::DashStyle_RECTRELATIVE, 1, 800, 2, 100, 300}, // lgDashDotDot
833 {drawing::DashStyle_RECTRELATIVE, 1, 300, 0, 0, 100}, // sysDash
834 {drawing::DashStyle_RECTRELATIVE, 1, 300, 1, 100, 100}, // sysDashDot
835 {drawing::DashStyle_RECTRELATIVE, 1, 300, 2, 100, 100}, // sysDashDotDot
836 {drawing::DashStyle_RECTRELATIVE, 1, 100, 0, 0, 100} // sysDot
838 drawing::LineDash aPresetLineDash;
839 drawing::LineDash aShapeLineDash;
840 for (sal_uInt16 i = 0; i < 10; i++)
842 aPresetLineDash = dashParams[i];
843 uno::Reference<drawing::XShape> xShape = getShape(i+1);
844 aShapeLineDash = getProperty<drawing::LineDash>(xShape, u"LineDash"_ustr);
845 bool bIsEqual = aPresetLineDash.Style == aShapeLineDash.Style
846 && aPresetLineDash.Dots == aShapeLineDash.Dots
847 && aPresetLineDash.DotLen == aShapeLineDash.DotLen
848 && aPresetLineDash.Dashes == aShapeLineDash.Dashes
849 && aPresetLineDash.DashLen == aShapeLineDash.DashLen
850 && aPresetLineDash.Distance == aShapeLineDash.Distance;
851 CPPUNIT_ASSERT_MESSAGE("LineDash differ", bIsEqual);
854 xmlDocUniquePtr pLayout = parseLayoutDump();
855 // Ensure that there is no tabstop in the first paragraph (despite chapter numbering's setting)
856 // This is a pre-emptive test to ensure something visibly correct is not broken.
857 assertXPath(pLayout, "//body/txt[1]//SwFixPortion", 0);
860 CPPUNIT_TEST_FIXTURE(Test, testRtlGutter)
862 auto verify = [this]() {
863 uno::Reference<beans::XPropertySet> xStandard(
864 getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
865 CPPUNIT_ASSERT(getProperty<bool>(xStandard, u"RtlGutter"_ustr));
868 // Given a document with RTL gutter, when loading it:
869 createSwDoc("rtl-gutter.doc");
870 // Then make sure the section's gutter is still RTL:
871 // Without the accompanying fix in place, this test would have failed as the SPRM was missing.
872 verify();
873 saveAndReload(u"MS Word 97"_ustr);
874 verify();
877 DECLARE_WW8EXPORT_TEST(testTdf94326_notOutlineNumbering, "tdf94326_notOutlineNumbering.doc")
879 // The directly applied numbering list must not be lost.
880 uno::Reference<beans::XPropertySet> xPara(getParagraph(2, u"ОБЩИЕ ПОЛОЖЕНИЯ"_ustr), uno::UNO_QUERY);
881 CPPUNIT_ASSERT_EQUAL(u"1."_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
884 DECLARE_WW8EXPORT_TEST(testTdf106541_cancelOutline, "tdf106541_cancelOutline.doc")
886 // The ability to cancel numbering must not be lost.
887 uno::Reference<beans::XPropertySet> xPara(getParagraph(1, u"Cancelled by style"_ustr), uno::UNO_QUERY);
888 CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
889 xPara.set(getParagraph(2, u"Cancelled by inherited style"_ustr), uno::UNO_QUERY);
890 CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
891 xPara.set(getParagraph(4, u"Cancelled by direct paragraph formatting"_ustr), uno::UNO_QUERY);
892 CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
895 DECLARE_WW8EXPORT_TEST(testTdf104239_chapterNumbering, "tdf104239_chapterNumbering.doc")
897 uno::Reference<text::XChapterNumberingSupplier> xNumberingSupplier(mxComponent, uno::UNO_QUERY);
898 uno::Reference<container::XIndexAccess> xNumberingRules = xNumberingSupplier->getChapterNumberingRules();
900 comphelper::SequenceAsHashMap hashMap(xNumberingRules->getByIndex(0));
901 CPPUNIT_ASSERT(hashMap[u"HeadingStyleName"_ustr].get<OUString>().match("Heading 1"));
902 sal_uInt16 nNumberingType = style::NumberingType::CHARS_UPPER_LETTER_N;
903 CPPUNIT_ASSERT_EQUAL(nNumberingType, hashMap[u"NumberingType"_ustr].get<sal_uInt16>());
905 hashMap = xNumberingRules->getByIndex(5);
906 CPPUNIT_ASSERT(hashMap[u"HeadingStyleName"_ustr].get<OUString>().match("Heading 6"));
907 nNumberingType = style::NumberingType::ARABIC;
908 CPPUNIT_ASSERT_EQUAL(nNumberingType, hashMap[u"NumberingType"_ustr].get<sal_uInt16>());
911 DECLARE_WW8EXPORT_TEST(testTdf106541_inheritChapterNumbering, "tdf106541_inheritChapterNumbering.doc")
913 // The level and numbering are inherited from Heading 1.
914 uno::Reference<beans::XPropertySet> xPara(getParagraph(3, u"Letter A"_ustr), uno::UNO_QUERY);
915 CPPUNIT_ASSERT_EQUAL(u"a."_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
918 DECLARE_WW8EXPORT_TEST(testTdf106541_inheritChapterNumberingB, "tdf106541_inheritChapterNumberingB.doc")
920 // The level and numbering are inherited from Heading 1.
921 uno::Reference<beans::XPropertySet> xPara(getParagraph(1, u"Chapter 1, level 1"_ustr), uno::UNO_QUERY);
922 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
923 xPara.set(getParagraph(2, u"Chapter 1, level 2"_ustr), uno::UNO_QUERY);
924 CPPUNIT_ASSERT_EQUAL(u"1.1"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
927 DECLARE_WW8EXPORT_TEST(testTdf75748_inheritChapterNumberingC, "tdf75748_inheritChapterNumberingC.doc")
929 uno::Reference<beans::XPropertySet> xPara(getParagraph(5, u"Inherited from Heading 3"_ustr), uno::UNO_QUERY);
930 CPPUNIT_ASSERT_EQUAL(u"II.B.1."_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
933 DECLARE_WW8EXPORT_TEST(testTdf104239_numbering, "tdf104239_numbering.doc")
935 // The paragraph starts with "paraksta Pieņemšanas". [Roundtrip by Word 2016 avoids the problem.]
936 uno::Reference<beans::XPropertySet> xPara(getParagraph(51), uno::UNO_QUERY);
937 CPPUNIT_ASSERT_EQUAL(u"3.3.1."_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
940 DECLARE_WW8EXPORT_TEST(testTdf104239_chapterNumberingLevels, "tdf104239_chapterNumberingLevels.doc")
942 uno::Reference<beans::XPropertySet> xPara(getParagraph(1, u"Heading 1"_ustr), uno::UNO_QUERY);
943 CPPUNIT_ASSERT_EQUAL(u"Article I."_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
944 xPara.set(getParagraph(2, u"Heading 2"_ustr), uno::UNO_QUERY);
945 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
946 xPara.set(getParagraph(3, u"Heading 3"_ustr), uno::UNO_QUERY);
947 CPPUNIT_ASSERT_EQUAL(u"First"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
948 xPara.set(getParagraph(4, u"Heading 4"_ustr), uno::UNO_QUERY);
949 CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
950 xPara.set(getParagraph(8, u"Heading 9"_ustr), uno::UNO_QUERY);
951 CPPUNIT_ASSERT_EQUAL(u"1.1.1.1.1.1.1.1.1."_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
954 CPPUNIT_TEST_FIXTURE(Test, testTdf104239_chapterNumberTortureTest)
956 auto verify = [this](bool bIsExport = false) {
957 // There is no point in identifying what the wrong values where in this test,
958 //because EVERYTHING was wrong, and MANY different fixes are required to solve the problems.
959 uno::Reference<beans::XPropertySet> xPara(getParagraph(1, u"No numId in style or paragraph"_ustr), uno::UNO_QUERY);
960 CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
961 xPara.set(getParagraph(2, u"Paragraph cancels numbering(0)"_ustr), uno::UNO_QUERY);
962 CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
963 xPara.set(getParagraph(3, u"First numbered line"_ustr), uno::UNO_QUERY);
964 CPPUNIT_ASSERT_EQUAL(u"1st.i.a.1.I"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
965 xPara.set(getParagraph(7, u"inheritOnly: inherit outlineLvl and listLvl."_ustr), uno::UNO_QUERY);
966 CPPUNIT_ASSERT_EQUAL(u"2nd.ii"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
967 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty<sal_Int16>(xPara, u"NumberingLevel"_ustr)); // Level 2
968 xPara.set(getParagraph(9, u"outline with Body listLvl(9)."_ustr), uno::UNO_QUERY);
969 if (!bIsExport)
970 CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
971 xPara.set(getParagraph(10, u"outline with Body listLvl(9) #2."_ustr), uno::UNO_QUERY);
972 if (!bIsExport)
973 CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
974 xPara.set(getParagraph(11, u"direct formatting - Body listLvl(9)."_ustr), uno::UNO_QUERY);
975 CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
976 xPara.set(getParagraph(12, u"direct numId, inherit listLvl."_ustr), uno::UNO_QUERY);
977 CPPUNIT_ASSERT_EQUAL(u"2nd.ii.a.1.I"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
978 CPPUNIT_ASSERT_EQUAL(sal_Int16(4), getProperty<sal_Int16>(xPara, u"NumberingLevel"_ustr)); // Level 5
979 xPara.set(getParagraph(13, u"Style numId0 cancels inherited numbering."_ustr), uno::UNO_QUERY);
980 CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
983 createSwDoc("tdf104239_chapterNumberTortureTest.doc");
984 verify();
985 saveAndReload(mpFilter);
986 verify(/*bIsExport*/ true);
989 DECLARE_WW8EXPORT_TEST(testTdf106541_inheritOutlineNumbering, "tdf106541_inheritOutlineNumbering.doc")
991 // The level and numbering are inherited from Level2.
992 uno::Reference<beans::XPropertySet> xPara(getParagraph(2, u"This should be a sub-point."_ustr), uno::UNO_QUERY);
993 CPPUNIT_ASSERT_EQUAL(u"1.1"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
996 DECLARE_WW8EXPORT_TEST(testTdf104239_sharedOutlineNumId, "tdf104239_sharedOutlineNumId.doc")
998 uno::Reference<beans::XPropertySet> xPara(getParagraph(5, u"Principes"_ustr), uno::UNO_QUERY);
999 // This was ".1." previously.
1000 CPPUNIT_ASSERT_EQUAL(u"2.1."_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1003 DECLARE_WW8EXPORT_TEST(testTdf120394, "tdf120394.doc")
1005 CPPUNIT_ASSERT_EQUAL(1, getPages());
1007 uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
1008 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, u"NumberingLevel"_ustr));
1009 CPPUNIT_ASSERT_EQUAL(u"1.1.1"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1012 uno::Reference<beans::XPropertySet> xPara(getParagraph(5), uno::UNO_QUERY);
1013 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), getProperty<sal_Int16>(xPara, u"NumberingLevel"_ustr));
1014 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1017 uno::Reference<beans::XPropertySet> xPara(getParagraph(8), uno::UNO_QUERY);
1018 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, u"NumberingLevel"_ustr));
1019 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1022 uno::Reference<beans::XPropertySet> xPara(getParagraph(9), uno::UNO_QUERY);
1023 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, u"NumberingLevel"_ustr));
1024 CPPUNIT_ASSERT_EQUAL(u"1.1.2"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1027 uno::Reference<beans::XPropertySet> xPara(getParagraph(10), uno::UNO_QUERY);
1028 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, u"NumberingLevel"_ustr));
1029 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1033 DECLARE_WW8EXPORT_TEST(testTdf142760, "tdf142760.doc")
1035 // Without the fix in place, this test would have failed with
1036 // - Expected: 2
1037 // - Actual : 6
1038 CPPUNIT_ASSERT_EQUAL(2, getPages());
1039 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1041 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1042 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1043 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
1046 DECLARE_WW8EXPORT_TEST(testTdf134570, "tdf134570.doc")
1048 CPPUNIT_ASSERT_EQUAL(1, getPages());
1049 uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
1050 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), getProperty<sal_Int16>(xPara, u"NumberingLevel"_ustr));
1051 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1054 CPPUNIT_TEST_FIXTURE(Test, testTdf136814)
1056 loadAndReload("tdf136814.odt");
1057 CPPUNIT_ASSERT_EQUAL(1, getPages());
1058 uno::Reference<beans::XPropertySet> xStyle(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
1059 sal_Int32 nBorderDistance = static_cast<sal_Int32>(106);
1061 CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, u"TopBorderDistance"_ustr));
1062 CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, u"RightBorderDistance"_ustr));
1063 CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, u"BottomBorderDistance"_ustr));
1064 CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, u"LeftBorderDistance"_ustr));
1067 CPPUNIT_TEST_FIXTURE(Test, testTdf79186_noLayoutInCell)
1069 // given a native ODT file with a paragraph-oriented textbox anchored/located in cell B2
1071 // Note: there is no direct equivalent layout for this in MSO format,
1072 // so there has to be some give and take as the most suitable choice is selected.
1074 loadAndReload("tdf79186_noLayoutInCell.odt");
1075 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1076 // CPPUNIT_ASSERT_EQUAL(1, getPages());
1078 // Although setting "Follow Text Flow" significantly changes this doc's layout during ODF->DOC
1079 // it preserves orienting the frame in the proper column.
1080 // (While this example looked perfect in a LO round-trip without FTF,
1081 // in MS Word the textbox was contained in column A instead of the original column B.)
1082 // Thus the "perfect look" simply proves that LO is doing the layout wrong.
1083 CPPUNIT_ASSERT(getProperty<bool>(getShape(1), u"IsFollowingTextFlow"_ustr)); // tdf#157637
1084 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getShape(1), u"IsFollowingTextFlow"_ustr));
1085 xmlDocUniquePtr pDump = parseLayoutDump();
1086 sal_Int32 nShapeLeft
1087 = getXPath(pDump, "//anchored/SwAnchoredDrawObject/bounds",
1088 "left")
1089 .toInt32();
1090 sal_Int32 nColumnBLeft
1091 = getXPath(pDump, "//page[1]/body/tab/row[1]/cell[2]/infos/bounds",
1092 "left").toInt32();
1093 // The textbox's horizontal placement is of primary concern. It must remain in cell B2
1094 CPPUNIT_ASSERT(nShapeLeft > nColumnBLeft);
1096 CPPUNIT_ASSERT(getProperty<bool>(getShape(1), u"SurroundContour"_ustr)); // tdf#140508
1099 CPPUNIT_TEST_FIXTURE(Test, testClearingBreak)
1101 auto verify = [this]() {
1102 uno::Reference<container::XEnumerationAccess> xParagraph(getParagraph(1), uno::UNO_QUERY);
1103 uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration();
1104 xPortions->nextElement();
1105 xPortions->nextElement();
1106 // Without the accompanying fix in place, this test would have failed with:
1107 // An uncaught exception of type com.sun.star.container.NoSuchElementException
1108 // i.e. the first para was just a fly + text portion, the clearing break was lost.
1109 uno::Reference<beans::XPropertySet> xPortion(xPortions->nextElement(), uno::UNO_QUERY);
1110 OUString aPortionType;
1111 xPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aPortionType;
1112 CPPUNIT_ASSERT_EQUAL(u"LineBreak"_ustr, aPortionType);
1113 uno::Reference<text::XTextContent> xLineBreak;
1114 xPortion->getPropertyValue(u"LineBreak"_ustr) >>= xLineBreak;
1115 sal_Int16 eClear{};
1116 uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY);
1117 xLineBreakProps->getPropertyValue(u"Clear"_ustr) >>= eClear;
1118 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(SwLineBreakClear::ALL), eClear);
1121 // Given a document with a clearing break:
1122 // When loading that file:
1123 createSwDoc("clearing-break.doc");
1124 // Then make sure that the clear property of the break is not ignored:
1125 verify();
1126 saveAndReload(u"MS Word 97"_ustr);
1127 // Make sure that the clear property of the break is not ignored during export:
1128 verify();
1131 CPPUNIT_TEST_FIXTURE(Test, testTdf142840)
1133 loadAndReload("tdf142840.odt");
1134 CPPUNIT_ASSERT_EQUAL(1, getPages());
1136 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
1137 uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
1138 uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
1140 // Ensure space are replaced by underscore in bookmark name (it was working before, but ensure this)
1141 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xBookmarksByIdx->getCount());
1142 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Chapter_1"_ustr));
1143 CPPUNIT_ASSERT(!xBookmarksByName->hasByName(u"Chapter 1"_ustr));
1145 // And hyperlink is referring bookmark with underscore also (this was broken)
1146 CPPUNIT_ASSERT_EQUAL(u"#Chapter_1"_ustr, getProperty<OUString>(getRun(getParagraph(1), 1), u"HyperLinkURL"_ustr));
1149 CPPUNIT_PLUGIN_IMPLEMENT();
1151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */