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/BorderLine.hpp>
28 #include <com/sun/star/table/BorderLine2.hpp>
29 #include <com/sun/star/table/BorderLineStyle.hpp>
30 #include <com/sun/star/text/RelOrientation.hpp>
31 #include <com/sun/star/text/SizeType.hpp>
32 #include <com/sun/star/text/TableColumnSeparator.hpp>
33 #include <com/sun/star/text/TextContentAnchorType.hpp>
34 #include <com/sun/star/text/XDocumentIndexMark.hpp>
35 #include <com/sun/star/text/XFootnotesSupplier.hpp>
36 #include <com/sun/star/text/XPageCursor.hpp>
37 #include <com/sun/star/text/XTextFramesSupplier.hpp>
38 #include <com/sun/star/text/XTextTablesSupplier.hpp>
39 #include <com/sun/star/text/XTextTable.hpp>
40 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
41 #include <com/sun/star/text/WrapTextMode.hpp>
42 #include <com/sun/star/text/HoriOrientation.hpp>
43 #include <com/sun/star/text/VertOrientation.hpp>
44 #include <com/sun/star/text/XFormField.hpp>
45 #include <com/sun/star/lang/Locale.hpp>
46 #include <com/sun/star/drawing/XShapes.hpp>
47 #include <com/sun/star/text/XTextDocument.hpp>
48 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
49 #include <com/sun/star/beans/XPropertyState.hpp>
50 #include <com/sun/star/document/XDocumentInsertable.hpp>
52 #include <o3tl/cppunittraitshelper.hxx>
53 #include <tools/UnitConversion.hxx>
54 #include <rtl/ustring.hxx>
55 #include <vcl/settings.hxx>
56 #include <comphelper/sequenceashashmap.hxx>
57 #include <comphelper/configuration.hxx>
59 #include <editeng/charhiddenitem.hxx>
61 #include <ndindex.hxx>
63 #include <fmtautofmt.hxx>
67 class Test
: public SwModelTestBase
71 : SwModelTestBase(u
"/sw/qa/extras/rtfimport/data/"_ustr
, u
"Rich Text Format"_ustr
)
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
,
86 getProperty
<sal_Int16
>(xPropertySet
, u
"SizeType"_ustr
));
87 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(300)),
88 getProperty
<sal_Int32
>(xPropertySet
, u
"Height"_ustr
));
90 int nShapes
= getShapes();
91 CPPUNIT_ASSERT_EQUAL(3, nShapes
);
93 bool bFrameFound
= false, bDrawFound
= false;
94 for (int i
= 0; i
< nShapes
; ++i
)
96 uno::Reference
<lang::XServiceInfo
> xServiceInfo(getShape(i
+ 1), uno::UNO_QUERY
);
97 if (xServiceInfo
->supportsService(u
"com.sun.star.text.TextFrame"_ustr
))
99 // Both frames should be anchored to the first paragraph.
101 uno::Reference
<text::XTextContent
> xTextContent(xServiceInfo
, uno::UNO_QUERY
);
102 uno::Reference
<text::XTextRange
> xRange
= xTextContent
->getAnchor();
103 uno::Reference
<text::XText
> xText
= xRange
->getText();
104 CPPUNIT_ASSERT_EQUAL(u
"plain"_ustr
, xText
->getString());
107 // Additionally, the first frame should have double border at the bottom.
108 CPPUNIT_ASSERT_EQUAL(
109 table::BorderLineStyle::DOUBLE
,
110 getProperty
<table::BorderLine2
>(xPropertySet
, u
"BottomBorder"_ustr
).LineStyle
);
112 else if (xServiceInfo
->supportsService(u
"com.sun.star.drawing.LineShape"_ustr
))
114 // The older "drawing objects" syntax should be recognized.
116 xPropertySet
.set(xServiceInfo
, uno::UNO_QUERY
);
117 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
,
118 getProperty
<sal_Int16
>(xPropertySet
, u
"HoriOrientRelation"_ustr
));
119 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
120 getProperty
<sal_Int16
>(xPropertySet
, u
"VertOrientRelation"_ustr
));
123 CPPUNIT_ASSERT(bFrameFound
);
124 CPPUNIT_ASSERT(bDrawFound
);
127 CPPUNIT_TEST_FIXTURE(Test
, testTdf117246
)
129 createSwDoc("tdf117246.rtf");
130 // This was 2, all but the last \page was lost.
131 CPPUNIT_ASSERT_EQUAL(3, getPages());
134 CPPUNIT_TEST_FIXTURE(Test
, testTdf108943
)
136 createSwDoc("tdf108943.rtf");
137 uno::Reference
<beans::XPropertySet
> xPropertySet(
138 getStyles(u
"NumberingStyles"_ustr
)->getByName(u
"WWNum1"_ustr
), uno::UNO_QUERY
);
139 uno::Reference
<container::XIndexAccess
> xLevels(
140 xPropertySet
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
141 uno::Sequence
<beans::PropertyValue
> aProps
;
142 xLevels
->getByIndex(0) >>= aProps
; // 1st level
144 sal_Int32 nListtabStopPosition
= 0;
145 for (int i
= 0; i
< aProps
.getLength(); ++i
)
147 const beans::PropertyValue
& rProp
= aProps
[i
];
149 if (rProp
.Name
== "ListtabStopPosition")
150 nListtabStopPosition
= rProp
.Value
.get
<sal_Int32
>();
152 // This was 0, \tx was handled in paragraphs only (and not in list definitions).
153 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1270), nListtabStopPosition
);
156 CPPUNIT_TEST_FIXTURE(Test
, testFdo46662
)
158 createSwDoc("fdo46662.rtf");
163 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
164 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0),
165 getProperty
<sal_Int16
>(xPara
, u
"NumberingLevel"_ustr
));
166 CPPUNIT_ASSERT(xPara
->getPropertyValue(u
"NumberingStyleName"_ustr
) >>= listStyle
);
167 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
168 CPPUNIT_ASSERT_EQUAL(u
"1"_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
172 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(2), uno::UNO_QUERY
);
173 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1),
174 getProperty
<sal_Int16
>(xPara
, u
"NumberingLevel"_ustr
));
175 CPPUNIT_ASSERT(xPara
->getPropertyValue(u
"NumberingStyleName"_ustr
) >>= listStyle
);
176 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
177 CPPUNIT_ASSERT_EQUAL(u
"1.1"_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
181 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(3), uno::UNO_QUERY
);
182 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(2),
183 getProperty
<sal_Int16
>(xPara
, u
"NumberingLevel"_ustr
));
184 CPPUNIT_ASSERT(xPara
->getPropertyValue(u
"NumberingStyleName"_ustr
) >>= listStyle
);
185 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
186 CPPUNIT_ASSERT_EQUAL(u
"1.1.1"_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
190 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(4), uno::UNO_QUERY
);
191 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(3),
192 getProperty
<sal_Int16
>(xPara
, u
"NumberingLevel"_ustr
));
193 CPPUNIT_ASSERT(xPara
->getPropertyValue(u
"NumberingStyleName"_ustr
) >>= listStyle
);
194 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
195 CPPUNIT_ASSERT_EQUAL(u
"1.1.1.1"_ustr
,
196 getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
200 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(5), uno::UNO_QUERY
);
201 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0),
202 getProperty
<sal_Int16
>(xPara
, u
"NumberingLevel"_ustr
));
203 CPPUNIT_ASSERT(xPara
->getPropertyValue(u
"NumberingStyleName"_ustr
) >>= listStyle
);
204 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
205 CPPUNIT_ASSERT_EQUAL(u
"2"_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
209 CPPUNIT_TEST_FIXTURE(Test
, testTdf115715
)
211 createSwDoc("tdf115715.rtf");
212 // This was 0, second paragraph was shifted to the right, it had the same
213 // horizontal position as the 3rd paragraph.
214 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-1270),
215 getProperty
<sal_Int32
>(getParagraph(2), u
"ParaFirstLineIndent"_ustr
));
218 CPPUNIT_TEST_FIXTURE(Test
, testTdf81943
)
220 createSwDoc("tdf81943.rtf");
221 // The shape wasn't in background.
222 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(getShape(1), u
"Opaque"_ustr
));
225 CPPUNIT_TEST_FIXTURE(Test
, testTdf115155
)
227 createSwDoc("tdf115155.rtf");
228 auto xLevels
= getProperty
<uno::Reference
<container::XIndexAccess
>>(getParagraph(2),
229 u
"NumberingRules"_ustr
);
231 comphelper::SequenceAsHashMap
aMap(xLevels
->getByIndex(0));
232 // This was 1270: the left margin in the numbering rule was too small.
233 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2540), aMap
[u
"IndentAt"_ustr
].get
<sal_Int32
>());
236 CPPUNIT_TEST_FIXTURE(Test
, testTdf108951
)
238 createSwDoc("tdf108951.rtf");
239 // This test is import-only, as we assert the list ID, which is OK to
240 // re-order on export, but then this test would not pass anymore.
242 // \ls2 was imported as WWNum1.
243 CPPUNIT_ASSERT_EQUAL(u
"WWNum2"_ustr
,
244 getProperty
<OUString
>(getParagraph(1), u
"NumberingStyleName"_ustr
));
247 CPPUNIT_TEST_FIXTURE(Test
, testFdo47036
)
249 createSwDoc("fdo47036.rtf");
251 int nShapes
= getShapes();
252 CPPUNIT_ASSERT_EQUAL(3, nShapes
);
253 int nAtCharacter
= 0;
254 for (int i
= 0; i
< nShapes
; ++i
)
256 if (getProperty
<text::TextContentAnchorType
>(getShape(i
+ 1), u
"AnchorType"_ustr
)
257 == text::TextContentAnchorType_AT_CHARACTER
)
260 // The image at the document start was ignored.
261 CPPUNIT_ASSERT_EQUAL(1, nAtCharacter
);
263 // There should be 2 textboxes, not 4
264 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
265 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(),
267 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
270 CPPUNIT_TEST_FIXTURE(Test
, testFdo45182
)
272 createSwDoc("fdo45182.rtf");
273 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
274 uno::Reference
<container::XIndexAccess
> xFootnotes
= xFootnotesSupplier
->getFootnotes();
275 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
276 // Encoding in the footnote was wrong.
277 CPPUNIT_ASSERT_EQUAL(u
"\u017Eivnost\u00ED" SAL_NEWLINE_STRING
""_ustr
, xTextRange
->getString());
280 CPPUNIT_TEST_FIXTURE(Test
, testFdo85812
)
282 createSwDoc("fdo85812.rtf");
284 getProperty
<lang::Locale
>(getRun(getParagraph(1), 1, u
"This "_ustr
), u
"CharLocale"_ustr
));
285 // the \lang inside the group was applied to CJK not Western
286 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
287 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
288 // further testing indicates that Word is doing really weird stuff
289 // \loch \hich \dbch is reset by opening a group
290 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(2), 1, u
"CharGroup"_ustr
),
292 CPPUNIT_ASSERT_EQUAL(u
"ru"_ustr
, locale
.Language
);
293 CPPUNIT_ASSERT_EQUAL(u
"RU"_ustr
, locale
.Country
);
294 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(2), 2, u
"AfterChar"_ustr
),
296 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
297 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
298 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(3), 2, u
"AfterBookmark"_ustr
),
300 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
301 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
302 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 1, u
"CharGroup"_ustr
),
304 CPPUNIT_ASSERT_EQUAL(u
"ru"_ustr
, locale
.Language
);
305 CPPUNIT_ASSERT_EQUAL(u
"RU"_ustr
, locale
.Country
);
306 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 1, u
"CharGroup"_ustr
),
307 u
"CharLocaleComplex"_ustr
);
308 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
309 CPPUNIT_ASSERT_EQUAL(u
"DZ"_ustr
, locale
.Country
);
310 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 2, u
"AfterChar"_ustr
),
312 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
313 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
314 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 2, u
"AfterChar"_ustr
),
315 u
"CharLocaleComplex"_ustr
);
316 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
317 CPPUNIT_ASSERT_EQUAL(u
"DZ"_ustr
, locale
.Country
);
318 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(5), 2, u
"AfterBookmark"_ustr
),
320 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
321 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
322 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(5), 2, u
"AfterBookmark"_ustr
),
323 u
"CharLocaleComplex"_ustr
);
324 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
325 CPPUNIT_ASSERT_EQUAL(u
"DZ"_ustr
, locale
.Country
);
326 // \ltrch \rtlch works differently - it is sticky across groups
327 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 1, u
"CharGroup"_ustr
),
329 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
330 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
331 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 1, u
"CharGroup"_ustr
),
332 u
"CharLocaleComplex"_ustr
);
333 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
334 CPPUNIT_ASSERT_EQUAL(u
"DZ"_ustr
, locale
.Country
);
335 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 2, u
"AfterChar"_ustr
),
337 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
338 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
339 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 2, u
"AfterChar"_ustr
),
340 u
"CharLocaleComplex"_ustr
);
341 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
342 CPPUNIT_ASSERT_EQUAL(u
"EG"_ustr
, locale
.Country
);
343 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(7), 2, u
"AfterBookmark"_ustr
),
345 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
346 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
347 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(7), 2, u
"AfterBookmark"_ustr
),
348 u
"CharLocaleComplex"_ustr
);
349 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
350 CPPUNIT_ASSERT_EQUAL(u
"EG"_ustr
, locale
.Country
);
353 CPPUNIT_TEST_FIXTURE(Test
, testFdo49692
)
355 createSwDoc("fdo49692.rtf");
356 uno::Reference
<beans::XPropertySet
> xPropertySet(
357 getStyles(u
"NumberingStyles"_ustr
)->getByName(u
"WWNum1"_ustr
), uno::UNO_QUERY
);
358 uno::Reference
<container::XIndexAccess
> xLevels(
359 xPropertySet
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
360 uno::Sequence
<beans::PropertyValue
> aProps
;
361 xLevels
->getByIndex(0) >>= aProps
; // 1st level
363 for (int i
= 0; i
< aProps
.getLength(); ++i
)
365 const beans::PropertyValue
& rProp
= aProps
[i
];
367 if (rProp
.Name
== "Suffix")
369 CPPUNIT_ASSERT(rProp
.Value
.get
<OUString
>().isEmpty());
374 CPPUNIT_TEST_FIXTURE(Test
, testFdo45190
)
376 createSwDoc("fdo45190.rtf");
377 // inherited \fi should be reset
378 CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
379 getProperty
<sal_Int32
>(getParagraph(1), u
"ParaFirstLineIndent"_ustr
));
381 // but direct one not
382 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-100)),
383 getProperty
<sal_Int32
>(getParagraph(2), u
"ParaFirstLineIndent"_ustr
));
386 CPPUNIT_TEST_FIXTURE(Test
, testTdf59699
)
388 createSwDoc("tdf59699.rtf");
389 // This resulted in a lang.IndexOutOfBoundsException: the referenced graphic data wasn't imported.
390 uno::Reference
<beans::XPropertySet
> xImage(getShape(1), uno::UNO_QUERY
);
391 auto xGraphic
= getProperty
<uno::Reference
<graphic::XGraphic
>>(xImage
, u
"Graphic"_ustr
);
392 CPPUNIT_ASSERT(xGraphic
.is());
395 CPPUNIT_TEST_FIXTURE(Test
, testFdo52066
)
397 createSwDoc("fdo52066.rtf");
399 * The problem was that the height of the shape was too big.
401 * xray ThisComponent.DrawPage(0).Size.Height
403 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
404 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(19)), xShape
->getSize().Height
);
407 CPPUNIT_TEST_FIXTURE(Test
, testTdf112211_2
)
409 createSwDoc("tdf112211-2.rtf");
410 // Spacing between the bullet and the actual text was too large.
411 // This is now around 269, large old value was 629.
412 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
413 int nWidth
= getXPath(pXmlDoc
,
414 "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/"
415 "child::*[@type='PortionType::TabLeft']"_ostr
,
418 CPPUNIT_ASSERT_LESS(300, nWidth
);
421 CPPUNIT_TEST_FIXTURE(Test
, testTdf122430
)
423 createSwDoc("tdf122430.rtf");
424 // Without the accompanying fix in place, this test would have failed with
425 // 'Expected: 18, Actual : 12', i.e. the font was smaller than expected.
426 CPPUNIT_ASSERT_EQUAL(18.0f
, getProperty
<float>(getRun(getParagraph(1), 2), u
"CharHeight"_ustr
));
429 CPPUNIT_TEST_FIXTURE(Test
, testFdo49892
)
431 createSwDoc("fdo49892.rtf");
432 int nShapes
= getShapes();
433 CPPUNIT_ASSERT_EQUAL(5, nShapes
);
434 for (int i
= 0; i
< nShapes
; ++i
)
436 OUString aDescription
= getProperty
<OUString
>(getShape(i
+ 1), u
"Description"_ustr
);
437 if (aDescription
== "red")
438 CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
439 getProperty
<sal_Int32
>(getShape(i
+ 1), u
"ZOrder"_ustr
));
440 else if (aDescription
== "green")
441 CPPUNIT_ASSERT_EQUAL(sal_Int32(1),
442 getProperty
<sal_Int32
>(getShape(i
+ 1), u
"ZOrder"_ustr
));
443 else if (aDescription
== "blue")
444 CPPUNIT_ASSERT_EQUAL(sal_Int32(2),
445 getProperty
<sal_Int32
>(getShape(i
+ 1), u
"ZOrder"_ustr
));
446 else if (aDescription
== "rect")
448 CPPUNIT_ASSERT_EQUAL(
449 text::RelOrientation::PAGE_FRAME
,
450 getProperty
<sal_Int16
>(getShape(i
+ 1), u
"HoriOrientRelation"_ustr
));
451 CPPUNIT_ASSERT_EQUAL(
452 text::RelOrientation::PAGE_FRAME
,
453 getProperty
<sal_Int16
>(getShape(i
+ 1), u
"VertOrientRelation"_ustr
));
458 CPPUNIT_TEST_FIXTURE(Test
, testFdo52052
)
460 createSwDoc("fdo52052.rtf");
461 // Make sure the textframe containing the text "third" appears on the 3rd page.
462 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
463 CPPUNIT_ASSERT_EQUAL(
465 getXPathContent(pXmlDoc
, "/root/page[3]/body/txt/anchored/fly/txt/text()"_ostr
));
468 CPPUNIT_TEST_FIXTURE(Test
, testInk
)
470 createSwDoc("ink.rtf");
472 * The problem was that the second segment had wrong command count and wrap type.
474 * oShape = ThisComponent.DrawPage(0)
475 * oPathPropVec = oShape.CustomShapeGeometry(1).Value
476 * oSegments = oPathPropVec(1).Value
477 * msgbox oSegments(1).Count ' was 0x2000 | 10, should be 10
478 * msgbox oShape.Surround ' was 2, should be 1
480 uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(
481 getShape(1), u
"CustomShapeGeometry"_ustr
);
482 uno::Sequence
<beans::PropertyValue
> aPathProps
;
483 for (int i
= 0; i
< aProps
.getLength(); ++i
)
485 const beans::PropertyValue
& rProp
= aProps
[i
];
486 if (rProp
.Name
== "Path")
487 rProp
.Value
>>= aPathProps
;
489 uno::Sequence
<drawing::EnhancedCustomShapeSegment
> aSegments
;
490 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
492 const beans::PropertyValue
& rProp
= aPathProps
[i
];
493 if (rProp
.Name
== "Segments")
494 rProp
.Value
>>= aSegments
;
496 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aSegments
[1].Count
);
497 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
498 getProperty
<text::WrapTextMode
>(getShape(1), u
"Surround"_ustr
));
501 CPPUNIT_TEST_FIXTURE(Test
, testFdo79319
)
503 createSwDoc("fdo79319.rtf");
504 // the thin horizontal rule was imported as a big fat rectangle
505 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
506 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(xShape
, u
"RelativeWidth"_ustr
));
507 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(16508), xShape
->getSize().Width
, 10);
508 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(53), xShape
->getSize().Height
, 10);
510 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER
, getProperty
<sal_Int16
>(xShape
, "VertOrient"));
511 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER
, getProperty
<sal_Int16
>(xShape
, "HoriOrient"));
515 CPPUNIT_TEST_FIXTURE(Test
, testFdo48442
)
517 createSwDoc("fdo48442.rtf");
518 // The problem was that \pvmrg is the default in RTF, but not in Writer.
519 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
520 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
,
521 getProperty
<sal_Int16
>(xShape
, u
"VertOrientRelation"_ustr
)); // was FRAME
524 CPPUNIT_TEST_FIXTURE(Test
, testFdo55525
)
526 createSwDoc("fdo55525.rtf");
527 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
528 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
530 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
531 // Negative left margin was ~missing, -191
532 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty
<sal_Int32
>(xTable
, u
"LeftMargin"_ustr
));
533 // Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
534 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
535 CPPUNIT_ASSERT_EQUAL(sal_Int16(896),
536 getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
537 xTableRows
->getByIndex(0), u
"TableColumnSeparators"_ustr
)[0]
541 CPPUNIT_TEST_FIXTURE(Test
, testFdo57708
)
543 createSwDoc("fdo57708.rtf");
544 // There were two issues: the doc was of 2 pages and the picture was missing.
545 CPPUNIT_ASSERT_EQUAL(1, getPages());
546 // Two objects: a picture and a textframe.
547 CPPUNIT_ASSERT_EQUAL(2, getShapes());
550 CPPUNIT_TEST_FIXTURE(Test
, testFdo45183
)
552 createSwDoc("fdo45183.rtf");
553 // Was text::WrapTextMode_PARALLEL, i.e. shpfblwtxt didn't send the shape below text.
554 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
555 getProperty
<text::WrapTextMode
>(getShape(1), u
"Surround"_ustr
));
557 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
558 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
560 // Was 247, resulting in a table having width almost zero and height of 10+ pages.
561 CPPUNIT_ASSERT_EQUAL(sal_Int32(16237),
562 getProperty
<sal_Int32
>(xTables
->getByIndex(0), u
"Width"_ustr
));
565 CPPUNIT_TEST_FIXTURE(Test
, testFdo59953
)
567 createSwDoc("fdo59953.rtf");
568 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
569 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
571 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
572 // Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width)
573 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
574 CPPUNIT_ASSERT_EQUAL(sal_Int16(7649),
575 getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
576 xTableRows
->getByIndex(0), u
"TableColumnSeparators"_ustr
)[0]
580 CPPUNIT_TEST_FIXTURE(Test
, testTdf84684
)
582 createSwDoc("tdf84684.rtf");
583 // The ZOrder of the two children of the group shape were swapped.
584 uno::Reference
<drawing::XShapes
> xGroup(getShape(1), uno::UNO_QUERY
);
585 uno::Reference
<container::XNamed
> xChild1(xGroup
->getByIndex(0), uno::UNO_QUERY
);
587 CPPUNIT_ASSERT_EQUAL(u
"Rectangle 1"_ustr
, xChild1
->getName());
588 uno::Reference
<container::XNamed
> xChild2(xGroup
->getByIndex(1), uno::UNO_QUERY
);
589 // This was Rectangle 1.
590 CPPUNIT_ASSERT_EQUAL(u
"Pie 2"_ustr
, xChild2
->getName());
593 CPPUNIT_TEST_FIXTURE(Test
, testFdo81944
)
595 createSwDoc("fdo81944.rtf");
596 // font properties in style were not imported
597 uno::Reference
<beans::XPropertySet
> xPropertySet(
598 getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Standard"_ustr
), uno::UNO_QUERY
);
599 uno::Reference
<style::XStyle
> xStyle(xPropertySet
, uno::UNO_QUERY
);
600 CPPUNIT_ASSERT_EQUAL(u
"Segoe UI"_ustr
, getProperty
<OUString
>(xStyle
, u
"CharFontName"_ustr
));
601 CPPUNIT_ASSERT_EQUAL(9.0f
, getProperty
<float>(xStyle
, u
"CharHeight"_ustr
));
602 // not sure if this should be set on Asian or Complex or both?
603 CPPUNIT_ASSERT_EQUAL(u
"Times New Roman"_ustr
,
604 getProperty
<OUString
>(xStyle
, u
"CharFontNameComplex"_ustr
));
605 CPPUNIT_ASSERT_EQUAL(11.0f
, getProperty
<float>(xStyle
, u
"CharHeightComplex"_ustr
));
608 CPPUNIT_TEST_FIXTURE(Test
, testSbkodd
)
610 createSwDoc("sbkodd.rtf");
611 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
612 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(
613 xModel
->getCurrentController(), uno::UNO_QUERY
);
614 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(),
616 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), xCursor
->getPage());
617 xCursor
->jumpToNextPage();
618 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(3), xCursor
->getPage());
621 CPPUNIT_TEST_FIXTURE(Test
, testSbkeven
)
623 createSwDoc("sbkeven.rtf");
624 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
625 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(
626 xModel
->getCurrentController(), uno::UNO_QUERY
);
627 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(),
629 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), xCursor
->getPage());
630 xCursor
->jumpToNextPage();
631 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(2), xCursor
->getPage());
632 xCursor
->jumpToNextPage();
633 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(4), xCursor
->getPage());
636 CPPUNIT_TEST_FIXTURE(Test
, testPoshPosv
)
638 createSwDoc("posh-posv.rtf");
639 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER
,
640 getProperty
<sal_Int16
>(getShape(1), u
"HoriOrient"_ustr
));
641 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER
,
642 getProperty
<sal_Int16
>(getShape(1), u
"VertOrient"_ustr
));
643 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getShape(1), u
"FrameIsAutomaticHeight"_ustr
));
646 CPPUNIT_TEST_FIXTURE(Test
, testPoshLeftRight
)
648 createSwDoc("posh-leftright.rtf");
649 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT
,
650 getProperty
<sal_Int16
>(getShape(1), u
"HoriOrient"_ustr
));
651 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::LEFT
,
652 getProperty
<sal_Int16
>(getShape(2), u
"HoriOrient"_ustr
));
655 CPPUNIT_TEST_FIXTURE(Test
, testTdf96326
)
657 createSwDoc("tdf96326.rtf");
658 // Make sure this is not checked.
659 auto xFormField
= getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(1), 2),
661 uno::Reference
<container::XNameContainer
> xParameters
= xFormField
->getParameters();
662 // This was true, ffres=25 was interpreted as checked.
663 CPPUNIT_ASSERT_EQUAL(false, bool(xParameters
->hasElements()));
665 // And this is checked.
666 xFormField
= getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(2), 2),
668 xParameters
= xFormField
->getParameters();
669 CPPUNIT_ASSERT_EQUAL(true, xParameters
->getByName(u
"Checkbox_Checked"_ustr
).get
<bool>());
672 CPPUNIT_TEST_FIXTURE(Test
, testN823655
)
674 createSwDoc("n823655.rtf");
675 uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(
676 getShape(1), u
"CustomShapeGeometry"_ustr
);
677 uno::Sequence
<beans::PropertyValue
> aPathProps
;
678 for (int i
= 0; i
< aProps
.getLength(); ++i
)
680 const beans::PropertyValue
& rProp
= aProps
[i
];
681 if (rProp
.Name
== "Path")
682 aPathProps
= rProp
.Value
.get
<uno::Sequence
<beans::PropertyValue
>>();
684 uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> aCoordinates
;
685 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
687 const beans::PropertyValue
& rProp
= aPathProps
[i
];
688 if (rProp
.Name
== "Coordinates")
690 = rProp
.Value
.get
<uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
>>();
692 // The first coordinate pair of this freeform shape was 286,0 instead of 0,286.
693 CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates
[0].Second
.Value
.get
<sal_Int32
>());
696 CPPUNIT_TEST_FIXTURE(Test
, testN823675
)
698 createSwDoc("n823675.rtf");
699 uno::Reference
<beans::XPropertySet
> xPropertySet(
700 getStyles(u
"NumberingStyles"_ustr
)->getByName(u
"WWNum1"_ustr
), uno::UNO_QUERY
);
701 uno::Reference
<container::XIndexAccess
> xLevels(
702 xPropertySet
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
703 uno::Sequence
<beans::PropertyValue
> aProps
;
704 xLevels
->getByIndex(0) >>= aProps
; // 1st level
705 awt::FontDescriptor aFont
;
707 for (int i
= 0; i
< aProps
.getLength(); ++i
)
709 const beans::PropertyValue
& rProp
= aProps
[i
];
711 if (rProp
.Name
== "BulletFont")
712 aFont
= rProp
.Value
.get
<awt::FontDescriptor
>();
714 // This was empty, i.e. no font name was set for the bullet numbering.
715 CPPUNIT_ASSERT_EQUAL(u
"Symbol"_ustr
, aFont
.Name
);
718 CPPUNIT_TEST_FIXTURE(Test
, testGroupshape
)
720 createSwDoc("groupshape.rtf");
721 // There should be a single groupshape with 2 children.
722 CPPUNIT_ASSERT_EQUAL(1, getShapes());
723 uno::Reference
<drawing::XShapes
> xGroupshape(getShape(1), uno::UNO_QUERY
);
724 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape
->getCount());
727 CPPUNIT_TEST_FIXTURE(Test
, testGroupshape_notext
)
729 createSwDoc("groupshape-notext.rtf");
730 // There should be a single groupshape with 2 children.
731 CPPUNIT_ASSERT_EQUAL(1, getShapes());
732 uno::Reference
<drawing::XShapes
> xGroupshape(getShape(1), uno::UNO_QUERY
);
733 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape
->getCount());
736 CPPUNIT_TEST_FIXTURE(Test
, testFdo81033
)
738 createSwDoc("fdo81033.rtf");
739 // Number of tabstops in the paragraph should be 2, was 3.
740 uno::Sequence
<style::TabStop
> tabs(
741 getProperty
<uno::Sequence
<style::TabStop
>>(getParagraph(1), u
"ParaTabStops"_ustr
));
742 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabs
.getLength());
743 CPPUNIT_ASSERT_EQUAL(sal_Int32(5808), tabs
[0].Position
);
744 CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT
, tabs
[0].Alignment
);
745 CPPUNIT_ASSERT_EQUAL(u
' ', tabs
[0].FillChar
);
746 CPPUNIT_ASSERT_EQUAL(sal_Int32(16002), tabs
[1].Position
);
747 CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT
, tabs
[1].Alignment
);
748 CPPUNIT_ASSERT_EQUAL(u
'_', tabs
[1].FillChar
);
751 CPPUNIT_TEST_FIXTURE(Test
, testTdf116269
)
753 createSwDoc("tdf116269.rtf");
754 // This was 2540, implicit 0 left margin was ignored on import (inherited
755 // value from list definition is repeated if it's not 0).
756 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0),
757 getProperty
<sal_Int32
>(getParagraph(1), u
"ParaLeftMargin"_ustr
));
760 CPPUNIT_TEST_FIXTURE(Test
, testTdf116265
)
762 createSwDoc("tdf116265.rtf");
763 // This was -635, \fi as direct formatting has to be ignored due to
764 // matching \fi in list definition (and with invalid level numbers).
765 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0),
766 getProperty
<sal_Int32
>(getParagraph(2), u
"ParaFirstLineIndent"_ustr
));
768 xmlDocUniquePtr pLayout
= parseLayoutDump();
769 // Ensure that there is a tabstop in the pseudo-numbering (numbering::NONE followed by tabstop)
770 assertXPath(pLayout
, "//SwFixPortion"_ostr
, 1);
773 CPPUNIT_TEST_FIXTURE(Test
, testFdo66565
)
775 createSwDoc("fdo66565.rtf");
776 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
777 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
779 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
780 // Cell width of A2 was 554, should be 453/14846*10000
781 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
782 CPPUNIT_ASSERT_EQUAL(sal_Int16(304),
783 getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
784 xTableRows
->getByIndex(1), u
"TableColumnSeparators"_ustr
)[0]
788 CPPUNIT_TEST_FIXTURE(Test
, testFdo67365
)
790 createSwDoc("fdo67365.rtf");
791 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
792 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
794 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
795 uno::Reference
<table::XTableRows
> xRows
= xTable
->getRows();
796 // The table only had 3 rows.
797 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xRows
->getCount());
798 // This was 4999, i.e. the two cells of the row had equal widths instead of a larger and a smaller cell.
799 CPPUNIT_ASSERT_EQUAL(sal_Int16(5290),
800 getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
801 xRows
->getByIndex(2), u
"TableColumnSeparators"_ustr
)[0]
803 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName(u
"A2"_ustr
), uno::UNO_QUERY
);
804 // Paragraph was aligned to center, should be left.
805 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT
,
806 static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(
807 getParagraphOfText(1, xCell
->getText()), u
"ParaAdjust"_ustr
)));
810 CPPUNIT_TEST_FIXTURE(Test
, testFdo47440
)
812 createSwDoc("fdo47440.rtf");
813 // Vertical and horizontal orientation of the picture wasn't imported (was text::RelOrientation::FRAME).
814 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
815 getProperty
<sal_Int16
>(getShape(1), u
"HoriOrientRelation"_ustr
));
816 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
817 getProperty
<sal_Int16
>(getShape(1), u
"VertOrientRelation"_ustr
));
820 CPPUNIT_TEST_FIXTURE(Test
, testFdo53556
)
822 createSwDoc("fdo53556.rtf");
823 // This was drawing::FillStyle_SOLID, which resulted in being non-transparent, hiding text which would be visible.
824 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
,
825 getProperty
<drawing::FillStyle
>(getShape(3), u
"FillStyle"_ustr
));
827 // This was a com.sun.star.drawing.CustomShape, which resulted in lack of word wrapping in the bugdoc.
828 uno::Reference
<beans::XPropertySet
> xShapeProperties(getShape(1), uno::UNO_QUERY
);
829 uno::Reference
<drawing::XShapeDescriptor
> xShapeDescriptor(xShapeProperties
, uno::UNO_QUERY
);
830 CPPUNIT_ASSERT_EQUAL(u
"FrameShape"_ustr
, xShapeDescriptor
->getShapeType());
833 CPPUNIT_TEST_FIXTURE(Test
, testGroupshapeRotation
)
835 createSwDoc("groupshape-rotation.rtf");
836 // Rotation on groupshapes wasn't handled correctly, RotateAngle was 4500.
837 CPPUNIT_ASSERT_EQUAL(sal_Int32(315 * 100),
838 getProperty
<sal_Int32
>(getShape(1), u
"RotateAngle"_ustr
));
841 CPPUNIT_TEST_FIXTURE(Test
, testTdf115153
)
843 createSwDoc("tdf115153.rtf");
844 auto const xShape(getShape(1));
845 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::NONE
,
846 getProperty
<sal_Int16
>(xShape
, u
"HoriOrient"_ustr
));
847 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
848 getProperty
<sal_Int16
>(xShape
, u
"HoriOrientRelation"_ustr
));
849 CPPUNIT_ASSERT_EQUAL(sal_Int32(2533),
850 getProperty
<sal_Int32
>(xShape
, u
"HoriOrientPosition"_ustr
));
851 // VertOrient was wrong
852 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::NONE
,
853 getProperty
<sal_Int16
>(xShape
, u
"VertOrient"_ustr
));
854 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
855 getProperty
<sal_Int16
>(xShape
, u
"VertOrientRelation"_ustr
));
856 CPPUNIT_ASSERT_EQUAL(sal_Int32(2131),
857 getProperty
<sal_Int32
>(xShape
, u
"VertOrientPosition"_ustr
));
860 CPPUNIT_TEST_FIXTURE(Test
, testFdo68291
)
862 createSwDoc("fdo68291.odt");
863 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
864 uno::Reference
<text::XTextRange
> xText
= xTextDocument
->getText();
865 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
866 paste(u
"rtfimport/data/fdo68291-paste.rtf", u
"com.sun.star.comp.Writer.RtfFilter"_ustr
, xEnd
);
868 // This was "Standard", causing an unwanted page break on next paste.
869 CPPUNIT_ASSERT_EQUAL(uno::Any(),
870 uno::Reference
<beans::XPropertySet
>(getParagraph(1), uno::UNO_QUERY_THROW
)
871 ->getPropertyValue(u
"PageDescName"_ustr
));
874 CPPUNIT_TEST_FIXTURE(Test
, testTdf105511
)
876 struct DefaultLocale
: public comphelper::ConfigurationProperty
<DefaultLocale
, OUString
>
878 static OUString
path()
880 return u
"/org.openoffice.Office.Linguistic/General/DefaultLocale"_ustr
;
882 ~DefaultLocale() = delete;
884 auto batch
= comphelper::ConfigurationChanges::create();
885 DefaultLocale::set(u
"ru-RU"_ustr
, batch
);
887 createSwDoc("tdf105511.rtf");
888 getParagraph(1, u
"\u0418\u043C\u044F"_ustr
);
891 CPPUNIT_TEST_FIXTURE(Test
, testContSectionPageBreak
)
893 createSwDoc("cont-section-pagebreak.rtf");
894 uno::Reference
<text::XTextRange
> xParaSecond
= getParagraph(2);
895 CPPUNIT_ASSERT_EQUAL(u
"SECOND"_ustr
, xParaSecond
->getString());
896 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
897 getProperty
<style::BreakType
>(xParaSecond
, u
"BreakType"_ustr
));
898 CPPUNIT_ASSERT_EQUAL(uno::Any(),
899 uno::Reference
<beans::XPropertySet
>(xParaSecond
, uno::UNO_QUERY_THROW
)
900 ->getPropertyValue(u
"PageDescName"_ustr
));
901 // actually not sure how many paragraph there should be between
902 // SECOND and THIRD - important is that the page break is on there
903 // (could be either 1 or 2; in Word it's a 2-line paragraph with the 1st
904 // line containing only the page break being ~0 height)
905 uno::Reference
<text::XTextRange
> xParaNext
= getParagraph(3);
906 CPPUNIT_ASSERT_EQUAL(OUString(), xParaNext
->getString());
907 //If PageDescName is not empty, a page break / switch to page style is defined
908 CPPUNIT_ASSERT(uno::Any() != getProperty
<OUString
>(xParaNext
, u
"PageDescName"_ustr
));
909 uno::Reference
<text::XTextRange
> xParaThird
= getParagraph(4);
910 CPPUNIT_ASSERT_EQUAL(u
"THIRD"_ustr
, xParaThird
->getString());
911 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
912 getProperty
<style::BreakType
>(xParaThird
, u
"BreakType"_ustr
));
913 CPPUNIT_ASSERT_EQUAL(uno::Any(),
914 uno::Reference
<beans::XPropertySet
>(xParaThird
, uno::UNO_QUERY_THROW
)
915 ->getPropertyValue(u
"PageDescName"_ustr
));
916 // there is an empty paragraph after THIRD
917 uno::Reference
<text::XTextRange
> xParaLast
= getParagraph(5);
918 CPPUNIT_ASSERT_EQUAL(OUString(), xParaLast
->getString());
923 catch (container::NoSuchElementException
const&)
925 // does not exist - expected
928 CPPUNIT_ASSERT_EQUAL(2, getPages());
931 CPPUNIT_TEST_FIXTURE(Test
, testSectionPageBreak
)
933 createSwDoc("section-pagebreak.rtf");
934 uno::Reference
<text::XTextRange
> xParaSecond
= getParagraph(2);
935 CPPUNIT_ASSERT_EQUAL(u
"SECOND"_ustr
, xParaSecond
->getString());
936 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
937 getProperty
<style::BreakType
>(xParaSecond
, u
"BreakType"_ustr
));
938 CPPUNIT_ASSERT(uno::Any() != getProperty
<OUString
>(xParaSecond
, u
"PageDescName"_ustr
));
939 // actually not sure how many paragraph there should be between
940 // SECOND and THIRD - important is that the page break is on there
941 // (could be either 1 or 2; in Word it's a 2-line paragraph with the 1st
942 // line containing only the page break being ~0 height)
943 uno::Reference
<text::XTextRange
> xParaNext
= getParagraph(3);
944 CPPUNIT_ASSERT_EQUAL(OUString(), xParaNext
->getString());
945 //If PageDescName is not empty, a page break / switch to page style is defined
946 CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE
,
947 getProperty
<style::BreakType
>(xParaNext
, u
"BreakType"_ustr
));
948 uno::Reference
<text::XTextRange
> xParaThird
= getParagraph(4);
949 CPPUNIT_ASSERT_EQUAL(u
"THIRD"_ustr
, xParaThird
->getString());
950 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
951 getProperty
<style::BreakType
>(xParaThird
, u
"BreakType"_ustr
));
952 CPPUNIT_ASSERT(uno::Any() != getProperty
<OUString
>(xParaThird
, u
"PageDescName"_ustr
));
953 // there is an empty paragraph after THIRD
954 uno::Reference
<text::XTextRange
> xParaLast
= getParagraph(5);
955 CPPUNIT_ASSERT_EQUAL(OUString(), xParaLast
->getString());
960 catch (container::NoSuchElementException
const&)
962 // does not exist - expected
965 CPPUNIT_ASSERT_EQUAL(4, getPages());
968 CPPUNIT_TEST_FIXTURE(Test
, testBackground
)
970 createSwDoc("background.rtf");
971 // The first shape wasn't in the foreground.
972 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getShape(1), u
"Opaque"_ustr
));
973 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(getShape(2), u
"Opaque"_ustr
));
976 CPPUNIT_TEST_FIXTURE(Test
, testFdo74823
)
978 createSwDoc("fdo74823.rtf");
979 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
980 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
982 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
983 // Cell width of C2 was too large / column separator being 3749 too small (e.g. not set, around 3/7 of total width)
984 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
985 CPPUNIT_ASSERT_EQUAL(sal_Int16(5391),
986 getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
987 xTableRows
->getByIndex(1), u
"TableColumnSeparators"_ustr
)[2]
991 CPPUNIT_TEST_FIXTURE(Test
, testFdo74599
)
993 createSwDoc("fdo74599.rtf");
994 uno::Reference
<beans::XPropertySet
> xPropertySet(
995 getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Heading 3"_ustr
), uno::UNO_QUERY
);
996 // Writer default styles weren't disabled, so the color was gray, not default (black).
997 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-1),
998 getProperty
<sal_Int32
>(xPropertySet
, u
"CharColor"_ustr
));
1001 CPPUNIT_TEST_FIXTURE(Test
, testColumnBreak
)
1003 createSwDoc("column-break.rtf");
1004 // Column break at the very start of the document was ignored.
1005 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE
,
1006 getProperty
<style::BreakType
>(getParagraph(2), u
"BreakType"_ustr
));
1009 CPPUNIT_TEST_FIXTURE(Test
, testUnbalancedColumnsCompat
)
1011 createSwDoc("unbalanced-columns-compat.rtf");
1012 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
1013 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(),
1015 // This was false, we ignored the relevant compat setting to make this non-last section unbalanced.
1016 CPPUNIT_ASSERT_EQUAL(
1017 true, getProperty
<bool>(xTextSections
->getByIndex(0), u
"DontBalanceTextColumns"_ustr
));
1020 CPPUNIT_TEST_FIXTURE(Test
, testOleInline
)
1022 createSwDoc("ole-inline.rtf");
1023 // Problem was that inline shape had at-page anchor.
1024 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER
,
1025 getProperty
<text::TextContentAnchorType
>(getShape(1), u
"AnchorType"_ustr
));
1028 CPPUNIT_TEST_FIXTURE(Test
, testTdf128611
)
1030 createSwDoc("tdf128611.rtf");
1031 auto aPolyPolySequence
1032 = getProperty
<uno::Sequence
<uno::Sequence
<awt::Point
>>>(getShape(1), u
"PolyPolygon"_ustr
);
1033 CPPUNIT_ASSERT(aPolyPolySequence
.hasElements());
1034 const uno::Sequence
<awt::Point
>& rPolygon
= aPolyPolySequence
[0];
1035 CPPUNIT_ASSERT_GREATER(static_cast<sal_uInt32
>(1), rPolygon
.size());
1036 sal_Int32 nY1
= rPolygon
[0].Y
;
1037 sal_Int32 nY2
= rPolygon
[1].Y
;
1039 // Without the accompanying fix in place, this test would have failed with:
1040 // - Expected greater than: 6242
1042 // i.e. the vertical flip was missing, and the y1 > y2 assert failed, because the line pointed
1043 // from top left to bottom right, not bottom left to top right.
1044 CPPUNIT_ASSERT_GREATER(nY2
, nY1
);
1047 CPPUNIT_TEST_FIXTURE(Test
, testFdo80742
)
1049 createSwDoc("fdo80742.rtf");
1050 uno::Reference
<beans::XPropertySet
> xPropertySet(
1051 getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Heading 2"_ustr
), uno::UNO_QUERY
);
1052 // This was 0, outline level was body text.
1053 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xPropertySet
, u
"OutlineLevel"_ustr
));
1056 CPPUNIT_TEST_FIXTURE(Test
, testBehindDoc
)
1058 createSwDoc("behind-doc.rtf");
1059 // The problem was that "behind doc" didn't result in the shape being in the background, only in being wrapped as "through".
1060 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1061 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
1062 getProperty
<text::WrapTextMode
>(xShape
, u
"Surround"_ustr
));
1064 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xShape
, u
"Opaque"_ustr
));
1067 CPPUNIT_TEST_FIXTURE(Test
, testFdo82114
)
1069 createSwDoc("fdo82114.rtf");
1070 uno::Reference
<text::XText
> xHeaderTextPage1
= getProperty
<uno::Reference
<text::XText
>>(
1071 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), u
"HeaderTextFirst"_ustr
);
1072 CPPUNIT_ASSERT_EQUAL(u
"First page header, section 1"_ustr
, xHeaderTextPage1
->getString());
1074 uno::Reference
<text::XText
> xHeaderTextPage2
= getProperty
<uno::Reference
<text::XText
>>(
1075 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Converted1"_ustr
), u
"HeaderTextFirst"_ustr
);
1076 CPPUNIT_ASSERT_EQUAL(u
"First page header, section 2"_ustr
, xHeaderTextPage2
->getString());
1079 CPPUNIT_TEST_FIXTURE(Test
, testFdo44984
)
1081 createSwDoc("fdo44984.rtf");
1082 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1083 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1085 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1086 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName(u
"A1"_ustr
), uno::UNO_QUERY
);
1087 // This was Text, i.e. the checkbox field portion was missing.
1088 CPPUNIT_ASSERT_EQUAL(u
"TextFieldStartEnd"_ustr
,
1089 getProperty
<OUString
>(getRun(getParagraphOfText(1, xCell
->getText()), 1),
1090 u
"TextPortionType"_ustr
));
1093 CPPUNIT_TEST_FIXTURE(Test
, testTdf131386
)
1095 createSwDoc("hidden-para-separator.rtf");
1096 SwDoc
const* const pDoc
= getSwDoc();
1097 SwNodeIndex
ix(pDoc
->GetNodes().GetEndOfContent(), -1);
1098 CPPUNIT_ASSERT(ix
.GetNode()
1100 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1102 ->Get(RES_CHRATR_HIDDEN
)
1106 CPPUNIT_ASSERT(ix
.GetNode()
1108 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1110 ->Get(RES_CHRATR_HIDDEN
)
1113 CPPUNIT_ASSERT(ix
.GetNode()
1115 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1117 ->Get(RES_CHRATR_HIDDEN
)
1120 CPPUNIT_ASSERT(ix
.GetNode()
1122 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1124 ->Get(RES_CHRATR_HIDDEN
)
1128 CPPUNIT_TEST_FIXTURE(Test
, testFdo82071
)
1130 createSwDoc("fdo82071.rtf");
1131 // The problem was that in TOC, chapter names were underlined, but they should not be.
1132 uno::Reference
<text::XTextRange
> xRun
= getRun(getParagraph(1), 1);
1133 // Make sure we test the right text portion.
1134 CPPUNIT_ASSERT_EQUAL(u
"Chapter 1"_ustr
, xRun
->getString());
1135 // This was awt::FontUnderline::SINGLE.
1136 CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE
,
1137 getProperty
<sal_Int16
>(xRun
, u
"CharUnderline"_ustr
));
1140 CPPUNIT_TEST_FIXTURE(Test
, testFdo85179
)
1142 createSwDoc("fdo85179.rtf");
1143 // This was 0, border around the picture was ignored on import.
1144 // 360: EMU -> MM100
1145 CPPUNIT_ASSERT_EQUAL(sal_uInt32(50800 / 360),
1146 getProperty
<table::BorderLine2
>(getShape(1), u
"TopBorder"_ustr
).LineWidth
);
1149 CPPUNIT_TEST_FIXTURE(Test
, testPasteFirstParaDirectFormat
)
1151 // Create a new document.
1154 // Set some direct formatting on the first paragraph, but leave paragraph adjust at its
1156 uno::Reference
<beans::XPropertySet
> xParagraph(getParagraph(1), uno::UNO_QUERY
);
1157 xParagraph
->setPropertyValue(u
"PageNumberOffset"_ustr
, uno::Any(static_cast<sal_Int16
>(0)));
1161 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1162 uno::Reference
<text::XText
> xText
= xTextDocument
->getText();
1163 uno::Reference
<document::XDocumentInsertable
> xCursor(
1164 xText
->createTextCursorByRange(xText
->getStart()), uno::UNO_QUERY
);
1165 xCursor
->insertDocumentFromURL(createFileURL(u
"paste-first-para-direct-format.rtf"), {});
1167 // Without the accompanying fix in place, this test would have failed with:
1168 // - Expected: 3 (center)
1169 // - Actual : 0 (left)
1170 // i.e. the inserted document's first paragraph's paragraph formatting was lost.
1171 uno::Reference
<beans::XPropertySet
> xParagraph(getParagraph(1), uno::UNO_QUERY
);
1172 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(style::ParagraphAdjust_CENTER
),
1173 getProperty
<sal_Int16
>(xParagraph
, u
"ParaAdjust"_ustr
));
1176 CPPUNIT_TEST_FIXTURE(Test
, testFdo82512
)
1178 createSwDoc("fdo82512.rtf");
1179 // This was style::BreakType_NONE, column break was before the 3rd paragraph, not before the 2nd one.
1180 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE
,
1181 getProperty
<style::BreakType
>(getParagraph(2), u
"BreakType"_ustr
));
1184 CPPUNIT_TEST_FIXTURE(Test
, testUnbalancedColumns
)
1186 createSwDoc("unbalanced-columns.rtf");
1187 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
1188 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(),
1190 // This was false, last section was balanced, but it's unbalanced in Word.
1191 CPPUNIT_ASSERT_EQUAL(
1192 true, getProperty
<bool>(xTextSections
->getByIndex(0), u
"DontBalanceTextColumns"_ustr
));
1195 CPPUNIT_TEST_FIXTURE(Test
, testTdf126173
)
1197 createSwDoc("tdf126173.rtf");
1198 // Without the accompanying fix in place, this test would have failed, as the TextFrame was lost
1200 CPPUNIT_ASSERT(getShape(1).is());
1203 CPPUNIT_TEST_FIXTURE(Test
, testFdo84685
)
1205 createSwDoc("fdo84685.rtf");
1206 // index mark was not imported
1207 uno::Reference
<text::XDocumentIndexMark
> xMark(
1208 getProperty
<uno::Reference
<text::XDocumentIndexMark
>>(getRun(getParagraph(1), 1),
1209 u
"DocumentIndexMark"_ustr
));
1210 CPPUNIT_ASSERT(xMark
.is());
1211 CPPUNIT_ASSERT_EQUAL(u
"Key the 1st"_ustr
, getProperty
<OUString
>(xMark
, u
"PrimaryKey"_ustr
));
1212 // let's test toc entry too
1213 uno::Reference
<text::XDocumentIndexMark
> xTOCMark(
1214 getProperty
<uno::Reference
<text::XDocumentIndexMark
>>(getRun(getParagraph(2), 1),
1215 u
"DocumentIndexMark"_ustr
));
1216 CPPUNIT_ASSERT(xTOCMark
.is());
1217 uno::Reference
<lang::XServiceInfo
> xTOCSI(xTOCMark
, uno::UNO_QUERY
);
1218 CPPUNIT_ASSERT(xTOCSI
->supportsService(u
"com.sun.star.text.ContentIndexMark"_ustr
));
1221 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
1222 CPPUNIT_TEST_FIXTURE(Test
, testCp950listleveltext1
)
1224 createSwDoc("cp950listleveltext1.rtf");
1225 // suffix with Chinese only ( most common case generated by MSO2010 TC)
1226 // This is a dot that is generally used as suffix of Chinese list number
1227 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u4e00\u3001";
1229 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1230 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1231 getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
1234 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
1235 CPPUNIT_TEST_FIXTURE(Test
, testCp950listleveltext2
)
1237 createSwDoc("cp950listleveltext2.rtf");
1238 // Prefix and suffix with Chinese only ( tweaked from default in MSO2010 TC)
1239 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u524d\u7f6e\u7532\u3001\u5f8c\u7f6e";
1241 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1242 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1243 getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
1246 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 )
1247 CPPUNIT_TEST_FIXTURE(Test
, testCp950listleveltext3
)
1249 createSwDoc("cp950listleveltext3.rtf");
1250 // Numbering is a mix Chinese and English ( tweaked from default in MSO2010 TC)
1251 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u524da\u7f6eb\u7532\u3001"
1254 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1255 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1256 getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
1259 CPPUNIT_TEST_FIXTURE(Test
, testChtOutlineNumberingRtf
)
1261 createSwDoc("chtoutline.rtf");
1263 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u7b2c 1 \u7ae0";
1265 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1266 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1267 getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
1270 CPPUNIT_TEST_FIXTURE(Test
, testTdf90046
)
1272 createSwDoc("tdf90046.rtf");
1273 // this was crashing on importing the footnote
1274 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
1275 uno::Reference
<container::XIndexAccess
> xFootnotes
= xFootnotesSupplier
->getFootnotes();
1276 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
1277 CPPUNIT_ASSERT_EQUAL(u
"Ma"_ustr
, xTextRange
->getString());
1280 CPPUNIT_TEST_FIXTURE(Test
, testFdo49893
)
1282 createSwDoc("fdo49893.rtf");
1283 // Image from shape was not loaded, invalid size of image after load
1284 uno::Reference
<drawing::XShape
> xShape
= getShape(2);
1285 CPPUNIT_ASSERT(xShape
.is());
1286 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(432)), xShape
->getSize().Height
);
1287 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(1296)), xShape
->getSize().Width
);
1290 CPPUNIT_TEST_FIXTURE(Test
, testFdo49893_3
)
1292 createSwDoc("fdo49893-3.rtf");
1293 // No artifacts (black lines in left top corner) as shape #3 are expected
1294 CPPUNIT_ASSERT_EQUAL(2, getShapes());
1296 // Correct wrapping for shape
1297 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
1298 getProperty
<text::WrapTextMode
>(getShape(2), u
"Surround"_ustr
));
1301 CPPUNIT_TEST_FIXTURE(Test
, testWrapDistance
)
1303 createSwDoc("wrap-distance.rtf");
1304 // Custom shape, handled directly in RTFSdrImport.
1305 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1306 CPPUNIT_ASSERT_EQUAL(u
"com.sun.star.drawing.CustomShape"_ustr
, xShape
->getShapeType());
1307 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1),
1308 getProperty
<sal_Int32
>(xShape
, u
"TopMargin"_ustr
) / 1000);
1309 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2),
1310 getProperty
<sal_Int32
>(xShape
, u
"BottomMargin"_ustr
) / 1000);
1311 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3),
1312 getProperty
<sal_Int32
>(xShape
, u
"LeftMargin"_ustr
) / 1000);
1313 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4),
1314 getProperty
<sal_Int32
>(xShape
, u
"RightMargin"_ustr
) / 1000);
1316 // Picture, handled in GraphicImport, shared with DOCX.
1317 xShape
= getShape(2);
1318 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1),
1319 getProperty
<sal_Int32
>(xShape
, u
"TopMargin"_ustr
) / 1000);
1320 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2),
1321 getProperty
<sal_Int32
>(xShape
, u
"BottomMargin"_ustr
) / 1000);
1322 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3),
1323 getProperty
<sal_Int32
>(xShape
, u
"LeftMargin"_ustr
) / 1000);
1324 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4),
1325 getProperty
<sal_Int32
>(xShape
, u
"RightMargin"_ustr
) / 1000);
1328 CPPUNIT_TEST_FIXTURE(Test
, testTdf90260Par
)
1330 createSwDoc("hello.rtf");
1331 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1332 uno::Reference
<text::XTextRange
> xText
= xTextDocument
->getText();
1333 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1334 paste(u
"rtfimport/data/tdf90260-par.rtf", u
"com.sun.star.comp.Writer.RtfFilter"_ustr
, xEnd
);
1335 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
1338 CPPUNIT_TEST_FIXTURE(Test
, testTdf119599
)
1340 createSwDoc("tdf119599.rtf");
1341 uno::Reference
<beans::XPropertyState
> xRun(getRun(getParagraph(1), 1), uno::UNO_QUERY
);
1342 // This was beans::PropertyState_DIRECT_VALUE, changing the font size in
1343 // the style had no effect on the rendering result.
1344 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE
,
1345 xRun
->getPropertyState(u
"CharHeight"_ustr
));
1348 CPPUNIT_TEST_FIXTURE(Test
, testTdf90315
)
1350 createSwDoc("tdf90315.rtf");
1351 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
1352 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(),
1354 uno::Reference
<beans::XPropertySet
> xTextSection(xTextSections
->getByIndex(0), uno::UNO_QUERY
);
1355 // This was 0, but default should be 720 twips.
1356 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1270),
1357 getProperty
<sal_Int32
>(xTextSection
->getPropertyValue(u
"TextColumns"_ustr
),
1358 u
"AutomaticDistance"_ustr
));
1361 CPPUNIT_TEST_FIXTURE(Test
, testTdf59454
)
1363 createSwDoc("tdf59454.rtf");
1364 // This was 1, section break was ignored right before a table.
1365 CPPUNIT_ASSERT_EQUAL(2, getPages());
1368 CPPUNIT_TEST_FIXTURE(Test
, testTdf96308Tabpos
)
1370 createSwDoc("tdf96308-tabpos.rtf");
1371 // Get the tab stops of the second para in the B1 cell of the first table in the document.
1372 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1373 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1375 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1376 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName(u
"B1"_ustr
), uno::UNO_QUERY
);
1377 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
1378 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1379 xParaEnum
->nextElement();
1380 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1381 auto aTabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, u
"ParaTabStops"_ustr
);
1382 // This failed: tab stops were not deleted as direct formatting on the paragraph.
1383 CPPUNIT_ASSERT(!aTabStops
.hasElements());
1386 CPPUNIT_TEST_FIXTURE(Test
, testLndscpsxn
)
1388 createSwDoc("lndscpsxn.rtf");
1389 // Check landscape flag.
1390 CPPUNIT_ASSERT_EQUAL(4, getPages());
1392 uno::Reference
<container::XNameAccess
> pageStyles
= getStyles(u
"PageStyles"_ustr
);
1394 // get a page cursor
1395 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
1396 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(
1397 xModel
->getCurrentController(), uno::UNO_QUERY
);
1398 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(),
1401 // check that the first page has landscape flag
1402 xCursor
->jumpToFirstPage();
1403 OUString pageStyleName
= getProperty
<OUString
>(xCursor
, u
"PageStyleName"_ustr
);
1404 uno::Reference
<style::XStyle
> xStylePage(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1405 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStylePage
, u
"IsLandscape"_ustr
));
1407 // check that the second page has no landscape flag
1408 xCursor
->jumpToPage(2);
1409 pageStyleName
= getProperty
<OUString
>(xCursor
, u
"PageStyleName"_ustr
);
1410 xStylePage
.set(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1411 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xStylePage
, u
"IsLandscape"_ustr
));
1413 // check that the third page has landscape flag
1414 xCursor
->jumpToPage(3);
1415 pageStyleName
= getProperty
<OUString
>(xCursor
, u
"PageStyleName"_ustr
);
1416 xStylePage
.set(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1417 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStylePage
, u
"IsLandscape"_ustr
));
1419 // check that the last page has no landscape flag
1420 xCursor
->jumpToLastPage();
1421 pageStyleName
= getProperty
<OUString
>(xCursor
, u
"PageStyleName"_ustr
);
1422 xStylePage
.set(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1423 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xStylePage
, u
"IsLandscape"_ustr
));
1426 CPPUNIT_TEST_FIXTURE(Test
, testTdf99498
)
1428 createSwDoc("tdf99498.rtf");
1429 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1430 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1433 // Table width was a tiny sub one char wide 145twips, it should now be a table wide
1434 // enough to see all the text in the first column without breaking into multiple lines
1435 CPPUNIT_ASSERT_EQUAL(sal_Int32(7056),
1436 getProperty
<sal_Int32
>(xTables
->getByIndex(0), u
"Width"_ustr
));
1439 CPPUNIT_TEST_FIXTURE(Test
, testClassificatonPaste
)
1441 createSwDoc("hello.rtf");
1442 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1443 uno::Reference
<text::XTextRange
> xText
= xTextDocument
->getText();
1444 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1446 // Not classified source, not classified destination: OK.
1447 paste(u
"rtfimport/data/classification-no.rtf", u
"com.sun.star.comp.Writer.RtfFilter"_ustr
,
1449 CPPUNIT_ASSERT_EQUAL(u
"classification-no"_ustr
, getParagraph(2)->getString());
1451 // Classified source, not classified destination: nothing should happen.
1452 OUString aOld
= xText
->getString();
1453 paste(u
"rtfimport/data/classification-yes.rtf", u
"com.sun.star.comp.Writer.RtfFilter"_ustr
,
1455 CPPUNIT_ASSERT_EQUAL(aOld
, xText
->getString());
1458 CPPUNIT_TEST_FIXTURE(Test
, testTdf90097
)
1460 createSwDoc("tdf90097.rtf");
1461 // Get the second child of the group shape.
1462 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
1463 uno::Reference
<beans::XPropertySet
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
1464 uno::Sequence
<uno::Sequence
<awt::Point
>> aPolyPolySequence
;
1465 xShape
->getPropertyValue(u
"PolyPolygon"_ustr
) >>= aPolyPolySequence
;
1466 const uno::Sequence
<awt::Point
>& rPolygon
= aPolyPolySequence
[0];
1468 // Vertical flip for the line shape was ignored, so Y coordinates were swapped.
1469 CPPUNIT_ASSERT(rPolygon
[0].Y
> rPolygon
[1].Y
);
1472 CPPUNIT_TEST_FIXTURE(Test
, testTdf91684
)
1474 createSwDoc("tdf91684.rtf");
1475 // Scaling of the group shape children were incorrect, this was 3203.
1476 // (Unit was assumed to be twips, but it was relative coordinates.)
1477 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1337), getShape(1)->getSize().Height
);
1480 CPPUNIT_TEST_FIXTURE(Test
, testFlip
)
1482 createSwDoc("flip.rtf");
1483 comphelper::SequenceAsHashMap aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(
1484 getShapeByName(u
"h-and-v"), u
"CustomShapeGeometry"_ustr
);
1485 // This resulted in a uno::RuntimeException, as MirroredX wasn't set at all, so could not extract void to boolean.
1486 CPPUNIT_ASSERT_EQUAL(true, aMap
[u
"MirroredX"_ustr
].get
<bool>());
1487 CPPUNIT_ASSERT_EQUAL(true, aMap
[u
"MirroredY"_ustr
].get
<bool>());
1489 aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShapeByName(u
"h-only"),
1490 u
"CustomShapeGeometry"_ustr
);
1491 CPPUNIT_ASSERT_EQUAL(true, aMap
[u
"MirroredX"_ustr
].get
<bool>());
1492 CPPUNIT_ASSERT(!aMap
[u
"MirroredY"_ustr
].hasValue());
1494 aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShapeByName(u
"v-only"),
1495 u
"CustomShapeGeometry"_ustr
);
1496 CPPUNIT_ASSERT(!aMap
[u
"MirroredX"_ustr
].hasValue());
1497 CPPUNIT_ASSERT_EQUAL(true, aMap
[u
"MirroredY"_ustr
].get
<bool>());
1499 aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShapeByName(u
"neither-h-nor-v"),
1500 u
"CustomShapeGeometry"_ustr
);
1501 CPPUNIT_ASSERT(!aMap
[u
"MirroredX"_ustr
].hasValue());
1502 CPPUNIT_ASSERT(!aMap
[u
"MirroredY"_ustr
].hasValue());
1505 CPPUNIT_TEST_FIXTURE(Test
, testTdf78506
)
1507 createSwDoc("tdf78506.rtf");
1508 uno::Reference
<beans::XPropertySet
> xPropertySet(
1509 getStyles(u
"NumberingStyles"_ustr
)->getByName(u
"WWNum1"_ustr
), uno::UNO_QUERY
);
1510 uno::Reference
<container::XIndexAccess
> xLevels(
1511 xPropertySet
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
1512 uno::Sequence
<beans::PropertyValue
> aProps
;
1513 xLevels
->getByIndex(0) >>= aProps
; // 1sd level
1515 for (int i
= 0; i
< aProps
.getLength(); ++i
)
1517 const beans::PropertyValue
& rProp
= aProps
[i
];
1519 if (rProp
.Name
== "Suffix")
1520 // This was '0', invalid \levelnumbers wasn't ignored.
1521 CPPUNIT_ASSERT(rProp
.Value
.get
<OUString
>().isEmpty());
1524 xmlDocUniquePtr pLayout
= parseLayoutDump();
1525 // Ensure that there is a tabstop in the pseudo-numbering (numbering::NONE followed by tabstop)
1526 assertXPath(pLayout
, "//SwFixPortion"_ostr
, 1);
1529 CPPUNIT_TEST_FIXTURE(Test
, testTdf117403
)
1531 createSwDoc("tdf117403.rtf");
1532 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1533 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1535 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1536 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName(u
"A1"_ustr
), uno::UNO_QUERY
);
1537 CPPUNIT_ASSERT(xCell
.is());
1538 table::BorderLine2
aExpected(static_cast<sal_Int32
>(COL_BLACK
), 0, 4, 0,
1539 table::BorderLineStyle::SOLID
, 4);
1540 // This failed, border was not imported, OuterLineWidth was 0 instead of 4.
1541 CPPUNIT_ASSERT_BORDER_EQUAL(aExpected
,
1542 getProperty
<table::BorderLine2
>(xCell
, u
"BottomBorder"_ustr
));
1545 CPPUNIT_TEST_FIXTURE(Test
, testImportHeaderFooter
)
1547 createSwDoc("tdf108055.rtf");
1548 // The RTF import sometimes added Header and Footer multiple Times
1549 // as well as added the Header to the document body.
1550 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1551 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(),
1553 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1555 // Check if any Header or Footer text snuck into the TextBody
1556 uno::Reference
<text::XTextRange
> paragraph
= getParagraph(1);
1557 OUString value
= paragraph
->getString();
1558 CPPUNIT_ASSERT_EQUAL(u
"First Page"_ustr
, value
);
1560 paragraph
= getParagraph(3);
1561 value
= paragraph
->getString();
1562 CPPUNIT_ASSERT_EQUAL(u
"Second Page"_ustr
, value
);
1564 paragraph
= getParagraph(5);
1565 value
= paragraph
->getString();
1566 CPPUNIT_ASSERT_EQUAL(u
"Third Page"_ustr
, value
);
1568 //Check if Headers/Footers only contain what they should in this document
1569 uno::Reference
<text::XText
> xHeaderText
= getProperty
<uno::Reference
<text::XText
>>(
1570 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Default Page Style"_ustr
),
1571 u
"HeaderTextFirst"_ustr
);
1572 OUString aActual
= xHeaderText
->getString();
1573 CPPUNIT_ASSERT_EQUAL(u
"First Page Header"_ustr
, aActual
);
1575 uno::Reference
<text::XText
> xHeaderTextLeft
= getProperty
<uno::Reference
<text::XText
>>(
1576 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Default Page Style"_ustr
),
1577 u
"HeaderTextLeft"_ustr
);
1578 aActual
= xHeaderTextLeft
->getString();
1579 CPPUNIT_ASSERT_EQUAL(u
"Header even"_ustr
, aActual
);
1581 uno::Reference
<text::XText
> xHeaderTextRight
= getProperty
<uno::Reference
<text::XText
>>(
1582 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Default Page Style"_ustr
),
1583 u
"HeaderTextRight"_ustr
);
1584 aActual
= xHeaderTextRight
->getString();
1585 CPPUNIT_ASSERT_EQUAL(u
"Header uneven"_ustr
, aActual
);
1587 uno::Reference
<text::XText
> xFooterText
= getProperty
<uno::Reference
<text::XText
>>(
1588 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Default Page Style"_ustr
),
1589 u
"FooterTextFirst"_ustr
);
1590 aActual
= xFooterText
->getString();
1591 CPPUNIT_ASSERT_EQUAL(u
"First Page Footer"_ustr
, aActual
);
1593 uno::Reference
<text::XText
> xFooterTextLeft
= getProperty
<uno::Reference
<text::XText
>>(
1594 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Default Page Style"_ustr
),
1595 u
"FooterTextLeft"_ustr
);
1596 aActual
= xFooterTextLeft
->getString();
1597 CPPUNIT_ASSERT_EQUAL(u
"Footer even"_ustr
, aActual
);
1599 uno::Reference
<text::XText
> xFooterTextRight
= getProperty
<uno::Reference
<text::XText
>>(
1600 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Default Page Style"_ustr
),
1601 u
"FooterTextRight"_ustr
);
1602 aActual
= xFooterTextRight
->getString();
1603 CPPUNIT_ASSERT_EQUAL(u
"Footer uneven"_ustr
, aActual
);
1606 CPPUNIT_TEST_FIXTURE(Test
, testTdf108947
)
1608 createSwDoc("tdf108947.rtf");
1609 //Check if Headers/Footers contain what they should in this document
1610 uno::Reference
<text::XText
> xHeaderTextRight
= getProperty
<uno::Reference
<text::XText
>>(
1611 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Default Page Style"_ustr
),
1612 u
"HeaderTextRight"_ustr
);
1613 OUString aActual
= xHeaderTextRight
->getString();
1614 CPPUNIT_ASSERT_EQUAL(u
""_ustr
, aActual
);
1616 //Document is very fragile, hence we need this guard.
1618 uno::Reference
<text::XText
> xHeaderTextLeft
= getProperty
<uno::Reference
<text::XText
>>(
1619 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Default Page Style"_ustr
),
1620 u
"HeaderTextLeft"_ustr
);
1621 aActual
= xHeaderTextLeft
->getString();
1622 CPPUNIT_ASSERT_EQUAL(u
"" SAL_NEWLINE_STRING
"Header Page 2 ?"_ustr
, aActual
);
1626 CPPUNIT_TEST_FIXTURE(Test
, testWatermark
)
1628 createSwDoc("watermark.rtf");
1629 Size
aExpectedSize(14965, 7482);
1630 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1631 awt::Size
aActualSize(xShape
->getSize());
1633 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Width()), aActualSize
.Width
);
1634 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Height()), aActualSize
.Height
);
1637 CPPUNIT_TEST_FIXTURE(Test
, testTdf104016
)
1639 createSwDoc("tdf104016.rtf");
1640 uno::Reference
<beans::XPropertyState
> xParagraph(getParagraph(1), uno::UNO_QUERY
);
1641 // This was beans::PropertyState_DIRECT_VALUE, leading to lack of
1642 // inheritance from numbering.
1643 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE
,
1644 xParagraph
->getPropertyState(u
"ParaLeftMargin"_ustr
));
1647 CPPUNIT_TEST_FIXTURE(Test
, testTdf115242
)
1649 createSwDoc("tdf115242.rtf");
1650 // This was 0, overridden left margin was lost by too aggressive style
1652 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2787),
1653 getProperty
<sal_Int32
>(getParagraph(1), u
"ParaLeftMargin"_ustr
));
1656 CPPUNIT_TEST_FIXTURE(Test
, testTdf153196
)
1658 createSwDoc("tdf153196.rtf");
1660 xmlDocUniquePtr pLayout
= parseLayoutDump();
1662 CPPUNIT_ASSERT_EQUAL(4, getPages());
1664 // TODO: Writer creates an empty page 1 here, which Word does not
1665 assertXPath(pLayout
, "/root/page[1]/footer"_ostr
, 0);
1666 assertXPath(pLayout
, "/root/page[2]/footer"_ostr
, 1);
1667 // the first page (2) has a page style applied, which has a follow page
1668 // style; the problem was that the follow page style had a footer.
1669 assertXPath(pLayout
, "/root/page[3]/footer"_ostr
, 0);
1670 assertXPath(pLayout
, "/root/page[4]/footer"_ostr
, 1);
1672 // TODO exporting this, wrongly produces "even" footer from stashed one
1673 // TODO importing that, wrongly creates a footer even without evenAndOddHeaders
1676 CPPUNIT_TEST_FIXTURE(Test
, testDefaultValues
)
1678 createSwDoc("default-values.rtf");
1679 // tdf#105910: control words without values must be treated as having default values,
1680 // instead of being silently ignored
1682 uno::Reference
<text::XTextRange
> paragraph
= getParagraph(1);
1684 uno::Reference
<text::XTextRange
> run
= getRun(paragraph
, 1, u
"scaleWidth50%"_ustr
);
1685 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1686 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1687 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1688 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1689 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1690 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1692 run
= getRun(paragraph
, 2, u
"scaleWidth100%"_ustr
);
1693 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1694 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1695 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1696 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1697 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1698 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1700 run
= getRun(paragraph
, 3, u
"fontSize25"_ustr
);
1701 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1702 CPPUNIT_ASSERT_EQUAL(double(25), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1703 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1704 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1705 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1706 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1708 run
= getRun(paragraph
, 4, u
"fontSize12"_ustr
);
1709 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1710 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1711 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1712 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1713 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1714 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1716 run
= getRun(paragraph
, 5, u
"textDown3pt"_ustr
);
1717 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1718 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1719 CPPUNIT_ASSERT_EQUAL(sal_Int32(-25), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1720 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1721 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1722 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1724 run
= getRun(paragraph
, 6, u
"textUp3pt"_ustr
);
1725 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1726 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1727 CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1728 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1729 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1730 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1732 run
= getRun(paragraph
, 7, u
"expand1pt"_ustr
);
1733 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1734 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1735 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1736 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1737 CPPUNIT_ASSERT_EQUAL(
1739 o3tl::toTwips(getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
), o3tl::Length::mm100
));
1740 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1742 run
= getRun(paragraph
, 8, u
"expand0pt"_ustr
);
1743 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1744 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1745 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1746 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1747 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1748 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1750 run
= getRun(paragraph
, 9, u
"expand1pt"_ustr
);
1751 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1752 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1753 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1754 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1755 CPPUNIT_ASSERT_EQUAL(
1757 o3tl::toTwips(getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
), o3tl::Length::mm100
));
1758 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1760 run
= getRun(paragraph
, 10, u
"expand0pt"_ustr
);
1761 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1762 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1763 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1764 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1765 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1766 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1768 run
= getRun(paragraph
, 11, u
"colorBlack"_ustr
);
1769 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1770 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1771 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1772 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1773 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1774 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_BLACK
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1776 run
= getRun(paragraph
, 12, u
"colorRed"_ustr
);
1777 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1778 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1779 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1780 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1781 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1782 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTRED
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1784 run
= getRun(paragraph
, 13, u
"colorGreen"_ustr
);
1785 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1786 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1787 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1788 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1789 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1790 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTGREEN
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1792 run
= getRun(paragraph
, 14, u
"colorBlue"_ustr
);
1793 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1794 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1795 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1796 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1797 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1798 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTBLUE
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1800 run
= getRun(paragraph
, 15, u
"colorAuto"_ustr
);
1801 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1802 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1803 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1804 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1805 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1806 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1809 CPPUNIT_TEST_FIXTURE(Test
, testParaStyleBottomMargin
)
1811 createSwDoc("para-style-bottom-margin.rtf");
1812 uno::Reference
<beans::XPropertySet
> xPropertySet(
1813 getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Standard"_ustr
), uno::UNO_QUERY
);
1814 CPPUNIT_ASSERT_EQUAL(sal_Int32(353),
1815 getProperty
<sal_Int32
>(xPropertySet
, u
"ParaBottomMargin"_ustr
));
1816 CPPUNIT_ASSERT_EQUAL(
1817 style::LineSpacingMode::PROP
,
1818 getProperty
<style::LineSpacing
>(xPropertySet
, u
"ParaLineSpacing"_ustr
).Mode
);
1819 CPPUNIT_ASSERT_EQUAL(
1821 getProperty
<style::LineSpacing
>(xPropertySet
, u
"ParaLineSpacing"_ustr
).Height
);
1823 // The reason why this is 0 despite the default style containing \sa200
1824 // is that Word will actually interpret \basedonN
1825 // as "set style N and for every attribute of that style,
1826 // set an attribute with default value on the style"
1827 uno::Reference
<beans::XPropertySet
> xPropertySet1(
1828 getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Contents 1"_ustr
), uno::UNO_QUERY
);
1829 CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
1830 getProperty
<sal_Int32
>(xPropertySet1
, u
"ParaBottomMargin"_ustr
));
1831 CPPUNIT_ASSERT_EQUAL(
1832 style::LineSpacingMode::PROP
,
1833 getProperty
<style::LineSpacing
>(xPropertySet1
, u
"ParaLineSpacing"_ustr
).Mode
);
1834 CPPUNIT_ASSERT_EQUAL(
1836 getProperty
<style::LineSpacing
>(xPropertySet1
, u
"ParaLineSpacing"_ustr
).Height
);
1837 auto const xPara(getParagraph(1));
1838 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xPara
, u
"ParaBottomMargin"_ustr
));
1839 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP
, // 0 or 3 ???
1840 getProperty
<style::LineSpacing
>(xPara
, u
"ParaLineSpacing"_ustr
).Mode
);
1841 CPPUNIT_ASSERT_EQUAL(sal_Int16(100),
1842 getProperty
<style::LineSpacing
>(xPara
, u
"ParaLineSpacing"_ustr
).Height
);
1845 CPPUNIT_TEST_FIXTURE(Test
, test158044Tdf
)
1847 createSwDoc("tdf158044.rtf");
1850 auto xPara(getParagraph(1));
1851 auto tabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, u
"ParaTabStops"_ustr
);
1853 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), tabStops
.getLength());
1857 auto xPara(getParagraph(2));
1858 auto fillColor
= getProperty
<Color
>(xPara
, u
"FillColor"_ustr
);
1859 auto fillStyle
= getProperty
<drawing::FillStyle
>(xPara
, u
"FillStyle"_ustr
);
1861 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, fillStyle
);
1862 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, fillColor
);
1866 auto xPara(getParagraph(3));
1867 auto adjust
= getProperty
<sal_Int16
>(xPara
, u
"ParaAdjust"_ustr
);
1869 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), adjust
);
1873 auto xPara(getParagraph(4));
1874 auto tabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, u
"ParaTabStops"_ustr
);
1876 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabStops
.getLength());
1880 auto xPara(getParagraph(5));
1881 auto fillColor
= getProperty
<Color
>(xPara
, u
"FillColor"_ustr
);
1882 auto fillStyle
= getProperty
<drawing::FillStyle
>(xPara
, u
"FillStyle"_ustr
);
1883 auto tabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, u
"ParaTabStops"_ustr
);
1885 CPPUNIT_ASSERT_LESS(sal_Int32(2), tabStops
.getLength());
1886 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, fillStyle
);
1887 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED
, fillColor
);
1891 auto xPara(getParagraph(6));
1892 auto fillStyle
= getProperty
<drawing::FillStyle
>(xPara
, u
"FillStyle"_ustr
);
1893 auto tabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, u
"ParaTabStops"_ustr
);
1895 CPPUNIT_ASSERT_LESS(sal_Int32(2), tabStops
.getLength());
1896 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, fillStyle
);
1900 CPPUNIT_TEST_FIXTURE(Test
, test148544Tdf
)
1902 createSwDoc("tdf148544.rtf");
1903 uno::Reference
<text::XTextTablesSupplier
> tablesSupplier(mxComponent
, uno::UNO_QUERY
);
1904 uno::Reference
<container::XNameAccess
> tables
= tablesSupplier
->getTextTables();
1905 uno::Reference
<text::XTextTable
> xTable1(tables
->getByName(u
"Table2"_ustr
), uno::UNO_QUERY
);
1906 const char* aCellNames
[] = { "B2", "C5", "F6", "F7", "F8", "F9", "F10", "F11" };
1907 for (tools::ULong nName
= 0; nName
< sizeof(aCellNames
) / sizeof(const char*); ++nName
)
1909 uno::Reference
<table::XCell
> xCell
1910 = xTable1
->getCellByName(OUString::createFromAscii(aCellNames
[nName
]));
1911 uno::Reference
<beans::XPropertySet
> xPropSet(xCell
, uno::UNO_QUERY_THROW
);
1913 const char* aBorderNames
[] = { "BottomBorder", "TopBorder", "RightBorder", "LeftBorder" };
1914 for (tools::ULong nBorder
= 0; nBorder
< sizeof(aBorderNames
) / sizeof(const char*);
1917 table::BorderLine bottomBorder
= getProperty
<table::BorderLine
>(
1918 xCell
, OUString::createFromAscii(aBorderNames
[nBorder
]));
1920 CPPUNIT_ASSERT(!bottomBorder
.InnerLineWidth
);
1921 CPPUNIT_ASSERT(!bottomBorder
.OuterLineWidth
);
1926 CPPUNIT_TEST_FIXTURE(Test
, testTdf163003
)
1928 createSwDoc("tdf163003.rtf");
1929 uno::Reference
<container::XNameAccess
> xParaStyles(getStyles(u
"ParagraphStyles"_ustr
));
1930 uno::Reference
<beans::XPropertySet
> xStyle1(xParaStyles
->getByName(u
"Standard"_ustr
),
1932 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStyle1
, u
"ParaHyphenationNoCaps"_ustr
));
1934 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(1)),
1935 getProperty
<sal_Int32
>(getShape(1), u
"VertOrientPosition"_ustr
));
1938 // tests should only be added to rtfIMPORT *if* they fail round-tripping in rtfEXPORT
1939 } // end of anonymous namespace
1940 CPPUNIT_PLUGIN_IMPLEMENT();
1942 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */