tdf#116883: sw: support for lists level format string
[LibreOffice.git] / sw / qa / extras / rtfexport / rtfexport.cxx
blob535374da886344fd61c8285e641978cbe203cc0c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <swmodeltestbase.hxx>
12 #include <com/sun/star/awt/Gradient.hpp>
13 #include <com/sun/star/awt/XBitmap.hpp>
14 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
15 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
16 #include <com/sun/star/drawing/FillStyle.hpp>
17 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
18 #include <com/sun/star/style/PageStyleLayout.hpp>
19 #include <com/sun/star/table/BorderLine2.hpp>
20 #include <com/sun/star/table/ShadowFormat.hpp>
21 #include <com/sun/star/text/FontEmphasis.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/XTextViewCursorSupplier.hpp>
28 #include <com/sun/star/text/WritingMode2.hpp>
29 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
30 #include <com/sun/star/text/RubyAdjust.hpp>
31 #include <com/sun/star/text/RubyPosition.hpp>
32 #include <com/sun/star/text/XTextColumns.hpp>
33 #include <com/sun/star/text/HoriOrientation.hpp>
35 class Test : public SwModelTestBase
37 public:
38 Test()
39 : SwModelTestBase("/sw/qa/extras/rtfexport/data/", "Rich Text Format")
43 bool mustTestImportOf(const char* filename) const override
45 // Don't test the first import of these, for some reason those tests fail
46 const char* aBlacklist[] = {
47 "math-eqarray.rtf", "math-escaping.rtf", "math-lim.rtf",
48 "math-mso2007.rtf", "math-nary.rtf", "math-rad.rtf",
49 "math-vertical-stacks.rtf", "math-runs.rtf",
51 std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist));
53 // If the testcase is stored in some other format, it's pointless to test.
54 return (OString(filename).endsWith(".rtf")
55 && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end());
58 virtual void postLoad(const char* pFilename) override
60 if (OString(pFilename) == "tdf90421.fodt")
62 // Change the hyperlink, so its URL is empty.
63 uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 2), uno::UNO_QUERY);
64 xRun->setPropertyValue("HyperLinkURL", uno::makeAny(OUString()));
69 DECLARE_RTFEXPORT_TEST(testZoom, "zoom.rtf")
71 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
72 uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(
73 xModel->getCurrentController(), uno::UNO_QUERY);
74 uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings());
75 sal_Int16 nValue = 0;
76 xPropertySet->getPropertyValue("ZoomValue") >>= nValue;
77 CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue);
80 DECLARE_RTFEXPORT_TEST(testFdo38176, "fdo38176.rtf") { CPPUNIT_ASSERT_EQUAL(9, getLength()); }
82 DECLARE_RTFEXPORT_TEST(testFdo49683, "fdo49683.rtf")
84 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(
85 mxComponent, uno::UNO_QUERY);
86 uno::Reference<document::XDocumentProperties> xDocumentProperties(
87 xDocumentPropertiesSupplier->getDocumentProperties());
88 uno::Sequence<OUString> aKeywords(xDocumentProperties->getKeywords());
89 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aKeywords.getLength());
90 CPPUNIT_ASSERT_EQUAL(OUString("one"), aKeywords[0]);
91 CPPUNIT_ASSERT_EQUAL(OUString("two"), aKeywords[1]);
94 DECLARE_RTFEXPORT_TEST(testFdo44174, "fdo44174.rtf")
96 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
97 uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
98 xModel->getCurrentController(), uno::UNO_QUERY);
99 uno::Reference<beans::XPropertySet> xPropertySet(xTextViewCursorSupplier->getViewCursor(),
100 uno::UNO_QUERY);
101 OUString aValue;
102 xPropertySet->getPropertyValue("PageStyleName") >>= aValue;
103 CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aValue);
106 DECLARE_RTFEXPORT_TEST(testFdo50087, "fdo50087.rtf")
108 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(
109 mxComponent, uno::UNO_QUERY);
110 uno::Reference<document::XDocumentProperties> xDocumentProperties(
111 xDocumentPropertiesSupplier->getDocumentProperties());
112 CPPUNIT_ASSERT_EQUAL(OUString("Title"), xDocumentProperties->getTitle());
113 CPPUNIT_ASSERT_EQUAL(OUString("Subject"), xDocumentProperties->getSubject());
114 CPPUNIT_ASSERT_EQUAL(OUString("First line.\nSecond line."),
115 xDocumentProperties->getDescription());
118 DECLARE_RTFEXPORT_TEST(testFdo50831, "fdo50831.rtf")
120 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
121 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
122 uno::UNO_QUERY);
123 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
124 uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
125 float fValue = 0;
126 xPropertySet->getPropertyValue("CharHeight") >>= fValue;
127 CPPUNIT_ASSERT_EQUAL(10.f, fValue);
130 DECLARE_RTFEXPORT_TEST(testFdo48335, "fdo48335.odt")
133 * The problem was that we exported a fake pagebreak, make sure it's just a soft one now.
135 * oParas = ThisComponent.Text.createEnumeration
136 * oPara = oParas.nextElement
137 * oPara = oParas.nextElement
138 * oPara = oParas.nextElement
139 * oRuns = oPara.createEnumeration
140 * oRun = oRuns.nextElement
141 * xray oRun.TextPortionType 'was Text, should be SoftPageBreak
143 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
144 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
145 uno::UNO_QUERY);
146 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
147 for (int i = 0; i < 2; i++)
148 xParaEnum->nextElement();
149 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(),
150 uno::UNO_QUERY);
151 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
152 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
153 OUString aValue;
154 xPropertySet->getPropertyValue("TextPortionType") >>= aValue;
155 CPPUNIT_ASSERT_EQUAL(OUString("SoftPageBreak"), aValue);
158 DECLARE_RTFEXPORT_TEST(testFdo38244, "fdo38244.rtf")
160 // See ooxmlexport's testFdo38244().
161 // Test comment range feature.
162 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
163 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
164 uno::UNO_QUERY);
165 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
166 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(),
167 uno::UNO_QUERY);
168 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
169 xRunEnum->nextElement();
170 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
171 CPPUNIT_ASSERT_EQUAL(OUString("Annotation"),
172 getProperty<OUString>(xPropertySet, "TextPortionType"));
173 xRunEnum->nextElement();
174 xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
175 CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"),
176 getProperty<OUString>(xPropertySet, "TextPortionType"));
178 // Test initials.
179 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
180 uno::Reference<container::XEnumerationAccess> xFieldsAccess(
181 xTextFieldsSupplier->getTextFields());
182 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
183 xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
184 CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
187 DECLARE_RTFEXPORT_TEST(testCommentsNested, "comments-nested.odt")
189 uno::Reference<beans::XPropertySet> xOuter(
190 getProperty<uno::Reference<beans::XPropertySet>>(getRun(getParagraph(1), 2), "TextField"),
191 uno::UNO_QUERY);
192 CPPUNIT_ASSERT_EQUAL(OUString("Outer"), getProperty<OUString>(xOuter, "Content").trim());
194 uno::Reference<beans::XPropertySet> xInner(
195 getProperty<uno::Reference<beans::XPropertySet>>(getRun(getParagraph(1), 4), "TextField"),
196 uno::UNO_QUERY);
197 CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content").trim());
200 DECLARE_RTFEXPORT_TEST(testMathAccents, "math-accents.rtf")
202 OUString aActual = getFormula(getRun(getParagraph(1), 1));
203 OUString const aExpected("acute {a} grave {a} check {a} breve {a} circle {a} widevec {a} "
204 "widetilde {a} widehat {a} dot {a} widevec {a} widevec {a} widetilde "
205 "{a} underline {a}");
206 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
209 DECLARE_RTFEXPORT_TEST(testMathEqarray, "math-eqarray.rtf")
211 OUString aActual = getFormula(getRun(getParagraph(1), 1));
212 OUString const aExpected(
213 "y = left lbrace stack { 0 , x < 0 # 1 , x = 0 # {x} ^ {2} , x > 0 } right none");
214 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
217 DECLARE_RTFEXPORT_TEST(testMathD, "math-d.rtf")
219 OUString aActual = getFormula(getRun(getParagraph(1), 1));
220 OUString const aExpected("left (x mline y mline z right ) left (1 right ) left [2 right ] left "
221 "ldbracket 3 right rdbracket left lline 4 right rline left ldline 5 "
222 "right rdline left langle 6 right rangle left langle a mline b right "
223 "rangle left ({x} over {y} right )");
224 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
227 DECLARE_RTFEXPORT_TEST(testMathEscaping, "math-escaping.rtf")
229 OUString aActual = getFormula(getRun(getParagraph(1), 1));
230 OUString aExpected(u"\u00E1 \\{");
231 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
234 DECLARE_RTFEXPORT_TEST(testMathLim, "math-lim.rtf")
236 OUString aActual = getFormula(getRun(getParagraph(1), 1));
237 OUString aExpected(u"lim from {x \u2192 1} {x}");
238 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
241 DECLARE_RTFEXPORT_TEST(testMathMatrix, "math-matrix.rtf")
243 OUString aActual = getFormula(getRun(getParagraph(1), 1));
244 OUString const aExpected("left [matrix {1 # 2 ## 3 # 4} right ]");
245 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
248 DECLARE_RTFEXPORT_TEST(testMathBox, "math-mbox.rtf")
250 OUString aActual = getFormula(getRun(getParagraph(1), 1));
251 OUString const aExpected("a");
252 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
255 DECLARE_RTFEXPORT_TEST(testMathMso2007, "math-mso2007.rtf")
257 OUString aActual = getFormula(getRun(getParagraph(1), 1));
258 OUString aExpected(u"A = \u03C0 {r} ^ {2}");
259 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
261 aActual = getFormula(getRun(getParagraph(2), 1));
262 aExpected = OUString(u"{left (x + a right )} ^ {n} = sum from {k = 0} to {n} {left (stack { n "
263 u"# k } right ) {x} ^ {k} {a} ^ {n \u2212 k}}");
264 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
266 aActual = getFormula(getRun(getParagraph(3), 1));
267 aExpected = OUString(u"{left (1 + x right )} ^ {n} = 1 + {nx} over {1 !} + {n left (n \u2212 1 "
268 u"right ) {x} ^ {2}} over {2 !} + \u2026");
269 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
271 aActual = getFormula(getRun(getParagraph(4), 1));
272 aExpected = OUString(u"f left (x right ) = {a} rsub {0} + sum from {n = 1} to {\u221E} {left "
273 u"({a} rsub {n} cos {n\u03C0x} over {L} + {b} rsub {n} sin {n\u03C0x} "
274 u"over {L} right )}");
275 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
277 aActual = getFormula(getRun(getParagraph(5), 1));
278 aExpected = "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}";
279 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
281 aActual = getFormula(getRun(getParagraph(6), 1));
282 aExpected = OUString(u"x = {\u2212 b \u00B1 sqrt {{b} ^ {2} \u2212 4 ac}} over {2 a}");
283 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
285 aActual = getFormula(getRun(getParagraph(7), 1));
286 aExpected = OUString(u"{e} ^ {x} = 1 + {x} over {1 !} + {{x} ^ {2}} over {2 !} + {{x} ^ {3}} "
287 u"over {3 !} + \u2026 , \u2212 \u221E < x < \u221E");
288 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
290 aActual = getFormula(getRun(getParagraph(8), 1));
291 aExpected = OUString(u"sin \u03B1 \u00B1 sin \u03B2 = 2 sin {1} over {2} left (\u03B1 \u00B1 "
292 u"\u03B2 right ) cos {1} over {2} left (\u03B1 \u2213 \u03B2 right )");
293 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
295 aActual = getFormula(getRun(getParagraph(9), 1));
296 aExpected = OUString(u"cos \u03B1 + cos \u03B2 = 2 cos {1} over {2} left (\u03B1 + \u03B2 "
297 u"right ) cos {1} over {2} left (\u03B1 \u2212 \u03B2 right )");
298 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
301 DECLARE_RTFEXPORT_TEST(testMathNary, "math-nary.rtf")
303 OUString aActual = getFormula(getRun(getParagraph(1), 1));
304 OUString const aExpected("lllint from {1} to {2} {x + 1} prod from {a} {b} sum to {2} {x}");
305 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
308 DECLARE_RTFEXPORT_TEST(testMathLimupp, "math-limupp.rtf")
310 OUString aActual = getFormula(getRun(getParagraph(1), 1));
311 CPPUNIT_ASSERT_EQUAL(OUString("{abcd} overbrace {4}"), aActual);
313 aActual = getFormula(getRun(getParagraph(2), 1));
314 CPPUNIT_ASSERT_EQUAL(OUString("{xyz} underbrace {3}"), aActual);
317 DECLARE_RTFEXPORT_TEST(testMathStrikeh, "math-strikeh.rtf")
319 OUString aActual = getFormula(getRun(getParagraph(1), 1));
320 CPPUNIT_ASSERT_EQUAL(OUString("overstrike {abc}"), aActual);
323 DECLARE_RTFEXPORT_TEST(testMathPlaceholders, "math-placeholders.rtf")
325 OUString aActual = getFormula(getRun(getParagraph(1), 1));
326 CPPUNIT_ASSERT_EQUAL(OUString("sum from <?> to <?> <?>"), aActual);
329 DECLARE_RTFEXPORT_TEST(testMathRad, "math-rad.rtf")
331 OUString aActual = getFormula(getRun(getParagraph(1), 1));
332 CPPUNIT_ASSERT_EQUAL(OUString("sqrt {4} nroot {3} {x + 1}"), aActual);
335 DECLARE_RTFEXPORT_TEST(testMathSepchr, "math-sepchr.rtf")
337 OUString aActual = getFormula(getRun(getParagraph(1), 1));
338 CPPUNIT_ASSERT_EQUAL(OUString("AxByBzC"), aActual);
341 DECLARE_RTFEXPORT_TEST(testMathSubscripts, "math-subscripts.rtf")
343 OUString aActual = getFormula(getRun(getParagraph(1), 1));
344 OUString const aExpected("{x} ^ {y} + {e} ^ {x} {x} ^ {b} {x} rsub {b} {a} rsub {c} rsup {b} "
345 "{x} lsub {2} lsup {1} {{x csup {6} csub {3}} lsub {4} lsup {5}} rsub "
346 "{2} rsup {1}");
347 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
350 DECLARE_RTFEXPORT_TEST(testMathVerticalstacks, "math-vertical-stacks.rtf")
352 CPPUNIT_ASSERT_EQUAL(OUString("{a} over {b}"), getFormula(getRun(getParagraph(1), 1)));
353 CPPUNIT_ASSERT_EQUAL(OUString("{a} / {b}"), getFormula(getRun(getParagraph(2), 1)));
354 CPPUNIT_ASSERT_EQUAL(OUString("stack { a # b }"), getFormula(getRun(getParagraph(3), 1)));
355 CPPUNIT_ASSERT_EQUAL(OUString("stack { a # stack { b # c } }"),
356 getFormula(getRun(getParagraph(4), 1)));
359 DECLARE_RTFEXPORT_TEST(testTdf49073, "tdf49073.rtf")
361 // test case for Asian phontic guide (ruby text.)
362 sal_Unicode aRuby[3] = { 0x304D, 0x3082, 0x3093 };
363 OUString sRuby(aRuby, SAL_N_ELEMENTS(aRuby));
364 CPPUNIT_ASSERT_EQUAL(sRuby, getProperty<OUString>(getParagraph(1)->getStart(), "RubyText"));
365 OUString sStyle = getProperty<OUString>(getParagraph(1)->getStart(), "RubyCharStyleName");
366 uno::Reference<beans::XPropertySet> xPropertySet(
367 getStyles("CharacterStyles")->getByName(sStyle), uno::UNO_QUERY);
368 CPPUNIT_ASSERT_EQUAL(5.f, getProperty<float>(xPropertySet, "CharHeight"));
369 CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_CENTER),
370 getProperty<sal_Int16>(getParagraph(2)->getStart(), "RubyAdjust"));
371 CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_BLOCK),
372 getProperty<sal_Int16>(getParagraph(3)->getStart(), "RubyAdjust"));
373 CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_INDENT_BLOCK),
374 getProperty<sal_Int16>(getParagraph(4)->getStart(), "RubyAdjust"));
375 CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_LEFT),
376 getProperty<sal_Int16>(getParagraph(5)->getStart(), "RubyAdjust"));
377 CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_RIGHT),
378 getProperty<sal_Int16>(getParagraph(6)->getStart(), "RubyAdjust"));
379 CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyPosition::INTER_CHARACTER),
380 getProperty<sal_Int16>(getParagraph(7)->getStart(), "RubyPosition"));
383 DECLARE_RTFEXPORT_TEST(testMathRuns, "math-runs.rtf")
385 // was [](){}, i.e. first curly bracket had an incorrect position
386 CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"),
387 getFormula(getRun(getParagraph(1), 1)));
390 DECLARE_RTFEXPORT_TEST(testFdo77979, "fdo77979.odt")
392 // font name is encoded with \fcharset of font
393 OUString aExpected(u"\u5FAE\u8F6F\u96C5\u9ED1");
394 CPPUNIT_ASSERT_EQUAL(aExpected,
395 getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
398 DECLARE_RTFEXPORT_TEST(testFdo53113, "fdo53113.odt")
401 * The problem was that a custom shape was missing its second (and all the other remaining) coordinates.
403 * oShape = ThisComponent.DrawPage(0)
404 * oPathPropVec = oShape.CustomShapeGeometry(1).Value
405 * oCoordinates = oPathPropVec(0).Value
406 * xray oCoordinates(1).First.Value ' 535
407 * xray oCoordinates(1).Second.Value ' 102
410 uno::Sequence<beans::PropertyValue> aProps
411 = getProperty<uno::Sequence<beans::PropertyValue>>(getShape(1), "CustomShapeGeometry");
412 uno::Sequence<beans::PropertyValue> aPathProps;
413 for (int i = 0; i < aProps.getLength(); ++i)
415 const beans::PropertyValue& rProp = aProps[i];
416 if (rProp.Name == "Path")
417 rProp.Value >>= aPathProps;
419 uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aPairs;
420 for (int i = 0; i < aPathProps.getLength(); ++i)
422 const beans::PropertyValue& rProp = aPathProps[i];
423 if (rProp.Name == "Coordinates")
424 rProp.Value >>= aPairs;
426 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aPairs.getLength());
427 CPPUNIT_ASSERT_EQUAL(sal_Int32(535), aPairs[1].First.Value.get<sal_Int32>());
428 CPPUNIT_ASSERT_EQUAL(sal_Int32(102), aPairs[1].Second.Value.get<sal_Int32>());
431 DECLARE_RTFEXPORT_TEST(testFdo55939, "fdo55939.odt")
433 // The problem was that the exported RTF was invalid.
434 // Also, the 'Footnote text.' had an additional newline at its end.
435 uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
436 getRun(xParagraph, 1, "Main text before footnote.");
437 // Why the tab has to be removed here?
438 CPPUNIT_ASSERT_EQUAL(OUString("Footnote text."), getProperty<uno::Reference<text::XTextRange>>(
439 getRun(xParagraph, 2), "Footnote")
440 ->getText()
441 ->getString()
442 .replaceAll("\t", ""));
443 getRun(xParagraph, 3,
444 " Text after the footnote."); // However, this leading space is intentional and OK.
447 DECLARE_RTFEXPORT_TEST(testTextFrames, "textframes.odt")
449 // The output was simply invalid, so let's check if all 3 frames were imported back.
450 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
451 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(),
452 uno::UNO_QUERY);
453 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount());
456 DECLARE_RTFEXPORT_TEST(testFdo53604, "fdo53604.odt")
458 // Invalid output on empty footnote.
459 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
460 uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
461 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
464 DECLARE_RTFEXPORT_TEST(testFdo52286, "fdo52286.odt")
466 // The problem was that font size wasn't reduced in sub/super script.
467 CPPUNIT_ASSERT_EQUAL(
468 sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapementHeight"));
469 CPPUNIT_ASSERT_EQUAL(
470 sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(2), 2), "CharEscapementHeight"));
473 DECLARE_RTFEXPORT_TEST(testFdo61507, "fdo61507.rtf")
476 * Unicode-only characters in \title confused Wordpad. Once the exporter
477 * was fixed to guard the problematic characters with \upr and \ud, the
478 * importer didn't cope with these new keywords.
481 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(
482 mxComponent, uno::UNO_QUERY);
483 uno::Reference<document::XDocumentProperties> xDocumentProperties(
484 xDocumentPropertiesSupplier->getDocumentProperties());
485 OUString aExpected(u"\u00C9\u00C1\u0150\u0170\u222D");
486 CPPUNIT_ASSERT_EQUAL(aExpected, xDocumentProperties->getTitle());
488 // Only "Hello.", no additional characters.
489 CPPUNIT_ASSERT_EQUAL(6, getLength());
492 DECLARE_RTFEXPORT_TEST(testFdo30983, "fdo30983.rtf")
494 // These were 'page text area', not 'entire page', i.e. both the horizontal
495 // and vertical positions were incorrect.
496 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME,
497 getProperty<sal_Int16>(getShape(1), "HoriOrientRelation"));
498 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME,
499 getProperty<sal_Int16>(getShape(1), "VertOrientRelation"));
502 DECLARE_RTFEXPORT_TEST(testPlaceholder, "placeholder.odt")
504 // Only the field text was exported, make sure we still have a field with the correct Hint text.
505 uno::Reference<text::XTextRange> xRun(getRun(getParagraph(1), 2));
506 CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(xRun, "TextPortionType"));
507 uno::Reference<beans::XPropertySet> xField
508 = getProperty<uno::Reference<beans::XPropertySet>>(xRun, "TextField");
509 CPPUNIT_ASSERT_EQUAL(OUString("place holder"), getProperty<OUString>(xField, "Hint"));
512 DECLARE_RTFEXPORT_TEST(testMnor, "mnor.rtf")
514 // \mnor wasn't handled, leading to missing quotes around "divF" and so on.
515 OUString aActual = getFormula(getRun(getParagraph(1), 1));
516 OUString aExpected(
517 u"iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\" \u2219 \"n\" dS}");
518 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
521 DECLARE_RTFEXPORT_TEST(testI120928, "i120928.rtf")
523 // \listpicture and \levelpicture0 was ignored, leading to missing graphic bullet in numbering.
524 uno::Reference<beans::XPropertySet> xPropertySet(
525 getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
526 uno::Reference<container::XIndexAccess> xLevels(
527 xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
528 uno::Sequence<beans::PropertyValue> aProps;
529 xLevels->getByIndex(0) >>= aProps; // 1st level
531 uno::Reference<awt::XBitmap> xBitmap;
532 sal_Int16 nNumberingType = -1;
534 for (int i = 0; i < aProps.getLength(); ++i)
536 const beans::PropertyValue& rProp = aProps[i];
538 if (rProp.Name == "NumberingType")
539 nNumberingType = rProp.Value.get<sal_Int16>();
540 else if (rProp.Name == "GraphicBitmap")
541 xBitmap = rProp.Value.get<uno::Reference<awt::XBitmap>>();
543 CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType);
544 CPPUNIT_ASSERT(xBitmap.is());
547 DECLARE_RTFEXPORT_TEST(testBookmark, "bookmark.rtf")
549 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
550 uno::Reference<text::XTextContent> xBookmark(
551 xBookmarksSupplier->getBookmarks()->getByName("firstword"), uno::UNO_QUERY);
552 CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xBookmark->getAnchor()->getString());
555 DECLARE_RTFEXPORT_TEST(testHyperlink, "hyperlink.rtf")
557 CPPUNIT_ASSERT_EQUAL(
558 OUString(), getProperty<OUString>(getRun(getParagraph(1), 1, "Hello"), "HyperLinkURL"));
559 CPPUNIT_ASSERT_EQUAL(
560 OUString("http://en.wikipedia.org/wiki/World"),
561 getProperty<OUString>(getRun(getParagraph(1), 2, "world"), "HyperLinkURL"));
562 CPPUNIT_ASSERT_EQUAL(OUString(),
563 getProperty<OUString>(getRun(getParagraph(1), 3, "!"), "HyperLinkURL"));
566 DECLARE_RTFEXPORT_TEST(testHyperlinkTdf100105, "hyperlink_empty.rtf")
568 // export of empty link was invalid, group was closed before it was opened
569 uno::Reference<text::XTextDocument> xTextDoc(mxComponent, uno::UNO_QUERY);
570 uno::Reference<text::XTextCursor> xCursor(xTextDoc->getText()->createTextCursor());
571 xCursor->gotoStart(false);
572 CPPUNIT_ASSERT_EQUAL(OUString("http://example.net"),
573 getProperty<OUString>(xCursor, "HyperLinkURL"));
574 // getRun doesn't provide a 0-length hyperlink
575 CPPUNIT_ASSERT_EQUAL(
576 OUString(), getProperty<OUString>(getRun(getParagraph(1), 1, "foobar"), "HyperLinkURL"));
579 DECLARE_RTFEXPORT_TEST(test78758, "fdo78758.rtf")
581 CPPUNIT_ASSERT_EQUAL(
582 OUString("#__RefHeading___Toc264438068"),
583 getProperty<OUString>(getRun(getParagraph(2), 1, "EE5E EeEEE5EE"), "HyperLinkURL"));
584 CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
585 getProperty<OUString>(getRun(getParagraph(2), 2, "e"), "HyperLinkURL"));
586 CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
587 getProperty<OUString>(getRun(getParagraph(2), 3, "\t46"), "HyperLinkURL"));
590 DECLARE_RTFEXPORT_TEST(testTextFrameBorders, "textframe-borders.rtf")
592 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
593 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(),
594 uno::UNO_QUERY);
595 uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
596 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xFrame, "BackColor"));
598 table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder");
599 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aBorder.Color);
600 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth);
602 table::ShadowFormat aShadowFormat = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat");
603 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location);
604 CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth);
605 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aShadowFormat.Color);
608 DECLARE_RTFEXPORT_TEST(testTextframeGradient, "textframe-gradient.rtf")
610 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
611 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(),
612 uno::UNO_QUERY);
613 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
615 uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
616 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT,
617 getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
618 awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
619 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor);
620 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor);
621 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
623 xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
624 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT,
625 getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
626 aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
627 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor);
628 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor);
629 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
632 DECLARE_RTFEXPORT_TEST(testRecordChanges, "record-changes.rtf")
634 // \revisions wasn't imported/exported.
635 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(mxComponent, "RecordChanges"));
638 DECLARE_RTFEXPORT_TEST(testTextframeTable, "textframe-table.rtf")
640 uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY);
641 uno::Reference<text::XText> xText = xTextRange->getText();
642 CPPUNIT_ASSERT_EQUAL(OUString("First para."), getParagraphOfText(1, xText)->getString());
643 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
644 CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(
645 xTable->getCellByName("A1"), uno::UNO_QUERY_THROW)
646 ->getString());
647 CPPUNIT_ASSERT_EQUAL(OUString("B"), uno::Reference<text::XTextRange>(
648 xTable->getCellByName("B1"), uno::UNO_QUERY_THROW)
649 ->getString());
650 CPPUNIT_ASSERT_EQUAL(OUString("Last para."), getParagraphOfText(3, xText)->getString());
653 DECLARE_RTFEXPORT_TEST(testFdo66682, "fdo66682.rtf")
655 uno::Reference<beans::XPropertySet> xPropertySet(
656 getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
657 uno::Reference<container::XIndexAccess> xLevels(
658 xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
659 uno::Sequence<beans::PropertyValue> aProps;
660 xLevels->getByIndex(0) >>= aProps; // 1st level
662 OUString aListFormat;
663 for (int i = 0; i < aProps.getLength(); ++i)
665 const beans::PropertyValue& rProp = aProps[i];
667 if (rProp.Name == "ListFormat")
668 aListFormat = rProp.Value.get<OUString>();
670 // Suffix was '\0' instead of ' '.
671 CPPUNIT_ASSERT_EQUAL(OUString(" %1 "), aListFormat);
674 DECLARE_RTFEXPORT_TEST(testParaShadow, "para-shadow.rtf")
676 // The problem was that \brdrsh was ignored.
677 table::ShadowFormat aShadow
678 = getProperty<table::ShadowFormat>(getParagraph(2), "ParaShadowFormat");
679 CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(aShadow.Color));
680 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
681 CPPUNIT_ASSERT_EQUAL(sal_Int16(convertTwipToMm100(60)), aShadow.ShadowWidth);
684 DECLARE_RTFEXPORT_TEST(testCharacterBorder, "charborder.odt")
686 uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 1), uno::UNO_QUERY);
687 // RTF has just one border attribute (chbrdr) for text border so all side has
688 // the same border with the same padding
689 // Border
691 const table::BorderLine2 aTopBorder
692 = getProperty<table::BorderLine2>(xRun, "CharTopBorder");
693 CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF6600, 0, 318, 0, 0, 318), aTopBorder);
694 CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder,
695 getProperty<table::BorderLine2>(xRun, "CharLeftBorder"));
696 CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder,
697 getProperty<table::BorderLine2>(xRun, "CharBottomBorder"));
698 CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder,
699 getProperty<table::BorderLine2>(xRun, "CharRightBorder"));
702 // Padding (brsp)
704 const sal_Int32 nTopPadding = getProperty<sal_Int32>(xRun, "CharTopBorderDistance");
705 // In the original ODT file the padding is 150, but the unit conversion round it down.
706 CPPUNIT_ASSERT_EQUAL(sal_Int32(141), nTopPadding);
707 CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun, "CharLeftBorderDistance"));
708 CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun, "CharBottomBorderDistance"));
709 CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun, "CharRightBorderDistance"));
712 // Shadow (brdrsh)
713 /* RTF use just one bool value for shadow so the next conversions
714 are made during an export-import round
715 color: any -> black
716 location: any -> bottom-right
717 width: any -> border width */
719 const table::ShadowFormat aShadow
720 = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
721 CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(aShadow.Color));
722 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
723 CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth);
727 DECLARE_RTFEXPORT_TEST(testFdo66743, "fdo66743.rtf")
729 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
730 uno::Reference<table::XCell> xCell = xTable->getCellByName("A1");
731 // This was too dark, 0x7f7f7f.
732 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xd8d8d8), getProperty<sal_Int32>(xCell, "BackColor"));
735 DECLARE_RTFEXPORT_TEST(testFdo68787, "fdo68787.rtf")
737 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"),
738 uno::UNO_QUERY);
739 // This was 0, the 'lack of \chftnsep' <-> '0 line width' mapping was missing in the RTF tokenizer / exporter.
740 CPPUNIT_ASSERT_EQUAL(sal_Int32(25),
741 getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth"));
744 DECLARE_RTFEXPORT_TEST(testFdo74709, "fdo74709.rtf")
746 uno::Reference<table::XCell> xCell = getCell(getParagraphOrTable(1), "B1");
747 // This was 0, as top/bottom/left/right padding wasn't imported.
748 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(360)),
749 getProperty<sal_Int32>(xCell, "RightBorderDistance"));
752 DECLARE_RTFEXPORT_TEST(testTdf84832, "tdf84832.docx")
754 uno::Reference<table::XCell> xCell = getCell(getParagraphOrTable(2), "A1");
755 // This was 0, as left padding wasn't exported.
756 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(108)),
757 getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
760 DECLARE_RTFEXPORT_TEST(testRelsize, "relsize.rtf")
762 uno::Reference<drawing::XShape> xShape = getShape(1);
763 CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(xShape, "RelativeWidth"));
764 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME,
765 getProperty<sal_Int16>(xShape, "RelativeWidthRelation"));
766 CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(xShape, "RelativeHeight"));
767 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME,
768 getProperty<sal_Int16>(xShape, "RelativeHeightRelation"));
771 DECLARE_RTFEXPORT_TEST(testLineNumbering, "linenumbering.rtf")
773 uno::Reference<text::XLineNumberingProperties> xLineNumberingProperties(mxComponent,
774 uno::UNO_QUERY_THROW);
775 uno::Reference<beans::XPropertySet> xPropertySet
776 = xLineNumberingProperties->getLineNumberingProperties();
777 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPropertySet, "IsOn"));
778 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), getProperty<sal_Int32>(xPropertySet, "Interval"));
781 DECLARE_RTFEXPORT_TEST(testFdo77600, "fdo77600.rtf")
783 // This was 'Liberation Serif'.
784 CPPUNIT_ASSERT_EQUAL(OUString("Arial"),
785 getProperty<OUString>(getRun(getParagraph(1), 3), "CharFontName"));
788 DECLARE_RTFEXPORT_TEST(testFdo80167, "fdo80167.rtf")
790 // Problem was that after export, the page break was missing, so this was 1.
791 CPPUNIT_ASSERT_EQUAL(2, getPages());
794 DECLARE_RTFEXPORT_TEST(testFdo32613, "fdo32613.odt")
796 // This was AS_CHARACTER, RTF export did not support writing anchored pictures.
797 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,
798 getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
801 DECLARE_RTFEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf")
803 // The problem was that the wrap polygon was ignored during import.
804 drawing::PointSequenceSequence aSeqSeq
805 = getProperty<drawing::PointSequenceSequence>(getShape(1), "ContourPolyPolygon");
806 // This was 0: the polygon list was empty.
807 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeqSeq.getLength());
809 drawing::PointSequence aSeq = aSeqSeq[0];
810 CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aSeq.getLength());
812 // The shape also didn't have negative top / left coordinates.
813 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-1177)),
814 getProperty<sal_Int32>(getShape(1), "HoriOrientPosition"));
815 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)),
816 getProperty<sal_Int32>(getShape(1), "VertOrientPosition"));
819 DECLARE_RTFEXPORT_TEST(testTdf113408, "tdf113408.rtf")
821 // This was 0, left margin was not inherited from style properly.
822 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270),
823 getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
826 DECLARE_RTFEXPORT_TEST(testAbi10039, "abi10039.odt")
828 // Make sure we don't just crash on export, and additionally the shape should not be inline (as it's at-page anchored originally).
829 CPPUNIT_ASSERT(text::TextContentAnchorType_AS_CHARACTER
830 != getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
833 DECLARE_RTFEXPORT_TEST(testAbi10076, "abi10076.odt")
835 // Just make sure that we don't crash after exporting a fully calculated layout.
838 DECLARE_RTFEXPORT_TEST(testEm, "em.rtf")
840 // Test all possible \acc* control words.
841 CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::NONE,
842 getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharEmphasis"));
843 CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_ABOVE,
844 getProperty<sal_Int16>(getRun(getParagraph(1), 2), "CharEmphasis"));
845 CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::ACCENT_ABOVE,
846 getProperty<sal_Int16>(getRun(getParagraph(1), 3), "CharEmphasis"));
847 // This was missing.
848 CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::CIRCLE_ABOVE,
849 getProperty<sal_Int16>(getRun(getParagraph(1), 4), "CharEmphasis"));
850 // This one, too.
851 CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_BELOW,
852 getProperty<sal_Int16>(getRun(getParagraph(1), 5), "CharEmphasis"));
855 DECLARE_RTFEXPORT_TEST(testNumberingFont, "numbering-font.rtf")
857 uno::Reference<beans::XPropertySet> xStyle(
858 getStyles("CharacterStyles")->getByName("ListLabel 1"), uno::UNO_QUERY);
859 // This was Liberation Serif, i.e. custom font of the numbering itself ("1.\t") was lost on import.
860 CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(xStyle, "CharFontName"));
863 DECLARE_RTFEXPORT_TEST(testFdo82860, "fdo82860.odt")
865 // The problem was that:
866 // 1) The import tried to use fieldmarks for SHAPE fields
867 // 2) The exporter did not handle "shape with textbox" text.
868 uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY);
869 uno::Reference<text::XText> xText = xTextRange->getText();
870 CPPUNIT_ASSERT_EQUAL(OUString("hello"), getParagraphOfText(1, xText)->getString());
873 DECLARE_RTFEXPORT_TEST(testFdo82858, "fdo82858.docx")
875 // This was table::BorderLineStyle::SOLID, exporter failed to write explicit no line when line color was written.
876 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE,
877 getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineStyle);
880 DECLARE_RTFEXPORT_TEST(testTdf104936, "tdf104936.rtf")
882 uno::Reference<text::XTextRange> xShape1(getShape(1), uno::UNO_QUERY);
883 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xShape1, "ZOrder"));
884 // This failed, the shape without text covered the shape with text.
885 CPPUNIT_ASSERT(xShape1->getString().isEmpty());
886 uno::Reference<text::XTextRange> xShape2(getShape(2), uno::UNO_QUERY);
887 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), getProperty<sal_Int32>(xShape2, "ZOrder"));
888 CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xShape2->getString());
891 DECLARE_RTFEXPORT_TEST(testTableRtl, "table-rtl.rtf")
893 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
894 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
895 uno::UNO_QUERY);
896 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
897 // This was text::WritingMode2::LR_TB, i.e. direction of the table was ignored.
898 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>(xTable, "WritingMode"));
901 DECLARE_RTFEXPORT_TEST(testNumOverrideStart, "num-override-start.rtf")
903 // The numbering on the second level was "3.1", not "1.3".
904 uno::Reference<container::XIndexAccess> xRules
905 = getProperty<uno::Reference<container::XIndexAccess>>(
906 getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
907 CPPUNIT_ASSERT_EQUAL(
908 sal_Int16(1),
909 comphelper::SequenceAsHashMap(xRules->getByIndex(0))["StartWith"].get<sal_Int16>());
910 CPPUNIT_ASSERT_EQUAL(
911 sal_Int16(3),
912 comphelper::SequenceAsHashMap(xRules->getByIndex(1))["StartWith"].get<sal_Int16>());
915 DECLARE_RTFEXPORT_TEST(testFdo82006, "fdo82006.rtf")
917 // These were 176 (100 twips), as \sbauto and \sbbefore were ignored.
918 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
919 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
920 getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
921 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
922 getProperty<sal_Int32>(getParagraph(2), "ParaTopMargin"));
923 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
924 getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
927 DECLARE_RTFEXPORT_TEST(testTdf104081, "tdf104081.rtf")
929 // These were 494 (280 twips), as \htmautsp was ignored.
930 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(100)),
931 getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
932 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(100)),
933 getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
936 DECLARE_RTFEXPORT_TEST(testTdf88583, "tdf88583.odt")
938 // This was FillStyle_NONE, as background color was missing from the color table during export.
939 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID,
940 getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle"));
941 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x00cc00),
942 getProperty<sal_Int32>(getParagraph(1), "FillColor"));
945 DECLARE_RTFEXPORT_TEST(testMargmirror, "margmirror.rtf")
947 // \margmirror was not handled, this was PageStyleLayout_ALL.
948 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"),
949 uno::UNO_QUERY);
950 CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_MIRRORED,
951 getProperty<style::PageStyleLayout>(xPageStyle, "PageStyleLayout"));
954 DECLARE_RTFEXPORT_TEST(testSautoupd, "sautoupd.rtf")
956 // \sautoupd was ignored during import and export.
957 uno::Reference<beans::XPropertySet> xHeading1(
958 getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
959 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xHeading1, "IsAutoUpdate"));
960 uno::Reference<beans::XPropertySet> xHeading2(
961 getStyles("ParagraphStyles")->getByName("Heading 2"), uno::UNO_QUERY);
962 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xHeading2, "IsAutoUpdate"));
965 DECLARE_RTFEXPORT_TEST(testHyphauto, "hyphauto.rtf")
967 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getParagraph(1), "ParaIsHyphenation"));
970 DECLARE_RTFEXPORT_TEST(testHyphpar, "hyphpar.rtf")
972 // Hyphenation was enabled for all 3 paragraphs, but it should be disabled for the 2nd one.
973 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getParagraph(2), "ParaIsHyphenation"));
976 DECLARE_RTFEXPORT_TEST(testTdf108955, "tdf108955.rtf")
978 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID,
979 getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle"));
980 // This was 0xffffff, i.e. non-white background was overwritten from the paragraph style.
981 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffff99),
982 getProperty<sal_Int32>(getParagraph(1), "FillColor"));
985 DECLARE_RTFEXPORT_TEST(testTdf80708, "tdf80708.rtf")
987 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
988 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
989 uno::UNO_QUERY);
990 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(1), uno::UNO_QUERY);
991 uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
992 // This was 2, i.e. the second table had 3 cols, now 2 as expected.
993 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1),
994 getProperty<uno::Sequence<text::TableColumnSeparator>>(
995 xTableRows->getByIndex(0), "TableColumnSeparators")
996 .getLength());
999 DECLARE_RTFEXPORT_TEST(testTdf90421, "tdf90421.fodt")
1001 if (mbExported)
1003 SvMemoryStream aMemoryStream;
1004 SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
1005 aStream.ReadStream(aMemoryStream);
1006 OString aData(static_cast<const char*>(aMemoryStream.GetData()), aMemoryStream.GetSize());
1007 // This was some positive number, i.e. we exported a hyperlink with an empty URL.
1008 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), aData.indexOf("HYPERLINK"));
1012 DECLARE_RTFEXPORT_TEST(testTdf92521, "tdf92521.odt")
1014 // There should be a page break that's in the middle of the document: right after the table.
1015 // But there wasn't, so this was 1.
1016 CPPUNIT_ASSERT_EQUAL(2, getPages());
1019 DECLARE_RTFEXPORT_TEST(testTdf94043, "tdf94043.rtf")
1021 auto xTextSection
1022 = getProperty<uno::Reference<beans::XPropertySet>>(getParagraph(2), "TextSection");
1023 auto xTextColumns
1024 = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns");
1025 // This was 0, the separator line was not visible due to 0 width.
1026 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2),
1027 getProperty<sal_Int32>(xTextColumns, "SeparatorLineWidth"));
1029 CPPUNIT_ASSERT_EQUAL(7, getParagraphs());
1032 DECLARE_RTFEXPORT_TEST(testTdf94377, "tdf94377.rtf")
1034 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
1035 uno::Reference<container::XEnumerationAccess> xFieldsAccess(
1036 xTextFieldsSupplier->getTextFields());
1037 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
1038 uno::Reference<beans::XPropertySet> xPropertySet(xFields->nextElement(), uno::UNO_QUERY);
1039 auto xText = getProperty<uno::Reference<text::XText>>(xPropertySet, "TextRange");
1040 // This failed, as:
1041 // 1) multiple paragraphs were not exported, so the text was "Asdf10asdf12".
1042 // 2) direct formatting of runs were not exported, so this was 12 (the document default).
1043 CPPUNIT_ASSERT_EQUAL(
1044 10.f, getProperty<float>(getRun(getParagraphOfText(1, xText, "Asdf10"), 1), "CharHeight"));
1045 CPPUNIT_ASSERT_EQUAL(
1046 12.f, getProperty<float>(getRun(getParagraphOfText(2, xText, "asdf12"), 1), "CharHeight"));
1049 DECLARE_RTFEXPORT_TEST(testTdf104079, "tdf104079.rtf")
1051 bool bFound = false;
1052 int nIndex = 0;
1053 while (!bFound)
1055 uno::Reference<text::XTextRange> xParagraph = getParagraph(++nIndex);
1056 if (!xParagraph->getString().startsWith("toc3"))
1057 continue;
1059 bFound = true;
1060 // This was 0, 3rd paragraph of ToC lost its bottom paragraph margin.
1061 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(212),
1062 getProperty<sal_Int32>(xParagraph, "ParaBottomMargin"));
1066 DECLARE_RTFEXPORT_TEST(testPageBackground, "page-background.rtf")
1068 // The problem was that \background was ignored.
1069 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"),
1070 uno::UNO_QUERY);
1071 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
1074 DECLARE_RTFEXPORT_TEST(testTdf96175, "tdf96175.rtf")
1076 // The problem that a user defined property named "Company" was lost on export.
1077 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(
1078 mxComponent, uno::UNO_QUERY);
1079 uno::Reference<document::XDocumentProperties> xDocumentProperties
1080 = xDocumentPropertiesSupplier->getDocumentProperties();
1081 uno::Reference<beans::XPropertyContainer> xUserDefinedProperties
1082 = xDocumentProperties->getUserDefinedProperties();
1083 // This resulted in a beans::UnknownPropertyException.
1084 CPPUNIT_ASSERT_EQUAL(OUString("foobar"),
1085 getProperty<OUString>(xUserDefinedProperties, "Company"));
1088 DECLARE_RTFEXPORT_TEST(testRedline, "redline.rtf")
1090 CPPUNIT_ASSERT_EQUAL(OUString("Rebecca Lopez"),
1091 getProperty<OUString>(getRun(getParagraph(1), 2), "RedlineAuthor"));
1092 CPPUNIT_ASSERT_EQUAL(OUString("Dorothy Jones"),
1093 getProperty<OUString>(getRun(getParagraph(2), 2), "RedlineAuthor"));
1096 DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf")
1098 // Custom document properties were not improved, this resulted in a beans::UnknownPropertyException.
1099 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(
1100 mxComponent, uno::UNO_QUERY);
1101 uno::Reference<document::XDocumentProperties> xDocumentProperties
1102 = xDocumentPropertiesSupplier->getDocumentProperties();
1103 uno::Reference<beans::XPropertyContainer> xUserDefinedProperties
1104 = xDocumentProperties->getUserDefinedProperties();
1105 CPPUNIT_ASSERT_EQUAL(
1106 OUString("2016-03-08T10:55:18,531376147"),
1107 getProperty<OUString>(xUserDefinedProperties,
1108 "urn:bails:IntellectualProperty:Authorization:StartValidity"));
1109 CPPUNIT_ASSERT_EQUAL(
1110 OUString("None"),
1111 getProperty<OUString>(xUserDefinedProperties,
1112 "urn:bails:IntellectualProperty:Authorization:StopValidity"));
1113 // Test roundtrip of numbers. This failed as getProperty() did not find "n".
1114 CPPUNIT_ASSERT_EQUAL(42.0, getProperty<double>(xUserDefinedProperties, "n"));
1115 // Test boolean "yes".
1116 CPPUNIT_ASSERT(getProperty<bool>(xUserDefinedProperties, "by"));
1117 // Test boolean "no".
1118 CPPUNIT_ASSERT(!getProperty<bool>(xUserDefinedProperties, "bn"));
1120 // Test roundtrip of date in general, and year/month/day in particular.
1121 util::DateTime aDate = getProperty<util::DateTime>(xUserDefinedProperties, "d");
1122 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2016), aDate.Year);
1123 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), aDate.Month);
1124 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(30), aDate.Day);
1126 // Test real number.
1127 CPPUNIT_ASSERT_EQUAL(3.14, getProperty<double>(xUserDefinedProperties, "pi"));
1130 DECLARE_RTFEXPORT_TEST(testTdf65642, "tdf65642.rtf")
1132 uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
1133 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
1134 uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
1135 xModel->getCurrentController(), uno::UNO_QUERY);
1136 uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(),
1137 uno::UNO_QUERY);
1138 xCursor->jumpToLastPage();
1139 OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
1140 // The second page's numbering type: this was style::NumberingType::ARABIC.
1141 CPPUNIT_ASSERT_EQUAL(
1142 style::NumberingType::CHARS_UPPER_LETTER_N,
1143 getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType"));
1144 // The second page's restart value: this was 0.
1145 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1),
1146 getProperty<sal_Int32>(getParagraph(2), "PageNumberOffset"));
1149 DECLARE_RTFEXPORT_TEST(testPgnlcltr, "pgnlcltr.rtf")
1151 uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
1152 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
1153 uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
1154 xModel->getCurrentController(), uno::UNO_QUERY);
1155 uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(),
1156 uno::UNO_QUERY);
1157 xCursor->jumpToLastPage();
1158 OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
1159 // The second page's numbering type: this was style::NumberingType::ARABIC.
1160 CPPUNIT_ASSERT_EQUAL(
1161 style::NumberingType::CHARS_LOWER_LETTER_N,
1162 getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType"));
1165 DECLARE_RTFEXPORT_TEST(testPgnucrm, "pgnucrm.rtf")
1167 uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
1168 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
1169 uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
1170 xModel->getCurrentController(), uno::UNO_QUERY);
1171 uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(),
1172 uno::UNO_QUERY);
1173 xCursor->jumpToLastPage();
1174 OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
1175 // The second page's numbering type: this was style::NumberingType::ARABIC.
1176 CPPUNIT_ASSERT_EQUAL(
1177 style::NumberingType::ROMAN_UPPER,
1178 getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType"));
1181 DECLARE_RTFEXPORT_TEST(testPgnlcrm, "pgnlcrm.rtf")
1183 uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
1184 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
1185 uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
1186 xModel->getCurrentController(), uno::UNO_QUERY);
1187 uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(),
1188 uno::UNO_QUERY);
1189 xCursor->jumpToLastPage();
1190 OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
1191 // The second page's numbering type: this was style::NumberingType::ARABIC.
1192 CPPUNIT_ASSERT_EQUAL(
1193 style::NumberingType::ROMAN_LOWER,
1194 getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType"));
1197 DECLARE_RTFEXPORT_TEST(testPgndec, "pgndec.rtf")
1199 uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
1200 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
1201 uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
1202 xModel->getCurrentController(), uno::UNO_QUERY);
1203 uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(),
1204 uno::UNO_QUERY);
1205 xCursor->jumpToLastPage();
1206 OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
1207 // The second page's numbering type: this was style::NumberingType::ROMAN_LOWER.
1208 CPPUNIT_ASSERT_EQUAL(
1209 style::NumberingType::ARABIC,
1210 getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType"));
1213 DECLARE_RTFEXPORT_TEST(testTdf98806, "tdf98806.rtf")
1215 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
1216 uno::Reference<text::XTextContent> xBookmark(
1217 xBookmarksSupplier->getBookmarks()->getByName("bookmark"), uno::UNO_QUERY);
1218 // This was empty, bookmark in table wasn't imported correctly.
1219 CPPUNIT_ASSERT_EQUAL(OUString("BBB"), xBookmark->getAnchor()->getString());
1222 DECLARE_RTFEXPORT_TEST(testTdf61901, "tdf61901.rtf")
1224 // Test the file directly, as current RTF import gives the correct font name with and without the fix.
1225 if (mbExported)
1227 SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
1228 OString sLine;
1229 while (pStream->ReadLine(sLine))
1231 sal_Int32 nIndex = sLine.indexOf("\\loch\\loch");
1232 if (nIndex != -1)
1234 // Make sure that \hich is always written after a \loch\loch.
1235 OString sRemaining = sLine.copy(nIndex);
1236 CPPUNIT_ASSERT(sRemaining.indexOf("\\hich") != -1);
1242 DECLARE_RTFEXPORT_TEST(testTdf103925, "tdf103925.rtf")
1244 // This was true, \animtext0 resulted in setting the blinking font effect.
1245 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getRun(getParagraph(1), 1), "CharFlash"));
1248 DECLARE_RTFEXPORT_TEST(testTdf104228, "tdf104228.rtf")
1250 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2), uno::UNO_QUERY);
1251 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("C1"), uno::UNO_QUERY);
1252 uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xCell->getText());
1253 // This was 2103, implicit 0 as direct formatting was ignored on the
1254 // paragraph (and the style had this larger value).
1255 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
1256 getProperty<sal_Int32>(xParagraph, "ParaLeftMargin"));
1259 DECLARE_RTFEXPORT_TEST(testTdf104085, "tdf104085.rtf")
1261 uno::Reference<text::XTextRange> xPara(getParagraph(1));
1262 uno::Reference<beans::XPropertySet> properties(xPara, uno::UNO_QUERY);
1263 uno::Reference<container::XIndexAccess> xLevels(properties->getPropertyValue("NumberingRules"),
1264 uno::UNO_QUERY);
1265 uno::Sequence<beans::PropertyValue> aProps;
1266 xLevels->getByIndex(0) >>= aProps;
1267 for (int i = 0; i < aProps.getLength(); ++i)
1269 if (aProps[i].Name == "BulletChar")
1270 return;
1272 CPPUNIT_FAIL("no BulletChar property");
1275 DECLARE_RTFEXPORT_TEST(testTdf113550, "tdf113550.rtf")
1277 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
1278 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1279 uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xCell->getText());
1280 // This was 2501, 0 as direct formatting was ignored on the paragraph (and
1281 // the style had this larger value).
1282 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
1283 getProperty<sal_Int32>(xParagraph, "ParaLeftMargin"));
1286 DECLARE_RTFEXPORT_TEST(testLeveljcCenter, "leveljc-center.rtf")
1288 // Tests that \leveljc1 is mapped to Adjust=Center for a numbering rule.
1289 uno::Reference<text::XTextRange> xPara(getParagraph(1));
1290 uno::Reference<beans::XPropertySet> properties(xPara, uno::UNO_QUERY);
1291 uno::Reference<container::XIndexAccess> xLevels(properties->getPropertyValue("NumberingRules"),
1292 uno::UNO_QUERY);
1293 uno::Sequence<beans::PropertyValue> aProps;
1294 xLevels->getByIndex(0) >>= aProps;
1295 for (int i = 0; i < aProps.getLength(); ++i)
1297 if (aProps[i].Name == "Adjust")
1299 sal_Int16 nValue = 0;
1300 CPPUNIT_ASSERT(aProps[i].Value >>= nValue);
1301 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, nValue);
1302 return;
1305 CPPUNIT_FAIL("no Adjust property");
1308 DECLARE_RTFEXPORT_TEST(testHyperlinkTarget, "hyperlink-target.rtf")
1310 // This was empty, hyperlink target was lost on import.
1311 CPPUNIT_ASSERT_EQUAL(OUString("_blank"),
1312 getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkTarget"));
1315 DECLARE_RTFEXPORT_TEST(testTdf107620, "tdf107620.docx")
1317 // This failed, RTF export didn't write the \htmautsp compat flag, the
1318 // original bugdoc resulting in 2 pages instead of 1.
1319 uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
1320 uno::Reference<beans::XPropertySet> xSettings(
1321 xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
1322 bool bAddParaTableSpacing = true;
1323 xSettings->getPropertyValue("AddParaTableSpacing") >>= bAddParaTableSpacing;
1324 CPPUNIT_ASSERT(!bAddParaTableSpacing);
1327 DECLARE_RTFEXPORT_TEST(testTdf104937, "tdf104937.rtf")
1329 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1330 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
1331 uno::UNO_QUERY);
1332 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1333 uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
1334 auto aSeparators = getProperty<uno::Sequence<text::TableColumnSeparator>>(
1335 xTableRows->getByIndex(1), "TableColumnSeparators");
1336 // First table's second row had 9 cells (so 8 separators).
1337 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(8), aSeparators.getLength());
1338 // This was 3174, i.e. last cell was wider than expected, while others were
1339 // narrower.
1340 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int16>(4500), aSeparators[7].Position);
1343 DECLARE_RTFEXPORT_TEST(testTdf112507, "tdf112507.rtf")
1345 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1346 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
1347 uno::UNO_QUERY);
1348 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1349 uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
1350 auto aSeparators = getProperty<uno::Sequence<text::TableColumnSeparator>>(
1351 xTableRows->getByIndex(1), "TableColumnSeparators");
1352 // First table's second row had 3 cells (so 2 separators).
1353 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), aSeparators.getLength());
1354 // This was 3333, i.e. the B2 cell was too narrow and the text needed 2 lines.
1355 CPPUNIT_ASSERT_GREATEREQUAL(5000, aSeparators[1].Position - aSeparators[0].Position);
1358 DECLARE_RTFEXPORT_TEST(testTdf107480, "tdf107480.rtf")
1360 // These were 176 (100 twips), as \htmautsp was parsed too late.
1361 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
1362 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
1363 getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
1364 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
1365 getProperty<sal_Int32>(getParagraph(2), "ParaTopMargin"));
1366 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
1367 getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
1370 DECLARE_RTFEXPORT_TEST(testWatermark, "watermark.rtf")
1372 uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY);
1373 CPPUNIT_ASSERT_EQUAL(OUString("WatermarkRTF"), xShape->getString());
1375 uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
1376 OUString aFont;
1377 float nFontSize;
1379 // Check transparency
1380 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty<sal_Int16>(xShape, "FillTransparence"));
1382 // Check font family
1383 CPPUNIT_ASSERT(xPropertySet->getPropertyValue("CharFontName") >>= aFont);
1384 CPPUNIT_ASSERT_EQUAL(OUString("DejaVu Serif"), aFont);
1386 // Check font size
1387 CPPUNIT_ASSERT(xPropertySet->getPropertyValue("CharHeight") >>= nFontSize);
1388 CPPUNIT_ASSERT_EQUAL(float(66), nFontSize);
1391 DECLARE_RTFEXPORT_TEST(testTdf109790, "tdf109790.rtf")
1393 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2), uno::UNO_QUERY);
1394 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1395 // Style information was reset, which caused character height to be 22.
1396 CPPUNIT_ASSERT_EQUAL(
1397 10.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight"));
1400 DECLARE_RTFEXPORT_TEST(testTdf112211, "tdf112211.rtf")
1402 // This was 0, \fi in a list level definition was not imported.
1403 auto xRules = getProperty<uno::Reference<container::XIndexAccess>>(
1404 getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
1405 comphelper::SequenceAsHashMap aRule(xRules->getByIndex(0));
1406 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-635), aRule["FirstLineIndent"].get<sal_Int32>());
1409 DECLARE_RTFEXPORT_TEST(testTdf113202, "tdf113202.rtf")
1411 // This failed, contextual spacing in 4th paragraph was lost.
1412 CPPUNIT_ASSERT(getProperty<bool>(getParagraph(4), "ParaContextMargin"));
1415 CPPUNIT_PLUGIN_IMPLEMENT();
1417 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */