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 <com/sun/star/awt/FontDescriptor.hpp>
10 : #include <com/sun/star/document/XFilter.hpp>
11 : #include <com/sun/star/document/XImporter.hpp>
12 : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
13 : #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
14 : #include <com/sun/star/drawing/LineStyle.hpp>
15 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
16 : #include <com/sun/star/graphic/GraphicType.hpp>
17 : #include <com/sun/star/lang/XServiceInfo.hpp>
18 : #include <com/sun/star/style/CaseMap.hpp>
19 : #include <com/sun/star/style/LineSpacing.hpp>
20 : #include <com/sun/star/style/LineSpacingMode.hpp>
21 : #include <com/sun/star/table/BorderLine2.hpp>
22 : #include <com/sun/star/table/BorderLineStyle.hpp>
23 : #include <com/sun/star/text/RelOrientation.hpp>
24 : #include <com/sun/star/text/SizeType.hpp>
25 : #include <com/sun/star/text/TableColumnSeparator.hpp>
26 : #include <com/sun/star/text/TextContentAnchorType.hpp>
27 : #include <com/sun/star/text/XFootnotesSupplier.hpp>
28 : #include <com/sun/star/text/XPageCursor.hpp>
29 : #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
30 : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
31 : #include <com/sun/star/text/XTextFramesSupplier.hpp>
32 : #include <com/sun/star/text/XTextRangeCompare.hpp>
33 : #include <com/sun/star/text/XTextTablesSupplier.hpp>
34 : #include <com/sun/star/text/XTextTable.hpp>
35 : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
36 : #include <com/sun/star/text/WrapTextMode.hpp>
37 : #include <com/sun/star/text/HoriOrientation.hpp>
38 : #include <com/sun/star/text/VertOrientation.hpp>
39 : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
40 :
41 : #include <rtl/ustring.hxx>
42 : #include <vcl/outdev.hxx>
43 : #include <vcl/svapp.hxx>
44 : #include <unotools/ucbstreamhelper.hxx>
45 : #include <unotools/streamwrap.hxx>
46 :
47 : #include <swmodeltestbase.hxx>
48 : #include <bordertest.hxx>
49 :
50 : #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
51 :
52 3 : class Test : public SwModelTestBase
53 : {
54 : public:
55 : void testFdo45553();
56 : void testN192129();
57 : void testFdo45543();
58 : void testN695479();
59 : void testFdo42465();
60 : void testFdo45187();
61 : void testFdo46662();
62 : void testN750757();
63 : void testFdo45563();
64 : void testFdo43965();
65 : void testN751020();
66 : void testFdo47326();
67 : void testFdo47036();
68 : void testFdo46955();
69 : void testFdo45394();
70 : void testFdo48104();
71 : void testFdo47107();
72 : void testFdo45182();
73 : void testFdo44176();
74 : void testFdo39053();
75 : void testFdo48356();
76 : void testFdo48023();
77 : void testFdo48876();
78 : void testFdo48193();
79 : void testFdo44211();
80 : void testFdo48037();
81 : void testFdo47764();
82 : void testFdo38786();
83 : void testN757651();
84 : void testFdo49501();
85 : void testFdo49271();
86 : void testFdo49692();
87 : void testFdo45190();
88 : void testFdo50539();
89 : void testFdo50665();
90 : void testFdo49659();
91 : void testFdo46966();
92 : void testFdo52066();
93 : void testFdo48033_53594();
94 : void testFdo36089();
95 : void testFdo49892();
96 : void testFdo48446();
97 : void testFdo47495();
98 : void testAllGapsWord();
99 : void testFdo52052();
100 : void testInk();
101 : void testFdo52389();
102 : void testFdo49655_62805();
103 : void testFdo52475();
104 : void testFdo55493();
105 : void testCopyPastePageStyle();
106 : void testCopyPasteFootnote();
107 : void testShptxtPard();
108 : void testDoDhgt();
109 : void testDplinehollow();
110 : void testLeftmarginDefault();
111 : void testDppolyline();
112 : void testFdo56512();
113 : void testFdo52989();
114 : void testFdo48442();
115 : void testFdo55525();
116 : void testFdo57708();
117 : void testFdo54473();
118 : void testFdo49934();
119 : void testFdo57886();
120 : void testFdo58076();
121 : void testFdo57678();
122 : void testFdo45183();
123 : void testFdo54612();
124 : void testFdo58933();
125 : void testFdo44053();
126 : void testFdo48440();
127 : void testFdo58646line();
128 : void testFdo58646();
129 : void testFdo59419();
130 : void testFdo58076_2();
131 : void testFdo59953();
132 : void testFdo59638();
133 : void testFdo60722();
134 : void testFdo61909();
135 : void testFdo62288();
136 : void testFdo37716();
137 : void testFdo51916();
138 : void testFdo61193();
139 : void testFdo63023();
140 : void testFdo42109();
141 : void testFdo62977();
142 : void testN818997();
143 : void testFdo64671();
144 : void testPageBackground();
145 : void testFdo62044();
146 : void testPoshPosv();
147 : void testN825305();
148 : void testParaBottomMargin();
149 : void testN823655();
150 : void testFdo66040();
151 : void testN823675();
152 : void testFdo47802();
153 : void testFdo39001();
154 :
155 2 : CPPUNIT_TEST_SUITE(Test);
156 : #if !defined(MACOSX) && !defined(WNT)
157 1 : CPPUNIT_TEST(run);
158 : #endif
159 2 : CPPUNIT_TEST_SUITE_END();
160 :
161 : private:
162 : void run();
163 : /// Copy&paste helper.
164 4 : void paste(OUString aFilename, uno::Reference<text::XTextRange> xTextRange = uno::Reference<text::XTextRange>())
165 : {
166 4 : uno::Reference<document::XFilter> xFilter(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
167 8 : uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
168 4 : xImporter->setTargetDocument(mxComponent);
169 8 : uno::Sequence<beans::PropertyValue> aDescriptor(xTextRange.is() ? 3 : 2);
170 4 : aDescriptor[0].Name = "InputStream";
171 4 : SvStream* pStream = utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + aFilename, STREAM_WRITE);
172 8 : uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
173 4 : aDescriptor[0].Value <<= xStream;
174 4 : aDescriptor[1].Name = "IsNewDoc";
175 4 : aDescriptor[1].Value <<= sal_False;
176 4 : if (xTextRange.is())
177 : {
178 3 : aDescriptor[2].Name = "TextInsertModeRange";
179 3 : aDescriptor[2].Value <<= xTextRange;
180 : }
181 8 : xFilter->filter(aDescriptor);
182 4 : }
183 :
184 : };
185 :
186 1 : void Test::run()
187 : {
188 : MethodEntry<Test> aMethods[] = {
189 : {"fdo45553.rtf", &Test::testFdo45553},
190 : {"n192129.rtf", &Test::testN192129},
191 : {"fdo45543.rtf", &Test::testFdo45543},
192 : {"n695479.rtf", &Test::testN695479},
193 : {"fdo42465.rtf", &Test::testFdo42465},
194 : {"fdo45187.rtf", &Test::testFdo45187},
195 : {"fdo46662.rtf", &Test::testFdo46662},
196 : {"n750757.rtf", &Test::testN750757},
197 : {"fdo45563.rtf", &Test::testFdo45563},
198 : {"fdo43965.rtf", &Test::testFdo43965},
199 : {"n751020.rtf", &Test::testN751020},
200 : {"fdo47326.rtf", &Test::testFdo47326},
201 : {"fdo47036.rtf", &Test::testFdo47036},
202 : {"fdo46955.rtf", &Test::testFdo46955},
203 : {"fdo45394.rtf", &Test::testFdo45394},
204 : {"fdo48104.rtf", &Test::testFdo48104},
205 : {"fdo47107.rtf", &Test::testFdo47107},
206 : {"fdo45182.rtf", &Test::testFdo45182},
207 : {"fdo44176.rtf", &Test::testFdo44176},
208 : {"fdo39053.rtf", &Test::testFdo39053},
209 : {"fdo48356.rtf", &Test::testFdo48356},
210 : {"fdo48023.rtf", &Test::testFdo48023},
211 : {"fdo48876.rtf", &Test::testFdo48876},
212 : {"fdo48193.rtf", &Test::testFdo48193},
213 : {"fdo44211.rtf", &Test::testFdo44211},
214 : {"fdo48037.rtf", &Test::testFdo48037},
215 : {"fdo47764.rtf", &Test::testFdo47764},
216 : {"fdo38786.rtf", &Test::testFdo38786},
217 : {"n757651.rtf", &Test::testN757651},
218 : {"fdo49501.rtf", &Test::testFdo49501},
219 : {"fdo49271.rtf", &Test::testFdo49271},
220 : {"fdo49692.rtf", &Test::testFdo49692},
221 : {"fdo45190.rtf", &Test::testFdo45190},
222 : {"fdo50539.rtf", &Test::testFdo50539},
223 : {"fdo50665.rtf", &Test::testFdo50665},
224 : {"fdo49659.rtf", &Test::testFdo49659},
225 : {"fdo46966.rtf", &Test::testFdo46966},
226 : {"fdo52066.rtf", &Test::testFdo52066},
227 : {"fdo48033.rtf", &Test::testFdo48033_53594},
228 : {"fdo53594.rtf", &Test::testFdo48033_53594},
229 : {"fdo36089.rtf", &Test::testFdo36089},
230 : {"fdo49892.rtf", &Test::testFdo49892},
231 : {"fdo48446.rtf", &Test::testFdo48446},
232 : {"fdo47495.rtf", &Test::testFdo47495},
233 : {"all_gaps_word.rtf", &Test::testAllGapsWord},
234 : {"fdo52052.rtf", &Test::testFdo52052},
235 : {"ink.rtf", &Test::testInk},
236 : {"fdo52389.rtf", &Test::testFdo52389},
237 : {"fdo49655.rtf", &Test::testFdo49655_62805},
238 : {"fdo62805.rtf", &Test::testFdo49655_62805},
239 : {"fdo52475.rtf", &Test::testFdo52475},
240 : {"fdo55493.rtf", &Test::testFdo55493},
241 : {"copypaste-pagestyle.rtf", &Test::testCopyPastePageStyle},
242 : {"copypaste-footnote.rtf", &Test::testCopyPasteFootnote},
243 : {"shptxt-pard.rtf", &Test::testShptxtPard},
244 : {"do-dhgt.rtf", &Test::testDoDhgt},
245 : {"dplinehollow.rtf", &Test::testDplinehollow},
246 : {"leftmargin-default.rtf", &Test::testLeftmarginDefault},
247 : {"dppolyline.rtf", &Test::testDppolyline},
248 : {"fdo56512.rtf", &Test::testFdo56512},
249 : {"fdo52989.rtf", &Test::testFdo52989},
250 : {"fdo48442.rtf", &Test::testFdo48442},
251 : {"fdo55525.rtf", &Test::testFdo55525},
252 : {"fdo57708.rtf", &Test::testFdo57708},
253 : {"fdo54473.rtf", &Test::testFdo54473},
254 : {"fdo49934.rtf", &Test::testFdo49934},
255 : {"fdo57886.rtf", &Test::testFdo57886},
256 : {"fdo58076.rtf", &Test::testFdo58076},
257 : {"fdo57678.rtf", &Test::testFdo57678},
258 : {"fdo45183.rtf", &Test::testFdo45183},
259 : {"fdo54612.rtf", &Test::testFdo54612},
260 : {"fdo58933.rtf", &Test::testFdo58933},
261 : {"fdo44053.rtf", &Test::testFdo44053},
262 : {"fdo48440.rtf", &Test::testFdo48440},
263 : {"fdo58646line.rtf", &Test::testFdo58646line},
264 : {"fdo58646.rtf", &Test::testFdo58646},
265 : {"fdo59419.rtf", &Test::testFdo59419},
266 : {"fdo58076-2.rtf", &Test::testFdo58076_2},
267 : {"fdo59953.rtf", &Test::testFdo59953},
268 : {"fdo59638.rtf", &Test::testFdo59638},
269 : {"fdo60722.rtf", &Test::testFdo60722},
270 : {"fdo61909.rtf", &Test::testFdo61909},
271 : {"fdo62288.rtf", &Test::testFdo62288},
272 : {"fdo37716.rtf", &Test::testFdo37716},
273 : {"fdo51916.rtf", &Test::testFdo51916},
274 : {"hello.rtf", &Test::testFdo61193},
275 : {"fdo63023.rtf", &Test::testFdo63023},
276 : {"fdo42109.rtf", &Test::testFdo42109},
277 : {"fdo62977.rtf", &Test::testFdo62977},
278 : {"n818997.rtf", &Test::testN818997},
279 : {"fdo64671.rtf", &Test::testFdo64671},
280 : {"page-background.rtf", &Test::testPageBackground},
281 : {"fdo62044.rtf", &Test::testFdo62044},
282 : {"posh-posv.rtf", &Test::testPoshPosv},
283 : {"n825305.rtf", &Test::testN825305},
284 : {"para-bottom-margin.rtf", &Test::testParaBottomMargin},
285 : {"n823655.rtf", &Test::testN823655},
286 : {"fdo66040.rtf", &Test::testFdo66040},
287 : {"n823675.rtf", &Test::testN823675},
288 : {"fdo47802.rtf", &Test::testFdo47802},
289 : {"fdo39001.rtf", &Test::testFdo39001},
290 1 : };
291 1 : header();
292 102 : for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
293 : {
294 101 : MethodEntry<Test>& rEntry = aMethods[i];
295 101 : AllSettings aSavedSettings(Application::GetSettings());
296 101 : if (OString(rEntry.pName) == "fdo48023.rtf")
297 : {
298 1 : AllSettings aSettings(aSavedSettings);
299 1 : aSettings.SetLanguageTag(LanguageTag("ru"));
300 1 : Application::SetSettings(aSettings);
301 : }
302 100 : else if (OString(rEntry.pName) == "fdo44211.rtf")
303 : {
304 1 : AllSettings aSettings(aSavedSettings);
305 1 : aSettings.SetLanguageTag(LanguageTag("lt"));
306 1 : Application::SetSettings(aSettings);
307 : }
308 101 : load("/sw/qa/extras/rtfimport/data/", rEntry.pName);
309 101 : if (OString(rEntry.pName) == "fdo48023.rtf" || OString(rEntry.pName) == "fdo44211.rtf")
310 2 : Application::SetSettings(aSavedSettings);
311 101 : (this->*rEntry.pMethod)();
312 101 : finish();
313 101 : }
314 1 : }
315 :
316 1 : void Test::testFdo45553()
317 : {
318 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
319 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
320 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
321 4 : while (xParaEnum->hasMoreElements())
322 : {
323 2 : uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
324 4 : uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
325 6 : while (xRangeEnum->hasMoreElements())
326 : {
327 2 : uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY);
328 4 : OUString aStr = xRange->getString();
329 2 : if ( aStr == "space-before" )
330 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(120)), getProperty<sal_Int32>(xRange, "ParaTopMargin"));
331 1 : else if ( aStr == "space-after" )
332 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(240)), getProperty<sal_Int32>(xRange, "ParaBottomMargin"));
333 2 : }
334 3 : }
335 1 : }
336 :
337 1 : void Test::testN192129()
338 : {
339 : // We expect that the result will be 16x16px.
340 1 : Size aExpectedSize(16, 16);
341 1 : MapMode aMap(MAP_100TH_MM);
342 1 : aExpectedSize = Application::GetDefaultDevice()->PixelToLogic( aExpectedSize, aMap );
343 :
344 2 : uno::Reference<text::XTextGraphicObjectsSupplier> xTextGraphicObjectsSupplier(mxComponent, uno::UNO_QUERY);
345 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextGraphicObjectsSupplier->getGraphicObjects(), uno::UNO_QUERY);
346 2 : uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
347 1 : awt::Size aActualSize(xShape->getSize());
348 :
349 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Width()), aActualSize.Width);
350 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Height()), aActualSize.Height);
351 1 : }
352 :
353 1 : void Test::testFdo45543()
354 : {
355 1 : CPPUNIT_ASSERT_EQUAL(5, getLength());
356 1 : }
357 :
358 1 : void Test::testN695479()
359 : {
360 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
361 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
362 2 : uno::Reference<beans::XPropertySet> xPropertySet(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
363 :
364 : // Negative ABSH should mean fixed size.
365 1 : CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX, getProperty<sal_Int16>(xPropertySet, "SizeType"));
366 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(300)), getProperty<sal_Int32>(xPropertySet, "Height"));
367 :
368 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
369 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
370 1 : bool bFrameFound = false, bDrawFound = false;
371 4 : for (int i = 0; i < xDraws->getCount(); ++i)
372 : {
373 3 : uno::Reference<lang::XServiceInfo> xServiceInfo(xDraws->getByIndex(i), uno::UNO_QUERY);
374 3 : if (xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
375 : {
376 : // Both frames should be anchored to the first paragraph.
377 2 : bFrameFound = true;
378 2 : uno::Reference<text::XTextContent> xTextContent(xServiceInfo, uno::UNO_QUERY);
379 4 : uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
380 4 : uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY);
381 2 : CPPUNIT_ASSERT_EQUAL(OUString("plain"), xText->getString());
382 :
383 2 : if (i == 0)
384 : // Additonally, the frist frame should have double border at the bottom.
385 2 : CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::DOUBLE, getProperty<table::BorderLine2>(xPropertySet, "BottomBorder").LineStyle);
386 : }
387 1 : else if (xServiceInfo->supportsService("com.sun.star.drawing.LineShape"))
388 : {
389 : // The older "drawing objects" syntax should be recognized.
390 1 : bDrawFound = true;
391 1 : xPropertySet.set(xServiceInfo, uno::UNO_QUERY);
392 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xPropertySet, "HoriOrientRelation"));
393 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xPropertySet, "VertOrientRelation"));
394 : }
395 3 : }
396 1 : CPPUNIT_ASSERT(bFrameFound);
397 2 : CPPUNIT_ASSERT(bDrawFound);
398 1 : }
399 :
400 1 : void Test::testFdo42465()
401 : {
402 1 : CPPUNIT_ASSERT_EQUAL(3, getLength());
403 1 : }
404 :
405 1 : void Test::testFdo45187()
406 : {
407 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
408 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
409 : // There should be two shapes.
410 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
411 :
412 : // They should be anchored to different paragraphs.
413 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
414 2 : uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xTextDocument->getText(), uno::UNO_QUERY);
415 2 : uno::Reference<text::XTextRange> xAnchor0 = uno::Reference<text::XTextContent>(xDraws->getByIndex(0), uno::UNO_QUERY)->getAnchor();
416 2 : uno::Reference<text::XTextRange> xAnchor1 = uno::Reference<text::XTextContent>(xDraws->getByIndex(1), uno::UNO_QUERY)->getAnchor();
417 : // Was 0 ("starts at the same position"), should be 1 ("starts before")
418 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xTextRangeCompare->compareRegionStarts(xAnchor0, xAnchor1));
419 1 : }
420 :
421 1 : void Test::testFdo46662()
422 : {
423 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY);
424 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
425 2 : uno::Sequence<beans::PropertyValue> aProps;
426 1 : xLevels->getByIndex(1) >>= aProps; // 2nd level
427 :
428 13 : for (int i = 0; i < aProps.getLength(); ++i)
429 : {
430 12 : const beans::PropertyValue& rProp = aProps[i];
431 :
432 12 : if ( rProp.Name == "ParentNumbering" )
433 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(2), rProp.Value.get<sal_Int16>());
434 11 : else if ( rProp.Name == "Suffix" )
435 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get<OUString>().getLength());
436 1 : }
437 1 : }
438 :
439 1 : void Test::testN750757()
440 : {
441 1 : 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 :
445 1 : CPPUNIT_ASSERT_EQUAL(sal_Bool(false), getProperty<sal_Bool>(xParaEnum->nextElement(), "ParaContextMargin"));
446 2 : CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty<sal_Bool>(xParaEnum->nextElement(), "ParaContextMargin"));
447 1 : }
448 :
449 1 : void Test::testFdo45563()
450 : {
451 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
452 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
453 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
454 1 : int i = 0;
455 6 : while (xParaEnum->hasMoreElements())
456 : {
457 4 : xParaEnum->nextElement();
458 4 : i++;
459 : }
460 2 : CPPUNIT_ASSERT_EQUAL(4, i);
461 1 : }
462 :
463 1 : void Test::testFdo43965()
464 : {
465 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
466 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
467 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
468 :
469 : // First paragraph: the parameter of \up was ignored
470 2 : uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
471 2 : uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
472 2 : uno::Reference<beans::XPropertySet> xPropertySet(xRangeEnum->nextElement(), uno::UNO_QUERY);
473 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(36), getProperty<sal_Int32>(xPropertySet, "CharEscapement"));
474 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xPropertySet, "CharEscapementHeight"));
475 :
476 : // Second paragraph: Word vs Writer border default problem
477 1 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty<table::BorderLine2>(xParaEnum->nextElement(), "TopBorder").LineWidth);
478 :
479 : // Finally, make sure that we have two pages
480 2 : CPPUNIT_ASSERT_EQUAL(2, getPages());
481 1 : }
482 :
483 1 : void Test::testN751020()
484 : {
485 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
486 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
487 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
488 1 : CPPUNIT_ASSERT(xParaEnum->hasMoreElements());
489 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(200)), getProperty<sal_Int32>(xParaEnum->nextElement(), "ParaBottomMargin"));
490 1 : }
491 :
492 1 : void Test::testFdo47326()
493 : {
494 : // This was 15 only, as \super buffered text, then the contents of it got lost.
495 1 : CPPUNIT_ASSERT_EQUAL(19, getLength());
496 1 : }
497 :
498 1 : void Test::testFdo47036()
499 : {
500 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
501 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
502 1 : int nAtCharacter = 0;
503 4 : for (int i = 0; i < xDraws->getCount(); ++i)
504 : {
505 3 : if (getProperty<text::TextContentAnchorType>(xDraws->getByIndex(i), "AnchorType") == text::TextContentAnchorType_AT_CHARACTER)
506 1 : nAtCharacter++;
507 : }
508 : // The image at the document start was ignored.
509 1 : CPPUNIT_ASSERT_EQUAL(1, nAtCharacter);
510 :
511 : // There should be 2 textboxes, not 4
512 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
513 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
514 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
515 1 : }
516 :
517 1 : void Test::testFdo46955()
518 : {
519 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
520 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
521 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
522 3 : while (xParaEnum->hasMoreElements())
523 : {
524 1 : uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
525 2 : uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
526 3 : while (xRangeEnum->hasMoreElements())
527 1 : CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE, getProperty<sal_Int16>(xRangeEnum->nextElement(), "CharCaseMap"));
528 2 : }
529 1 : }
530 :
531 1 : void Test::testFdo45394()
532 : {
533 1 : uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText");
534 2 : OUString aActual = xHeaderText->getString();
535 : // Encoding in the header was wrong.
536 2 : OUString aExpected("ПК РИК", 11, RTL_TEXTENCODING_UTF8);
537 1 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
538 :
539 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
540 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
541 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
542 1 : }
543 :
544 1 : void Test::testFdo48104()
545 : {
546 1 : CPPUNIT_ASSERT_EQUAL(2, getPages());
547 1 : }
548 :
549 1 : void Test::testFdo47107()
550 : {
551 1 : uno::Reference<container::XNameAccess> xNumberingStyles(getStyles("NumberingStyles"));
552 : // Make sure numbered and bullet legacy syntax is recognized, this used to throw a NoSuchElementException
553 1 : xNumberingStyles->getByName("WWNum1");
554 1 : xNumberingStyles->getByName("WWNum2");
555 1 : }
556 :
557 1 : void Test::testFdo45182()
558 : {
559 1 : uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
560 2 : uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
561 2 : uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
562 : // Encoding in the footnote was wrong.
563 2 : OUString aExpected("živností", 10, RTL_TEXTENCODING_UTF8);
564 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
565 1 : }
566 :
567 1 : void Test::testFdo44176()
568 : {
569 1 : uno::Reference<container::XNameAccess> xPageStyles(getStyles("PageStyles"));
570 2 : uno::Reference<beans::XPropertySet> xFirstPage(xPageStyles->getByName("First Page"), uno::UNO_QUERY);
571 2 : uno::Reference<beans::XPropertySet> xDefault(xPageStyles->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
572 1 : sal_Int32 nFirstTop = 0, nDefaultTop = 0, nDefaultHeader = 0;
573 1 : xFirstPage->getPropertyValue("TopMargin") >>= nFirstTop;
574 1 : xDefault->getPropertyValue("TopMargin") >>= nDefaultTop;
575 1 : xDefault->getPropertyValue("HeaderHeight") >>= nDefaultHeader;
576 2 : CPPUNIT_ASSERT_EQUAL(nFirstTop, nDefaultTop + nDefaultHeader);
577 1 : }
578 :
579 1 : void Test::testFdo39053()
580 : {
581 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
582 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
583 1 : int nAsCharacter = 0;
584 2 : for (int i = 0; i < xDraws->getCount(); ++i)
585 1 : if (getProperty<text::TextContentAnchorType>(xDraws->getByIndex(i), "AnchorType") == text::TextContentAnchorType_AS_CHARACTER)
586 1 : nAsCharacter++;
587 : // The image in binary format was ignored.
588 2 : CPPUNIT_ASSERT_EQUAL(1, nAsCharacter);
589 1 : }
590 :
591 1 : void Test::testFdo48356()
592 : {
593 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
594 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
595 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
596 1 : int i = 0;
597 3 : while (xParaEnum->hasMoreElements())
598 : {
599 1 : xParaEnum->nextElement();
600 1 : i++;
601 : }
602 : // The document used to be imported as two paragraphs.
603 2 : CPPUNIT_ASSERT_EQUAL(1, i);
604 1 : }
605 :
606 1 : void Test::testFdo48023()
607 : {
608 1 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
609 :
610 : // Implicit encoding detection based on locale was missing
611 2 : OUString aExpected("Программист", 22, RTL_TEXTENCODING_UTF8);
612 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
613 1 : }
614 :
615 1 : void Test::testFdo48876()
616 : {
617 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
618 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
619 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
620 1 : CPPUNIT_ASSERT(xParaEnum->hasMoreElements());
621 2 : CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::MINIMUM, getProperty<style::LineSpacing>(xParaEnum->nextElement(), "ParaLineSpacing").Mode);
622 1 : }
623 :
624 1 : void Test::testFdo48193()
625 : {
626 1 : CPPUNIT_ASSERT_EQUAL(7, getLength());
627 1 : }
628 :
629 1 : void Test::testFdo44211()
630 : {
631 1 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
632 :
633 2 : OUString aExpected("ąčę", 6, RTL_TEXTENCODING_UTF8);
634 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
635 1 : }
636 :
637 1 : void Test::testFdo48037()
638 : {
639 1 : uno::Reference<util::XNumberFormatsSupplier> xNumberSupplier(mxComponent, uno::UNO_QUERY_THROW);
640 2 : lang::Locale aUSLocale, aFRLocale;
641 1 : aUSLocale.Language = "en";
642 1 : aFRLocale.Language = "fr";
643 1 : sal_Int32 nExpected = xNumberSupplier->getNumberFormats()->addNewConverted("d MMMM yyyy", aUSLocale, aFRLocale);
644 :
645 2 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
646 2 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
647 2 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
648 2 : uno::Reference<beans::XPropertySet> xPropertySet(xFields->nextElement(), uno::UNO_QUERY);
649 1 : sal_Int32 nActual = 0;
650 1 : xPropertySet->getPropertyValue("NumberFormat") >>= nActual;
651 :
652 2 : CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
653 1 : }
654 :
655 1 : void Test::testFdo47764()
656 : {
657 : // \cbpat with zero argument should mean the auto (-1) color, not a default color (black)
658 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getParagraph(1), "ParaBackColor"));
659 1 : }
660 :
661 1 : void Test::testFdo38786()
662 : {
663 1 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
664 2 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
665 2 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
666 : // \chpgn was ignored, so exception was thrown
667 2 : xFields->nextElement();
668 1 : }
669 :
670 1 : void Test::testN757651()
671 : {
672 : // The bug was that due to buggy layout the text expanded to two pages.
673 1 : if (Application::GetDefaultDevice()->IsFontAvailable(OUString("Times New Roman")))
674 0 : CPPUNIT_ASSERT_EQUAL(1, getPages());
675 1 : }
676 :
677 1 : void Test::testFdo49501()
678 : {
679 1 : uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
680 :
681 1 : CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xStyle, "IsLandscape"));
682 1 : sal_Int32 nExpected(TWIP_TO_MM100(567));
683 1 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "LeftMargin"));
684 1 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "RightMargin"));
685 1 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "TopMargin"));
686 1 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "BottomMargin"));
687 1 : }
688 :
689 1 : void Test::testFdo49271()
690 : {
691 1 : CPPUNIT_ASSERT_EQUAL(25.f, getProperty<float>(getParagraph(2), "CharHeight"));
692 1 : }
693 :
694 1 : void Test::testFdo49692()
695 : {
696 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
697 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
698 2 : uno::Sequence<beans::PropertyValue> aProps;
699 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
700 :
701 13 : for (int i = 0; i < aProps.getLength(); ++i)
702 : {
703 12 : const beans::PropertyValue& rProp = aProps[i];
704 :
705 12 : if (rProp.Name == "Suffix")
706 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get<OUString>().getLength());
707 1 : }
708 1 : }
709 :
710 1 : void Test::testFdo45190()
711 : {
712 : // inherited \fi should be reset
713 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent"));
714 :
715 : // but direct one not
716 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(-100)), getProperty<sal_Int32>(getParagraph(2), "ParaFirstLineIndent"));
717 1 : }
718 :
719 1 : void Test::testFdo50539()
720 : {
721 : // \chcbpat with zero argument should mean the auto (-1) color, not a default color (black)
722 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor"));
723 1 : }
724 :
725 1 : void Test::testFdo50665()
726 : {
727 : // Access the second run, which is a textfield
728 1 : uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 2), uno::UNO_QUERY);
729 : // This used to be the default, as character properties were ignored.
730 1 : CPPUNIT_ASSERT_EQUAL(OUString("Book Antiqua"), getProperty<OUString>(xRun, "CharFontName"));
731 1 : }
732 :
733 1 : void Test::testFdo49659()
734 : {
735 : // Both tables were ignored: 1) was in the header, 2) was ignored due to missing empty par at the end of the doc
736 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
737 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
738 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
739 :
740 : // The graphic was also empty
741 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
742 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
743 2 : uno::Reference<beans::XPropertySet> xGraphic(getProperty< uno::Reference<beans::XPropertySet> >(xDraws->getByIndex(0), "Graphic"), uno::UNO_QUERY);
744 2 : CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL, getProperty<sal_Int8>(xGraphic, "GraphicType"));
745 1 : }
746 :
747 1 : void Test::testFdo46966()
748 : {
749 : /*
750 : * The problem was the top margin was 1440 (1 inch), but it should be 720 (0.5 inch).
751 : *
752 : * xray ThisComponent.StyleFamilies.PageStyles.Default.TopMargin
753 : */
754 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
755 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(720)), getProperty<sal_Int32>(xPropertySet, "TopMargin"));
756 1 : }
757 :
758 1 : void Test::testFdo52066()
759 : {
760 : /*
761 : * The problem was that the height of the shape was too big.
762 : *
763 : * xray ThisComponent.DrawPage(0).Size.Height
764 : */
765 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
766 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
767 2 : uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
768 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(19)), xShape->getSize().Height);
769 1 : }
770 :
771 2 : void Test::testFdo48033_53594()
772 : {
773 : /*
774 : * The problem was that the picture (48033) or OLE object (53594) was in the first cell,
775 : * instead of the second one.
776 : *
777 : * oTable = ThisComponent.TextTables(0)
778 : * oParas = oTable.getCellByName("B1").Text.createEnumeration
779 : * oPara = oParas.nextElement
780 : * oRuns = oPara.createEnumeration
781 : * oRun = oRuns.nextElement
782 : * xray oRun.TextPortionType ' Frame, was Text
783 : */
784 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
785 4 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
786 4 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
787 4 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
788 4 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
789 4 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
790 4 : uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
791 4 : CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty<OUString>(getRun(xPara, 1), "TextPortionType"));
792 2 : }
793 :
794 1 : void Test::testFdo36089()
795 : {
796 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(-50), getProperty<sal_Int16>(getRun(getParagraph(1), 2), "CharEscapement"));
797 1 : }
798 :
799 1 : void Test::testFdo49892()
800 : {
801 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
802 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
803 6 : for (int i = 0; i < xDraws->getCount(); ++i)
804 : {
805 5 : OUString aDescription = getProperty<OUString>(xDraws->getByIndex(i), "Description");
806 5 : if (aDescription == "red")
807 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
808 4 : else if (aDescription == "green")
809 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
810 3 : else if (aDescription == "blue")
811 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
812 2 : else if (aDescription == "rect")
813 : {
814 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(i), "HoriOrientRelation"));
815 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(i), "VertOrientRelation"));
816 : }
817 6 : }
818 1 : }
819 :
820 1 : void Test::testFdo48446()
821 : {
822 1 : OUString aExpected("Имя", 6, RTL_TEXTENCODING_UTF8);
823 1 : getParagraph(1, aExpected);
824 1 : }
825 :
826 1 : void Test::testFdo47495()
827 : {
828 : // Used to have 4 paragraphs, as a result the original bugdoc had 2 pages instead of 1.
829 1 : CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
830 1 : }
831 :
832 1 : void Test::testAllGapsWord()
833 : {
834 1 : BorderTest borderTest;
835 1 : borderTest.testTheBorders(mxComponent);
836 1 : }
837 :
838 1 : void Test::testFdo52052()
839 : {
840 : // Make sure the textframe containing the text "third" appears on the 3rd page.
841 1 : CPPUNIT_ASSERT_EQUAL(OUString("third"), parseDump("/root/page[3]/body/txt/anchored/fly/txt/text()"));
842 1 : }
843 :
844 1 : void Test::testInk()
845 : {
846 : /*
847 : * The problem was that the second segment had wrong command count and wrap type.
848 : *
849 : * oShape = ThisComponent.DrawPage(0)
850 : * oPathPropVec = oShape.CustomShapeGeometry(1).Value
851 : * oSegments = oPathPropVec(1).Value
852 : * msgbox oSegments(1).Count ' was 0x2000 | 10, should be 10
853 : * msgbox oShape.Surround ' was 2, should be 1
854 : */
855 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
856 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
857 2 : uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xDraws->getByIndex(0), "CustomShapeGeometry");
858 2 : uno::Sequence<beans::PropertyValue> aPathProps;
859 4 : for (int i = 0; i < aProps.getLength(); ++i)
860 : {
861 3 : const beans::PropertyValue& rProp = aProps[i];
862 3 : if (rProp.Name == "Path")
863 1 : rProp.Value >>= aPathProps;
864 : }
865 2 : uno::Sequence<drawing::EnhancedCustomShapeSegment> aSegments;
866 3 : for (int i = 0; i < aPathProps.getLength(); ++i)
867 : {
868 2 : const beans::PropertyValue& rProp = aPathProps[i];
869 2 : if (rProp.Name == "Segments")
870 1 : rProp.Value >>= aSegments;
871 : }
872 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aSegments[1].Count);
873 2 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(xDraws->getByIndex(0), "Surround"));
874 1 : }
875 :
876 1 : void Test::testFdo52389()
877 : {
878 : // The last '!' character at the end of the document was lost
879 1 : CPPUNIT_ASSERT_EQUAL(6, getLength());
880 1 : }
881 :
882 2 : void Test::testFdo49655_62805()
883 : {
884 : /*
885 : * 49655 :
886 : * The problem was that the table was not imported due to the ' ' string in the middle of the table definition.
887 : *
888 : * xray ThisComponent.TextTables.Count 'was 0
889 : *
890 : * 62805 :
891 : * The problem was that the table was not imported due to the absence of \pard after \row.
892 : * The table was instead in a group (the '}' replace the \pard).
893 : */
894 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
895 4 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
896 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
897 2 : }
898 :
899 1 : void Test::testFdo52475()
900 : {
901 : // The problem was that \chcbpat0 resulted in no color, instead of COL_AUTO.
902 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 3), "CharBackColor"));
903 1 : }
904 :
905 1 : void Test::testFdo55493()
906 : {
907 : // The problem was that the width of the PNG was detected as 15,24cm, instead of 3.97cm
908 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
909 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
910 2 : uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
911 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3969), xShape->getSize().Width);
912 1 : }
913 :
914 1 : void Test::testCopyPastePageStyle()
915 : {
916 : // The problem was that RTF import during copy&paste did not ignore page styles.
917 : // Once we have more copy&paste tests, makes sense to refactor this to some helper method.
918 1 : paste("copypaste-pagestyle-paste.rtf");
919 :
920 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
921 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), getProperty<sal_Int32>(xPropertySet, "Width")); // Was letter, i.e. 21590
922 1 : }
923 :
924 1 : void Test::testCopyPasteFootnote()
925 : {
926 : // The RTF import did not handle the case when the position wasn't the main document XText, but something different, e.g. a footnote.
927 1 : uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
928 2 : uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
929 2 : uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
930 1 : paste("copypaste-footnote-paste.rtf", xTextRange);
931 :
932 2 : CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange->getString());
933 1 : }
934 :
935 1 : void Test::testFdo61193()
936 : {
937 : // Pasting content that contained a footnote caused a crash.
938 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
939 2 : uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
940 2 : uno::Reference<text::XTextRange> xEnd = xText->getEnd();
941 2 : paste("fdo61193.rtf", xEnd);
942 1 : }
943 :
944 1 : void Test::testShptxtPard()
945 : {
946 : // The problem was that \pard inside \shptxt caused loss of shape text
947 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
948 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
949 2 : uno::Reference<text::XText> xText(xDraws->getByIndex(0), uno::UNO_QUERY);
950 2 : CPPUNIT_ASSERT_EQUAL(OUString("shape text"), xText->getString());
951 1 : }
952 :
953 1 : void Test::testDoDhgt()
954 : {
955 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
956 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
957 4 : for (int i = 0; i < xDraws->getCount(); ++i)
958 : {
959 3 : sal_Int32 nFillColor = getProperty<sal_Int32>(xDraws->getByIndex(i), "FillColor");
960 3 : if (nFillColor == 0xc0504d) // red
961 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
962 2 : else if (nFillColor == 0x9bbb59) // green
963 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
964 1 : else if (nFillColor == 0x4f81bd) // blue
965 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
966 1 : }
967 1 : }
968 :
969 1 : void Test::testDplinehollow()
970 : {
971 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
972 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
973 2 : uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
974 2 : CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, getProperty<drawing::LineStyle>(xPropertySet, "LineStyle"));
975 1 : }
976 :
977 1 : void Test::testLeftmarginDefault()
978 : {
979 : // The default left/right margin was incorrect when the top margin was set to zero.
980 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2540), getProperty<sal_Int32>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "LeftMargin"));
981 1 : }
982 :
983 1 : void Test::testDppolyline()
984 : {
985 : // This was completely ignored, for now, just make sure we have all 4 lines.
986 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
987 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
988 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws->getCount());
989 1 : }
990 :
991 1 : void Test::testFdo56512()
992 : {
993 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
994 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
995 2 : uno::Reference<text::XTextRange> xTextRange(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
996 2 : OUString aExpected("עוסק מורשה ", 20, RTL_TEXTENCODING_UTF8);
997 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
998 1 : }
999 :
1000 1 : void Test::testFdo52989()
1001 : {
1002 : // Same as n#192129, but for JPEG files.
1003 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1004 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1005 2 : uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
1006 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(423), xShape->getSize().Width);
1007 1 : }
1008 :
1009 1 : void Test::testFdo48442()
1010 : {
1011 : // The problem was that \pvmrg is the default in RTF, but not in Writer.
1012 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1013 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1014 2 : uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
1015 2 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xShape, "VertOrientRelation")); // was FRAME
1016 1 : }
1017 :
1018 1 : void Test::testFdo55525()
1019 : {
1020 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1021 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1022 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1023 : // Negative left margin was ~missing, -191
1024 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty<sal_Int32>(xTable, "LeftMargin"));
1025 : // Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
1026 2 : uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
1027 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(896), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
1028 1 : }
1029 :
1030 1 : void Test::testFdo57708()
1031 : {
1032 : // There were two issues: the doc was of 2 pages and the picture was missing.
1033 1 : CPPUNIT_ASSERT_EQUAL(1, getPages());
1034 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1035 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1036 : // Two objects: a picture and a textframe.
1037 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
1038 1 : }
1039 :
1040 1 : void Test::testFdo54473()
1041 : {
1042 : // The problem was that character styles were not imported due to a typo.
1043 1 : CPPUNIT_ASSERT_EQUAL(OUString("Anot"), getProperty<OUString>(getRun(getParagraph(1), 1, "Text "), "CharStyleName"));
1044 1 : CPPUNIT_ASSERT_EQUAL(OUString("ForeignTxt"), getProperty<OUString>(getRun(getParagraph(1), 3, "character "), "CharStyleName"));
1045 1 : }
1046 :
1047 1 : void Test::testFdo49934()
1048 : {
1049 : // Column break without columns defined should be a page break, but it was just ignored.
1050 1 : CPPUNIT_ASSERT_EQUAL(2, getPages());
1051 1 : }
1052 :
1053 1 : void Test::testFdo57886()
1054 : {
1055 : // Was 'int from <?> to <?> <?>'.
1056 1 : CPPUNIT_ASSERT_EQUAL(OUString("int from {firstlower} to {firstupper} {firstbody}"), getFormula(getRun(getParagraph(1), 1)));
1057 1 : }
1058 :
1059 1 : void Test::testFdo58076()
1060 : {
1061 : // An additional section was created, so the default page style didn't have the custom margins.
1062 1 : uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
1063 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2251), getProperty<sal_Int32>(xStyle, "LeftMargin"));
1064 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1752), getProperty<sal_Int32>(xStyle, "RightMargin"));
1065 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty<sal_Int32>(xStyle, "TopMargin"));
1066 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty<sal_Int32>(xStyle, "BottomMargin"));
1067 1 : }
1068 :
1069 1 : void Test::testFdo57678()
1070 : {
1071 : // Paragraphs of the two tables were not converted to tables.
1072 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1073 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1074 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
1075 1 : }
1076 :
1077 1 : void Test::testFdo45183()
1078 : {
1079 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1080 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1081 : // Was text::WrapTextMode_PARALLEL, i.e. shpfblwtxt didn't send the shape below text.
1082 1 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(xDraws->getByIndex(0), "Surround"));
1083 :
1084 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1085 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1086 : // Was 247, resulting in a table having width almost zero and height of 10+ pages.
1087 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(16237), getProperty<sal_Int32>(xTables->getByIndex(0), "Width"));
1088 1 : }
1089 :
1090 1 : void Test::testFdo54612()
1091 : {
1092 : // \dpptx without a \dppolycount caused a crash.
1093 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1094 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1095 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws->getCount());
1096 1 : }
1097 :
1098 1 : void Test::testFdo58933()
1099 : {
1100 : // The problem was that the table had an additional cell in its first line.
1101 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1102 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1103 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1104 : // This was 4.
1105 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getCellNames().getLength());
1106 1 : }
1107 :
1108 1 : void Test::testFdo44053()
1109 : {
1110 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1111 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1112 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1113 2 : uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
1114 : // The with of the table's A1 and A2 cell should equal.
1115 2 : CPPUNIT_ASSERT_EQUAL(getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position,
1116 2 : getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position);
1117 1 : }
1118 :
1119 1 : void Test::testFdo48440()
1120 : {
1121 : // Page break was ignored.
1122 1 : CPPUNIT_ASSERT_EQUAL(2, getPages());
1123 1 : }
1124 :
1125 1 : void Test::testFdo58646line()
1126 : {
1127 : // \line symbol was ignored
1128 1 : getParagraph(1, "foo\nbar");
1129 1 : }
1130 :
1131 1 : void Test::testFdo58646()
1132 : {
1133 : // Page break was ignored inside a continous section, on title page.
1134 1 : CPPUNIT_ASSERT_EQUAL(2, getPages());
1135 1 : }
1136 :
1137 1 : void Test::testFdo59419()
1138 : {
1139 : // Junk to be ignored broke import of the table.
1140 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1141 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1142 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
1143 1 : }
1144 :
1145 1 : void Test::testFdo58076_2()
1146 : {
1147 : // Position of the picture wasn't correct.
1148 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1149 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1150 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(8345)), getProperty<sal_Int32>(xDraws->getByIndex(0), "HoriOrientPosition"));
1151 1 : }
1152 :
1153 1 : void Test::testFdo59953()
1154 : {
1155 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1156 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1157 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1158 : // Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width)
1159 2 : uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
1160 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(7649), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
1161 1 : }
1162 :
1163 1 : void Test::testFdo59638()
1164 : {
1165 : // The problem was that w:lvlOverride inside w:num was ignores by dmapper.
1166 :
1167 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
1168 1 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
1169 1 : uno::Sequence<beans::PropertyValue> aProps;
1170 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
1171 :
1172 14 : for (int i = 0; i < aProps.getLength(); ++i)
1173 : {
1174 14 : const beans::PropertyValue& rProp = aProps[i];
1175 :
1176 14 : if (rProp.Name == "BulletChar")
1177 : {
1178 : // Was '*', should be 'o'.
1179 1 : CPPUNIT_ASSERT_EQUAL(OUString("\xEF\x82\xB7", 3, RTL_TEXTENCODING_UTF8), rProp.Value.get<OUString>());
1180 2 : return;
1181 : }
1182 : }
1183 0 : CPPUNIT_FAIL("no BulletChar property");
1184 : }
1185 :
1186 1 : void Test::testFdo60722()
1187 : {
1188 : // The problem was that the larger shape was over the smaller one, and not the other way around.
1189 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1190 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1191 2 : uno::Reference<beans::XPropertySet> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
1192 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xShape, "ZOrder"));
1193 1 : CPPUNIT_ASSERT_EQUAL(OUString("larger"), getProperty<OUString>(xShape, "Description"));
1194 :
1195 1 : xShape.set(xDraws->getByIndex(1), uno::UNO_QUERY);
1196 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(xShape, "ZOrder"));
1197 1 : CPPUNIT_ASSERT_EQUAL(OUString("smaller"), getProperty<OUString>(xShape, "Description"));
1198 :
1199 : // Color of the line was blue, and it had zero width.
1200 1 : xShape.set(xDraws->getByIndex(2), uno::UNO_QUERY);
1201 1 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty<sal_uInt32>(xShape, "LineWidth"));
1202 2 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty<sal_uInt32>(xShape, "LineColor"));
1203 1 : }
1204 :
1205 1 : void Test::testFdo61909()
1206 : {
1207 1 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
1208 : // Was the Writer default font.
1209 1 : CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty<OUString>(xTextRange, "CharFontName"));
1210 : // Was 0x008000.
1211 1 : CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(xTextRange, "CharBackColor"));
1212 1 : }
1213 :
1214 1 : void Test::testFdo62288()
1215 : {
1216 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1217 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1218 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1219 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
1220 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
1221 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
1222 2 : uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
1223 : // Margins were inherited from the previous cell, even there was a \pard there.
1224 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaLeftMargin"));
1225 1 : }
1226 :
1227 1 : void Test::testFdo37716()
1228 : {
1229 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
1230 2 : uno::Reference<container::XIndexAccess> xFrames(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
1231 : // \nowrap got ignored, so Surround was text::WrapTextMode_PARALLEL
1232 2 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_NONE, getProperty<text::WrapTextMode>(xFrames->getByIndex(0), "Surround"));
1233 1 : }
1234 :
1235 1 : void Test::testFdo51916()
1236 : {
1237 : // Complex nested table caused a crash.
1238 1 : }
1239 :
1240 1 : void Test::testFdo63023()
1241 : {
1242 1 : uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText");
1243 : // Back color was black (0) in the header, due to missing color table in the substream.
1244 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF99), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xHeaderText), 1), "CharBackColor"));
1245 1 : }
1246 :
1247 1 : void Test::testFdo42109()
1248 : {
1249 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1250 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1251 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1252 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
1253 : // Make sure the page number is imported as a field in the B1 cell.
1254 2 : CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 1), "TextPortionType"));
1255 1 : }
1256 :
1257 1 : void Test::testFdo62977()
1258 : {
1259 : // The middle character was imported as '?' instead of the proper unicode value.
1260 1 : getRun(getParagraph(1), 1, OUString("\xE5\xB9\xB4\xEF\xBC\x94\xE6\x9C\x88", 9, RTL_TEXTENCODING_UTF8));
1261 1 : }
1262 :
1263 1 : void Test::testN818997()
1264 : {
1265 : // \page was ignored between two \shp tokens.
1266 1 : CPPUNIT_ASSERT_EQUAL(2, getPages());
1267 1 : }
1268 :
1269 1 : void Test::testFdo64671()
1270 : {
1271 : // Additional '}' was inserted before the special character.
1272 1 : getRun(getParagraph(1), 1, OUString("\xC5\xBD", 2, RTL_TEXTENCODING_UTF8));
1273 1 : }
1274 :
1275 1 : void Test::testPageBackground()
1276 : {
1277 : // The problem was that \background was ignored.
1278 1 : uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
1279 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
1280 1 : }
1281 :
1282 1 : void Test::testFdo62044()
1283 : {
1284 : // The problem was that RTF import during copy&paste did not ignore existing paragraph styles.
1285 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
1286 2 : uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
1287 2 : uno::Reference<text::XTextRange> xEnd = xText->getEnd();
1288 1 : paste("fdo62044-paste.rtf", xEnd);
1289 :
1290 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
1291 2 : CPPUNIT_ASSERT_EQUAL(10.f, getProperty<float>(xPropertySet, "CharHeight")); // Was 18, i.e. reset back to original value.
1292 1 : }
1293 :
1294 1 : void Test::testPoshPosv()
1295 : {
1296 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1297 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1298 1 : CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(xDraws->getByIndex(0), "HoriOrient"));
1299 1 : CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty<sal_Int16>(xDraws->getByIndex(0), "VertOrient"));
1300 2 : CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xDraws->getByIndex(0), "FrameIsAutomaticHeight"));
1301 1 : }
1302 :
1303 1 : void Test::testN825305()
1304 : {
1305 : // The problem was that the textbox wasn't transparent, due to unimplemented fFilled == 0.
1306 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1307 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1308 2 : uno::Reference<beans::XPropertyState> xPropertyState(xDraws->getByIndex(1), uno::UNO_QUERY);
1309 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xDraws->getByIndex(1), "BackColorTransparency"));
1310 1 : beans::PropertyState ePropertyState = xPropertyState->getPropertyState("BackColorTransparency");
1311 : // Was beans::PropertyState_DEFAULT_VALUE.
1312 2 : CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState);
1313 1 : }
1314 :
1315 1 : void Test::testParaBottomMargin()
1316 : {
1317 : // This was 353, i.e. bottom margin of the paragraph was 0.35cm instead of 0.
1318 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
1319 1 : }
1320 :
1321 1 : void Test::testN823655()
1322 : {
1323 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1324 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1325 2 : uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xDraws->getByIndex(0), "CustomShapeGeometry");
1326 2 : uno::Sequence<beans::PropertyValue> aPathProps;
1327 4 : for (int i = 0; i < aProps.getLength(); ++i)
1328 : {
1329 3 : const beans::PropertyValue& rProp = aProps[i];
1330 3 : if (rProp.Name == "Path")
1331 1 : aPathProps = rProp.Value.get< uno::Sequence<beans::PropertyValue> >();
1332 : }
1333 2 : uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aCoordinates;
1334 3 : for (int i = 0; i < aPathProps.getLength(); ++i)
1335 : {
1336 2 : const beans::PropertyValue& rProp = aPathProps[i];
1337 2 : if (rProp.Name == "Coordinates")
1338 1 : aCoordinates = rProp.Value.get< uno::Sequence<drawing::EnhancedCustomShapeParameterPair> >();
1339 : }
1340 : // The first coordinate pair of this freeform shape was 286,0 instead of 0,286.
1341 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates[0].Second.Value.get<sal_Int32>());
1342 1 : }
1343 :
1344 1 : void Test::testFdo66040()
1345 : {
1346 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1347 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1348 : // This was 0 (no shapes were imported), we want two textframes.
1349 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
1350 :
1351 : // The second paragraph of the first shape should be actually a table, with "A" in its A1 cell.
1352 2 : uno::Reference<text::XTextRange> xTextRange(xDraws->getByIndex(0), uno::UNO_QUERY);
1353 2 : uno::Reference<text::XText> xText = xTextRange->getText();
1354 2 : uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
1355 1 : CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString());
1356 :
1357 : // Make sure the second shape has the correct position and size.
1358 2 : uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(1), uno::UNO_QUERY);
1359 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(14420), getProperty<sal_Int32>(xShape, "HoriOrientPosition"));
1360 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1032), getProperty<sal_Int32>(xShape, "VertOrientPosition"));
1361 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(14000), xShape->getSize().Width);
1362 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), xShape->getSize().Height);
1363 1 : }
1364 :
1365 1 : void Test::testN823675()
1366 : {
1367 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
1368 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
1369 2 : uno::Sequence<beans::PropertyValue> aProps;
1370 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
1371 2 : awt::FontDescriptor aFont;
1372 :
1373 17 : for (int i = 0; i < aProps.getLength(); ++i)
1374 : {
1375 16 : const beans::PropertyValue& rProp = aProps[i];
1376 :
1377 16 : if (rProp.Name == "BulletFont")
1378 1 : aFont = rProp.Value.get<awt::FontDescriptor>();
1379 : }
1380 : // This was empty, i.e. no font name was set for the bullet numbering.
1381 2 : CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), aFont.Name);
1382 1 : }
1383 :
1384 1 : void Test::testFdo47802()
1385 : {
1386 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1387 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1388 : // Shape inside table was ignored.
1389 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
1390 1 : }
1391 :
1392 1 : void Test::testFdo39001()
1393 : {
1394 : // Document was of 4 pages, \sect at the end of the doc wasn't ignored.
1395 1 : CPPUNIT_ASSERT_EQUAL(3, getPages());
1396 1 : }
1397 :
1398 1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
1399 :
1400 4 : CPPUNIT_PLUGIN_IMPLEMENT();
1401 :
1402 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|