2 * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Initial Developer of the Original Code is
15 * Miklos Vajna <vmiklos@suse.cz> (SUSE, Inc.)
16 * Portions created by the Initial Developer are Copyright (C) 2012 the
17 * Initial Developer. All Rights Reserved.
21 * Alternatively, the contents of this file may be used under the terms of
22 * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
23 * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
24 * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
25 * instead of those above.
28 #include <com/sun/star/document/XFilter.hpp>
29 #include <com/sun/star/document/XImporter.hpp>
30 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
31 #include <com/sun/star/drawing/LineStyle.hpp>
32 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
33 #include <com/sun/star/graphic/GraphicType.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/style/CaseMap.hpp>
36 #include <com/sun/star/style/LineSpacing.hpp>
37 #include <com/sun/star/style/LineSpacingMode.hpp>
38 #include <com/sun/star/table/BorderLine2.hpp>
39 #include <com/sun/star/table/BorderLineStyle.hpp>
40 #include <com/sun/star/text/RelOrientation.hpp>
41 #include <com/sun/star/text/SizeType.hpp>
42 #include <com/sun/star/text/TableColumnSeparator.hpp>
43 #include <com/sun/star/text/TextContentAnchorType.hpp>
44 #include <com/sun/star/text/XFootnotesSupplier.hpp>
45 #include <com/sun/star/text/XPageCursor.hpp>
46 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
47 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
48 #include <com/sun/star/text/XTextFramesSupplier.hpp>
49 #include <com/sun/star/text/XTextTablesSupplier.hpp>
50 #include <com/sun/star/text/XTextTable.hpp>
51 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
52 #include <com/sun/star/text/WrapTextMode.hpp>
53 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
55 #include <rtl/ustring.hxx>
56 #include <vcl/outdev.hxx>
57 #include <vcl/svapp.hxx>
58 #include <unotools/ucbstreamhelper.hxx>
59 #include <unotools/streamwrap.hxx>
61 #include <swmodeltestbase.hxx>
62 #include <bordertest.hxx>
64 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
66 class Test
: public SwModelTestBase
112 void testAllGapsWord();
119 void testCopyPastePageStyle();
120 void testCopyPasteFootnote();
121 void testShptxtPard();
123 void testDplinehollow();
124 void testLeftmarginDefault();
125 void testDppolyline();
140 void testFdo58646line();
145 CPPUNIT_TEST_SUITE(Test
);
146 #if !defined(MACOSX) && !defined(WNT)
149 CPPUNIT_TEST_SUITE_END();
159 MethodEntry
<Test
> aMethods
[] = {
160 {"fdo45553.rtf", &Test::testFdo45553
},
161 {"n192129.rtf", &Test::testN192129
},
162 {"fdo45543.rtf", &Test::testFdo45543
},
163 {"n695479.rtf", &Test::testN695479
},
164 {"fdo42465.rtf", &Test::testFdo42465
},
165 {"fdo45187.rtf", &Test::testFdo45187
},
166 {"fdo46662.rtf", &Test::testFdo46662
},
167 {"n750757.rtf", &Test::testN750757
},
168 {"fdo45563.rtf", &Test::testFdo45563
},
169 {"fdo43965.rtf", &Test::testFdo43965
},
170 {"n751020.rtf", &Test::testN751020
},
171 {"fdo47326.rtf", &Test::testFdo47326
},
172 {"fdo47036.rtf", &Test::testFdo47036
},
173 {"fdo46955.rtf", &Test::testFdo46955
},
174 {"fdo45394.rtf", &Test::testFdo45394
},
175 {"fdo48104.rtf", &Test::testFdo48104
},
176 {"fdo47107.rtf", &Test::testFdo47107
},
177 {"fdo45182.rtf", &Test::testFdo45182
},
178 {"fdo44176.rtf", &Test::testFdo44176
},
179 {"fdo39053.rtf", &Test::testFdo39053
},
180 {"fdo48356.rtf", &Test::testFdo48356
},
181 {"fdo48023.rtf", &Test::testFdo48023
},
182 {"fdo48876.rtf", &Test::testFdo48876
},
183 {"fdo48193.rtf", &Test::testFdo48193
},
184 {"fdo44211.rtf", &Test::testFdo44211
},
185 {"fdo48037.rtf", &Test::testFdo48037
},
186 {"fdo47764.rtf", &Test::testFdo47764
},
187 {"fdo38786.rtf", &Test::testFdo38786
},
188 {"n757651.rtf", &Test::testN757651
},
189 {"fdo49501.rtf", &Test::testFdo49501
},
190 {"fdo49271.rtf", &Test::testFdo49271
},
191 {"fdo49692.rtf", &Test::testFdo49692
},
192 {"fdo45190.rtf", &Test::testFdo45190
},
193 {"fdo50539.rtf", &Test::testFdo50539
},
194 {"fdo50665.rtf", &Test::testFdo50665
},
195 {"fdo49659.rtf", &Test::testFdo49659
},
196 {"fdo46966.rtf", &Test::testFdo46966
},
197 {"fdo52066.rtf", &Test::testFdo52066
},
198 {"fdo48033.rtf", &Test::testFdo48033
},
199 {"fdo36089.rtf", &Test::testFdo36089
},
200 {"fdo49892.rtf", &Test::testFdo49892
},
201 {"fdo48446.rtf", &Test::testFdo48446
},
202 {"fdo47495.rtf", &Test::testFdo47495
},
203 {"all_gaps_word.rtf", &Test::testAllGapsWord
},
204 {"fdo52052.rtf", &Test::testFdo52052
},
205 {"ink.rtf", &Test::testInk
},
206 {"fdo52389.rtf", &Test::testFdo52389
},
207 {"fdo49655.rtf", &Test::testFdo49655
},
208 {"fdo52475.rtf", &Test::testFdo52475
},
209 {"fdo55493.rtf", &Test::testFdo55493
},
210 {"copypaste-pagestyle.rtf", &Test::testCopyPastePageStyle
},
211 {"copypaste-footnote.rtf", &Test::testCopyPasteFootnote
},
212 {"shptxt-pard.rtf", &Test::testShptxtPard
},
213 {"do-dhgt.rtf", &Test::testDoDhgt
},
214 {"dplinehollow.rtf", &Test::testDplinehollow
},
215 {"leftmargin-default.rtf", &Test::testLeftmarginDefault
},
216 {"dppolyline.rtf", &Test::testDppolyline
},
217 {"fdo56512.rtf", &Test::testFdo56512
},
218 {"fdo52989.rtf", &Test::testFdo52989
},
219 {"fdo48442.rtf", &Test::testFdo48442
},
220 {"fdo55525.rtf", &Test::testFdo55525
},
221 {"fdo57708.rtf", &Test::testFdo57708
},
222 {"fdo54473.rtf", &Test::testFdo54473
},
223 {"fdo49934.rtf", &Test::testFdo49934
},
224 {"fdo57886.rtf", &Test::testFdo57886
},
225 {"fdo58076.rtf", &Test::testFdo58076
},
226 {"fdo57678.rtf", &Test::testFdo57678
},
227 {"fdo45183.rtf", &Test::testFdo45183
},
228 {"fdo54612.rtf", &Test::testFdo54612
},
229 {"fdo58933.rtf", &Test::testFdo58933
},
230 {"fdo44053.rtf", &Test::testFdo44053
},
231 {"fdo58646line.rtf", &Test::testFdo58646line
},
232 {"fdo59953.rtf", &Test::testFdo59953
},
233 {"fdo59638.rtf", &Test::testFdo59638
},
234 {"fdo60722.rtf", &Test::testFdo60722
},
236 for (unsigned int i
= 0; i
< SAL_N_ELEMENTS(aMethods
); ++i
)
238 MethodEntry
<Test
>& rEntry
= aMethods
[i
];
239 AllSettings
aSavedSettings(Application::GetSettings());
240 if (OString(rEntry
.pName
) == "fdo48023.rtf")
242 AllSettings
aSettings(aSavedSettings
);
243 aSettings
.SetLanguageTag(LanguageTag("ru"));
244 Application::SetSettings(aSettings
);
246 else if (OString(rEntry
.pName
) == "fdo44211.rtf")
248 AllSettings
aSettings(aSavedSettings
);
249 aSettings
.SetLanguageTag(LanguageTag("lt"));
250 Application::SetSettings(aSettings
);
252 mxComponent
= loadFromDesktop(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + OUString::createFromAscii(rEntry
.pName
));
253 if (OString(rEntry
.pName
) == "fdo48023.rtf" || OString(rEntry
.pName
) == "fdo44211.rtf")
254 Application::SetSettings(aSavedSettings
);
255 (this->*rEntry
.pMethod
)();
261 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
262 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
263 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(), uno::UNO_QUERY
);
264 xCursor
->jumpToLastPage();
265 return xCursor
->getPage();
268 void Test::testFdo45553()
270 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
271 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
272 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
273 while (xParaEnum
->hasMoreElements())
275 uno::Reference
<container::XEnumerationAccess
> xRangeEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
276 uno::Reference
<container::XEnumeration
> xRangeEnum
= xRangeEnumAccess
->createEnumeration();
277 while (xRangeEnum
->hasMoreElements())
279 uno::Reference
<text::XTextRange
> xRange(xRangeEnum
->nextElement(), uno::UNO_QUERY
);
280 OUString aStr
= xRange
->getString();
281 if ( aStr
== "space-before" )
282 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(120)), getProperty
<sal_Int32
>(xRange
, "ParaTopMargin"));
283 else if ( aStr
== "space-after" )
284 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(240)), getProperty
<sal_Int32
>(xRange
, "ParaBottomMargin"));
289 void Test::testN192129()
291 // We expect that the result will be 16x16px.
292 Size
aExpectedSize(16, 16);
293 MapMode
aMap(MAP_100TH_MM
);
294 aExpectedSize
= Application::GetDefaultDevice()->PixelToLogic( aExpectedSize
, aMap
);
296 uno::Reference
<text::XTextGraphicObjectsSupplier
> xTextGraphicObjectsSupplier(mxComponent
, uno::UNO_QUERY
);
297 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextGraphicObjectsSupplier
->getGraphicObjects(), uno::UNO_QUERY
);
298 uno::Reference
<drawing::XShape
> xShape(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
299 awt::Size
aActualSize(xShape
->getSize());
301 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Width()), aActualSize
.Width
);
302 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Height()), aActualSize
.Height
);
305 void Test::testFdo45543()
307 CPPUNIT_ASSERT_EQUAL(5, getLength());
310 void Test::testN695479()
312 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
313 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
314 uno::Reference
<beans::XPropertySet
> xPropertySet(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
316 // Negative ABSH should mean fixed size.
317 CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX
, getProperty
<sal_Int16
>(xPropertySet
, "SizeType"));
318 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(300)), getProperty
<sal_Int32
>(xPropertySet
, "Height"));
320 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
321 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
322 bool bFrameFound
= false, bDrawFound
= false;
323 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
325 uno::Reference
<lang::XServiceInfo
> xServiceInfo(xDraws
->getByIndex(i
), uno::UNO_QUERY
);
326 if (xServiceInfo
->supportsService("com.sun.star.text.TextFrame"))
328 // Both frames should be anchored to the first paragraph.
330 uno::Reference
<text::XTextContent
> xTextContent(xServiceInfo
, uno::UNO_QUERY
);
331 uno::Reference
<text::XTextRange
> xRange(xTextContent
->getAnchor(), uno::UNO_QUERY
);
332 uno::Reference
<text::XText
> xText(xRange
->getText(), uno::UNO_QUERY
);
333 CPPUNIT_ASSERT_EQUAL(OUString("plain"), xText
->getString());
336 // Additonally, the frist frame should have double border at the bottom.
337 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::DOUBLE
, getProperty
<table::BorderLine2
>(xPropertySet
, "BottomBorder").LineStyle
);
339 else if (xServiceInfo
->supportsService("com.sun.star.drawing.LineShape"))
341 // The older "drawing objects" syntax should be recognized.
343 xPropertySet
.set(xServiceInfo
, uno::UNO_QUERY
);
344 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
, getProperty
<sal_Int16
>(xPropertySet
, "HoriOrientRelation"));
345 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xPropertySet
, "VertOrientRelation"));
348 CPPUNIT_ASSERT(bFrameFound
);
349 CPPUNIT_ASSERT(bDrawFound
);
352 void Test::testFdo42465()
354 CPPUNIT_ASSERT_EQUAL(3, getLength());
357 void Test::testFdo45187()
359 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
360 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
361 // There should be two shapes.
362 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws
->getCount());
363 // They should be anchored to different paragraphs.
364 CPPUNIT_ASSERT(getProperty
<awt::Point
>(xDraws
->getByIndex(0), "AnchorPosition").Y
!= getProperty
<awt::Point
>(xDraws
->getByIndex(1), "AnchorPosition").Y
);
367 void Test::testFdo46662()
369 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY
);
370 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
371 uno::Sequence
<beans::PropertyValue
> aProps
;
372 xLevels
->getByIndex(1) >>= aProps
; // 2nd level
374 for (int i
= 0; i
< aProps
.getLength(); ++i
)
376 const beans::PropertyValue
& rProp
= aProps
[i
];
378 if ( rProp
.Name
== "ParentNumbering" )
379 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), rProp
.Value
.get
<sal_Int16
>());
380 else if ( rProp
.Name
== "Suffix" )
381 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp
.Value
.get
<OUString
>().getLength());
385 void Test::testN750757()
387 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
388 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
389 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
391 CPPUNIT_ASSERT_EQUAL(sal_Bool(false), getProperty
<sal_Bool
>(xParaEnum
->nextElement(), "ParaContextMargin"));
392 CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty
<sal_Bool
>(xParaEnum
->nextElement(), "ParaContextMargin"));
395 void Test::testFdo45563()
397 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
398 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
399 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
401 while (xParaEnum
->hasMoreElements())
403 xParaEnum
->nextElement();
406 CPPUNIT_ASSERT_EQUAL(4, i
);
409 void Test::testFdo43965()
411 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
412 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
413 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
415 // First paragraph: the parameter of \up was ignored
416 uno::Reference
<container::XEnumerationAccess
> xRangeEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
417 uno::Reference
<container::XEnumeration
> xRangeEnum
= xRangeEnumAccess
->createEnumeration();
418 uno::Reference
<beans::XPropertySet
> xPropertySet(xRangeEnum
->nextElement(), uno::UNO_QUERY
);
419 CPPUNIT_ASSERT_EQUAL(sal_Int32(36), getProperty
<sal_Int32
>(xPropertySet
, "CharEscapement"));
420 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(xPropertySet
, "CharEscapementHeight"));
422 // Second paragraph: Word vs Writer border default problem
423 CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty
<table::BorderLine2
>(xParaEnum
->nextElement(), "TopBorder").LineWidth
);
425 // Finally, make sure that we have two pages
426 CPPUNIT_ASSERT_EQUAL(2, getPages());
429 void Test::testN751020()
431 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
432 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
433 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
434 CPPUNIT_ASSERT(xParaEnum
->hasMoreElements());
435 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(200)), getProperty
<sal_Int32
>(xParaEnum
->nextElement(), "ParaBottomMargin"));
438 void Test::testFdo47326()
440 // This was 15 only, as \super buffered text, then the contents of it got lost.
441 CPPUNIT_ASSERT_EQUAL(19, getLength());
444 void Test::testFdo47036()
446 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
447 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
448 int nAtCharacter
= 0;
449 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
451 if (getProperty
<text::TextContentAnchorType
>(xDraws
->getByIndex(i
), "AnchorType") == text::TextContentAnchorType_AT_CHARACTER
)
454 // The image at the document start was ignored.
455 CPPUNIT_ASSERT_EQUAL(1, nAtCharacter
);
457 // There should be 2 textboxes, not 4
458 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
459 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
460 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
463 void Test::testFdo46955()
465 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
466 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
467 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
468 while (xParaEnum
->hasMoreElements())
470 uno::Reference
<container::XEnumerationAccess
> xRangeEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
471 uno::Reference
<container::XEnumeration
> xRangeEnum
= xRangeEnumAccess
->createEnumeration();
472 while (xRangeEnum
->hasMoreElements())
473 CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE
, getProperty
<sal_Int16
>(xRangeEnum
->nextElement(), "CharCaseMap"));
477 void Test::testFdo45394()
479 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "HeaderText");
480 OUString aActual
= xHeaderText
->getString();
481 // Encoding in the header was wrong.
482 OUString
aExpected("ПК РИК", 11, RTL_TEXTENCODING_UTF8
);
483 CPPUNIT_ASSERT_EQUAL(aExpected
, aActual
);
485 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
486 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
487 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess
->getCount());
490 void Test::testFdo48104()
492 CPPUNIT_ASSERT_EQUAL(2, getPages());
495 void Test::testFdo47107()
497 uno::Reference
<container::XNameAccess
> xNumberingStyles(getStyles("NumberingStyles"));
498 // Make sure numbered and bullet legacy syntax is recognized, this used to throw a NoSuchElementException
499 xNumberingStyles
->getByName("WWNum1");
500 xNumberingStyles
->getByName("WWNum2");
503 void Test::testFdo45182()
505 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
506 uno::Reference
<container::XIndexAccess
> xFootnotes(xFootnotesSupplier
->getFootnotes(), uno::UNO_QUERY
);
507 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
508 // Encoding in the footnote was wrong.
509 OUString
aExpected("živností", 10, RTL_TEXTENCODING_UTF8
);
510 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
513 void Test::testFdo44176()
515 uno::Reference
<container::XNameAccess
> xPageStyles(getStyles("PageStyles"));
516 uno::Reference
<beans::XPropertySet
> xFirstPage(xPageStyles
->getByName("First Page"), uno::UNO_QUERY
);
517 uno::Reference
<beans::XPropertySet
> xDefault(xPageStyles
->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
518 sal_Int32 nFirstTop
= 0, nDefaultTop
= 0, nDefaultHeader
= 0;
519 xFirstPage
->getPropertyValue("TopMargin") >>= nFirstTop
;
520 xDefault
->getPropertyValue("TopMargin") >>= nDefaultTop
;
521 xDefault
->getPropertyValue("HeaderHeight") >>= nDefaultHeader
;
522 CPPUNIT_ASSERT_EQUAL(nFirstTop
, nDefaultTop
+ nDefaultHeader
);
525 void Test::testFdo39053()
527 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
528 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
529 int nAsCharacter
= 0;
530 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
531 if (getProperty
<text::TextContentAnchorType
>(xDraws
->getByIndex(i
), "AnchorType") == text::TextContentAnchorType_AS_CHARACTER
)
533 // The image in binary format was ignored.
534 CPPUNIT_ASSERT_EQUAL(1, nAsCharacter
);
537 void Test::testFdo48356()
539 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
540 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
541 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
544 while (xParaEnum
->hasMoreElements())
546 xParaEnum
->nextElement();
549 // The document used to be imported as two paragraphs.
550 CPPUNIT_ASSERT_EQUAL(1, i
);
553 void Test::testFdo48023()
555 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
557 // Implicit encoding detection based on locale was missing
558 OUString
aExpected("Программист", 22, RTL_TEXTENCODING_UTF8
);
559 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
562 void Test::testFdo48876()
564 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
565 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
566 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
567 CPPUNIT_ASSERT(xParaEnum
->hasMoreElements());
568 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::MINIMUM
, getProperty
<style::LineSpacing
>(xParaEnum
->nextElement(), "ParaLineSpacing").Mode
);
571 void Test::testFdo48193()
573 CPPUNIT_ASSERT_EQUAL(7, getLength());
576 void Test::testFdo44211()
578 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
580 OUString
aExpected("ąčę", 6, RTL_TEXTENCODING_UTF8
);
581 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
584 void Test::testFdo48037()
586 uno::Reference
<util::XNumberFormatsSupplier
> xNumberSupplier(mxComponent
, uno::UNO_QUERY_THROW
);
587 lang::Locale aUSLocale
, aFRLocale
;
588 aUSLocale
.Language
= "en";
589 aFRLocale
.Language
= "fr";
590 sal_Int32 nExpected
= xNumberSupplier
->getNumberFormats()->addNewConverted("d MMMM yyyy", aUSLocale
, aFRLocale
);
592 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
593 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
594 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
595 uno::Reference
<beans::XPropertySet
> xPropertySet(xFields
->nextElement(), uno::UNO_QUERY
);
596 sal_Int32 nActual
= 0;
597 xPropertySet
->getPropertyValue("NumberFormat") >>= nActual
;
599 CPPUNIT_ASSERT_EQUAL(nExpected
, nActual
);
602 void Test::testFdo47764()
604 // \cbpat with zero argument should mean the auto (-1) color, not a default color (black)
605 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(getParagraph(1), "ParaBackColor"));
608 void Test::testFdo38786()
610 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
611 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
612 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
613 // \chpgn was ignored, so exception was thrown
614 xFields
->nextElement();
617 void Test::testN757651()
619 // The bug was that due to buggy layout the text expanded to two pages.
620 if (Application::GetDefaultDevice()->IsFontAvailable(OUString("Times New Roman")))
621 CPPUNIT_ASSERT_EQUAL(1, getPages());
624 void Test::testFdo49501()
626 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
628 CPPUNIT_ASSERT_EQUAL(sal_True
, getProperty
<sal_Bool
>(xStyle
, "IsLandscape"));
629 sal_Int32
nExpected(TWIP_TO_MM100(567));
630 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "LeftMargin"));
631 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "RightMargin"));
632 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "TopMargin"));
633 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "BottomMargin"));
636 void Test::testFdo49271()
638 CPPUNIT_ASSERT_EQUAL(25.f
, getProperty
<float>(getParagraph(2), "CharHeight"));
641 void Test::testFdo49692()
643 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
644 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
645 uno::Sequence
<beans::PropertyValue
> aProps
;
646 xLevels
->getByIndex(0) >>= aProps
; // 1st level
648 for (int i
= 0; i
< aProps
.getLength(); ++i
)
650 const beans::PropertyValue
& rProp
= aProps
[i
];
652 if (rProp
.Name
== "Suffix")
653 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp
.Value
.get
<OUString
>().getLength());
657 void Test::testFdo45190()
659 // inherited \fi should be reset
660 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(getParagraph(1), "ParaFirstLineIndent"));
662 // but direct one not
663 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(-100)), getProperty
<sal_Int32
>(getParagraph(2), "ParaFirstLineIndent"));
666 void Test::testFdo50539()
668 // \chcbpat with zero argument should mean the auto (-1) color, not a default color (black)
669 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(getRun(getParagraph(1), 1), "CharBackColor"));
672 void Test::testFdo50665()
674 // Access the second run, which is a textfield
675 uno::Reference
<beans::XPropertySet
> xRun(getRun(getParagraph(1), 2), uno::UNO_QUERY
);
676 // This used to be the default, as character properties were ignored.
677 CPPUNIT_ASSERT_EQUAL(OUString("Book Antiqua"), getProperty
<OUString
>(xRun
, "CharFontName"));
680 void Test::testFdo49659()
682 // Both tables were ignored: 1) was in the header, 2) was ignored due to missing empty par at the end of the doc
683 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
684 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
685 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
687 // The graphic was also empty
688 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
689 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
690 uno::Reference
<beans::XPropertySet
> xGraphic(getProperty
< uno::Reference
<beans::XPropertySet
> >(xDraws
->getByIndex(0), "Graphic"), uno::UNO_QUERY
);
691 CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL
, getProperty
<sal_Int8
>(xGraphic
, "GraphicType"));
694 void Test::testFdo46966()
697 * The problem was the top margin was 1440 (1 inch), but it should be 720 (0.5 inch).
699 * xray ThisComponent.StyleFamilies.PageStyles.Default.TopMargin
701 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
702 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(720)), getProperty
<sal_Int32
>(xPropertySet
, "TopMargin"));
705 void Test::testFdo52066()
708 * The problem was that the height of the shape was too big.
710 * xray ThisComponent.DrawPage(0).Size.Height
712 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
713 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
714 uno::Reference
<drawing::XShape
> xShape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
715 CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(19)), xShape
->getSize().Height
);
718 void Test::testFdo48033()
721 * The problem was that the picture was in the first cell, instead of the second one.
723 * oTable = ThisComponent.TextTables(0)
724 * oParas = oTable.getCellByName("B1").Text.createEnumeration
725 * oPara = oParas.nextElement
726 * oRuns = oPara.createEnumeration
727 * oRun = oRuns.nextElement
728 * xray oRun.TextPortionType ' Frame, was Text
730 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
731 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
732 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
733 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
734 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
735 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
736 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
737 CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty
<OUString
>(getRun(xPara
, 1), "TextPortionType"));
740 void Test::testFdo36089()
742 CPPUNIT_ASSERT_EQUAL(sal_Int16(-50), getProperty
<sal_Int16
>(getRun(getParagraph(1), 2), "CharEscapement"));
745 void Test::testFdo49892()
747 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
748 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
749 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
751 OUString aDescription
= getProperty
<OUString
>(xDraws
->getByIndex(i
), "Description");
752 if (aDescription
== "red")
753 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
754 else if (aDescription
== "green")
755 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
756 else if (aDescription
== "blue")
757 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
758 else if (aDescription
== "rect")
760 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xDraws
->getByIndex(i
), "HoriOrientRelation"));
761 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xDraws
->getByIndex(i
), "VertOrientRelation"));
766 void Test::testFdo48446()
768 OUString
aExpected("Имя", 6, RTL_TEXTENCODING_UTF8
);
769 getParagraph(1, aExpected
);
772 void Test::testFdo47495()
774 // Used to have 4 paragraphs, as a result the original bugdoc had 2 pages instead of 1.
775 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
778 void Test::testAllGapsWord()
780 BorderTest borderTest
;
781 borderTest
.testTheBorders(mxComponent
);
784 void Test::testFdo52052()
786 // Make sure the textframe containing the text "third" appears on the 3rd page.
787 CPPUNIT_ASSERT_EQUAL(OUString("third"), parseDump("/root/page[3]/body/txt/anchored/fly/txt/text()"));
793 * The problem was that the second segment had wrong command count and wrap type.
795 * oShape = ThisComponent.DrawPage(0)
796 * oPathPropVec = oShape.CustomShapeGeometry(1).Value
797 * oSegments = oPathPropVec(1).Value
798 * msgbox oSegments(1).Count ' was 0x2000 | 10, should be 10
799 * msgbox oShape.Surround ' was 2, should be 1
801 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
802 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
803 uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(xDraws
->getByIndex(0), "CustomShapeGeometry");
804 uno::Sequence
<beans::PropertyValue
> aPathProps
;
805 for (int i
= 0; i
< aProps
.getLength(); ++i
)
807 const beans::PropertyValue
& rProp
= aProps
[i
];
808 if (rProp
.Name
== "Path")
809 rProp
.Value
>>= aPathProps
;
811 uno::Sequence
<drawing::EnhancedCustomShapeSegment
> aSegments
;
812 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
814 const beans::PropertyValue
& rProp
= aPathProps
[i
];
815 if (rProp
.Name
== "Segments")
816 rProp
.Value
>>= aSegments
;
818 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aSegments
[1].Count
);
819 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT
, getProperty
<text::WrapTextMode
>(xDraws
->getByIndex(0), "Surround"));
822 void Test::testFdo52389()
824 // The last '!' character at the end of the document was lost
825 CPPUNIT_ASSERT_EQUAL(6, getLength());
828 void Test::testFdo49655()
831 * The problem was that the table was not imported due to the ' ' string in the middle of the table definition.
833 * xray ThisComponent.TextTables.Count 'was 0
835 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
836 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
837 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess
->getCount());
840 void Test::testFdo52475()
842 // The problem was that \chcbpat0 resulted in no color, instead of COL_AUTO.
843 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(getRun(getParagraph(1), 3), "CharBackColor"));
846 void Test::testFdo55493()
848 // The problem was that the width of the PNG was detected as 15,24cm, instead of 3.97cm
849 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
850 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
851 uno::Reference
<drawing::XShape
> xShape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
852 CPPUNIT_ASSERT_EQUAL(sal_Int32(3969), xShape
->getSize().Width
);
855 void Test::testCopyPastePageStyle()
857 // The problem was that RTF import during copy&paste did not ignore page styles.
858 // Once we have more copy&paste tests, makes sense to refactor this to some helper method.
859 uno::Reference
<uno::XInterface
> xInterface(m_xSFactory
->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW
);
860 uno::Reference
<document::XImporter
> xImporter(xInterface
, uno::UNO_QUERY_THROW
);
861 xImporter
->setTargetDocument(mxComponent
);
862 uno::Reference
<document::XFilter
> xFilter(xInterface
, uno::UNO_QUERY_THROW
);
863 uno::Sequence
<beans::PropertyValue
> aDescriptor(2);
864 aDescriptor
[0].Name
= "InputStream";
865 SvStream
* pStream
= utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + "copypaste-pagestyle-paste.rtf", STREAM_WRITE
);
866 uno::Reference
<io::XStream
> xStream(new utl::OStreamWrapper(*pStream
));
867 aDescriptor
[0].Value
<<= xStream
;
868 aDescriptor
[1].Name
= "IsNewDoc";
869 aDescriptor
[1].Value
<<= sal_False
;
870 xFilter
->filter(aDescriptor
);
872 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
873 CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), getProperty
<sal_Int32
>(xPropertySet
, "Width")); // Was letter, i.e. 21590
876 void Test::testCopyPasteFootnote()
878 // The RTF import did not handle the case when the position wasn't the main document XText, but something different, e.g. a footnote.
879 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
880 uno::Reference
<container::XIndexAccess
> xFootnotes(xFootnotesSupplier
->getFootnotes(), uno::UNO_QUERY
);
881 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
883 uno::Reference
<uno::XInterface
> xInterface(m_xSFactory
->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW
);
884 uno::Reference
<document::XImporter
> xImporter(xInterface
, uno::UNO_QUERY_THROW
);
885 xImporter
->setTargetDocument(mxComponent
);
886 uno::Reference
<document::XFilter
> xFilter(xInterface
, uno::UNO_QUERY_THROW
);
887 uno::Sequence
<beans::PropertyValue
> aDescriptor(3);
888 aDescriptor
[0].Name
= "InputStream";
889 SvStream
* pStream
= utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + "copypaste-footnote-paste.rtf", STREAM_WRITE
);
890 uno::Reference
<io::XStream
> xStream(new utl::OStreamWrapper(*pStream
));
891 aDescriptor
[0].Value
<<= xStream
;
892 aDescriptor
[1].Name
= "IsNewDoc";
893 aDescriptor
[1].Value
<<= sal_False
;
894 aDescriptor
[2].Name
= "TextInsertModeRange";
895 aDescriptor
[2].Value
<<= xTextRange
;
896 xFilter
->filter(aDescriptor
);
898 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange
->getString());
901 void Test::testShptxtPard()
903 // The problem was that \pard inside \shptxt caused loss of shape text
904 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
905 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
906 uno::Reference
<text::XText
> xText(xDraws
->getByIndex(0), uno::UNO_QUERY
);
907 CPPUNIT_ASSERT_EQUAL(OUString("shape text"), xText
->getString());
910 void Test::testDoDhgt()
912 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
913 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
914 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
916 sal_Int32 nFillColor
= getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "FillColor");
917 if (nFillColor
== 0xc0504d) // red
918 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
919 else if (nFillColor
== 0x9bbb59) // green
920 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
921 else if (nFillColor
== 0x4f81bd) // blue
922 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
926 void Test::testDplinehollow()
928 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
929 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
930 uno::Reference
<beans::XPropertySet
> xPropertySet(xDraws
->getByIndex(0), uno::UNO_QUERY
);
931 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE
, getProperty
<drawing::LineStyle
>(xPropertySet
, "LineStyle"));
934 void Test::testLeftmarginDefault()
936 // The default left/right margin was incorrect when the top margin was set to zero.
937 CPPUNIT_ASSERT_EQUAL(sal_Int32(2540), getProperty
<sal_Int32
>(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "LeftMargin"));
940 void Test::testDppolyline()
942 // This was completely ignored, for now, just make sure we have all 4 lines.
943 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
944 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
945 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws
->getCount());
948 void Test::testFdo56512()
950 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
951 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
952 uno::Reference
<text::XTextRange
> xTextRange(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
953 OUString
aExpected("עוסק מורשה ", 20, RTL_TEXTENCODING_UTF8
);
954 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
957 void Test::testFdo52989()
959 // Same as n#192129, but for JPEG files.
960 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
961 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
962 uno::Reference
<drawing::XShape
> xShape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
963 CPPUNIT_ASSERT_EQUAL(sal_Int32(423), xShape
->getSize().Width
);
966 void Test::testFdo48442()
968 // The problem was that \pvmrg is the default in RTF, but not in Writer.
969 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
970 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
971 uno::Reference
<drawing::XShape
> xShape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
972 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
, getProperty
<sal_Int16
>(xShape
, "VertOrientRelation")); // was FRAME
975 void Test::testFdo55525()
977 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
978 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
979 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
980 // Negative left margin was ~missing, -191
981 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty
<sal_Int32
>(xTable
, "LeftMargin"));
982 // Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
983 uno::Reference
<table::XTableRows
> xTableRows(xTable
->getRows(), uno::UNO_QUERY
);
984 CPPUNIT_ASSERT_EQUAL(sal_Int16(1016), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators")[0].Position
);
987 void Test::testFdo57708()
989 // There were two issues: the doc was of 2 pages and the picture was missing.
990 CPPUNIT_ASSERT_EQUAL(1, getPages());
991 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
992 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
993 // Two objects: a picture and a textframe.
994 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws
->getCount());
997 void Test::testFdo54473()
999 // The problem was that character styles were not imported due to a typo.
1000 CPPUNIT_ASSERT_EQUAL(OUString("Anot"), getProperty
<OUString
>(getRun(getParagraph(1), 1, "Text "), "CharStyleName"));
1001 CPPUNIT_ASSERT_EQUAL(OUString("ForeignTxt"), getProperty
<OUString
>(getRun(getParagraph(1), 3, "character "), "CharStyleName"));
1004 void Test::testFdo49934()
1006 // Column break without columns defined should be a page break, but it was just ignored.
1007 CPPUNIT_ASSERT_EQUAL(2, getPages());
1010 void Test::testFdo57886()
1012 // Was 'int from <?> to <?> <?>'.
1013 CPPUNIT_ASSERT_EQUAL(OUString("int from {firstlower} to {firstupper} {firstbody}"), getFormula(getRun(getParagraph(1), 1)));
1016 void Test::testFdo58076()
1018 // An additional section was created, so the default page style didn't have the custom margins.
1019 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
1020 CPPUNIT_ASSERT_EQUAL(sal_Int32(2251), getProperty
<sal_Int32
>(xStyle
, "LeftMargin"));
1021 CPPUNIT_ASSERT_EQUAL(sal_Int32(1752), getProperty
<sal_Int32
>(xStyle
, "RightMargin"));
1022 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty
<sal_Int32
>(xStyle
, "TopMargin"));
1023 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty
<sal_Int32
>(xStyle
, "BottomMargin"));
1026 void Test::testFdo57678()
1028 // Paragraphs of the two tables were not converted to tables.
1029 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1030 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1031 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
1034 void Test::testFdo45183()
1036 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1037 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1038 // Was text::WrapTextMode_PARALLEL, i.e. shpfblwtxt didn't send the shape below text.
1039 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT
, getProperty
<text::WrapTextMode
>(xDraws
->getByIndex(0), "Surround"));
1041 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1042 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1043 // Was 247, resulting in a table having width almost zero and height of 10+ pages.
1044 CPPUNIT_ASSERT_EQUAL(sal_Int32(16237), getProperty
<sal_Int32
>(xTables
->getByIndex(0), "Width"));
1047 void Test::testFdo54612()
1049 // \dpptx without a \dppolycount caused a crash.
1050 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1051 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1052 CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws
->getCount());
1055 void Test::testFdo58933()
1057 // The problem was that the table had an additional cell in its first line.
1058 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1059 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1060 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1062 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable
->getCellNames().getLength());
1065 void Test::testFdo44053()
1067 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1068 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables( ), uno::UNO_QUERY
);
1069 uno::Reference
<text::XTextTable
> xTextTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1070 uno::Reference
<table::XTableRows
> xTableRows(xTextTable
->getRows(), uno::UNO_QUERY
);
1071 // The with of the table's A1 and A2 cell should equal.
1072 CPPUNIT_ASSERT_EQUAL(getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators")[0].Position
,
1073 getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(1), "TableColumnSeparators")[0].Position
);
1076 void Test::testFdo58646line()
1078 // \line symbol was ignored
1079 getParagraph(1, "foo\nbar");
1082 void Test::testFdo59953()
1084 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1085 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1086 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1087 // Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width)
1088 uno::Reference
<table::XTableRows
> xTableRows(xTable
->getRows(), uno::UNO_QUERY
);
1089 CPPUNIT_ASSERT_EQUAL(sal_Int16(7650), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators")[0].Position
);
1092 void Test::testFdo59638()
1094 // The problem was that w:lvlOverride inside w:num was ignores by dmapper.
1096 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
1097 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
1098 uno::Sequence
<beans::PropertyValue
> aProps
;
1099 xLevels
->getByIndex(0) >>= aProps
; // 1st level
1101 for (int i
= 0; i
< aProps
.getLength(); ++i
)
1103 const beans::PropertyValue
& rProp
= aProps
[i
];
1105 if (rProp
.Name
== "BulletChar")
1107 // Was '*', should be 'o'.
1108 CPPUNIT_ASSERT_EQUAL(OUString("\xEF\x82\xB7", 3, RTL_TEXTENCODING_UTF8
), rProp
.Value
.get
<OUString
>());
1112 CPPUNIT_FAIL("no BulletChar property");
1115 void Test::testFdo60722()
1117 // The problem was that the larger shape was over the smaller one, and not the other way around.
1118 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1119 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1120 uno::Reference
<beans::XPropertySet
> xShape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
1121 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1122 CPPUNIT_ASSERT_EQUAL(OUString("larger"), getProperty
<OUString
>(xShape
, "Description"));
1124 xShape
.set(xDraws
->getByIndex(1), uno::UNO_QUERY
);
1125 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1126 CPPUNIT_ASSERT_EQUAL(OUString("smaller"), getProperty
<OUString
>(xShape
, "Description"));
1128 // Color of the line was blue, and it had zero width.
1129 xShape
.set(xDraws
->getByIndex(2), uno::UNO_QUERY
);
1130 CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty
<sal_uInt32
>(xShape
, "LineWidth"));
1131 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty
<sal_uInt32
>(xShape
, "LineColor"));
1134 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
1136 CPPUNIT_PLUGIN_IMPLEMENT();
1138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */