1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  */
9 
10 #include <memory>
11 #include <swmodeltestbase.hxx>
12 
13 #include <com/sun/star/awt/FontWeight.hpp>
14 #include <com/sun/star/graphic/GraphicType.hpp>
15 #include <com/sun/star/style/LineSpacing.hpp>
16 #include <com/sun/star/style/LineSpacingMode.hpp>
17 #include <com/sun/star/style/ParagraphAdjust.hpp>
18 #include <com/sun/star/style/TabStop.hpp>
19 #include <com/sun/star/table/BorderLine2.hpp>
20 #include <com/sun/star/table/BorderLineStyle.hpp>
21 #include <com/sun/star/text/RelOrientation.hpp>
22 #include <com/sun/star/text/TableColumnSeparator.hpp>
23 #include <com/sun/star/text/TextContentAnchorType.hpp>
24 #include <com/sun/star/text/XFootnotesSupplier.hpp>
25 #include <com/sun/star/text/XPageCursor.hpp>
26 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
27 #include <com/sun/star/text/XTextTablesSupplier.hpp>
28 #include <com/sun/star/text/XTextTable.hpp>
29 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
30 #include <com/sun/star/text/WritingMode2.hpp>
31 #include <com/sun/star/graphic/XGraphic.hpp>
32 
33 #include <rtl/ustring.hxx>
34 #include <vcl/svapp.hxx>
35 #include <vcl/settings.hxx>
36 #include <comphelper/sequenceashashmap.hxx>
37 #include <i18nlangtag/languagetag.hxx>
38 
39 class Test : public SwModelTestBase
40 {
41 public:
Test()42     Test()
43         : SwModelTestBase("/sw/qa/extras/rtfexport/data/", "Rich Text Format")
44     {
45     }
46 
preTest(const char * filename)47     virtual std::unique_ptr<Resetter> preTest(const char* filename) override
48     {
49         m_aSavedSettings = Application::GetSettings();
50         if (OString(filename) == "fdo72031.rtf")
51         {
52             std::unique_ptr<Resetter> pResetter(
53                 new Resetter([this]() { Application::SetSettings(this->m_aSavedSettings); }));
54             AllSettings aSettings(m_aSavedSettings);
55             aSettings.SetLanguageTag(LanguageTag("ru"));
56             Application::SetSettings(aSettings);
57             return pResetter;
58         }
59         return nullptr;
60     }
61 
62 protected:
63     /// Blacklist handling.
mustTestImportOf(const char * filename) const64     bool mustTestImportOf(const char* filename) const override
65     {
66         // If the testcase is stored in some other format, it's pointless to
67         // test.
68         return OString(filename).endsWith(".rtf");
69     }
70 
71     AllSettings m_aSavedSettings;
72 };
73 
74 DECLARE_RTFEXPORT_TEST(testFdo63023, "fdo63023.rtf")
75 {
76     uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>(
77         getStyles("PageStyles")->getByName("Standard"), "HeaderText");
78     // Back color was black (0) in the header, due to missing color table in the substream.
79     CPPUNIT_ASSERT_EQUAL(
80         sal_Int32(0xFFFF99),
81         getProperty<sal_Int32>(getRun(getParagraphOfText(1, xHeaderText), 1), "CharBackColor"));
82 }
83 
84 DECLARE_RTFEXPORT_TEST(testFdo42109, "fdo42109.rtf")
85 {
86     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
87     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
88                                                     uno::UNO_QUERY);
89     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
90     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
91     // Make sure the page number is imported as a field in the B1 cell.
92     CPPUNIT_ASSERT_EQUAL(OUString("TextField"),
93                          getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 1),
94                                                "TextPortionType"));
95 }
96 
97 DECLARE_RTFEXPORT_TEST(testFdo62977, "fdo62977.rtf")
98 {
99     // The middle character was imported as '?' instead of the proper unicode value.
100     getRun(getParagraph(1), 1, OUString(u"\u5E74\uFF14\u6708"));
101 }
102 
103 DECLARE_RTFEXPORT_TEST(testN818997, "n818997.rtf")
104 {
105     // \page was ignored between two \shp tokens.
106     CPPUNIT_ASSERT_EQUAL(2, getPages());
107 }
108 
109 DECLARE_RTFEXPORT_TEST(testFdo64671, "fdo64671.rtf")
110 {
111     // Additional '}' was inserted before the special character.
112     getRun(getParagraph(1), 1, OUString(u"\u017D"));
113 }
114 
115 DECLARE_RTFEXPORT_TEST(testFdo62044, "fdo62044.rtf")
116 {
117     // The problem was that RTF import during copy&paste did not ignore existing paragraph styles.
118     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
119     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
120     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
121     paste("rtfexport/data/fdo62044-paste.rtf", xEnd);
122 
123     uno::Reference<beans::XPropertySet> xPropertySet(
124         getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
125     CPPUNIT_ASSERT_EQUAL(
126         10.f, getProperty<float>(xPropertySet,
127                                  "CharHeight")); // Was 18, i.e. reset back to original value.
128 }
129 
130 DECLARE_RTFEXPORT_TEST(testFdo70578, "fdo70578.rtf")
131 {
132     // Style without explicit \s0 was not imported as the default style
133     uno::Reference<beans::XPropertySet> xPropertySet(
134         getStyles("ParagraphStyles")->getByName("Subtitle"), uno::UNO_QUERY);
135     uno::Reference<style::XStyle> xStyle(xPropertySet, uno::UNO_QUERY);
136     CPPUNIT_ASSERT_EQUAL(OUString("Standard"), xStyle->getParentStyle());
137     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "ParaTopMargin"));
138     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
139 }
140 
141 DECLARE_RTFEXPORT_TEST(testN825305, "n825305.rtf")
142 {
143     // The problem was that the textbox wasn't transparent, due to unimplemented fFilled == 0.
144     uno::Reference<beans::XPropertyState> xPropertyState(getShape(2), uno::UNO_QUERY);
145     CPPUNIT_ASSERT_EQUAL(sal_Int32(100),
146                          getProperty<sal_Int32>(getShape(2), "BackColorTransparency"));
147     beans::PropertyState ePropertyState = xPropertyState->getPropertyState("BackColorTransparency");
148     // Was beans::PropertyState_DEFAULT_VALUE.
149     CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState);
150 }
151 
152 DECLARE_RTFEXPORT_TEST(testTdf106953, "tdf106953.rtf")
153 {
154     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270),
155                          getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
156     auto xRules = getProperty<uno::Reference<container::XIndexAccess>>(
157         getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
158     comphelper::SequenceAsHashMap aRule(xRules->getByIndex(0));
159     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aRule["FirstLineIndent"].get<sal_Int32>());
160 }
161 
162 DECLARE_RTFEXPORT_TEST(testTdf112208, "tdf112208_hangingIndent.rtf")
163 {
164     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-2000),
165                          getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent"));
166     CPPUNIT_ASSERT_EQUAL(1, getPages());
167 }
168 
169 DECLARE_RTFEXPORT_TEST(testParaBottomMargin, "para-bottom-margin.rtf")
170 {
171     uno::Reference<beans::XPropertySet> xPropertySet(
172         getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
173     CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
174 
175     // This was 353, i.e. bottom margin of the paragraph was 0.35cm instead of 0.
176     // The reason why this is 0 despite the default style containing \sa200
177     // is that Word will actually interpret \sN (or \pard which apparently
178     // implies \s0) as "set style N and for every attribute of that style,
179     // set an attribute with default value on the paragraph"
180     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
181     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
182 }
183 
CPPUNIT_TEST_FIXTURE(Test,testParaStyleBottomMargin2)184 CPPUNIT_TEST_FIXTURE(Test, testParaStyleBottomMargin2)
185 {
186     load(mpTestDocumentPath, "para-style-bottom-margin-2.rtf");
187     uno::Reference<beans::XPropertySet> xPropertySet(
188         getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
189     CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
190     CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP,
191                          getProperty<style::LineSpacing>(xPropertySet, "ParaLineSpacing").Mode);
192     CPPUNIT_ASSERT_EQUAL(sal_Int16(115),
193                          getProperty<style::LineSpacing>(xPropertySet, "ParaLineSpacing").Height);
194 
195     // the derived style contains \sa200, as does its parent
196     uno::Reference<beans::XPropertySet> xPropertySet1(
197         getStyles("ParagraphStyles")->getByName("List Paragraph"), uno::UNO_QUERY);
198     CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty<sal_Int32>(xPropertySet1, "ParaBottomMargin"));
199     CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP,
200                          getProperty<style::LineSpacing>(xPropertySet1, "ParaLineSpacing").Mode);
201     CPPUNIT_ASSERT_EQUAL(sal_Int16(115),
202                          getProperty<style::LineSpacing>(xPropertySet1, "ParaLineSpacing").Height);
203     // for the paragraph there is no \saN, so it should default to 0
204     auto const xPara(getParagraph(1));
205     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaBottomMargin"));
206     CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP,
207                          getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Mode);
208     CPPUNIT_ASSERT_EQUAL(sal_Int16(115),
209                          getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height);
210 }
211 
212 DECLARE_RTFEXPORT_TEST(testFdo66040, "fdo66040.rtf")
213 {
214     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
215     uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
216     // This was 0 (no shapes were imported), we want two textframes.
217     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
218 
219     // The second paragraph of the first shape should be actually a table, with "A" in its A1 cell.
220     uno::Reference<text::XTextRange> xTextRange(xDraws->getByIndex(0), uno::UNO_QUERY);
221     uno::Reference<text::XText> xText = xTextRange->getText();
222     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
223     CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(
224                                             xTable->getCellByName("A1"), uno::UNO_QUERY_THROW)
225                                             ->getString());
226 
227     // Make sure the second shape has the correct position and size.
228     uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(1), uno::UNO_QUERY);
229     CPPUNIT_ASSERT_EQUAL(sal_Int32(14420), getProperty<sal_Int32>(xShape, "HoriOrientPosition"));
230     CPPUNIT_ASSERT_EQUAL(sal_Int32(-1032), getProperty<sal_Int32>(xShape, "VertOrientPosition"));
231     CPPUNIT_ASSERT_EQUAL(sal_Int32(14000), xShape->getSize().Width);
232     CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), xShape->getSize().Height);
233 }
234 
235 DECLARE_RTFEXPORT_TEST(testFdo77996, "fdo77996.rtf")
236 {
237     // all styles were imported as name "0"
238     uno::Reference<container::XNameAccess> xChars(getStyles("CharacterStyles"));
239     CPPUNIT_ASSERT(!xChars->hasByName("0"));
240     CPPUNIT_ASSERT(xChars->hasByName("strong"));
241     CPPUNIT_ASSERT(xChars->hasByName("author"));
242     uno::Reference<container::XNameAccess> xParas(getStyles("ParagraphStyles"));
243     CPPUNIT_ASSERT(!xParas->hasByName("0"));
244     CPPUNIT_ASSERT(xParas->hasByName("extract2"));
245     // some document properties were lost
246     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(
247         mxComponent, uno::UNO_QUERY);
248     uno::Reference<document::XDocumentProperties> xProps(
249         xDocumentPropertiesSupplier->getDocumentProperties());
250     CPPUNIT_ASSERT_EQUAL(OUString("Aln Lin (Bei Jing)"), xProps->getAuthor());
251     OUString aTitle(u"\u53A6\u95E8\u94A8\u4E1A\u80A1\u4EFD\u6709\u9650\u516C\u53F8");
252     CPPUNIT_ASSERT_EQUAL(aTitle, xProps->getTitle());
253     uno::Reference<beans::XPropertySet> xUDProps(xProps->getUserDefinedProperties(),
254                                                  uno::UNO_QUERY);
255     CPPUNIT_ASSERT_EQUAL(OUString("jay"), getProperty<OUString>(xUDProps, "Operator"));
256 
257     // fdo#80486 also check that the ftnsep doesn't insert paragraph breaks
258     getParagraph(1, aTitle);
259 }
260 
261 DECLARE_RTFEXPORT_TEST(testFdo47802, "fdo47802.rtf")
262 {
263     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
264     uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
265     // Shape inside table was ignored.
266     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
267 }
268 
269 DECLARE_RTFEXPORT_TEST(testFdo39001, "fdo39001.rtf")
270 {
271     // Document was of 4 pages, \sect at the end of the doc wasn't ignored.
272     CPPUNIT_ASSERT_EQUAL(3, getPages());
273 }
274 
275 DECLARE_RTFEXPORT_TEST(testFdo54900, "fdo54900.rtf")
276 {
277     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
278     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
279                                                     uno::UNO_QUERY);
280     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
281     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
282     // Paragraph was aligned to left, should be center.
283     CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER,
284                          static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(
285                              getParagraphOfText(1, xCell->getText()), "ParaAdjust")));
286 }
287 
288 DECLARE_RTFEXPORT_TEST(testFdo64637, "fdo64637.rtf")
289 {
290     // The problem was that the custom "Company" property was added twice, the second invocation resulted in an exception.
291     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(
292         mxComponent, uno::UNO_QUERY);
293     uno::Reference<beans::XPropertySet> xPropertySet(
294         xDocumentPropertiesSupplier->getDocumentProperties()->getUserDefinedProperties(),
295         uno::UNO_QUERY);
296     CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getProperty<OUString>(xPropertySet, "Company"));
297 }
298 
299 DECLARE_RTFEXPORT_TEST(testN820504, "n820504.rtf")
300 {
301     // The shape was anchored at-page instead of at-character (that's incorrect as Word only supports at-character and as-character).
302     CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,
303                          getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
304 }
305 
306 DECLARE_RTFEXPORT_TEST(testFdo67498, "fdo67498.rtf")
307 {
308     // Left margin of the default page style wasn't set (was 2000).
309     CPPUNIT_ASSERT_EQUAL(
310         sal_Int32(convertTwipToMm100(5954)),
311         getProperty<sal_Int32>(getStyles("PageStyles")->getByName("Standard"), "LeftMargin"));
312 }
313 
314 DECLARE_RTFEXPORT_TEST(testFdo44715, "fdo44715.rtf")
315 {
316     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
317     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
318     // Style information wasn't reset, which caused character height to be 16.
319     CPPUNIT_ASSERT_EQUAL(12.f,
320                          getProperty<float>(getParagraphOfText(2, xCell->getText()), "CharHeight"));
321 }
322 
323 DECLARE_RTFEXPORT_TEST(testFdo68076, "fdo68076.rtf")
324 {
325     // Encoding of the last char was wrong (more 'o' than 'y').
326     OUString aExpected(u"\u041E\u0431\u044A\u0435\u043A\u0442 \u2013 \u0443");
327     getParagraph(1, aExpected);
328 }
329 
330 DECLARE_RTFEXPORT_TEST(testFdo70221, "fdo70221.rtf")
331 {
332     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
333     uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
334     // The picture was imported twice.
335     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
336 }
337 
338 DECLARE_RTFEXPORT_TEST(testCp1000018, "cp1000018.rtf")
339 {
340     // The problem was that the empty paragraph at the end of the footnote got
341     // lost during import.
342     uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
343     uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
344     uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
345 
346     OUString const aExpected = "Footnote first line." SAL_NEWLINE_STRING;
347     OUString const aActual = xTextRange->getString();
348 
349     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
350 }
351 
352 DECLARE_RTFEXPORT_TEST(testFdo94835, "fdo94835.rtf")
353 {
354     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
355     uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
356     // The picture was imported twice.
357     CPPUNIT_ASSERT_EQUAL(sal_Int32(19), xDraws->getCount());
358 }
359 DECLARE_RTFEXPORT_TEST(testNestedTable, "rhbz1065629.rtf")
360 {
361     // nested table in second cell was missing
362     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
363     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
364                                                     uno::UNO_QUERY);
365     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(1), uno::UNO_QUERY);
366     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
367     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
368     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
369     uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
370     CPPUNIT_ASSERT_EQUAL(OUString("Responsable Commercial:"), xPara->getString());
371     xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
372     xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY);
373     xParaEnum = xParaEnumAccess->createEnumeration();
374     xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
375     xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
376     CPPUNIT_ASSERT_EQUAL(OUString("Nom: John Doe"), xPara->getString());
377 
378     // outer table: background color, borders for B1/B2 cell
379     xTable.set(xTables->getByIndex(2), uno::UNO_QUERY);
380     xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
381     CPPUNIT_ASSERT(xCell.is());
382     table::BorderLine2 fullPtSolid(sal_Int32(COL_BLACK), 0, 35, 0, table::BorderLineStyle::SOLID,
383                                    35);
384     CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
385     CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid, getProperty<table::BorderLine2>(xCell, "RightBorder"));
386     CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid, getProperty<table::BorderLine2>(xCell, "TopBorder"));
387     CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid,
388                                 getProperty<table::BorderLine2>(xCell, "BottomBorder"));
389     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xCC0000), getProperty<sal_Int32>(xCell, "BackColor"));
390     xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
391     CPPUNIT_ASSERT(xCell.is());
392     table::BorderLine2 halfPtSolid(sal_Int32(COL_BLACK), 0, 18, 0, table::BorderLineStyle::SOLID,
393                                    18);
394     CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
395     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffffff),
396                          getProperty<sal_Int32>(xCell, "BackColor"));
397     xCell.set(xTable->getCellByName("B2"), uno::UNO_QUERY);
398     CPPUNIT_ASSERT(xCell.is());
399     CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
400     CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid, getProperty<table::BorderLine2>(xCell, "RightBorder"));
401     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffffff),
402                          getProperty<sal_Int32>(xCell, "BackColor"));
403 
404     // \sect at the end resulted in spurious page break
405     CPPUNIT_ASSERT_EQUAL(1, getPages());
406 }
407 
408 DECLARE_RTFEXPORT_TEST(testFooterPara, "footer-para.rtf")
409 {
410     // check that paragraph properties in footer are imported
411     uno::Reference<text::XText> xFooterText = getProperty<uno::Reference<text::XText>>(
412         getStyles("PageStyles")->getByName("First Page"), "FooterText");
413     uno::Reference<text::XTextContent> xParagraph = getParagraphOrTable(1, xFooterText);
414     CPPUNIT_ASSERT_EQUAL(
415         OUString("All Rights Reserved."),
416         uno::Reference<text::XTextRange>(xParagraph, uno::UNO_QUERY_THROW)->getString());
417     CPPUNIT_ASSERT_EQUAL(
418         sal_Int16(style::ParagraphAdjust_CENTER),
419         getProperty</*style::ParagraphAdjust*/ sal_Int16>(xParagraph, "ParaAdjust"));
420 }
421 
422 DECLARE_RTFEXPORT_TEST(testCp1000016, "hello.rtf")
423 {
424     // The single-line document had a second fake empty para on Windows.
425     bool bFound = true;
426     try
427     {
428         getParagraph(2);
429     }
430     catch (const container::NoSuchElementException&)
431     {
432         bFound = false;
433     }
434     CPPUNIT_ASSERT_EQUAL(false, bFound);
435 }
436 
437 DECLARE_RTFEXPORT_TEST(testFdo65090, "fdo65090.rtf")
438 {
439     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
440     uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
441                                                     uno::UNO_QUERY);
442     uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
443     uno::Reference<table::XTableRows> xTableRows = xTextTable->getRows();
444     // The first row had 3 cells, instead of a horizontally merged one and a normal one (2 -> 1 separator).
445     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<uno::Sequence<text::TableColumnSeparator>>(
446                                            xTableRows->getByIndex(0), "TableColumnSeparators")
447                                            .getLength());
448 }
449 
450 DECLARE_RTFEXPORT_TEST(testTableBorderDefaults, "fdo68779.rtf")
451 {
452     // table borders without \brdrw were not imported
453     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
454     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
455                                                     uno::UNO_QUERY);
456     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
457     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
458     CPPUNIT_ASSERT(xCell.is());
459     table::BorderLine2 solid(sal_Int32(COL_BLACK), 0, 26, 0, table::BorderLineStyle::SOLID, 26);
460     CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
461     CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty<table::BorderLine2>(xCell, "RightBorder"));
462     CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty<table::BorderLine2>(xCell, "TopBorder"));
463     CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty<table::BorderLine2>(xCell, "BottomBorder"));
464 
465     xTable.set(xTables->getByIndex(1), uno::UNO_QUERY);
466     xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
467     CPPUNIT_ASSERT(xCell.is());
468     table::BorderLine2 dotted(sal_Int32(COL_BLACK), 0, 26, 0, table::BorderLineStyle::DOTTED, 26);
469     CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
470     CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty<table::BorderLine2>(xCell, "RightBorder"));
471     CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty<table::BorderLine2>(xCell, "TopBorder"));
472     CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty<table::BorderLine2>(xCell, "BottomBorder"));
473 
474     xTable.set(xTables->getByIndex(2), uno::UNO_QUERY);
475     xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
476     CPPUNIT_ASSERT(xCell.is());
477     table::BorderLine2 doubled(sal_Int32(COL_BLACK), 26, 26, 26, table::BorderLineStyle::DOUBLE,
478                                79);
479     CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
480     CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty<table::BorderLine2>(xCell, "RightBorder"));
481     CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty<table::BorderLine2>(xCell, "TopBorder"));
482     CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty<table::BorderLine2>(xCell, "BottomBorder"));
483 
484     xTable.set(xTables->getByIndex(3), uno::UNO_QUERY);
485     xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
486     CPPUNIT_ASSERT(xCell.is());
487     table::BorderLine2 thinThickMG(sal_Int32(COL_BLACK), 14, 26, 14,
488                                    table::BorderLineStyle::THINTHICK_MEDIUMGAP, 53);
489     CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG, getProperty<table::BorderLine2>(xCell, "LeftBorder"));
490     CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG, getProperty<table::BorderLine2>(xCell, "RightBorder"));
491     CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG, getProperty<table::BorderLine2>(xCell, "TopBorder"));
492     CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG,
493                                 getProperty<table::BorderLine2>(xCell, "BottomBorder"));
494 }
495 
496 DECLARE_RTFEXPORT_TEST(testShpzDhgt, "shpz-dhgt.rtf")
497 {
498     // Test that shpz has priority over dhgt and not the other way around.
499     // Drawpage is sorted by ZOrder, so first should be red (back).
500     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), getProperty<sal_Int32>(getShape(1), "FillColor"));
501     // Second (front) should be green.
502     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00ff00), getProperty<sal_Int32>(getShape(2), "FillColor"));
503 }
504 
505 DECLARE_RTFEXPORT_TEST(testLevelfollow, "levelfollow.rtf")
506 {
507     uno::Reference<container::XIndexAccess> xNum1Levels
508         = getProperty<uno::Reference<container::XIndexAccess>>(
509             getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
510     CPPUNIT_ASSERT_EQUAL(
511         sal_Int16(SvxNumberFormat::LISTTAB),
512         comphelper::SequenceAsHashMap(xNum1Levels->getByIndex(0))["LabelFollowedBy"]
513             .get<sal_Int16>()); // first level, tab
514 
515     uno::Reference<container::XIndexAccess> xNum2Levels
516         = getProperty<uno::Reference<container::XIndexAccess>>(
517             getStyles("NumberingStyles")->getByName("WWNum2"), "NumberingRules");
518     CPPUNIT_ASSERT_EQUAL(
519         sal_Int16(SvxNumberFormat::SPACE),
520         comphelper::SequenceAsHashMap(xNum2Levels->getByIndex(0))["LabelFollowedBy"]
521             .get<sal_Int16>()); // first level, space
522 
523     uno::Reference<container::XIndexAccess> xNum3Levels
524         = getProperty<uno::Reference<container::XIndexAccess>>(
525             getStyles("NumberingStyles")->getByName("WWNum3"), "NumberingRules");
526     CPPUNIT_ASSERT_EQUAL(
527         sal_Int16(SvxNumberFormat::NOTHING),
528         comphelper::SequenceAsHashMap(xNum3Levels->getByIndex(0))["LabelFollowedBy"]
529             .get<sal_Int16>()); // first level, nothing
530 }
531 
532 DECLARE_RTFEXPORT_TEST(testCharColor, "char-color.rtf")
533 {
534     // This was -1: character color wasn't set.
535     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x365F91), getProperty<sal_Int32>(getParagraph(1), "CharColor"));
536 }
537 
538 DECLARE_RTFEXPORT_TEST(testFdo69289, "fdo69289.rtf")
539 {
540     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
541     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
542                                                     uno::UNO_QUERY);
543     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
544     uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
545     // There were only 2 cells (1 separators) in the table, should be 3 (2 separators).
546     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<uno::Sequence<text::TableColumnSeparator>>(
547                                            xTableRows->getByIndex(0), "TableColumnSeparators")
548                                            .getLength());
549 }
550 
551 DECLARE_RTFEXPORT_TEST(testDptxbxRelation, "dptxbx-relation.rtf")
552 {
553     // This was FRAME, not PAGE_FRAME, even if dobxpage is in the document.
554     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME,
555                          getProperty<sal_Int16>(getShape(1), "HoriOrientRelation"));
556 }
557 
558 DECLARE_RTFEXPORT_TEST(testDprectAnchor, "dprect-anchor.rtf")
559 {
560     // This was at-page, which is not something Word supports, so clearly an import error.
561     CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,
562                          getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
563 }
564 
565 DECLARE_RTFEXPORT_TEST(testFdo76628, "fdo76628.rtf")
566 {
567     OUString aExpected(u"\u041E\u0411\u0420\u0410\u0417\u0415\u0426");
568     // Should be 'SAMPLE' in Russian, was garbage.
569     getParagraph(1, aExpected);
570 
571     uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>(
572         getStyles("PageStyles")->getByName("Standard"), "HeaderText");
573     OUString aExpectedHeader(
574         u"\u041F\u043E\u0434\u0433\u043E\u0442\u043E\u0432\u043B\u0435\u043D\u043E");
575     // Should be 'prepared' in Russian, was garbage.
576     getParagraphOfText(1, xHeaderText, aExpectedHeader);
577 }
578 
579 DECLARE_RTFEXPORT_TEST(testFdo77267, "fdo77267.rtf")
580 {
581     // Paragraph was aligned to left, should be center.
582     CPPUNIT_ASSERT_EQUAL(
583         style::ParagraphAdjust_CENTER,
584         static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
585 }
586 
587 DECLARE_RTFEXPORT_TEST(testFdo75735, "fdo75735.rtf")
588 {
589     // Number of tabstops in the second paragraph should be 3, was 6.
590     CPPUNIT_ASSERT_EQUAL(
591         sal_Int32(3),
592         getProperty<uno::Sequence<style::TabStop>>(getParagraph(2), "ParaTabStops").getLength());
593 }
594 
595 DECLARE_RTFEXPORT_TEST(testFontOverride, "font-override.rtf")
596 {
597     // This was "Times New Roman".
598     CPPUNIT_ASSERT_EQUAL(OUString("Arial"),
599                          getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
600 }
601 
602 DECLARE_RTFEXPORT_TEST(testFdo73241, "fdo73241.rtf")
603 {
604     // This was 2, page break in table wasn't ignored.
605     CPPUNIT_ASSERT_EQUAL(1, getPages());
606 }
607 
608 DECLARE_RTFEXPORT_TEST(testFdo80905, "fdo80905.rtf")
609 {
610     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
611     uno::Reference<container::XEnumerationAccess> xFieldsAccess(
612         xTextFieldsSupplier->getTextFields());
613     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
614     xFields->nextElement();
615     // The problem was that there was only one field in the document, but there should be true.
616     CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(xFields->hasMoreElements()));
617 }
618 
619 DECLARE_RTFEXPORT_TEST(testFdo82106, "fdo82106.rtf")
620 {
621     // Tab was missing after footnote not containing a tab.
622     getParagraph(2, "before\tafter");
623 }
624 
625 DECLARE_RTFEXPORT_TEST(testFdo74229, "fdo74229.rtf")
626 {
627     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
628     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
629                                                     uno::UNO_QUERY);
630     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
631     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
632     // This was 0, due to ignoring RTF_TRGAPH.
633     CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(67)),
634                          getProperty<sal_Int32>(xCell, "RightBorderDistance"));
635 }
636 
637 DECLARE_RTFEXPORT_TEST(testFdo79959, "fdo79959.rtf")
638 {
639     // This was false, as the style was imported as " Test", i.e. no whitespace stripping.
640     CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(getStyles("ParagraphStyles")->hasByName("Test")));
641 }
642 
643 DECLARE_RTFEXPORT_TEST(testFdo82078, "fdo82078.rtf")
644 {
645     // This was awt::FontWeight::BOLD, i.e. the second run was bold, when it should be normal.
646     CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL,
647                          getProperty<float>(getRun(getParagraph(1), 2), "CharWeight"));
648 }
649 
650 DECLARE_RTFEXPORT_TEST(testCsBold, "cs-bold.rtf")
651 {
652     // This was awt::FontWeight::NORMAL, i.e. the first run was bold, when it should be bold (applied character style without direct formatting).
653     CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD,
654                          getProperty<float>(getRun(getParagraph(1), 1), "CharWeight"));
655 }
656 
657 DECLARE_RTFEXPORT_TEST(testFdo84679, "fdo84679.rtf")
658 {
659     // The problem was that the paragraph in A1 had some bottom margin, but it should not.
660     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
661     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
662                                                     uno::UNO_QUERY);
663     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
664     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
665     // This was 282.
666     CPPUNIT_ASSERT_EQUAL(
667         static_cast<sal_Int32>(0),
668         getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
669 }
670 
671 DECLARE_RTFEXPORT_TEST(testTdf123393, "tdf123393.rtf")
672 {
673     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
674     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
675                                                     uno::UNO_QUERY);
676     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
677     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
678     // Without the accompanying fix in place, this test would have failed with
679     // 'Expected: 7; Actual  : 10', i.e. font size was too large.
680     CPPUNIT_ASSERT_EQUAL(
681         7.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight"));
682 }
683 
684 DECLARE_RTFEXPORT_TEST(testFdo83464, "fdo83464.rtf")
685 {
686     // Problem was that the text in the textframe had wrong font.
687     uno::Reference<text::XTextRange> xFrameText(getShape(1), uno::UNO_QUERY);
688     CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xFrameText->getString());
689     // This was Times New Roman.
690     CPPUNIT_ASSERT_EQUAL(
691         OUString("Verdana"),
692         getProperty<OUString>(getRun(getParagraphOfText(1, xFrameText->getText()), 1),
693                               "CharFontName"));
694 }
695 
696 DECLARE_RTFEXPORT_TEST(testFdo86761, "fdo86761.rtf")
697 {
698     // This was 26, even if the picture should have no border, due to fLine=0.
699     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0),
700                          getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineWidth);
701 }
702 
703 DECLARE_RTFEXPORT_TEST(testFdo82859, "fdo82859.rtf")
704 {
705     // This was 0: "0xffffff" was converted to 0, i.e. the background was black instead of the default.
706     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1),
707                          getProperty<sal_Int32>(getShape(1), "BackColor"));
708 }
709 
710 DECLARE_RTFEXPORT_TEST(testFdo82076, "fdo82076.rtf")
711 {
712     // Footnote position was wrong: should be at the end of the B1 cell.
713     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
714     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
715                                                     uno::UNO_QUERY);
716     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
717     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
718     // This resulted in container::NoSuchElementException: the footnote was at the start of the A1 cell.
719     CPPUNIT_ASSERT_EQUAL(OUString("Footnote"),
720                          getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 2),
721                                                "TextPortionType"));
722 }
723 
724 DECLARE_RTFEXPORT_TEST(testFdo83204, "fdo83204.rtf")
725 {
726     // This was Standard, \sN was ignored after \bkmkstart and \pard.
727     CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
728                          getProperty<OUString>(getParagraph(1), "ParaStyleName"));
729 }
730 
731 DECLARE_RTFEXPORT_TEST(testFdo85889pc, "fdo85889-pc.rtf")
732 {
733     uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
734 
735     OUString aExpected(u"\u00B1\u2265\u2264");
736     CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
737 }
738 
739 DECLARE_RTFEXPORT_TEST(testFdo85889pca, "fdo85889-pca.rtf")
740 {
741     uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
742 
743     OUString aExpected(u"\u00B1\u2017\u00BE");
744     CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
745 }
746 
747 DECLARE_RTFEXPORT_TEST(testFdo85889mac, "fdo85889-mac.rtf")
748 {
749     uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
750 
751     OUString aExpected(u"\u00D2\u00DA\u00DB");
752     CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
753 }
754 
755 DECLARE_RTFEXPORT_TEST(testFdo72031, "fdo72031.rtf")
756 {
757     OUString aExpected(u"\uF0C5");
758     CPPUNIT_ASSERT_EQUAL(aExpected, getRun(getParagraph(1), 1)->getString());
759 }
760 
761 DECLARE_RTFEXPORT_TEST(testFdo86750, "fdo86750.rtf")
762 {
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"));
766 }
767 
768 DECLARE_RTFEXPORT_TEST(testTdf88811, "tdf88811.rtf")
769 {
770     // The problem was that shapes anchored to the paragraph that is moved into a textframe were lost, so this was 2.
771     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
772     uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
773     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xDrawPage->getCount());
774 }
775 
776 DECLARE_RTFEXPORT_TEST(testFdo49893_2, "fdo49893-2.rtf")
777 {
778     // Ensure that header text exists on each page (especially on second page)
779     CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[1]/header/txt/text()"));
780     CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[2]/header/txt/text()"));
781     CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[3]/header/txt/text()"));
782 }
783 
784 DECLARE_RTFEXPORT_TEST(testFdo89496, "fdo89496.rtf")
785 {
786     // Just ensure that document is loaded and shape exists
787     uno::Reference<drawing::XShape> xShape = getShape(1);
788     CPPUNIT_ASSERT(xShape.is());
789 }
790 
791 DECLARE_RTFEXPORT_TEST(testFdo75614, "tdf75614.rtf")
792 {
793     // Text after the footnote was missing, so this resulted in a css::container::NoSuchElementException.
794     CPPUNIT_ASSERT_EQUAL(OUString("after."), getRun(getParagraph(1), 3)->getString());
795 }
796 
797 DECLARE_RTFEXPORT_TEST(mathtype, "mathtype.rtf")
798 {
799     OUString aFormula = getFormula(getRun(getParagraph(1), 1));
800     CPPUNIT_ASSERT(!aFormula.isEmpty());
801 }
802 
803 DECLARE_RTFEXPORT_TEST(testTdf86182, "tdf86182.rtf")
804 {
805     // Writing mode was the default, i.e. text::WritingMode2::CONTEXT.
806     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB,
807                          getProperty<sal_Int16>(getParagraph(1), "WritingMode"));
808 }
809 
810 DECLARE_RTFEXPORT_TEST(testTdf91074, "tdf91074.rtf")
811 {
812     // The file failed to load, as the border color was imported using the LineColor UNO property.
813     uno::Reference<drawing::XShape> xShape = getShape(1);
814     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_LIGHTRED),
815                          getProperty<table::BorderLine2>(xShape, "TopBorder").Color);
816 }
817 
818 DECLARE_RTFEXPORT_TEST(testTdf90260Nopar, "hello.rtf")
819 {
820     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
821     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
822     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
823     paste("rtfexport/data/tdf90260-nopar.rtf", xEnd);
824     CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
825 }
826 
827 DECLARE_RTFEXPORT_TEST(testTdf86814, "tdf86814.rtf")
828 {
829     // This was awt::FontWeight::NORMAL, i.e. the first run wasn't bold, when it should be bold (applied paragraph style with direct formatting).
830     CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD,
831                          getProperty<float>(getRun(getParagraph(1), 1), "CharWeight"));
832 }
833 
834 DECLARE_RTFEXPORT_TEST(testTdf108416, "tdf108416.rtf")
835 {
836     uno::Reference<container::XNameAccess> xCharacterStyles(getStyles("CharacterStyles"));
837     uno::Reference<beans::XPropertySet> xListLabel(xCharacterStyles->getByName("ListLabel 1"),
838                                                    uno::UNO_QUERY);
839     // This was awt::FontWeight::BOLD, list numbering got an unexpected bold formatting.
840     CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xListLabel, "CharWeight"));
841 }
842 
843 DECLARE_RTFEXPORT_TEST(testBinSkipping, "bin-skipping.rtf")
844 {
845     // before, it was importing '/nMUST NOT IMPORT'
846     CPPUNIT_ASSERT_EQUAL(OUString("text"), getRun(getParagraph(1), 1)->getString());
847 }
848 
849 DECLARE_RTFEXPORT_TEST(testTdf92061, "tdf92061.rtf")
850 {
851     // This was "C", i.e. part of the footnote ended up in the body text.
852     CPPUNIT_ASSERT_EQUAL(OUString("body-after"), getRun(getParagraph(1), 3)->getString());
853 }
854 
855 DECLARE_RTFEXPORT_TEST(testTdf92481, "tdf92481.rtf")
856 {
857     // This was 0, RTF_WIDOWCTRL was not imported.
858     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int8>(2),
859                          getProperty<sal_Int8>(getParagraph(1), "ParaWidows"));
860 }
861 
862 DECLARE_RTFEXPORT_TEST(testTdf94456, "tdf94456.rtf")
863 {
864     // Paragraph left margin and first line indent wasn't imported correctly.
865 
866     // This was 1270.
867     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(762),
868                          getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
869     // This was -635.
870     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-762),
871                          getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent"));
872 }
873 
874 DECLARE_RTFEXPORT_TEST(testTdf94435, "tdf94435.rtf")
875 {
876     // This was style::ParagraphAdjust_LEFT, \ltrpar undone the effect of \qc.
877     CPPUNIT_ASSERT_EQUAL(
878         style::ParagraphAdjust_CENTER,
879         static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
880 }
881 
882 DECLARE_RTFEXPORT_TEST(testTdf54584, "tdf54584.rtf")
883 {
884     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
885     uno::Reference<container::XEnumerationAccess> xFieldsAccess(
886         xTextFieldsSupplier->getTextFields());
887     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
888     // \PAGE was ignored, so no fields were in document -> exception was thrown
889     CPPUNIT_ASSERT_NO_THROW_MESSAGE(
890         "No fields in document found: field \"\\PAGE\" was not properly read",
891         xFields->nextElement());
892 }
893 
894 DECLARE_RTFEXPORT_TEST(testTdf96308Deftab, "tdf96308-deftab.rtf")
895 {
896     uno::Reference<lang::XMultiServiceFactory> xTextFactory(mxComponent, uno::UNO_QUERY);
897     uno::Reference<beans::XPropertySet> xDefaults(
898         xTextFactory->createInstance("com.sun.star.text.Defaults"), uno::UNO_QUERY);
899     // This was 1270 as \deftab was ignored on import.
900     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(284)),
901                          getProperty<sal_Int32>(xDefaults, "TabStopDistance"));
902 }
903 
904 DECLARE_RTFEXPORT_TEST(testLandscape, "landscape.rtf")
905 {
906     // Check landscape flag.
907     CPPUNIT_ASSERT_EQUAL(3, getPages());
908 
909     // All pages should have flag orientation
910     uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles");
911 
912     // get a page cursor
913     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
914     uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
915         xModel->getCurrentController(), uno::UNO_QUERY);
916     uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(),
917                                               uno::UNO_QUERY);
918 
919     // check that the first page has landscape flag
920     xCursor->jumpToFirstPage();
921     OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
922     uno::Reference<style::XStyle> xStylePage(pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
923     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStylePage, "IsLandscape"));
924 
925     // check that the second page has landscape flag
926     xCursor->jumpToPage(2);
927     pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
928     xStylePage.set(pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
929     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStylePage, "IsLandscape"));
930 
931     // check that the last page has landscape flag
932     xCursor->jumpToLastPage();
933     pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
934     xStylePage.set(pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
935     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStylePage, "IsLandscape"));
936 }
937 
938 DECLARE_RTFEXPORT_TEST(testTdf97035, "tdf97035.rtf")
939 {
940     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
941     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
942                                                     uno::UNO_QUERY);
943     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
944 
945     // First cell width of the second row should be 2300
946     uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
947     CPPUNIT_ASSERT_EQUAL(sal_Int16(2300), getProperty<uno::Sequence<text::TableColumnSeparator>>(
948                                               xTableRows->getByIndex(1), "TableColumnSeparators")[0]
949                                               .Position);
950 }
951 
952 DECLARE_RTFEXPORT_TEST(testTdf87034, "tdf87034.rtf")
953 {
954     // This was A1BC34D, i.e. the first "super" text portion was mis-imported,
955     // and was inserted instead right before the second "super" text portion.
956     CPPUNIT_ASSERT_EQUAL(OUString("A1B3C4D"), getParagraph(1)->getString());
957 }
958 
959 DECLARE_RTFEXPORT_TEST(testClassificatonPasteLevels, "classification-confidential.rtf")
960 {
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();
964 
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("rtfexport/data/classification-yes.rtf", xEnd);
969     CPPUNIT_ASSERT_EQUAL(aOld, xText->getString());
970 }
971 
972 DECLARE_RTFEXPORT_TEST(testTdf95707, "tdf95707.rtf")
973 {
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);
979 }
980 
981 DECLARE_RTFEXPORT_TEST(testTdf96275, "tdf96275.rtf")
982 {
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"));
989 }
990 
991 DECLARE_RTFEXPORT_TEST(testTdf82073, "tdf82073.rtf")
992 {
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"));
997 }
998 
999 DECLARE_RTFEXPORT_TEST(testTdf74795, "tdf74795.rtf")
1000 {
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"));
1006 
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"));
1011 }
1012 
1013 DECLARE_RTFEXPORT_TEST(testTdf77349, "tdf77349.rtf")
1014 {
1015     uno::Reference<container::XNamed> xImage(getShape(1), uno::UNO_QUERY);
1016     // This was empty: imported image wasn't named automatically.
1017     CPPUNIT_ASSERT_EQUAL(OUString("Image1"), xImage->getName());
1018 }
1019 
1020 DECLARE_RTFEXPORT_TEST(testTdf50821, "tdf50821.rtf")
1021 {
1022     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2), uno::UNO_QUERY);
1023     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1024     // This was 0, \trpaddfl was mishandled on import.
1025     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(191),
1026                          getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
1027 }
1028 
1029 DECLARE_RTFEXPORT_TEST(testTdf100507, "tdf100507.rtf")
1030 {
1031     // This was 0: left margin of the first paragraph was lost on import.
1032     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6618),
1033                          getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
1034 }
1035 
1036 DECLARE_RTFEXPORT_TEST(testTdf44986, "tdf44986.rtf")
1037 {
1038     // Check that the table at the second paragraph.
1039     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2), uno::UNO_QUERY);
1040     uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
1041     // Check the first row of the table, it should have two cells (one separator).
1042     // This was 0: the first row had no separators, so it had only one cell, which was too wide.
1043     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<uno::Sequence<text::TableColumnSeparator>>(
1044                                            xTableRows->getByIndex(0), "TableColumnSeparators")
1045                                            .getLength());
1046 }
1047 
1048 DECLARE_RTFEXPORT_TEST(testTdf90697, "tdf90697.rtf")
1049 {
1050     // We want section breaks to be seen as section breaks, not as page breaks,
1051     // so this document should have only one page, not three.
1052     CPPUNIT_ASSERT_EQUAL(1, getPages());
1053 }
1054 
1055 DECLARE_RTFEXPORT_TEST(testTdf104317, "tdf104317.rtf")
1056 {
1057     // This failed to load, we tried to set CustomShapeGeometry on a line shape.
1058     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1059     uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
1060     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDrawPage->getCount());
1061 }
1062 
1063 DECLARE_RTFEXPORT_TEST(testTdf104744, "tdf104744.rtf")
1064 {
1065     auto xRules = getProperty<uno::Reference<container::XIndexAccess>>(
1066         getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
1067     comphelper::SequenceAsHashMap aRule(xRules->getByIndex(0));
1068     // This was 0.
1069     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), aRule["IndentAt"].get<sal_Int32>());
1070 }
1071 
1072 DECLARE_RTFEXPORT_TEST(testTdf105852, "tdf105852.rtf")
1073 {
1074     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1075     uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
1076                                                     uno::UNO_QUERY);
1077     uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1078     uno::Reference<table::XTableRows> xTableRows = xTextTable->getRows();
1079     // All rows but last were merged -> there were only 2 rows
1080     CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTableRows->getCount());
1081     // The first row must have 4 cells.
1082     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty<uno::Sequence<text::TableColumnSeparator>>(
1083                                            xTableRows->getByIndex(0), "TableColumnSeparators")
1084                                            .getLength());
1085     // The third row must have 1 merged cell.
1086     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<uno::Sequence<text::TableColumnSeparator>>(
1087                                            xTableRows->getByIndex(2), "TableColumnSeparators")
1088                                            .getLength());
1089 }
1090 
1091 DECLARE_RTFEXPORT_TEST(testTdf104287, "tdf104287.rtf")
1092 {
1093     uno::Reference<text::XTextContent> xShape(getShape(1), uno::UNO_QUERY);
1094     CPPUNIT_ASSERT(xShape.is());
1095     // This failed, the bitmap had no valid anchor.
1096     CPPUNIT_ASSERT(xShape->getAnchor().is());
1097 }
1098 
1099 DECLARE_RTFEXPORT_TEST(testTdf105729, "tdf105729.rtf")
1100 {
1101     // This was style::ParagraphAdjust_LEFT, \ltrpar undone the effect of \qc from style.
1102     CPPUNIT_ASSERT_EQUAL(
1103         style::ParagraphAdjust_CENTER,
1104         static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
1105 }
1106 
1107 DECLARE_RTFEXPORT_TEST(testTdf106694, "tdf106694.rtf")
1108 {
1109     auto aTabs = getProperty<uno::Sequence<style::TabStop>>(getParagraph(1), "ParaTabStops");
1110     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aTabs.getLength());
1111     // This was 0, tab position was incorrect, looked like it was missing.
1112     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(14605), aTabs[0].Position);
1113 }
1114 
1115 DECLARE_RTFEXPORT_TEST(testTdf107116, "tdf107116.rtf")
1116 {
1117     // This was 0, upper border around text (and its distance) was missing.
1118     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(120)),
1119                          getProperty<sal_Int32>(getParagraph(2), "TopBorderDistance"));
1120 }
1121 
1122 DECLARE_RTFEXPORT_TEST(testTdf106950, "tdf106950.rtf")
1123 {
1124     uno::Reference<text::XTextRange> xPara(getParagraph(1));
1125     // This was ParagraphAdjust_LEFT, trying to set CharShadingValue on a
1126     // paragraph style thrown an exception, and remaining properties were not
1127     // set.
1128     CPPUNIT_ASSERT_EQUAL(
1129         style::ParagraphAdjust_CENTER,
1130         static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xPara, "ParaAdjust")));
1131 }
1132 
1133 DECLARE_RTFEXPORT_TEST(testTdf116371, "tdf116371.odt")
1134 {
1135     auto xShape(getShape(1));
1136     // Without the accompanying fix in place, this test would have failed with
1137     // 'Unknown property: RotateAngle', i.e. export lost the rotation, and then
1138     // import created a Writer picture (instead of a Draw one).
1139     CPPUNIT_ASSERT_DOUBLES_EQUAL(4700.0, getProperty<double>(xShape, "RotateAngle"), 10);
1140 }
1141 
1142 DECLARE_RTFEXPORT_TEST(testTdf133437, "tdf133437.rtf")
1143 {
1144     CPPUNIT_ASSERT_EQUAL(3, getPages());
1145 
1146     // Check total amount of shapes
1147     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1148     uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
1149     CPPUNIT_ASSERT_EQUAL(sal_Int32(560), xDraws->getCount()); // 285 \shp + 275 \poswX
1150 
1151     xmlDocPtr pDump = parseLayoutDump();
1152     // Count shapes on first page
1153     {
1154         xmlXPathObjectPtr pXmlObj
1155             = getXPathNode(pDump, "/root/page[1]/body/txt[1]/anchored/SwAnchoredDrawObject");
1156         xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
1157         sal_Int32 shapesOnPage = xmlXPathNodeSetGetLength(pXmlNodes);
1158         xmlXPathFreeObject(pXmlObj);
1159         CPPUNIT_ASSERT_EQUAL(sal_Int32(79), shapesOnPage);
1160     }
1161     // Second page
1162     {
1163         xmlXPathObjectPtr pXmlObj
1164             = getXPathNode(pDump, "/root/page[2]/body/txt[2]/anchored/SwAnchoredDrawObject");
1165         xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
1166         sal_Int32 shapesOnPage = xmlXPathNodeSetGetLength(pXmlNodes);
1167         xmlXPathFreeObject(pXmlObj);
1168         CPPUNIT_ASSERT_EQUAL(sal_Int32(120), shapesOnPage);
1169     }
1170     // Third page
1171     {
1172         xmlXPathObjectPtr pXmlObj
1173             = getXPathNode(pDump, "/root/page[3]/body/txt[2]/anchored/SwAnchoredDrawObject");
1174         xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
1175         sal_Int32 shapesOnPage = xmlXPathNodeSetGetLength(pXmlNodes);
1176         xmlXPathFreeObject(pXmlObj);
1177         CPPUNIT_ASSERT_EQUAL(sal_Int32(86), shapesOnPage);
1178     }
1179 }
1180 
1181 DECLARE_RTFEXPORT_TEST(testTdf128320, "tdf128320.odt")
1182 {
1183     // Shape does exist in RTF output
1184     auto xShape(getShape(1));
1185     CPPUNIT_ASSERT(xShape.is());
1186 
1187     // Let's see what is inside output RTF file
1188     SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
1189     CPPUNIT_ASSERT(pStream);
1190     OString aRtfContent(read_uInt8s_ToOString(*pStream, pStream->TellEnd()));
1191 
1192     // There are some RTF tokens for shape props
1193     // They are much more inside, but let's use \shpwr2 as an inducator
1194     sal_Int32 nPos = aRtfContent.indexOf("\\shpwr2", 0);
1195     CPPUNIT_ASSERT(nPos > 0);
1196 
1197     // It goes AFTER shape instruction (sadly here we do not check if it is contaned inside)
1198     sal_Int32 nPosShp = aRtfContent.indexOf("\\shpinst", 0);
1199     CPPUNIT_ASSERT(nPosShp > 0);
1200 
1201     // But there are no more shape properties!
1202     nPos = aRtfContent.indexOf("\\shpwr2", nPos + 1);
1203     CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), nPos);
1204 }
1205 
1206 DECLARE_RTFEXPORT_TEST(testTdf129513, "tdf129513.rtf")
1207 {
1208     // \pagebb after \intbl must not reset the "in table" flag
1209     CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
1210     // Make sure the first paragraph is imported in table
1211     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY_THROW);
1212     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getCellNames().getLength());
1213     uno::Reference<text::XText> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY_THROW);
1214     CPPUNIT_ASSERT_EQUAL(OUString("In table"), xCell->getString());
1215 }
1216 
1217 CPPUNIT_PLUGIN_IMPLEMENT();
1218 
1219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1220