update emoji autocorrect entries from po-files
[LibreOffice.git] / sw / qa / extras / ww8export / ww8export.cxx
blobcdf6d14f361a7058defeaac6163c317152ae8030
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/form/validation/XValidatableFormComponent.hpp>
13 #include <com/sun/star/frame/XStorable.hpp>
14 #include <com/sun/star/drawing/XControlShape.hpp>
15 #include <com/sun/star/beans/XPropertySet.hpp>
16 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
17 #include <com/sun/star/table/ShadowFormat.hpp>
18 #include <com/sun/star/table/TableBorder2.hpp>
19 #include <com/sun/star/text/GraphicCrop.hpp>
20 #include <com/sun/star/text/XFormField.hpp>
21 #include <com/sun/star/view/DocumentZoomType.hpp>
23 class Test : public SwModelTestBase
25 public:
26 Test() : SwModelTestBase("/sw/qa/extras/ww8export/data/", "MS Word 97") {}
28 bool mustTestImportOf(const char* filename) const SAL_OVERRIDE
30 // If the testcase is stored in some other format, it's pointless to test.
31 return OString(filename).endsWith(".doc");
33 protected:
34 bool CjkNumberedListTestHelper(sal_Int16 &nValue)
36 bool isNumber = false;
37 uno::Reference<text::XTextRange> xPara(getParagraph(1));
38 uno::Reference< beans::XPropertySet > properties( xPara, uno::UNO_QUERY);
39 properties->getPropertyValue("NumberingIsNumber") >>= isNumber;
40 if (!isNumber)
41 return false;
42 uno::Reference<container::XIndexAccess> xLevels( properties->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
43 uno::Sequence< beans::PropertyValue > aPropertyValue;
44 xLevels->getByIndex(0) >>= aPropertyValue;
45 for( int j = 0 ; j< aPropertyValue.getLength() ; ++j)
47 beans::PropertyValue aProp= aPropertyValue[j];
48 if (aProp.Name == "NumberingType")
50 nValue = aProp.Value.get<sal_Int16>();
51 return true;
54 return false;
58 DECLARE_WW8EXPORT_TEST(testN325936, "n325936.doc")
61 * The problem was that the transparent background of the drawing in the
62 * header was exported as non-transparent.
64 * xray ThisComponent.DrawPage(0).BackColorTransparency
67 uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
68 sal_Int32 nValue = getProperty< sal_Int32 >(getShape(1), "BackColorTransparency");
69 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), nValue);
72 DECLARE_WW8EXPORT_TEST(testFdo45724, "fdo45724.odt")
74 // The text and background color of the control shape was not correct.
75 uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
76 uno::Reference<form::validation::XValidatableFormComponent> xComponent(xControlShape->getControl(), uno::UNO_QUERY);
77 CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<sal_uInt32>(xComponent, "BackgroundColor"));
78 CPPUNIT_ASSERT_EQUAL(OUString("xxx"), xComponent->getCurrentValue().get<OUString>());
81 DECLARE_WW8EXPORT_TEST(testFdo46020, "fdo46020.odt")
83 // The footnote in that document wasn't exported, check that it is actually exported
84 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
85 uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
86 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
89 DECLARE_WW8EXPORT_TEST(testFirstHeaderFooter, "first-header-footer.doc")
91 // Test import and export of a section's headerf/footerf properties.
93 // The document has 6 pages. Note that we don't test if 4 or just 2 page
94 // styles are created, the point is that layout should be correct.
95 CPPUNIT_ASSERT_EQUAL(OUString("First page header"), parseDump("/root/page[1]/header/txt/text()"));
96 CPPUNIT_ASSERT_EQUAL(OUString("First page footer"), parseDump("/root/page[1]/footer/txt/text()"));
97 CPPUNIT_ASSERT_EQUAL(OUString("Even page header"), parseDump("/root/page[2]/header/txt/text()"));
98 CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"), parseDump("/root/page[2]/footer/txt/text()"));
99 CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"), parseDump("/root/page[3]/header/txt/text()"));
100 CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"), parseDump("/root/page[3]/footer/txt/text()"));
101 CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), parseDump("/root/page[4]/header/txt/text()"));
102 CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), parseDump("/root/page[4]/footer/txt/text()"));
103 CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), parseDump("/root/page[5]/header/txt/text()"));
104 CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), parseDump("/root/page[5]/footer/txt/text()"));
105 CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"), parseDump("/root/page[6]/header/txt/text()"));
106 CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"), parseDump("/root/page[6]/footer/txt/text()"));
109 DECLARE_WW8EXPORT_TEST(testZoom, "zoom.doc")
111 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
112 uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
113 uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings());
114 sal_Int16 nValue = 0;
115 xPropertySet->getPropertyValue("ZoomValue") >>= nValue;
116 CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue);
119 DECLARE_WW8EXPORT_TEST(testZoomType, "zoomtype.doc")
121 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
122 uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
123 uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings());
124 sal_Int16 nValue = 0;
125 xPropertySet->getPropertyValue("ZoomType") >>= nValue;
126 CPPUNIT_ASSERT_EQUAL(sal_Int16(view::DocumentZoomType::PAGE_WIDTH), nValue);
129 DECLARE_WW8EXPORT_TEST(test56513, "fdo56513.doc")
131 CPPUNIT_ASSERT_EQUAL(OUString("This is the header of the first section"), parseDump("/root/page[1]/header/txt/text()"));
132 CPPUNIT_ASSERT_EQUAL(OUString("This is the first page header of the second section"), parseDump("/root/page[2]/header/txt/text()"));
133 CPPUNIT_ASSERT_EQUAL(OUString("This is the non-first-page header of the second section"), parseDump("/root/page[3]/header/txt/text()"));
136 DECLARE_WW8EXPORT_TEST(testNewPageStylesTable, "new-page-styles.doc")
138 CPPUNIT_ASSERT_EQUAL(OUString("Sigma Space Performance Goals and Results (Page 1)*"), parseDump("/root/page[1]/header/txt/text()"));
139 CPPUNIT_ASSERT_EQUAL(OUString("Sigma Space Performance Assessment (Page 2)****"), parseDump("/root/page[2]/header/txt/text()"));
140 CPPUNIT_ASSERT_EQUAL(OUString("Sigma Space Performance Goals: Next Year (Page 3)*******"), parseDump("/root/page[3]/header/txt/text()"));
143 DECLARE_WW8EXPORT_TEST(testFdo42144, "fdo42144.odt")
145 // Footer wasn't disabled -- instead empty footer was exported.
146 uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
147 CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(xStyle, "FooterIsOn")));
150 DECLARE_WW8EXPORT_TEST(testCharacterBorder, "charborder.odt")
152 uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
153 // WW8 has just one border attribute (sprmCBrc) for text border so all side has
154 // the same border
155 // Border
157 const table::BorderLine2 aTopBorder = getProperty<table::BorderLine2>(xRun,"CharTopBorder");
158 CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF3333,0,318,0,0,318), aTopBorder);
159 CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharLeftBorder"));
160 CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharBottomBorder"));
161 CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharRightBorder"));
164 // Padding (dptSpace) it is constant 0
166 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,"CharTopBorderDistance"));
167 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,"CharLeftBorderDistance"));
168 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,"CharBottomBorderDistance"));
169 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,"CharRightBorderDistance"));
172 // Shadow (fShadow)
173 /* WW8 use just one bool value for shadow so the next conversions
174 are made during an export-import round
175 color: any -> black
176 location: any -> bottom-right
177 width: any -> border width */
179 const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
180 CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
181 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
182 CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth);
186 DECLARE_WW8EXPORT_TEST(testFdo77454, "fdo77454.doc")
189 // check negative crops round-trip
190 text::GraphicCrop const crop =
191 getProperty<text::GraphicCrop>(getShape(1), "GraphicCrop");
192 CPPUNIT_ASSERT_EQUAL(sal_Int32( -439), crop.Left);
193 CPPUNIT_ASSERT_EQUAL(sal_Int32(-7040), crop.Right);
194 CPPUNIT_ASSERT_EQUAL(sal_Int32( -220), crop.Top);
195 CPPUNIT_ASSERT_EQUAL(sal_Int32(-7040), crop.Bottom);
199 // check positive crops round-trip
200 text::GraphicCrop const crop =
201 getProperty<text::GraphicCrop>(getShape(2), "GraphicCrop");
202 CPPUNIT_ASSERT_EQUAL(sal_Int32( 326), crop.Left);
203 CPPUNIT_ASSERT_EQUAL(sal_Int32( 1208), crop.Right);
204 CPPUNIT_ASSERT(abs(sal_Int32(1635) - crop.Top) <= 2);
205 CPPUNIT_ASSERT(abs(sal_Int32( 95) - crop.Bottom) <= 2);
209 DECLARE_WW8EXPORT_TEST(testFdo59530, "fdo59530.doc")
211 // See ooxmlexport's testFdo38244().
212 // Test comment range feature.
213 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
214 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
215 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
216 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
217 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
218 xRunEnum->nextElement();
219 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
220 CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(xPropertySet, "TextPortionType"));
221 xRunEnum->nextElement();
222 xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
223 CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
225 // Test initials.
226 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
227 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
228 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
229 xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
230 CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
232 // Test commented text range which spans over more text nodes
233 // Comment starts in the second paragraph
234 xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
235 xRunEnum = xRunEnumAccess->createEnumeration();
236 xRunEnum->nextElement();
237 xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
238 CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(xPropertySet, "TextPortionType"));
239 // Comment ends in the third paragraph
240 xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
241 xRunEnum = xRunEnumAccess->createEnumeration();
242 xRunEnum->nextElement();
243 xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
244 CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
247 DECLARE_WW8EXPORT_TEST(testCommentsNested, "comments-nested.doc")
249 uno::Reference<beans::XPropertySet> xOuter(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField"), uno::UNO_QUERY);
250 CPPUNIT_ASSERT_EQUAL(OUString("Outer"), getProperty<OUString>(xOuter, "Content"));
252 uno::Reference<beans::XPropertySet> xInner(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 4), "TextField"), uno::UNO_QUERY);
253 CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content"));
256 DECLARE_WW8EXPORT_TEST(testBorderColoursExport, "bordercolours.odt")
258 // This is very close to testBorderColours in ww8import.cxx, but for export
260 // The following 6 colours can only be represented with WW9 (Word 2000)
261 // BRC (BoRder Control) structures. We can tell that they have been
262 // exported/imported using a WW8 (Word '97) BRC if they instead come
263 // through as one of the 16 colours listed at this link:
264 // http://msdn.microsoft.com/en-us/library/dd773060.aspx
265 table::BorderLine2 expectedTop(0xFA670C, 0, 53, 0, 1, 53);
266 table::BorderLine2 expectedLeft(0xD99594, 0, 79, 0, 0, 79);
267 table::BorderLine2 expectedRight(0xB2A1C7, 53, 53, 53, 3, 159);
268 table::BorderLine2 expectedBottom(0xB6DDE8, 0, 106, 0, 14, 106);
269 table::BorderLine2 expectedDashedRed(0xFA670C, 0, 53, 0, 2, 53);
270 table::BorderLine2 expectedDoubleGreen(0xC2D69B, 26, 106, 26, 4, 159);
272 // Paragraph border
273 uno::Reference<text::XBookmarksSupplier> bookmarksSupplier(mxComponent,
274 uno::UNO_QUERY);
275 uno::Reference<container::XNameAccess> bookmarks(
276 bookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
277 uno::Reference<text::XTextContent> bookmark(
278 bookmarks->getByName("ParagraphBorder"), uno::UNO_QUERY);
279 uno::Reference<text::XTextRange> anchor(bookmark->getAnchor());
280 table::BorderLine2 border;
281 border = getProperty<table::BorderLine2>(anchor, "TopBorder");
282 CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
283 border = getProperty<table::BorderLine2>(anchor, "LeftBorder");
284 CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
285 border = getProperty<table::BorderLine2>(anchor, "RightBorder");
286 CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
287 border = getProperty<table::BorderLine2>(anchor, "BottomBorder");
288 CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
290 // Page border
291 OUString pageStyleName = getProperty<OUString>(anchor, "PageStyleName");
292 uno::Reference<style::XStyle> pageStyle(
293 getStyles("PageStyles")->getByName(pageStyleName), uno::UNO_QUERY);
294 border = getProperty<table::BorderLine2>(pageStyle, "TopBorder");
295 CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
296 border = getProperty<table::BorderLine2>(pageStyle, "LeftBorder");
297 CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
298 border = getProperty<table::BorderLine2>(pageStyle, "RightBorder");
299 CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
300 border = getProperty<table::BorderLine2>(pageStyle, "BottomBorder");
301 CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
303 // Character border
304 bookmark.set(bookmarks->getByName("CharBorder"), uno::UNO_QUERY);
305 anchor = bookmark->getAnchor();
306 border = getProperty<table::BorderLine2>(anchor, "CharTopBorder");
307 CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
308 border = getProperty<table::BorderLine2>(anchor, "CharLeftBorder");
309 CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
310 border = getProperty<table::BorderLine2>(anchor, "CharRightBorder");
311 CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
312 border = getProperty<table::BorderLine2>(anchor, "CharBottomBorder");
313 CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
315 // Table border
316 uno::Reference<text::XTextTablesSupplier> tablesSupplier(mxComponent,
317 uno::UNO_QUERY);
318 uno::Reference<container::XNameAccess> tables(
319 tablesSupplier->getTextTables(), uno::UNO_QUERY);
320 uno::Reference<text::XTextTable> table(
321 tables->getByName("Table1"), uno::UNO_QUERY);
322 table::TableBorder2 tableBorder = getProperty<table::TableBorder2>(
323 table, "TableBorder2");
324 CPPUNIT_ASSERT_EQUAL(expectedTop.Color, tableBorder.TopLine.Color);
325 CPPUNIT_ASSERT_EQUAL(expectedLeft.Color, tableBorder.LeftLine.Color);
326 CPPUNIT_ASSERT_EQUAL(expectedRight.Color, tableBorder.RightLine.Color);
327 #if 0
328 // #if'd out because the "fine dashed" border line style for table borders
329 // does not seem to save or load correctly in odt format at present
330 CPPUNIT_ASSERT_EQUAL(expectedBottom.Color, tableBorder.BottomLine.Color);
331 #endif
333 // Table cells
334 uno::Reference<table::XCell> cell(
335 table->getCellByName("A2"), uno::UNO_QUERY);
336 border = getProperty<table::BorderLine2>(cell, "TopBorder");
337 CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
338 border = getProperty<table::BorderLine2>(cell, "LeftBorder");
339 CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
340 border = getProperty<table::BorderLine2>(cell, "BottomBorder");
341 #if 0
342 // #if'd out because the "fine dashed" border line style for table borders
343 // does not seem to save or load correctly in odt format at present
344 CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
345 #endif
347 cell.set(table->getCellByName("B2"), uno::UNO_QUERY);
348 border = getProperty<table::BorderLine2>(cell, "TopBorder");
349 CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
350 border = getProperty<table::BorderLine2>(cell, "LeftBorder");
351 CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
352 border = getProperty<table::BorderLine2>(cell, "BottomBorder");
353 CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
355 cell.set(table->getCellByName("C2"), uno::UNO_QUERY);
356 border = getProperty<table::BorderLine2>(cell, "TopBorder");
357 CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
358 border = getProperty<table::BorderLine2>(cell, "LeftBorder");
359 CPPUNIT_ASSERT_BORDER_EQUAL(expectedDashedRed, border);
360 border = getProperty<table::BorderLine2>(cell, "RightBorder");
361 CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
362 border = getProperty<table::BorderLine2>(cell, "BottomBorder");
363 CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
365 // Picture border
366 // (#if'd out as they are not yet exported with correct colours)
367 #if 0
368 bookmark.set(bookmarks->getByName("PictureBorder"),uno::UNO_QUERY);
369 anchor = bookmark->getAnchor();
370 border = getProperty<table::BorderLine2>(anchor, "TopBorder");
371 CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
372 border = getProperty<table::BorderLine2>(anchor, "LeftBorder");
373 CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
374 border = getProperty<table::BorderLine2>(anchor, "RightBorder");
375 CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
376 border = getProperty<table::BorderLine2>(anchor, "BottomBorder");
377 CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
378 #endif
381 DECLARE_WW8EXPORT_TEST(testRedlineExport1, "redline-export-1.odt")
383 uno::Reference<text::XTextRange> xParagraph = getParagraph(1);
384 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
385 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
386 //there must be no redline information on the first line before and after reloading
387 while (xRunEnum->hasMoreElements())
389 uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
390 CPPUNIT_ASSERT_EQUAL(false, hasProperty(xRun, "RedlineType"));
394 DECLARE_WW8EXPORT_TEST(testRedlineExport2, "redline-export-2.odt")
396 //there must be redline information on the first portion of the third paragraph before and after reloading
397 CPPUNIT_ASSERT_EQUAL(true, hasProperty(getRun(getParagraph(3), 1), "RedlineType"));
400 DECLARE_WW8EXPORT_TEST(testRedlineExport3, "redline-export-3.odt")
402 //there must be redline information just on the para-break boundary between para one and two
403 CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(getParagraph(1), 1), "RedlineType"));
404 CPPUNIT_ASSERT_EQUAL(true, hasProperty(getRun(getParagraph(1), 2), "RedlineType"));
405 CPPUNIT_ASSERT_EQUAL(true, hasProperty(getRun(getParagraph(2), 1), "RedlineType"));
406 CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(getParagraph(2), 2), "RedlineType"));
409 DECLARE_WW8EXPORT_TEST(testCellBgColor, "cell-bg-color.odt")
411 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
412 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
413 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
414 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xCC0000), getProperty<sal_Int32>(xTable->getCellByName("A1"), "BackColor"));
417 DECLARE_WW8EXPORT_TEST(testBnc636128, "bnc636128.doc")
419 // Import / export of FFData.cch was missing.
420 uno::Reference<text::XFormField> xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(1), 2), "Bookmark");
421 uno::Reference<container::XNameContainer> xParameters = xFormField->getParameters();
422 // This resulted in a container.NoSuchElementException.
423 CPPUNIT_ASSERT_EQUAL(OUString("5"), xParameters->getByName("MaxLength").get<OUString>());
427 DECLARE_WW8EXPORT_TEST(testWw8Cjklist30, "cjklist30.doc")
429 sal_Int16 numFormat;
430 CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
431 CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH, numFormat);
434 DECLARE_WW8EXPORT_TEST(testWw8Cjklist31, "cjklist31.doc")
436 sal_Int16 numFormat;
437 CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
438 CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat);
441 DECLARE_WW8EXPORT_TEST(testWw8Cjklist34, "cjklist34.doc")
443 sal_Int16 numFormat;
444 CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
445 CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW, numFormat);
448 DECLARE_WW8EXPORT_TEST(testWw8Cjklist35, "cjklist35.doc")
450 sal_Int16 numFormat;
451 CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
452 CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_LOWER_ZH, numFormat);
455 DECLARE_WW8EXPORT_TEST(testTdf92281, "tdf92281.doc")
457 uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
458 CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty<OUString>(xRun, "CharFontName"));
459 CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty<OUString>(xRun, "CharFontNameAsian"));
460 CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty<OUString>(xRun, "CharFontNameComplex"));
463 DECLARE_WW8EXPORT_TEST(testCommentedTable, "commented-table.doc")
465 // Document has a non-trivial commented text range, as the range contains a table.
466 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
467 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
468 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
469 uno::Reference<text::XTextContent> xField(xFields->nextElement(), uno::UNO_QUERY);
470 // After first import, there was an off-by-one during import, so this was "efore.\nA1\nB1\nAfte". (Notice the additional "e" prefix.)
471 // After export and import, things got worse, this was "\nA1\nB1\nAfte".
472 CPPUNIT_ASSERT_EQUAL(OUString("fore." SAL_NEWLINE_STRING "A1" SAL_NEWLINE_STRING "B1" SAL_NEWLINE_STRING "Afte"), xField->getAnchor()->getString());
475 DECLARE_WW8EXPORT_TEST(testCommentExport, "comment-export.odt")
477 struct TextPortionInfo {
478 OUString sKind;
479 OUString sText;
480 int nAnnotationID;
483 const TextPortionInfo aTextPortions[] = {
484 {OUString("Annotation"), OUString("Comment on [A...A]"), 0},
485 {OUString("Text"), OUString("[A xx "), 0},
486 {OUString("Annotation"), OUString("Comment on [B...B]"), 1},
487 {OUString("Text"), OUString("[B x "), 0},
488 {OUString("Annotation"), OUString("Comment on [C..C]"), 2},
489 {OUString("Text"), OUString("[C x B]"), 0},
490 {OUString("AnnotationEnd"), OUString(""), 1},
491 {OUString("Text"), OUString(" x C]"), 0},
492 {OUString("AnnotationEnd"), OUString(""), 2},
493 {OUString("Text"), OUString(" xx A]"), 0},
494 {OUString("AnnotationEnd"), OUString(""), 0},
495 {OUString("Text"), OUString(" Comment on a point"), 0},
496 {OUString("Annotation"), OUString("Comment on point"), 3},
497 {OUString("Text"), OUString("x "), 0},
498 {OUString("Annotation"), OUString("Comment on AA...BB"), 4},
499 {OUString("Annotation"), OUString("Comment on AAAAAA"), 5},
500 {OUString("Text"), OUString("AAAAAA"), 0},
501 {OUString("AnnotationEnd"), OUString(""), 5},
502 {OUString("Text"), OUString(" BBBBBB"), 0},
503 {OUString("AnnotationEnd"), OUString(""), 4}
506 OUString sNames[6];
508 const int nNumberOfTextPortions = sizeof(aTextPortions) / (sizeof(TextPortionInfo));
510 uno::Reference<text::XTextRange> xPara = getParagraph(1);
512 for (int i = 0; i < nNumberOfTextPortions; ++i)
514 OUString sKind = aTextPortions[i].sKind;
515 uno::Reference<text::XTextRange> xRun(getRun(xPara, i + 1), uno::UNO_QUERY);
516 uno::Reference<beans::XPropertySet> xPropertySet(xRun, uno::UNO_QUERY);
517 CPPUNIT_ASSERT_EQUAL(sKind, getProperty<OUString>(xPropertySet, "TextPortionType"));
519 if (sKind == "Text")
521 // Check if textportion has the correct text
522 CPPUNIT_ASSERT_EQUAL(aTextPortions[i].sText, xRun->getString());
524 else if (sKind == "Annotation")
526 // Check if the comment text is correct and save the name of the comment
527 uno::Reference<beans::XPropertySet> xComment(getProperty< uno::Reference<beans::XPropertySet> >(xRun, "TextField"), uno::UNO_QUERY);
528 CPPUNIT_ASSERT_EQUAL(aTextPortions[i].sText, getProperty<OUString>(xComment, "Content"));
529 sNames[aTextPortions[i].nAnnotationID] = getProperty<OUString>(xComment, "Name");
531 else // if (sKind == OUString("AnnotationEnd"))
533 // Check if the correct Annotation ends here (by Name)
534 uno::Reference<container::XNamed> xBookmark(getProperty< uno::Reference<beans::XPropertySet> >(xRun, "Bookmark"), uno::UNO_QUERY);
535 CPPUNIT_ASSERT_EQUAL(sNames[aTextPortions[i].nAnnotationID], xBookmark->getName());
540 DECLARE_WW8EXPORT_TEST(testMoveRange, "fdo66304-1.odt")
542 //the save must survive without asserting
545 CPPUNIT_PLUGIN_IMPLEMENT();
547 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */