2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
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/FillStyle.hpp>
15 #include <com/sun/star/drawing/LineStyle.hpp>
16 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
17 #include <com/sun/star/graphic/GraphicType.hpp>
18 #include <com/sun/star/lang/XServiceInfo.hpp>
19 #include <com/sun/star/style/CaseMap.hpp>
20 #include <com/sun/star/style/LineSpacing.hpp>
21 #include <com/sun/star/style/LineSpacingMode.hpp>
22 #include <com/sun/star/style/ParagraphAdjust.hpp>
23 #include <com/sun/star/table/BorderLine2.hpp>
24 #include <com/sun/star/table/BorderLineStyle.hpp>
25 #include <com/sun/star/text/RelOrientation.hpp>
26 #include <com/sun/star/text/SizeType.hpp>
27 #include <com/sun/star/text/TableColumnSeparator.hpp>
28 #include <com/sun/star/text/TextContentAnchorType.hpp>
29 #include <com/sun/star/text/XFootnotesSupplier.hpp>
30 #include <com/sun/star/text/XPageCursor.hpp>
31 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
32 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
33 #include <com/sun/star/text/XTextFramesSupplier.hpp>
34 #include <com/sun/star/text/XTextRangeCompare.hpp>
35 #include <com/sun/star/text/XTextTablesSupplier.hpp>
36 #include <com/sun/star/text/XTextTable.hpp>
37 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
38 #include <com/sun/star/text/WrapTextMode.hpp>
39 #include <com/sun/star/text/HoriOrientation.hpp>
40 #include <com/sun/star/text/VertOrientation.hpp>
41 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
43 #include <rtl/ustring.hxx>
44 #include <vcl/outdev.hxx>
45 #include <vcl/svapp.hxx>
46 #include <unotools/ucbstreamhelper.hxx>
47 #include <unotools/streamwrap.hxx>
49 #include <swmodeltestbase.hxx>
50 #include <bordertest.hxx>
52 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
54 class Test
: public SwModelTestBase
95 void testFdo48033_53594();
100 void testAllGapsWord();
104 void testFdo49655_62805();
107 void testCopyPastePageStyle();
108 void testCopyPasteFootnote();
109 void testShptxtPard();
111 void testDplinehollow();
112 void testLeftmarginDefault();
113 void testDppolyline();
129 void testFdo58646line();
132 void testFdo58076_2();
148 void testParaBottomMargin();
167 void testCp1000018();
168 void testNestedTable();
170 CPPUNIT_TEST_SUITE(Test
);
171 #if !defined(MACOSX) && !defined(WNT)
174 CPPUNIT_TEST_SUITE_END();
178 /// Copy&paste helper.
179 void paste(OUString aFilename
, uno::Reference
<text::XTextRange
> xTextRange
= uno::Reference
<text::XTextRange
>())
181 uno::Reference
<document::XFilter
> xFilter(m_xSFactory
->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW
);
182 uno::Reference
<document::XImporter
> xImporter(xFilter
, uno::UNO_QUERY_THROW
);
183 xImporter
->setTargetDocument(mxComponent
);
184 uno::Sequence
<beans::PropertyValue
> aDescriptor(xTextRange
.is() ? 3 : 2);
185 aDescriptor
[0].Name
= "InputStream";
186 SvStream
* pStream
= utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + aFilename
, STREAM_WRITE
);
187 uno::Reference
<io::XStream
> xStream(new utl::OStreamWrapper(*pStream
));
188 aDescriptor
[0].Value
<<= xStream
;
189 aDescriptor
[1].Name
= "IsNewDoc";
190 aDescriptor
[1].Value
<<= sal_False
;
193 aDescriptor
[2].Name
= "TextInsertModeRange";
194 aDescriptor
[2].Value
<<= xTextRange
;
196 xFilter
->filter(aDescriptor
);
203 MethodEntry
<Test
> aMethods
[] = {
204 {"fdo45553.rtf", &Test::testFdo45553
},
205 {"n192129.rtf", &Test::testN192129
},
206 {"fdo45543.rtf", &Test::testFdo45543
},
207 {"n695479.rtf", &Test::testN695479
},
208 {"fdo42465.rtf", &Test::testFdo42465
},
209 {"fdo45187.rtf", &Test::testFdo45187
},
210 {"fdo46662.rtf", &Test::testFdo46662
},
211 {"n750757.rtf", &Test::testN750757
},
212 {"fdo45563.rtf", &Test::testFdo45563
},
213 {"fdo43965.rtf", &Test::testFdo43965
},
214 {"n751020.rtf", &Test::testN751020
},
215 {"fdo47326.rtf", &Test::testFdo47326
},
216 {"fdo47036.rtf", &Test::testFdo47036
},
217 {"fdo46955.rtf", &Test::testFdo46955
},
218 {"fdo45394.rtf", &Test::testFdo45394
},
219 {"fdo48104.rtf", &Test::testFdo48104
},
220 {"fdo47107.rtf", &Test::testFdo47107
},
221 {"fdo45182.rtf", &Test::testFdo45182
},
222 {"fdo44176.rtf", &Test::testFdo44176
},
223 {"fdo39053.rtf", &Test::testFdo39053
},
224 {"fdo48356.rtf", &Test::testFdo48356
},
225 {"fdo48023.rtf", &Test::testFdo48023
},
226 {"fdo48876.rtf", &Test::testFdo48876
},
227 {"fdo48193.rtf", &Test::testFdo48193
},
228 {"fdo44211.rtf", &Test::testFdo44211
},
229 {"fdo48037.rtf", &Test::testFdo48037
},
230 {"fdo47764.rtf", &Test::testFdo47764
},
231 {"fdo38786.rtf", &Test::testFdo38786
},
232 {"n757651.rtf", &Test::testN757651
},
233 {"fdo49501.rtf", &Test::testFdo49501
},
234 {"fdo49271.rtf", &Test::testFdo49271
},
235 {"fdo49692.rtf", &Test::testFdo49692
},
236 {"fdo45190.rtf", &Test::testFdo45190
},
237 {"fdo50539.rtf", &Test::testFdo50539
},
238 {"fdo50665.rtf", &Test::testFdo50665
},
239 {"fdo49659.rtf", &Test::testFdo49659
},
240 {"fdo46966.rtf", &Test::testFdo46966
},
241 {"fdo52066.rtf", &Test::testFdo52066
},
242 {"fdo48033.rtf", &Test::testFdo48033_53594
},
243 {"fdo53594.rtf", &Test::testFdo48033_53594
},
244 {"fdo36089.rtf", &Test::testFdo36089
},
245 {"fdo49892.rtf", &Test::testFdo49892
},
246 {"fdo48446.rtf", &Test::testFdo48446
},
247 {"fdo47495.rtf", &Test::testFdo47495
},
248 {"all_gaps_word.rtf", &Test::testAllGapsWord
},
249 {"fdo52052.rtf", &Test::testFdo52052
},
250 {"ink.rtf", &Test::testInk
},
251 {"fdo52389.rtf", &Test::testFdo52389
},
252 {"fdo49655.rtf", &Test::testFdo49655_62805
},
253 {"fdo62805.rtf", &Test::testFdo49655_62805
},
254 {"fdo52475.rtf", &Test::testFdo52475
},
255 {"fdo55493.rtf", &Test::testFdo55493
},
256 {"copypaste-pagestyle.rtf", &Test::testCopyPastePageStyle
},
257 {"copypaste-footnote.rtf", &Test::testCopyPasteFootnote
},
258 {"shptxt-pard.rtf", &Test::testShptxtPard
},
259 {"do-dhgt.rtf", &Test::testDoDhgt
},
260 {"dplinehollow.rtf", &Test::testDplinehollow
},
261 {"leftmargin-default.rtf", &Test::testLeftmarginDefault
},
262 {"dppolyline.rtf", &Test::testDppolyline
},
263 {"fdo56512.rtf", &Test::testFdo56512
},
264 {"fdo52989.rtf", &Test::testFdo52989
},
265 {"fdo48442.rtf", &Test::testFdo48442
},
266 {"fdo55525.rtf", &Test::testFdo55525
},
267 {"fdo57708.rtf", &Test::testFdo57708
},
268 {"fdo54473.rtf", &Test::testFdo54473
},
269 {"fdo49934.rtf", &Test::testFdo49934
},
270 {"fdo57886.rtf", &Test::testFdo57886
},
271 {"fdo58076.rtf", &Test::testFdo58076
},
272 {"fdo57678.rtf", &Test::testFdo57678
},
273 {"fdo45183.rtf", &Test::testFdo45183
},
274 {"fdo54612.rtf", &Test::testFdo54612
},
275 {"fdo58933.rtf", &Test::testFdo58933
},
276 {"fdo44053.rtf", &Test::testFdo44053
},
277 {"fdo48440.rtf", &Test::testFdo48440
},
278 {"fdo58646line.rtf", &Test::testFdo58646line
},
279 {"fdo58646.rtf", &Test::testFdo58646
},
280 {"fdo59419.rtf", &Test::testFdo59419
},
281 {"fdo58076-2.rtf", &Test::testFdo58076_2
},
282 {"fdo59953.rtf", &Test::testFdo59953
},
283 {"fdo59638.rtf", &Test::testFdo59638
},
284 {"fdo60722.rtf", &Test::testFdo60722
},
285 {"fdo61909.rtf", &Test::testFdo61909
},
286 {"fdo62288.rtf", &Test::testFdo62288
},
287 {"fdo37716.rtf", &Test::testFdo37716
},
288 {"fdo51916.rtf", &Test::testFdo51916
},
289 {"hello.rtf", &Test::testFdo61193
},
290 {"fdo63023.rtf", &Test::testFdo63023
},
291 {"fdo42109.rtf", &Test::testFdo42109
},
292 {"fdo62977.rtf", &Test::testFdo62977
},
293 {"n818997.rtf", &Test::testN818997
},
294 {"fdo64671.rtf", &Test::testFdo64671
},
295 {"fdo62044.rtf", &Test::testFdo62044
},
296 {"n825305.rtf", &Test::testN825305
},
297 {"para-bottom-margin.rtf", &Test::testParaBottomMargin
},
298 {"n823655.rtf", &Test::testN823655
},
299 {"fdo39001.rtf", &Test::testFdo39001
},
300 {"fdo66565.rtf", &Test::testFdo66565
},
301 {"fdo54900.rtf", &Test::testFdo54900
},
302 {"fdo64637.rtf", &Test::testFdo64637
},
303 {"fdo67365.rtf", &Test::testFdo67365
},
304 {"fdo67498.rtf", &Test::testFdo67498
},
305 {"fdo47440.rtf", &Test::testFdo47440
},
306 {"posh-posv.rtf", &Test::testPoshPosv
},
307 {"fdo53556.rtf", &Test::testFdo53556
},
308 {"hello.rtf", &Test::testFdo63428
},
309 {"fdo44715.rtf", &Test::testFdo44715
},
310 {"fdo68076.rtf", &Test::testFdo68076
},
311 {"fdo68291.odt", &Test::testFdo68291
},
312 {"hello.rtf", &Test::testFdo69384
},
313 {"fdo70221.rtf", &Test::testFdo70221
},
314 {"fdo65090.rtf", &Test::testFdo65090
},
315 {"n823675.rtf", &Test::testN823675
},
316 {"cp1000018.rtf", &Test::testCp1000018
},
317 {"rhbz1065629.rtf", &Test::testNestedTable
},
320 for (unsigned int i
= 0; i
< SAL_N_ELEMENTS(aMethods
); ++i
)
322 MethodEntry
<Test
>& rEntry
= aMethods
[i
];
323 AllSettings
aSavedSettings(Application::GetSettings());
324 if (OString(rEntry
.pName
) == "fdo48023.rtf")
326 AllSettings
aSettings(aSavedSettings
);
327 aSettings
.SetLanguageTag(LanguageTag("ru"));
328 Application::SetSettings(aSettings
);
330 else if (OString(rEntry
.pName
) == "fdo44211.rtf")
332 AllSettings
aSettings(aSavedSettings
);
333 aSettings
.SetLanguageTag(LanguageTag("lt"));
334 Application::SetSettings(aSettings
);
336 load("/sw/qa/extras/rtfimport/data/", rEntry
.pName
);
337 if (OString(rEntry
.pName
) == "fdo48023.rtf" || OString(rEntry
.pName
) == "fdo44211.rtf")
338 Application::SetSettings(aSavedSettings
);
339 (this->*rEntry
.pMethod
)();
344 void Test::testFdo45553()
346 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
347 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
348 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
349 while (xParaEnum
->hasMoreElements())
351 uno::Reference
<container::XEnumerationAccess
> xRangeEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
352 uno::Reference
<container::XEnumeration
> xRangeEnum
= xRangeEnumAccess
->createEnumeration();
353 while (xRangeEnum
->hasMoreElements())
355 uno::Reference
<text::XTextRange
> xRange(xRangeEnum
->nextElement(), uno::UNO_QUERY
);
356 OUString aStr
= xRange
->getString();
357 if ( aStr
== "space-before" )
358 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(120)), getProperty
<sal_Int32
>(xRange
, "ParaTopMargin"));
359 else if ( aStr
== "space-after" )
360 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(240)), getProperty
<sal_Int32
>(xRange
, "ParaBottomMargin"));
365 void Test::testN192129()
367 // We expect that the result will be 16x16px.
368 Size
aExpectedSize(16, 16);
369 MapMode
aMap(MAP_100TH_MM
);
370 aExpectedSize
= Application::GetDefaultDevice()->PixelToLogic( aExpectedSize
, aMap
);
372 uno::Reference
<text::XTextGraphicObjectsSupplier
> xTextGraphicObjectsSupplier(mxComponent
, uno::UNO_QUERY
);
373 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextGraphicObjectsSupplier
->getGraphicObjects(), uno::UNO_QUERY
);
374 uno::Reference
<drawing::XShape
> xShape(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
375 awt::Size
aActualSize(xShape
->getSize());
377 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Width()), aActualSize
.Width
);
378 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Height()), aActualSize
.Height
);
381 void Test::testFdo45543()
383 CPPUNIT_ASSERT_EQUAL(5, getLength());
386 void Test::testN695479()
388 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
389 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
390 uno::Reference
<beans::XPropertySet
> xPropertySet(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
392 // Negative ABSH should mean fixed size.
393 CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX
, getProperty
<sal_Int16
>(xPropertySet
, "SizeType"));
394 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(300)), getProperty
<sal_Int32
>(xPropertySet
, "Height"));
396 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
397 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
398 bool bFrameFound
= false, bDrawFound
= false;
399 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
401 uno::Reference
<lang::XServiceInfo
> xServiceInfo(xDraws
->getByIndex(i
), uno::UNO_QUERY
);
402 if (xServiceInfo
->supportsService("com.sun.star.text.TextFrame"))
404 // Both frames should be anchored to the first paragraph.
406 uno::Reference
<text::XTextContent
> xTextContent(xServiceInfo
, uno::UNO_QUERY
);
407 uno::Reference
<text::XTextRange
> xRange(xTextContent
->getAnchor(), uno::UNO_QUERY
);
408 uno::Reference
<text::XText
> xText(xRange
->getText(), uno::UNO_QUERY
);
409 CPPUNIT_ASSERT_EQUAL(OUString("plain"), xText
->getString());
412 // Additonally, the frist frame should have double border at the bottom.
413 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::DOUBLE
, getProperty
<table::BorderLine2
>(xPropertySet
, "BottomBorder").LineStyle
);
415 else if (xServiceInfo
->supportsService("com.sun.star.drawing.LineShape"))
417 // The older "drawing objects" syntax should be recognized.
419 xPropertySet
.set(xServiceInfo
, uno::UNO_QUERY
);
420 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
, getProperty
<sal_Int16
>(xPropertySet
, "HoriOrientRelation"));
421 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xPropertySet
, "VertOrientRelation"));
424 CPPUNIT_ASSERT(bFrameFound
);
425 CPPUNIT_ASSERT(bDrawFound
);
428 void Test::testFdo42465()
430 CPPUNIT_ASSERT_EQUAL(3, getLength());
433 void Test::testFdo45187()
435 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
436 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
437 // There should be two shapes.
438 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws
->getCount());
440 // They should be anchored to different paragraphs.
441 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
442 uno::Reference
<text::XTextRangeCompare
> xTextRangeCompare(xTextDocument
->getText(), uno::UNO_QUERY
);
443 uno::Reference
<text::XTextRange
> xAnchor0
= uno::Reference
<text::XTextContent
>(xDraws
->getByIndex(0), uno::UNO_QUERY
)->getAnchor();
444 uno::Reference
<text::XTextRange
> xAnchor1
= uno::Reference
<text::XTextContent
>(xDraws
->getByIndex(1), uno::UNO_QUERY
)->getAnchor();
445 // Was 0 ("starts at the same position"), should be 1 ("starts before")
446 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xTextRangeCompare
->compareRegionStarts(xAnchor0
, xAnchor1
));
449 void Test::testFdo46662()
451 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY
);
452 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
453 uno::Sequence
<beans::PropertyValue
> aProps
;
454 xLevels
->getByIndex(1) >>= aProps
; // 2nd level
456 for (int i
= 0; i
< aProps
.getLength(); ++i
)
458 const beans::PropertyValue
& rProp
= aProps
[i
];
460 if ( rProp
.Name
== "ParentNumbering" )
461 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), rProp
.Value
.get
<sal_Int16
>());
462 else if ( rProp
.Name
== "Suffix" )
463 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp
.Value
.get
<OUString
>().getLength());
467 void Test::testN750757()
469 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
470 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
471 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
473 CPPUNIT_ASSERT_EQUAL(sal_Bool(false), getProperty
<sal_Bool
>(xParaEnum
->nextElement(), "ParaContextMargin"));
474 CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty
<sal_Bool
>(xParaEnum
->nextElement(), "ParaContextMargin"));
477 void Test::testFdo45563()
479 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
480 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
481 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
483 while (xParaEnum
->hasMoreElements())
485 xParaEnum
->nextElement();
488 CPPUNIT_ASSERT_EQUAL(4, i
);
491 void Test::testFdo43965()
493 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
494 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
495 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
497 // First paragraph: the parameter of \up was ignored
498 uno::Reference
<container::XEnumerationAccess
> xRangeEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
499 uno::Reference
<container::XEnumeration
> xRangeEnum
= xRangeEnumAccess
->createEnumeration();
500 uno::Reference
<beans::XPropertySet
> xPropertySet(xRangeEnum
->nextElement(), uno::UNO_QUERY
);
501 CPPUNIT_ASSERT_EQUAL(sal_Int32(36), getProperty
<sal_Int32
>(xPropertySet
, "CharEscapement"));
502 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(xPropertySet
, "CharEscapementHeight"));
504 // Second paragraph: Word vs Writer border default problem
505 CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty
<table::BorderLine2
>(xParaEnum
->nextElement(), "TopBorder").LineWidth
);
507 // Finally, make sure that we have two pages
508 CPPUNIT_ASSERT_EQUAL(2, getPages());
511 void Test::testN751020()
513 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
514 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
515 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
516 CPPUNIT_ASSERT(xParaEnum
->hasMoreElements());
517 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(200)), getProperty
<sal_Int32
>(xParaEnum
->nextElement(), "ParaBottomMargin"));
520 void Test::testFdo47326()
522 // This was 15 only, as \super buffered text, then the contents of it got lost.
523 CPPUNIT_ASSERT_EQUAL(19, getLength());
526 void Test::testFdo47036()
528 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
529 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
530 int nAtCharacter
= 0;
531 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
533 if (getProperty
<text::TextContentAnchorType
>(xDraws
->getByIndex(i
), "AnchorType") == text::TextContentAnchorType_AT_CHARACTER
)
536 // The image at the document start was ignored.
537 CPPUNIT_ASSERT_EQUAL(1, nAtCharacter
);
539 // There should be 2 textboxes, not 4
540 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
541 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
542 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
545 void Test::testFdo46955()
547 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
548 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
549 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
550 while (xParaEnum
->hasMoreElements())
552 uno::Reference
<container::XEnumerationAccess
> xRangeEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
553 uno::Reference
<container::XEnumeration
> xRangeEnum
= xRangeEnumAccess
->createEnumeration();
554 while (xRangeEnum
->hasMoreElements())
555 CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE
, getProperty
<sal_Int16
>(xRangeEnum
->nextElement(), "CharCaseMap"));
559 void Test::testFdo45394()
561 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "HeaderText");
562 OUString aActual
= xHeaderText
->getString();
563 // Encoding in the header was wrong.
564 OUString
aExpected("ПК РИК", 11, RTL_TEXTENCODING_UTF8
);
565 CPPUNIT_ASSERT_EQUAL(aExpected
, aActual
);
567 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
568 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
569 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess
->getCount());
572 void Test::testFdo48104()
574 CPPUNIT_ASSERT_EQUAL(2, getPages());
577 void Test::testFdo47107()
579 uno::Reference
<container::XNameAccess
> xNumberingStyles(getStyles("NumberingStyles"));
580 // Make sure numbered and bullet legacy syntax is recognized, this used to throw a NoSuchElementException
581 xNumberingStyles
->getByName("WWNum1");
582 xNumberingStyles
->getByName("WWNum2");
585 void Test::testFdo45182()
587 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
588 uno::Reference
<container::XIndexAccess
> xFootnotes(xFootnotesSupplier
->getFootnotes(), uno::UNO_QUERY
);
589 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
590 // Encoding in the footnote was wrong.
591 OUString
aExpected("živností\n", 11, RTL_TEXTENCODING_UTF8
);
592 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
595 void Test::testFdo44176()
597 uno::Reference
<container::XNameAccess
> xPageStyles(getStyles("PageStyles"));
598 uno::Reference
<beans::XPropertySet
> xFirstPage(xPageStyles
->getByName("First Page"), uno::UNO_QUERY
);
599 uno::Reference
<beans::XPropertySet
> xDefault(xPageStyles
->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
600 sal_Int32 nFirstTop
= 0, nDefaultTop
= 0, nDefaultHeader
= 0;
601 xFirstPage
->getPropertyValue("TopMargin") >>= nFirstTop
;
602 xDefault
->getPropertyValue("TopMargin") >>= nDefaultTop
;
603 xDefault
->getPropertyValue("HeaderHeight") >>= nDefaultHeader
;
604 CPPUNIT_ASSERT_EQUAL(nFirstTop
, nDefaultTop
+ nDefaultHeader
);
607 void Test::testFdo39053()
609 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
610 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
611 int nAsCharacter
= 0;
612 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
613 if (getProperty
<text::TextContentAnchorType
>(xDraws
->getByIndex(i
), "AnchorType") == text::TextContentAnchorType_AS_CHARACTER
)
615 // The image in binary format was ignored.
616 CPPUNIT_ASSERT_EQUAL(1, nAsCharacter
);
619 void Test::testFdo48356()
621 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
622 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
623 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
625 while (xParaEnum
->hasMoreElements())
627 xParaEnum
->nextElement();
630 // The document used to be imported as two paragraphs.
631 CPPUNIT_ASSERT_EQUAL(1, i
);
634 void Test::testFdo48023()
636 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
638 // Implicit encoding detection based on locale was missing
639 OUString
aExpected("Программист", 22, RTL_TEXTENCODING_UTF8
);
640 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
643 void Test::testFdo48876()
645 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
646 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
647 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
648 CPPUNIT_ASSERT(xParaEnum
->hasMoreElements());
649 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::MINIMUM
, getProperty
<style::LineSpacing
>(xParaEnum
->nextElement(), "ParaLineSpacing").Mode
);
652 void Test::testFdo48193()
654 CPPUNIT_ASSERT_EQUAL(7, getLength());
657 void Test::testFdo44211()
659 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
661 OUString
aExpected("ąčę", 6, RTL_TEXTENCODING_UTF8
);
662 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
665 void Test::testFdo48037()
667 uno::Reference
<util::XNumberFormatsSupplier
> xNumberSupplier(mxComponent
, uno::UNO_QUERY_THROW
);
668 lang::Locale aUSLocale
, aFRLocale
;
669 aUSLocale
.Language
= "en";
670 aFRLocale
.Language
= "fr";
671 sal_Int32 nExpected
= xNumberSupplier
->getNumberFormats()->addNewConverted("d MMMM yyyy", aUSLocale
, aFRLocale
);
673 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
674 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
675 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
676 uno::Reference
<beans::XPropertySet
> xPropertySet(xFields
->nextElement(), uno::UNO_QUERY
);
677 sal_Int32 nActual
= 0;
678 xPropertySet
->getPropertyValue("NumberFormat") >>= nActual
;
680 CPPUNIT_ASSERT_EQUAL(nExpected
, nActual
);
683 void Test::testFdo47764()
685 // \cbpat with zero argument should mean the auto (-1) color, not a default color (black)
686 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(getParagraph(1), "ParaBackColor"));
689 void Test::testFdo38786()
691 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
692 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
693 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
694 // \chpgn was ignored, so exception was thrown
695 xFields
->nextElement();
698 void Test::testN757651()
700 // The bug was that due to buggy layout the text expanded to two pages.
701 if (Application::GetDefaultDevice()->IsFontAvailable(OUString("Times New Roman")))
702 CPPUNIT_ASSERT_EQUAL(1, getPages());
705 void Test::testFdo49501()
707 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
709 CPPUNIT_ASSERT_EQUAL(sal_True
, getProperty
<sal_Bool
>(xStyle
, "IsLandscape"));
710 sal_Int32
nExpected(TWIP_TO_MM100(567));
711 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "LeftMargin"));
712 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "RightMargin"));
713 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "TopMargin"));
714 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "BottomMargin"));
717 void Test::testFdo49271()
719 CPPUNIT_ASSERT_EQUAL(25.f
, getProperty
<float>(getParagraph(2), "CharHeight"));
722 void Test::testFdo49692()
724 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
725 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
726 uno::Sequence
<beans::PropertyValue
> aProps
;
727 xLevels
->getByIndex(0) >>= aProps
; // 1st level
729 for (int i
= 0; i
< aProps
.getLength(); ++i
)
731 const beans::PropertyValue
& rProp
= aProps
[i
];
733 if (rProp
.Name
== "Suffix")
734 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp
.Value
.get
<OUString
>().getLength());
738 void Test::testFdo45190()
740 // inherited \fi should be reset
741 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(getParagraph(1), "ParaFirstLineIndent"));
743 // but direct one not
744 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(-100)), getProperty
<sal_Int32
>(getParagraph(2), "ParaFirstLineIndent"));
747 void Test::testFdo50539()
749 // \chcbpat with zero argument should mean the auto (-1) color, not a default color (black)
750 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(getRun(getParagraph(1), 1), "CharBackColor"));
753 void Test::testFdo50665()
755 // Access the second run, which is a textfield
756 uno::Reference
<beans::XPropertySet
> xRun(getRun(getParagraph(1), 2), uno::UNO_QUERY
);
757 // This used to be the default, as character properties were ignored.
758 CPPUNIT_ASSERT_EQUAL(OUString("Book Antiqua"), getProperty
<OUString
>(xRun
, "CharFontName"));
761 void Test::testFdo49659()
763 // Both tables were ignored: 1) was in the header, 2) was ignored due to missing empty par at the end of the doc
764 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
765 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
766 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
768 // The graphic was also empty
769 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
770 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
771 uno::Reference
<beans::XPropertySet
> xGraphic(getProperty
< uno::Reference
<beans::XPropertySet
> >(xDraws
->getByIndex(0), "Graphic"), uno::UNO_QUERY
);
772 CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL
, getProperty
<sal_Int8
>(xGraphic
, "GraphicType"));
775 void Test::testFdo46966()
778 * The problem was the top margin was 1440 (1 inch), but it should be 720 (0.5 inch).
780 * xray ThisComponent.StyleFamilies.PageStyles.Default.TopMargin
782 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
783 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(720)), getProperty
<sal_Int32
>(xPropertySet
, "TopMargin"));
786 void Test::testFdo52066()
789 * The problem was that the height of the shape was too big.
791 * xray ThisComponent.DrawPage(0).Size.Height
793 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
794 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
795 uno::Reference
<drawing::XShape
> xShape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
796 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(19)), xShape
->getSize().Height
);
799 void Test::testFdo48033_53594()
802 * The problem was that the picture (48033) or OLE object (53594) was in the first cell,
803 * instead of the second one.
805 * oTable = ThisComponent.TextTables(0)
806 * oParas = oTable.getCellByName("B1").Text.createEnumeration
807 * oPara = oParas.nextElement
808 * oRuns = oPara.createEnumeration
809 * oRun = oRuns.nextElement
810 * xray oRun.TextPortionType ' Frame, was Text
812 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
813 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
814 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
815 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
816 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
817 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
818 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
819 CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty
<OUString
>(getRun(xPara
, 1), "TextPortionType"));
822 void Test::testFdo36089()
824 CPPUNIT_ASSERT_EQUAL(sal_Int16(-50), getProperty
<sal_Int16
>(getRun(getParagraph(1), 2), "CharEscapement"));
827 void Test::testFdo49892()
829 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
830 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
831 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
833 OUString aDescription
= getProperty
<OUString
>(xDraws
->getByIndex(i
), "Description");
834 if (aDescription
== "red")
835 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
836 else if (aDescription
== "green")
837 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
838 else if (aDescription
== "blue")
839 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
840 else if (aDescription
== "rect")
842 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xDraws
->getByIndex(i
), "HoriOrientRelation"));
843 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xDraws
->getByIndex(i
), "VertOrientRelation"));
848 void Test::testFdo48446()
850 OUString
aExpected("Имя", 6, RTL_TEXTENCODING_UTF8
);
851 getParagraph(1, aExpected
);
854 void Test::testFdo47495()
856 // Used to have 4 paragraphs, as a result the original bugdoc had 2 pages instead of 1.
857 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
860 void Test::testAllGapsWord()
862 BorderTest borderTest
;
863 borderTest
.testTheBorders(mxComponent
);
866 void Test::testFdo52052()
868 // Make sure the textframe containing the text "third" appears on the 3rd page.
869 CPPUNIT_ASSERT_EQUAL(OUString("third"), parseDump("/root/page[3]/body/txt/anchored/fly/txt/text()"));
875 * The problem was that the second segment had wrong command count and wrap type.
877 * oShape = ThisComponent.DrawPage(0)
878 * oPathPropVec = oShape.CustomShapeGeometry(1).Value
879 * oSegments = oPathPropVec(1).Value
880 * msgbox oSegments(1).Count ' was 0x2000 | 10, should be 10
881 * msgbox oShape.Surround ' was 2, should be 1
883 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
884 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
885 uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(xDraws
->getByIndex(0), "CustomShapeGeometry");
886 uno::Sequence
<beans::PropertyValue
> aPathProps
;
887 for (int i
= 0; i
< aProps
.getLength(); ++i
)
889 const beans::PropertyValue
& rProp
= aProps
[i
];
890 if (rProp
.Name
== "Path")
891 rProp
.Value
>>= aPathProps
;
893 uno::Sequence
<drawing::EnhancedCustomShapeSegment
> aSegments
;
894 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
896 const beans::PropertyValue
& rProp
= aPathProps
[i
];
897 if (rProp
.Name
== "Segments")
898 rProp
.Value
>>= aSegments
;
900 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aSegments
[1].Count
);
901 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT
, getProperty
<text::WrapTextMode
>(xDraws
->getByIndex(0), "Surround"));
904 void Test::testFdo52389()
906 // The last '!' character at the end of the document was lost
907 CPPUNIT_ASSERT_EQUAL(6, getLength());
910 void Test::testFdo49655_62805()
914 * The problem was that the table was not imported due to the ' ' string in the middle of the table definition.
916 * xray ThisComponent.TextTables.Count 'was 0
919 * The problem was that the table was not imported due to the absence of \pard after \row.
920 * The table was instead in a group (the '}' replace the \pard).
922 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
923 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
924 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess
->getCount());
927 void Test::testFdo52475()
929 // The problem was that \chcbpat0 resulted in no color, instead of COL_AUTO.
930 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(getRun(getParagraph(1), 3), "CharBackColor"));
933 void Test::testFdo55493()
935 // The problem was that the width of the PNG was detected as 15,24cm, instead of 3.97cm
936 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
937 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
938 uno::Reference
<drawing::XShape
> xShape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
939 CPPUNIT_ASSERT_EQUAL(sal_Int32(3969), xShape
->getSize().Width
);
942 void Test::testCopyPastePageStyle()
944 // The problem was that RTF import during copy&paste did not ignore page styles.
945 // Once we have more copy&paste tests, makes sense to refactor this to some helper method.
946 paste("copypaste-pagestyle-paste.rtf");
948 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
949 CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), getProperty
<sal_Int32
>(xPropertySet
, "Width")); // Was letter, i.e. 21590
952 void Test::testCopyPasteFootnote()
954 // The RTF import did not handle the case when the position wasn't the main document XText, but something different, e.g. a footnote.
955 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
956 uno::Reference
<container::XIndexAccess
> xFootnotes(xFootnotesSupplier
->getFootnotes(), uno::UNO_QUERY
);
957 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
958 paste("copypaste-footnote-paste.rtf", xTextRange
);
960 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange
->getString());
963 void Test::testFdo61193()
965 // Pasting content that contained a footnote caused a crash.
966 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
967 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
968 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
969 paste("fdo61193.rtf", xEnd
);
972 void Test::testShptxtPard()
974 // The problem was that \pard inside \shptxt caused loss of shape text
975 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
976 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
977 uno::Reference
<text::XText
> xText(xDraws
->getByIndex(0), uno::UNO_QUERY
);
978 CPPUNIT_ASSERT_EQUAL(OUString("shape text"), xText
->getString());
981 void Test::testDoDhgt()
983 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
984 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
985 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
987 sal_Int32 nFillColor
= getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "FillColor");
988 if (nFillColor
== 0xc0504d) // red
989 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
990 else if (nFillColor
== 0x9bbb59) // green
991 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
992 else if (nFillColor
== 0x4f81bd) // blue
993 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
997 void Test::testDplinehollow()
999 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1000 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1001 uno::Reference
<beans::XPropertySet
> xPropertySet(xDraws
->getByIndex(0), uno::UNO_QUERY
);
1002 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE
, getProperty
<drawing::LineStyle
>(xPropertySet
, "LineStyle"));
1005 void Test::testLeftmarginDefault()
1007 // The default left/right margin was incorrect when the top margin was set to zero.
1008 CPPUNIT_ASSERT_EQUAL(sal_Int32(2540), getProperty
<sal_Int32
>(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "LeftMargin"));
1011 void Test::testDppolyline()
1013 // This was completely ignored, for now, just make sure we have all 4 lines.
1014 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1015 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1016 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws
->getCount());
1019 void Test::testFdo56512()
1021 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
1022 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
1023 uno::Reference
<text::XTextRange
> xTextRange(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
1024 OUString
aExpected("עוסק מורשה ", 20, RTL_TEXTENCODING_UTF8
);
1025 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
1028 void Test::testFdo52989()
1030 // Same as n#192129, but for JPEG files.
1031 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1032 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1033 uno::Reference
<drawing::XShape
> xShape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
1034 CPPUNIT_ASSERT_EQUAL(sal_Int32(423), xShape
->getSize().Width
);
1037 void Test::testFdo48442()
1039 // The problem was that \pvmrg is the default in RTF, but not in Writer.
1040 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1041 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1042 uno::Reference
<drawing::XShape
> xShape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
1043 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
, getProperty
<sal_Int16
>(xShape
, "VertOrientRelation")); // was FRAME
1046 void Test::testFdo55525()
1048 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1049 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1050 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1051 // Negative left margin was ~missing, -191
1052 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty
<sal_Int32
>(xTable
, "LeftMargin"));
1053 // Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
1054 uno::Reference
<table::XTableRows
> xTableRows(xTable
->getRows(), uno::UNO_QUERY
);
1055 CPPUNIT_ASSERT_EQUAL(sal_Int16(896), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators")[0].Position
);
1058 void Test::testFdo57708()
1060 // There were two issues: the doc was of 2 pages and the picture was missing.
1061 CPPUNIT_ASSERT_EQUAL(1, getPages());
1062 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1063 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1064 // Two objects: a picture and a textframe.
1065 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws
->getCount());
1068 void Test::testFdo54473()
1070 // The problem was that character styles were not imported due to a typo.
1071 CPPUNIT_ASSERT_EQUAL(OUString("Anot"), getProperty
<OUString
>(getRun(getParagraph(1), 1, "Text "), "CharStyleName"));
1072 CPPUNIT_ASSERT_EQUAL(OUString("ForeignTxt"), getProperty
<OUString
>(getRun(getParagraph(1), 3, "character "), "CharStyleName"));
1075 void Test::testFdo49934()
1077 // Column break without columns defined should be a page break, but it was just ignored.
1078 CPPUNIT_ASSERT_EQUAL(2, getPages());
1081 void Test::testFdo57886()
1083 // Was 'int from <?> to <?> <?>'.
1084 CPPUNIT_ASSERT_EQUAL(OUString("int from {firstlower} to {firstupper} {firstbody}"), getFormula(getRun(getParagraph(1), 1)));
1087 void Test::testFdo58076()
1089 // An additional section was created, so the default page style didn't have the custom margins.
1090 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
1091 CPPUNIT_ASSERT_EQUAL(sal_Int32(2251), getProperty
<sal_Int32
>(xStyle
, "LeftMargin"));
1092 CPPUNIT_ASSERT_EQUAL(sal_Int32(1752), getProperty
<sal_Int32
>(xStyle
, "RightMargin"));
1093 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty
<sal_Int32
>(xStyle
, "TopMargin"));
1094 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty
<sal_Int32
>(xStyle
, "BottomMargin"));
1097 void Test::testFdo57678()
1099 // Paragraphs of the two tables were not converted to tables.
1100 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1101 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1102 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
1105 void Test::testFdo45183()
1107 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1108 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1109 // Was text::WrapTextMode_PARALLEL, i.e. shpfblwtxt didn't send the shape below text.
1110 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT
, getProperty
<text::WrapTextMode
>(xDraws
->getByIndex(0), "Surround"));
1112 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1113 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1114 // Was 247, resulting in a table having width almost zero and height of 10+ pages.
1115 CPPUNIT_ASSERT_EQUAL(sal_Int32(16237), getProperty
<sal_Int32
>(xTables
->getByIndex(0), "Width"));
1118 void Test::testFdo54612()
1120 // \dpptx without a \dppolycount caused a crash.
1121 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1122 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1123 CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws
->getCount());
1126 void Test::testFdo58933()
1128 // The problem was that the table had an additional cell in its first line.
1129 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1130 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1131 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1133 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable
->getCellNames().getLength());
1136 void Test::testFdo44053()
1138 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1139 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables( ), uno::UNO_QUERY
);
1140 uno::Reference
<text::XTextTable
> xTextTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1141 uno::Reference
<table::XTableRows
> xTableRows(xTextTable
->getRows(), uno::UNO_QUERY
);
1142 // The with of the table's A1 and A2 cell should equal.
1143 CPPUNIT_ASSERT_EQUAL(getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators")[0].Position
,
1144 getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(1), "TableColumnSeparators")[0].Position
);
1147 void Test::testFdo48440()
1149 // Page break was ignored.
1150 CPPUNIT_ASSERT_EQUAL(2, getPages());
1153 void Test::testFdo58646line()
1155 // \line symbol was ignored
1156 getParagraph(1, "foo\nbar");
1159 void Test::testFdo58646()
1161 // Page break was ignored inside a continous section, on title page.
1162 CPPUNIT_ASSERT_EQUAL(2, getPages());
1165 void Test::testFdo59419()
1167 // Junk to be ignored broke import of the table.
1168 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1169 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1170 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables
->getCount());
1173 void Test::testFdo58076_2()
1175 // Position of the picture wasn't correct.
1176 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1177 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1178 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(8345)), getProperty
<sal_Int32
>(xDraws
->getByIndex(0), "HoriOrientPosition"));
1181 void Test::testFdo59953()
1183 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1184 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1185 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1186 // Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width)
1187 uno::Reference
<table::XTableRows
> xTableRows(xTable
->getRows(), uno::UNO_QUERY
);
1188 CPPUNIT_ASSERT_EQUAL(sal_Int16(7649), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators")[0].Position
);
1191 void Test::testFdo59638()
1193 // The problem was that w:lvlOverride inside w:num was ignores by dmapper.
1195 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
1196 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
1197 uno::Sequence
<beans::PropertyValue
> aProps
;
1198 xLevels
->getByIndex(0) >>= aProps
; // 1st level
1200 for (int i
= 0; i
< aProps
.getLength(); ++i
)
1202 const beans::PropertyValue
& rProp
= aProps
[i
];
1204 if (rProp
.Name
== "BulletChar")
1206 // Was '*', should be 'o'.
1207 CPPUNIT_ASSERT_EQUAL(OUString("\xEF\x82\xB7", 3, RTL_TEXTENCODING_UTF8
), rProp
.Value
.get
<OUString
>());
1211 CPPUNIT_FAIL("no BulletChar property");
1214 void Test::testFdo60722()
1216 // The problem was that the larger shape was over the smaller one, and not the other way around.
1217 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1218 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1219 uno::Reference
<beans::XPropertySet
> xShape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
1220 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1221 CPPUNIT_ASSERT_EQUAL(OUString("larger"), getProperty
<OUString
>(xShape
, "Description"));
1223 xShape
.set(xDraws
->getByIndex(1), uno::UNO_QUERY
);
1224 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1225 CPPUNIT_ASSERT_EQUAL(OUString("smaller"), getProperty
<OUString
>(xShape
, "Description"));
1227 // Color of the line was blue, and it had zero width.
1228 xShape
.set(xDraws
->getByIndex(2), uno::UNO_QUERY
);
1229 CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty
<sal_uInt32
>(xShape
, "LineWidth"));
1230 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty
<sal_uInt32
>(xShape
, "LineColor"));
1233 void Test::testFdo61909()
1235 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
1236 // Was the Writer default font.
1237 CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty
<OUString
>(xTextRange
, "CharFontName"));
1239 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, getProperty
<sal_uInt32
>(xTextRange
, "CharBackColor"));
1242 void Test::testFdo62288()
1244 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1245 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1246 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1247 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
1248 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
1249 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1250 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1251 // Margins were inherited from the previous cell, even there was a \pard there.
1252 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xPara
, "ParaLeftMargin"));
1255 void Test::testFdo37716()
1257 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
1258 uno::Reference
<container::XIndexAccess
> xFrames(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
1259 // \nowrap got ignored, so Surround was text::WrapTextMode_PARALLEL
1260 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_NONE
, getProperty
<text::WrapTextMode
>(xFrames
->getByIndex(0), "Surround"));
1263 void Test::testFdo51916()
1265 // Complex nested table caused a crash.
1268 void Test::testFdo63023()
1270 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "HeaderText");
1271 // Back color was black (0) in the header, due to missing color table in the substream.
1272 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF99), getProperty
<sal_Int32
>(getRun(getParagraphOfText(1, xHeaderText
), 1), "CharBackColor"));
1275 void Test::testFdo42109()
1277 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1278 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1279 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1280 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
1281 // Make sure the page number is imported as a field in the B1 cell.
1282 CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty
<OUString
>(getRun(getParagraphOfText(1, xCell
->getText()), 1), "TextPortionType"));
1285 void Test::testFdo62977()
1287 // The middle character was imported as '?' instead of the proper unicode value.
1288 getRun(getParagraph(1), 1, OUString("\xE5\xB9\xB4\xEF\xBC\x94\xE6\x9C\x88", 9, RTL_TEXTENCODING_UTF8
));
1291 void Test::testN818997()
1293 // \page was ignored between two \shp tokens.
1294 CPPUNIT_ASSERT_EQUAL(2, getPages());
1297 void Test::testFdo64671()
1299 // Additional '}' was inserted before the special character.
1300 getRun(getParagraph(1), 1, OUString("\xC5\xBD", 2, RTL_TEXTENCODING_UTF8
));
1303 void Test::testFdo62044()
1305 // The problem was that RTF import during copy&paste did not ignore existing paragraph styles.
1306 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1307 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
1308 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1309 paste("fdo62044-paste.rtf", xEnd
);
1311 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY
);
1312 CPPUNIT_ASSERT_EQUAL(10.f
, getProperty
<float>(xPropertySet
, "CharHeight")); // Was 18, i.e. reset back to original value.
1315 void Test::testN825305()
1317 // The problem was that the textbox wasn't transparent, due to unimplemented fFilled == 0.
1318 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1319 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1320 uno::Reference
<beans::XPropertyState
> xPropertyState(xDraws
->getByIndex(1), uno::UNO_QUERY
);
1321 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(xDraws
->getByIndex(1), "BackColorTransparency"));
1322 beans::PropertyState ePropertyState
= xPropertyState
->getPropertyState("BackColorTransparency");
1323 // Was beans::PropertyState_DEFAULT_VALUE.
1324 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1327 void Test::testParaBottomMargin()
1329 // This was 353, i.e. bottom margin of the paragraph was 0.35cm instead of 0.
1330 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(getParagraph(1), "ParaBottomMargin"));
1333 void Test::testN823655()
1335 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1336 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1337 uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(xDraws
->getByIndex(0), "CustomShapeGeometry");
1338 uno::Sequence
<beans::PropertyValue
> aPathProps
;
1339 for (int i
= 0; i
< aProps
.getLength(); ++i
)
1341 const beans::PropertyValue
& rProp
= aProps
[i
];
1342 if (rProp
.Name
== "Path")
1343 aPathProps
= rProp
.Value
.get
< uno::Sequence
<beans::PropertyValue
> >();
1345 uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> aCoordinates
;
1346 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
1348 const beans::PropertyValue
& rProp
= aPathProps
[i
];
1349 if (rProp
.Name
== "Coordinates")
1350 aCoordinates
= rProp
.Value
.get
< uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> >();
1352 // The first coordinate pair of this freeform shape was 286,0 instead of 0,286.
1353 CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates
[0].Second
.Value
.get
<sal_Int32
>());
1356 void Test::testFdo39001()
1358 // Document was of 4 pages, \sect at the end of the doc wasn't ignored.
1359 CPPUNIT_ASSERT_EQUAL(3, getPages());
1362 void Test::testFdo66565()
1364 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1365 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1366 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1367 // Cell width of A2 was 554, should be 453/14846*10000
1368 uno::Reference
<table::XTableRows
> xTableRows(xTable
->getRows(), uno::UNO_QUERY
);
1369 CPPUNIT_ASSERT_EQUAL(sal_Int16(304), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(1), "TableColumnSeparators")[0].Position
);
1372 void Test::testFdo54900()
1374 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1375 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1376 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1377 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1378 // Paragraph was aligned to left, should be center.
1379 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(getParagraphOfText(1, xCell
->getText()), "ParaAdjust")));
1382 void Test::testFdo64637()
1384 // The problem was that the custom "Company" property was added twice, the second invocation resulted in an exception.
1385 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(mxComponent
, uno::UNO_QUERY
);
1386 uno::Reference
<beans::XPropertySet
> xPropertySet(xDocumentPropertiesSupplier
->getDocumentProperties()->getUserDefinedProperties(), uno::UNO_QUERY
);
1387 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getProperty
<OUString
>(xPropertySet
, "Company"));
1390 void Test::testFdo67365()
1392 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1393 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1394 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1395 uno::Reference
<table::XTableRows
> xRows
= xTable
->getRows();
1396 // The table only had 3 rows.
1397 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xRows
->getCount());
1398 // This was 4999, i.e. the two cells of the row had equal widths instead of a larger and a smaller cell.
1399 CPPUNIT_ASSERT_EQUAL(sal_Int16(5290), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xRows
->getByIndex(2), "TableColumnSeparators")[0].Position
);
1400 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A2"), uno::UNO_QUERY
);
1401 // Paragraph was aligned to center, should be left.
1402 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT
, static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(getParagraphOfText(1, xCell
->getText()), "ParaAdjust")));
1405 void Test::testFdo67498()
1407 // Left margin of the default page style wasn't set (was 2000).
1408 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(5954)), getProperty
<sal_Int32
>(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "LeftMargin"));
1411 void Test::testFdo47440()
1413 // Vertical and horizontal orientation of the picture wasn't imported (was text::RelOrientation::FRAME).
1414 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1415 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1416 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xDraws
->getByIndex(0), "HoriOrientRelation"));
1417 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xDraws
->getByIndex(0), "VertOrientRelation"));
1420 void Test::testPoshPosv()
1422 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1423 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1424 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER
, getProperty
<sal_Int16
>(xDraws
->getByIndex(0), "HoriOrient"));
1425 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER
, getProperty
<sal_Int16
>(xDraws
->getByIndex(0), "VertOrient"));
1428 void Test::testFdo53556()
1430 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1431 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1432 // This was drawing::FillStyle_SOLID, which resulted in being non-transparent, hiding text which would be visible.
1433 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, getProperty
<drawing::FillStyle
>(xDraws
->getByIndex(2), "FillStyle"));
1435 // This was a com.sun.star.drawing.CustomShape, which resulted in lack of word wrapping in the bugdoc.
1436 uno::Reference
<beans::XPropertySet
> xShapeProperties(xDraws
->getByIndex(0), uno::UNO_QUERY
);
1437 uno::Reference
<drawing::XShapeDescriptor
> xShapeDescriptor(xShapeProperties
, uno::UNO_QUERY
);
1438 CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), xShapeDescriptor
->getShapeType());
1441 void Test::testFdo63428()
1443 // Pasting content that contained an annotation caused a crash.
1444 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1445 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
1446 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1447 paste("fdo63428.rtf", xEnd
);
1449 // Additionally, commented range was imported as a normal comment.
1450 CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty
<OUString
>(getRun(getParagraph(1), 2), "TextPortionType"));
1451 CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty
<OUString
>(getRun(getParagraph(1), 4), "TextPortionType"));
1454 void Test::testFdo44715()
1456 uno::Reference
<text::XTextTable
> xTable(getParagraphOrTable(1), uno::UNO_QUERY
);
1457 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1458 // Style information wasn't reset, which caused character height to be 16.
1459 CPPUNIT_ASSERT_EQUAL(12.f
, getProperty
<float>(getParagraphOfText(2, xCell
->getText()), "CharHeight"));
1462 void Test::testFdo68076()
1464 // Encoding of the last char was wrong (more 'o' than 'y').
1465 OUString
aExpected("\xD0\x9E\xD0\xB1\xD1\x8A\xD0\xB5\xD0\xBA\xD1\x82 \xE2\x80\x93 \xD1\x83", 19, RTL_TEXTENCODING_UTF8
);
1466 getParagraph(1, aExpected
);
1469 void Test::testFdo68291()
1471 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1472 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
1473 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1474 paste("fdo68291-paste.rtf", xEnd
);
1476 // This was "Standard", causing an unwanted page break on next paste.
1477 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty
<OUString
>(getParagraph(1), "PageDescName"));
1480 void Test::testFdo69384()
1482 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1483 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
1484 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1485 paste("fdo69384-paste.rtf", xEnd
);
1487 // Import got interrupted in the middle of style sheet table import,
1488 // resuling in missing styles and text.
1489 getStyles("ParagraphStyles")->getByName("Text body justified");
1492 void Test::testFdo70221()
1494 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1495 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1496 // The picture was imported twice.
1497 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws
->getCount());
1500 void Test::testN823675()
1502 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
1503 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
1504 uno::Sequence
<beans::PropertyValue
> aProps
;
1505 xLevels
->getByIndex(0) >>= aProps
; // 1st level
1506 awt::FontDescriptor aFont
;
1508 for (int i
= 0; i
< aProps
.getLength(); ++i
)
1510 const beans::PropertyValue
& rProp
= aProps
[i
];
1512 if (rProp
.Name
== "BulletFont")
1513 aFont
= rProp
.Value
.get
<awt::FontDescriptor
>();
1515 // This was empty, i.e. no font name was set for the bullet numbering.
1516 CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), aFont
.Name
);
1519 void Test::testCp1000018()
1521 // The problem was that the empty paragraph at the end of the footnote got
1522 // lost during import.
1523 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
1524 uno::Reference
<container::XIndexAccess
> xFootnotes(xFootnotesSupplier
->getFootnotes(), uno::UNO_QUERY
);
1525 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
1526 OUString
aExpected("Footnote first line.\n");
1527 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
1530 void Test::testFdo65090()
1532 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1533 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables( ), uno::UNO_QUERY
);
1534 uno::Reference
<text::XTextTable
> xTextTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1535 uno::Reference
<table::XTableRows
> xTableRows(xTextTable
->getRows(), uno::UNO_QUERY
);
1536 // The first row had 3 cells, instead of a horizontally merged one and a normal one (2 -> 1 separator).
1537 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators").getLength());
1540 void Test::testNestedTable()
1542 // nested table in second cell was missing
1543 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1544 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1545 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(1), uno::UNO_QUERY
);
1546 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1547 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
1548 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1549 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1550 CPPUNIT_ASSERT_EQUAL(OUString("Responsable Commercial:"), xPara
->getString());
1551 xCell
.set(xTable
->getCellByName("A2"), uno::UNO_QUERY
);
1552 xParaEnumAccess
.set(xCell
->getText(), uno::UNO_QUERY
);
1553 xParaEnum
= xParaEnumAccess
->createEnumeration();
1554 xPara
.set(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1555 xPara
.set(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1556 CPPUNIT_ASSERT_EQUAL(OUString("Nom: John Doe"), xPara
->getString());
1558 // \sect at the end resulted in spurious page break
1559 CPPUNIT_ASSERT_EQUAL(1, getPages());
1562 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
1564 #if !defined(MACOSX) && !defined(WNT)
1566 class BackportedTest
: public SwModelTestBase
1569 BackportedTest() : SwModelTestBase("/sw/qa/extras/rtfimport/data/", "Rich Text Format")
1574 #define DECLARE_RTFIMPORT_TEST(TestName, filename) DECLARE_SW_IMPORT_TEST(TestName, filename, BackportedTest)
1576 DECLARE_RTFIMPORT_TEST(testCharColor
, "char-color.rtf")
1578 // This was -1: character color wasn't set.
1579 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x365F91), getProperty
<sal_Int32
>(getParagraph(1), "CharColor"));
1582 DECLARE_RTFIMPORT_TEST(testDptxbxRelation
, "dptxbx-relation.rtf")
1584 // This was FRAME, not PAGE_FRAME, even if dobxpage is in the document.
1585 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(getShape(1), "HoriOrientRelation"));
1588 DECLARE_RTFIMPORT_TEST(testDprectAnchor
, "dprect-anchor.rtf")
1590 // This was at-page, which is not something Word supports, so clearly an import error.
1591 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER
, getProperty
<text::TextContentAnchorType
>(getShape(1), "AnchorType"));
1594 DECLARE_RTFIMPORT_TEST(testDoDhgtOld
, "do-dhgt-old.rtf")
1596 // The file contains 3 shapes which have the same dhgt (z-order).
1597 // Test that the order is 1) a 2) black rectangle 3) b, and not something else
1598 uno::Reference
<text::XText
> xShape(getShape(1), uno::UNO_QUERY
);
1599 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1600 CPPUNIT_ASSERT_EQUAL(OUString("a"), xShape
->getString());
1602 xShape
.set(getShape(2), uno::UNO_QUERY
);
1603 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1604 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, getProperty
<sal_uInt32
>(xShape
, "FillColor"));
1606 xShape
.set(getShape(3), uno::UNO_QUERY
);
1607 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1608 CPPUNIT_ASSERT_EQUAL(OUString("b"), xShape
->getString());
1611 DECLARE_RTFIMPORT_TEST(testFooterPara
, "footer-para.rtf")
1613 // check that paragraph properties in footer are imported
1614 uno::Reference
<text::XText
> xFooterText
=
1615 getProperty
< uno::Reference
<text::XText
> >(
1616 getStyles("PageStyles")->getByName("First Page"), "FooterText");
1617 uno::Reference
<text::XTextContent
> xParagraph
=
1618 getParagraphOrTable(1, xFooterText
);
1619 CPPUNIT_ASSERT_EQUAL(OUString("All Rights Reserved."),
1620 uno::Reference
<text::XTextRange
>(xParagraph
, uno::UNO_QUERY
)->getString());
1621 CPPUNIT_ASSERT_EQUAL((sal_Int16
)style::ParagraphAdjust_CENTER
,
1622 getProperty
</*style::ParagraphAdjust*/sal_Int16
>(xParagraph
, "ParaAdjust"));
1627 CPPUNIT_PLUGIN_IMPLEMENT();
1629 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */