Line data Source code
1 : /*
2 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
3 : *
4 : * The contents of this file are subject to the Mozilla Public License Version
5 : * 1.1 (the "License"); you may not use this file except in compliance with
6 : * the License. You may obtain a copy of the License at
7 : * http://www.mozilla.org/MPL/
8 : *
9 : * Software distributed under the License is distributed on an "AS IS" basis,
10 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 : * for the specific language governing rights and limitations under the
12 : * License.
13 : *
14 : * The Initial Developer of the Original Code is
15 : * Miklos Vajna <vmiklos@suse.cz> (SUSE, Inc.)
16 : * Portions created by the Initial Developer are Copyright (C) 2012 the
17 : * Initial Developer. All Rights Reserved.
18 : *
19 : * Contributor(s):
20 : *
21 : * Alternatively, the contents of this file may be used under the terms of
22 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
23 : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
24 : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
25 : * instead of those above.
26 : */
27 :
28 : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
29 : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
30 : #include <com/sun/star/frame/XStorable.hpp>
31 : #include <com/sun/star/text/XPageCursor.hpp>
32 : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
33 : #include <com/sun/star/view/XViewSettingsSupplier.hpp>
34 :
35 : #include <unotools/tempfile.hxx>
36 : #include <vcl/svapp.hxx>
37 : #include <swmodeltestbase.hxx>
38 :
39 6 : class Test : public SwModelTestBase
40 : {
41 : public:
42 : void testZoom();
43 : void testFdo38176();
44 : void testFdo49683();
45 : void testFdo44174();
46 : void testFdo50087();
47 : void testFdo50831();
48 : void testFdo48335();
49 : void testFdo38244();
50 : void testMathAccents();
51 : void testMathEqarray();
52 : void testMathD();
53 : void testMathEscaping();
54 : void testMathLim();
55 : void testMathMatrix();
56 : void testMathBox();
57 : void testMathMso2007();
58 : void testMathNary();
59 : void testMathLimupp();
60 : void testMathStrikeh();
61 : void testMathPlaceholders();
62 : void testMathRad();
63 : void testMathSepchr();
64 : void testMathSubscripts();
65 : void testMathVerticalstacks();
66 : void testMathRuns();
67 : void testFdo53113();
68 : void testFdo55939();
69 : void testTextFrames();
70 :
71 4 : CPPUNIT_TEST_SUITE(Test);
72 : #if !defined(MACOSX) && !defined(WNT)
73 2 : CPPUNIT_TEST(run);
74 : #endif
75 4 : CPPUNIT_TEST_SUITE_END();
76 :
77 : private:
78 : void run();
79 : };
80 :
81 2 : void Test::run()
82 : {
83 : MethodEntry<Test> aMethods[] = {
84 : {"zoom.rtf", &Test::testZoom},
85 : {"fdo38176.rtf", &Test::testFdo38176},
86 : {"fdo49683.rtf", &Test::testFdo49683},
87 : {"fdo44174.rtf", &Test::testFdo44174},
88 : {"fdo50087.rtf", &Test::testFdo50087},
89 : {"fdo50831.rtf", &Test::testFdo50831},
90 : {"fdo48335.odt", &Test::testFdo48335},
91 : {"fdo38244.rtf", &Test::testFdo38244},
92 : {"math-accents.rtf", &Test::testMathAccents},
93 : {"math-eqarray.rtf", &Test::testMathEqarray},
94 : {"math-d.rtf", &Test::testMathD},
95 : {"math-escaping.rtf", &Test::testMathEscaping},
96 : {"math-lim.rtf", &Test::testMathLim},
97 : {"math-matrix.rtf", &Test::testMathMatrix},
98 : {"math-mbox.rtf", &Test::testMathBox},
99 : {"math-mso2007.rtf", &Test::testMathMso2007},
100 : {"math-nary.rtf", &Test::testMathNary},
101 : {"math-limupp.rtf", &Test::testMathLimupp},
102 : {"math-strikeh.rtf", &Test::testMathStrikeh},
103 : {"math-placeholders.rtf", &Test::testMathPlaceholders},
104 : {"math-rad.rtf", &Test::testMathRad},
105 : {"math-sepchr.rtf", &Test::testMathSepchr},
106 : {"math-subscripts.rtf", &Test::testMathSubscripts},
107 : {"math-vertical-stacks.rtf", &Test::testMathVerticalstacks},
108 : {"math-runs.rtf", &Test::testMathRuns},
109 : {"fdo53113.odt", &Test::testFdo53113},
110 : {"fdo55939.odt", &Test::testFdo55939},
111 : {"textframes.odt", &Test::testTextFrames},
112 2 : };
113 : // Don't test the first import of these, for some reason those tests fail
114 : const char* aBlacklist[] = {
115 : "math-eqarray.rtf",
116 : "math-escaping.rtf",
117 : "math-lim.rtf",
118 : "math-mso2007.rtf",
119 : "math-nary.rtf",
120 : "math-rad.rtf",
121 : "math-vertical-stacks.rtf",
122 : "math-runs.rtf",
123 2 : };
124 2 : std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist));
125 58 : for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
126 : {
127 56 : MethodEntry<Test>& rEntry = aMethods[i];
128 56 : mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/rtfexport/data/") + OUString::createFromAscii(rEntry.pName));
129 : // If the testcase is stored in some other format, it's pointless to test.
130 56 : if (OString(rEntry.pName).endsWith(".rtf") && std::find(vBlacklist.begin(), vBlacklist.end(), rEntry.pName) == vBlacklist.end())
131 32 : (this->*rEntry.pMethod)();
132 56 : uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
133 56 : uno::Sequence<beans::PropertyValue> aArgs(1);
134 56 : aArgs[0].Name = "FilterName";
135 56 : aArgs[0].Value <<= OUString("Rich Text Format");
136 56 : utl::TempFile aTempFile;
137 56 : aTempFile.EnableKillingFile();
138 56 : xStorable->storeToURL(aTempFile.GetURL(), aArgs);
139 56 : mxComponent = loadFromDesktop(aTempFile.GetURL());
140 56 : (this->*rEntry.pMethod)();
141 58 : }
142 2 : }
143 :
144 4 : void Test::testZoom()
145 : {
146 4 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
147 4 : uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
148 4 : uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings());
149 4 : sal_Int16 nValue = 0;
150 4 : xPropertySet->getPropertyValue("ZoomValue") >>= nValue;
151 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue);
152 4 : }
153 :
154 4 : void Test::testFdo38176()
155 : {
156 4 : CPPUNIT_ASSERT_EQUAL(9, getLength());
157 4 : }
158 :
159 4 : void Test::testFdo49683()
160 : {
161 4 : uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
162 4 : uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
163 4 : uno::Sequence<OUString> aKeywords(xDocumentProperties->getKeywords());
164 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aKeywords.getLength());
165 4 : CPPUNIT_ASSERT_EQUAL(OUString("one"), aKeywords[0]);
166 4 : CPPUNIT_ASSERT_EQUAL(OUString("two"), aKeywords[1]);
167 4 : }
168 :
169 4 : void Test::testFdo44174()
170 : {
171 4 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
172 4 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
173 4 : uno::Reference<beans::XPropertySet> xPropertySet(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
174 4 : OUString aValue;
175 4 : xPropertySet->getPropertyValue("PageStyleName") >>= aValue;
176 4 : CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aValue);
177 4 : }
178 :
179 4 : void Test::testFdo50087()
180 : {
181 4 : uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
182 4 : uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
183 4 : CPPUNIT_ASSERT_EQUAL(OUString("Title"), xDocumentProperties->getTitle());
184 4 : CPPUNIT_ASSERT_EQUAL(OUString("Subject"), xDocumentProperties->getSubject());
185 4 : CPPUNIT_ASSERT_EQUAL(OUString("First line.\nSecond line."), xDocumentProperties->getDescription());
186 4 : }
187 :
188 4 : void Test::testFdo50831()
189 : {
190 4 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
191 4 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
192 4 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
193 4 : uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
194 4 : float fValue = 0;
195 4 : xPropertySet->getPropertyValue("CharHeight") >>= fValue;
196 4 : CPPUNIT_ASSERT_EQUAL(10.f, fValue);
197 4 : }
198 :
199 2 : void Test::testFdo48335()
200 : {
201 : /*
202 : * The problem was that we exported a fake pagebreak, make sure it's just a soft one now.
203 : *
204 : * oParas = ThisComponent.Text.createEnumeration
205 : * oPara = oParas.nextElement
206 : * oPara = oParas.nextElement
207 : * oPara = oParas.nextElement
208 : * oRuns = oPara.createEnumeration
209 : * oRun = oRuns.nextElement
210 : * xray oRun.TextPortionType 'was Text, should be SoftPageBreak
211 : */
212 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
213 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
214 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
215 6 : for (int i = 0; i < 2; i++)
216 4 : xParaEnum->nextElement();
217 2 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
218 2 : uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
219 2 : uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
220 2 : OUString aValue;
221 2 : xPropertySet->getPropertyValue("TextPortionType") >>= aValue;
222 2 : CPPUNIT_ASSERT_EQUAL(OUString("SoftPageBreak"), aValue);
223 2 : }
224 :
225 4 : void Test::testFdo38244()
226 : {
227 : // See ooxmlexport's testFdo38244().
228 : // Test comment range feature.
229 4 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
230 4 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
231 4 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
232 4 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
233 4 : uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
234 4 : xRunEnum->nextElement();
235 4 : uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
236 4 : CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
237 4 : xRunEnum->nextElement();
238 4 : xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
239 4 : CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
240 :
241 : // Test initials.
242 4 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
243 4 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
244 4 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
245 4 : xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
246 4 : CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
247 4 : }
248 :
249 4 : void Test::testMathAccents()
250 : {
251 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
252 4 : 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}");
253 4 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
254 4 : }
255 :
256 2 : void Test::testMathEqarray()
257 : {
258 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
259 2 : OUString aExpected("y = left lbrace stack { 0, x < 0 # 1, x = 0 # {x} ^ {2} , x > 0 } right none");
260 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
261 2 : }
262 :
263 4 : void Test::testMathD()
264 : {
265 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
266 4 : 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 )");
267 4 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
268 4 : }
269 :
270 2 : void Test::testMathEscaping()
271 : {
272 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
273 2 : OUString aExpected("á \\{", 5, RTL_TEXTENCODING_UTF8);
274 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
275 2 : }
276 :
277 2 : void Test::testMathLim()
278 : {
279 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
280 2 : OUString aExpected("lim from {x → 1} {x}", 22, RTL_TEXTENCODING_UTF8);
281 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
282 2 : }
283 :
284 4 : void Test::testMathMatrix()
285 : {
286 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
287 4 : OUString aExpected("left [matrix {1 # 2 ## 3 # 4} right ]");
288 4 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
289 4 : }
290 :
291 4 : void Test::testMathBox()
292 : {
293 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
294 4 : OUString aExpected("a");
295 4 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
296 4 : }
297 :
298 2 : void Test::testMathMso2007()
299 : {
300 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
301 2 : OUString aExpected("A = π {r} ^ {2}", 16, RTL_TEXTENCODING_UTF8);
302 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
303 :
304 2 : aActual = getFormula(getRun(getParagraph(2), 1));
305 2 : 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);
306 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
307 :
308 2 : aActual = getFormula(getRun(getParagraph(3), 1));
309 2 : aExpected = OUString("{left (1 + x right )} ^ {n} = 1 + {nx} over {1 !} + {n left (n − 1 right ) {x} ^ {2}} over {2 !} + …", 104, RTL_TEXTENCODING_UTF8);
310 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
311 :
312 2 : aActual = getFormula(getRun(getParagraph(4), 1));
313 : 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,
314 2 : RTL_TEXTENCODING_UTF8);
315 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
316 :
317 2 : aActual = getFormula(getRun(getParagraph(5), 1));
318 2 : aExpected = "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}";
319 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
320 :
321 2 : aActual = getFormula(getRun(getParagraph(6), 1));
322 2 : aExpected = OUString("x = {− b ± sqrt {{b} ^ {2} − 4 ac}} over {2 a}", 51, RTL_TEXTENCODING_UTF8);
323 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
324 :
325 2 : aActual = getFormula(getRun(getParagraph(7), 1));
326 2 : aExpected = OUString("{e} ^ {x} = 1 + {x} over {1 !} + {{x} ^ {2}} over {2 !} + {{x} ^ {3}} over {3 !} + … , − ∞ < x < ∞", 106, RTL_TEXTENCODING_UTF8);
327 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
328 :
329 2 : aActual = getFormula(getRun(getParagraph(8), 1));
330 2 : aExpected = OUString("sin α ± sin β = 2 sin {1} over {2} left (α ± β right ) cos {1} over {2} left (α ∓ β right )", 101, RTL_TEXTENCODING_UTF8);
331 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
332 :
333 2 : aActual = getFormula(getRun(getParagraph(9), 1));
334 2 : aExpected = OUString("cos α + cos β = 2 cos {1} over {2} left (α + β right ) cos {1} over {2} left (α − β right )", 99, RTL_TEXTENCODING_UTF8);
335 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
336 2 : }
337 :
338 2 : void Test::testMathNary()
339 : {
340 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
341 2 : OUString aExpected("lllint from {1} to {2} {x + 1} prod from {a} {b} sum to {2} {x}");
342 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
343 2 : }
344 :
345 4 : void Test::testMathLimupp()
346 : {
347 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
348 4 : CPPUNIT_ASSERT_EQUAL(OUString("{abcd} overbrace {4}"), aActual);
349 :
350 4 : aActual = getFormula(getRun(getParagraph(2), 1));
351 4 : CPPUNIT_ASSERT_EQUAL(OUString("{xyz} underbrace {3}"), aActual);
352 4 : }
353 :
354 4 : void Test::testMathStrikeh()
355 : {
356 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
357 4 : CPPUNIT_ASSERT_EQUAL(OUString("overstrike {abc}"), aActual);
358 4 : }
359 :
360 4 : void Test::testMathPlaceholders()
361 : {
362 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
363 4 : CPPUNIT_ASSERT_EQUAL(OUString("sum from <?> to <?> <?>"), aActual);
364 4 : }
365 :
366 2 : void Test::testMathRad()
367 : {
368 2 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
369 2 : CPPUNIT_ASSERT_EQUAL(OUString("sqrt {4} nroot {3} {x + 1}"), aActual);
370 2 : }
371 :
372 4 : void Test::testMathSepchr()
373 : {
374 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
375 4 : CPPUNIT_ASSERT_EQUAL(OUString("AxByBzC"), aActual);
376 4 : }
377 :
378 4 : void Test::testMathSubscripts()
379 : {
380 4 : OUString aActual = getFormula(getRun(getParagraph(1), 1));
381 4 : 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}");
382 4 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
383 4 : }
384 :
385 2 : void Test::testMathVerticalstacks()
386 : {
387 2 : CPPUNIT_ASSERT_EQUAL(OUString("{a} over {b}"), getFormula(getRun(getParagraph(1), 1)));
388 2 : CPPUNIT_ASSERT_EQUAL(OUString("{a} / {b}"), getFormula(getRun(getParagraph(2), 1)));
389 2 : CPPUNIT_ASSERT_EQUAL(OUString("stack { a # b }"), getFormula(getRun(getParagraph(3), 1)));
390 2 : CPPUNIT_ASSERT_EQUAL(OUString("stack { a # stack { b # c } }"), getFormula(getRun(getParagraph(4), 1)));
391 2 : }
392 :
393 2 : void Test::testMathRuns()
394 : {
395 : // was [](){}, i.e. first curly bracket had an incorrect position
396 2 : CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"), getFormula(getRun(getParagraph(1), 1)));
397 2 : }
398 :
399 2 : void Test::testFdo53113()
400 : {
401 : /*
402 : * The problem was that a custom shape was missings its second (and all the other remaining) coordinates.
403 : *
404 : * oShape = ThisComponent.DrawPage(0)
405 : * oPathPropVec = oShape.CustomShapeGeometry(1).Value
406 : * oCoordinates = oPathPropVec(0).Value
407 : * xray oCoordinates(1).First.Value ' 535
408 : * xray oCoordinates(1).Second.Value ' 102
409 : */
410 :
411 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
412 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
413 2 : uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xDraws->getByIndex(0), "CustomShapeGeometry");
414 2 : uno::Sequence<beans::PropertyValue> aPathProps;
415 8 : for (int i = 0; i < aProps.getLength(); ++i)
416 : {
417 6 : const beans::PropertyValue& rProp = aProps[i];
418 6 : if (rProp.Name == "Path")
419 2 : rProp.Value >>= aPathProps;
420 : }
421 2 : uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aPairs;
422 6 : for (int i = 0; i < aPathProps.getLength(); ++i)
423 : {
424 4 : const beans::PropertyValue& rProp = aPathProps[i];
425 4 : if (rProp.Name == "Coordinates")
426 2 : rProp.Value >>= aPairs;
427 : }
428 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aPairs.getLength());
429 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(535), aPairs[1].First.Value.get<sal_Int32>());
430 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(102), aPairs[1].Second.Value.get<sal_Int32>());
431 2 : }
432 :
433 2 : void Test::testFdo55939()
434 : {
435 : // The problem was that the exported RTF was invalid.
436 2 : uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
437 2 : getRun(xParagraph, 1, "Main text before footnote.");
438 : // Why the tab has to be removed here?
439 4 : CPPUNIT_ASSERT_EQUAL(OUString("Footnote text."),
440 2 : getProperty< uno::Reference<text::XTextRange> >(getRun(xParagraph, 2), "Footnote")->getText()->getString().replaceAll("\t", ""));
441 2 : getRun(xParagraph, 3, " Text after the footnote."); // However, this leading space is intentional and OK.
442 2 : }
443 :
444 2 : void Test::testTextFrames()
445 : {
446 : // The output was simply invalid, so let's check if all 3 frames were imported back.
447 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
448 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
449 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount());
450 2 : }
451 :
452 2 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
453 :
454 8 : CPPUNIT_PLUGIN_IMPLEMENT();
455 :
456 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|