1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #include <swmodeltestbase.hxx>
13 #include <config_fonts.h>
15 #include <com/sun/star/awt/FontDescriptor.hpp>
16 #include <com/sun/star/awt/FontUnderline.hpp>
17 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
18 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
19 #include <com/sun/star/drawing/FillStyle.hpp>
20 #include <com/sun/star/graphic/XGraphic.hpp>
21 #include <com/sun/star/lang/XServiceInfo.hpp>
22 #include <com/sun/star/style/BreakType.hpp>
23 #include <com/sun/star/style/LineSpacing.hpp>
24 #include <com/sun/star/style/LineSpacingMode.hpp>
25 #include <com/sun/star/style/ParagraphAdjust.hpp>
26 #include <com/sun/star/style/TabStop.hpp>
27 #include <com/sun/star/table/BorderLine2.hpp>
28 #include <com/sun/star/table/BorderLineStyle.hpp>
29 #include <com/sun/star/text/RelOrientation.hpp>
30 #include <com/sun/star/text/SizeType.hpp>
31 #include <com/sun/star/text/TableColumnSeparator.hpp>
32 #include <com/sun/star/text/TextContentAnchorType.hpp>
33 #include <com/sun/star/text/XDocumentIndexMark.hpp>
34 #include <com/sun/star/text/XFootnotesSupplier.hpp>
35 #include <com/sun/star/text/XPageCursor.hpp>
36 #include <com/sun/star/text/XTextFramesSupplier.hpp>
37 #include <com/sun/star/text/XTextTablesSupplier.hpp>
38 #include <com/sun/star/text/XTextTable.hpp>
39 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
40 #include <com/sun/star/text/WrapTextMode.hpp>
41 #include <com/sun/star/text/HoriOrientation.hpp>
42 #include <com/sun/star/text/VertOrientation.hpp>
43 #include <com/sun/star/text/XFormField.hpp>
44 #include <com/sun/star/lang/Locale.hpp>
45 #include <com/sun/star/drawing/XShapes.hpp>
46 #include <com/sun/star/text/XTextDocument.hpp>
47 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
48 #include <com/sun/star/beans/XPropertyState.hpp>
49 #include <com/sun/star/document/XDocumentInsertable.hpp>
51 #include <o3tl/cppunittraitshelper.hxx>
52 #include <tools/UnitConversion.hxx>
53 #include <rtl/ustring.hxx>
54 #include <vcl/settings.hxx>
55 #include <comphelper/sequenceashashmap.hxx>
56 #include <comphelper/configuration.hxx>
58 #include <editeng/charhiddenitem.hxx>
60 #include <ndindex.hxx>
62 #include <fmtautofmt.hxx>
64 class Test
: public SwModelTestBase
68 : SwModelTestBase("/sw/qa/extras/rtfimport/data/", "Rich Text Format")
73 AllSettings m_aSavedSettings
;
76 CPPUNIT_TEST_FIXTURE(Test
, testN695479
)
78 createSwDoc("n695479.rtf");
79 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
80 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(),
82 uno::Reference
<beans::XPropertySet
> xPropertySet(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
84 // Negative ABSH should mean fixed size.
85 CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX
, getProperty
<sal_Int16
>(xPropertySet
, "SizeType"));
86 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(300)),
87 getProperty
<sal_Int32
>(xPropertySet
, "Height"));
89 int nShapes
= getShapes();
90 CPPUNIT_ASSERT_EQUAL(3, nShapes
);
92 bool bFrameFound
= false, bDrawFound
= false;
93 for (int i
= 0; i
< nShapes
; ++i
)
95 uno::Reference
<lang::XServiceInfo
> xServiceInfo(getShape(i
+ 1), uno::UNO_QUERY
);
96 if (xServiceInfo
->supportsService("com.sun.star.text.TextFrame"))
98 // Both frames should be anchored to the first paragraph.
100 uno::Reference
<text::XTextContent
> xTextContent(xServiceInfo
, uno::UNO_QUERY
);
101 uno::Reference
<text::XTextRange
> xRange
= xTextContent
->getAnchor();
102 uno::Reference
<text::XText
> xText
= xRange
->getText();
103 CPPUNIT_ASSERT_EQUAL(OUString("plain"), xText
->getString());
106 // Additionally, the first frame should have double border at the bottom.
107 CPPUNIT_ASSERT_EQUAL(
108 table::BorderLineStyle::DOUBLE
,
109 getProperty
<table::BorderLine2
>(xPropertySet
, "BottomBorder").LineStyle
);
111 else if (xServiceInfo
->supportsService("com.sun.star.drawing.LineShape"))
113 // The older "drawing objects" syntax should be recognized.
115 xPropertySet
.set(xServiceInfo
, uno::UNO_QUERY
);
116 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
,
117 getProperty
<sal_Int16
>(xPropertySet
, "HoriOrientRelation"));
118 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
119 getProperty
<sal_Int16
>(xPropertySet
, "VertOrientRelation"));
122 CPPUNIT_ASSERT(bFrameFound
);
123 CPPUNIT_ASSERT(bDrawFound
);
126 CPPUNIT_TEST_FIXTURE(Test
, testTdf117246
)
128 createSwDoc("tdf117246.rtf");
129 // This was 2, all but the last \page was lost.
130 CPPUNIT_ASSERT_EQUAL(3, getPages());
133 CPPUNIT_TEST_FIXTURE(Test
, testTdf108943
)
135 createSwDoc("tdf108943.rtf");
136 uno::Reference
<beans::XPropertySet
> xPropertySet(
137 getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
138 uno::Reference
<container::XIndexAccess
> xLevels(
139 xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
140 uno::Sequence
<beans::PropertyValue
> aProps
;
141 xLevels
->getByIndex(0) >>= aProps
; // 1st level
143 sal_Int32 nListtabStopPosition
= 0;
144 for (int i
= 0; i
< aProps
.getLength(); ++i
)
146 const beans::PropertyValue
& rProp
= aProps
[i
];
148 if (rProp
.Name
== "ListtabStopPosition")
149 nListtabStopPosition
= rProp
.Value
.get
<sal_Int32
>();
151 // This was 0, \tx was handled in paragraphs only (and not in list definitions).
152 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1270), nListtabStopPosition
);
155 CPPUNIT_TEST_FIXTURE(Test
, testFdo46662
)
157 createSwDoc("fdo46662.rtf");
162 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
163 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0),
164 getProperty
<sal_Int16
>(xPara
, "NumberingLevel"));
165 CPPUNIT_ASSERT(xPara
->getPropertyValue("NumberingStyleName") >>= listStyle
);
166 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
167 CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty
<OUString
>(xPara
, "ListLabelString"));
171 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(2), uno::UNO_QUERY
);
172 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1),
173 getProperty
<sal_Int16
>(xPara
, "NumberingLevel"));
174 CPPUNIT_ASSERT(xPara
->getPropertyValue("NumberingStyleName") >>= listStyle
);
175 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
176 CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty
<OUString
>(xPara
, "ListLabelString"));
180 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(3), uno::UNO_QUERY
);
181 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(2),
182 getProperty
<sal_Int16
>(xPara
, "NumberingLevel"));
183 CPPUNIT_ASSERT(xPara
->getPropertyValue("NumberingStyleName") >>= listStyle
);
184 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
185 CPPUNIT_ASSERT_EQUAL(OUString("1.1.1"), getProperty
<OUString
>(xPara
, "ListLabelString"));
189 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(4), uno::UNO_QUERY
);
190 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(3),
191 getProperty
<sal_Int16
>(xPara
, "NumberingLevel"));
192 CPPUNIT_ASSERT(xPara
->getPropertyValue("NumberingStyleName") >>= listStyle
);
193 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
194 CPPUNIT_ASSERT_EQUAL(OUString("1.1.1.1"), getProperty
<OUString
>(xPara
, "ListLabelString"));
198 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(5), uno::UNO_QUERY
);
199 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0),
200 getProperty
<sal_Int16
>(xPara
, "NumberingLevel"));
201 CPPUNIT_ASSERT(xPara
->getPropertyValue("NumberingStyleName") >>= listStyle
);
202 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
203 CPPUNIT_ASSERT_EQUAL(OUString("2"), getProperty
<OUString
>(xPara
, "ListLabelString"));
207 CPPUNIT_TEST_FIXTURE(Test
, testTdf115715
)
209 createSwDoc("tdf115715.rtf");
210 // This was 0, second paragraph was shifted to the right, it had the same
211 // horizontal position as the 3rd paragraph.
212 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-1270),
213 getProperty
<sal_Int32
>(getParagraph(2), "ParaFirstLineIndent"));
216 CPPUNIT_TEST_FIXTURE(Test
, testTdf81943
)
218 createSwDoc("tdf81943.rtf");
219 // The shape wasn't in background.
220 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(getShape(1), "Opaque"));
223 CPPUNIT_TEST_FIXTURE(Test
, testTdf115155
)
225 createSwDoc("tdf115155.rtf");
227 = getProperty
<uno::Reference
<container::XIndexAccess
>>(getParagraph(2), "NumberingRules");
229 comphelper::SequenceAsHashMap
aMap(xLevels
->getByIndex(0));
230 // This was 1270: the left margin in the numbering rule was too small.
231 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2540), aMap
["IndentAt"].get
<sal_Int32
>());
234 CPPUNIT_TEST_FIXTURE(Test
, testTdf108951
)
236 createSwDoc("tdf108951.rtf");
237 // This test is import-only, as we assert the list ID, which is OK to
238 // re-order on export, but then this test would not pass anymore.
240 // \ls2 was imported as WWNum1.
241 CPPUNIT_ASSERT_EQUAL(OUString("WWNum2"),
242 getProperty
<OUString
>(getParagraph(1), "NumberingStyleName"));
245 CPPUNIT_TEST_FIXTURE(Test
, testFdo47036
)
247 createSwDoc("fdo47036.rtf");
249 int nShapes
= getShapes();
250 CPPUNIT_ASSERT_EQUAL(3, nShapes
);
251 int nAtCharacter
= 0;
252 for (int i
= 0; i
< nShapes
; ++i
)
254 if (getProperty
<text::TextContentAnchorType
>(getShape(i
+ 1), "AnchorType")
255 == text::TextContentAnchorType_AT_CHARACTER
)
258 // The image at the document start was ignored.
259 CPPUNIT_ASSERT_EQUAL(1, nAtCharacter
);
261 // There should be 2 textboxes, not 4
262 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
263 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(),
265 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
268 CPPUNIT_TEST_FIXTURE(Test
, testFdo45182
)
270 createSwDoc("fdo45182.rtf");
271 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
272 uno::Reference
<container::XIndexAccess
> xFootnotes
= xFootnotesSupplier
->getFootnotes();
273 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
274 // Encoding in the footnote was wrong.
275 CPPUNIT_ASSERT_EQUAL(OUString(u
"\u017Eivnost\u00ED" SAL_NEWLINE_STRING
),
276 xTextRange
->getString());
279 CPPUNIT_TEST_FIXTURE(Test
, testFdo85812
)
281 createSwDoc("fdo85812.rtf");
283 getProperty
<lang::Locale
>(getRun(getParagraph(1), 1, "This "), "CharLocale"));
284 // the \lang inside the group was applied to CJK not Western
285 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
286 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
287 // further testing indicates that Word is doing really weird stuff
288 // \loch \hich \dbch is reset by opening a group
289 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(2), 1, "CharGroup"), "CharLocale");
290 CPPUNIT_ASSERT_EQUAL(OUString("ru"), locale
.Language
);
291 CPPUNIT_ASSERT_EQUAL(OUString("RU"), locale
.Country
);
292 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(2), 2, "AfterChar"), "CharLocale");
293 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
294 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
295 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(3), 2, "AfterBookmark"), "CharLocale");
296 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
297 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
298 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 1, "CharGroup"), "CharLocale");
299 CPPUNIT_ASSERT_EQUAL(OUString("ru"), locale
.Language
);
300 CPPUNIT_ASSERT_EQUAL(OUString("RU"), locale
.Country
);
302 = getProperty
<lang::Locale
>(getRun(getParagraph(4), 1, "CharGroup"), "CharLocaleComplex");
303 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
304 CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale
.Country
);
305 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 2, "AfterChar"), "CharLocale");
306 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
307 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
309 = getProperty
<lang::Locale
>(getRun(getParagraph(4), 2, "AfterChar"), "CharLocaleComplex");
310 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
311 CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale
.Country
);
312 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(5), 2, "AfterBookmark"), "CharLocale");
313 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
314 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
315 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(5), 2, "AfterBookmark"),
316 "CharLocaleComplex");
317 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
318 CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale
.Country
);
319 // \ltrch \rtlch works differently - it is sticky across groups
320 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 1, "CharGroup"), "CharLocale");
321 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
322 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
324 = getProperty
<lang::Locale
>(getRun(getParagraph(6), 1, "CharGroup"), "CharLocaleComplex");
325 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
326 CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale
.Country
);
327 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 2, "AfterChar"), "CharLocale");
328 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
329 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
331 = getProperty
<lang::Locale
>(getRun(getParagraph(6), 2, "AfterChar"), "CharLocaleComplex");
332 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
333 CPPUNIT_ASSERT_EQUAL(OUString("EG"), locale
.Country
);
334 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(7), 2, "AfterBookmark"), "CharLocale");
335 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
336 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
337 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(7), 2, "AfterBookmark"),
338 "CharLocaleComplex");
339 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
340 CPPUNIT_ASSERT_EQUAL(OUString("EG"), locale
.Country
);
343 CPPUNIT_TEST_FIXTURE(Test
, testFdo49692
)
345 createSwDoc("fdo49692.rtf");
346 uno::Reference
<beans::XPropertySet
> xPropertySet(
347 getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
348 uno::Reference
<container::XIndexAccess
> xLevels(
349 xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
350 uno::Sequence
<beans::PropertyValue
> aProps
;
351 xLevels
->getByIndex(0) >>= aProps
; // 1st level
353 for (int i
= 0; i
< aProps
.getLength(); ++i
)
355 const beans::PropertyValue
& rProp
= aProps
[i
];
357 if (rProp
.Name
== "Suffix")
359 CPPUNIT_ASSERT(rProp
.Value
.get
<OUString
>().isEmpty());
364 CPPUNIT_TEST_FIXTURE(Test
, testFdo45190
)
366 createSwDoc("fdo45190.rtf");
367 // inherited \fi should be reset
368 CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
369 getProperty
<sal_Int32
>(getParagraph(1), "ParaFirstLineIndent"));
371 // but direct one not
372 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-100)),
373 getProperty
<sal_Int32
>(getParagraph(2), "ParaFirstLineIndent"));
376 CPPUNIT_TEST_FIXTURE(Test
, testTdf59699
)
378 createSwDoc("tdf59699.rtf");
379 // This resulted in a lang.IndexOutOfBoundsException: the referenced graphic data wasn't imported.
380 uno::Reference
<beans::XPropertySet
> xImage(getShape(1), uno::UNO_QUERY
);
381 auto xGraphic
= getProperty
<uno::Reference
<graphic::XGraphic
>>(xImage
, "Graphic");
382 CPPUNIT_ASSERT(xGraphic
.is());
385 CPPUNIT_TEST_FIXTURE(Test
, testFdo52066
)
387 createSwDoc("fdo52066.rtf");
389 * The problem was that the height of the shape was too big.
391 * xray ThisComponent.DrawPage(0).Size.Height
393 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
394 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(19)), xShape
->getSize().Height
);
397 CPPUNIT_TEST_FIXTURE(Test
, testTdf112211_2
)
399 createSwDoc("tdf112211-2.rtf");
400 // Spacing between the bullet and the actual text was too large.
401 // This is now around 269, large old value was 629.
402 int nWidth
= parseDump("/root/page/body/txt[2]/SwParaPortion/SwLineLayout/"
403 "child::*[@type='PortionType::TabLeft']",
406 CPPUNIT_ASSERT_LESS(300, nWidth
);
409 CPPUNIT_TEST_FIXTURE(Test
, testTdf122430
)
411 createSwDoc("tdf122430.rtf");
412 // Without the accompanying fix in place, this test would have failed with
413 // 'Expected: 18, Actual : 12', i.e. the font was smaller than expected.
414 CPPUNIT_ASSERT_EQUAL(18.0f
, getProperty
<float>(getRun(getParagraph(1), 2), "CharHeight"));
417 CPPUNIT_TEST_FIXTURE(Test
, testFdo49892
)
419 createSwDoc("fdo49892.rtf");
420 int nShapes
= getShapes();
421 CPPUNIT_ASSERT_EQUAL(5, nShapes
);
422 for (int i
= 0; i
< nShapes
; ++i
)
424 OUString aDescription
= getProperty
<OUString
>(getShape(i
+ 1), "Description");
425 if (aDescription
== "red")
426 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(getShape(i
+ 1), "ZOrder"));
427 else if (aDescription
== "green")
428 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(getShape(i
+ 1), "ZOrder"));
429 else if (aDescription
== "blue")
430 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(getShape(i
+ 1), "ZOrder"));
431 else if (aDescription
== "rect")
433 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
434 getProperty
<sal_Int16
>(getShape(i
+ 1), "HoriOrientRelation"));
435 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
436 getProperty
<sal_Int16
>(getShape(i
+ 1), "VertOrientRelation"));
441 CPPUNIT_TEST_FIXTURE(Test
, testFdo52052
)
443 createSwDoc("fdo52052.rtf");
444 // Make sure the textframe containing the text "third" appears on the 3rd page.
445 CPPUNIT_ASSERT_EQUAL(OUString("third"),
446 parseDump("/root/page[3]/body/txt/anchored/fly/txt/text()"));
449 CPPUNIT_TEST_FIXTURE(Test
, testInk
)
451 createSwDoc("ink.rtf");
453 * The problem was that the second segment had wrong command count and wrap type.
455 * oShape = ThisComponent.DrawPage(0)
456 * oPathPropVec = oShape.CustomShapeGeometry(1).Value
457 * oSegments = oPathPropVec(1).Value
458 * msgbox oSegments(1).Count ' was 0x2000 | 10, should be 10
459 * msgbox oShape.Surround ' was 2, should be 1
461 uno::Sequence
<beans::PropertyValue
> aProps
462 = getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShape(1), "CustomShapeGeometry");
463 uno::Sequence
<beans::PropertyValue
> aPathProps
;
464 for (int i
= 0; i
< aProps
.getLength(); ++i
)
466 const beans::PropertyValue
& rProp
= aProps
[i
];
467 if (rProp
.Name
== "Path")
468 rProp
.Value
>>= aPathProps
;
470 uno::Sequence
<drawing::EnhancedCustomShapeSegment
> aSegments
;
471 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
473 const beans::PropertyValue
& rProp
= aPathProps
[i
];
474 if (rProp
.Name
== "Segments")
475 rProp
.Value
>>= aSegments
;
477 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aSegments
[1].Count
);
478 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
479 getProperty
<text::WrapTextMode
>(getShape(1), "Surround"));
482 CPPUNIT_TEST_FIXTURE(Test
, testFdo79319
)
484 createSwDoc("fdo79319.rtf");
485 // the thin horizontal rule was imported as a big fat rectangle
486 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
487 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(xShape
, "RelativeWidth"));
488 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(16508), xShape
->getSize().Width
, 10);
489 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(53), xShape
->getSize().Height
, 10);
491 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER
, getProperty
<sal_Int16
>(xShape
, "VertOrient"));
492 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER
, getProperty
<sal_Int16
>(xShape
, "HoriOrient"));
496 CPPUNIT_TEST_FIXTURE(Test
, testFdo48442
)
498 createSwDoc("fdo48442.rtf");
499 // The problem was that \pvmrg is the default in RTF, but not in Writer.
500 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
501 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
,
502 getProperty
<sal_Int16
>(xShape
, "VertOrientRelation")); // was FRAME
505 CPPUNIT_TEST_FIXTURE(Test
, testFdo55525
)
507 createSwDoc("fdo55525.rtf");
508 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
509 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
511 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
512 // Negative left margin was ~missing, -191
513 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty
<sal_Int32
>(xTable
, "LeftMargin"));
514 // Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
515 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
516 CPPUNIT_ASSERT_EQUAL(sal_Int16(896), getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
517 xTableRows
->getByIndex(0), "TableColumnSeparators")[0]
521 CPPUNIT_TEST_FIXTURE(Test
, testFdo57708
)
523 createSwDoc("fdo57708.rtf");
524 // There were two issues: the doc was of 2 pages and the picture was missing.
525 CPPUNIT_ASSERT_EQUAL(1, getPages());
526 // Two objects: a picture and a textframe.
527 CPPUNIT_ASSERT_EQUAL(2, getShapes());
530 CPPUNIT_TEST_FIXTURE(Test
, testFdo45183
)
532 createSwDoc("fdo45183.rtf");
533 // Was text::WrapTextMode_PARALLEL, i.e. shpfblwtxt didn't send the shape below text.
534 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
535 getProperty
<text::WrapTextMode
>(getShape(1), "Surround"));
537 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
538 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
540 // Was 247, resulting in a table having width almost zero and height of 10+ pages.
541 CPPUNIT_ASSERT_EQUAL(sal_Int32(16237), getProperty
<sal_Int32
>(xTables
->getByIndex(0), "Width"));
544 CPPUNIT_TEST_FIXTURE(Test
, testFdo59953
)
546 createSwDoc("fdo59953.rtf");
547 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
548 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
550 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
551 // Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width)
552 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
553 CPPUNIT_ASSERT_EQUAL(sal_Int16(7649), getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
554 xTableRows
->getByIndex(0), "TableColumnSeparators")[0]
558 CPPUNIT_TEST_FIXTURE(Test
, testTdf84684
)
560 createSwDoc("tdf84684.rtf");
561 // The ZOrder of the two children of the group shape were swapped.
562 uno::Reference
<drawing::XShapes
> xGroup(getShape(1), uno::UNO_QUERY
);
563 uno::Reference
<container::XNamed
> xChild1(xGroup
->getByIndex(0), uno::UNO_QUERY
);
565 CPPUNIT_ASSERT_EQUAL(OUString("Rectangle 1"), xChild1
->getName());
566 uno::Reference
<container::XNamed
> xChild2(xGroup
->getByIndex(1), uno::UNO_QUERY
);
567 // This was Rectangle 1.
568 CPPUNIT_ASSERT_EQUAL(OUString("Pie 2"), xChild2
->getName());
571 CPPUNIT_TEST_FIXTURE(Test
, testFdo81944
)
573 createSwDoc("fdo81944.rtf");
574 // font properties in style were not imported
575 uno::Reference
<beans::XPropertySet
> xPropertySet(
576 getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY
);
577 uno::Reference
<style::XStyle
> xStyle(xPropertySet
, uno::UNO_QUERY
);
578 CPPUNIT_ASSERT_EQUAL(OUString("Segoe UI"), getProperty
<OUString
>(xStyle
, "CharFontName"));
579 CPPUNIT_ASSERT_EQUAL(9.0f
, getProperty
<float>(xStyle
, "CharHeight"));
580 // not sure if this should be set on Asian or Complex or both?
581 CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"),
582 getProperty
<OUString
>(xStyle
, "CharFontNameComplex"));
583 CPPUNIT_ASSERT_EQUAL(11.0f
, getProperty
<float>(xStyle
, "CharHeightComplex"));
586 CPPUNIT_TEST_FIXTURE(Test
, testSbkodd
)
588 createSwDoc("sbkodd.rtf");
589 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
590 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(
591 xModel
->getCurrentController(), uno::UNO_QUERY
);
592 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(),
594 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), xCursor
->getPage());
595 xCursor
->jumpToNextPage();
596 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(3), xCursor
->getPage());
599 CPPUNIT_TEST_FIXTURE(Test
, testSbkeven
)
601 createSwDoc("sbkeven.rtf");
602 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
603 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(
604 xModel
->getCurrentController(), uno::UNO_QUERY
);
605 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(),
607 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), xCursor
->getPage());
608 xCursor
->jumpToNextPage();
609 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(2), xCursor
->getPage());
610 xCursor
->jumpToNextPage();
611 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(4), xCursor
->getPage());
614 CPPUNIT_TEST_FIXTURE(Test
, testPoshPosv
)
616 createSwDoc("posh-posv.rtf");
617 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER
,
618 getProperty
<sal_Int16
>(getShape(1), "HoriOrient"));
619 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER
,
620 getProperty
<sal_Int16
>(getShape(1), "VertOrient"));
621 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getShape(1), "FrameIsAutomaticHeight"));
624 CPPUNIT_TEST_FIXTURE(Test
, testPoshLeftRight
)
626 createSwDoc("posh-leftright.rtf");
627 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT
,
628 getProperty
<sal_Int16
>(getShape(1), "HoriOrient"));
629 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::LEFT
,
630 getProperty
<sal_Int16
>(getShape(2), "HoriOrient"));
633 CPPUNIT_TEST_FIXTURE(Test
, testTdf96326
)
635 createSwDoc("tdf96326.rtf");
636 // Make sure this is not checked.
638 = getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(1), 2), "Bookmark");
639 uno::Reference
<container::XNameContainer
> xParameters
= xFormField
->getParameters();
640 // This was true, ffres=25 was interpreted as checked.
641 CPPUNIT_ASSERT_EQUAL(false, bool(xParameters
->hasElements()));
643 // And this is checked.
645 = getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(2), 2), "Bookmark");
646 xParameters
= xFormField
->getParameters();
647 CPPUNIT_ASSERT_EQUAL(true, xParameters
->getByName("Checkbox_Checked").get
<bool>());
650 CPPUNIT_TEST_FIXTURE(Test
, testN823655
)
652 createSwDoc("n823655.rtf");
653 uno::Sequence
<beans::PropertyValue
> aProps
654 = getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShape(1), "CustomShapeGeometry");
655 uno::Sequence
<beans::PropertyValue
> aPathProps
;
656 for (int i
= 0; i
< aProps
.getLength(); ++i
)
658 const beans::PropertyValue
& rProp
= aProps
[i
];
659 if (rProp
.Name
== "Path")
660 aPathProps
= rProp
.Value
.get
<uno::Sequence
<beans::PropertyValue
>>();
662 uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> aCoordinates
;
663 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
665 const beans::PropertyValue
& rProp
= aPathProps
[i
];
666 if (rProp
.Name
== "Coordinates")
668 = rProp
.Value
.get
<uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
>>();
670 // The first coordinate pair of this freeform shape was 286,0 instead of 0,286.
671 CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates
[0].Second
.Value
.get
<sal_Int32
>());
674 CPPUNIT_TEST_FIXTURE(Test
, testN823675
)
676 createSwDoc("n823675.rtf");
677 uno::Reference
<beans::XPropertySet
> xPropertySet(
678 getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
679 uno::Reference
<container::XIndexAccess
> xLevels(
680 xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
681 uno::Sequence
<beans::PropertyValue
> aProps
;
682 xLevels
->getByIndex(0) >>= aProps
; // 1st level
683 awt::FontDescriptor aFont
;
685 for (int i
= 0; i
< aProps
.getLength(); ++i
)
687 const beans::PropertyValue
& rProp
= aProps
[i
];
689 if (rProp
.Name
== "BulletFont")
690 aFont
= rProp
.Value
.get
<awt::FontDescriptor
>();
692 // This was empty, i.e. no font name was set for the bullet numbering.
693 CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), aFont
.Name
);
696 CPPUNIT_TEST_FIXTURE(Test
, testGroupshape
)
698 createSwDoc("groupshape.rtf");
699 // There should be a single groupshape with 2 children.
700 CPPUNIT_ASSERT_EQUAL(1, getShapes());
701 uno::Reference
<drawing::XShapes
> xGroupshape(getShape(1), uno::UNO_QUERY
);
702 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape
->getCount());
705 CPPUNIT_TEST_FIXTURE(Test
, testGroupshape_notext
)
707 createSwDoc("groupshape-notext.rtf");
708 // There should be a single groupshape with 2 children.
709 CPPUNIT_ASSERT_EQUAL(1, getShapes());
710 uno::Reference
<drawing::XShapes
> xGroupshape(getShape(1), uno::UNO_QUERY
);
711 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape
->getCount());
714 CPPUNIT_TEST_FIXTURE(Test
, testFdo81033
)
716 createSwDoc("fdo81033.rtf");
717 // Number of tabstops in the paragraph should be 2, was 3.
718 uno::Sequence
<style::TabStop
> tabs(
719 getProperty
<uno::Sequence
<style::TabStop
>>(getParagraph(1), "ParaTabStops"));
720 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabs
.getLength());
721 CPPUNIT_ASSERT_EQUAL(sal_Int32(5808), tabs
[0].Position
);
722 CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT
, tabs
[0].Alignment
);
723 CPPUNIT_ASSERT_EQUAL(u
' ', tabs
[0].FillChar
);
724 CPPUNIT_ASSERT_EQUAL(sal_Int32(16002), tabs
[1].Position
);
725 CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT
, tabs
[1].Alignment
);
726 CPPUNIT_ASSERT_EQUAL(u
'_', tabs
[1].FillChar
);
729 CPPUNIT_TEST_FIXTURE(Test
, testTdf116269
)
731 createSwDoc("tdf116269.rtf");
732 // This was 2540, implicit 0 left margin was ignored on import (inherited
733 // value from list definition is repeated if it's not 0).
734 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0),
735 getProperty
<sal_Int32
>(getParagraph(1), "ParaLeftMargin"));
738 CPPUNIT_TEST_FIXTURE(Test
, testTdf116265
)
740 createSwDoc("tdf116265.rtf");
741 // This was -635, \fi as direct formatting has to be ignored due to
742 // matching \fi in list definition (and with invalid level numbers).
743 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0),
744 getProperty
<sal_Int32
>(getParagraph(2), "ParaFirstLineIndent"));
746 const auto& pLayout
= parseLayoutDump();
747 // Ensure that there is a tabstop in the pseudo-numbering (numbering::NONE followed by tabstop)
748 assertXPath(pLayout
, "//SwFixPortion", 1);
751 CPPUNIT_TEST_FIXTURE(Test
, testFdo66565
)
753 createSwDoc("fdo66565.rtf");
754 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
755 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
757 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
758 // Cell width of A2 was 554, should be 453/14846*10000
759 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
760 CPPUNIT_ASSERT_EQUAL(sal_Int16(304), getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
761 xTableRows
->getByIndex(1), "TableColumnSeparators")[0]
765 CPPUNIT_TEST_FIXTURE(Test
, testFdo67365
)
767 createSwDoc("fdo67365.rtf");
768 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
769 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
771 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
772 uno::Reference
<table::XTableRows
> xRows
= xTable
->getRows();
773 // The table only had 3 rows.
774 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xRows
->getCount());
775 // This was 4999, i.e. the two cells of the row had equal widths instead of a larger and a smaller cell.
776 CPPUNIT_ASSERT_EQUAL(sal_Int16(5290), getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
777 xRows
->getByIndex(2), "TableColumnSeparators")[0]
779 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A2"), uno::UNO_QUERY
);
780 // Paragraph was aligned to center, should be left.
781 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT
,
782 static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(
783 getParagraphOfText(1, xCell
->getText()), "ParaAdjust")));
786 CPPUNIT_TEST_FIXTURE(Test
, testFdo47440
)
788 createSwDoc("fdo47440.rtf");
789 // Vertical and horizontal orientation of the picture wasn't imported (was text::RelOrientation::FRAME).
790 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
791 getProperty
<sal_Int16
>(getShape(1), "HoriOrientRelation"));
792 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
793 getProperty
<sal_Int16
>(getShape(1), "VertOrientRelation"));
796 CPPUNIT_TEST_FIXTURE(Test
, testFdo53556
)
798 createSwDoc("fdo53556.rtf");
799 // This was drawing::FillStyle_SOLID, which resulted in being non-transparent, hiding text which would be visible.
800 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
,
801 getProperty
<drawing::FillStyle
>(getShape(3), "FillStyle"));
803 // This was a com.sun.star.drawing.CustomShape, which resulted in lack of word wrapping in the bugdoc.
804 uno::Reference
<beans::XPropertySet
> xShapeProperties(getShape(1), uno::UNO_QUERY
);
805 uno::Reference
<drawing::XShapeDescriptor
> xShapeDescriptor(xShapeProperties
, uno::UNO_QUERY
);
806 CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), xShapeDescriptor
->getShapeType());
809 CPPUNIT_TEST_FIXTURE(Test
, testGroupshapeRotation
)
811 createSwDoc("groupshape-rotation.rtf");
812 // Rotation on groupshapes wasn't handled correctly, RotateAngle was 4500.
813 CPPUNIT_ASSERT_EQUAL(sal_Int32(315 * 100), getProperty
<sal_Int32
>(getShape(1), "RotateAngle"));
816 CPPUNIT_TEST_FIXTURE(Test
, testTdf115153
)
818 createSwDoc("tdf115153.rtf");
819 auto const xShape(getShape(1));
820 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::NONE
, getProperty
<sal_Int16
>(xShape
, "HoriOrient"));
821 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
822 getProperty
<sal_Int16
>(xShape
, "HoriOrientRelation"));
823 CPPUNIT_ASSERT_EQUAL(sal_Int32(2533), getProperty
<sal_Int32
>(xShape
, "HoriOrientPosition"));
824 // VertOrient was wrong
825 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::NONE
, getProperty
<sal_Int16
>(xShape
, "VertOrient"));
826 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
827 getProperty
<sal_Int16
>(xShape
, "VertOrientRelation"));
828 CPPUNIT_ASSERT_EQUAL(sal_Int32(2131), getProperty
<sal_Int32
>(xShape
, "VertOrientPosition"));
831 CPPUNIT_TEST_FIXTURE(Test
, testFdo68291
)
833 createSwDoc("fdo68291.odt");
834 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
835 uno::Reference
<text::XTextRange
> xText
= xTextDocument
->getText();
836 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
837 paste(u
"rtfimport/data/fdo68291-paste.rtf", "com.sun.star.comp.Writer.RtfFilter", xEnd
);
839 // This was "Standard", causing an unwanted page break on next paste.
840 CPPUNIT_ASSERT_EQUAL(uno::Any(),
841 uno::Reference
<beans::XPropertySet
>(getParagraph(1), uno::UNO_QUERY_THROW
)
842 ->getPropertyValue("PageDescName"));
845 CPPUNIT_TEST_FIXTURE(Test
, testTdf105511
)
847 struct DefaultLocale
: public comphelper::ConfigurationProperty
<DefaultLocale
, OUString
>
849 static OUString
path() { return "/org.openoffice.Office.Linguistic/General/DefaultLocale"; }
850 ~DefaultLocale() = delete;
852 auto batch
= comphelper::ConfigurationChanges::create();
853 DefaultLocale::set("ru-RU", batch
);
855 createSwDoc("tdf105511.rtf");
856 getParagraph(1, u
"\u0418\u043C\u044F");
859 CPPUNIT_TEST_FIXTURE(Test
, testContSectionPageBreak
)
861 createSwDoc("cont-section-pagebreak.rtf");
862 uno::Reference
<text::XTextRange
> xParaSecond
= getParagraph(2);
863 CPPUNIT_ASSERT_EQUAL(OUString("SECOND"), xParaSecond
->getString());
864 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
865 getProperty
<style::BreakType
>(xParaSecond
, "BreakType"));
866 CPPUNIT_ASSERT_EQUAL(uno::Any(),
867 uno::Reference
<beans::XPropertySet
>(xParaSecond
, uno::UNO_QUERY_THROW
)
868 ->getPropertyValue("PageDescName"));
869 // actually not sure how many paragraph there should be between
870 // SECOND and THIRD - important is that the page break is on there
871 uno::Reference
<text::XTextRange
> xParaNext
= getParagraph(3);
872 CPPUNIT_ASSERT_EQUAL(OUString(), xParaNext
->getString());
873 //If PageDescName is not empty, a page break / switch to page style is defined
874 CPPUNIT_ASSERT(uno::Any() != getProperty
<OUString
>(xParaNext
, "PageDescName"));
875 uno::Reference
<text::XTextRange
> xParaThird
= getParagraph(4);
876 CPPUNIT_ASSERT_EQUAL(OUString("THIRD"), xParaThird
->getString());
877 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
878 getProperty
<style::BreakType
>(xParaThird
, "BreakType"));
879 CPPUNIT_ASSERT_EQUAL(uno::Any(),
880 uno::Reference
<beans::XPropertySet
>(xParaThird
, uno::UNO_QUERY_THROW
)
881 ->getPropertyValue("PageDescName"));
883 CPPUNIT_ASSERT_EQUAL(2, getPages());
886 CPPUNIT_TEST_FIXTURE(Test
, testBackground
)
888 createSwDoc("background.rtf");
889 // The first shape wasn't in the foreground.
890 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getShape(1), "Opaque"));
891 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(getShape(2), "Opaque"));
894 CPPUNIT_TEST_FIXTURE(Test
, testFdo74823
)
896 createSwDoc("fdo74823.rtf");
897 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
898 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
900 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
901 // Cell width of C2 was too large / column separator being 3749 too small (e.g. not set, around 3/7 of total width)
902 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
903 CPPUNIT_ASSERT_EQUAL(sal_Int16(5391), getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
904 xTableRows
->getByIndex(1), "TableColumnSeparators")[2]
908 CPPUNIT_TEST_FIXTURE(Test
, testFdo74599
)
910 createSwDoc("fdo74599.rtf");
911 uno::Reference
<beans::XPropertySet
> xPropertySet(
912 getStyles("ParagraphStyles")->getByName("Heading 3"), uno::UNO_QUERY
);
913 // Writer default styles weren't disabled, so the color was gray, not default (black).
914 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-1),
915 getProperty
<sal_Int32
>(xPropertySet
, "CharColor"));
918 CPPUNIT_TEST_FIXTURE(Test
, testColumnBreak
)
920 createSwDoc("column-break.rtf");
921 // Column break at the very start of the document was ignored.
922 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE
,
923 getProperty
<style::BreakType
>(getParagraph(2), "BreakType"));
926 CPPUNIT_TEST_FIXTURE(Test
, testUnbalancedColumnsCompat
)
928 createSwDoc("unbalanced-columns-compat.rtf");
929 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
930 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(),
932 // This was false, we ignored the relevant compat setting to make this non-last section unbalanced.
933 CPPUNIT_ASSERT_EQUAL(true,
934 getProperty
<bool>(xTextSections
->getByIndex(0), "DontBalanceTextColumns"));
937 CPPUNIT_TEST_FIXTURE(Test
, testOleInline
)
939 createSwDoc("ole-inline.rtf");
940 // Problem was that inline shape had at-page anchor.
941 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER
,
942 getProperty
<text::TextContentAnchorType
>(getShape(1), "AnchorType"));
945 CPPUNIT_TEST_FIXTURE(Test
, testTdf128611
)
947 createSwDoc("tdf128611.rtf");
948 auto aPolyPolySequence
949 = getProperty
<uno::Sequence
<uno::Sequence
<awt::Point
>>>(getShape(1), "PolyPolygon");
950 CPPUNIT_ASSERT(aPolyPolySequence
.hasElements());
951 const uno::Sequence
<awt::Point
>& rPolygon
= aPolyPolySequence
[0];
952 CPPUNIT_ASSERT_GREATER(static_cast<sal_uInt32
>(1), rPolygon
.size());
953 sal_Int32 nY1
= rPolygon
[0].Y
;
954 sal_Int32 nY2
= rPolygon
[1].Y
;
956 // Without the accompanying fix in place, this test would have failed with:
957 // - Expected greater than: 6242
959 // i.e. the vertical flip was missing, and the y1 > y2 assert failed, because the line pointed
960 // from top left to bottom right, not bottom left to top right.
961 CPPUNIT_ASSERT_GREATER(nY2
, nY1
);
964 CPPUNIT_TEST_FIXTURE(Test
, testFdo80742
)
966 createSwDoc("fdo80742.rtf");
967 uno::Reference
<beans::XPropertySet
> xPropertySet(
968 getStyles("ParagraphStyles")->getByName("Heading 2"), uno::UNO_QUERY
);
969 // This was 0, outline level was body text.
970 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xPropertySet
, "OutlineLevel"));
973 CPPUNIT_TEST_FIXTURE(Test
, testBehindDoc
)
975 createSwDoc("behind-doc.rtf");
976 // The problem was that "behind doc" didn't result in the shape being in the background, only in being wrapped as "through".
977 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
978 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
979 getProperty
<text::WrapTextMode
>(xShape
, "Surround"));
981 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xShape
, "Opaque"));
984 CPPUNIT_TEST_FIXTURE(Test
, testFdo82114
)
986 createSwDoc("fdo82114.rtf");
987 uno::Reference
<text::XText
> xHeaderText
= getProperty
<uno::Reference
<text::XText
>>(
988 getStyles("PageStyles")->getByName("Converted1"), "HeaderText");
989 OUString aActual
= xHeaderText
->getString();
990 // This was 'Right page header, section 1'.
991 CPPUNIT_ASSERT_EQUAL(OUString("First page header, section 2"), aActual
);
994 CPPUNIT_TEST_FIXTURE(Test
, testFdo44984
)
996 createSwDoc("fdo44984.rtf");
997 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
998 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1000 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1001 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1002 // This was Text, i.e. the checkbox field portion was missing.
1003 CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStartEnd"),
1004 getProperty
<OUString
>(getRun(getParagraphOfText(1, xCell
->getText()), 1),
1005 "TextPortionType"));
1008 CPPUNIT_TEST_FIXTURE(Test
, testTdf131386
)
1010 createSwDoc("hidden-para-separator.rtf");
1011 SwDoc
const* const pDoc
= getSwDoc();
1012 SwNodeIndex
ix(pDoc
->GetNodes().GetEndOfContent(), -1);
1013 CPPUNIT_ASSERT(ix
.GetNode()
1015 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1017 ->Get(RES_CHRATR_HIDDEN
)
1021 CPPUNIT_ASSERT(ix
.GetNode()
1023 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1025 ->Get(RES_CHRATR_HIDDEN
)
1028 CPPUNIT_ASSERT(ix
.GetNode()
1030 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1032 ->Get(RES_CHRATR_HIDDEN
)
1035 CPPUNIT_ASSERT(ix
.GetNode()
1037 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1039 ->Get(RES_CHRATR_HIDDEN
)
1043 CPPUNIT_TEST_FIXTURE(Test
, testFdo82071
)
1045 createSwDoc("fdo82071.rtf");
1046 // The problem was that in TOC, chapter names were underlined, but they should not be.
1047 uno::Reference
<text::XTextRange
> xRun
= getRun(getParagraph(1), 1);
1048 // Make sure we test the right text portion.
1049 CPPUNIT_ASSERT_EQUAL(OUString("Chapter 1"), xRun
->getString());
1050 // This was awt::FontUnderline::SINGLE.
1051 CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE
, getProperty
<sal_Int16
>(xRun
, "CharUnderline"));
1054 CPPUNIT_TEST_FIXTURE(Test
, testFdo85179
)
1056 createSwDoc("fdo85179.rtf");
1057 // This was 0, border around the picture was ignored on import.
1058 // 360: EMU -> MM100
1059 CPPUNIT_ASSERT_EQUAL(sal_uInt32(50800 / 360),
1060 getProperty
<table::BorderLine2
>(getShape(1), "TopBorder").LineWidth
);
1063 CPPUNIT_TEST_FIXTURE(Test
, testPasteFirstParaDirectFormat
)
1065 // Create a new document.
1068 // Set some direct formatting on the first paragraph, but leave paragraph adjust at its
1070 uno::Reference
<beans::XPropertySet
> xParagraph(getParagraph(1), uno::UNO_QUERY
);
1071 xParagraph
->setPropertyValue("PageNumberOffset", uno::Any(static_cast<sal_Int16
>(0)));
1075 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1076 uno::Reference
<text::XText
> xText
= xTextDocument
->getText();
1077 uno::Reference
<document::XDocumentInsertable
> xCursor(
1078 xText
->createTextCursorByRange(xText
->getStart()), uno::UNO_QUERY
);
1079 xCursor
->insertDocumentFromURL(createFileURL(u
"paste-first-para-direct-format.rtf"), {});
1081 // Without the accompanying fix in place, this test would have failed with:
1082 // - Expected: 3 (center)
1083 // - Actual : 0 (left)
1084 // i.e. the inserted document's first paragraph's paragraph formatting was lost.
1085 uno::Reference
<beans::XPropertySet
> xParagraph(getParagraph(1), uno::UNO_QUERY
);
1086 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(style::ParagraphAdjust_CENTER
),
1087 getProperty
<sal_Int16
>(xParagraph
, "ParaAdjust"));
1090 CPPUNIT_TEST_FIXTURE(Test
, testFdo82512
)
1092 createSwDoc("fdo82512.rtf");
1093 // This was style::BreakType_NONE, column break was before the 3rd paragraph, not before the 2nd one.
1094 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE
,
1095 getProperty
<style::BreakType
>(getParagraph(2), "BreakType"));
1098 CPPUNIT_TEST_FIXTURE(Test
, testUnbalancedColumns
)
1100 createSwDoc("unbalanced-columns.rtf");
1101 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
1102 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(),
1104 // This was false, last section was balanced, but it's unbalanced in Word.
1105 CPPUNIT_ASSERT_EQUAL(true,
1106 getProperty
<bool>(xTextSections
->getByIndex(0), "DontBalanceTextColumns"));
1109 CPPUNIT_TEST_FIXTURE(Test
, testTdf126173
)
1111 createSwDoc("tdf126173.rtf");
1112 // Without the accompanying fix in place, this test would have failed, as the TextFrame was lost
1114 CPPUNIT_ASSERT(getShape(1).is());
1117 CPPUNIT_TEST_FIXTURE(Test
, testFdo84685
)
1119 createSwDoc("fdo84685.rtf");
1120 // index mark was not imported
1121 uno::Reference
<text::XDocumentIndexMark
> xMark(
1122 getProperty
<uno::Reference
<text::XDocumentIndexMark
>>(getRun(getParagraph(1), 1),
1123 "DocumentIndexMark"));
1124 CPPUNIT_ASSERT(xMark
.is());
1125 CPPUNIT_ASSERT_EQUAL(OUString("Key the 1st"), getProperty
<OUString
>(xMark
, "PrimaryKey"));
1126 // let's test toc entry too
1127 uno::Reference
<text::XDocumentIndexMark
> xTOCMark(
1128 getProperty
<uno::Reference
<text::XDocumentIndexMark
>>(getRun(getParagraph(2), 1),
1129 "DocumentIndexMark"));
1130 CPPUNIT_ASSERT(xTOCMark
.is());
1131 uno::Reference
<lang::XServiceInfo
> xTOCSI(xTOCMark
, uno::UNO_QUERY
);
1132 CPPUNIT_ASSERT(xTOCSI
->supportsService("com.sun.star.text.ContentIndexMark"));
1135 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
1136 CPPUNIT_TEST_FIXTURE(Test
, testCp950listleveltext1
)
1138 createSwDoc("cp950listleveltext1.rtf");
1139 // suffix with Chinese only ( most common case generated by MSO2010 TC)
1140 // This is a dot that is generally used as suffix of Chinese list number
1141 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u4e00\u3001";
1143 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1144 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1145 getProperty
<OUString
>(xPara
, "ListLabelString"));
1148 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
1149 CPPUNIT_TEST_FIXTURE(Test
, testCp950listleveltext2
)
1151 createSwDoc("cp950listleveltext2.rtf");
1152 // Prefix and suffix with Chinese only ( tweaked from default in MSO2010 TC)
1153 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u524d\u7f6e\u7532\u3001\u5f8c\u7f6e";
1155 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1156 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1157 getProperty
<OUString
>(xPara
, "ListLabelString"));
1160 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 )
1161 CPPUNIT_TEST_FIXTURE(Test
, testCp950listleveltext3
)
1163 createSwDoc("cp950listleveltext3.rtf");
1164 // Numbering is a mix Chinese and English ( tweaked from default in MSO2010 TC)
1165 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u524da\u7f6eb\u7532\u3001"
1168 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1169 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1170 getProperty
<OUString
>(xPara
, "ListLabelString"));
1173 CPPUNIT_TEST_FIXTURE(Test
, testChtOutlineNumberingRtf
)
1175 createSwDoc("chtoutline.rtf");
1177 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u7b2c 1 \u7ae0";
1179 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1180 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1181 getProperty
<OUString
>(xPara
, "ListLabelString"));
1184 CPPUNIT_TEST_FIXTURE(Test
, testTdf90046
)
1186 createSwDoc("tdf90046.rtf");
1187 // this was crashing on importing the footnote
1188 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
1189 uno::Reference
<container::XIndexAccess
> xFootnotes
= xFootnotesSupplier
->getFootnotes();
1190 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
1191 CPPUNIT_ASSERT_EQUAL(OUString("Ma"), xTextRange
->getString());
1194 CPPUNIT_TEST_FIXTURE(Test
, testFdo49893
)
1196 createSwDoc("fdo49893.rtf");
1197 // Image from shape was not loaded, invalid size of image after load
1198 uno::Reference
<drawing::XShape
> xShape
= getShape(2);
1199 CPPUNIT_ASSERT(xShape
.is());
1200 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(432)), xShape
->getSize().Height
);
1201 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(1296)), xShape
->getSize().Width
);
1204 CPPUNIT_TEST_FIXTURE(Test
, testFdo49893_3
)
1206 createSwDoc("fdo49893-3.rtf");
1207 // No artifacts (black lines in left top corner) as shape #3 are expected
1208 CPPUNIT_ASSERT_EQUAL(2, getShapes());
1210 // Correct wrapping for shape
1211 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
1212 getProperty
<text::WrapTextMode
>(getShape(2), "Surround"));
1215 CPPUNIT_TEST_FIXTURE(Test
, testWrapDistance
)
1217 createSwDoc("wrap-distance.rtf");
1218 // Custom shape, handled directly in RTFSdrImport.
1219 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1220 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), xShape
->getShapeType());
1221 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1),
1222 getProperty
<sal_Int32
>(xShape
, "TopMargin") / 1000);
1223 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2),
1224 getProperty
<sal_Int32
>(xShape
, "BottomMargin") / 1000);
1225 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3),
1226 getProperty
<sal_Int32
>(xShape
, "LeftMargin") / 1000);
1227 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4),
1228 getProperty
<sal_Int32
>(xShape
, "RightMargin") / 1000);
1230 // Picture, handled in GraphicImport, shared with DOCX.
1231 xShape
= getShape(2);
1232 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1),
1233 getProperty
<sal_Int32
>(xShape
, "TopMargin") / 1000);
1234 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2),
1235 getProperty
<sal_Int32
>(xShape
, "BottomMargin") / 1000);
1236 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3),
1237 getProperty
<sal_Int32
>(xShape
, "LeftMargin") / 1000);
1238 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4),
1239 getProperty
<sal_Int32
>(xShape
, "RightMargin") / 1000);
1242 CPPUNIT_TEST_FIXTURE(Test
, testTdf90260Par
)
1244 createSwDoc("hello.rtf");
1245 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1246 uno::Reference
<text::XTextRange
> xText
= xTextDocument
->getText();
1247 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1248 paste(u
"rtfimport/data/tdf90260-par.rtf", "com.sun.star.comp.Writer.RtfFilter", xEnd
);
1249 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
1252 CPPUNIT_TEST_FIXTURE(Test
, testTdf119599
)
1254 createSwDoc("tdf119599.rtf");
1255 uno::Reference
<beans::XPropertyState
> xRun(getRun(getParagraph(1), 1), uno::UNO_QUERY
);
1256 // This was beans::PropertyState_DIRECT_VALUE, changing the font size in
1257 // the style had no effect on the rendering result.
1258 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE
, xRun
->getPropertyState("CharHeight"));
1261 CPPUNIT_TEST_FIXTURE(Test
, testTdf90315
)
1263 createSwDoc("tdf90315.rtf");
1264 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
1265 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(),
1267 uno::Reference
<beans::XPropertySet
> xTextSection(xTextSections
->getByIndex(0), uno::UNO_QUERY
);
1268 // This was 0, but default should be 720 twips.
1269 CPPUNIT_ASSERT_EQUAL(
1270 static_cast<sal_Int32
>(1270),
1271 getProperty
<sal_Int32
>(xTextSection
->getPropertyValue("TextColumns"), "AutomaticDistance"));
1274 CPPUNIT_TEST_FIXTURE(Test
, testTdf59454
)
1276 createSwDoc("tdf59454.rtf");
1277 // This was 1, section break was ignored right before a table.
1278 CPPUNIT_ASSERT_EQUAL(2, getPages());
1281 CPPUNIT_TEST_FIXTURE(Test
, testTdf96308Tabpos
)
1283 createSwDoc("tdf96308-tabpos.rtf");
1284 // Get the tab stops of the second para in the B1 cell of the first table in the document.
1285 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1286 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1288 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1289 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
1290 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
1291 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1292 xParaEnum
->nextElement();
1293 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1294 auto aTabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, "ParaTabStops");
1295 // This failed: tab stops were not deleted as direct formatting on the paragraph.
1296 CPPUNIT_ASSERT(!aTabStops
.hasElements());
1299 CPPUNIT_TEST_FIXTURE(Test
, testLndscpsxn
)
1301 createSwDoc("lndscpsxn.rtf");
1302 // Check landscape flag.
1303 CPPUNIT_ASSERT_EQUAL(4, getPages());
1305 uno::Reference
<container::XNameAccess
> pageStyles
= getStyles("PageStyles");
1307 // get a page cursor
1308 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
1309 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(
1310 xModel
->getCurrentController(), uno::UNO_QUERY
);
1311 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(),
1314 // check that the first page has landscape flag
1315 xCursor
->jumpToFirstPage();
1316 OUString pageStyleName
= getProperty
<OUString
>(xCursor
, "PageStyleName");
1317 uno::Reference
<style::XStyle
> xStylePage(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1318 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStylePage
, "IsLandscape"));
1320 // check that the second page has no landscape flag
1321 xCursor
->jumpToPage(2);
1322 pageStyleName
= getProperty
<OUString
>(xCursor
, "PageStyleName");
1323 xStylePage
.set(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1324 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xStylePage
, "IsLandscape"));
1326 // check that the third page has landscape flag
1327 xCursor
->jumpToPage(3);
1328 pageStyleName
= getProperty
<OUString
>(xCursor
, "PageStyleName");
1329 xStylePage
.set(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1330 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStylePage
, "IsLandscape"));
1332 // check that the last page has no landscape flag
1333 xCursor
->jumpToLastPage();
1334 pageStyleName
= getProperty
<OUString
>(xCursor
, "PageStyleName");
1335 xStylePage
.set(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1336 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xStylePage
, "IsLandscape"));
1339 CPPUNIT_TEST_FIXTURE(Test
, testTdf99498
)
1341 createSwDoc("tdf99498.rtf");
1342 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1343 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1346 // Table width was a tiny sub one char wide 145twips, it should now be a table wide
1347 // enough to see all the text in the first column without breaking into multiple lines
1348 CPPUNIT_ASSERT_EQUAL(sal_Int32(7056), getProperty
<sal_Int32
>(xTables
->getByIndex(0), "Width"));
1351 CPPUNIT_TEST_FIXTURE(Test
, testClassificatonPaste
)
1353 createSwDoc("hello.rtf");
1354 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1355 uno::Reference
<text::XTextRange
> xText
= xTextDocument
->getText();
1356 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1358 // Not classified source, not classified destination: OK.
1359 paste(u
"rtfimport/data/classification-no.rtf", "com.sun.star.comp.Writer.RtfFilter", xEnd
);
1360 CPPUNIT_ASSERT_EQUAL(OUString("classification-no"), getParagraph(2)->getString());
1362 // Classified source, not classified destination: nothing should happen.
1363 OUString aOld
= xText
->getString();
1364 paste(u
"rtfimport/data/classification-yes.rtf", "com.sun.star.comp.Writer.RtfFilter", xEnd
);
1365 CPPUNIT_ASSERT_EQUAL(aOld
, xText
->getString());
1368 CPPUNIT_TEST_FIXTURE(Test
, testTdf90097
)
1370 createSwDoc("tdf90097.rtf");
1371 // Get the second child of the group shape.
1372 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
1373 uno::Reference
<beans::XPropertySet
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
1374 uno::Sequence
<uno::Sequence
<awt::Point
>> aPolyPolySequence
;
1375 xShape
->getPropertyValue("PolyPolygon") >>= aPolyPolySequence
;
1376 const uno::Sequence
<awt::Point
>& rPolygon
= aPolyPolySequence
[0];
1378 // Vertical flip for the line shape was ignored, so Y coordinates were swapped.
1379 CPPUNIT_ASSERT(rPolygon
[0].Y
> rPolygon
[1].Y
);
1382 CPPUNIT_TEST_FIXTURE(Test
, testTdf91684
)
1384 createSwDoc("tdf91684.rtf");
1385 // Scaling of the group shape children were incorrect, this was 3203.
1386 // (Unit was assumed to be twips, but it was relative coordinates.)
1387 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1337), getShape(1)->getSize().Height
);
1390 CPPUNIT_TEST_FIXTURE(Test
, testFlip
)
1392 createSwDoc("flip.rtf");
1393 comphelper::SequenceAsHashMap aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(
1394 getShapeByName(u
"h-and-v"), "CustomShapeGeometry");
1395 // This resulted in a uno::RuntimeException, as MirroredX wasn't set at all, so could not extract void to boolean.
1396 CPPUNIT_ASSERT_EQUAL(true, aMap
["MirroredX"].get
<bool>());
1397 CPPUNIT_ASSERT_EQUAL(true, aMap
["MirroredY"].get
<bool>());
1399 aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShapeByName(u
"h-only"),
1400 "CustomShapeGeometry");
1401 CPPUNIT_ASSERT_EQUAL(true, aMap
["MirroredX"].get
<bool>());
1402 CPPUNIT_ASSERT(!aMap
["MirroredY"].hasValue());
1404 aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShapeByName(u
"v-only"),
1405 "CustomShapeGeometry");
1406 CPPUNIT_ASSERT(!aMap
["MirroredX"].hasValue());
1407 CPPUNIT_ASSERT_EQUAL(true, aMap
["MirroredY"].get
<bool>());
1409 aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShapeByName(u
"neither-h-nor-v"),
1410 "CustomShapeGeometry");
1411 CPPUNIT_ASSERT(!aMap
["MirroredX"].hasValue());
1412 CPPUNIT_ASSERT(!aMap
["MirroredY"].hasValue());
1415 CPPUNIT_TEST_FIXTURE(Test
, testTdf78506
)
1417 createSwDoc("tdf78506.rtf");
1418 uno::Reference
<beans::XPropertySet
> xPropertySet(
1419 getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
1420 uno::Reference
<container::XIndexAccess
> xLevels(
1421 xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
1422 uno::Sequence
<beans::PropertyValue
> aProps
;
1423 xLevels
->getByIndex(0) >>= aProps
; // 1sd level
1425 for (int i
= 0; i
< aProps
.getLength(); ++i
)
1427 const beans::PropertyValue
& rProp
= aProps
[i
];
1429 if (rProp
.Name
== "Suffix")
1430 // This was '0', invalid \levelnumbers wasn't ignored.
1431 CPPUNIT_ASSERT(rProp
.Value
.get
<OUString
>().isEmpty());
1434 const auto& pLayout
= parseLayoutDump();
1435 // Ensure that there is a tabstop in the pseudo-numbering (numbering::NONE followed by tabstop)
1436 assertXPath(pLayout
, "//SwFixPortion", 1);
1439 CPPUNIT_TEST_FIXTURE(Test
, testTdf117403
)
1441 createSwDoc("tdf117403.rtf");
1442 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1443 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1445 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1446 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1447 CPPUNIT_ASSERT(xCell
.is());
1448 table::BorderLine2
aExpected(static_cast<sal_Int32
>(COL_BLACK
), 0, 4, 0,
1449 table::BorderLineStyle::SOLID
, 4);
1450 // This failed, border was not imported, OuterLineWidth was 0 instead of 4.
1451 CPPUNIT_ASSERT_BORDER_EQUAL(aExpected
, getProperty
<table::BorderLine2
>(xCell
, "BottomBorder"));
1454 CPPUNIT_TEST_FIXTURE(Test
, testImportHeaderFooter
)
1456 createSwDoc("tdf108055.rtf");
1457 // The RTF import sometimes added Header and Footer multiple Times
1458 // as well as added the Header to the document body.
1459 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1460 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(),
1462 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1464 // Check if any Header or Footer text snuck into the TextBody
1465 uno::Reference
<text::XTextRange
> paragraph
= getParagraph(1);
1466 OUString value
= paragraph
->getString();
1467 CPPUNIT_ASSERT_EQUAL(OUString("First Page"), value
);
1469 paragraph
= getParagraph(3);
1470 value
= paragraph
->getString();
1471 CPPUNIT_ASSERT_EQUAL(OUString("Second Page"), value
);
1473 paragraph
= getParagraph(5);
1474 value
= paragraph
->getString();
1475 CPPUNIT_ASSERT_EQUAL(OUString("Third Page"), value
);
1477 //Check if Headers/Footers only contain what they should in this document
1478 uno::Reference
<text::XText
> xHeaderText
= getProperty
<uno::Reference
<text::XText
>>(
1479 getStyles("PageStyles")->getByName("First Page"), "HeaderText");
1480 OUString aActual
= xHeaderText
->getString();
1481 CPPUNIT_ASSERT_EQUAL(OUString("First Page Header"), aActual
);
1483 uno::Reference
<text::XText
> xHeaderTextLeft
= getProperty
<uno::Reference
<text::XText
>>(
1484 getStyles("PageStyles")->getByName("Default Page Style"), "HeaderTextLeft");
1485 aActual
= xHeaderTextLeft
->getString();
1486 CPPUNIT_ASSERT_EQUAL(OUString("Header even"), aActual
);
1488 uno::Reference
<text::XText
> xHeaderTextRight
= getProperty
<uno::Reference
<text::XText
>>(
1489 getStyles("PageStyles")->getByName("Default Page Style"), "HeaderTextRight");
1490 aActual
= xHeaderTextRight
->getString();
1491 CPPUNIT_ASSERT_EQUAL(OUString("Header uneven"), aActual
);
1493 uno::Reference
<text::XText
> xFooterText
= getProperty
<uno::Reference
<text::XText
>>(
1494 getStyles("PageStyles")->getByName("First Page"), "FooterText");
1495 aActual
= xFooterText
->getString();
1496 CPPUNIT_ASSERT_EQUAL(OUString("First Page Footer"), aActual
);
1498 uno::Reference
<text::XText
> xFooterTextLeft
= getProperty
<uno::Reference
<text::XText
>>(
1499 getStyles("PageStyles")->getByName("Default Page Style"), "FooterTextLeft");
1500 aActual
= xFooterTextLeft
->getString();
1501 CPPUNIT_ASSERT_EQUAL(OUString("Footer even"), aActual
);
1503 uno::Reference
<text::XText
> xFooterTextRight
= getProperty
<uno::Reference
<text::XText
>>(
1504 getStyles("PageStyles")->getByName("Default Page Style"), "FooterTextRight");
1505 aActual
= xFooterTextRight
->getString();
1506 CPPUNIT_ASSERT_EQUAL(OUString("Footer uneven"), aActual
);
1509 CPPUNIT_TEST_FIXTURE(Test
, testTdf108947
)
1511 createSwDoc("tdf108947.rtf");
1512 //Check if Headers/Footers contain what they should in this document
1513 uno::Reference
<text::XText
> xHeaderTextRight
= getProperty
<uno::Reference
<text::XText
>>(
1514 getStyles("PageStyles")->getByName("Default Page Style"), "HeaderTextRight");
1515 OUString aActual
= xHeaderTextRight
->getString();
1516 CPPUNIT_ASSERT_EQUAL(OUString(""), aActual
);
1518 //Document is very fragile, hence we need this guard.
1520 uno::Reference
<text::XText
> xHeaderTextLeft
= getProperty
<uno::Reference
<text::XText
>>(
1521 getStyles("PageStyles")->getByName("Default Page Style"), "HeaderTextLeft");
1522 aActual
= xHeaderTextLeft
->getString();
1523 CPPUNIT_ASSERT_EQUAL(OUString(SAL_NEWLINE_STRING SAL_NEWLINE_STRING
"Header Page 2 ?"),
1528 CPPUNIT_TEST_FIXTURE(Test
, testWatermark
)
1530 createSwDoc("watermark.rtf");
1531 Size
aExpectedSize(14965, 7482);
1532 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1533 awt::Size
aActualSize(xShape
->getSize());
1535 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Width()), aActualSize
.Width
);
1536 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Height()), aActualSize
.Height
);
1539 CPPUNIT_TEST_FIXTURE(Test
, testTdf104016
)
1541 createSwDoc("tdf104016.rtf");
1542 uno::Reference
<beans::XPropertyState
> xParagraph(getParagraph(1), uno::UNO_QUERY
);
1543 // This was beans::PropertyState_DIRECT_VALUE, leading to lack of
1544 // inheritance from numbering.
1545 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE
,
1546 xParagraph
->getPropertyState("ParaLeftMargin"));
1549 CPPUNIT_TEST_FIXTURE(Test
, testTdf115242
)
1551 createSwDoc("tdf115242.rtf");
1552 // This was 0, overridden left margin was lost by too aggressive style
1554 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2787),
1555 getProperty
<sal_Int32
>(getParagraph(1), "ParaLeftMargin"));
1558 CPPUNIT_TEST_FIXTURE(Test
, testDefaultValues
)
1560 createSwDoc("default-values.rtf");
1561 // tdf#105910: control words without values must be treated as having default values,
1562 // instead of being silently ignored
1564 uno::Reference
<text::XTextRange
> paragraph
= getParagraph(1);
1566 uno::Reference
<text::XTextRange
> run
= getRun(paragraph
, 1, "scaleWidth50%");
1567 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1568 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1569 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1570 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1571 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1572 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1574 run
= getRun(paragraph
, 2, "scaleWidth100%");
1575 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1576 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1577 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1578 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1579 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1580 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1582 run
= getRun(paragraph
, 3, "fontSize25");
1583 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1584 CPPUNIT_ASSERT_EQUAL(double(25), getProperty
<double>(run
, "CharHeight"));
1585 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1586 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1587 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1588 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1590 run
= getRun(paragraph
, 4, "fontSize12");
1591 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1592 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1593 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1594 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1595 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1596 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1598 run
= getRun(paragraph
, 5, "textDown3pt");
1599 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1600 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1601 CPPUNIT_ASSERT_EQUAL(sal_Int32(-25), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1602 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1603 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1604 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1606 run
= getRun(paragraph
, 6, "textUp3pt");
1607 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1608 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1609 CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1610 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1611 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1612 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1614 run
= getRun(paragraph
, 7, "expand1pt");
1615 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1616 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1617 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1618 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1619 CPPUNIT_ASSERT_EQUAL(sal_Int64(20), o3tl::toTwips(getProperty
<sal_Int16
>(run
, "CharKerning"),
1620 o3tl::Length::mm100
));
1621 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1623 run
= getRun(paragraph
, 8, "expand0pt");
1624 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1625 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1626 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1627 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1628 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1629 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1631 run
= getRun(paragraph
, 9, "expand1pt");
1632 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1633 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1634 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1635 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1636 CPPUNIT_ASSERT_EQUAL(sal_Int64(20), o3tl::toTwips(getProperty
<sal_Int16
>(run
, "CharKerning"),
1637 o3tl::Length::mm100
));
1638 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1640 run
= getRun(paragraph
, 10, "expand0pt");
1641 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1642 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1643 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1644 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1645 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1646 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1648 run
= getRun(paragraph
, 11, "colorBlack");
1649 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1650 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1651 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1652 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1653 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1654 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_BLACK
), getProperty
<sal_Int32
>(run
, "CharColor"));
1656 run
= getRun(paragraph
, 12, "colorRed");
1657 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1658 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1659 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1660 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1661 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1662 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTRED
), getProperty
<sal_Int32
>(run
, "CharColor"));
1664 run
= getRun(paragraph
, 13, "colorGreen");
1665 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1666 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1667 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1668 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1669 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1670 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTGREEN
), getProperty
<sal_Int32
>(run
, "CharColor"));
1672 run
= getRun(paragraph
, 14, "colorBlue");
1673 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1674 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1675 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1676 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1677 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1678 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTBLUE
), getProperty
<sal_Int32
>(run
, "CharColor"));
1680 run
= getRun(paragraph
, 15, "colorAuto");
1681 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, "CharScaleWidth"));
1682 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, "CharHeight"));
1683 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, "CharEscapement"));
1684 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, "CharEscapementHeight"));
1685 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, "CharKerning"));
1686 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, "CharColor"));
1689 CPPUNIT_TEST_FIXTURE(Test
, testParaStyleBottomMargin
)
1691 createSwDoc("para-style-bottom-margin.rtf");
1692 uno::Reference
<beans::XPropertySet
> xPropertySet(
1693 getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY
);
1694 CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty
<sal_Int32
>(xPropertySet
, "ParaBottomMargin"));
1695 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP
,
1696 getProperty
<style::LineSpacing
>(xPropertySet
, "ParaLineSpacing").Mode
);
1697 CPPUNIT_ASSERT_EQUAL(sal_Int16(115),
1698 getProperty
<style::LineSpacing
>(xPropertySet
, "ParaLineSpacing").Height
);
1700 // The reason why this is 0 despite the default style containing \sa200
1701 // is that Word will actually interpret \basedonN
1702 // as "set style N and for every attribute of that style,
1703 // set an attribute with default value on the style"
1704 uno::Reference
<beans::XPropertySet
> xPropertySet1(
1705 getStyles("ParagraphStyles")->getByName("Contents 1"), uno::UNO_QUERY
);
1706 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xPropertySet1
, "ParaBottomMargin"));
1707 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP
,
1708 getProperty
<style::LineSpacing
>(xPropertySet1
, "ParaLineSpacing").Mode
);
1709 CPPUNIT_ASSERT_EQUAL(sal_Int16(100),
1710 getProperty
<style::LineSpacing
>(xPropertySet1
, "ParaLineSpacing").Height
);
1711 auto const xPara(getParagraph(1));
1712 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xPara
, "ParaBottomMargin"));
1713 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP
, // 0 or 3 ???
1714 getProperty
<style::LineSpacing
>(xPara
, "ParaLineSpacing").Mode
);
1715 CPPUNIT_ASSERT_EQUAL(sal_Int16(100),
1716 getProperty
<style::LineSpacing
>(xPara
, "ParaLineSpacing").Height
);
1719 // tests should only be added to rtfIMPORT *if* they fail round-tripping in rtfEXPORT
1721 CPPUNIT_PLUGIN_IMPLEMENT();
1723 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */