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/XFilter.hpp>
29 : #include <com/sun/star/document/XImporter.hpp>
30 : #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
31 : #include <com/sun/star/drawing/LineStyle.hpp>
32 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
33 : #include <com/sun/star/graphic/GraphicType.hpp>
34 : #include <com/sun/star/lang/XServiceInfo.hpp>
35 : #include <com/sun/star/style/CaseMap.hpp>
36 : #include <com/sun/star/style/LineSpacing.hpp>
37 : #include <com/sun/star/style/LineSpacingMode.hpp>
38 : #include <com/sun/star/table/BorderLine2.hpp>
39 : #include <com/sun/star/table/BorderLineStyle.hpp>
40 : #include <com/sun/star/text/RelOrientation.hpp>
41 : #include <com/sun/star/text/SizeType.hpp>
42 : #include <com/sun/star/text/TableColumnSeparator.hpp>
43 : #include <com/sun/star/text/TextContentAnchorType.hpp>
44 : #include <com/sun/star/text/XFootnotesSupplier.hpp>
45 : #include <com/sun/star/text/XPageCursor.hpp>
46 : #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
47 : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
48 : #include <com/sun/star/text/XTextFramesSupplier.hpp>
49 : #include <com/sun/star/text/XTextTablesSupplier.hpp>
50 : #include <com/sun/star/text/XTextTable.hpp>
51 : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
52 : #include <com/sun/star/text/WrapTextMode.hpp>
53 : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
54 :
55 : #include <rtl/ustring.hxx>
56 : #include <vcl/outdev.hxx>
57 : #include <vcl/svapp.hxx>
58 : #include <unotools/ucbstreamhelper.hxx>
59 : #include <unotools/streamwrap.hxx>
60 :
61 : #include <swmodeltestbase.hxx>
62 : #include <bordertest.hxx>
63 :
64 : #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
65 :
66 6 : class Test : public SwModelTestBase
67 : {
68 : public:
69 : void testFdo45553();
70 : void testN192129();
71 : void testFdo45543();
72 : void testN695479();
73 : void testFdo42465();
74 : void testFdo45187();
75 : void testFdo46662();
76 : void testN750757();
77 : void testFdo45563();
78 : void testFdo43965();
79 : void testN751020();
80 : void testFdo47326();
81 : void testFdo47036();
82 : void testFdo46955();
83 : void testFdo45394();
84 : void testFdo48104();
85 : void testFdo47107();
86 : void testFdo45182();
87 : void testFdo44176();
88 : void testFdo39053();
89 : void testFdo48356();
90 : void testFdo48023();
91 : void testFdo48876();
92 : void testFdo48193();
93 : void testFdo44211();
94 : void testFdo48037();
95 : void testFdo47764();
96 : void testFdo38786();
97 : void testN757651();
98 : void testFdo49501();
99 : void testFdo49271();
100 : void testFdo49692();
101 : void testFdo45190();
102 : void testFdo50539();
103 : void testFdo50665();
104 : void testFdo49659();
105 : void testFdo46966();
106 : void testFdo52066();
107 : void testFdo48033();
108 : void testFdo36089();
109 : void testFdo49892();
110 : void testFdo48446();
111 : void testFdo47495();
112 : void testAllGapsWord();
113 : void testFdo52052();
114 : void testInk();
115 : void testFdo52389();
116 : void testFdo49655();
117 : void testFdo52475();
118 : void testFdo55493();
119 : void testCopyPastePageStyle();
120 : void testShptxtPard();
121 : void testDoDhgt();
122 : void testDplinehollow();
123 : void testLeftmarginDefault();
124 : void testDppolyline();
125 : void testFdo56512();
126 : void testFdo52989();
127 : void testFdo48442();
128 : void testFdo55525();
129 : void testFdo57708();
130 : void testFdo54473();
131 : void testFdo49934();
132 :
133 4 : CPPUNIT_TEST_SUITE(Test);
134 : #if !defined(MACOSX) && !defined(WNT)
135 2 : CPPUNIT_TEST(run);
136 : #endif
137 4 : CPPUNIT_TEST_SUITE_END();
138 :
139 : private:
140 : void run();
141 : /// Get page count.
142 : int getPages();
143 : };
144 :
145 2 : void Test::run()
146 : {
147 : MethodEntry<Test> aMethods[] = {
148 : {"fdo45553.rtf", &Test::testFdo45553},
149 : {"n192129.rtf", &Test::testN192129},
150 : {"fdo45543.rtf", &Test::testFdo45543},
151 : {"n695479.rtf", &Test::testN695479},
152 : {"fdo42465.rtf", &Test::testFdo42465},
153 : {"fdo45187.rtf", &Test::testFdo45187},
154 : {"fdo46662.rtf", &Test::testFdo46662},
155 : {"n750757.rtf", &Test::testN750757},
156 : {"fdo45563.rtf", &Test::testFdo45563},
157 : {"fdo43965.rtf", &Test::testFdo43965},
158 : {"n751020.rtf", &Test::testN751020},
159 : {"fdo47326.rtf", &Test::testFdo47326},
160 : {"fdo47036.rtf", &Test::testFdo47036},
161 : {"fdo46955.rtf", &Test::testFdo46955},
162 : {"fdo45394.rtf", &Test::testFdo45394},
163 : {"fdo48104.rtf", &Test::testFdo48104},
164 : {"fdo47107.rtf", &Test::testFdo47107},
165 : {"fdo45182.rtf", &Test::testFdo45182},
166 : {"fdo44176.rtf", &Test::testFdo44176},
167 : {"fdo39053.rtf", &Test::testFdo39053},
168 : {"fdo48356.rtf", &Test::testFdo48356},
169 : {"fdo48023.rtf", &Test::testFdo48023},
170 : {"fdo48876.rtf", &Test::testFdo48876},
171 : {"fdo48193.rtf", &Test::testFdo48193},
172 : {"fdo44211.rtf", &Test::testFdo44211},
173 : {"fdo48037.rtf", &Test::testFdo48037},
174 : {"fdo47764.rtf", &Test::testFdo47764},
175 : {"fdo38786.rtf", &Test::testFdo38786},
176 : {"n757651.rtf", &Test::testN757651},
177 : {"fdo49501.rtf", &Test::testFdo49501},
178 : {"fdo49271.rtf", &Test::testFdo49271},
179 : {"fdo49692.rtf", &Test::testFdo49692},
180 : {"fdo45190.rtf", &Test::testFdo45190},
181 : {"fdo50539.rtf", &Test::testFdo50539},
182 : {"fdo50665.rtf", &Test::testFdo50665},
183 : {"fdo49659.rtf", &Test::testFdo49659},
184 : {"fdo46966.rtf", &Test::testFdo46966},
185 : {"fdo52066.rtf", &Test::testFdo52066},
186 : {"fdo48033.rtf", &Test::testFdo48033},
187 : {"fdo36089.rtf", &Test::testFdo36089},
188 : {"fdo49892.rtf", &Test::testFdo49892},
189 : {"fdo48446.rtf", &Test::testFdo48446},
190 : {"fdo47495.rtf", &Test::testFdo47495},
191 : {"all_gaps_word.rtf", &Test::testAllGapsWord},
192 : {"fdo52052.rtf", &Test::testFdo52052},
193 : {"ink.rtf", &Test::testInk},
194 : {"fdo52389.rtf", &Test::testFdo52389},
195 : {"fdo49655.rtf", &Test::testFdo49655},
196 : {"fdo52475.rtf", &Test::testFdo52475},
197 : {"fdo55493.rtf", &Test::testFdo55493},
198 : {"copypaste-pagestyle.rtf", &Test::testCopyPastePageStyle},
199 : {"shptxt-pard.rtf", &Test::testShptxtPard},
200 : {"do-dhgt.rtf", &Test::testDoDhgt},
201 : {"dplinehollow.rtf", &Test::testDplinehollow},
202 : {"leftmargin-default.rtf", &Test::testLeftmarginDefault},
203 : {"dppolyline.rtf", &Test::testDppolyline},
204 : {"fdo56512.rtf", &Test::testFdo56512},
205 : {"fdo52989.rtf", &Test::testFdo52989},
206 : {"fdo48442.rtf", &Test::testFdo48442},
207 : {"fdo55525.rtf", &Test::testFdo55525},
208 : {"fdo57708.rtf", &Test::testFdo57708},
209 : {"fdo54473.rtf", &Test::testFdo54473},
210 : {"fdo49934.rtf", &Test::testFdo49934},
211 2 : };
212 128 : for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
213 : {
214 126 : MethodEntry<Test>& rEntry = aMethods[i];
215 126 : AllSettings aSavedSettings(Application::GetSettings());
216 126 : if (OString(rEntry.pName) == "fdo48023.rtf")
217 : {
218 2 : AllSettings aSettings(aSavedSettings);
219 2 : aSettings.SetLanguageTag(LanguageTag("ru"));
220 2 : Application::SetSettings(aSettings);
221 : }
222 124 : else if (OString(rEntry.pName) == "fdo44211.rtf")
223 : {
224 2 : AllSettings aSettings(aSavedSettings);
225 2 : aSettings.SetLanguageTag(LanguageTag("lt"));
226 2 : Application::SetSettings(aSettings);
227 : }
228 126 : mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + OUString::createFromAscii(rEntry.pName));
229 126 : if (OString(rEntry.pName) == "fdo48023.rtf" || OString(rEntry.pName) == "fdo44211.rtf")
230 4 : Application::SetSettings(aSavedSettings);
231 126 : (this->*rEntry.pMethod)();
232 126 : }
233 2 : }
234 :
235 8 : int Test::getPages()
236 : {
237 8 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
238 8 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
239 8 : uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
240 8 : xCursor->jumpToLastPage();
241 8 : return xCursor->getPage();
242 : }
243 :
244 2 : void Test::testFdo45553()
245 : {
246 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
247 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
248 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
249 8 : while (xParaEnum->hasMoreElements())
250 : {
251 4 : uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
252 4 : uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
253 12 : while (xRangeEnum->hasMoreElements())
254 : {
255 4 : uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY);
256 4 : OUString aStr = xRange->getString();
257 4 : if ( aStr == "space-before" )
258 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(120)), getProperty<sal_Int32>(xRange, "ParaTopMargin"));
259 2 : else if ( aStr == "space-after" )
260 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(240)), getProperty<sal_Int32>(xRange, "ParaBottomMargin"));
261 4 : }
262 6 : }
263 2 : }
264 :
265 2 : void Test::testN192129()
266 : {
267 : // We expect that the result will be 16x16px.
268 2 : Size aExpectedSize(16, 16);
269 2 : MapMode aMap(MAP_100TH_MM);
270 2 : aExpectedSize = Application::GetDefaultDevice()->PixelToLogic( aExpectedSize, aMap );
271 :
272 2 : uno::Reference<text::XTextGraphicObjectsSupplier> xTextGraphicObjectsSupplier(mxComponent, uno::UNO_QUERY);
273 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextGraphicObjectsSupplier->getGraphicObjects(), uno::UNO_QUERY);
274 2 : uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
275 2 : awt::Size aActualSize(xShape->getSize());
276 :
277 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Width()), aActualSize.Width);
278 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Height()), aActualSize.Height);
279 2 : }
280 :
281 2 : void Test::testFdo45543()
282 : {
283 2 : CPPUNIT_ASSERT_EQUAL(5, getLength());
284 2 : }
285 :
286 2 : void Test::testN695479()
287 : {
288 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
289 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
290 2 : uno::Reference<beans::XPropertySet> xPropertySet(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
291 :
292 : // Negative ABSH should mean fixed size.
293 2 : CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX, getProperty<sal_Int16>(xPropertySet, "SizeType"));
294 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(300)), getProperty<sal_Int32>(xPropertySet, "Height"));
295 :
296 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
297 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
298 2 : bool bFrameFound = false, bDrawFound = false;
299 8 : for (int i = 0; i < xDraws->getCount(); ++i)
300 : {
301 6 : uno::Reference<lang::XServiceInfo> xServiceInfo(xDraws->getByIndex(i), uno::UNO_QUERY);
302 6 : if (xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
303 : {
304 : // Both frames should be anchored to the first paragraph.
305 4 : bFrameFound = true;
306 4 : uno::Reference<text::XTextContent> xTextContent(xServiceInfo, uno::UNO_QUERY);
307 4 : uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
308 4 : uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY);
309 4 : CPPUNIT_ASSERT_EQUAL(OUString("plain"), xText->getString());
310 :
311 4 : if (i == 0)
312 : // Additonally, the frist frame should have double border at the bottom.
313 0 : CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::DOUBLE, getProperty<table::BorderLine2>(xPropertySet, "BottomBorder").LineStyle);
314 : }
315 2 : else if (xServiceInfo->supportsService("com.sun.star.drawing.LineShape"))
316 : {
317 : // The older "drawing objects" syntax should be recognized.
318 2 : bDrawFound = true;
319 2 : xPropertySet.set(xServiceInfo, uno::UNO_QUERY);
320 2 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xPropertySet, "HoriOrientRelation"));
321 2 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xPropertySet, "VertOrientRelation"));
322 : }
323 6 : }
324 2 : CPPUNIT_ASSERT(bFrameFound);
325 2 : CPPUNIT_ASSERT(bDrawFound);
326 2 : }
327 :
328 2 : void Test::testFdo42465()
329 : {
330 2 : CPPUNIT_ASSERT_EQUAL(3, getLength());
331 2 : }
332 :
333 2 : void Test::testFdo45187()
334 : {
335 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
336 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
337 : // There should be two shapes.
338 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
339 : // They should be anchored to different paragraphs.
340 2 : CPPUNIT_ASSERT(getProperty<awt::Point>(xDraws->getByIndex(0), "AnchorPosition").Y != getProperty<awt::Point>(xDraws->getByIndex(1), "AnchorPosition").Y);
341 2 : }
342 :
343 2 : void Test::testFdo46662()
344 : {
345 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY);
346 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
347 2 : uno::Sequence<beans::PropertyValue> aProps;
348 2 : xLevels->getByIndex(1) >>= aProps; // 2nd level
349 :
350 26 : for (int i = 0; i < aProps.getLength(); ++i)
351 : {
352 24 : const beans::PropertyValue& rProp = aProps[i];
353 :
354 24 : if ( rProp.Name == "ParentNumbering" )
355 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(2), rProp.Value.get<sal_Int16>());
356 22 : else if ( rProp.Name == "Suffix" )
357 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get<OUString>().getLength());
358 2 : }
359 2 : }
360 :
361 2 : void Test::testN750757()
362 : {
363 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
364 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
365 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
366 :
367 2 : CPPUNIT_ASSERT_EQUAL(sal_Bool(false), getProperty<sal_Bool>(xParaEnum->nextElement(), "ParaContextMargin"));
368 2 : CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty<sal_Bool>(xParaEnum->nextElement(), "ParaContextMargin"));
369 2 : }
370 :
371 2 : void Test::testFdo45563()
372 : {
373 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
374 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
375 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
376 2 : int i = 0;
377 12 : while (xParaEnum->hasMoreElements())
378 : {
379 8 : xParaEnum->nextElement();
380 8 : i++;
381 : }
382 2 : CPPUNIT_ASSERT_EQUAL(4, i);
383 2 : }
384 :
385 2 : void Test::testFdo43965()
386 : {
387 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
388 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
389 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
390 :
391 : // First paragraph: the parameter of \up was ignored
392 2 : uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
393 2 : uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
394 2 : uno::Reference<beans::XPropertySet> xPropertySet(xRangeEnum->nextElement(), uno::UNO_QUERY);
395 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(36), getProperty<sal_Int32>(xPropertySet, "CharEscapement"));
396 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xPropertySet, "CharEscapementHeight"));
397 :
398 : // Second paragraph: Word vs Writer border default problem
399 2 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty<table::BorderLine2>(xParaEnum->nextElement(), "TopBorder").LineWidth);
400 :
401 : // Finally, make sure that we have two pages
402 2 : CPPUNIT_ASSERT_EQUAL(2, getPages());
403 2 : }
404 :
405 2 : void Test::testN751020()
406 : {
407 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
408 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
409 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
410 2 : CPPUNIT_ASSERT(xParaEnum->hasMoreElements());
411 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(200)), getProperty<sal_Int32>(xParaEnum->nextElement(), "ParaBottomMargin"));
412 2 : }
413 :
414 2 : void Test::testFdo47326()
415 : {
416 : // This was 15 only, as \super buffered text, then the contents of it got lost.
417 2 : CPPUNIT_ASSERT_EQUAL(19, getLength());
418 2 : }
419 :
420 2 : void Test::testFdo47036()
421 : {
422 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
423 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
424 2 : int nAtCharacter = 0;
425 8 : for (int i = 0; i < xDraws->getCount(); ++i)
426 : {
427 6 : if (getProperty<text::TextContentAnchorType>(xDraws->getByIndex(i), "AnchorType") == text::TextContentAnchorType_AT_CHARACTER)
428 2 : nAtCharacter++;
429 : }
430 : // The image at the document start was ignored.
431 2 : CPPUNIT_ASSERT_EQUAL(1, nAtCharacter);
432 :
433 : // There should be 2 textboxes, not 4
434 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
435 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
436 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
437 2 : }
438 :
439 2 : void Test::testFdo46955()
440 : {
441 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
442 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
443 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
444 6 : while (xParaEnum->hasMoreElements())
445 : {
446 2 : uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
447 2 : uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
448 6 : while (xRangeEnum->hasMoreElements())
449 2 : CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE, getProperty<sal_Int16>(xRangeEnum->nextElement(), "CharCaseMap"));
450 4 : }
451 2 : }
452 :
453 2 : void Test::testFdo45394()
454 : {
455 2 : uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText");
456 2 : OUString aActual = xHeaderText->getString();
457 : // Encoding in the header was wrong.
458 2 : OUString aExpected("ПК РИК", 11, RTL_TEXTENCODING_UTF8);
459 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
460 :
461 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
462 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
463 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
464 2 : }
465 :
466 2 : void Test::testFdo48104()
467 : {
468 2 : CPPUNIT_ASSERT_EQUAL(2, getPages());
469 2 : }
470 :
471 2 : void Test::testFdo47107()
472 : {
473 2 : uno::Reference<container::XNameAccess> xNumberingStyles(getStyles("NumberingStyles"));
474 : // Make sure numbered and bullet legacy syntax is recognized, this used to throw a NoSuchElementException
475 2 : xNumberingStyles->getByName("WWNum1");
476 2 : xNumberingStyles->getByName("WWNum2");
477 2 : }
478 :
479 2 : void Test::testFdo45182()
480 : {
481 2 : uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
482 2 : uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
483 2 : uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
484 : // Encoding in the footnote was wrong.
485 2 : OUString aExpected("živností", 10, RTL_TEXTENCODING_UTF8);
486 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
487 2 : }
488 :
489 2 : void Test::testFdo44176()
490 : {
491 2 : uno::Reference<container::XNameAccess> xPageStyles(getStyles("PageStyles"));
492 2 : uno::Reference<beans::XPropertySet> xFirstPage(xPageStyles->getByName("First Page"), uno::UNO_QUERY);
493 2 : uno::Reference<beans::XPropertySet> xDefault(xPageStyles->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
494 2 : sal_Int32 nFirstTop = 0, nDefaultTop = 0, nDefaultHeader = 0;
495 2 : xFirstPage->getPropertyValue("TopMargin") >>= nFirstTop;
496 2 : xDefault->getPropertyValue("TopMargin") >>= nDefaultTop;
497 2 : xDefault->getPropertyValue("HeaderHeight") >>= nDefaultHeader;
498 2 : CPPUNIT_ASSERT_EQUAL(nFirstTop, nDefaultTop + nDefaultHeader);
499 2 : }
500 :
501 2 : void Test::testFdo39053()
502 : {
503 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
504 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
505 2 : int nAsCharacter = 0;
506 4 : for (int i = 0; i < xDraws->getCount(); ++i)
507 2 : if (getProperty<text::TextContentAnchorType>(xDraws->getByIndex(i), "AnchorType") == text::TextContentAnchorType_AS_CHARACTER)
508 2 : nAsCharacter++;
509 : // The image in binary format was ignored.
510 2 : CPPUNIT_ASSERT_EQUAL(1, nAsCharacter);
511 2 : }
512 :
513 2 : void Test::testFdo48356()
514 : {
515 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
516 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
517 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
518 2 : OUStringBuffer aBuf;
519 2 : int i = 0;
520 6 : while (xParaEnum->hasMoreElements())
521 : {
522 2 : xParaEnum->nextElement();
523 2 : i++;
524 : }
525 : // The document used to be imported as two paragraphs.
526 2 : CPPUNIT_ASSERT_EQUAL(1, i);
527 2 : }
528 :
529 2 : void Test::testFdo48023()
530 : {
531 2 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
532 :
533 : // Implicit encoding detection based on locale was missing
534 2 : OUString aExpected("Программист", 22, RTL_TEXTENCODING_UTF8);
535 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
536 2 : }
537 :
538 2 : void Test::testFdo48876()
539 : {
540 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
541 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
542 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
543 2 : CPPUNIT_ASSERT(xParaEnum->hasMoreElements());
544 2 : CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::MINIMUM, getProperty<style::LineSpacing>(xParaEnum->nextElement(), "ParaLineSpacing").Mode);
545 2 : }
546 :
547 2 : void Test::testFdo48193()
548 : {
549 2 : CPPUNIT_ASSERT_EQUAL(7, getLength());
550 2 : }
551 :
552 2 : void Test::testFdo44211()
553 : {
554 2 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
555 :
556 2 : OUString aExpected("ąčę", 6, RTL_TEXTENCODING_UTF8);
557 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
558 2 : }
559 :
560 2 : void Test::testFdo48037()
561 : {
562 2 : uno::Reference<util::XNumberFormatsSupplier> xNumberSupplier(mxComponent, uno::UNO_QUERY_THROW);
563 2 : lang::Locale aUSLocale, aFRLocale;
564 2 : aUSLocale.Language = "en";
565 2 : aFRLocale.Language = "fr";
566 2 : sal_Int32 nExpected = xNumberSupplier->getNumberFormats()->addNewConverted("d MMMM yyyy", aUSLocale, aFRLocale);
567 :
568 2 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
569 2 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
570 2 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
571 2 : uno::Reference<beans::XPropertySet> xPropertySet(xFields->nextElement(), uno::UNO_QUERY);
572 2 : sal_Int32 nActual = 0;
573 2 : xPropertySet->getPropertyValue("NumberFormat") >>= nActual;
574 :
575 2 : CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
576 2 : }
577 :
578 2 : void Test::testFdo47764()
579 : {
580 : // \cbpat with zero argument should mean the auto (-1) color, not a default color (black)
581 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getParagraph(1), "ParaBackColor"));
582 2 : }
583 :
584 2 : void Test::testFdo38786()
585 : {
586 2 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
587 2 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
588 2 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
589 : // \chpgn was ignored, so exception was thrown
590 2 : xFields->nextElement();
591 2 : }
592 :
593 2 : void Test::testN757651()
594 : {
595 : // The bug was that due to buggy layout the text expanded to two pages.
596 2 : if (Application::GetDefaultDevice()->IsFontAvailable(OUString("Times New Roman")))
597 0 : CPPUNIT_ASSERT_EQUAL(1, getPages());
598 2 : }
599 :
600 2 : void Test::testFdo49501()
601 : {
602 2 : uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
603 :
604 2 : CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xStyle, "IsLandscape"));
605 2 : sal_Int32 nExpected(TWIP_TO_MM100(567));
606 2 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "LeftMargin"));
607 2 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "RightMargin"));
608 2 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "TopMargin"));
609 2 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "BottomMargin"));
610 2 : }
611 :
612 2 : void Test::testFdo49271()
613 : {
614 2 : CPPUNIT_ASSERT_EQUAL(25.f, getProperty<float>(getParagraph(2), "CharHeight"));
615 2 : }
616 :
617 2 : void Test::testFdo49692()
618 : {
619 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
620 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
621 2 : uno::Sequence<beans::PropertyValue> aProps;
622 2 : xLevels->getByIndex(0) >>= aProps; // 1st level
623 :
624 26 : for (int i = 0; i < aProps.getLength(); ++i)
625 : {
626 24 : const beans::PropertyValue& rProp = aProps[i];
627 :
628 24 : if (rProp.Name == "Suffix")
629 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get<OUString>().getLength());
630 2 : }
631 2 : }
632 :
633 2 : void Test::testFdo45190()
634 : {
635 : // inherited \fi should be reset
636 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent"));
637 :
638 : // but direct one not
639 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(-100)), getProperty<sal_Int32>(getParagraph(2), "ParaFirstLineIndent"));
640 2 : }
641 :
642 2 : void Test::testFdo50539()
643 : {
644 : // \chcbpat with zero argument should mean the auto (-1) color, not a default color (black)
645 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor"));
646 2 : }
647 :
648 2 : void Test::testFdo50665()
649 : {
650 : // Access the second run, which is a textfield
651 2 : uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 2), uno::UNO_QUERY);
652 : // This used to be the default, as character properties were ignored.
653 2 : CPPUNIT_ASSERT_EQUAL(OUString("Book Antiqua"), getProperty<OUString>(xRun, "CharFontName"));
654 2 : }
655 :
656 2 : void Test::testFdo49659()
657 : {
658 : // Both tables were ignored: 1) was in the header, 2) was ignored due to missing empty par at the end of the doc
659 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
660 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
661 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
662 :
663 : // The graphic was also empty
664 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
665 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
666 2 : uno::Reference<beans::XPropertySet> xGraphic(getProperty< uno::Reference<beans::XPropertySet> >(xDraws->getByIndex(0), "Graphic"), uno::UNO_QUERY);
667 2 : CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL, getProperty<sal_Int8>(xGraphic, "GraphicType"));
668 2 : }
669 :
670 2 : void Test::testFdo46966()
671 : {
672 : /*
673 : * The problem was the top margin was 1440 (1 inch), but it should be 720 (0.5 inch).
674 : *
675 : * xray ThisComponent.StyleFamilies.PageStyles.Default.TopMargin
676 : */
677 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
678 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(720)), getProperty<sal_Int32>(xPropertySet, "TopMargin"));
679 2 : }
680 :
681 2 : void Test::testFdo52066()
682 : {
683 : /*
684 : * The problem was that the height of the shape was too big.
685 : *
686 : * xray ThisComponent.DrawPage(0).Size.Height
687 : */
688 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
689 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
690 2 : uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
691 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(19)), xShape->getSize().Height);
692 2 : }
693 :
694 2 : void Test::testFdo48033()
695 : {
696 : /*
697 : * The problem was that the picture was in the first cell, instead of the second one.
698 : *
699 : * oTable = ThisComponent.TextTables(0)
700 : * oParas = oTable.getCellByName("B1").Text.createEnumeration
701 : * oPara = oParas.nextElement
702 : * oRuns = oPara.createEnumeration
703 : * oRun = oRuns.nextElement
704 : * xray oRun.TextPortionType ' Frame, was Text
705 : */
706 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
707 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
708 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
709 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
710 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
711 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
712 2 : uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
713 2 : CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty<OUString>(getRun(xPara, 1), "TextPortionType"));
714 2 : }
715 :
716 2 : void Test::testFdo36089()
717 : {
718 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(-50), getProperty<sal_Int16>(getRun(getParagraph(1), 2), "CharEscapement"));
719 2 : }
720 :
721 2 : void Test::testFdo49892()
722 : {
723 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
724 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
725 12 : for (int i = 0; i < xDraws->getCount(); ++i)
726 : {
727 10 : OUString aDescription = getProperty<OUString>(xDraws->getByIndex(i), "Description");
728 10 : if (aDescription == "red")
729 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
730 8 : else if (aDescription == "green")
731 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
732 6 : else if (aDescription == "blue")
733 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
734 4 : else if (aDescription == "rect")
735 : {
736 2 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(i), "HoriOrientRelation"));
737 2 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(i), "VertOrientRelation"));
738 : }
739 12 : }
740 2 : }
741 :
742 2 : void Test::testFdo48446()
743 : {
744 2 : OUString aExpected("Имя", 6, RTL_TEXTENCODING_UTF8);
745 2 : getParagraph(1, aExpected);
746 2 : }
747 :
748 2 : void Test::testFdo47495()
749 : {
750 : // Used to have 4 paragraphs, as a result the original bugdoc had 2 pages instead of 1.
751 2 : CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
752 2 : }
753 :
754 2 : void Test::testAllGapsWord()
755 : {
756 2 : BorderTest borderTest;
757 2 : borderTest.testTheBorders(mxComponent);
758 2 : }
759 :
760 2 : void Test::testFdo52052()
761 : {
762 : // Make sure the textframe containing the text "third" appears on the 3rd page.
763 2 : CPPUNIT_ASSERT_EQUAL(OUString("third"), parseDump("/root/page[3]/body/txt/anchored/fly/txt/text()"));
764 2 : }
765 :
766 2 : void Test::testInk()
767 : {
768 : /*
769 : * The problem was that the second segment had wrong command count and wrap type.
770 : *
771 : * oShape = ThisComponent.DrawPage(0)
772 : * oPathPropVec = oShape.CustomShapeGeometry(1).Value
773 : * oSegments = oPathPropVec(1).Value
774 : * msgbox oSegments(1).Count ' was 0x2000 | 10, should be 10
775 : * msgbox oShape.Surround ' was 2, should be 1
776 : */
777 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
778 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
779 2 : uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xDraws->getByIndex(0), "CustomShapeGeometry");
780 2 : uno::Sequence<beans::PropertyValue> aPathProps;
781 8 : for (int i = 0; i < aProps.getLength(); ++i)
782 : {
783 6 : const beans::PropertyValue& rProp = aProps[i];
784 6 : if (rProp.Name == "Path")
785 2 : rProp.Value >>= aPathProps;
786 : }
787 2 : uno::Sequence<drawing::EnhancedCustomShapeSegment> aSegments;
788 6 : for (int i = 0; i < aPathProps.getLength(); ++i)
789 : {
790 4 : const beans::PropertyValue& rProp = aPathProps[i];
791 4 : if (rProp.Name == "Segments")
792 2 : rProp.Value >>= aSegments;
793 : }
794 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aSegments[1].Count);
795 2 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(xDraws->getByIndex(0), "Surround"));
796 2 : }
797 :
798 2 : void Test::testFdo52389()
799 : {
800 : // The last '!' character at the end of the document was lost
801 2 : CPPUNIT_ASSERT_EQUAL(6, getLength());
802 2 : }
803 :
804 2 : void Test::testFdo49655()
805 : {
806 : /*
807 : * The problem was that the table was not imported due to the ' ' string in the middle of the table definition.
808 : *
809 : * xray ThisComponent.TextTables.Count 'was 0
810 : */
811 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
812 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
813 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
814 2 : }
815 :
816 2 : void Test::testFdo52475()
817 : {
818 : // The problem was that \chcbpat0 resulted in no color, instead of COL_AUTO.
819 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 3), "CharBackColor"));
820 2 : }
821 :
822 2 : void Test::testFdo55493()
823 : {
824 : // The problem was that the width of the PNG was detected as 15,24cm, instead of 3.97cm
825 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
826 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
827 2 : uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
828 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3969), xShape->getSize().Width);
829 2 : }
830 :
831 2 : void Test::testCopyPastePageStyle()
832 : {
833 : // The problem was that RTF import during copy&paste did not ignore page styles.
834 : // Once we have more copy&paste tests, makes sense to refactor this to some helper method.
835 2 : uno::Reference<uno::XInterface> xInterface(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
836 2 : uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
837 2 : xImporter->setTargetDocument(mxComponent);
838 2 : uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
839 2 : uno::Sequence<beans::PropertyValue> aDescriptor(2);
840 2 : aDescriptor[0].Name = "InputStream";
841 2 : SvStream* pStream = utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + "copypaste-pagestyle-paste.rtf", STREAM_WRITE);
842 2 : uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
843 2 : aDescriptor[0].Value <<= xStream;
844 2 : aDescriptor[1].Name = "IsNewDoc";
845 2 : aDescriptor[1].Value <<= sal_False;
846 2 : xFilter->filter(aDescriptor);
847 :
848 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
849 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), getProperty<sal_Int32>(xPropertySet, "Width")); // Was letter, i.e. 21590
850 2 : }
851 :
852 2 : void Test::testShptxtPard()
853 : {
854 : // The problem was that \pard inside \shptxt caused loss of shape text
855 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
856 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
857 2 : uno::Reference<text::XText> xText(xDraws->getByIndex(0), uno::UNO_QUERY);
858 2 : CPPUNIT_ASSERT_EQUAL(OUString("shape text"), xText->getString());
859 2 : }
860 :
861 2 : void Test::testDoDhgt()
862 : {
863 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
864 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
865 8 : for (int i = 0; i < xDraws->getCount(); ++i)
866 : {
867 6 : sal_Int32 nFillColor = getProperty<sal_Int32>(xDraws->getByIndex(i), "FillColor");
868 6 : if (nFillColor == 0xc0504d) // red
869 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
870 4 : else if (nFillColor == 0x9bbb59) // green
871 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
872 2 : else if (nFillColor == 0x4f81bd) // blue
873 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
874 2 : }
875 2 : }
876 :
877 2 : void Test::testDplinehollow()
878 : {
879 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
880 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
881 2 : uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
882 2 : CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, getProperty<drawing::LineStyle>(xPropertySet, "LineStyle"));
883 2 : }
884 :
885 2 : void Test::testLeftmarginDefault()
886 : {
887 : // The default left/right margin was incorrect when the top margin was set to zero.
888 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2540), getProperty<sal_Int32>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "LeftMargin"));
889 2 : }
890 :
891 2 : void Test::testDppolyline()
892 : {
893 : // This was completely ignored, for now, just make sure we have all 4 lines.
894 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
895 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
896 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws->getCount());
897 2 : }
898 :
899 2 : void Test::testFdo56512()
900 : {
901 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
902 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
903 2 : uno::Reference<text::XTextRange> xTextRange(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
904 2 : OUString aExpected("עוסק מורשה ", 20, RTL_TEXTENCODING_UTF8);
905 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
906 2 : }
907 :
908 2 : void Test::testFdo52989()
909 : {
910 : // Same as n#192129, but for JPEG files.
911 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
912 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
913 2 : uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
914 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(423), xShape->getSize().Width);
915 2 : }
916 :
917 2 : void Test::testFdo48442()
918 : {
919 : // The problem was that \pvmrg is the default in RTF, but not in Writer.
920 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
921 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
922 2 : uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
923 2 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xShape, "VertOrientRelation")); // was FRAME
924 2 : }
925 :
926 2 : void Test::testFdo55525()
927 : {
928 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
929 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
930 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
931 : // Negative left margin was ~missing, -191
932 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty<sal_Int32>(xTable, "LeftMargin"));
933 : // Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
934 2 : uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
935 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(1016), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
936 2 : }
937 :
938 2 : void Test::testFdo57708()
939 : {
940 : // There were two issues: the doc was of 2 pages and the picture was missing.
941 2 : CPPUNIT_ASSERT_EQUAL(1, getPages());
942 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
943 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
944 : // Two objects: a picture and a textframe.
945 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
946 2 : }
947 :
948 2 : void Test::testFdo54473()
949 : {
950 : // The problem was that character styles were not imported due to a typo.
951 2 : CPPUNIT_ASSERT_EQUAL(OUString("Anot"), getProperty<OUString>(getRun(getParagraph(1), 1, "Text "), "CharStyleName"));
952 2 : CPPUNIT_ASSERT_EQUAL(OUString("ForeignTxt"), getProperty<OUString>(getRun(getParagraph(1), 3, "character "), "CharStyleName"));
953 2 : }
954 :
955 2 : void Test::testFdo49934()
956 : {
957 : // Column break without columns defined should be a page break, but it was just ignored.
958 2 : CPPUNIT_ASSERT_EQUAL(2, getPages());
959 2 : }
960 :
961 2 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
962 :
963 8 : CPPUNIT_PLUGIN_IMPLEMENT();
964 :
965 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|