tdf#131234: RTF import: extend default char props list
[LibreOffice.git] / sw / qa / extras / rtfexport / rtfexport5.cxx
blobb9a7321d724bf00ba9b86b11db5176dfa8f4aa24
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 <memory>
11 #include <string_view>
12 #include <swmodeltestbase.hxx>
14 #include <com/sun/star/awt/FontWeight.hpp>
15 #include <com/sun/star/graphic/GraphicType.hpp>
16 #include <com/sun/star/style/LineSpacing.hpp>
17 #include <com/sun/star/style/LineSpacingMode.hpp>
18 #include <com/sun/star/style/ParagraphAdjust.hpp>
19 #include <com/sun/star/style/TabStop.hpp>
20 #include <com/sun/star/table/BorderLine2.hpp>
21 #include <com/sun/star/table/BorderLineStyle.hpp>
22 #include <com/sun/star/text/RelOrientation.hpp>
23 #include <com/sun/star/text/TableColumnSeparator.hpp>
24 #include <com/sun/star/text/TextContentAnchorType.hpp>
25 #include <com/sun/star/text/XFootnotesSupplier.hpp>
26 #include <com/sun/star/text/XPageCursor.hpp>
27 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
28 #include <com/sun/star/text/XTextTablesSupplier.hpp>
29 #include <com/sun/star/text/XTextFramesSupplier.hpp>
30 #include <com/sun/star/text/XTextTable.hpp>
31 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
32 #include <com/sun/star/text/WritingMode2.hpp>
33 #include <com/sun/star/graphic/XGraphic.hpp>
34 #include <com/sun/star/text/XTextContentAppend.hpp>
35 #include <com/sun/star/text/XTextDocument.hpp>
36 #include <com/sun/star/beans/XPropertyState.hpp>
37 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
38 #include <com/sun/star/awt/FontWeight.hpp>
39 #include <com/sun/star/awt/FontSlant.hpp>
40 #include <com/sun/star/awt/FontUnderline.hpp>
42 #include <rtl/ustring.hxx>
43 #include <tools/UnitConversion.hxx>
44 #include <vcl/svapp.hxx>
45 #include <vcl/settings.hxx>
46 #include <comphelper/sequenceashashmap.hxx>
47 #include <i18nlangtag/languagetag.hxx>
49 using namespace css;
51 class Test : public SwModelTestBase
53 public:
54 Test()
55 : SwModelTestBase("/sw/qa/extras/rtfexport/data/", "Rich Text Format")
59 virtual std::unique_ptr<Resetter> preTest(const char* filename) override
61 m_aSavedSettings = Application::GetSettings();
62 if (filename == std::string_view("fdo72031.rtf"))
64 std::unique_ptr<Resetter> pResetter(
65 new Resetter([this]() { Application::SetSettings(this->m_aSavedSettings); }));
66 AllSettings aSettings(m_aSavedSettings);
67 aSettings.SetLanguageTag(LanguageTag("ru"));
68 Application::SetSettings(aSettings);
69 return pResetter;
71 return nullptr;
74 protected:
75 /// Denylist handling.
76 bool mustTestImportOf(const char* filename) const override
78 // If the testcase is stored in some other format, it's pointless to
79 // test.
80 return OString(filename).endsWith(".rtf");
83 AllSettings m_aSavedSettings;
86 DECLARE_RTFEXPORT_TEST(testFdo63023, "fdo63023.rtf")
88 uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>(
89 getStyles("PageStyles")->getByName("Standard"), "HeaderText");
90 // Back color was black (0) in the header, due to missing color table in the substream.
91 CPPUNIT_ASSERT_EQUAL(
92 sal_Int32(0xFFFF99),
93 getProperty<sal_Int32>(getRun(getParagraphOfText(1, xHeaderText), 1), "CharBackColor"));
96 DECLARE_RTFEXPORT_TEST(testFdo42109, "fdo42109.rtf")
98 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
99 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
100 uno::UNO_QUERY);
101 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
102 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
103 // Make sure the page number is imported as a field in the B1 cell.
104 CPPUNIT_ASSERT_EQUAL(OUString("TextField"),
105 getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 1),
106 "TextPortionType"));
109 DECLARE_RTFEXPORT_TEST(testFdo62977, "fdo62977.rtf")
111 // The middle character was imported as '?' instead of the proper unicode value.
112 getRun(getParagraph(1), 1, OUString(u"\u5E74\uFF14\u6708"));
115 DECLARE_RTFEXPORT_TEST(testN818997, "n818997.rtf")
117 // \page was ignored between two \shp tokens.
118 CPPUNIT_ASSERT_EQUAL(2, getPages());
121 DECLARE_RTFEXPORT_TEST(testFdo64671, "fdo64671.rtf")
123 // Additional '}' was inserted before the special character.
124 getRun(getParagraph(1), 1, OUString(u"\u017D"));
127 CPPUNIT_TEST_FIXTURE(Test, testFdo62044)
129 load(mpTestDocumentPath, "fdo62044.rtf");
130 // The problem was that RTF import during copy&paste did not ignore existing paragraph styles.
131 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
132 uno::Reference<text::XTextRange> xText = xTextDocument->getText();
133 uno::Reference<text::XTextRange> xEnd = xText->getEnd();
134 paste(u"rtfexport/data/fdo62044-paste.rtf", xEnd);
136 uno::Reference<beans::XPropertySet> xPropertySet(
137 getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
138 CPPUNIT_ASSERT_EQUAL(
139 10.f, getProperty<float>(xPropertySet,
140 "CharHeight")); // Was 18, i.e. reset back to original value.
143 DECLARE_RTFEXPORT_TEST(testFdo70578, "fdo70578.rtf")
145 // Style without explicit \s0 was not imported as the default style
146 uno::Reference<beans::XPropertySet> xPropertySet(
147 getStyles("ParagraphStyles")->getByName("Subtitle"), uno::UNO_QUERY);
148 uno::Reference<style::XStyle> xStyle(xPropertySet, uno::UNO_QUERY);
149 CPPUNIT_ASSERT_EQUAL(OUString("Standard"), xStyle->getParentStyle());
150 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "ParaTopMargin"));
151 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
154 DECLARE_RTFEXPORT_TEST(testN825305, "n825305.rtf")
156 // The problem was that the textbox wasn't transparent, due to unimplemented fFilled == 0.
157 uno::Reference<beans::XPropertyState> xPropertyState(getShape(2), uno::UNO_QUERY);
158 CPPUNIT_ASSERT_EQUAL(sal_Int32(100),
159 getProperty<sal_Int32>(getShape(2), "BackColorTransparency"));
160 beans::PropertyState ePropertyState = xPropertyState->getPropertyState("BackColorTransparency");
161 // Was beans::PropertyState_DEFAULT_VALUE.
162 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState);
165 DECLARE_RTFEXPORT_TEST(testTdf106953, "tdf106953.rtf")
167 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270),
168 getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
169 auto xRules = getProperty<uno::Reference<container::XIndexAccess>>(
170 getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
171 comphelper::SequenceAsHashMap aRule(xRules->getByIndex(0));
172 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aRule["FirstLineIndent"].get<sal_Int32>());
175 DECLARE_RTFEXPORT_TEST(testTdf112208, "tdf112208_hangingIndent.rtf")
177 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-2000),
178 getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent"));
179 CPPUNIT_ASSERT_EQUAL(1, getPages());
182 DECLARE_RTFEXPORT_TEST(testParaBottomMargin, "para-bottom-margin.rtf")
184 uno::Reference<beans::XPropertySet> xPropertySet(
185 getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
186 CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
188 // This was 353, i.e. bottom margin of the paragraph was 0.35cm instead of 0.
189 // The reason why this is 0 despite the default style containing \sa200
190 // is that Word will actually interpret \sN (or \pard which apparently
191 // implies \s0) as "set style N and for every attribute of that style,
192 // set an attribute with default value on the paragraph"
193 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
194 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
197 CPPUNIT_TEST_FIXTURE(Test, testParaStyleBottomMargin2)
199 load(mpTestDocumentPath, "para-style-bottom-margin-2.rtf");
200 uno::Reference<beans::XPropertySet> xPropertySet(
201 getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
202 CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
203 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP,
204 getProperty<style::LineSpacing>(xPropertySet, "ParaLineSpacing").Mode);
205 CPPUNIT_ASSERT_EQUAL(sal_Int16(115),
206 getProperty<style::LineSpacing>(xPropertySet, "ParaLineSpacing").Height);
208 // the derived style contains \sa200, as does its parent
209 uno::Reference<beans::XPropertySet> xPropertySet1(
210 getStyles("ParagraphStyles")->getByName("List Paragraph"), uno::UNO_QUERY);
211 CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty<sal_Int32>(xPropertySet1, "ParaBottomMargin"));
212 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP,
213 getProperty<style::LineSpacing>(xPropertySet1, "ParaLineSpacing").Mode);
214 CPPUNIT_ASSERT_EQUAL(sal_Int16(115),
215 getProperty<style::LineSpacing>(xPropertySet1, "ParaLineSpacing").Height);
216 // for the paragraph there is no \saN, so it should default to 0
217 auto const xPara(getParagraph(1));
218 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaBottomMargin"));
219 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP,
220 getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Mode);
221 CPPUNIT_ASSERT_EQUAL(sal_Int16(115),
222 getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height);
225 DECLARE_RTFEXPORT_TEST(testFdo66040, "fdo66040.rtf")
227 // This was 0 (no shapes were imported), we want two textframes.
228 CPPUNIT_ASSERT_EQUAL(2, getShapes());
230 // The second paragraph of the first shape should be actually a table, with "A" in its A1 cell.
231 uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY);
232 uno::Reference<text::XText> xText = xTextRange->getText();
233 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
234 CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(
235 xTable->getCellByName("A1"), uno::UNO_QUERY_THROW)
236 ->getString());
238 // Make sure the second shape has the correct position and size.
239 uno::Reference<drawing::XShape> xShape(getShape(2), uno::UNO_QUERY);
240 CPPUNIT_ASSERT_EQUAL(sal_Int32(14420), getProperty<sal_Int32>(xShape, "HoriOrientPosition"));
241 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1032), getProperty<sal_Int32>(xShape, "VertOrientPosition"));
242 CPPUNIT_ASSERT_EQUAL(sal_Int32(14000), xShape->getSize().Width);
243 CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), xShape->getSize().Height);
246 DECLARE_RTFEXPORT_TEST(testFdo77996, "fdo77996.rtf")
248 // all styles were imported as name "0"
249 uno::Reference<container::XNameAccess> xChars(getStyles("CharacterStyles"));
250 CPPUNIT_ASSERT(!xChars->hasByName("0"));
251 CPPUNIT_ASSERT(xChars->hasByName("strong"));
252 CPPUNIT_ASSERT(xChars->hasByName("author"));
253 uno::Reference<container::XNameAccess> xParas(getStyles("ParagraphStyles"));
254 CPPUNIT_ASSERT(!xParas->hasByName("0"));
255 CPPUNIT_ASSERT(xParas->hasByName("extract2"));
256 // some document properties were lost
257 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(
258 mxComponent, uno::UNO_QUERY);
259 uno::Reference<document::XDocumentProperties> xProps(
260 xDocumentPropertiesSupplier->getDocumentProperties());
261 CPPUNIT_ASSERT_EQUAL(OUString("Aln Lin (Bei Jing)"), xProps->getAuthor());
262 OUString aTitle(u"\u53A6\u95E8\u94A8\u4E1A\u80A1\u4EFD\u6709\u9650\u516C\u53F8");
263 CPPUNIT_ASSERT_EQUAL(aTitle, xProps->getTitle());
264 uno::Reference<beans::XPropertySet> xUDProps(xProps->getUserDefinedProperties(),
265 uno::UNO_QUERY);
266 CPPUNIT_ASSERT_EQUAL(OUString("jay"), getProperty<OUString>(xUDProps, "Operator"));
268 // fdo#80486 also check that the ftnsep doesn't insert paragraph breaks
269 getParagraph(1, aTitle);
272 DECLARE_RTFEXPORT_TEST(testFdo47802, "fdo47802.rtf")
274 // Shape inside table was ignored.
275 CPPUNIT_ASSERT_EQUAL(1, getShapes());
278 DECLARE_RTFEXPORT_TEST(testFdo39001, "fdo39001.rtf")
280 // Document was of 4 pages, \sect at the end of the doc wasn't ignored.
281 CPPUNIT_ASSERT_EQUAL(3, getPages());
284 DECLARE_RTFEXPORT_TEST(testFdo54900, "fdo54900.rtf")
286 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
287 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
288 uno::UNO_QUERY);
289 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
290 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
291 // Paragraph was aligned to left, should be center.
292 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER,
293 static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(
294 getParagraphOfText(1, xCell->getText()), "ParaAdjust")));
297 DECLARE_RTFEXPORT_TEST(testFdo64637, "fdo64637.rtf")
299 // The problem was that the custom "Company" property was added twice, the second invocation resulted in an exception.
300 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(
301 mxComponent, uno::UNO_QUERY);
302 uno::Reference<beans::XPropertySet> xPropertySet(
303 xDocumentPropertiesSupplier->getDocumentProperties()->getUserDefinedProperties(),
304 uno::UNO_QUERY);
305 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getProperty<OUString>(xPropertySet, "Company"));
308 DECLARE_RTFEXPORT_TEST(testN820504, "n820504.rtf")
310 // The shape was anchored at-page instead of at-character (that's incorrect as Word only supports at-character and as-character).
311 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,
312 getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
315 DECLARE_RTFEXPORT_TEST(testFdo67498, "fdo67498.rtf")
317 // Left margin of the default page style wasn't set (was 2000).
318 CPPUNIT_ASSERT_EQUAL(
319 sal_Int32(convertTwipToMm100(5954)),
320 getProperty<sal_Int32>(getStyles("PageStyles")->getByName("Standard"), "LeftMargin"));
323 DECLARE_RTFEXPORT_TEST(testFdo44715, "fdo44715.rtf")
325 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
326 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
327 // Style information wasn't reset, which caused character height to be 16.
328 CPPUNIT_ASSERT_EQUAL(12.f,
329 getProperty<float>(getParagraphOfText(2, xCell->getText()), "CharHeight"));
332 DECLARE_RTFEXPORT_TEST(testFdo68076, "fdo68076.rtf")
334 // Encoding of the last char was wrong (more 'o' than 'y').
335 getParagraph(1, u"\u041E\u0431\u044A\u0435\u043A\u0442 \u2013 \u0443");
338 DECLARE_RTFEXPORT_TEST(testFdo70221, "fdo70221.rtf")
340 // The picture was imported twice.
341 CPPUNIT_ASSERT_EQUAL(1, getShapes());
344 DECLARE_RTFEXPORT_TEST(testCp1000018, "cp1000018.rtf")
346 // The problem was that the empty paragraph at the end of the footnote got
347 // lost during import.
348 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
349 uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
350 uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
352 OUString const aActual = xTextRange->getString();
354 CPPUNIT_ASSERT_EQUAL(OUString("Footnote first line." SAL_NEWLINE_STRING), aActual);
357 DECLARE_RTFEXPORT_TEST(testFdo94835, "fdo94835.rtf")
359 // The picture was imported twice.
360 CPPUNIT_ASSERT_EQUAL(19, getShapes());
362 DECLARE_RTFEXPORT_TEST(testNestedTable, "rhbz1065629.rtf")
364 // nested table in second cell was missing
365 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
366 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
367 uno::UNO_QUERY);
368 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(1), uno::UNO_QUERY);
369 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
370 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
371 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
372 uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
373 CPPUNIT_ASSERT_EQUAL(OUString("Responsable Commercial:"), xPara->getString());
374 xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
375 xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY);
376 xParaEnum = xParaEnumAccess->createEnumeration();
377 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
378 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
379 CPPUNIT_ASSERT_EQUAL(OUString("Nom: John Doe"), xPara->getString());
381 // outer table: background color, borders for B1/B2 cell
382 xTable.set(xTables->getByIndex(2), uno::UNO_QUERY);
383 xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
384 CPPUNIT_ASSERT(xCell.is());
385 table::BorderLine2 fullPtSolid(sal_Int32(COL_BLACK), 0, 35, 0, table::BorderLineStyle::SOLID,
386 35);
387 CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
388 CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid, getProperty<table::BorderLine2>(xCell, "RightBorder"));
389 CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid, getProperty<table::BorderLine2>(xCell, "TopBorder"));
390 CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid,
391 getProperty<table::BorderLine2>(xCell, "BottomBorder"));
392 CPPUNIT_ASSERT_EQUAL(Color(0xCC0000),
393 Color(ColorTransparency, getProperty<sal_Int32>(xCell, "BackColor")));
394 xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
395 CPPUNIT_ASSERT(xCell.is());
396 table::BorderLine2 halfPtSolid(sal_Int32(COL_BLACK), 0, 18, 0, table::BorderLineStyle::SOLID,
397 18);
398 CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
399 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty<Color>(xCell, "BackColor"));
400 xCell.set(xTable->getCellByName("B2"), uno::UNO_QUERY);
401 CPPUNIT_ASSERT(xCell.is());
402 CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
403 CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid, getProperty<table::BorderLine2>(xCell, "RightBorder"));
404 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty<Color>(xCell, "BackColor"));
406 // \sect at the end resulted in spurious page break
407 CPPUNIT_ASSERT_EQUAL(1, getPages());
410 DECLARE_RTFEXPORT_TEST(testFooterPara, "footer-para.rtf")
412 // check that paragraph properties in footer are imported
413 uno::Reference<text::XText> xFooterText = getProperty<uno::Reference<text::XText>>(
414 getStyles("PageStyles")->getByName("First Page"), "FooterText");
415 uno::Reference<text::XTextContent> xParagraph = getParagraphOrTable(1, xFooterText);
416 CPPUNIT_ASSERT_EQUAL(
417 OUString("All Rights Reserved."),
418 uno::Reference<text::XTextRange>(xParagraph, uno::UNO_QUERY_THROW)->getString());
419 CPPUNIT_ASSERT_EQUAL(
420 sal_Int16(style::ParagraphAdjust_CENTER),
421 getProperty</*style::ParagraphAdjust*/ sal_Int16>(xParagraph, "ParaAdjust"));
424 DECLARE_RTFEXPORT_TEST(testCp1000016, "hello.rtf")
426 // The single-line document had a second fake empty para on Windows.
427 bool bFound = true;
430 getParagraph(2);
432 catch (const container::NoSuchElementException&)
434 bFound = false;
436 CPPUNIT_ASSERT_EQUAL(false, bFound);
439 DECLARE_RTFEXPORT_TEST(testFdo65090, "fdo65090.rtf")
441 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
442 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
443 uno::UNO_QUERY);
444 uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
445 uno::Reference<table::XTableRows> xTableRows = xTextTable->getRows();
446 // The first row had 3 cells, instead of a horizontally merged one and a normal one (2 -> 1 separator).
447 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<uno::Sequence<text::TableColumnSeparator>>(
448 xTableRows->getByIndex(0), "TableColumnSeparators")
449 .getLength());
452 DECLARE_RTFEXPORT_TEST(testTableBorderDefaults, "fdo68779.rtf")
454 // table borders without \brdrw were not imported
455 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
456 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
457 uno::UNO_QUERY);
458 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
459 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
460 CPPUNIT_ASSERT(xCell.is());
461 table::BorderLine2 solid(sal_Int32(COL_BLACK), 0, 26, 0, table::BorderLineStyle::SOLID, 26);
462 CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
463 CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty<table::BorderLine2>(xCell, "RightBorder"));
464 CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty<table::BorderLine2>(xCell, "TopBorder"));
465 CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty<table::BorderLine2>(xCell, "BottomBorder"));
467 xTable.set(xTables->getByIndex(1), uno::UNO_QUERY);
468 xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
469 CPPUNIT_ASSERT(xCell.is());
470 table::BorderLine2 dotted(sal_Int32(COL_BLACK), 0, 26, 0, table::BorderLineStyle::DOTTED, 26);
471 CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
472 CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty<table::BorderLine2>(xCell, "RightBorder"));
473 CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty<table::BorderLine2>(xCell, "TopBorder"));
474 CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty<table::BorderLine2>(xCell, "BottomBorder"));
476 xTable.set(xTables->getByIndex(2), uno::UNO_QUERY);
477 xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
478 CPPUNIT_ASSERT(xCell.is());
479 table::BorderLine2 doubled(sal_Int32(COL_BLACK), 26, 26, 26, table::BorderLineStyle::DOUBLE,
480 79);
481 CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
482 CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty<table::BorderLine2>(xCell, "RightBorder"));
483 CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty<table::BorderLine2>(xCell, "TopBorder"));
484 CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty<table::BorderLine2>(xCell, "BottomBorder"));
486 xTable.set(xTables->getByIndex(3), uno::UNO_QUERY);
487 xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
488 CPPUNIT_ASSERT(xCell.is());
489 table::BorderLine2 thinThickMG(sal_Int32(COL_BLACK), 14, 26, 14,
490 table::BorderLineStyle::THINTHICK_MEDIUMGAP, 53);
491 CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
492 CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG, getProperty<table::BorderLine2>(xCell, "RightBorder"));
493 CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG, getProperty<table::BorderLine2>(xCell, "TopBorder"));
494 CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG,
495 getProperty<table::BorderLine2>(xCell, "BottomBorder"));
498 DECLARE_RTFEXPORT_TEST(testShpzDhgt, "shpz-dhgt.rtf")
500 // Test that shpz has priority over dhgt and not the other way around.
501 // Drawpage is sorted by ZOrder, so first should be red (back).
502 CPPUNIT_ASSERT_EQUAL(Color(0xff0000), Color(ColorTransparency,
503 getProperty<sal_Int32>(getShape(1), "FillColor")));
504 // Second (front) should be green.
505 CPPUNIT_ASSERT_EQUAL(Color(0x00ff00), Color(ColorTransparency,
506 getProperty<sal_Int32>(getShape(2), "FillColor")));
509 DECLARE_RTFEXPORT_TEST(testLevelfollow, "levelfollow.rtf")
511 uno::Reference<container::XIndexAccess> xNum1Levels
512 = getProperty<uno::Reference<container::XIndexAccess>>(
513 getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
514 CPPUNIT_ASSERT_EQUAL(
515 sal_Int16(SvxNumberFormat::LISTTAB),
516 comphelper::SequenceAsHashMap(xNum1Levels->getByIndex(0))["LabelFollowedBy"]
517 .get<sal_Int16>()); // first level, tab
519 uno::Reference<container::XIndexAccess> xNum2Levels
520 = getProperty<uno::Reference<container::XIndexAccess>>(
521 getStyles("NumberingStyles")->getByName("WWNum2"), "NumberingRules");
522 CPPUNIT_ASSERT_EQUAL(
523 sal_Int16(SvxNumberFormat::SPACE),
524 comphelper::SequenceAsHashMap(xNum2Levels->getByIndex(0))["LabelFollowedBy"]
525 .get<sal_Int16>()); // first level, space
527 uno::Reference<container::XIndexAccess> xNum3Levels
528 = getProperty<uno::Reference<container::XIndexAccess>>(
529 getStyles("NumberingStyles")->getByName("WWNum3"), "NumberingRules");
530 CPPUNIT_ASSERT_EQUAL(
531 sal_Int16(SvxNumberFormat::NOTHING),
532 comphelper::SequenceAsHashMap(xNum3Levels->getByIndex(0))["LabelFollowedBy"]
533 .get<sal_Int16>()); // first level, nothing
536 DECLARE_RTFEXPORT_TEST(testCharColor, "char-color.rtf")
538 // This was -1: character color wasn't set.
539 CPPUNIT_ASSERT_EQUAL(
540 Color(0x365F91),
541 Color(ColorTransparency, getProperty<sal_Int32>(getParagraph(1), "CharColor")));
544 DECLARE_RTFEXPORT_TEST(testFdo69289, "fdo69289.rtf")
546 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
547 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
548 uno::UNO_QUERY);
549 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
550 uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
551 // There were only 2 cells (1 separators) in the table, should be 3 (2 separators).
552 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<uno::Sequence<text::TableColumnSeparator>>(
553 xTableRows->getByIndex(0), "TableColumnSeparators")
554 .getLength());
557 DECLARE_RTFEXPORT_TEST(testDptxbxRelation, "dptxbx-relation.rtf")
559 // This was FRAME, not PAGE_FRAME, even if dobxpage is in the document.
560 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME,
561 getProperty<sal_Int16>(getShape(1), "HoriOrientRelation"));
564 DECLARE_RTFEXPORT_TEST(testDprectAnchor, "dprect-anchor.rtf")
566 // This was at-page, which is not something Word supports, so clearly an import error.
567 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,
568 getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
571 DECLARE_RTFEXPORT_TEST(testFdo76628, "fdo76628.rtf")
573 // Should be 'SAMPLE' in Russian, was garbage.
574 getParagraph(1, u"\u041E\u0411\u0420\u0410\u0417\u0415\u0426");
576 uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>(
577 getStyles("PageStyles")->getByName("Standard"), "HeaderText");
578 // Should be 'prepared' in Russian, was garbage.
579 getParagraphOfText(1, xHeaderText,
580 u"\u041F\u043E\u0434\u0433\u043E\u0442\u043E\u0432\u043B\u0435\u043D\u043E");
583 DECLARE_RTFEXPORT_TEST(testFdo77267, "fdo77267.rtf")
585 // Paragraph was aligned to left, should be center.
586 CPPUNIT_ASSERT_EQUAL(
587 style::ParagraphAdjust_CENTER,
588 static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
591 DECLARE_RTFEXPORT_TEST(testFdo75735, "fdo75735.rtf")
593 // Number of tabstops in the second paragraph should be 3, was 6.
594 CPPUNIT_ASSERT_EQUAL(
595 sal_Int32(3),
596 getProperty<uno::Sequence<style::TabStop>>(getParagraph(2), "ParaTabStops").getLength());
599 DECLARE_RTFEXPORT_TEST(testFontOverride, "font-override.rtf")
601 // This was "Times New Roman".
602 CPPUNIT_ASSERT_EQUAL(OUString("Arial"),
603 getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
606 DECLARE_RTFEXPORT_TEST(testFdo73241, "fdo73241.rtf")
608 // This was 2, page break in table wasn't ignored.
609 CPPUNIT_ASSERT_EQUAL(1, getPages());
612 DECLARE_RTFEXPORT_TEST(testFdo80905, "fdo80905.rtf")
614 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
615 uno::Reference<container::XEnumerationAccess> xFieldsAccess(
616 xTextFieldsSupplier->getTextFields());
617 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
618 xFields->nextElement();
619 // The problem was that there was only one field in the document, but there should be true.
620 CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(xFields->hasMoreElements()));
623 DECLARE_RTFEXPORT_TEST(testFdo82106, "fdo82106.rtf")
625 // Tab was missing after footnote not containing a tab.
626 getParagraph(2, "before\tafter");
629 DECLARE_RTFEXPORT_TEST(testFdo74229, "fdo74229.rtf")
631 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
632 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
633 uno::UNO_QUERY);
634 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
635 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
636 // This was 0, due to ignoring RTF_TRGAPH.
637 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(67)),
638 getProperty<sal_Int32>(xCell, "RightBorderDistance"));
641 DECLARE_RTFEXPORT_TEST(testFdo79959, "fdo79959.rtf")
643 // This was false, as the style was imported as " Test", i.e. no whitespace stripping.
644 CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(getStyles("ParagraphStyles")->hasByName("Test")));
647 DECLARE_RTFEXPORT_TEST(testFdo82078, "fdo82078.rtf")
649 // This was awt::FontWeight::BOLD, i.e. the second run was bold, when it should be normal.
650 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL,
651 getProperty<float>(getRun(getParagraph(1), 2), "CharWeight"));
654 DECLARE_RTFEXPORT_TEST(testCsBold, "cs-bold.rtf")
656 // This was awt::FontWeight::NORMAL, i.e. the first run was bold, when it should be bold (applied character style without direct formatting).
657 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD,
658 getProperty<float>(getRun(getParagraph(1), 1), "CharWeight"));
661 DECLARE_RTFEXPORT_TEST(testFdo84679, "fdo84679.rtf")
663 // The problem was that the paragraph in A1 had some bottom margin, but it should not.
664 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
665 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
666 uno::UNO_QUERY);
667 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
668 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
669 // This was 282.
670 CPPUNIT_ASSERT_EQUAL(
671 static_cast<sal_Int32>(0),
672 getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
675 DECLARE_RTFEXPORT_TEST(testTdf123393, "tdf123393.rtf")
677 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
678 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
679 uno::UNO_QUERY);
680 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
681 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
682 // Without the accompanying fix in place, this test would have failed with
683 // 'Expected: 7; Actual : 10', i.e. font size was too large.
684 CPPUNIT_ASSERT_EQUAL(
685 7.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight"));
688 DECLARE_RTFEXPORT_TEST(testFdo83464, "fdo83464.rtf")
690 // Problem was that the text in the textframe had wrong font.
691 uno::Reference<text::XTextRange> xFrameText(getShape(1), uno::UNO_QUERY);
692 CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xFrameText->getString());
693 // This was Times New Roman.
694 CPPUNIT_ASSERT_EQUAL(
695 OUString("Verdana"),
696 getProperty<OUString>(getRun(getParagraphOfText(1, xFrameText->getText()), 1),
697 "CharFontName"));
700 DECLARE_RTFEXPORT_TEST(testFdo86761, "fdo86761.rtf")
702 // This was 26, even if the picture should have no border, due to fLine=0.
703 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0),
704 getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineWidth);
707 DECLARE_RTFEXPORT_TEST(testFdo82859, "fdo82859.rtf")
709 // This was 0: "0xffffff" was converted to 0, i.e. the background was black instead of the default.
710 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1),
711 getProperty<sal_Int32>(getShape(1), "BackColor"));
714 DECLARE_RTFEXPORT_TEST(testFdo82076, "fdo82076.rtf")
716 // Footnote position was wrong: should be at the end of the B1 cell.
717 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
718 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
719 uno::UNO_QUERY);
720 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
721 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
722 // This resulted in container::NoSuchElementException: the footnote was at the start of the A1 cell.
723 CPPUNIT_ASSERT_EQUAL(OUString("Footnote"),
724 getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 2),
725 "TextPortionType"));
728 DECLARE_RTFEXPORT_TEST(testFdo83204, "fdo83204.rtf")
730 // This was Standard, \sN was ignored after \bkmkstart and \pard.
731 CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
732 getProperty<OUString>(getParagraph(1), "ParaStyleName"));
735 DECLARE_RTFEXPORT_TEST(testFdo85889pc, "fdo85889-pc.rtf")
737 uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
739 CPPUNIT_ASSERT_EQUAL(OUString(u"\u00B1\u2265\u2264"), xTextRange->getString());
742 DECLARE_RTFEXPORT_TEST(testFdo85889pca, "fdo85889-pca.rtf")
744 uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
746 CPPUNIT_ASSERT_EQUAL(OUString(u"\u00B1\u2017\u00BE"), xTextRange->getString());
749 DECLARE_RTFEXPORT_TEST(testFdo85889mac, "fdo85889-mac.rtf")
751 uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
753 CPPUNIT_ASSERT_EQUAL(OUString(u"\u00D2\u00DA\u00DB"), xTextRange->getString());
756 DECLARE_RTFEXPORT_TEST(testFdo72031, "fdo72031.rtf")
758 CPPUNIT_ASSERT_EQUAL(OUString(u"\uF0C5"), getRun(getParagraph(1), 1)->getString());
761 DECLARE_RTFEXPORT_TEST(testFdo86750, "fdo86750.rtf")
763 // This was 'HYPERLINK#anchor', the URL of the hyperlink had the field type as a prefix, leading to broken links.
764 CPPUNIT_ASSERT_EQUAL(OUString("#anchor"),
765 getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL"));
768 DECLARE_RTFEXPORT_TEST(testTdf88811, "tdf88811.rtf")
770 // The problem was that shapes anchored to the paragraph that is moved into a textframe were lost, so this was 2.
771 CPPUNIT_ASSERT_EQUAL(4, getShapes());
774 DECLARE_RTFEXPORT_TEST(testFdo49893_2, "fdo49893-2.rtf")
776 // Ensure that header text exists on each page (especially on second page)
777 CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[1]/header/txt/text()"));
778 CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[2]/header/txt/text()"));
779 CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[3]/header/txt/text()"));
782 DECLARE_RTFEXPORT_TEST(testFdo89496, "fdo89496.rtf")
784 // Just ensure that document is loaded and shape exists
785 uno::Reference<drawing::XShape> xShape = getShape(1);
786 CPPUNIT_ASSERT(xShape.is());
789 DECLARE_RTFEXPORT_TEST(testFdo75614, "tdf75614.rtf")
791 // Text after the footnote was missing, so this resulted in a css::container::NoSuchElementException.
792 CPPUNIT_ASSERT_EQUAL(OUString("after."), getRun(getParagraph(1), 3)->getString());
795 DECLARE_RTFEXPORT_TEST(mathtype, "mathtype.rtf")
797 OUString aFormula = getFormula(getRun(getParagraph(1), 1));
798 CPPUNIT_ASSERT(!aFormula.isEmpty());
801 DECLARE_RTFEXPORT_TEST(testTdf86182, "tdf86182.rtf")
803 // Writing mode was the default, i.e. text::WritingMode2::CONTEXT.
804 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB,
805 getProperty<sal_Int16>(getParagraph(1), "WritingMode"));
808 DECLARE_RTFEXPORT_TEST(testTdf91074, "tdf91074.rtf")
810 // The file failed to load, as the border color was imported using the LineColor UNO property.
811 uno::Reference<drawing::XShape> xShape = getShape(1);
812 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_LIGHTRED),
813 getProperty<table::BorderLine2>(xShape, "TopBorder").Color);
816 CPPUNIT_TEST_FIXTURE(Test, testTdf90260Nopar)
818 load(mpTestDocumentPath, "hello.rtf");
819 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
820 uno::Reference<text::XTextRange> xText = xTextDocument->getText();
821 uno::Reference<text::XTextRange> xEnd = xText->getEnd();
822 paste(u"rtfexport/data/tdf90260-nopar.rtf", xEnd);
823 CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
826 DECLARE_RTFEXPORT_TEST(testTdf86814, "tdf86814.rtf")
828 // This was awt::FontWeight::NORMAL, i.e. the first run wasn't bold, when it should be bold (applied paragraph style with direct formatting).
829 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD,
830 getProperty<float>(getRun(getParagraph(1), 1), "CharWeight"));
833 DECLARE_RTFEXPORT_TEST(testTdf108416, "tdf108416.rtf")
835 uno::Reference<container::XNameAccess> xCharacterStyles(getStyles("CharacterStyles"));
836 uno::Reference<beans::XPropertySet> xListLabel(xCharacterStyles->getByName("ListLabel 1"),
837 uno::UNO_QUERY);
838 // This was awt::FontWeight::BOLD, list numbering got an unexpected bold formatting.
839 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xListLabel, "CharWeight"));
842 DECLARE_RTFEXPORT_TEST(testBinSkipping, "bin-skipping.rtf")
844 // before, it was importing '/nMUST NOT IMPORT'
845 CPPUNIT_ASSERT_EQUAL(OUString("text"), getRun(getParagraph(1), 1)->getString());
848 DECLARE_RTFEXPORT_TEST(testTdf92061, "tdf92061.rtf")
850 // This was "C", i.e. part of the footnote ended up in the body text.
851 CPPUNIT_ASSERT_EQUAL(OUString("body-after"), getRun(getParagraph(1), 3)->getString());
854 DECLARE_RTFEXPORT_TEST(testTdf92481, "tdf92481.rtf")
856 // This was 0, RTF_WIDOWCTRL was not imported.
857 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int8>(2),
858 getProperty<sal_Int8>(getParagraph(1), "ParaWidows"));
861 DECLARE_RTFEXPORT_TEST(testTdf94456, "tdf94456.rtf")
863 // Paragraph left margin and first line indent wasn't imported correctly.
865 // This was 1270.
866 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(762),
867 getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
868 // This was -635.
869 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-762),
870 getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent"));
873 DECLARE_RTFEXPORT_TEST(testTdf94435, "tdf94435.rtf")
875 // This was style::ParagraphAdjust_LEFT, \ltrpar undone the effect of \qc.
876 CPPUNIT_ASSERT_EQUAL(
877 style::ParagraphAdjust_CENTER,
878 static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
881 DECLARE_RTFEXPORT_TEST(testTdf54584, "tdf54584.rtf")
883 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
884 uno::Reference<container::XEnumerationAccess> xFieldsAccess(
885 xTextFieldsSupplier->getTextFields());
886 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
887 // \PAGE was ignored, so no fields were in document -> exception was thrown
888 CPPUNIT_ASSERT_NO_THROW_MESSAGE(
889 "No fields in document found: field \"\\PAGE\" was not properly read",
890 xFields->nextElement());
893 DECLARE_RTFEXPORT_TEST(testTdf96308Deftab, "tdf96308-deftab.rtf")
895 uno::Reference<lang::XMultiServiceFactory> xTextFactory(mxComponent, uno::UNO_QUERY);
896 uno::Reference<beans::XPropertySet> xDefaults(
897 xTextFactory->createInstance("com.sun.star.text.Defaults"), uno::UNO_QUERY);
898 // This was 1270 as \deftab was ignored on import.
899 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(284)),
900 getProperty<sal_Int32>(xDefaults, "TabStopDistance"));
903 DECLARE_RTFEXPORT_TEST(testLandscape, "landscape.rtf")
905 // Check landscape flag.
906 CPPUNIT_ASSERT_EQUAL(3, getPages());
908 // All pages should have flag orientation
909 uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles");
911 // get a page cursor
912 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
913 uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
914 xModel->getCurrentController(), uno::UNO_QUERY);
915 uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(),
916 uno::UNO_QUERY);
918 // check that the first page has landscape flag
919 xCursor->jumpToFirstPage();
920 OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
921 uno::Reference<style::XStyle> xStylePage(pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
922 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStylePage, "IsLandscape"));
924 // check that the second page has landscape flag
925 xCursor->jumpToPage(2);
926 pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
927 xStylePage.set(pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
928 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStylePage, "IsLandscape"));
930 // check that the last page has landscape flag
931 xCursor->jumpToLastPage();
932 pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
933 xStylePage.set(pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
934 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStylePage, "IsLandscape"));
937 DECLARE_RTFEXPORT_TEST(testTdf97035, "tdf97035.rtf")
939 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
940 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
941 uno::UNO_QUERY);
942 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
944 // First cell width of the second row should be 2300
945 uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
946 CPPUNIT_ASSERT_EQUAL(sal_Int16(2300), getProperty<uno::Sequence<text::TableColumnSeparator>>(
947 xTableRows->getByIndex(1), "TableColumnSeparators")[0]
948 .Position);
951 DECLARE_RTFEXPORT_TEST(testTdf87034, "tdf87034.rtf")
953 // This was A1BC34D, i.e. the first "super" text portion was mis-imported,
954 // and was inserted instead right before the second "super" text portion.
955 CPPUNIT_ASSERT_EQUAL(OUString("A1B3C4D"), getParagraph(1)->getString());
958 CPPUNIT_TEST_FIXTURE(Test, testClassificatonPasteLevels)
960 load(mpTestDocumentPath, "classification-confidential.rtf");
961 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
962 uno::Reference<text::XTextRange> xText = xTextDocument->getText();
963 uno::Reference<text::XTextRange> xEnd = xText->getEnd();
965 // Classified source and classified destination, but internal only has a
966 // higher level than confidential: nothing should happen.
967 OUString aOld = xText->getString();
968 paste(u"rtfexport/data/classification-yes.rtf", xEnd);
969 CPPUNIT_ASSERT_EQUAL(aOld, xText->getString());
972 DECLARE_RTFEXPORT_TEST(testTdf95707, "tdf95707.rtf")
974 // Graphic was replaced with a "Read-Error" placeholder.
975 uno::Reference<graphic::XGraphic> xGraphic
976 = getProperty<uno::Reference<graphic::XGraphic>>(getShape(1), "Graphic");
977 CPPUNIT_ASSERT(xGraphic.is());
978 CPPUNIT_ASSERT(xGraphic->getType() != graphic::GraphicType::EMPTY);
981 DECLARE_RTFEXPORT_TEST(testTdf96275, "tdf96275.rtf")
983 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
984 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
985 uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(3, xCell->getText());
986 // This was text: the shape's frame was part of the 1st paragraph instead of the 3rd one.
987 CPPUNIT_ASSERT_EQUAL(OUString("Frame"),
988 getProperty<OUString>(getRun(xParagraph, 1), "TextPortionType"));
991 DECLARE_RTFEXPORT_TEST(testTdf82073, "tdf82073.rtf")
993 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2), uno::UNO_QUERY);
994 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
995 // This was -1: the background color was automatic, not black.
996 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xCell, "BackColor"));
999 DECLARE_RTFEXPORT_TEST(testTdf74795, "tdf74795.rtf")
1001 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
1002 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1003 // This was 0, \trpaddl was ignored on import.
1004 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(635),
1005 getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
1007 xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
1008 // Make sure that the scope of the default is only one row.
1009 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
1010 getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
1013 DECLARE_RTFEXPORT_TEST(testTdf137085, "tdf137085.rtf")
1015 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
1016 // \trpaddl0 overrides \trgaph600 (-1058 mm100) and built-in default of 190
1017 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xTable, "LeftMargin"));
1019 // the \trpaddl0 is applied to all cells
1020 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1021 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
1022 getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
1024 xCell.set(xTable->getCellByName("B1"), uno::UNO_QUERY);
1025 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
1026 getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
1029 DECLARE_RTFEXPORT_TEST(testTdf77349, "tdf77349.rtf")
1031 uno::Reference<container::XNamed> xImage(getShape(1), uno::UNO_QUERY);
1032 // This was empty: imported image wasn't named automatically.
1033 CPPUNIT_ASSERT_EQUAL(OUString("Image1"), xImage->getName());
1036 DECLARE_RTFEXPORT_TEST(testTdf50821, "tdf50821.rtf")
1038 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2), uno::UNO_QUERY);
1039 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1040 // This was 0, \trpaddfl was mishandled on import.
1041 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(191),
1042 getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
1045 DECLARE_RTFEXPORT_TEST(testTdf100507, "tdf100507.rtf")
1047 // This was 0: left margin of the first paragraph was lost on import.
1048 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6618),
1049 getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
1052 DECLARE_RTFEXPORT_TEST(testTdf44986, "tdf44986.rtf")
1054 // Check that the table at the second paragraph.
1055 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2), uno::UNO_QUERY);
1056 uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
1057 // Check the first row of the table, it should have two cells (one separator).
1058 // This was 0: the first row had no separators, so it had only one cell, which was too wide.
1059 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<uno::Sequence<text::TableColumnSeparator>>(
1060 xTableRows->getByIndex(0), "TableColumnSeparators")
1061 .getLength());
1064 DECLARE_RTFEXPORT_TEST(testTdf90697, "tdf90697.rtf")
1066 // We want section breaks to be seen as section breaks, not as page breaks,
1067 // so this document should have only one page, not three.
1068 CPPUNIT_ASSERT_EQUAL(1, getPages());
1071 DECLARE_RTFEXPORT_TEST(testTdf104317, "tdf104317.rtf")
1073 // This failed to load, we tried to set CustomShapeGeometry on a line shape.
1074 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1077 DECLARE_RTFEXPORT_TEST(testTdf104744, "tdf104744.rtf")
1079 auto xRules = getProperty<uno::Reference<container::XIndexAccess>>(
1080 getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
1081 comphelper::SequenceAsHashMap aRule(xRules->getByIndex(0));
1082 // This was 0.
1083 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), aRule["IndentAt"].get<sal_Int32>());
1086 CPPUNIT_TEST_FIXTURE(SwModelTestBase, testChicagoNumberingFootnote)
1088 // Create a document, set footnote numbering type to SYMBOL_CHICAGO.
1089 loadURL("private:factory/swriter", nullptr);
1090 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
1091 uno::Reference<beans::XPropertySet> xFootnoteSettings
1092 = xFootnotesSupplier->getFootnoteSettings();
1093 sal_uInt16 nNumberingType = style::NumberingType::SYMBOL_CHICAGO;
1094 xFootnoteSettings->setPropertyValue("NumberingType", uno::makeAny(nNumberingType));
1096 // Insert a footnote.
1097 uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
1098 uno::Reference<text::XTextContent> xFootnote(
1099 xFactory->createInstance("com.sun.star.text.Footnote"), uno::UNO_QUERY);
1100 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
1101 uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(),
1102 uno::UNO_QUERY);
1103 xTextContentAppend->appendTextContent(xFootnote, {});
1105 reload("Rich Text Format", "");
1106 xFootnotesSupplier.set(mxComponent, uno::UNO_QUERY);
1107 sal_uInt16 nExpected = style::NumberingType::SYMBOL_CHICAGO;
1108 auto nActual
1109 = getProperty<sal_uInt16>(xFootnotesSupplier->getFootnoteSettings(), "NumberingType");
1110 // Without the accompanying fix in place, this test would have failed with:
1111 // - Expected: 63
1112 // - Actual : 4
1113 // i.e. the numbering type was ARABIC, not SYMBOL_CHICAGO.
1114 CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
1117 DECLARE_RTFEXPORT_TEST(testTdf105852, "tdf105852.rtf")
1119 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1120 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
1121 uno::UNO_QUERY);
1122 uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1123 uno::Reference<table::XTableRows> xTableRows = xTextTable->getRows();
1124 // All rows but last were merged -> there were only 2 rows
1125 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTableRows->getCount());
1126 // The first row must have 4 cells.
1127 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty<uno::Sequence<text::TableColumnSeparator>>(
1128 xTableRows->getByIndex(0), "TableColumnSeparators")
1129 .getLength());
1130 // The third row must have 1 merged cell.
1131 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<uno::Sequence<text::TableColumnSeparator>>(
1132 xTableRows->getByIndex(2), "TableColumnSeparators")
1133 .getLength());
1136 DECLARE_RTFEXPORT_TEST(testTdf104287, "tdf104287.rtf")
1138 uno::Reference<text::XTextContent> xShape(getShape(1), uno::UNO_QUERY);
1139 CPPUNIT_ASSERT(xShape.is());
1140 // This failed, the bitmap had no valid anchor.
1141 CPPUNIT_ASSERT(xShape->getAnchor().is());
1144 DECLARE_RTFEXPORT_TEST(testTdf105729, "tdf105729.rtf")
1146 // This was style::ParagraphAdjust_LEFT, \ltrpar undone the effect of \qc from style.
1147 CPPUNIT_ASSERT_EQUAL(
1148 style::ParagraphAdjust_CENTER,
1149 static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
1152 DECLARE_RTFEXPORT_TEST(testTdf106694, "tdf106694.rtf")
1154 auto aTabs = getProperty<uno::Sequence<style::TabStop>>(getParagraph(1), "ParaTabStops");
1155 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aTabs.getLength());
1156 // This was 0, tab position was incorrect, looked like it was missing.
1157 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(14605), aTabs[0].Position);
1160 DECLARE_RTFEXPORT_TEST(testTdf107116, "tdf107116.rtf")
1162 // This was 0, upper border around text (and its distance) was missing.
1163 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(120)),
1164 getProperty<sal_Int32>(getParagraph(2), "TopBorderDistance"));
1167 DECLARE_RTFEXPORT_TEST(testTdf106950, "tdf106950.rtf")
1169 uno::Reference<text::XTextRange> xPara(getParagraph(1));
1170 // This was ParagraphAdjust_LEFT, trying to set CharShadingValue on a
1171 // paragraph style thrown an exception, and remaining properties were not
1172 // set.
1173 CPPUNIT_ASSERT_EQUAL(
1174 style::ParagraphAdjust_CENTER,
1175 static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xPara, "ParaAdjust")));
1178 DECLARE_RTFEXPORT_TEST(testTdf116371, "tdf116371.odt")
1180 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1181 CPPUNIT_ASSERT_EQUAL(1, getPages());
1182 auto xShape(getShape(1));
1183 // Without the accompanying fix in place, this test would have failed with
1184 // 'Unknown property: RotateAngle', i.e. export lost the rotation, and then
1185 // import created a Writer picture (instead of a Draw one).
1186 CPPUNIT_ASSERT_DOUBLES_EQUAL(4700.0, getProperty<double>(xShape, "RotateAngle"), 10);
1189 DECLARE_RTFEXPORT_TEST(testTdf133437, "tdf133437.rtf")
1191 CPPUNIT_ASSERT_EQUAL(3, getPages());
1192 CPPUNIT_ASSERT_EQUAL(560, getShapes()); // 285 \shp + 275 \poswX
1194 xmlDocUniquePtr pDump = parseLayoutDump();
1195 // Count shapes on first page
1197 xmlXPathObjectPtr pXmlObj
1198 = getXPathNode(pDump, "/root/page[1]/body/txt[1]/anchored/SwAnchoredDrawObject");
1199 xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
1200 sal_Int32 shapesOnPage = xmlXPathNodeSetGetLength(pXmlNodes);
1201 xmlXPathFreeObject(pXmlObj);
1202 CPPUNIT_ASSERT_EQUAL(sal_Int32(79), shapesOnPage);
1204 // Second page
1206 xmlXPathObjectPtr pXmlObj
1207 = getXPathNode(pDump, "/root/page[2]/body/txt[2]/anchored/SwAnchoredDrawObject");
1208 xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
1209 sal_Int32 shapesOnPage = xmlXPathNodeSetGetLength(pXmlNodes);
1210 xmlXPathFreeObject(pXmlObj);
1211 CPPUNIT_ASSERT_EQUAL(sal_Int32(120), shapesOnPage);
1213 // Third page
1215 xmlXPathObjectPtr pXmlObj
1216 = getXPathNode(pDump, "/root/page[3]/body/txt[2]/anchored/SwAnchoredDrawObject");
1217 xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
1218 sal_Int32 shapesOnPage = xmlXPathNodeSetGetLength(pXmlNodes);
1219 xmlXPathFreeObject(pXmlObj);
1220 CPPUNIT_ASSERT_EQUAL(sal_Int32(86), shapesOnPage);
1224 DECLARE_RTFEXPORT_TEST(testTdf128320, "tdf128320.odt")
1226 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1227 CPPUNIT_ASSERT_EQUAL(1, getPages());
1228 // Shape does exist in RTF output
1229 auto xShape(getShape(1));
1230 CPPUNIT_ASSERT(xShape.is());
1232 // Let's see what is inside output RTF file
1233 SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
1234 CPPUNIT_ASSERT(pStream);
1235 OString aRtfContent(read_uInt8s_ToOString(*pStream, pStream->TellEnd()));
1237 // There are some RTF tokens for shape props
1238 // They are much more inside, but let's use \shpwr2 as an indicator
1239 sal_Int32 nPos = aRtfContent.indexOf("\\shpwr2", 0);
1240 CPPUNIT_ASSERT(nPos > 0);
1242 // It goes AFTER shape instruction (sadly here we do not check if it is contained inside)
1243 sal_Int32 nPosShp = aRtfContent.indexOf("\\shpinst", 0);
1244 CPPUNIT_ASSERT(nPosShp > 0);
1246 // But there are no more shape properties!
1247 nPos = aRtfContent.indexOf("\\shpwr2", nPos + 1);
1248 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), nPos);
1251 DECLARE_RTFEXPORT_TEST(testTdf129513, "tdf129513.rtf")
1253 // \pagebb after \intbl must not reset the "in table" flag
1254 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
1255 // Make sure the first paragraph is imported in table
1256 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY_THROW);
1257 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getCellNames().getLength());
1258 uno::Reference<text::XText> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY_THROW);
1259 CPPUNIT_ASSERT_EQUAL(OUString("In table"), xCell->getString());
1262 DECLARE_RTFEXPORT_TEST(testTdf138210, "tdf138210.rtf")
1264 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
1265 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(),
1266 uno::UNO_QUERY);
1267 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
1270 DECLARE_RTFEXPORT_TEST(testTdf137894, "tdf137894.odt")
1272 CPPUNIT_ASSERT_EQUAL(1, getPages());
1273 lang::Locale locale1(getProperty<lang::Locale>(getRun(getParagraph(1), 1), "CharLocaleAsian"));
1274 CPPUNIT_ASSERT_EQUAL(OUString("ja"), locale1.Language);
1275 CPPUNIT_ASSERT_EQUAL(OUString("MS UI Gothic"),
1276 getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontNameAsian"));
1277 CPPUNIT_ASSERT_EQUAL(20.f, getProperty<float>(getRun(getParagraph(1), 1), "CharHeightAsian"));
1278 CPPUNIT_ASSERT_EQUAL(OUString("Mangal"),
1279 getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontNameComplex"));
1280 CPPUNIT_ASSERT_EQUAL(20.f, getProperty<float>(getRun(getParagraph(1), 1), "CharHeightComplex"));
1281 lang::Locale locale2(
1282 getProperty<lang::Locale>(getRun(getParagraph(2), 1), "CharLocaleComplex"));
1283 CPPUNIT_ASSERT_EQUAL(OUString("he"), locale2.Language);
1284 CPPUNIT_ASSERT_EQUAL(32.f, getProperty<float>(getRun(getParagraph(2), 1), "CharHeightComplex"));
1287 DECLARE_RTFEXPORT_TEST(testTdf138779, "tdf138779.docx")
1289 // The text "2. Kozuka Mincho Pro, 8 pt Ruby ..." has font size 11pt ( was 20pt ).
1290 CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(getRun(getParagraph(2), 14), "CharHeight"));
1293 DECLARE_RTFEXPORT_TEST(testTdf144437, "tdf144437.odt")
1295 SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
1296 CPPUNIT_ASSERT(pStream);
1297 OString aRtfContent(read_uInt8s_ToOString(*pStream, pStream->TellEnd()));
1299 sal_Int32 nTextEndPos = aRtfContent.indexOf("Bookmark here->", 0) + 14;
1300 CPPUNIT_ASSERT_MESSAGE("Para content wasn't found in file", nTextEndPos > 0);
1302 sal_Int32 nBmkStartPos = aRtfContent.indexOf("{\\*\\bkmkstart bookmark}", 0);
1303 CPPUNIT_ASSERT_MESSAGE("Bookmark start wasn't found in file", nBmkStartPos > 0);
1305 sal_Int32 nBmkEndPos = aRtfContent.indexOf("{\\*\\bkmkend bookmark}", 0);
1306 CPPUNIT_ASSERT_MESSAGE("Bookmark end wasn't found in file", nBmkEndPos > 0);
1308 CPPUNIT_ASSERT_MESSAGE("Bookmark started in wrong position", nBmkStartPos > nTextEndPos);
1309 CPPUNIT_ASSERT_MESSAGE("Bookmark ended in wrong position", nBmkEndPos > nTextEndPos);
1310 CPPUNIT_ASSERT_MESSAGE("Bookmark start & end are wrong", nBmkEndPos > nBmkStartPos);
1313 DECLARE_RTFEXPORT_TEST(testTdf131234, "tdf131234.rtf")
1315 uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 1, OUString(u"Hello"));
1317 // Ensure that text has default font attrs in spite of style referenced
1318 // E.g. 12pt, Times New Roman, black, no bold, no italic, no underline
1319 CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(xRun, "CharHeight"));
1320 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "CharColor"));
1321 CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), getProperty<OUString>(xRun, "CharFontName"));
1322 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xRun, "CharWeight"));
1323 CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE, getProperty<sal_Int16>(xRun, "CharUnderline"));
1324 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty<awt::FontSlant>(xRun, "CharPosture"));
1327 CPPUNIT_PLUGIN_IMPLEMENT();
1329 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */