Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / extras / ww8export / ww8export3.cxx
blob3f80ff8dcc9d1e1ae57d632d3e0894166af77478
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/FillStyle.hpp>
15 #include <com/sun/star/drawing/LineDash.hpp>
16 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
17 #include <com/sun/star/graphic/XGraphic.hpp>
18 #include <com/sun/star/table/ShadowFormat.hpp>
19 #include <com/sun/star/text/XFormField.hpp>
20 #include <com/sun/star/text/XTextField.hpp>
21 #include <com/sun/star/text/XTextTable.hpp>
22 #include <com/sun/star/text/XTextTablesSupplier.hpp>
23 #include <com/sun/star/text/WritingMode2.hpp>
24 #include <com/sun/star/text/XTextContentAppend.hpp>
25 #include <com/sun/star/frame/XStorable.hpp>
26 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
27 #include <com/sun/star/text/XFootnotesSupplier.hpp>
28 #include <com/sun/star/text/XTextDocument.hpp>
29 #include <com/sun/star/text/XLineNumberingProperties.hpp>
30 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
32 #include <comphelper/sequenceashashmap.hxx>
34 #include <IDocumentSettingAccess.hxx>
35 #include <docsh.hxx>
36 #include <unotxdoc.hxx>
37 #include <formatlinebreak.hxx>
38 #include <o3tl/string_view.hxx>
40 class Test : public SwModelTestBase
42 public:
43 Test()
44 : SwModelTestBase("/sw/qa/extras/ww8export/data/", "MS Word 97")
49 DECLARE_WW8EXPORT_TEST(testTdf37778_readonlySection, "tdf37778_readonlySection.doc")
51 uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
52 CPPUNIT_ASSERT( xStorable->isReadonly() );
54 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
55 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
56 // The problem was that section protection was being enabled in addition to being read-only.
57 // This created an explicit section with protection. There should be just the default, non-explicit section.
58 CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of Sections", sal_Int32(0), xSections->getCount());
60 // tdf#127862: page fill color (in this case white) was lost
61 uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
62 CPPUNIT_ASSERT(drawing::FillStyle_NONE != getProperty<drawing::FillStyle>(xStyle, "FillStyle"));
64 // tdf#136983
65 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(mxComponent, uno::UNO_QUERY);
66 CPPUNIT_ASSERT_EQUAL_MESSAGE("Last printed date", sal_Int16(2009), xDPS->getDocumentProperties()->getPrintDate().Year);
69 DECLARE_WW8EXPORT_TEST(testTdf100961_fixedDateTime, "tdf100961_fixedDateTime.doc")
71 // This should be a fixed date/time field, not the current time.
72 getParagraph(1, "05.01.19 04:06:08");
74 css::uno::Reference<css::text::XTextFieldsSupplier> xSupplier(mxComponent,
75 css::uno::UNO_QUERY_THROW);
76 auto xFieldsAccess(xSupplier->getTextFields());
77 auto xFields(xFieldsAccess->createEnumeration());
79 css::uno::Reference<css::uno::XInterface> xField(xFields->nextElement(), css::uno::UNO_QUERY);
80 // Check fixed property was imported and date value was parsed correctly
81 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xField, "IsFixed"));
82 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xField, "IsDate"));
83 auto datetime = getProperty<css::util::DateTime>(xField, "DateTimeValue");
84 CPPUNIT_ASSERT_EQUAL(sal_uInt16(5), datetime.Day);
85 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), datetime.Month);
86 CPPUNIT_ASSERT_EQUAL(sal_Int16(2019), datetime.Year);
88 xField.set(xFields->nextElement(), css::uno::UNO_QUERY);
89 // Check fixed property was imported and time value was parsed correctly
90 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xField, "IsFixed"));
91 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xField, "IsDate"));
92 datetime = getProperty<css::util::DateTime>(xField, "DateTimeValue");
93 CPPUNIT_ASSERT_EQUAL(sal_uInt16(4), datetime.Hours);
94 CPPUNIT_ASSERT_EQUAL(sal_uInt16(6), datetime.Minutes);
95 CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), datetime.Seconds);
98 DECLARE_WW8EXPORT_TEST(testTdf147861_customField, "tdf147861_customField.doc")
100 // These should each be specific values, not a shared DocProperty
101 getParagraph(1, "CustomEditedTitle"); // edited
102 // A couple of \x0\x0 at the end of the import variable thwart an equality comparison
103 CPPUNIT_ASSERT(getParagraph(2)->getString().startsWith(" INSERT Custom Title here"));
104 getParagraph(3, "My Title"); // edited
106 // Verify that these are fields, and not just plain text
107 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
108 auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
109 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
110 uno::Reference<text::XTextField> xField(xFields->nextElement(), uno::UNO_QUERY);
111 CPPUNIT_ASSERT_EQUAL(OUString("CustomEditedTitle"), xField->getPresentation(false));
112 // The " (fixed)" part is unnecessary, but it must be consistent across a round-trip
113 CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Title (fixed)"), xField->getPresentation(true));
116 DECLARE_WW8EXPORT_TEST(testTdf148380_createField, "tdf148380_createField.doc")
118 // Verify that these are fields, and not just plain text
119 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
120 auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
121 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
122 uno::Reference<text::XTextField> xField(xFields->nextElement(), uno::UNO_QUERY);
123 // This should NOT be "Lorenzo Chavez", or a real date since the user hand-modified the result.
124 CPPUNIT_ASSERT_EQUAL(OUString("Myself - that's who"), xField->getPresentation(false));
125 xField.set(xFields->nextElement(), uno::UNO_QUERY);
126 CPPUNIT_ASSERT_EQUAL(OUString("yesterday at noon"), xField->getPresentation(false));
129 DECLARE_WW8EXPORT_TEST(testTdf148380_fldLocked, "tdf148380_fldLocked.doc")
131 getParagraph(2, "4/5/2022 4:29:00 PM");
132 getParagraph(4, "1/23/4567 8:9:10 PM");
134 // Verify that these are fields, and not just plain text
135 // (import only, since export thankfully just dumps these fixed fields as plain text
136 if (isExported())
137 return;
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(OUString("4/5/2022 4:29:00 PM"), xField->getPresentation(false));
144 CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Modified (fixed)"), xField->getPresentation(true));
145 xField.set(xFields->nextElement(), uno::UNO_QUERY);
146 CPPUNIT_ASSERT_EQUAL(OUString("1/23/4567 8:9:10 PM"), xField->getPresentation(false));
147 CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Last printed (fixed)"), xField->getPresentation(true));
150 DECLARE_WW8EXPORT_TEST(testTdf138345_paraCharHighlight, "tdf138345_paraCharHighlight.doc")
152 uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(9), 1, "A side benefit is that "), 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, "CharHighlight"));
156 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, "CharBackColor"));
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, "CharHighlight"));
161 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, "CharBackColor"));
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("PageDescName"));
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("PageStyles")->getByName("Standard") >>= xPageStyle;
182 sal_Int32 nGutterMargin{};
183 xPageStyle->getPropertyValue("GutterMargin") >>= 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("MS Word 97");
195 uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
196 uno::Reference<beans::XPropertySet> xSettings(
197 xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
198 bool bGutterAtTop{};
199 xSettings->getPropertyValue("GutterAtTop") >>= 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), "NumberingRules");
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["NumberingType"].get<sal_uInt16>());
218 DECLARE_WW8EXPORT_TEST(testTdf128501, "tdf128501.doc")
220 if (!isExported())
222 uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor = getShape(1);
223 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), xShapeDescriptor->getShapeType());
225 else
227 uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor = getShape(1);
228 // Without the fix in place, this test would have failed with
229 // - Expected: FrameShape
230 // - Actual : com.sun.star.drawing.CustomShape
231 CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), xShapeDescriptor->getShapeType());
235 CPPUNIT_TEST_FIXTURE(SwModelTestBase, testArabicZeroNumberingFootnote)
237 // Create a document, set footnote numbering type to ARABIC_ZERO.
238 createSwDoc();
239 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
240 uno::Reference<beans::XPropertySet> xFootnoteSettings
241 = xFootnotesSupplier->getFootnoteSettings();
242 sal_uInt16 nNumberingType = style::NumberingType::ARABIC_ZERO;
243 xFootnoteSettings->setPropertyValue("NumberingType", uno::Any(nNumberingType));
245 // Insert a footnote.
246 uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
247 uno::Reference<text::XTextContent> xFootnote(
248 xFactory->createInstance("com.sun.star.text.Footnote"), uno::UNO_QUERY);
249 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
250 uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(),
251 uno::UNO_QUERY);
252 xTextContentAppend->appendTextContent(xFootnote, {});
254 saveAndReload("MS Word 97");
255 xFootnotesSupplier.set(mxComponent, uno::UNO_QUERY);
256 sal_uInt16 nExpected = style::NumberingType::ARABIC_ZERO;
257 auto nActual = getProperty<sal_uInt16>(xFootnotesSupplier->getFootnoteSettings(), "NumberingType");
258 // Without the accompanying fix in place, this test would have failed with:
259 // - Expected: 64
260 // - Actual : 4
261 // i.e. the numbering type was ARABIC, not ARABIC_ZERO.
262 CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
265 CPPUNIT_TEST_FIXTURE(SwModelTestBase, testChicagoNumberingFootnote)
267 // Create a document, set footnote numbering type to SYMBOL_CHICAGO.
268 createSwDoc();
269 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
270 uno::Reference<beans::XPropertySet> xFootnoteSettings
271 = xFootnotesSupplier->getFootnoteSettings();
272 sal_uInt16 nNumberingType = style::NumberingType::SYMBOL_CHICAGO;
273 xFootnoteSettings->setPropertyValue("NumberingType", uno::Any(nNumberingType));
275 // Insert a footnote.
276 uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
277 uno::Reference<text::XTextContent> xFootnote(
278 xFactory->createInstance("com.sun.star.text.Footnote"), uno::UNO_QUERY);
279 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
280 uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(),
281 uno::UNO_QUERY);
282 xTextContentAppend->appendTextContent(xFootnote, {});
284 saveAndReload("MS Word 97");
285 xFootnotesSupplier.set(mxComponent, uno::UNO_QUERY);
286 sal_uInt16 nExpected = style::NumberingType::SYMBOL_CHICAGO;
287 auto nActual = getProperty<sal_uInt16>(xFootnotesSupplier->getFootnoteSettings(), "NumberingType");
288 // Without the accompanying fix in place, this test would have failed with:
289 // - Expected: 63
290 // - Actual : 4
291 // i.e. the numbering type was ARABIC, not SYMBOL_CHICAGO.
292 CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
295 DECLARE_WW8EXPORT_TEST(testHyperLinkURLSaving, "tdf120003.doc")
297 OUString URL = getProperty<OUString>(getShape(1), "HyperLinkURL");
298 // Without the fix in place, this test would have failed with
299 // - Expected: https://www.libreoffice.org/
300 // - Actual : tps://www.libreoffice.org/
301 CPPUNIT_ASSERT_EQUAL(OUString("https://www.libreoffice.org/"), URL);
304 DECLARE_WW8EXPORT_TEST(testdf79553_lineNumbers, "tdf79553_lineNumbers.doc")
306 bool bValue = false;
307 sal_Int32 nValue = -1;
309 uno::Reference< text::XTextDocument > xtextDocument(mxComponent, uno::UNO_QUERY);
310 uno::Reference< text::XLineNumberingProperties > xLineProperties( xtextDocument, uno::UNO_QUERY_THROW );
311 uno::Reference< beans::XPropertySet > xPropertySet = xLineProperties->getLineNumberingProperties();
313 xPropertySet->getPropertyValue("IsOn") >>= bValue;
314 CPPUNIT_ASSERT_EQUAL(true, bValue);
316 xPropertySet->getPropertyValue("Distance") >>= nValue;
317 CPPUNIT_ASSERT_MESSAGE("automatic distance", nValue > 0);
320 CPPUNIT_TEST_FIXTURE(Test, testTdf138302_restartNumbering)
322 loadAndReload("tdf138302_restartNumbering.odt");
323 CPPUNIT_ASSERT_EQUAL(1, getPages());
324 uno::Reference<beans::XPropertySet> xPara(getParagraph(8), uno::UNO_QUERY);
325 CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(xPara, "ListLabelString"));
328 // tdf#143982: automatic tables should export as something better than just left-and-size
329 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
330 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
331 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
333 CPPUNIT_ASSERT(getProperty<bool>(xTable, "IsWidthRelative"));
334 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xTable, "RelativeWidth"));
337 DECLARE_WW8EXPORT_TEST(testTdf122429_header, "tdf122429_header.doc")
339 uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles");
340 uno::Reference<style::XStyle> pageStyle(pageStyles->getByName("Default Page Style"), uno::UNO_QUERY);
341 bool headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
342 CPPUNIT_ASSERT(headerIsOn);
345 CPPUNIT_TEST_FIXTURE(Test, testTdf122460_header)
347 loadAndReload("tdf122460_header.odt");
348 CPPUNIT_ASSERT_EQUAL(1, getPages());
349 uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles");
350 uno::Reference<style::XStyle> pageStyle(pageStyles->getByName("Default Page Style"), uno::UNO_QUERY);
351 bool headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
352 CPPUNIT_ASSERT(headerIsOn);
355 DECLARE_WW8EXPORT_TEST(testTdf139495_tinyHeader, "tdf139495_tinyHeader.doc")
357 // In Word 2003, this is one page, but definitely not six pages.
358 CPPUNIT_ASSERT(getPages() < 3);
361 DECLARE_WW8EXPORT_TEST(testTdf124937, "tdf124937.doc")
363 // Check it doesn't crash at import time
364 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
365 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
366 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
367 CPPUNIT_ASSERT_EQUAL(1, getPages());
370 DECLARE_WW8EXPORT_TEST(testFdo53985, "fdo53985.doc")
372 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
373 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
374 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xTables->getCount()); // Only 4 tables were imported.
376 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
377 CPPUNIT_ASSERT(pTextDoc);
378 SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
379 CPPUNIT_ASSERT_EQUAL_MESSAGE("Compatibility: Protect form", true, pDoc->getIDocumentSettingAccess().get( DocumentSettingId::PROTECT_FORM ) );
381 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
382 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
383 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xSections->getCount()); // The first paragraph wasn't counted as a section.
385 uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY);
386 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section1 is protected", true, getProperty<bool>(xSect, "IsProtected"));
387 xSect.set(xSections->getByIndex(3), uno::UNO_QUERY);
388 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section4 is protected", false, getProperty<bool>(xSect, "IsProtected"));
391 DECLARE_WW8EXPORT_TEST(testTdf73056_cellMargins, "tdf73056_cellMargins.doc")
393 uno::Reference< text::XTextTablesSupplier > xTablesSupplier( mxComponent, uno::UNO_QUERY );
394 uno::Reference< container::XIndexAccess > xTables( xTablesSupplier->getTextTables(), uno::UNO_QUERY );
395 uno::Reference< text::XTextTable > xTable1( xTables->getByIndex( 0 ), uno::UNO_QUERY );
396 uno::Reference< table::XCell > xCell = xTable1->getCellByName( "B4" );
398 // only the first cell with specific margins was processed, leaving the rest at table defaults. Was 0.
399 uno::Reference< beans::XPropertySet > xPropSet( xCell, uno::UNO_QUERY_THROW );
400 CPPUNIT_ASSERT_EQUAL_MESSAGE( "bottom cell spacing to contents",
401 sal_Int32(101), getProperty<sal_Int32>(xPropSet, "BottomBorderDistance" ) );
404 DECLARE_WW8EXPORT_TEST(testTdf135672_tableGrows, "tdf135672_tableGrows.doc")
406 auto const xTable(getParagraphOrTable(1));
407 // This would shift left every round-trip. First time was -259, next -418.
408 CPPUNIT_ASSERT_EQUAL(sal_Int32(-101), getProperty<sal_Int32>(xTable, "LeftMargin"));
410 // This would grow every round-trip. First time was 11118, next 11435
411 CPPUNIT_ASSERT_EQUAL(sal_Int32(10800), getProperty<sal_Int32>(xTable, "Width"));
414 CPPUNIT_TEST_FIXTURE(Test, testTdf79435_legacyInputFields)
416 loadAndReload("tdf79435_legacyInputFields.docx");
417 //using .docx input file to verify cross-format compatibility.
418 uno::Reference<text::XFormField> xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(5), 3), "Bookmark");
419 uno::Reference<container::XNameContainer> xParameters(xFormField->getParameters());
421 OUString sTmp;
422 // Too often the string reader can fail during import - fix that first to prevent round-tripping garbage.
423 // (for example BR-1010B.doc from tdf#48097)
424 //xParameters->getByName("EntryMacro") >>= sTmp;
425 //CPPUNIT_ASSERT_EQUAL(OUString("test"), sTmp);
426 //xParameters->getByName("Help") >>= sTmp;
427 //CPPUNIT_ASSERT_EQUAL(OUString("F1Help"), sTmp);
428 //xParameters->getByName("ExitMacro") >>= sTmp;
429 //CPPUNIT_ASSERT_EQUAL(OUString("test"), sTmp);
430 xParameters->getByName("Description") >>= sTmp;
431 CPPUNIT_ASSERT_EQUAL(OUString("StatusHelp"), sTmp);
432 //xParameters->getByName("Content") >>= sTmp;
433 //CPPUNIT_ASSERT_EQUAL(OUString("Camelcase"), sTmp);
434 //xParameters->getByName("Format") >>= sTmp;
435 //CPPUNIT_ASSERT_EQUAL(OUString("TITLE CASE"), sTmp);
437 sal_uInt16 nMaxLength = 0;
438 xParameters->getByName("MaxLength") >>= nMaxLength;
439 CPPUNIT_ASSERT_EQUAL_MESSAGE("Max Length", sal_uInt16(10), nMaxLength);
441 // too bad this is based on character runs - just found try trial and error.
442 xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(6), 2), "Bookmark");
443 xParameters.set(xFormField->getParameters());
444 xParameters->getByName("Type") >>= sTmp;
445 CPPUNIT_ASSERT_EQUAL(OUString("calculated"), sTmp);
447 xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(7), 2), "Bookmark");
448 xParameters.set(xFormField->getParameters());
449 xParameters->getByName("Type") >>= sTmp;
450 CPPUNIT_ASSERT_EQUAL(OUString("currentDate"), sTmp);
452 xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(7), 7), "Bookmark");
453 xParameters.set(xFormField->getParameters());
454 xParameters->getByName("Type") >>= sTmp;
455 CPPUNIT_ASSERT_EQUAL(OUString("currentTime"), sTmp);
457 xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(8), 2), "Bookmark");
458 xParameters.set(xFormField->getParameters());
459 xParameters->getByName("Type") >>= sTmp;
460 CPPUNIT_ASSERT_EQUAL(OUString("number"), sTmp);
462 xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(8), 7), "Bookmark");
463 xParameters.set(xFormField->getParameters());
464 xParameters->getByName("Type") >>= sTmp;
465 CPPUNIT_ASSERT_EQUAL(OUString("date"), sTmp);
468 CPPUNIT_TEST_FIXTURE(Test, testTdf134264)
470 loadAndReload("tdf134264.docx");
471 // Without the fix in place, ADDRESSBLOCK fields would have been lost after RT
472 CPPUNIT_ASSERT_EQUAL(OUString("MF"), getParagraph(1)->getString());
473 CPPUNIT_ASSERT_EQUAL(OUString("M19"), getParagraph(2)->getString());
474 CPPUNIT_ASSERT_EQUAL(OUString("1815"), getParagraph(3)->getString());
477 DECLARE_WW8EXPORT_TEST(testTdf120225_textControlCrossRef, "tdf120225_textControlCrossRef.doc")
479 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
480 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
481 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
482 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
483 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
484 xRunEnum->nextElement();
485 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
487 CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
488 uno::Reference<container::XNamed> xBookmark(getProperty< uno::Reference<beans::XPropertySet> >(xPropertySet, "Bookmark"), uno::UNO_QUERY_THROW);
490 // Critical test: does TextField's bookmark name match cross-reference?
491 const OUString& sTextFieldName( xBookmark->getName() );
492 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
493 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
494 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
495 CPPUNIT_ASSERT(xFields->hasMoreElements());
496 xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
497 CPPUNIT_ASSERT_EQUAL(sTextFieldName, getProperty<OUString>(xPropertySet, "SourceName"));
499 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
500 uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
501 uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
502 // TextFields should not be turned into real bookmarks.
503 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xBookmarksByIdx->getCount());
505 // The actual name isn't critical, but if it fails, it is worth asking why.
506 CPPUNIT_ASSERT_EQUAL(OUString("Text1"), sTextFieldName);
509 CPPUNIT_TEST_FIXTURE(Test, testTdf134948)
511 loadAndReload("tdf134948.odt");
512 CPPUNIT_ASSERT_EQUAL(1, getShapes());
513 CPPUNIT_ASSERT_EQUAL(1, getPages());
514 CPPUNIT_ASSERT_EQUAL_MESSAGE("Only 1 paragraph", 1, getParagraphs());
517 CPPUNIT_TEST_FIXTURE(Test, testTdf132726)
519 loadAndReload("tdf132726.odt");
520 CPPUNIT_ASSERT_EQUAL(1, getShapes());
521 CPPUNIT_ASSERT_EQUAL(1, getPages());
522 uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 1, "What sentence has a yellow background? ");
523 CPPUNIT_ASSERT_EQUAL( COL_AUTO, getProperty<Color>(xRun, "CharBackColor"));
525 xRun = getRun(getParagraph(1), 2, "Why, this sentence of course");
526 CPPUNIT_ASSERT_EQUAL( COL_YELLOW, getProperty<Color>(xRun, "CharBackColor"));
529 CPPUNIT_TEST_FIXTURE(Test, testTdf127316_autoEscapement)
531 loadAndReload("tdf127316_autoEscapement.odt");
532 CPPUNIT_ASSERT_EQUAL(1, getPages());
533 uno::Reference<text::XTextRange> xPara = getParagraph(2);
534 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.f, getProperty<float>(getRun(xPara, 1, "Normal text "), "CharEscapement"), 0);
535 // Negative escapements (subscripts) were decreasing by 1% every round-trip due to bad manual rounding.
536 // This should be roughly .2*35% of the ORIGINAL (non-reduced) size. However, during export the
537 // proportional height has to be changed into direct formatting, which then changes the relative percent.
538 // In this case, a 24pt font, proportional at 65% becomes roughly a 16pt font.
539 // Thus an escapement of 7% (1.68pt) becomes roughly 10.5% for the 16pt font.
540 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Subscript", -10.f, getProperty<float>(getRun(xPara, 2), "CharEscapement"), 1);
543 CPPUNIT_TEST_FIXTURE(Test, testTdf127316_autoEscapement2)
545 loadAndReload("tdf127316_autoEscapement2.odt");
546 CPPUNIT_ASSERT_EQUAL(2, getPages());
547 uno::Reference<text::XTextRange> xPara = getParagraph(1);
548 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.f, getProperty<float>(getRun(xPara, 1, "Base1"), "CharEscapement"), 0);
549 // Font is 80% of 40pt or 32pt, original escapement is 6.4pt, so round-trip escapement is 20%.
550 CPPUNIT_ASSERT_DOUBLES_EQUAL(20.f, getProperty<float>(getRun(xPara, 2,"AutoSuperscript"), "CharEscapement"), 1);
551 xPara.set( getParagraph(3) );
552 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.f, getProperty<float>(getRun(xPara, 1, "Base3"), "CharEscapement"), 0);
553 // font is 20% of 40pt or 8pt, original escapement is 25.6pt, so round-trip escapement is 320%.
554 CPPUNIT_ASSERT_DOUBLES_EQUAL(320.f, getProperty<float>(getRun(xPara, 2,"AutoSuperscript"), "CharEscapement"), 3);
557 CPPUNIT_TEST_FIXTURE(Test, testTdf120412_proportionalEscapement)
559 loadAndReload("tdf120412_proportionalEscapement.odt");
560 uno::Reference<text::XTextRange> xPara = getParagraph(2);
561 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.f, getProperty<float>(getRun(xPara, 2, "Base"), "CharEscapement"), 0);
562 // Import was limiting to 100%. And export based the position on the original height, not the proportional height.
563 CPPUNIT_ASSERT_DOUBLES_EQUAL( 150.f, getProperty<float>(getRun(xPara, 3,"Super"), "CharEscapement"), 2);
564 CPPUNIT_ASSERT_EQUAL(2, getPages());
567 DECLARE_WW8EXPORT_TEST(testTdf133453_realFontSize, "tdf133453_realFontSize.doc")
569 CPPUNIT_ASSERT_EQUAL( -95.f, getProperty<float>(getRun(getParagraph(1), 2, "2"), "CharEscapement") );
572 DECLARE_WW8EXPORT_TEST(testTdf116194, "tdf116194.doc")
574 CPPUNIT_ASSERT_EQUAL( Color(0xc00000), getProperty<Color>(getRun(getParagraph(1), 1), "CharColor"));
577 CPPUNIT_TEST_FIXTURE(Test, testTdf121111_fillStyleNone)
579 loadAndReload("tdf121111_fillStyleNone.docx");
580 uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Numbering - First level"),
581 uno::UNO_QUERY);
582 CPPUNIT_ASSERT_EQUAL(Color(0xb8cce4), getProperty<Color>(xStyle, "ParaBackColor"));//R:184 G:204 B:228
583 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xStyle, "FillStyle"));
585 uno::Reference<text::XTextRange> xText(getParagraph(12));
586 CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xText, "ParaBackColor"));
587 CPPUNIT_ASSERT_EQUAL_MESSAGE("No fill", drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xText, "FillStyle"));
590 CPPUNIT_TEST_FIXTURE(Test, testTdf128608_fillStyleNoneB)
592 loadAndReload("tdf128608_fillStyleNoneB.odt");
593 CPPUNIT_ASSERT_EQUAL(1, getPages());
594 uno::Reference<text::XTextRange> xText(getParagraph(1));
595 CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xText, "ParaBackColor"));
596 CPPUNIT_ASSERT_EQUAL_MESSAGE("No fill", drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xText, "FillStyle"));
599 DECLARE_WW8EXPORT_TEST(testTdf132094_transparentPageImage, "tdf132094_transparentPageImage.doc")
601 uno::Reference<drawing::XShape> image (getShape(1), uno::UNO_QUERY);
602 // Don't add fillstyle when none is set.
603 // Well, ok, at least make it transparent if you do uselessly set a solid color...
604 const bool bFillNone = drawing::FillStyle_NONE == getProperty<drawing::FillStyle>(image, "FillStyle");
605 const bool bTransparent = sal_Int16(0) != getProperty<sal_Int16>(image, "FillTransparence");
606 CPPUNIT_ASSERT_MESSAGE("no background fill", bTransparent || bFillNone);
609 DECLARE_WW8EXPORT_TEST(testTdf112618_textbox_no_bg, "tdf112618_textbox_no_bg.doc")
611 Color nTransparence = getProperty<Color>(getShape(2), "FillTransparence");
612 CPPUNIT_ASSERT_EQUAL(Color(0x000064), nTransparence);
613 CPPUNIT_ASSERT_EQUAL(nTransparence, getProperty<Color>(getShape(2), "BackColorTransparency"));
616 DECLARE_WW8EXPORT_TEST(testTdf101826_xattrTextBoxFill, "tdf101826_xattrTextBoxFill.doc")
618 //Basic 1 Color Fill: gradient from yellow(FFFF00) to brown(767600) currently saves as mid-color
619 CPPUNIT_ASSERT_MESSAGE("background color", Color(0xFF, 0xFF, 0x00) != getProperty<Color>(getShape(1), "BackColor"));
620 //Basic 2 Color Fill: gradient from yellow(FFFF00) to green(00B050) currently saves as mid-color
621 CPPUNIT_ASSERT_MESSAGE("background color", Color(0xFF, 0xFF, 0x00) != getProperty<Color>(getShape(4), "BackColor"));
622 //Basic Picture Fill: Tux image
623 CPPUNIT_ASSERT_EQUAL_MESSAGE("background image", drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(getShape(5), "FillStyle"));
626 DECLARE_WW8EXPORT_TEST(testTdf123433_fillStyleStop, "tdf123433_fillStyleStop.doc")
628 uno::Reference<text::XTextRange> xText(getParagraph(12));
629 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xText, "FillStyle"));
630 CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xText, "ParaBackColor"));
633 CPPUNIT_TEST_FIXTURE(Test, testTdf127862_pageFillStyle)
635 loadAndReload("tdf127862_pageFillStyle.odt");
636 CPPUNIT_ASSERT_EQUAL(6, getPages());
637 uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
638 CPPUNIT_ASSERT(drawing::FillStyle_NONE != getProperty<drawing::FillStyle>(xStyle, "FillStyle"));
641 DECLARE_WW8EXPORT_TEST(testTdf128608_tableParaBackColor, "tdf128608_tableParaBackColor.doc")
643 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
644 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
645 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
646 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A4"), uno::UNO_QUERY);
648 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
649 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
650 uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
651 // ParaBackColor doesn't seem to be used in this case, but keep it here to make sure it stays as AUTO.
652 CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xPara, "ParaBackColor"));
653 // No paragraph background colour/fill. (The cell background colour should be used.)
654 CPPUNIT_ASSERT_EQUAL_MESSAGE("No fillstyle", drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xPara, "FillStyle"));
657 CPPUNIT_TEST_FIXTURE(Test, testTdf117217_largeTableBackgrounds)
659 loadAndReload("tdf117217_largeTableBackgrounds.odt");
660 CPPUNIT_ASSERT_EQUAL(1, getPages());
661 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
662 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
663 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
664 // Cell 22: light-red == 16711680
665 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("V1"), uno::UNO_QUERY_THROW);
666 CPPUNIT_ASSERT_EQUAL_MESSAGE("light red", Color(0xE0C2CD), getProperty<Color>(xCell, "BackColor"));
667 xCell.set(xTable->getCellByName("Z1"), uno::UNO_QUERY_THROW);
668 CPPUNIT_ASSERT_EQUAL_MESSAGE("light red", Color(0xE0C2CD), getProperty<Color>(xCell, "BackColor"));
671 CPPUNIT_TEST_FIXTURE(Test, testTdf94009_zeroPgMargin)
673 loadAndReload("tdf94009_zeroPgMargin.odt");
674 CPPUNIT_ASSERT_EQUAL(1, getPages());
675 uno::Reference<beans::XPropertySet> defaultStyle(getStyles("PageStyles")->getByName("Standard"),
676 uno::UNO_QUERY);
677 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(defaultStyle, "TopMargin"));
680 DECLARE_WW8EXPORT_TEST(testTdf108518_CRnumformatting, "tdf108518_CRnumformatting.doc")
682 CPPUNIT_ASSERT_EQUAL(OUString("6.2.3."), parseDump("//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", "expand"));
683 //Without this fix in place, it would become 200 (and non-bold).
684 CPPUNIT_ASSERT_EQUAL(OUString("220"), parseDump("//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']/SwFont", "height"));
687 DECLARE_WW8EXPORT_TEST(testTdf120711_joinedParagraphWithChangeTracking, "tdf120711.doc")
689 sal_Int16 numFormat = getNumberingTypeOfParagraph(5);
690 // last paragraph is not a list item
691 CPPUNIT_ASSERT(style::NumberingType::CHAR_SPECIAL != numFormat);
694 CPPUNIT_TEST_FIXTURE(Test, testTdf129522_removeShadowStyle)
696 loadAndReload("tdf129522_removeShadowStyle.odt");
697 CPPUNIT_ASSERT_EQUAL(1, getPages());
698 uno::Reference< container::XNameAccess > paragraphStyles = getStyles("ParagraphStyles");
699 uno::Reference< beans::XPropertySet > xStyleProps(paragraphStyles->getByName("Shadow"), uno::UNO_QUERY_THROW);
700 table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xStyleProps, "ParaShadowFormat");
701 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
703 // Shadows were inherited regardless of whether the style disabled them.
704 xStyleProps.set(paragraphStyles->getByName("Shadow-removed"), uno::UNO_QUERY_THROW);
705 aShadow = getProperty<table::ShadowFormat>(xStyleProps, "ParaShadowFormat");
706 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
708 uno::Reference< container::XNameAccess > characterStyles = getStyles("CharacterStyles");
709 xStyleProps.set(characterStyles->getByName("CharShadow"), uno::UNO_QUERY_THROW);
710 aShadow = getProperty<table::ShadowFormat>(xStyleProps, "CharShadowFormat");
711 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
713 xStyleProps.set(characterStyles->getByName("CharShadow-removed"), uno::UNO_QUERY_THROW);
714 aShadow = getProperty<table::ShadowFormat>(xStyleProps, "CharShadowFormat");
715 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
718 DECLARE_WW8EXPORT_TEST(testTdf81705_outlineLevel, "tdf81705_outlineLevel.doc")
720 // direct formatting resets outline level to body text (0)
721 CPPUNIT_ASSERT_EQUAL_MESSAGE("Paragraph C", sal_uInt16(0), getProperty<sal_uInt16>(getParagraph(3), "OutlineLevel"));
722 // myStyle sets outline level to 1.
723 CPPUNIT_ASSERT_EQUAL_MESSAGE("Paragraph D", sal_uInt16(1), getProperty<sal_uInt16>(getParagraph(4), "OutlineLevel"));
726 DECLARE_WW8EXPORT_TEST(testBtlrCell, "btlr-cell.doc")
728 // Without the accompanying fix in place, this test would have failed, as
729 // the btlr text direction in the A1 cell was lost on DOC import and
730 // export.
731 uno::Reference<text::XTextTablesSupplier> xSupplier(mxComponent, uno::UNO_QUERY);
732 uno::Reference<container::XNameAccess> xTables = xSupplier->getTextTables();
733 uno::Reference<text::XTextTable> xTable(xTables->getByName("Table1"), uno::UNO_QUERY);
734 uno::Reference<beans::XPropertySet> xA1(xTable->getCellByName("A1"), uno::UNO_QUERY);
735 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, getProperty<sal_Int16>(xA1, "WritingMode"));
737 uno::Reference<beans::XPropertySet> xB1(xTable->getCellByName("B1"), uno::UNO_QUERY);
738 auto nActual = getProperty<sal_Int16>(xB1, "WritingMode");
739 CPPUNIT_ASSERT(nActual == text::WritingMode2::LR_TB || nActual == text::WritingMode2::CONTEXT);
741 uno::Reference<beans::XPropertySet> xC1(xTable->getCellByName("C1"), uno::UNO_QUERY);
742 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty<sal_Int16>(xC1, "WritingMode"));
745 DECLARE_WW8EXPORT_TEST(testTdf118375export, "tdf118375_240degClockwise.doc")
747 // The input document has one custom shape, which is rotated 240deg. Check
748 // that it has the same position as in Word.
749 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
750 uno::UNO_QUERY_THROW);
751 CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
752 uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
753 uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
754 CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage.is());
755 uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
756 CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape.is());
757 uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
758 CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps.is());
759 sal_Int32 nPosX = {}, nPosY = {};
760 CPPUNIT_ASSERT(xShapeProps->getPropertyValue("HoriOrientPosition") >>= nPosX);
761 CPPUNIT_ASSERT(xShapeProps->getPropertyValue("VertOrientPosition") >>= nPosY);
762 // Allow some tolerance because rounding errors through integer arithmetic
763 // in rotation.
764 CPPUNIT_ASSERT_DOUBLES_EQUAL(5200.0, static_cast<double>(nPosX), 1.0);
765 CPPUNIT_ASSERT_DOUBLES_EQUAL(1152.0, static_cast<double>(nPosY), 1.0);
768 DECLARE_WW8EXPORT_TEST(testImageCommentAtChar, "image-comment-at-char.doc")
770 uno::Reference<text::XTextRange> xPara = getParagraph(1);
771 CPPUNIT_ASSERT_EQUAL(OUString("Text"),
772 getProperty<OUString>(getRun(xPara, 1), "TextPortionType"));
773 // Without the accompanying fix in place, this test would have failed with 'Expected:
774 // Annotation; Actual: Frame', i.e. the comment start before the image was lost.
775 CPPUNIT_ASSERT_EQUAL(OUString("Annotation"),
776 getProperty<OUString>(getRun(xPara, 2), "TextPortionType"));
777 CPPUNIT_ASSERT_EQUAL(OUString("Frame"),
778 getProperty<OUString>(getRun(xPara, 3), "TextPortionType"));
779 CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"),
780 getProperty<OUString>(getRun(xPara, 4), "TextPortionType"));
781 CPPUNIT_ASSERT_EQUAL(OUString("Text"),
782 getProperty<OUString>(getRun(xPara, 5), "TextPortionType"));
785 CPPUNIT_TEST_FIXTURE(Test, testTdf126708emf)
787 loadAndReload("tdf126708_containsemf.odt");
788 CPPUNIT_ASSERT_EQUAL(1, getShapes());
789 CPPUNIT_ASSERT_EQUAL(1, getPages());
790 auto xShape = getShape(1);
791 // First check the size of the EMF graphic contained in the shape.
792 auto xGraphic = getProperty< uno::Reference<graphic::XGraphic> >(
793 xShape, "Graphic");
794 auto xSize = getProperty<awt::Size>(xGraphic, "Size100thMM");
795 CPPUNIT_ASSERT_EQUAL(sal_Int32(8501), xSize.Height);
796 CPPUNIT_ASSERT_EQUAL(sal_Int32(18939), xSize.Width);
798 // Now check that the shape itself has a decent size.
799 // This size varies slightly when round tripping through doc format.
800 xSize = getProperty<awt::Size>(xShape, "Size");
801 CPPUNIT_ASSERT(abs(xSize.Height - 7629) <= 6);
802 CPPUNIT_ASSERT(abs(xSize.Width - 17000) <= 6);
805 CPPUNIT_TEST_FIXTURE(Test, testBtlrFrame)
807 loadAndReload("btlr-frame.odt");
808 CPPUNIT_ASSERT_EQUAL(1, getShapes());
809 CPPUNIT_ASSERT_EQUAL(1, getPages());
810 if (!isExported())
812 return;
815 // Without the accompanying fix in place, this test would have failed with a
816 // beans.UnknownPropertyException, as the writing direction was lost, so the default direction
817 // resulted in a conversion to a Writer text frame.
818 uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY);
819 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(9000), getProperty<sal_Int32>(xFrame, "RotateAngle"));
822 DECLARE_WW8EXPORT_TEST(testPresetDash, "tdf127166_prstDash_Word97.doc")
824 // Error was, that the 'sys' preset dash styles were neither imported not
825 // exported, the mixed styles had wrong dash-dot order, they were imported
826 // with absolute values.
827 const drawing::LineDash dashParams[] =
829 {drawing::DashStyle_RECTRELATIVE, 1, 400, 0, 0, 300}, // dash
830 {drawing::DashStyle_RECTRELATIVE, 1, 400, 1, 100, 300}, // dashDot
831 {drawing::DashStyle_RECTRELATIVE, 1, 100, 0, 0, 300}, // dot
832 {drawing::DashStyle_RECTRELATIVE, 1, 800, 0, 0, 300}, // lgDash
833 {drawing::DashStyle_RECTRELATIVE, 1, 800, 1, 100, 300}, // lgDashDot
834 {drawing::DashStyle_RECTRELATIVE, 1, 800, 2, 100, 300}, // lgDashDotDot
835 {drawing::DashStyle_RECTRELATIVE, 1, 300, 0, 0, 100}, // sysDash
836 {drawing::DashStyle_RECTRELATIVE, 1, 300, 1, 100, 100}, // sysDashDot
837 {drawing::DashStyle_RECTRELATIVE, 1, 300, 2, 100, 100}, // sysDashDotDot
838 {drawing::DashStyle_RECTRELATIVE, 1, 100, 0, 0, 100} // sysDot
840 drawing::LineDash aPresetLineDash;
841 drawing::LineDash aShapeLineDash;
842 for (sal_uInt16 i = 0; i < 10; i++)
844 aPresetLineDash = dashParams[i];
845 uno::Reference<drawing::XShape> xShape = getShape(i+1);
846 aShapeLineDash = getProperty<drawing::LineDash>(xShape, "LineDash");
847 bool bIsEqual = aPresetLineDash.Style == aShapeLineDash.Style
848 && aPresetLineDash.Dots == aShapeLineDash.Dots
849 && aPresetLineDash.DotLen == aShapeLineDash.DotLen
850 && aPresetLineDash.Dashes == aShapeLineDash.Dashes
851 && aPresetLineDash.DashLen == aShapeLineDash.DashLen
852 && aPresetLineDash.Distance == aShapeLineDash.Distance;
853 CPPUNIT_ASSERT_MESSAGE("LineDash differ", bIsEqual);
856 const auto& pLayout = parseLayoutDump();
857 // Ensure that there is no tabstop in the first paragraph (despite chapter numbering's setting)
858 // This is a pre-emptive test to ensure something visibly correct is not broken.
859 assertXPath(pLayout, "//body/txt[1]//SwFixPortion", 0);
862 CPPUNIT_TEST_FIXTURE(Test, testRtlGutter)
864 auto verify = [this]() {
865 uno::Reference<beans::XPropertySet> xStandard(
866 getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
867 CPPUNIT_ASSERT(getProperty<bool>(xStandard, "RtlGutter"));
870 // Given a document with RTL gutter, when loading it:
871 createSwDoc("rtl-gutter.doc");
872 // Then make sure the section's gutter is still RTL:
873 // Without the accompanying fix in place, this test would have failed as the SPRM was missing.
874 verify();
875 saveAndReload("MS Word 97");
876 verify();
879 DECLARE_WW8EXPORT_TEST(testTdf94326_notOutlineNumbering, "tdf94326_notOutlineNumbering.doc")
881 // The directly applied numbering list must not be lost.
882 uno::Reference<beans::XPropertySet> xPara(getParagraph(2, u"ОБЩИЕ ПОЛОЖЕНИЯ"), uno::UNO_QUERY);
883 CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(xPara, "ListLabelString"));
886 DECLARE_WW8EXPORT_TEST(testTdf106541_cancelOutline, "tdf106541_cancelOutline.doc")
888 // The ability to cancel numbering must not be lost.
889 uno::Reference<beans::XPropertySet> xPara(getParagraph(1, "Cancelled by style"), uno::UNO_QUERY);
890 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
891 xPara.set(getParagraph(2, "Cancelled by inherited style"), uno::UNO_QUERY);
892 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
893 xPara.set(getParagraph(4, "Cancelled by direct paragraph formatting"), uno::UNO_QUERY);
894 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
897 DECLARE_WW8EXPORT_TEST(testTdf104239_chapterNumbering, "tdf104239_chapterNumbering.doc")
899 uno::Reference<text::XChapterNumberingSupplier> xNumberingSupplier(mxComponent, uno::UNO_QUERY);
900 uno::Reference<container::XIndexAccess> xNumberingRules = xNumberingSupplier->getChapterNumberingRules();
902 comphelper::SequenceAsHashMap hashMap(xNumberingRules->getByIndex(0));
903 CPPUNIT_ASSERT(hashMap["HeadingStyleName"].get<OUString>().match("Heading 1"));
904 sal_uInt16 nNumberingType = style::NumberingType::CHARS_UPPER_LETTER_N;
905 CPPUNIT_ASSERT_EQUAL(nNumberingType, hashMap["NumberingType"].get<sal_uInt16>());
907 hashMap = xNumberingRules->getByIndex(5);
908 CPPUNIT_ASSERT(hashMap["HeadingStyleName"].get<OUString>().match("Heading 6"));
909 nNumberingType = style::NumberingType::ARABIC;
910 CPPUNIT_ASSERT_EQUAL(nNumberingType, hashMap["NumberingType"].get<sal_uInt16>());
913 DECLARE_WW8EXPORT_TEST(testTdf106541_inheritChapterNumbering, "tdf106541_inheritChapterNumbering.doc")
915 // The level and numbering are inherited from Heading 1.
916 uno::Reference<beans::XPropertySet> xPara(getParagraph(3, "Letter A"), uno::UNO_QUERY);
917 CPPUNIT_ASSERT_EQUAL(OUString("a."), getProperty<OUString>(xPara, "ListLabelString"));
920 DECLARE_WW8EXPORT_TEST(testTdf106541_inheritChapterNumberingB, "tdf106541_inheritChapterNumberingB.doc")
922 // The level and numbering are inherited from Heading 1.
923 uno::Reference<beans::XPropertySet> xPara(getParagraph(1, "Chapter 1, level 1"), uno::UNO_QUERY);
924 CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty<OUString>(xPara, "ListLabelString"));
925 xPara.set(getParagraph(2, "Chapter 1, level 2"), uno::UNO_QUERY);
926 CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty<OUString>(xPara, "ListLabelString"));
929 DECLARE_WW8EXPORT_TEST(testTdf75748_inheritChapterNumberingC, "tdf75748_inheritChapterNumberingC.doc")
931 uno::Reference<beans::XPropertySet> xPara(getParagraph(5, "Inherited from Heading 3"), uno::UNO_QUERY);
932 CPPUNIT_ASSERT_EQUAL(OUString("II.B.1."), getProperty<OUString>(xPara, "ListLabelString"));
935 DECLARE_WW8EXPORT_TEST(testTdf104239_numbering, "tdf104239_numbering.doc")
937 // The paragraph starts with "paraksta Pieņemšanas". [Roundtrip by Word 2016 avoids the problem.]
938 uno::Reference<beans::XPropertySet> xPara(getParagraph(51), uno::UNO_QUERY);
939 CPPUNIT_ASSERT_EQUAL(OUString("3.3.1."), getProperty<OUString>(xPara, "ListLabelString"));
942 DECLARE_WW8EXPORT_TEST(testTdf104239_chapterNumberingLevels, "tdf104239_chapterNumberingLevels.doc")
944 uno::Reference<beans::XPropertySet> xPara(getParagraph(1, "Heading 1"), uno::UNO_QUERY);
945 CPPUNIT_ASSERT_EQUAL(OUString("Article I."), getProperty<OUString>(xPara, "ListLabelString"));
946 xPara.set(getParagraph(2, "Heading 2"), uno::UNO_QUERY);
947 CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty<OUString>(xPara, "ListLabelString"));
948 xPara.set(getParagraph(3, "Heading 3"), uno::UNO_QUERY);
949 CPPUNIT_ASSERT_EQUAL(OUString("First"), getProperty<OUString>(xPara, "ListLabelString"));
950 xPara.set(getParagraph(4, "Heading 4"), uno::UNO_QUERY);
951 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
952 xPara.set(getParagraph(8, "Heading 9"), uno::UNO_QUERY);
953 CPPUNIT_ASSERT_EQUAL(OUString("1.1.1.1.1.1.1.1.1."), getProperty<OUString>(xPara, "ListLabelString"));
956 DECLARE_WW8EXPORT_TEST(testTdf104239_chapterNumberTortureTest, "tdf104239_chapterNumberTortureTest.doc")
958 // There is no point in identifying what the wrong values where in this test,
959 //because EVERYTHING was wrong, and MANY different fixes are required to solve the problems.
960 uno::Reference<beans::XPropertySet> xPara(getParagraph(1, "No numId in style or paragraph"), uno::UNO_QUERY);
961 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
962 xPara.set(getParagraph(2, "Paragraph cancels numbering(0)"), uno::UNO_QUERY);
963 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
964 xPara.set(getParagraph(3, "First numbered line"), uno::UNO_QUERY);
965 CPPUNIT_ASSERT_EQUAL(OUString("1st.i.a.1.I"), getProperty<OUString>(xPara, "ListLabelString"));
966 xPara.set(getParagraph(7, "inheritOnly: inherit outlineLvl and listLvl."), uno::UNO_QUERY);
967 CPPUNIT_ASSERT_EQUAL(OUString("2nd.ii"), getProperty<OUString>(xPara, "ListLabelString"));
968 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty<sal_Int16>(xPara, "NumberingLevel")); // Level 2
969 xPara.set(getParagraph(9, "outline with Body listLvl(9)."), uno::UNO_QUERY);
970 if (!isExported())
971 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
972 xPara.set(getParagraph(10, "outline with Body listLvl(9) #2."), uno::UNO_QUERY);
973 if (!isExported())
974 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
975 xPara.set(getParagraph(11, "direct formatting - Body listLvl(9)."), uno::UNO_QUERY);
976 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
977 xPara.set(getParagraph(12, "direct numId, inherit listLvl."), uno::UNO_QUERY);
978 CPPUNIT_ASSERT_EQUAL(OUString("2nd.ii.a.1.I"), getProperty<OUString>(xPara, "ListLabelString"));
979 CPPUNIT_ASSERT_EQUAL(sal_Int16(4), getProperty<sal_Int16>(xPara, "NumberingLevel")); // Level 5
980 xPara.set(getParagraph(13, "Style numId0 cancels inherited numbering."), uno::UNO_QUERY);
981 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
984 DECLARE_WW8EXPORT_TEST(testTdf106541_inheritOutlineNumbering, "tdf106541_inheritOutlineNumbering.doc")
986 // The level and numbering are inherited from Level2.
987 uno::Reference<beans::XPropertySet> xPara(getParagraph(2, "This should be a sub-point."), uno::UNO_QUERY);
988 CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty<OUString>(xPara, "ListLabelString"));
991 DECLARE_WW8EXPORT_TEST(testTdf104239_sharedOutlineNumId, "tdf104239_sharedOutlineNumId.doc")
993 uno::Reference<beans::XPropertySet> xPara(getParagraph(5, "Principes"), uno::UNO_QUERY);
994 // This was ".1." previously.
995 CPPUNIT_ASSERT_EQUAL(OUString("2.1."), getProperty<OUString>(xPara, "ListLabelString"));
998 DECLARE_WW8EXPORT_TEST(testTdf120394, "tdf120394.doc")
1000 CPPUNIT_ASSERT_EQUAL(1, getPages());
1002 uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
1003 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, "NumberingLevel"));
1004 CPPUNIT_ASSERT_EQUAL(OUString("1.1.1"), getProperty<OUString>(xPara, "ListLabelString"));
1007 uno::Reference<beans::XPropertySet> xPara(getParagraph(5), uno::UNO_QUERY);
1008 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), getProperty<sal_Int16>(xPara, "NumberingLevel"));
1009 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
1012 uno::Reference<beans::XPropertySet> xPara(getParagraph(8), uno::UNO_QUERY);
1013 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, "NumberingLevel"));
1014 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
1017 uno::Reference<beans::XPropertySet> xPara(getParagraph(9), uno::UNO_QUERY);
1018 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, "NumberingLevel"));
1019 CPPUNIT_ASSERT_EQUAL(OUString("1.1.2"), getProperty<OUString>(xPara, "ListLabelString"));
1022 uno::Reference<beans::XPropertySet> xPara(getParagraph(10), uno::UNO_QUERY);
1023 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, "NumberingLevel"));
1024 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
1028 DECLARE_WW8EXPORT_TEST(testTdf142760, "tdf142760.doc")
1030 // Without the fix in place, this test would have failed with
1031 // - Expected: 2
1032 // - Actual : 6
1033 CPPUNIT_ASSERT_EQUAL(2, getPages());
1034 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1036 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1037 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1038 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
1041 DECLARE_WW8EXPORT_TEST(testTdf134570, "tdf134570.doc")
1043 CPPUNIT_ASSERT_EQUAL(1, getPages());
1044 uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
1045 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), getProperty<sal_Int16>(xPara, "NumberingLevel"));
1046 CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty<OUString>(xPara, "ListLabelString"));
1049 CPPUNIT_TEST_FIXTURE(Test, testTdf136814)
1051 loadAndReload("tdf136814.odt");
1052 CPPUNIT_ASSERT_EQUAL(1, getPages());
1053 uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
1054 sal_Int32 nBorderDistance = static_cast<sal_Int32>(106);
1056 CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, "TopBorderDistance"));
1057 CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, "RightBorderDistance"));
1058 CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, "BottomBorderDistance"));
1059 CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, "LeftBorderDistance"));
1062 CPPUNIT_TEST_FIXTURE(Test, testTdf79186_noLayoutInCell)
1064 loadAndReload("tdf79186_noLayoutInCell.odt");
1065 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1066 CPPUNIT_ASSERT_EQUAL(1, getPages());
1068 CPPUNIT_ASSERT(!getProperty<bool>(getShape(1), "IsFollowingTextFlow"));
1069 CPPUNIT_ASSERT(getProperty<bool>(getShape(1), "SurroundContour")); // tdf#140508
1072 CPPUNIT_TEST_FIXTURE(Test, testClearingBreak)
1074 auto verify = [this]() {
1075 uno::Reference<container::XEnumerationAccess> xParagraph(getParagraph(1), uno::UNO_QUERY);
1076 uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration();
1077 xPortions->nextElement();
1078 xPortions->nextElement();
1079 // Without the accompanying fix in place, this test would have failed with:
1080 // An uncaught exception of type com.sun.star.container.NoSuchElementException
1081 // i.e. the first para was just a fly + text portion, the clearing break was lost.
1082 uno::Reference<beans::XPropertySet> xPortion(xPortions->nextElement(), uno::UNO_QUERY);
1083 OUString aPortionType;
1084 xPortion->getPropertyValue("TextPortionType") >>= aPortionType;
1085 CPPUNIT_ASSERT_EQUAL(OUString("LineBreak"), aPortionType);
1086 uno::Reference<text::XTextContent> xLineBreak;
1087 xPortion->getPropertyValue("LineBreak") >>= xLineBreak;
1088 sal_Int16 eClear{};
1089 uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY);
1090 xLineBreakProps->getPropertyValue("Clear") >>= eClear;
1091 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(SwLineBreakClear::ALL), eClear);
1094 // Given a document with a clearing break:
1095 // When loading that file:
1096 createSwDoc("clearing-break.doc");
1097 // Then make sure that the clear property of the break is not ignored:
1098 verify();
1099 saveAndReload("MS Word 97");
1100 // Make sure that the clear property of the break is not ignored during export:
1101 verify();
1104 CPPUNIT_TEST_FIXTURE(Test, testTdf142840)
1106 loadAndReload("tdf142840.odt");
1107 CPPUNIT_ASSERT_EQUAL(1, getPages());
1109 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
1110 uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
1111 uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
1113 // Ensure space are replaced by underscore in bookmark name (it was working before, but ensure this)
1114 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xBookmarksByIdx->getCount());
1115 CPPUNIT_ASSERT(xBookmarksByName->hasByName("Chapter_1"));
1116 CPPUNIT_ASSERT(!xBookmarksByName->hasByName("Chapter 1"));
1118 // And hyperlink is referring bookmark with underscore also (this was broken)
1119 CPPUNIT_ASSERT_EQUAL(OUString("#Chapter_1"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL"));
1122 CPPUNIT_PLUGIN_IMPLEMENT();
1124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */