fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sw / qa / extras / rtfexport / rtfexport.cxx
blob442665f75f946b01a406d135121038e26597c2ed
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
9 #include <com/sun/star/awt/Gradient.hpp>
10 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
11 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
12 #include <com/sun/star/drawing/FillStyle.hpp>
13 #include <com/sun/star/frame/XStorable.hpp>
14 #include <com/sun/star/table/BorderLine2.hpp>
15 #include <com/sun/star/table/ShadowFormat.hpp>
16 #include <com/sun/star/text/XFootnotesSupplier.hpp>
17 #include <com/sun/star/text/XPageCursor.hpp>
18 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
19 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
20 #include <com/sun/star/text/RelOrientation.hpp>
22 #include <vcl/svapp.hxx>
23 #include <swmodeltestbase.hxx>
25 class Test : public SwModelTestBase
27 public:
28 void testZoom();
29 void testFdo38176();
30 void testFdo49683();
31 void testFdo44174();
32 void testFdo50087();
33 void testFdo50831();
34 void testFdo48335();
35 void testFdo38244();
36 void testMathAccents();
37 void testMathEqarray();
38 void testMathD();
39 void testMathEscaping();
40 void testMathLim();
41 void testMathMatrix();
42 void testMathBox();
43 void testMathMso2007();
44 void testMathNary();
45 void testMathLimupp();
46 void testMathStrikeh();
47 void testMathPlaceholders();
48 void testMathRad();
49 void testMathSepchr();
50 void testMathSubscripts();
51 void testMathVerticalstacks();
52 void testMathRuns();
53 void testFdo53113();
54 void testFdo55939();
55 void testTextFrames();
56 void testFdo53604();
57 void testFdo52286();
58 void testFdo61507();
59 void testFdo30983();
60 void testPlaceholder();
61 void testMnor();
62 void testI120928();
63 void testBookmark();
64 void testHyperlink();
65 void testTextFrameBorders();
66 void testTextframeGradient();
67 void testFdo66682();
68 void testFdo66743();
70 CPPUNIT_TEST_SUITE(Test);
71 #if !defined(MACOSX) && !defined(WNT)
72 CPPUNIT_TEST(run);
73 #endif
74 CPPUNIT_TEST_SUITE_END();
76 private:
77 void run();
80 void Test::run()
82 MethodEntry<Test> aMethods[] = {
83 {"zoom.rtf", &Test::testZoom},
84 {"fdo38176.rtf", &Test::testFdo38176},
85 {"fdo49683.rtf", &Test::testFdo49683},
86 {"fdo44174.rtf", &Test::testFdo44174},
87 {"fdo50087.rtf", &Test::testFdo50087},
88 {"fdo50831.rtf", &Test::testFdo50831},
89 {"fdo48335.odt", &Test::testFdo48335},
90 {"fdo38244.rtf", &Test::testFdo38244},
91 {"math-accents.rtf", &Test::testMathAccents},
92 {"math-eqarray.rtf", &Test::testMathEqarray},
93 {"math-d.rtf", &Test::testMathD},
94 {"math-escaping.rtf", &Test::testMathEscaping},
95 {"math-lim.rtf", &Test::testMathLim},
96 {"math-matrix.rtf", &Test::testMathMatrix},
97 {"math-mbox.rtf", &Test::testMathBox},
98 {"math-mso2007.rtf", &Test::testMathMso2007},
99 {"math-nary.rtf", &Test::testMathNary},
100 {"math-limupp.rtf", &Test::testMathLimupp},
101 {"math-strikeh.rtf", &Test::testMathStrikeh},
102 {"math-placeholders.rtf", &Test::testMathPlaceholders},
103 {"math-rad.rtf", &Test::testMathRad},
104 {"math-sepchr.rtf", &Test::testMathSepchr},
105 {"math-subscripts.rtf", &Test::testMathSubscripts},
106 {"math-vertical-stacks.rtf", &Test::testMathVerticalstacks},
107 {"math-runs.rtf", &Test::testMathRuns},
108 {"fdo53113.odt", &Test::testFdo53113},
109 {"fdo55939.odt", &Test::testFdo55939},
110 {"textframes.odt", &Test::testTextFrames},
111 {"fdo53604.odt", &Test::testFdo53604},
112 {"fdo52286.odt", &Test::testFdo52286},
113 {"fdo61507.rtf", &Test::testFdo61507},
114 {"fdo30983.rtf", &Test::testFdo30983},
115 {"placeholder.odt", &Test::testPlaceholder},
116 {"mnor.rtf", &Test::testMnor},
117 {"i120928.rtf", &Test::testI120928},
118 {"bookmark.rtf", &Test::testBookmark},
119 {"hyperlink.rtf", &Test::testHyperlink},
120 {"textframe-borders.rtf", &Test::testTextFrameBorders},
121 {"textframe-gradient.rtf", &Test::testTextframeGradient},
122 {"fdo66682.rtf", &Test::testFdo66682},
123 {"fdo66743.rtf", &Test::testFdo66743},
125 // Don't test the first import of these, for some reason those tests fail
126 const char* aBlacklist[] = {
127 "math-eqarray.rtf",
128 "math-escaping.rtf",
129 "math-lim.rtf",
130 "math-mso2007.rtf",
131 "math-nary.rtf",
132 "math-rad.rtf",
133 "math-vertical-stacks.rtf",
134 "math-runs.rtf",
136 std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist));
137 header();
138 for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
140 MethodEntry<Test>& rEntry = aMethods[i];
141 load("/sw/qa/extras/rtfexport/data/", rEntry.pName);
142 // If the testcase is stored in some other format, it's pointless to test.
143 if (OString(rEntry.pName).endsWith(".rtf") && std::find(vBlacklist.begin(), vBlacklist.end(), rEntry.pName) == vBlacklist.end())
144 (this->*rEntry.pMethod)();
145 reload("Rich Text Format");
146 (this->*rEntry.pMethod)();
147 finish();
151 void Test::testZoom()
153 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
154 uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
155 uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings());
156 sal_Int16 nValue = 0;
157 xPropertySet->getPropertyValue("ZoomValue") >>= nValue;
158 CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue);
161 void Test::testFdo38176()
163 CPPUNIT_ASSERT_EQUAL(9, getLength());
166 void Test::testFdo49683()
168 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
169 uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
170 uno::Sequence<OUString> aKeywords(xDocumentProperties->getKeywords());
171 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aKeywords.getLength());
172 CPPUNIT_ASSERT_EQUAL(OUString("one"), aKeywords[0]);
173 CPPUNIT_ASSERT_EQUAL(OUString("two"), aKeywords[1]);
176 void Test::testFdo44174()
178 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
179 uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
180 uno::Reference<beans::XPropertySet> xPropertySet(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
181 OUString aValue;
182 xPropertySet->getPropertyValue("PageStyleName") >>= aValue;
183 CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aValue);
186 void Test::testFdo50087()
188 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
189 uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
190 CPPUNIT_ASSERT_EQUAL(OUString("Title"), xDocumentProperties->getTitle());
191 CPPUNIT_ASSERT_EQUAL(OUString("Subject"), xDocumentProperties->getSubject());
192 CPPUNIT_ASSERT_EQUAL(OUString("First line.\nSecond line."), xDocumentProperties->getDescription());
195 void Test::testFdo50831()
197 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
198 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
199 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
200 uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
201 float fValue = 0;
202 xPropertySet->getPropertyValue("CharHeight") >>= fValue;
203 CPPUNIT_ASSERT_EQUAL(10.f, fValue);
206 void Test::testFdo48335()
209 * The problem was that we exported a fake pagebreak, make sure it's just a soft one now.
211 * oParas = ThisComponent.Text.createEnumeration
212 * oPara = oParas.nextElement
213 * oPara = oParas.nextElement
214 * oPara = oParas.nextElement
215 * oRuns = oPara.createEnumeration
216 * oRun = oRuns.nextElement
217 * xray oRun.TextPortionType 'was Text, should be SoftPageBreak
219 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
220 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
221 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
222 for (int i = 0; i < 2; i++)
223 xParaEnum->nextElement();
224 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
225 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
226 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
227 OUString aValue;
228 xPropertySet->getPropertyValue("TextPortionType") >>= aValue;
229 CPPUNIT_ASSERT_EQUAL(OUString("SoftPageBreak"), aValue);
232 void Test::testFdo38244()
234 // See ooxmlexport's testFdo38244().
235 // Test comment range feature.
236 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
237 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
238 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
239 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
240 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
241 xRunEnum->nextElement();
242 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
243 CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
244 xRunEnum->nextElement();
245 xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
246 CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
248 // Test initials.
249 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
250 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
251 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
252 xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
253 CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
256 void Test::testMathAccents()
258 OUString aActual = getFormula(getRun(getParagraph(1), 1));
259 OUString aExpected("acute {a} grave {a} check {a} breve {a} circle {a} widevec {a} widetilde {a} widehat {a} dot {a} widevec {a} widevec {a} widetilde {a} underline {a}");
260 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
263 void Test::testMathEqarray()
265 OUString aActual = getFormula(getRun(getParagraph(1), 1));
266 OUString aExpected("y = left lbrace stack { 0, x < 0 # 1, x = 0 # {x} ^ {2} , x > 0 } right none");
267 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
270 void Test::testMathD()
272 OUString aActual = getFormula(getRun(getParagraph(1), 1));
273 OUString aExpected("left (x mline y mline z right ) left (1 right ) left [2 right ] left ldbracket 3 right rdbracket left lline 4 right rline left ldline 5 right rdline left langle 6 right rangle left langle a mline b right rangle left ({x} over {y} right )");
274 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
277 void Test::testMathEscaping()
279 OUString aActual = getFormula(getRun(getParagraph(1), 1));
280 OUString aExpected( \\{", 5, RTL_TEXTENCODING_UTF8);
281 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
284 void Test::testMathLim()
286 OUString aActual = getFormula(getRun(getParagraph(1), 1));
287 OUString aExpected("lim from {x → 1} {x}", 22, RTL_TEXTENCODING_UTF8);
288 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
291 void Test::testMathMatrix()
293 OUString aActual = getFormula(getRun(getParagraph(1), 1));
294 OUString aExpected("left [matrix {1 # 2 ## 3 # 4} right ]");
295 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
298 void Test::testMathBox()
300 OUString aActual = getFormula(getRun(getParagraph(1), 1));
301 OUString aExpected("a");
302 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
305 void Test::testMathMso2007()
307 OUString aActual = getFormula(getRun(getParagraph(1), 1));
308 OUString aExpected("A = π {r} ^ {2}", 16, RTL_TEXTENCODING_UTF8);
309 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
311 aActual = getFormula(getRun(getParagraph(2), 1));
312 aExpected = OUString("{left (x + a right )} ^ {n} = sum from {k = 0} to {n} {left (stack { n # k } right ) {x} ^ {k} {a} ^ {n − k}}", 111, RTL_TEXTENCODING_UTF8);
313 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
315 aActual = getFormula(getRun(getParagraph(3), 1));
316 aExpected = OUString("{left (1 + x right )} ^ {n} = 1 + {nx} over {1 !} + {n left (n − 1 right ) {x} ^ {2}} over {2 !} + …", 104, RTL_TEXTENCODING_UTF8);
317 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
319 aActual = getFormula(getRun(getParagraph(4), 1));
320 aExpected = OUString("f left (x right ) = {a} rsub {0} + sum from {n = 1} to {∞} {left ({a} rsub {n} cos {nπx} over {L} + {b} rsub {n} sin {nπx} over {L} right )}", 144,
321 RTL_TEXTENCODING_UTF8);
322 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
324 aActual = getFormula(getRun(getParagraph(5), 1));
325 aExpected = "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}";
326 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
328 aActual = getFormula(getRun(getParagraph(6), 1));
329 aExpected = OUString("x = {− b ± sqrt {{b} ^ {2} − 4 ac}} over {2 a}", 51, RTL_TEXTENCODING_UTF8);
330 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
332 aActual = getFormula(getRun(getParagraph(7), 1));
333 aExpected = OUString("{e} ^ {x} = 1 + {x} over {1 !} + {{x} ^ {2}} over {2 !} + {{x} ^ {3}} over {3 !} + … , − ∞ < x < ∞", 106, RTL_TEXTENCODING_UTF8);
334 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
336 aActual = getFormula(getRun(getParagraph(8), 1));
337 aExpected = OUString("sin α ± sin β = 2 sin {1} over {2} left (α ± β right ) cos {1} over {2} left (α ∓ β right )", 101, RTL_TEXTENCODING_UTF8);
338 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
340 aActual = getFormula(getRun(getParagraph(9), 1));
341 aExpected = OUString("cos α + cos β = 2 cos {1} over {2} left (α + β right ) cos {1} over {2} left (α − β right )", 99, RTL_TEXTENCODING_UTF8);
342 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
345 void Test::testMathNary()
347 OUString aActual = getFormula(getRun(getParagraph(1), 1));
348 OUString aExpected("lllint from {1} to {2} {x + 1} prod from {a} {b} sum to {2} {x}");
349 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
352 void Test::testMathLimupp()
354 OUString aActual = getFormula(getRun(getParagraph(1), 1));
355 CPPUNIT_ASSERT_EQUAL(OUString("{abcd} overbrace {4}"), aActual);
357 aActual = getFormula(getRun(getParagraph(2), 1));
358 CPPUNIT_ASSERT_EQUAL(OUString("{xyz} underbrace {3}"), aActual);
361 void Test::testMathStrikeh()
363 OUString aActual = getFormula(getRun(getParagraph(1), 1));
364 CPPUNIT_ASSERT_EQUAL(OUString("overstrike {abc}"), aActual);
367 void Test::testMathPlaceholders()
369 OUString aActual = getFormula(getRun(getParagraph(1), 1));
370 CPPUNIT_ASSERT_EQUAL(OUString("sum from <?> to <?> <?>"), aActual);
373 void Test::testMathRad()
375 OUString aActual = getFormula(getRun(getParagraph(1), 1));
376 CPPUNIT_ASSERT_EQUAL(OUString("sqrt {4} nroot {3} {x + 1}"), aActual);
379 void Test::testMathSepchr()
381 OUString aActual = getFormula(getRun(getParagraph(1), 1));
382 CPPUNIT_ASSERT_EQUAL(OUString("AxByBzC"), aActual);
385 void Test::testMathSubscripts()
387 OUString aActual = getFormula(getRun(getParagraph(1), 1));
388 OUString aExpected("{x} ^ {y} + {e} ^ {x} {x} ^ {b} {x} rsub {b} {a} rsub {c} rsup {b} {x} lsub {2} lsup {1} {{x csup {6} csub {3}} lsub {4} lsup {5}} rsub {2} rsup {1}");
389 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
392 void Test::testMathVerticalstacks()
394 CPPUNIT_ASSERT_EQUAL(OUString("{a} over {b}"), getFormula(getRun(getParagraph(1), 1)));
395 CPPUNIT_ASSERT_EQUAL(OUString("{a} / {b}"), getFormula(getRun(getParagraph(2), 1)));
396 CPPUNIT_ASSERT_EQUAL(OUString("stack { a # b }"), getFormula(getRun(getParagraph(3), 1)));
397 CPPUNIT_ASSERT_EQUAL(OUString("stack { a # stack { b # c } }"), getFormula(getRun(getParagraph(4), 1)));
400 void Test::testMathRuns()
402 // was [](){}, i.e. first curly bracket had an incorrect position
403 CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"), getFormula(getRun(getParagraph(1), 1)));
406 void Test::testFdo53113()
409 * The problem was that a custom shape was missings its second (and all the other remaining) coordinates.
411 * oShape = ThisComponent.DrawPage(0)
412 * oPathPropVec = oShape.CustomShapeGeometry(1).Value
413 * oCoordinates = oPathPropVec(0).Value
414 * xray oCoordinates(1).First.Value ' 535
415 * xray oCoordinates(1).Second.Value ' 102
418 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
419 uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
420 uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xDraws->getByIndex(0), "CustomShapeGeometry");
421 uno::Sequence<beans::PropertyValue> aPathProps;
422 for (int i = 0; i < aProps.getLength(); ++i)
424 const beans::PropertyValue& rProp = aProps[i];
425 if (rProp.Name == "Path")
426 rProp.Value >>= aPathProps;
428 uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aPairs;
429 for (int i = 0; i < aPathProps.getLength(); ++i)
431 const beans::PropertyValue& rProp = aPathProps[i];
432 if (rProp.Name == "Coordinates")
433 rProp.Value >>= aPairs;
435 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aPairs.getLength());
436 CPPUNIT_ASSERT_EQUAL(sal_Int32(535), aPairs[1].First.Value.get<sal_Int32>());
437 CPPUNIT_ASSERT_EQUAL(sal_Int32(102), aPairs[1].Second.Value.get<sal_Int32>());
440 void Test::testFdo55939()
442 // The problem was that the exported RTF was invalid.
443 uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
444 getRun(xParagraph, 1, "Main text before footnote.");
445 // Why the tab has to be removed here?
446 CPPUNIT_ASSERT_EQUAL(OUString("Footnote text."),
447 getProperty< uno::Reference<text::XTextRange> >(getRun(xParagraph, 2), "Footnote")->getText()->getString().replaceAll("\t", ""));
448 getRun(xParagraph, 3, " Text after the footnote."); // However, this leading space is intentional and OK.
451 void Test::testTextFrames()
453 // The output was simply invalid, so let's check if all 3 frames were imported back.
454 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
455 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
456 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount());
459 void Test::testFdo53604()
461 // Invalid output on empty footnote.
462 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
463 uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
464 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
467 void Test::testFdo52286()
469 // The problem was that font size wasn't reduced in sub/super script.
470 CPPUNIT_ASSERT_EQUAL(sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapementHeight"));
471 CPPUNIT_ASSERT_EQUAL(sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(2), 2), "CharEscapementHeight"));
474 void Test::testFdo61507()
477 * Unicode-only characters in \title confused Wordpad. Once the exporter
478 * was fixed to guard the problematic characters with \upr and \ud, the
479 * importer didn't cope with these new keywords.
482 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
483 uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
484 OUString aExpected = OUString("ÉÁŐŰ∭", 11, RTL_TEXTENCODING_UTF8);
485 CPPUNIT_ASSERT_EQUAL(aExpected, xDocumentProperties->getTitle());
487 // Only "Hello.", no additional characters.
488 CPPUNIT_ASSERT_EQUAL(6, getLength());
491 void Test::testFdo30983()
493 // These were 'page text area', not 'entire page', i.e. both the horizontal
494 // and vertical positions were incorrect.
495 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
496 uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
497 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(0), "HoriOrientRelation"));
498 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(0), "VertOrientRelation"));
501 void Test::testPlaceholder()
503 // Only the field text was exported, make sure we still have a field with the correct Hint text.
504 uno::Reference<text::XTextRange> xRun(getRun(getParagraph(1), 2));
505 CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(xRun, "TextPortionType"));
506 uno::Reference<beans::XPropertySet> xField = getProperty< uno::Reference<beans::XPropertySet> >(xRun, "TextField");
507 CPPUNIT_ASSERT_EQUAL(OUString("place holder"), getProperty<OUString>(xField, "Hint"));
510 void Test::testMnor()
512 // \mnor wasn't handled, leading to missing quotes around "divF" and so on.
513 OUString aActual = getFormula(getRun(getParagraph(1), 1));
514 OUString aExpected("iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\" \"n\" dS}", 74, RTL_TEXTENCODING_UTF8);
515 CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
518 void Test::testI120928()
520 // \listpicture and \levelpicture0 was ignored, leading to missing graphic bullet in numbering.
521 uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
522 uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
523 uno::Sequence<beans::PropertyValue> aProps;
524 xLevels->getByIndex(0) >>= aProps; // 1st level
526 bool bIsGraphic = false;
527 for (int i = 0; i < aProps.getLength(); ++i)
529 const beans::PropertyValue& rProp = aProps[i];
531 if (rProp.Name == "NumberingType")
532 CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>());
533 else if (rProp.Name == "GraphicURL")
534 bIsGraphic = true;
536 CPPUNIT_ASSERT_EQUAL(true, bIsGraphic);
539 void Test::testBookmark()
541 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
542 uno::Reference<text::XTextContent> xBookmark(xBookmarksSupplier->getBookmarks()->getByName("firstword"), uno::UNO_QUERY);
543 CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xBookmark->getAnchor()->getString());
546 void Test::testHyperlink()
548 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 1, "Hello"), "HyperLinkURL"));
549 CPPUNIT_ASSERT_EQUAL(OUString("http://en.wikipedia.org/wiki/World"), getProperty<OUString>(getRun(getParagraph(1), 2, "world"), "HyperLinkURL"));
550 CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 3, "!"), "HyperLinkURL"));
553 void Test::testTextFrameBorders()
555 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
556 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
557 uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
558 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xFrame, "BackColor"));
560 table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder");
561 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aBorder.Color);
562 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth);
564 table::ShadowFormat aShadowFormat = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat");
565 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location);
566 CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth);
567 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aShadowFormat.Color);
570 void Test::testTextframeGradient()
572 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
573 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
574 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
576 uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
577 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
578 awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
579 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor);
580 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor);
581 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
583 xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
584 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
585 aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
586 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor);
587 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor);
588 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
591 void Test::testFdo66682()
593 uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
594 uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
595 uno::Sequence<beans::PropertyValue> aProps;
596 xLevels->getByIndex(0) >>= aProps; // 1st level
598 OUString aSuffix;
599 for (int i = 0; i < aProps.getLength(); ++i)
601 const beans::PropertyValue& rProp = aProps[i];
603 if (rProp.Name == "Suffix")
604 aSuffix = rProp.Value.get<OUString>();
606 // Suffix was '\0' instead of ' '.
607 CPPUNIT_ASSERT_EQUAL(OUString(" "), aSuffix);
610 void Test::testFdo66743()
612 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
613 uno::Reference<table::XCell> xCell = xTable->getCellByName("A1");
614 // This was too dark, 0x7f7f7f.
615 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xd8d8d8), getProperty<sal_Int32>(xCell, "BackColor"));
618 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
620 CPPUNIT_PLUGIN_IMPLEMENT();
622 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */