Line data Source code
1 : /*
2 : * This file is part of the LibreOffice project.
3 : *
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 : */
8 :
9 : #include <swmodeltestbase.hxx>
10 :
11 : #include <com/sun/star/awt/Gradient.hpp>
12 : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
13 : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
14 : #include <com/sun/star/drawing/FillStyle.hpp>
15 : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
16 : #include <com/sun/star/frame/XStorable.hpp>
17 : #include <com/sun/star/table/BorderLine2.hpp>
18 : #include <com/sun/star/table/ShadowFormat.hpp>
19 : #include <com/sun/star/text/FontEmphasis.hpp>
20 : #include <com/sun/star/text/RelOrientation.hpp>
21 : #include <com/sun/star/text/TextContentAnchorType.hpp>
22 : #include <com/sun/star/text/XFootnotesSupplier.hpp>
23 : #include <com/sun/star/text/XPageCursor.hpp>
24 : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
25 : #include <com/sun/star/view/XViewSettingsSupplier.hpp>
26 :
27 : #include <vcl/svapp.hxx>
28 :
29 252 : class Test : public SwModelTestBase
30 : {
31 : public:
32 252 : Test() : SwModelTestBase("/sw/qa/extras/rtfexport/data/", "Rich Text Format") {}
33 :
34 126 : bool mustTestImportOf(const char* filename) const SAL_OVERRIDE
35 : {
36 : // Don't test the first import of these, for some reason those tests fail
37 : const char* aBlacklist[] =
38 : {
39 : "math-eqarray.rtf",
40 : "math-escaping.rtf",
41 : "math-lim.rtf",
42 : "math-mso2007.rtf",
43 : "math-nary.rtf",
44 : "math-rad.rtf",
45 : "math-vertical-stacks.rtf",
46 : "math-runs.rtf",
47 126 : };
48 126 : std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist));
49 :
50 : // If the testcase is stored in some other format, it's pointless to test.
51 126 : return (OString(filename).endsWith(".rtf") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end());
52 : }
53 : };
54 :
55 28 : DECLARE_RTFEXPORT_TEST(testZoom, "zoom.rtf")
56 : {
57 4 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
58 8 : uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
59 8 : uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings());
60 4 : sal_Int16 nValue = 0;
61 4 : xPropertySet->getPropertyValue("ZoomValue") >>= nValue;
62 8 : CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue);
63 4 : }
64 :
65 28 : DECLARE_RTFEXPORT_TEST(testFdo38176, "fdo38176.rtf")
66 : {
67 4 : CPPUNIT_ASSERT_EQUAL(9, getLength());
68 4 : }
69 :
70 28 : DECLARE_RTFEXPORT_TEST(testFdo49683, "fdo49683.rtf")
71 : {
72 4 : uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
73 8 : uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
74 8 : uno::Sequence<OUString> aKeywords(xDocumentProperties->getKeywords());
75 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aKeywords.getLength());
76 4 : CPPUNIT_ASSERT_EQUAL(OUString("one"), aKeywords[0]);
77 8 : CPPUNIT_ASSERT_EQUAL(OUString("two"), aKeywords[1]);
78 4 : }
79 :
80 28 : DECLARE_RTFEXPORT_TEST(testFdo44174, "fdo44174.rtf")
81 : {
82 4 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
83 8 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
84 8 : uno::Reference<beans::XPropertySet> xPropertySet(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
85 8 : OUString aValue;
86 4 : xPropertySet->getPropertyValue("PageStyleName") >>= aValue;
87 8 : CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aValue);
88 4 : }
89 :
90 28 : DECLARE_RTFEXPORT_TEST(testFdo50087, "fdo50087.rtf")
91 : {
92 4 : uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
93 8 : uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
94 4 : CPPUNIT_ASSERT_EQUAL(OUString("Title"), xDocumentProperties->getTitle());
95 4 : CPPUNIT_ASSERT_EQUAL(OUString("Subject"), xDocumentProperties->getSubject());
96 8 : CPPUNIT_ASSERT_EQUAL(OUString("First line.\nSecond line."), xDocumentProperties->getDescription());
97 4 : }
98 :
99 28 : DECLARE_RTFEXPORT_TEST(testFdo50831, "fdo50831.rtf")
100 : {
101 4 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
102 8 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
103 8 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
104 8 : uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
105 4 : float fValue = 0;
106 4 : xPropertySet->getPropertyValue("CharHeight") >>= fValue;
107 8 : CPPUNIT_ASSERT_EQUAL(10.f, fValue);
108 4 : }
109 :
110 26 : DECLARE_RTFEXPORT_TEST(testFdo48335, "fdo48335.odt")
111 : {
112 : /*
113 : * The problem was that we exported a fake pagebreak, make sure it's just a soft one now.
114 : *
115 : * oParas = ThisComponent.Text.createEnumeration
116 : * oPara = oParas.nextElement
117 : * oPara = oParas.nextElement
118 : * oPara = oParas.nextElement
119 : * oRuns = oPara.createEnumeration
120 : * oRun = oRuns.nextElement
121 : * xray oRun.TextPortionType 'was Text, should be SoftPageBreak
122 : */
123 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
124 4 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
125 4 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
126 6 : for (int i = 0; i < 2; i++)
127 4 : xParaEnum->nextElement();
128 4 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
129 4 : uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
130 4 : uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
131 4 : OUString aValue;
132 2 : xPropertySet->getPropertyValue("TextPortionType") >>= aValue;
133 4 : CPPUNIT_ASSERT_EQUAL(OUString("SoftPageBreak"), aValue);
134 2 : }
135 :
136 28 : DECLARE_RTFEXPORT_TEST(testFdo38244, "fdo38244.rtf")
137 : {
138 : // See ooxmlexport's testFdo38244().
139 : // Test comment range feature.
140 4 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
141 8 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
142 8 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
143 8 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
144 8 : uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
145 4 : xRunEnum->nextElement();
146 8 : uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
147 4 : CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(xPropertySet, "TextPortionType"));
148 4 : xRunEnum->nextElement();
149 4 : xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
150 4 : CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
151 :
152 : // Test initials.
153 8 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
154 8 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
155 8 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
156 4 : xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
157 8 : CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
158 4 : }
159 :
160 26 : DECLARE_RTFEXPORT_TEST(testCommentsNested, "comments-nested.odt")
161 : {
162 2 : uno::Reference<beans::XPropertySet> xOuter(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField"), uno::UNO_QUERY);
163 2 : CPPUNIT_ASSERT_EQUAL(OUString("Outer"), getProperty<OUString>(xOuter, "Content").trim());
164 :
165 4 : uno::Reference<beans::XPropertySet> xInner(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 4), "TextField"), uno::UNO_QUERY);
166 4 : CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content").trim());
167 2 : }
168 :
169 28 : DECLARE_RTFEXPORT_TEST(testMathAccents, "math-accents.rtf")
170 : {
171 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
172 8 : 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}");
173 8 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
174 4 : }
175 :
176 26 : DECLARE_RTFEXPORT_TEST(testMathEqarray, "math-eqarray.rtf")
177 : {
178 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
179 4 : OUString aExpected("y = left lbrace stack { 0, x < 0 # 1, x = 0 # {x} ^ {2} , x > 0 } right none");
180 4 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
181 2 : }
182 :
183 28 : DECLARE_RTFEXPORT_TEST(testMathD, "math-d.rtf")
184 : {
185 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
186 8 : 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 )");
187 8 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
188 4 : }
189 :
190 26 : DECLARE_RTFEXPORT_TEST(testMathEscaping, "math-escaping.rtf")
191 : {
192 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
193 4 : OUString aExpected("\xc3\xa1 \\{", 5, RTL_TEXTENCODING_UTF8);
194 4 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
195 2 : }
196 :
197 26 : DECLARE_RTFEXPORT_TEST(testMathLim, "math-lim.rtf")
198 : {
199 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
200 4 : OUString aExpected("lim from {x \xe2\x86\x92 1} {x}", 22, RTL_TEXTENCODING_UTF8);
201 4 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
202 2 : }
203 :
204 28 : DECLARE_RTFEXPORT_TEST(testMathMatrix, "math-matrix.rtf")
205 : {
206 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
207 8 : OUString aExpected("left [matrix {1 # 2 ## 3 # 4} right ]");
208 8 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
209 4 : }
210 :
211 28 : DECLARE_RTFEXPORT_TEST(testMathBox, "math-mbox.rtf")
212 : {
213 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
214 8 : OUString aExpected("a");
215 8 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
216 4 : }
217 :
218 26 : DECLARE_RTFEXPORT_TEST(testMathMso2007, "math-mso2007.rtf")
219 : {
220 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
221 4 : OUString aExpected("A = \xcf\x80 {r} ^ {2}", 16, RTL_TEXTENCODING_UTF8);
222 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
223 :
224 2 : aActual = getFormula(getRun(getParagraph(2), 1));
225 2 : aExpected = OUString("{left (x + a right )} ^ {n} = sum from {k = 0} to {n} {left (stack { n # k } right ) {x} ^ {k} {a} ^ {n \xe2\x88\x92 k}}", 111, RTL_TEXTENCODING_UTF8);
226 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
227 :
228 2 : aActual = getFormula(getRun(getParagraph(3), 1));
229 2 : aExpected = OUString("{left (1 + x right )} ^ {n} = 1 + {nx} over {1 !} + {n left (n \xe2\x88\x92 1 right ) {x} ^ {2}} over {2 !} + \xe2\x80\xa6", 104, RTL_TEXTENCODING_UTF8);
230 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
231 :
232 2 : aActual = getFormula(getRun(getParagraph(4), 1));
233 4 : aExpected = OUString("f left (x right ) = {a} rsub {0} + sum from {n = 1} to {\xe2\x88\x9e} {left ({a} rsub {n} cos {n\xcf\x80x} over {L} + {b} rsub {n} sin {n\xcf\x80x} over {L} right )}", 144,
234 2 : RTL_TEXTENCODING_UTF8);
235 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
236 :
237 2 : aActual = getFormula(getRun(getParagraph(5), 1));
238 2 : aExpected = "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}";
239 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
240 :
241 2 : aActual = getFormula(getRun(getParagraph(6), 1));
242 2 : aExpected = OUString("x = {\xe2\x88\x92 b \xc2\xb1 sqrt {{b} ^ {2} \xe2\x88\x92 4 ac}} over {2 a}", 51, RTL_TEXTENCODING_UTF8);
243 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
244 :
245 2 : aActual = getFormula(getRun(getParagraph(7), 1));
246 2 : aExpected = OUString("{e} ^ {x} = 1 + {x} over {1 !} + {{x} ^ {2}} over {2 !} + {{x} ^ {3}} over {3 !} + \xe2\x80\xa6 , \xe2\x88\x92 \xe2\x88\x9e < x < \xe2\x88\x9e", 106, RTL_TEXTENCODING_UTF8);
247 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
248 :
249 2 : aActual = getFormula(getRun(getParagraph(8), 1));
250 2 : aExpected = OUString("sin \xce\xb1 \xc2\xb1 sin \xce\xb2 = 2 sin {1} over {2} left (\xce\xb1 \xc2\xb1 \xce\xb2 right ) cos {1} over {2} left (\xce\xb1 \xe2\x88\x93 \xce\xb2 right )", 101, RTL_TEXTENCODING_UTF8);
251 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
252 :
253 2 : aActual = getFormula(getRun(getParagraph(9), 1));
254 2 : aExpected = OUString("cos \xce\xb1 + cos \xce\xb2 = 2 cos {1} over {2} left (\xce\xb1 + \xce\xb2 right ) cos {1} over {2} left (\xce\xb1 \xe2\x88\x92 \xce\xb2 right )", 99, RTL_TEXTENCODING_UTF8);
255 4 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
256 2 : }
257 :
258 26 : DECLARE_RTFEXPORT_TEST(testMathNary, "math-nary.rtf")
259 : {
260 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
261 4 : OUString aExpected("lllint from {1} to {2} {x + 1} prod from {a} {b} sum to {2} {x}");
262 4 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
263 2 : }
264 :
265 28 : DECLARE_RTFEXPORT_TEST(testMathLimupp, "math-limupp.rtf")
266 : {
267 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
268 4 : CPPUNIT_ASSERT_EQUAL(OUString("{abcd} overbrace {4}"), aActual);
269 :
270 4 : aActual = getFormula(getRun(getParagraph(2), 1));
271 4 : CPPUNIT_ASSERT_EQUAL(OUString("{xyz} underbrace {3}"), aActual);
272 4 : }
273 :
274 28 : DECLARE_RTFEXPORT_TEST(testMathStrikeh, "math-strikeh.rtf")
275 : {
276 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
277 4 : CPPUNIT_ASSERT_EQUAL(OUString("overstrike {abc}"), aActual);
278 4 : }
279 :
280 28 : DECLARE_RTFEXPORT_TEST(testMathPlaceholders, "math-placeholders.rtf")
281 : {
282 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
283 4 : CPPUNIT_ASSERT_EQUAL(OUString("sum from <?> to <?> <?>"), aActual);
284 4 : }
285 :
286 26 : DECLARE_RTFEXPORT_TEST(testMathRad, "math-rad.rtf")
287 : {
288 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
289 2 : CPPUNIT_ASSERT_EQUAL(OUString("sqrt {4} nroot {3} {x + 1}"), aActual);
290 2 : }
291 :
292 28 : DECLARE_RTFEXPORT_TEST(testMathSepchr, "math-sepchr.rtf")
293 : {
294 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
295 4 : CPPUNIT_ASSERT_EQUAL(OUString("AxByBzC"), aActual);
296 4 : }
297 :
298 28 : DECLARE_RTFEXPORT_TEST(testMathSubscripts, "math-subscripts.rtf")
299 : {
300 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
301 8 : 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}");
302 8 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
303 4 : }
304 :
305 26 : DECLARE_RTFEXPORT_TEST(testMathVerticalstacks, "math-vertical-stacks.rtf")
306 : {
307 2 : CPPUNIT_ASSERT_EQUAL(OUString("{a} over {b}"), getFormula(getRun(getParagraph(1), 1)));
308 2 : CPPUNIT_ASSERT_EQUAL(OUString("{a} / {b}"), getFormula(getRun(getParagraph(2), 1)));
309 2 : CPPUNIT_ASSERT_EQUAL(OUString("stack { a # b }"), getFormula(getRun(getParagraph(3), 1)));
310 2 : CPPUNIT_ASSERT_EQUAL(OUString("stack { a # stack { b # c } }"), getFormula(getRun(getParagraph(4), 1)));
311 2 : }
312 :
313 26 : DECLARE_RTFEXPORT_TEST(testMathRuns, "math-runs.rtf")
314 : {
315 : // was [](){}, i.e. first curly bracket had an incorrect position
316 2 : CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"), getFormula(getRun(getParagraph(1), 1)));
317 2 : }
318 :
319 26 : DECLARE_RTFEXPORT_TEST(testFdo77979, "fdo77979.odt")
320 : {
321 : // font name is encoded with \fcharset of font
322 2 : OUString aExpected("\xE5\xBE\xAE\xE8\xBD\xAF\xE9\x9B\x85\xE9\xBB\x91", 12, RTL_TEXTENCODING_UTF8);
323 2 : CPPUNIT_ASSERT_EQUAL(aExpected, getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
324 2 : }
325 :
326 26 : DECLARE_RTFEXPORT_TEST(testFdo53113, "fdo53113.odt")
327 : {
328 : /*
329 : * The problem was that a custom shape was missings its second (and all the other remaining) coordinates.
330 : *
331 : * oShape = ThisComponent.DrawPage(0)
332 : * oPathPropVec = oShape.CustomShapeGeometry(1).Value
333 : * oCoordinates = oPathPropVec(0).Value
334 : * xray oCoordinates(1).First.Value ' 535
335 : * xray oCoordinates(1).Second.Value ' 102
336 : */
337 :
338 2 : uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(getShape(1), "CustomShapeGeometry");
339 4 : uno::Sequence<beans::PropertyValue> aPathProps;
340 8 : for (int i = 0; i < aProps.getLength(); ++i)
341 : {
342 6 : const beans::PropertyValue& rProp = aProps[i];
343 6 : if (rProp.Name == "Path")
344 2 : rProp.Value >>= aPathProps;
345 : }
346 4 : uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aPairs;
347 6 : for (int i = 0; i < aPathProps.getLength(); ++i)
348 : {
349 4 : const beans::PropertyValue& rProp = aPathProps[i];
350 4 : if (rProp.Name == "Coordinates")
351 2 : rProp.Value >>= aPairs;
352 : }
353 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aPairs.getLength());
354 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(535), aPairs[1].First.Value.get<sal_Int32>());
355 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(102), aPairs[1].Second.Value.get<sal_Int32>());
356 2 : }
357 :
358 26 : DECLARE_RTFEXPORT_TEST(testFdo55939, "fdo55939.odt")
359 : {
360 : // The problem was that the exported RTF was invalid.
361 : // Also, the 'Footnote text.' had an additional newline at its end.
362 2 : uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
363 2 : getRun(xParagraph, 1, "Main text before footnote.");
364 : // Why the tab has to be removed here?
365 4 : CPPUNIT_ASSERT_EQUAL(OUString("Footnote text."),
366 2 : getProperty< uno::Reference<text::XTextRange> >(getRun(xParagraph, 2), "Footnote")->getText()->getString().replaceAll("\t", ""));
367 2 : getRun(xParagraph, 3, " Text after the footnote."); // However, this leading space is intentional and OK.
368 2 : }
369 :
370 26 : DECLARE_RTFEXPORT_TEST(testTextFrames, "textframes.odt")
371 : {
372 : // The output was simply invalid, so let's check if all 3 frames were imported back.
373 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
374 4 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
375 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount());
376 2 : }
377 :
378 26 : DECLARE_RTFEXPORT_TEST(testFdo53604, "fdo53604.odt")
379 : {
380 : // Invalid output on empty footnote.
381 2 : uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
382 4 : uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
383 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
384 2 : }
385 :
386 26 : DECLARE_RTFEXPORT_TEST(testFdo52286, "fdo52286.odt")
387 : {
388 : // The problem was that font size wasn't reduced in sub/super script.
389 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapementHeight"));
390 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(2), 2), "CharEscapementHeight"));
391 2 : }
392 :
393 28 : DECLARE_RTFEXPORT_TEST(testFdo61507, "fdo61507.rtf")
394 : {
395 : /*
396 : * Unicode-only characters in \title confused Wordpad. Once the exporter
397 : * was fixed to guard the problematic characters with \upr and \ud, the
398 : * importer didn't cope with these new keywords.
399 : */
400 :
401 4 : uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
402 8 : uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
403 8 : OUString aExpected = OUString("\xc3\x89\xc3\x81\xc5\x90\xc5\xb0\xe2\x88\xad", 11, RTL_TEXTENCODING_UTF8);
404 4 : CPPUNIT_ASSERT_EQUAL(aExpected, xDocumentProperties->getTitle());
405 :
406 : // Only "Hello.", no additional characters.
407 8 : CPPUNIT_ASSERT_EQUAL(6, getLength());
408 4 : }
409 :
410 28 : DECLARE_RTFEXPORT_TEST(testFdo30983, "fdo30983.rtf")
411 : {
412 : // These were 'page text area', not 'entire page', i.e. both the horizontal
413 : // and vertical positions were incorrect.
414 4 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), "HoriOrientRelation"));
415 4 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), "VertOrientRelation"));
416 4 : }
417 :
418 26 : DECLARE_RTFEXPORT_TEST(testPlaceholder, "placeholder.odt")
419 : {
420 : // Only the field text was exported, make sure we still have a field with the correct Hint text.
421 2 : uno::Reference<text::XTextRange> xRun(getRun(getParagraph(1), 2));
422 2 : CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(xRun, "TextPortionType"));
423 4 : uno::Reference<beans::XPropertySet> xField = getProperty< uno::Reference<beans::XPropertySet> >(xRun, "TextField");
424 4 : CPPUNIT_ASSERT_EQUAL(OUString("place holder"), getProperty<OUString>(xField, "Hint"));
425 2 : }
426 :
427 28 : DECLARE_RTFEXPORT_TEST(testMnor, "mnor.rtf")
428 : {
429 : // \mnor wasn't handled, leading to missing quotes around "divF" and so on.
430 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
431 8 : OUString aExpected("iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\" \xe2\x88\x99 \"n\" dS}", 74, RTL_TEXTENCODING_UTF8);
432 8 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
433 4 : }
434 :
435 28 : DECLARE_RTFEXPORT_TEST(testI120928, "i120928.rtf")
436 : {
437 : // \listpicture and \levelpicture0 was ignored, leading to missing graphic bullet in numbering.
438 4 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
439 8 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
440 8 : uno::Sequence<beans::PropertyValue> aProps;
441 4 : xLevels->getByIndex(0) >>= aProps; // 1st level
442 :
443 4 : bool bIsGraphic = false;
444 64 : for (int i = 0; i < aProps.getLength(); ++i)
445 : {
446 60 : const beans::PropertyValue& rProp = aProps[i];
447 :
448 60 : if (rProp.Name == "NumberingType")
449 4 : CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>());
450 56 : else if (rProp.Name == "GraphicURL")
451 4 : bIsGraphic = true;
452 : }
453 8 : CPPUNIT_ASSERT_EQUAL(true, bIsGraphic);
454 4 : }
455 :
456 28 : DECLARE_RTFEXPORT_TEST(testBookmark, "bookmark.rtf")
457 : {
458 4 : uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
459 8 : uno::Reference<text::XTextContent> xBookmark(xBookmarksSupplier->getBookmarks()->getByName("firstword"), uno::UNO_QUERY);
460 8 : CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xBookmark->getAnchor()->getString());
461 4 : }
462 :
463 28 : DECLARE_RTFEXPORT_TEST(testHyperlink, "hyperlink.rtf")
464 : {
465 4 : CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 1, "Hello"), "HyperLinkURL"));
466 4 : CPPUNIT_ASSERT_EQUAL(OUString("http://en.wikipedia.org/wiki/World"), getProperty<OUString>(getRun(getParagraph(1), 2, "world"), "HyperLinkURL"));
467 4 : CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 3, "!"), "HyperLinkURL"));
468 4 : }
469 :
470 28 : DECLARE_RTFEXPORT_TEST(test78758, "fdo78758.rtf")
471 : {
472 8 : CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
473 4 : getProperty<OUString>(getRun(getParagraph(2), 1, "EE5E EeEEE5EE"), "HyperLinkURL"));
474 8 : CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
475 4 : getProperty<OUString>(getRun(getParagraph(2), 2, "e"), "HyperLinkURL"));
476 8 : CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
477 4 : getProperty<OUString>(getRun(getParagraph(2), 3, "\t46"), "HyperLinkURL"));
478 4 : }
479 :
480 28 : DECLARE_RTFEXPORT_TEST(testTextFrameBorders, "textframe-borders.rtf")
481 : {
482 4 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
483 8 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
484 8 : uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
485 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xFrame, "BackColor"));
486 :
487 4 : table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder");
488 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aBorder.Color);
489 4 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth);
490 :
491 4 : table::ShadowFormat aShadowFormat = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat");
492 4 : CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location);
493 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth);
494 8 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aShadowFormat.Color);
495 4 : }
496 :
497 28 : DECLARE_RTFEXPORT_TEST(testTextframeGradient, "textframe-gradient.rtf")
498 : {
499 4 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
500 8 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
501 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
502 :
503 8 : uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
504 4 : CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
505 4 : awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
506 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor);
507 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor);
508 4 : CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
509 :
510 4 : xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
511 4 : CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
512 4 : aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
513 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor);
514 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor);
515 8 : CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
516 4 : }
517 :
518 28 : DECLARE_RTFEXPORT_TEST(testRecordChanges, "record-changes.rtf")
519 : {
520 : // \revisions wasn't imported/exported.
521 4 : CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(mxComponent, "RecordChanges"));
522 4 : }
523 :
524 28 : DECLARE_RTFEXPORT_TEST(testTextframeTable, "textframe-table.rtf")
525 : {
526 4 : uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY);
527 8 : uno::Reference<text::XText> xText = xTextRange->getText();
528 4 : CPPUNIT_ASSERT_EQUAL(OUString("First para."), getParagraphOfText(1, xText)->getString());
529 8 : uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
530 4 : CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString());
531 4 : CPPUNIT_ASSERT_EQUAL(OUString("B"), uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY)->getString());
532 8 : CPPUNIT_ASSERT_EQUAL(OUString("Last para."), getParagraphOfText(3, xText)->getString());
533 4 : }
534 :
535 28 : DECLARE_RTFEXPORT_TEST(testFdo66682, "fdo66682.rtf")
536 : {
537 4 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
538 8 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
539 8 : uno::Sequence<beans::PropertyValue> aProps;
540 4 : xLevels->getByIndex(0) >>= aProps; // 1st level
541 :
542 8 : OUString aSuffix;
543 52 : for (int i = 0; i < aProps.getLength(); ++i)
544 : {
545 48 : const beans::PropertyValue& rProp = aProps[i];
546 :
547 48 : if (rProp.Name == "Suffix")
548 4 : aSuffix = rProp.Value.get<OUString>();
549 : }
550 : // Suffix was '\0' instead of ' '.
551 8 : CPPUNIT_ASSERT_EQUAL(OUString(" "), aSuffix);
552 4 : }
553 :
554 28 : DECLARE_RTFEXPORT_TEST(testParaShadow, "para-shadow.rtf")
555 : {
556 : // The problem was that \brdrsh was ignored.
557 4 : table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getParagraph(2), "ParaShadowFormat");
558 4 : CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
559 4 : CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
560 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(convertTwipToMm100(60)), aShadow.ShadowWidth);
561 4 : }
562 :
563 26 : DECLARE_RTFEXPORT_TEST(testCharacterBorder, "charborder.odt")
564 : {
565 2 : uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
566 : // RTF has just one border attribute (chbrdr) for text border so all side has
567 : // the same border with the same padding
568 : // Border
569 : {
570 2 : const table::BorderLine2 aTopBorder = getProperty<table::BorderLine2>(xRun,"CharTopBorder");
571 2 : CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF6600,0,318,0,0,318), aTopBorder);
572 2 : CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharLeftBorder"));
573 2 : CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharBottomBorder"));
574 2 : CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharRightBorder"));
575 : }
576 :
577 : // Padding (brsp)
578 : {
579 2 : const sal_Int32 nTopPadding = getProperty<sal_Int32>(xRun,"CharTopBorderDistance");
580 : // In the original ODT file the padding is 150, but the unit conversion round it down.
581 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(141), nTopPadding);
582 2 : CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharLeftBorderDistance"));
583 2 : CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharBottomBorderDistance"));
584 2 : CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharRightBorderDistance"));
585 : }
586 :
587 : // Shadow (brdrsh)
588 : /* RTF use just one bool value for shadow so the next conversions
589 : are made during an export-import round
590 : color: any -> black
591 : location: any -> bottom-right
592 : width: any -> border width */
593 : {
594 2 : const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
595 2 : CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
596 2 : CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
597 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth);
598 2 : }
599 2 : }
600 :
601 28 : DECLARE_RTFEXPORT_TEST(testFdo66743, "fdo66743.rtf")
602 : {
603 4 : uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
604 8 : uno::Reference<table::XCell> xCell = xTable->getCellByName("A1");
605 : // This was too dark, 0x7f7f7f.
606 8 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xd8d8d8), getProperty<sal_Int32>(xCell, "BackColor"));
607 4 : }
608 :
609 28 : DECLARE_RTFEXPORT_TEST(testFdo68787, "fdo68787.rtf")
610 : {
611 4 : uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
612 : // This was 0, the 'lack of \chftnsep' <-> '0 line width' mapping was missing in the RTF tokenizer / exporter.
613 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth"));
614 4 : }
615 :
616 28 : DECLARE_RTFEXPORT_TEST(testFdo74709, "fdo74709.rtf")
617 : {
618 4 : uno::Reference<table::XCell> xCell = getCell(getParagraphOrTable(1), "B1");
619 : // This was 0, as top/bottom/left/right padding wasn't imported.
620 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(360)), getProperty<sal_Int32>(xCell, "RightBorderDistance"));
621 4 : }
622 :
623 28 : DECLARE_RTFEXPORT_TEST(testRelsize, "relsize.rtf")
624 : {
625 4 : uno::Reference<drawing::XShape> xShape = getShape(1);
626 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(xShape, "RelativeWidth"));
627 4 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation"));
628 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(xShape, "RelativeHeight"));
629 4 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation"));
630 4 : }
631 :
632 28 : DECLARE_RTFEXPORT_TEST(testLineNumbering, "linenumbering.rtf")
633 : {
634 4 : uno::Reference<text::XLineNumberingProperties> xLineNumberingProperties(mxComponent, uno::UNO_QUERY_THROW);
635 8 : uno::Reference<beans::XPropertySet> xPropertySet = xLineNumberingProperties->getLineNumberingProperties();
636 4 : CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xPropertySet, "IsOn")));
637 8 : CPPUNIT_ASSERT_EQUAL(sal_Int32(5), getProperty<sal_Int32>(xPropertySet, "Interval"));
638 4 : }
639 :
640 28 : DECLARE_RTFEXPORT_TEST(testFdo77600, "fdo77600.rtf")
641 : {
642 : // This was 'Liberation Serif'.
643 4 : CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(getRun(getParagraph(1), 3), "CharFontName"));
644 4 : }
645 :
646 28 : DECLARE_RTFEXPORT_TEST(testFdo79599, "fdo79599.rtf")
647 : {
648 : // test for \highlightNN, document has full \colortbl (produced in MS Word 2003 or 2007)
649 :
650 : // test \highlight11 = dark magenta
651 4 : uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(11),1), uno::UNO_QUERY);
652 4 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty<sal_uInt32>(xRun, "CharBackColor"));
653 4 : }
654 :
655 28 : DECLARE_RTFEXPORT_TEST(testFdo80167, "fdo80167.rtf")
656 : {
657 : // Problem was that after export, the page break was missing, so this was 1.
658 4 : CPPUNIT_ASSERT_EQUAL(2, getPages());
659 4 : }
660 :
661 26 : DECLARE_RTFEXPORT_TEST(testFdo32613, "fdo32613.odt")
662 : {
663 : // This was AS_CHARACTER, RTF export did not support writing anchored pictures.
664 2 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
665 2 : }
666 :
667 28 : DECLARE_RTFEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf")
668 : {
669 : // The problem was that the wrap polygon was ignored during import.
670 4 : drawing::PointSequenceSequence aSeqSeq = getProperty<drawing::PointSequenceSequence>(getShape(1), "ContourPolyPolygon");
671 : // This was 0: the polygon list was empty.
672 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeqSeq.getLength());
673 :
674 8 : drawing::PointSequence aSeq = aSeqSeq[0];
675 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aSeq.getLength());
676 :
677 : // The shape also didn't have negative top / left coordinates.
678 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-1177)), getProperty<sal_Int32>(getShape(1), "HoriOrientPosition"));
679 8 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty<sal_Int32>(getShape(1), "VertOrientPosition"));
680 4 : }
681 :
682 26 : DECLARE_RTFEXPORT_TEST(testAbi10039, "abi10039.odt")
683 : {
684 : // Make sure we don't just crash on export, and additionally the shape should not be inline (as it's at-page anchored originally).
685 2 : CPPUNIT_ASSERT(text::TextContentAnchorType_AS_CHARACTER != getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
686 2 : }
687 :
688 26 : DECLARE_RTFEXPORT_TEST(testAbi10076, "abi10076.odt")
689 : {
690 : // Just make sure that we don't crash after exporting a fully calculated layout.
691 2 : }
692 :
693 28 : DECLARE_RTFEXPORT_TEST(testEm, "em.rtf")
694 : {
695 : // Test all possible \acc* control words.
696 4 : CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::NONE, getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharEmphasis"));
697 4 : CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_ABOVE, getProperty<sal_Int16>(getRun(getParagraph(1), 2), "CharEmphasis"));
698 4 : CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::ACCENT_ABOVE, getProperty<sal_Int16>(getRun(getParagraph(1), 3), "CharEmphasis"));
699 : // This was missing.
700 4 : CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::CIRCLE_ABOVE, getProperty<sal_Int16>(getRun(getParagraph(1), 4), "CharEmphasis"));
701 : // This one, too.
702 4 : CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_BELOW, getProperty<sal_Int16>(getRun(getParagraph(1), 5), "CharEmphasis"));
703 4 : }
704 :
705 28 : DECLARE_RTFEXPORT_TEST(testNumberingFont, "numbering-font.rtf")
706 : {
707 4 : uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName("ListLabel 1"), uno::UNO_QUERY);
708 : // This was Liberation Serif, i.e. custom font of the numbering itself ("1.\t") was lost on import.
709 4 : CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(xStyle, "CharFontName"));
710 4 : }
711 :
712 26 : DECLARE_RTFEXPORT_TEST(testFdo82860, "fdo82860.odt")
713 : {
714 : // The problem was that:
715 : // 1) The import tried to use fieldmarks for SHAPE fields
716 : // 2) The exporter did not handle "shape with textbox" text.
717 2 : uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY);
718 4 : uno::Reference<text::XText> xText = xTextRange->getText();
719 4 : CPPUNIT_ASSERT_EQUAL(OUString("hello"), getParagraphOfText(1, xText)->getString());
720 2 : }
721 :
722 26 : DECLARE_RTFEXPORT_TEST(testFdo82858, "fdo82858.docx")
723 : {
724 : // This was table::BorderLineStyle::SOLID, exporter failed to write explicit no line when line color was written.
725 2 : CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineStyle);
726 2 : }
727 :
728 8 : CPPUNIT_PLUGIN_IMPLEMENT();
729 :
730 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|