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/table/TableBorderDistances.hpp>
31 #include <com/sun/star/text/RelOrientation.hpp>
32 #include <com/sun/star/text/SizeType.hpp>
33 #include <com/sun/star/text/TableColumnSeparator.hpp>
34 #include <com/sun/star/text/TextContentAnchorType.hpp>
35 #include <com/sun/star/text/XDocumentIndexMark.hpp>
36 #include <com/sun/star/text/XFootnotesSupplier.hpp>
37 #include <com/sun/star/text/XPageCursor.hpp>
38 #include <com/sun/star/text/XTextFramesSupplier.hpp>
39 #include <com/sun/star/text/XTextTablesSupplier.hpp>
40 #include <com/sun/star/text/XTextTable.hpp>
41 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
42 #include <com/sun/star/text/WrapTextMode.hpp>
43 #include <com/sun/star/text/HoriOrientation.hpp>
44 #include <com/sun/star/text/VertOrientation.hpp>
45 #include <com/sun/star/text/XFormField.hpp>
46 #include <com/sun/star/lang/Locale.hpp>
47 #include <com/sun/star/drawing/XShapes.hpp>
48 #include <com/sun/star/text/XTextDocument.hpp>
49 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
50 #include <com/sun/star/beans/XPropertyState.hpp>
51 #include <com/sun/star/document/XDocumentInsertable.hpp>
53 #include <o3tl/cppunittraitshelper.hxx>
54 #include <tools/UnitConversion.hxx>
55 #include <rtl/ustring.hxx>
56 #include <vcl/settings.hxx>
57 #include <comphelper/sequenceashashmap.hxx>
58 #include <comphelper/configuration.hxx>
60 #include <editeng/charhiddenitem.hxx>
62 #include <ndindex.hxx>
64 #include <fmtautofmt.hxx>
68 class Test
: public SwModelTestBase
72 : SwModelTestBase(u
"/sw/qa/extras/rtfimport/data/"_ustr
, u
"Rich Text Format"_ustr
)
77 CPPUNIT_TEST_FIXTURE(Test
, testN695479
)
79 createSwDoc("n695479.rtf");
80 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
81 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(),
83 uno::Reference
<beans::XPropertySet
> xPropertySet(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
85 // Negative ABSH should mean fixed size.
86 CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX
,
87 getProperty
<sal_Int16
>(xPropertySet
, u
"SizeType"_ustr
));
88 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(300)),
89 getProperty
<sal_Int32
>(xPropertySet
, u
"Height"_ustr
));
91 int nShapes
= getShapes();
92 CPPUNIT_ASSERT_EQUAL(3, nShapes
);
94 bool bFrameFound
= false, bDrawFound
= false;
95 for (int i
= 0; i
< nShapes
; ++i
)
97 uno::Reference
<lang::XServiceInfo
> xServiceInfo(getShape(i
+ 1), uno::UNO_QUERY
);
98 if (xServiceInfo
->supportsService(u
"com.sun.star.text.TextFrame"_ustr
))
100 // Both frames should be anchored to the first paragraph.
102 uno::Reference
<text::XTextContent
> xTextContent(xServiceInfo
, uno::UNO_QUERY
);
103 uno::Reference
<text::XTextRange
> xRange
= xTextContent
->getAnchor();
104 uno::Reference
<text::XText
> xText
= xRange
->getText();
105 CPPUNIT_ASSERT_EQUAL(u
"plain"_ustr
, xText
->getString());
108 // Additionally, the first frame should have double border at the bottom.
109 CPPUNIT_ASSERT_EQUAL(
110 table::BorderLineStyle::DOUBLE
,
111 getProperty
<table::BorderLine2
>(xPropertySet
, u
"BottomBorder"_ustr
).LineStyle
);
113 else if (xServiceInfo
->supportsService(u
"com.sun.star.drawing.LineShape"_ustr
))
115 // The older "drawing objects" syntax should be recognized.
117 xPropertySet
.set(xServiceInfo
, uno::UNO_QUERY
);
118 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
,
119 getProperty
<sal_Int16
>(xPropertySet
, u
"HoriOrientRelation"_ustr
));
120 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
121 getProperty
<sal_Int16
>(xPropertySet
, u
"VertOrientRelation"_ustr
));
124 CPPUNIT_ASSERT(bFrameFound
);
125 CPPUNIT_ASSERT(bDrawFound
);
128 CPPUNIT_TEST_FIXTURE(Test
, testTdf117246
)
130 createSwDoc("tdf117246.rtf");
131 // This was 2, all but the last \page was lost.
132 CPPUNIT_ASSERT_EQUAL(3, getPages());
135 CPPUNIT_TEST_FIXTURE(Test
, testTdf108943
)
137 createSwDoc("tdf108943.rtf");
138 uno::Reference
<beans::XPropertySet
> xPropertySet(
139 getStyles(u
"NumberingStyles"_ustr
)->getByName(u
"WWNum1"_ustr
), uno::UNO_QUERY
);
140 uno::Reference
<container::XIndexAccess
> xLevels(
141 xPropertySet
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
142 uno::Sequence
<beans::PropertyValue
> aProps
;
143 xLevels
->getByIndex(0) >>= aProps
; // 1st level
145 sal_Int32 nListtabStopPosition
= 0;
146 for (int i
= 0; i
< aProps
.getLength(); ++i
)
148 const beans::PropertyValue
& rProp
= aProps
[i
];
150 if (rProp
.Name
== "ListtabStopPosition")
151 nListtabStopPosition
= rProp
.Value
.get
<sal_Int32
>();
153 // This was 0, \tx was handled in paragraphs only (and not in list definitions).
154 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1270), nListtabStopPosition
);
157 CPPUNIT_TEST_FIXTURE(Test
, testFdo46662
)
159 createSwDoc("fdo46662.rtf");
164 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
165 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0),
166 getProperty
<sal_Int16
>(xPara
, u
"NumberingLevel"_ustr
));
167 CPPUNIT_ASSERT(xPara
->getPropertyValue(u
"NumberingStyleName"_ustr
) >>= listStyle
);
168 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
169 CPPUNIT_ASSERT_EQUAL(u
"1"_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
173 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(2), uno::UNO_QUERY
);
174 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1),
175 getProperty
<sal_Int16
>(xPara
, u
"NumberingLevel"_ustr
));
176 CPPUNIT_ASSERT(xPara
->getPropertyValue(u
"NumberingStyleName"_ustr
) >>= listStyle
);
177 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
178 CPPUNIT_ASSERT_EQUAL(u
"1.1"_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
182 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(3), uno::UNO_QUERY
);
183 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(2),
184 getProperty
<sal_Int16
>(xPara
, u
"NumberingLevel"_ustr
));
185 CPPUNIT_ASSERT(xPara
->getPropertyValue(u
"NumberingStyleName"_ustr
) >>= listStyle
);
186 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
187 CPPUNIT_ASSERT_EQUAL(u
"1.1.1"_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
191 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(4), uno::UNO_QUERY
);
192 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(3),
193 getProperty
<sal_Int16
>(xPara
, u
"NumberingLevel"_ustr
));
194 CPPUNIT_ASSERT(xPara
->getPropertyValue(u
"NumberingStyleName"_ustr
) >>= listStyle
);
195 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
196 CPPUNIT_ASSERT_EQUAL(u
"1.1.1.1"_ustr
,
197 getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
201 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(5), uno::UNO_QUERY
);
202 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0),
203 getProperty
<sal_Int16
>(xPara
, u
"NumberingLevel"_ustr
));
204 CPPUNIT_ASSERT(xPara
->getPropertyValue(u
"NumberingStyleName"_ustr
) >>= listStyle
);
205 CPPUNIT_ASSERT(listStyle
.startsWith("WWNum"));
206 CPPUNIT_ASSERT_EQUAL(u
"2"_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
210 CPPUNIT_TEST_FIXTURE(Test
, testTdf115715
)
212 createSwDoc("tdf115715.rtf");
213 // This was 0, second paragraph was shifted to the right, it had the same
214 // horizontal position as the 3rd paragraph.
215 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-1270),
216 getProperty
<sal_Int32
>(getParagraph(2), u
"ParaFirstLineIndent"_ustr
));
219 CPPUNIT_TEST_FIXTURE(Test
, testTdf81943
)
221 createSwDoc("tdf81943.rtf");
222 // The shape wasn't in background.
223 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(getShape(1), u
"Opaque"_ustr
));
226 CPPUNIT_TEST_FIXTURE(Test
, testTdf115155
)
228 createSwDoc("tdf115155.rtf");
229 auto xLevels
= getProperty
<uno::Reference
<container::XIndexAccess
>>(getParagraph(2),
230 u
"NumberingRules"_ustr
);
232 comphelper::SequenceAsHashMap
aMap(xLevels
->getByIndex(0));
233 // This was 1270: the left margin in the numbering rule was too small.
234 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2540), aMap
[u
"IndentAt"_ustr
].get
<sal_Int32
>());
237 CPPUNIT_TEST_FIXTURE(Test
, testTdf108951
)
239 createSwDoc("tdf108951.rtf");
240 // This test is import-only, as we assert the list ID, which is OK to
241 // re-order on export, but then this test would not pass anymore.
243 // \ls2 was imported as WWNum1.
244 CPPUNIT_ASSERT_EQUAL(u
"WWNum2"_ustr
,
245 getProperty
<OUString
>(getParagraph(1), u
"NumberingStyleName"_ustr
));
248 CPPUNIT_TEST_FIXTURE(Test
, testFdo47036
)
250 createSwDoc("fdo47036.rtf");
252 int nShapes
= getShapes();
253 CPPUNIT_ASSERT_EQUAL(3, nShapes
);
254 int nAtCharacter
= 0;
255 for (int i
= 0; i
< nShapes
; ++i
)
257 if (getProperty
<text::TextContentAnchorType
>(getShape(i
+ 1), u
"AnchorType"_ustr
)
258 == text::TextContentAnchorType_AT_CHARACTER
)
261 // The image at the document start was ignored.
262 CPPUNIT_ASSERT_EQUAL(1, nAtCharacter
);
264 // There should be 2 textboxes, not 4
265 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
266 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(),
268 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
271 CPPUNIT_TEST_FIXTURE(Test
, testFdo45182
)
273 createSwDoc("fdo45182.rtf");
274 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
275 uno::Reference
<container::XIndexAccess
> xFootnotes
= xFootnotesSupplier
->getFootnotes();
276 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
277 // Encoding in the footnote was wrong.
278 CPPUNIT_ASSERT_EQUAL(u
"\u017Eivnost\u00ED" SAL_NEWLINE_STRING
""_ustr
, xTextRange
->getString());
281 CPPUNIT_TEST_FIXTURE(Test
, testFdo85812
)
283 createSwDoc("fdo85812.rtf");
285 getProperty
<lang::Locale
>(getRun(getParagraph(1), 1, u
"This "_ustr
), u
"CharLocale"_ustr
));
286 // the \lang inside the group was applied to CJK not Western
287 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
288 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
289 // further testing indicates that Word is doing really weird stuff
290 // \loch \hich \dbch is reset by opening a group
291 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(2), 1, u
"CharGroup"_ustr
),
293 CPPUNIT_ASSERT_EQUAL(u
"ru"_ustr
, locale
.Language
);
294 CPPUNIT_ASSERT_EQUAL(u
"RU"_ustr
, locale
.Country
);
295 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(2), 2, u
"AfterChar"_ustr
),
297 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
298 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
299 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(3), 2, u
"AfterBookmark"_ustr
),
301 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
302 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
303 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 1, u
"CharGroup"_ustr
),
305 CPPUNIT_ASSERT_EQUAL(u
"ru"_ustr
, locale
.Language
);
306 CPPUNIT_ASSERT_EQUAL(u
"RU"_ustr
, locale
.Country
);
307 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 1, u
"CharGroup"_ustr
),
308 u
"CharLocaleComplex"_ustr
);
309 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
310 CPPUNIT_ASSERT_EQUAL(u
"DZ"_ustr
, locale
.Country
);
311 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 2, u
"AfterChar"_ustr
),
313 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
314 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
315 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 2, u
"AfterChar"_ustr
),
316 u
"CharLocaleComplex"_ustr
);
317 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
318 CPPUNIT_ASSERT_EQUAL(u
"DZ"_ustr
, locale
.Country
);
319 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(5), 2, u
"AfterBookmark"_ustr
),
321 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
322 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
323 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(5), 2, u
"AfterBookmark"_ustr
),
324 u
"CharLocaleComplex"_ustr
);
325 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
326 CPPUNIT_ASSERT_EQUAL(u
"DZ"_ustr
, locale
.Country
);
327 // \ltrch \rtlch works differently - it is sticky across groups
328 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 1, u
"CharGroup"_ustr
),
330 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
331 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
332 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 1, u
"CharGroup"_ustr
),
333 u
"CharLocaleComplex"_ustr
);
334 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
335 CPPUNIT_ASSERT_EQUAL(u
"DZ"_ustr
, locale
.Country
);
336 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 2, u
"AfterChar"_ustr
),
338 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
339 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
340 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 2, u
"AfterChar"_ustr
),
341 u
"CharLocaleComplex"_ustr
);
342 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
343 CPPUNIT_ASSERT_EQUAL(u
"EG"_ustr
, locale
.Country
);
344 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(7), 2, u
"AfterBookmark"_ustr
),
346 CPPUNIT_ASSERT_EQUAL(u
"en"_ustr
, locale
.Language
);
347 CPPUNIT_ASSERT_EQUAL(u
"US"_ustr
, locale
.Country
);
348 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(7), 2, u
"AfterBookmark"_ustr
),
349 u
"CharLocaleComplex"_ustr
);
350 CPPUNIT_ASSERT_EQUAL(u
"ar"_ustr
, locale
.Language
);
351 CPPUNIT_ASSERT_EQUAL(u
"EG"_ustr
, locale
.Country
);
354 CPPUNIT_TEST_FIXTURE(Test
, testFdo49692
)
356 createSwDoc("fdo49692.rtf");
357 uno::Reference
<beans::XPropertySet
> xPropertySet(
358 getStyles(u
"NumberingStyles"_ustr
)->getByName(u
"WWNum1"_ustr
), uno::UNO_QUERY
);
359 uno::Reference
<container::XIndexAccess
> xLevels(
360 xPropertySet
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
361 uno::Sequence
<beans::PropertyValue
> aProps
;
362 xLevels
->getByIndex(0) >>= aProps
; // 1st level
364 for (int i
= 0; i
< aProps
.getLength(); ++i
)
366 const beans::PropertyValue
& rProp
= aProps
[i
];
368 if (rProp
.Name
== "Suffix")
370 CPPUNIT_ASSERT(rProp
.Value
.get
<OUString
>().isEmpty());
375 CPPUNIT_TEST_FIXTURE(Test
, testFdo45190
)
377 createSwDoc("fdo45190.rtf");
378 // inherited \fi should be reset
379 CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
380 getProperty
<sal_Int32
>(getParagraph(1), u
"ParaFirstLineIndent"_ustr
));
382 // but direct one not
383 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-100)),
384 getProperty
<sal_Int32
>(getParagraph(2), u
"ParaFirstLineIndent"_ustr
));
387 CPPUNIT_TEST_FIXTURE(Test
, testTdf59699
)
389 createSwDoc("tdf59699.rtf");
390 // This resulted in a lang.IndexOutOfBoundsException: the referenced graphic data wasn't imported.
391 uno::Reference
<beans::XPropertySet
> xImage(getShape(1), uno::UNO_QUERY
);
392 auto xGraphic
= getProperty
<uno::Reference
<graphic::XGraphic
>>(xImage
, u
"Graphic"_ustr
);
393 CPPUNIT_ASSERT(xGraphic
.is());
396 CPPUNIT_TEST_FIXTURE(Test
, testFdo52066
)
398 createSwDoc("fdo52066.rtf");
400 * The problem was that the height of the shape was too big.
402 * xray ThisComponent.DrawPage(0).Size.Height
404 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
405 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(19)), xShape
->getSize().Height
);
408 CPPUNIT_TEST_FIXTURE(Test
, testTdf112211_2
)
410 createSwDoc("tdf112211-2.rtf");
411 // Spacing between the bullet and the actual text was too large.
412 // This is now around 269, large old value was 629.
413 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
414 int nWidth
= getXPath(pXmlDoc
,
415 "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/"
416 "child::*[@type='PortionType::TabLeft']",
419 CPPUNIT_ASSERT_LESS(300, nWidth
);
422 CPPUNIT_TEST_FIXTURE(Test
, testTdf122430
)
424 createSwDoc("tdf122430.rtf");
425 // Without the accompanying fix in place, this test would have failed with
426 // 'Expected: 18, Actual : 12', i.e. the font was smaller than expected.
427 CPPUNIT_ASSERT_EQUAL(18.0f
, getProperty
<float>(getRun(getParagraph(1), 2), u
"CharHeight"_ustr
));
430 CPPUNIT_TEST_FIXTURE(Test
, testFdo49892
)
432 createSwDoc("fdo49892.rtf");
433 int nShapes
= getShapes();
434 CPPUNIT_ASSERT_EQUAL(5, nShapes
);
435 for (int i
= 0; i
< nShapes
; ++i
)
437 OUString aDescription
= getProperty
<OUString
>(getShape(i
+ 1), u
"Description"_ustr
);
438 if (aDescription
== "red")
439 CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
440 getProperty
<sal_Int32
>(getShape(i
+ 1), u
"ZOrder"_ustr
));
441 else if (aDescription
== "green")
442 CPPUNIT_ASSERT_EQUAL(sal_Int32(1),
443 getProperty
<sal_Int32
>(getShape(i
+ 1), u
"ZOrder"_ustr
));
444 else if (aDescription
== "blue")
445 CPPUNIT_ASSERT_EQUAL(sal_Int32(2),
446 getProperty
<sal_Int32
>(getShape(i
+ 1), u
"ZOrder"_ustr
));
447 else if (aDescription
== "rect")
449 CPPUNIT_ASSERT_EQUAL(
450 text::RelOrientation::PAGE_FRAME
,
451 getProperty
<sal_Int16
>(getShape(i
+ 1), u
"HoriOrientRelation"_ustr
));
452 CPPUNIT_ASSERT_EQUAL(
453 text::RelOrientation::PAGE_FRAME
,
454 getProperty
<sal_Int16
>(getShape(i
+ 1), u
"VertOrientRelation"_ustr
));
459 CPPUNIT_TEST_FIXTURE(Test
, testFdo52052
)
461 createSwDoc("fdo52052.rtf");
462 // Make sure the textframe containing the text "third" appears on the 3rd page.
463 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
464 assertXPathContent(pXmlDoc
, "/root/page[3]/body/txt/anchored/fly/txt/text()", u
"third");
467 CPPUNIT_TEST_FIXTURE(Test
, testInk
)
469 createSwDoc("ink.rtf");
471 * The problem was that the second segment had wrong command count and wrap type.
473 * oShape = ThisComponent.DrawPage(0)
474 * oPathPropVec = oShape.CustomShapeGeometry(1).Value
475 * oSegments = oPathPropVec(1).Value
476 * msgbox oSegments(1).Count ' was 0x2000 | 10, should be 10
477 * msgbox oShape.Surround ' was 2, should be 1
479 uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(
480 getShape(1), u
"CustomShapeGeometry"_ustr
);
481 uno::Sequence
<beans::PropertyValue
> aPathProps
;
482 for (int i
= 0; i
< aProps
.getLength(); ++i
)
484 const beans::PropertyValue
& rProp
= aProps
[i
];
485 if (rProp
.Name
== "Path")
486 rProp
.Value
>>= aPathProps
;
488 uno::Sequence
<drawing::EnhancedCustomShapeSegment
> aSegments
;
489 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
491 const beans::PropertyValue
& rProp
= aPathProps
[i
];
492 if (rProp
.Name
== "Segments")
493 rProp
.Value
>>= aSegments
;
495 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aSegments
[1].Count
);
496 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
497 getProperty
<text::WrapTextMode
>(getShape(1), u
"Surround"_ustr
));
500 CPPUNIT_TEST_FIXTURE(Test
, testFdo79319
)
502 createSwDoc("fdo79319.rtf");
503 // the thin horizontal rule was imported as a big fat rectangle
504 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
505 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(xShape
, u
"RelativeWidth"_ustr
));
506 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(16508), xShape
->getSize().Width
, 10);
507 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(53), xShape
->getSize().Height
, 10);
509 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER
, getProperty
<sal_Int16
>(xShape
, "VertOrient"));
510 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER
, getProperty
<sal_Int16
>(xShape
, "HoriOrient"));
514 CPPUNIT_TEST_FIXTURE(Test
, testFdo48442
)
516 createSwDoc("fdo48442.rtf");
517 // The problem was that \pvmrg is the default in RTF, but not in Writer.
518 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
519 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
,
520 getProperty
<sal_Int16
>(xShape
, u
"VertOrientRelation"_ustr
)); // was FRAME
523 CPPUNIT_TEST_FIXTURE(Test
, testFdo55525
)
525 createSwDoc("fdo55525.rtf");
526 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
527 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
529 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
530 // Negative left margin was ~missing, -191
531 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty
<sal_Int32
>(xTable
, u
"LeftMargin"_ustr
));
532 // Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
533 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
534 CPPUNIT_ASSERT_EQUAL(sal_Int16(896),
535 getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
536 xTableRows
->getByIndex(0), u
"TableColumnSeparators"_ustr
)[0]
540 CPPUNIT_TEST_FIXTURE(Test
, testFdo57708
)
542 createSwDoc("fdo57708.rtf");
543 // There were two issues: the doc was of 2 pages and the picture was missing.
544 CPPUNIT_ASSERT_EQUAL(1, getPages());
545 // Two objects: a picture and a textframe.
546 CPPUNIT_ASSERT_EQUAL(2, getShapes());
549 CPPUNIT_TEST_FIXTURE(Test
, testFdo45183
)
551 createSwDoc("fdo45183.rtf");
552 // Was text::WrapTextMode_PARALLEL, i.e. shpfblwtxt didn't send the shape below text.
553 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
554 getProperty
<text::WrapTextMode
>(getShape(1), u
"Surround"_ustr
));
556 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
557 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
559 // Was 247, resulting in a table having width almost zero and height of 10+ pages.
560 CPPUNIT_ASSERT_EQUAL(sal_Int32(16237),
561 getProperty
<sal_Int32
>(xTables
->getByIndex(0), u
"Width"_ustr
));
564 CPPUNIT_TEST_FIXTURE(Test
, testFdo59953
)
566 createSwDoc("fdo59953.rtf");
567 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
568 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
570 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
571 // Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width)
572 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
573 CPPUNIT_ASSERT_EQUAL(sal_Int16(7649),
574 getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
575 xTableRows
->getByIndex(0), u
"TableColumnSeparators"_ustr
)[0]
579 CPPUNIT_TEST_FIXTURE(Test
, testTdf84684
)
581 createSwDoc("tdf84684.rtf");
582 // The ZOrder of the two children of the group shape were swapped.
583 uno::Reference
<drawing::XShapes
> xGroup(getShape(1), uno::UNO_QUERY
);
584 uno::Reference
<container::XNamed
> xChild1(xGroup
->getByIndex(0), uno::UNO_QUERY
);
586 CPPUNIT_ASSERT_EQUAL(u
"Rectangle 1"_ustr
, xChild1
->getName());
587 uno::Reference
<container::XNamed
> xChild2(xGroup
->getByIndex(1), uno::UNO_QUERY
);
588 // This was Rectangle 1.
589 CPPUNIT_ASSERT_EQUAL(u
"Pie 2"_ustr
, xChild2
->getName());
592 CPPUNIT_TEST_FIXTURE(Test
, testFdo81944
)
594 createSwDoc("fdo81944.rtf");
595 // font properties in style were not imported
596 uno::Reference
<beans::XPropertySet
> xPropertySet(
597 getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Standard"_ustr
), uno::UNO_QUERY
);
598 uno::Reference
<style::XStyle
> xStyle(xPropertySet
, uno::UNO_QUERY
);
599 CPPUNIT_ASSERT_EQUAL(u
"Segoe UI"_ustr
, getProperty
<OUString
>(xStyle
, u
"CharFontName"_ustr
));
600 CPPUNIT_ASSERT_EQUAL(9.0f
, getProperty
<float>(xStyle
, u
"CharHeight"_ustr
));
601 // not sure if this should be set on Asian or Complex or both?
602 CPPUNIT_ASSERT_EQUAL(u
"Times New Roman"_ustr
,
603 getProperty
<OUString
>(xStyle
, u
"CharFontNameComplex"_ustr
));
604 CPPUNIT_ASSERT_EQUAL(11.0f
, getProperty
<float>(xStyle
, u
"CharHeightComplex"_ustr
));
607 CPPUNIT_TEST_FIXTURE(Test
, testSbkodd
)
609 createSwDoc("sbkodd.rtf");
610 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
611 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(
612 xModel
->getCurrentController(), uno::UNO_QUERY
);
613 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(),
615 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), xCursor
->getPage());
616 xCursor
->jumpToNextPage();
617 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(3), xCursor
->getPage());
620 CPPUNIT_TEST_FIXTURE(Test
, testSbkeven
)
622 createSwDoc("sbkeven.rtf");
623 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
624 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(
625 xModel
->getCurrentController(), uno::UNO_QUERY
);
626 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(),
628 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), xCursor
->getPage());
629 xCursor
->jumpToNextPage();
630 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(2), xCursor
->getPage());
631 xCursor
->jumpToNextPage();
632 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(4), xCursor
->getPage());
635 CPPUNIT_TEST_FIXTURE(Test
, testPoshPosv
)
637 createSwDoc("posh-posv.rtf");
638 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER
,
639 getProperty
<sal_Int16
>(getShape(1), u
"HoriOrient"_ustr
));
640 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER
,
641 getProperty
<sal_Int16
>(getShape(1), u
"VertOrient"_ustr
));
642 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getShape(1), u
"FrameIsAutomaticHeight"_ustr
));
645 CPPUNIT_TEST_FIXTURE(Test
, testPoshLeftRight
)
647 createSwDoc("posh-leftright.rtf");
648 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT
,
649 getProperty
<sal_Int16
>(getShape(1), u
"HoriOrient"_ustr
));
650 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::LEFT
,
651 getProperty
<sal_Int16
>(getShape(2), u
"HoriOrient"_ustr
));
654 CPPUNIT_TEST_FIXTURE(Test
, testTdf96326
)
656 createSwDoc("tdf96326.rtf");
657 // Make sure this is not checked.
658 auto xFormField
= getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(1), 2),
660 uno::Reference
<container::XNameContainer
> xParameters
= xFormField
->getParameters();
661 // This was true, ffres=25 was interpreted as checked.
662 CPPUNIT_ASSERT_EQUAL(false, bool(xParameters
->hasElements()));
664 // And this is checked.
665 xFormField
= getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(2), 2),
667 xParameters
= xFormField
->getParameters();
668 CPPUNIT_ASSERT_EQUAL(true, xParameters
->getByName(u
"Checkbox_Checked"_ustr
).get
<bool>());
671 CPPUNIT_TEST_FIXTURE(Test
, testN823655
)
673 createSwDoc("n823655.rtf");
674 uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(
675 getShape(1), u
"CustomShapeGeometry"_ustr
);
676 uno::Sequence
<beans::PropertyValue
> aPathProps
;
677 for (int i
= 0; i
< aProps
.getLength(); ++i
)
679 const beans::PropertyValue
& rProp
= aProps
[i
];
680 if (rProp
.Name
== "Path")
681 aPathProps
= rProp
.Value
.get
<uno::Sequence
<beans::PropertyValue
>>();
683 uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> aCoordinates
;
684 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
686 const beans::PropertyValue
& rProp
= aPathProps
[i
];
687 if (rProp
.Name
== "Coordinates")
689 = rProp
.Value
.get
<uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
>>();
691 // The first coordinate pair of this freeform shape was 286,0 instead of 0,286.
692 CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates
[0].Second
.Value
.get
<sal_Int32
>());
695 CPPUNIT_TEST_FIXTURE(Test
, testN823675
)
697 createSwDoc("n823675.rtf");
698 uno::Reference
<beans::XPropertySet
> xPropertySet(
699 getStyles(u
"NumberingStyles"_ustr
)->getByName(u
"WWNum1"_ustr
), uno::UNO_QUERY
);
700 uno::Reference
<container::XIndexAccess
> xLevels(
701 xPropertySet
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
702 uno::Sequence
<beans::PropertyValue
> aProps
;
703 xLevels
->getByIndex(0) >>= aProps
; // 1st level
704 awt::FontDescriptor aFont
;
706 for (int i
= 0; i
< aProps
.getLength(); ++i
)
708 const beans::PropertyValue
& rProp
= aProps
[i
];
710 if (rProp
.Name
== "BulletFont")
711 aFont
= rProp
.Value
.get
<awt::FontDescriptor
>();
713 // This was empty, i.e. no font name was set for the bullet numbering.
714 CPPUNIT_ASSERT_EQUAL(u
"Symbol"_ustr
, aFont
.Name
);
717 CPPUNIT_TEST_FIXTURE(Test
, testGroupshape
)
719 createSwDoc("groupshape.rtf");
720 // There should be a single groupshape with 2 children.
721 CPPUNIT_ASSERT_EQUAL(1, getShapes());
722 uno::Reference
<drawing::XShapes
> xGroupshape(getShape(1), uno::UNO_QUERY
);
723 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape
->getCount());
726 CPPUNIT_TEST_FIXTURE(Test
, testGroupshape_notext
)
728 createSwDoc("groupshape-notext.rtf");
729 // There should be a single groupshape with 2 children.
730 CPPUNIT_ASSERT_EQUAL(1, getShapes());
731 uno::Reference
<drawing::XShapes
> xGroupshape(getShape(1), uno::UNO_QUERY
);
732 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape
->getCount());
735 CPPUNIT_TEST_FIXTURE(Test
, testFdo81033
)
737 createSwDoc("fdo81033.rtf");
738 // Number of tabstops in the paragraph should be 2, was 3.
739 uno::Sequence
<style::TabStop
> tabs(
740 getProperty
<uno::Sequence
<style::TabStop
>>(getParagraph(1), u
"ParaTabStops"_ustr
));
741 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabs
.getLength());
742 CPPUNIT_ASSERT_EQUAL(sal_Int32(5808), tabs
[0].Position
);
743 CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT
, tabs
[0].Alignment
);
744 CPPUNIT_ASSERT_EQUAL(u
' ', tabs
[0].FillChar
);
745 CPPUNIT_ASSERT_EQUAL(sal_Int32(16002), tabs
[1].Position
);
746 CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT
, tabs
[1].Alignment
);
747 CPPUNIT_ASSERT_EQUAL(u
'_', tabs
[1].FillChar
);
750 CPPUNIT_TEST_FIXTURE(Test
, testTdf116269
)
752 createSwDoc("tdf116269.rtf");
753 // This was 2540, implicit 0 left margin was ignored on import (inherited
754 // value from list definition is repeated if it's not 0).
755 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0),
756 getProperty
<sal_Int32
>(getParagraph(1), u
"ParaLeftMargin"_ustr
));
759 CPPUNIT_TEST_FIXTURE(Test
, testTdf116265
)
761 createSwDoc("tdf116265.rtf");
762 // This was -635, \fi as direct formatting has to be ignored due to
763 // matching \fi in list definition (and with invalid level numbers).
764 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0),
765 getProperty
<sal_Int32
>(getParagraph(2), u
"ParaFirstLineIndent"_ustr
));
767 xmlDocUniquePtr pLayout
= parseLayoutDump();
768 // Ensure that there is a tabstop in the pseudo-numbering (numbering::NONE followed by tabstop)
769 assertXPath(pLayout
, "//SwFixPortion", 1);
772 CPPUNIT_TEST_FIXTURE(Test
, testFdo66565
)
774 createSwDoc("fdo66565.rtf");
775 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
776 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
778 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
779 // Cell width of A2 was 554, should be 453/14846*10000
780 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
781 CPPUNIT_ASSERT_EQUAL(sal_Int16(304),
782 getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
783 xTableRows
->getByIndex(1), u
"TableColumnSeparators"_ustr
)[0]
787 CPPUNIT_TEST_FIXTURE(Test
, testFdo67365
)
789 createSwDoc("fdo67365.rtf");
790 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
791 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
793 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
794 uno::Reference
<table::XTableRows
> xRows
= xTable
->getRows();
795 // The table only had 3 rows.
796 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xRows
->getCount());
797 // This was 4999, i.e. the two cells of the row had equal widths instead of a larger and a smaller cell.
798 CPPUNIT_ASSERT_EQUAL(sal_Int16(5290),
799 getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
800 xRows
->getByIndex(2), u
"TableColumnSeparators"_ustr
)[0]
802 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName(u
"A2"_ustr
), uno::UNO_QUERY
);
803 // Paragraph was aligned to center, should be left.
804 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT
,
805 static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(
806 getParagraphOfText(1, xCell
->getText()), u
"ParaAdjust"_ustr
)));
809 CPPUNIT_TEST_FIXTURE(Test
, testFdo47440
)
811 createSwDoc("fdo47440.rtf");
812 // Vertical and horizontal orientation of the picture wasn't imported (was text::RelOrientation::FRAME).
813 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
814 getProperty
<sal_Int16
>(getShape(1), u
"HoriOrientRelation"_ustr
));
815 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
816 getProperty
<sal_Int16
>(getShape(1), u
"VertOrientRelation"_ustr
));
819 CPPUNIT_TEST_FIXTURE(Test
, testFdo53556
)
821 createSwDoc("fdo53556.rtf");
822 // This was drawing::FillStyle_SOLID, which resulted in being non-transparent, hiding text which would be visible.
823 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
,
824 getProperty
<drawing::FillStyle
>(getShape(3), u
"FillStyle"_ustr
));
826 // This was a com.sun.star.drawing.CustomShape, which resulted in lack of word wrapping in the bugdoc.
827 uno::Reference
<beans::XPropertySet
> xShapeProperties(getShape(1), uno::UNO_QUERY
);
828 uno::Reference
<drawing::XShapeDescriptor
> xShapeDescriptor(xShapeProperties
, uno::UNO_QUERY
);
829 CPPUNIT_ASSERT_EQUAL(u
"FrameShape"_ustr
, xShapeDescriptor
->getShapeType());
832 CPPUNIT_TEST_FIXTURE(Test
, testGroupshapeRotation
)
834 createSwDoc("groupshape-rotation.rtf");
835 // Rotation on groupshapes wasn't handled correctly, RotateAngle was 4500.
836 CPPUNIT_ASSERT_EQUAL(sal_Int32(315 * 100),
837 getProperty
<sal_Int32
>(getShape(1), u
"RotateAngle"_ustr
));
840 CPPUNIT_TEST_FIXTURE(Test
, testTdf115153
)
842 createSwDoc("tdf115153.rtf");
843 auto const xShape(getShape(1));
844 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::NONE
,
845 getProperty
<sal_Int16
>(xShape
, u
"HoriOrient"_ustr
));
846 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
847 getProperty
<sal_Int16
>(xShape
, u
"HoriOrientRelation"_ustr
));
848 CPPUNIT_ASSERT_EQUAL(sal_Int32(2533),
849 getProperty
<sal_Int32
>(xShape
, u
"HoriOrientPosition"_ustr
));
850 // VertOrient was wrong
851 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::NONE
,
852 getProperty
<sal_Int16
>(xShape
, u
"VertOrient"_ustr
));
853 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
,
854 getProperty
<sal_Int16
>(xShape
, u
"VertOrientRelation"_ustr
));
855 CPPUNIT_ASSERT_EQUAL(sal_Int32(2131),
856 getProperty
<sal_Int32
>(xShape
, u
"VertOrientPosition"_ustr
));
859 CPPUNIT_TEST_FIXTURE(Test
, testFdo68291
)
861 createSwDoc("fdo68291.odt");
862 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
863 uno::Reference
<text::XTextRange
> xText
= xTextDocument
->getText();
864 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
865 paste(u
"rtfimport/data/fdo68291-paste.rtf", u
"com.sun.star.comp.Writer.RtfFilter"_ustr
, xEnd
);
867 // This was "Standard", causing an unwanted page break on next paste.
868 CPPUNIT_ASSERT_EQUAL(uno::Any(),
869 uno::Reference
<beans::XPropertySet
>(getParagraph(1), uno::UNO_QUERY_THROW
)
870 ->getPropertyValue(u
"PageDescName"_ustr
));
873 CPPUNIT_TEST_FIXTURE(Test
, testTdf105511
)
875 struct DefaultLocale
: public comphelper::ConfigurationProperty
<DefaultLocale
, OUString
>
877 static OUString
path()
879 return u
"/org.openoffice.Office.Linguistic/General/DefaultLocale"_ustr
;
881 ~DefaultLocale() = delete;
883 auto batch
= comphelper::ConfigurationChanges::create();
884 DefaultLocale::set(u
"ru-RU"_ustr
, batch
);
886 createSwDoc("tdf105511.rtf");
887 getParagraph(1, u
"\u0418\u043C\u044F"_ustr
);
890 CPPUNIT_TEST_FIXTURE(Test
, testContSectionPageBreak
)
892 createSwDoc("cont-section-pagebreak.rtf");
893 uno::Reference
<text::XTextRange
> xParaSecond
= getParagraph(2);
894 CPPUNIT_ASSERT_EQUAL(u
"SECOND"_ustr
, xParaSecond
->getString());
895 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
896 getProperty
<style::BreakType
>(xParaSecond
, u
"BreakType"_ustr
));
897 CPPUNIT_ASSERT_EQUAL(uno::Any(),
898 uno::Reference
<beans::XPropertySet
>(xParaSecond
, uno::UNO_QUERY_THROW
)
899 ->getPropertyValue(u
"PageDescName"_ustr
));
900 // actually not sure how many paragraph there should be between
901 // SECOND and THIRD - important is that the page break is on there
902 // (could be either 1 or 2; in Word it's a 2-line paragraph with the 1st
903 // line containing only the page break being ~0 height)
904 uno::Reference
<text::XTextRange
> xParaNext
= getParagraph(3);
905 CPPUNIT_ASSERT_EQUAL(OUString(), xParaNext
->getString());
906 //If PageDescName is not empty, a page break / switch to page style is defined
907 CPPUNIT_ASSERT(uno::Any() != getProperty
<OUString
>(xParaNext
, u
"PageDescName"_ustr
));
908 uno::Reference
<text::XTextRange
> xParaThird
= getParagraph(4);
909 CPPUNIT_ASSERT_EQUAL(u
"THIRD"_ustr
, xParaThird
->getString());
910 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
911 getProperty
<style::BreakType
>(xParaThird
, u
"BreakType"_ustr
));
912 CPPUNIT_ASSERT_EQUAL(uno::Any(),
913 uno::Reference
<beans::XPropertySet
>(xParaThird
, uno::UNO_QUERY_THROW
)
914 ->getPropertyValue(u
"PageDescName"_ustr
));
915 // there is an empty paragraph after THIRD
916 uno::Reference
<text::XTextRange
> xParaLast
= getParagraph(5);
917 CPPUNIT_ASSERT_EQUAL(OUString(), xParaLast
->getString());
922 catch (container::NoSuchElementException
const&)
924 // does not exist - expected
927 CPPUNIT_ASSERT_EQUAL(2, getPages());
930 CPPUNIT_TEST_FIXTURE(Test
, testSectionPageBreak
)
932 createSwDoc("section-pagebreak.rtf");
933 uno::Reference
<text::XTextRange
> xParaSecond
= getParagraph(2);
934 CPPUNIT_ASSERT_EQUAL(u
"SECOND"_ustr
, xParaSecond
->getString());
935 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
936 getProperty
<style::BreakType
>(xParaSecond
, u
"BreakType"_ustr
));
937 CPPUNIT_ASSERT(uno::Any() != getProperty
<OUString
>(xParaSecond
, u
"PageDescName"_ustr
));
938 // actually not sure how many paragraph there should be between
939 // SECOND and THIRD - important is that the page break is on there
940 // (could be either 1 or 2; in Word it's a 2-line paragraph with the 1st
941 // line containing only the page break being ~0 height)
942 uno::Reference
<text::XTextRange
> xParaNext
= getParagraph(3);
943 CPPUNIT_ASSERT_EQUAL(OUString(), xParaNext
->getString());
944 //If PageDescName is not empty, a page break / switch to page style is defined
945 CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE
,
946 getProperty
<style::BreakType
>(xParaNext
, u
"BreakType"_ustr
));
947 uno::Reference
<text::XTextRange
> xParaThird
= getParagraph(4);
948 CPPUNIT_ASSERT_EQUAL(u
"THIRD"_ustr
, xParaThird
->getString());
949 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
950 getProperty
<style::BreakType
>(xParaThird
, u
"BreakType"_ustr
));
951 CPPUNIT_ASSERT(uno::Any() != getProperty
<OUString
>(xParaThird
, u
"PageDescName"_ustr
));
952 // there is an empty paragraph after THIRD
953 uno::Reference
<text::XTextRange
> xParaLast
= getParagraph(5);
954 CPPUNIT_ASSERT_EQUAL(OUString(), xParaLast
->getString());
959 catch (container::NoSuchElementException
const&)
961 // does not exist - expected
964 CPPUNIT_ASSERT_EQUAL(4, getPages());
967 CPPUNIT_TEST_FIXTURE(Test
, testBackground
)
969 createSwDoc("background.rtf");
970 // The first shape wasn't in the foreground.
971 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getShape(1), u
"Opaque"_ustr
));
972 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(getShape(2), u
"Opaque"_ustr
));
975 CPPUNIT_TEST_FIXTURE(Test
, testFdo74823
)
977 createSwDoc("fdo74823.rtf");
978 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
979 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
981 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
982 // Cell width of C2 was too large / column separator being 3749 too small (e.g. not set, around 3/7 of total width)
983 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
984 CPPUNIT_ASSERT_EQUAL(sal_Int16(5391),
985 getProperty
<uno::Sequence
<text::TableColumnSeparator
>>(
986 xTableRows
->getByIndex(1), u
"TableColumnSeparators"_ustr
)[2]
990 CPPUNIT_TEST_FIXTURE(Test
, testFdo74599
)
992 createSwDoc("fdo74599.rtf");
993 uno::Reference
<beans::XPropertySet
> xPropertySet(
994 getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Heading 3"_ustr
), uno::UNO_QUERY
);
995 // Writer default styles weren't disabled, so the color was gray, not default (black).
996 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-1),
997 getProperty
<sal_Int32
>(xPropertySet
, u
"CharColor"_ustr
));
1000 CPPUNIT_TEST_FIXTURE(Test
, testColumnBreak
)
1002 createSwDoc("column-break.rtf");
1003 // Column break at the very start of the document was ignored.
1004 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE
,
1005 getProperty
<style::BreakType
>(getParagraph(2), u
"BreakType"_ustr
));
1008 CPPUNIT_TEST_FIXTURE(Test
, testUnbalancedColumnsCompat
)
1010 createSwDoc("unbalanced-columns-compat.rtf");
1011 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
1012 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(),
1014 // This was false, we ignored the relevant compat setting to make this non-last section unbalanced.
1015 CPPUNIT_ASSERT_EQUAL(
1016 true, getProperty
<bool>(xTextSections
->getByIndex(0), u
"DontBalanceTextColumns"_ustr
));
1019 CPPUNIT_TEST_FIXTURE(Test
, testOleInline
)
1021 createSwDoc("ole-inline.rtf");
1022 // Problem was that inline shape had at-page anchor.
1023 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER
,
1024 getProperty
<text::TextContentAnchorType
>(getShape(1), u
"AnchorType"_ustr
));
1027 CPPUNIT_TEST_FIXTURE(Test
, testTdf128611
)
1029 createSwDoc("tdf128611.rtf");
1030 auto aPolyPolySequence
1031 = getProperty
<uno::Sequence
<uno::Sequence
<awt::Point
>>>(getShape(1), u
"PolyPolygon"_ustr
);
1032 CPPUNIT_ASSERT(aPolyPolySequence
.hasElements());
1033 const uno::Sequence
<awt::Point
>& rPolygon
= aPolyPolySequence
[0];
1034 CPPUNIT_ASSERT_GREATER(static_cast<sal_uInt32
>(1), rPolygon
.size());
1035 sal_Int32 nY1
= rPolygon
[0].Y
;
1036 sal_Int32 nY2
= rPolygon
[1].Y
;
1038 // Without the accompanying fix in place, this test would have failed with:
1039 // - Expected greater than: 6242
1041 // i.e. the vertical flip was missing, and the y1 > y2 assert failed, because the line pointed
1042 // from top left to bottom right, not bottom left to top right.
1043 CPPUNIT_ASSERT_GREATER(nY2
, nY1
);
1046 CPPUNIT_TEST_FIXTURE(Test
, testFdo80742
)
1048 createSwDoc("fdo80742.rtf");
1049 uno::Reference
<beans::XPropertySet
> xPropertySet(
1050 getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Heading 2"_ustr
), uno::UNO_QUERY
);
1051 // This was 0, outline level was body text.
1052 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xPropertySet
, u
"OutlineLevel"_ustr
));
1055 CPPUNIT_TEST_FIXTURE(Test
, testBehindDoc
)
1057 createSwDoc("behind-doc.rtf");
1058 // The problem was that "behind doc" didn't result in the shape being in the background, only in being wrapped as "through".
1059 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1060 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
1061 getProperty
<text::WrapTextMode
>(xShape
, u
"Surround"_ustr
));
1063 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xShape
, u
"Opaque"_ustr
));
1066 CPPUNIT_TEST_FIXTURE(Test
, testFdo82114
)
1068 createSwDoc("fdo82114.rtf");
1069 uno::Reference
<text::XText
> xHeaderTextPage1
= getProperty
<uno::Reference
<text::XText
>>(
1070 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), u
"HeaderTextFirst"_ustr
);
1071 CPPUNIT_ASSERT_EQUAL(u
"First page header, section 1"_ustr
, xHeaderTextPage1
->getString());
1073 uno::Reference
<text::XText
> xHeaderTextPage2
= getProperty
<uno::Reference
<text::XText
>>(
1074 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Converted1"_ustr
), u
"HeaderTextFirst"_ustr
);
1075 CPPUNIT_ASSERT_EQUAL(u
"First page header, section 2"_ustr
, xHeaderTextPage2
->getString());
1078 CPPUNIT_TEST_FIXTURE(Test
, testFdo44984
)
1080 createSwDoc("fdo44984.rtf");
1081 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1082 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1084 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1085 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName(u
"A1"_ustr
), uno::UNO_QUERY
);
1086 // This was Text, i.e. the checkbox field portion was missing.
1087 CPPUNIT_ASSERT_EQUAL(u
"TextFieldStartEnd"_ustr
,
1088 getProperty
<OUString
>(getRun(getParagraphOfText(1, xCell
->getText()), 1),
1089 u
"TextPortionType"_ustr
));
1092 CPPUNIT_TEST_FIXTURE(Test
, testTdf131386
)
1094 createSwDoc("hidden-para-separator.rtf");
1095 SwDoc
const* const pDoc
= getSwDoc();
1096 SwNodeIndex
ix(pDoc
->GetNodes().GetEndOfContent(), -1);
1097 CPPUNIT_ASSERT(ix
.GetNode()
1099 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1101 ->Get(RES_CHRATR_HIDDEN
)
1105 CPPUNIT_ASSERT(ix
.GetNode()
1107 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1109 ->Get(RES_CHRATR_HIDDEN
)
1112 CPPUNIT_ASSERT(ix
.GetNode()
1114 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1116 ->Get(RES_CHRATR_HIDDEN
)
1119 CPPUNIT_ASSERT(ix
.GetNode()
1121 ->GetAttr(RES_PARATR_LIST_AUTOFMT
)
1123 ->Get(RES_CHRATR_HIDDEN
)
1127 CPPUNIT_TEST_FIXTURE(Test
, testFdo82071
)
1129 createSwDoc("fdo82071.rtf");
1130 // The problem was that in TOC, chapter names were underlined, but they should not be.
1131 uno::Reference
<text::XTextRange
> xRun
= getRun(getParagraph(1), 1);
1132 // Make sure we test the right text portion.
1133 CPPUNIT_ASSERT_EQUAL(u
"Chapter 1"_ustr
, xRun
->getString());
1134 // This was awt::FontUnderline::SINGLE.
1135 CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE
,
1136 getProperty
<sal_Int16
>(xRun
, u
"CharUnderline"_ustr
));
1139 CPPUNIT_TEST_FIXTURE(Test
, testFdo85179
)
1141 createSwDoc("fdo85179.rtf");
1142 // This was 0, border around the picture was ignored on import.
1143 // 360: EMU -> MM100
1144 CPPUNIT_ASSERT_EQUAL(sal_uInt32(50800 / 360),
1145 getProperty
<table::BorderLine2
>(getShape(1), u
"TopBorder"_ustr
).LineWidth
);
1148 CPPUNIT_TEST_FIXTURE(Test
, testPasteFirstParaDirectFormat
)
1150 // Create a new document.
1153 // Set some direct formatting on the first paragraph, but leave paragraph adjust at its
1155 uno::Reference
<beans::XPropertySet
> xParagraph(getParagraph(1), uno::UNO_QUERY
);
1156 xParagraph
->setPropertyValue(u
"PageNumberOffset"_ustr
, uno::Any(static_cast<sal_Int16
>(0)));
1160 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1161 uno::Reference
<text::XText
> xText
= xTextDocument
->getText();
1162 uno::Reference
<document::XDocumentInsertable
> xCursor(
1163 xText
->createTextCursorByRange(xText
->getStart()), uno::UNO_QUERY
);
1164 xCursor
->insertDocumentFromURL(createFileURL(u
"paste-first-para-direct-format.rtf"), {});
1166 // Without the accompanying fix in place, this test would have failed with:
1167 // - Expected: 3 (center)
1168 // - Actual : 0 (left)
1169 // i.e. the inserted document's first paragraph's paragraph formatting was lost.
1170 uno::Reference
<beans::XPropertySet
> xParagraph(getParagraph(1), uno::UNO_QUERY
);
1171 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(style::ParagraphAdjust_CENTER
),
1172 getProperty
<sal_Int16
>(xParagraph
, u
"ParaAdjust"_ustr
));
1175 CPPUNIT_TEST_FIXTURE(Test
, testFdo82512
)
1177 createSwDoc("fdo82512.rtf");
1178 // This was style::BreakType_NONE, column break was before the 3rd paragraph, not before the 2nd one.
1179 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE
,
1180 getProperty
<style::BreakType
>(getParagraph(2), u
"BreakType"_ustr
));
1183 CPPUNIT_TEST_FIXTURE(Test
, testUnbalancedColumns
)
1185 createSwDoc("unbalanced-columns.rtf");
1186 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
1187 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(),
1189 // This was false, last section was balanced, but it's unbalanced in Word.
1190 CPPUNIT_ASSERT_EQUAL(
1191 true, getProperty
<bool>(xTextSections
->getByIndex(0), u
"DontBalanceTextColumns"_ustr
));
1194 CPPUNIT_TEST_FIXTURE(Test
, testTdf126173
)
1196 createSwDoc("tdf126173.rtf");
1197 // Without the accompanying fix in place, this test would have failed, as the TextFrame was lost
1199 CPPUNIT_ASSERT(getShape(1).is());
1202 CPPUNIT_TEST_FIXTURE(Test
, testFdo84685
)
1204 createSwDoc("fdo84685.rtf");
1205 // index mark was not imported
1206 uno::Reference
<text::XDocumentIndexMark
> xMark(
1207 getProperty
<uno::Reference
<text::XDocumentIndexMark
>>(getRun(getParagraph(1), 1),
1208 u
"DocumentIndexMark"_ustr
));
1209 CPPUNIT_ASSERT(xMark
.is());
1210 CPPUNIT_ASSERT_EQUAL(u
"Key the 1st"_ustr
, getProperty
<OUString
>(xMark
, u
"PrimaryKey"_ustr
));
1211 // let's test toc entry too
1212 uno::Reference
<text::XDocumentIndexMark
> xTOCMark(
1213 getProperty
<uno::Reference
<text::XDocumentIndexMark
>>(getRun(getParagraph(2), 1),
1214 u
"DocumentIndexMark"_ustr
));
1215 CPPUNIT_ASSERT(xTOCMark
.is());
1216 uno::Reference
<lang::XServiceInfo
> xTOCSI(xTOCMark
, uno::UNO_QUERY
);
1217 CPPUNIT_ASSERT(xTOCSI
->supportsService(u
"com.sun.star.text.ContentIndexMark"_ustr
));
1220 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
1221 CPPUNIT_TEST_FIXTURE(Test
, testCp950listleveltext1
)
1223 createSwDoc("cp950listleveltext1.rtf");
1224 // suffix with Chinese only ( most common case generated by MSO2010 TC)
1225 // This is a dot that is generally used as suffix of Chinese list number
1226 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u4e00\u3001";
1228 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1229 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1230 getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
1233 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
1234 CPPUNIT_TEST_FIXTURE(Test
, testCp950listleveltext2
)
1236 createSwDoc("cp950listleveltext2.rtf");
1237 // Prefix and suffix with Chinese only ( tweaked from default in MSO2010 TC)
1238 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u524d\u7f6e\u7532\u3001\u5f8c\u7f6e";
1240 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1241 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1242 getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
1245 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 )
1246 CPPUNIT_TEST_FIXTURE(Test
, testCp950listleveltext3
)
1248 createSwDoc("cp950listleveltext3.rtf");
1249 // Numbering is a mix Chinese and English ( tweaked from default in MSO2010 TC)
1250 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u524da\u7f6eb\u7532\u3001"
1253 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1254 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1255 getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
1258 CPPUNIT_TEST_FIXTURE(Test
, testChtOutlineNumberingRtf
)
1260 createSwDoc("chtoutline.rtf");
1262 static constexpr OUStringLiteral aExpectedNumbering
= u
"\u7b2c 1 \u7ae0";
1264 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1265 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering
),
1266 getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
1269 CPPUNIT_TEST_FIXTURE(Test
, testTdf90046
)
1271 createSwDoc("tdf90046.rtf");
1272 // this was crashing on importing the footnote
1273 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
1274 uno::Reference
<container::XIndexAccess
> xFootnotes
= xFootnotesSupplier
->getFootnotes();
1275 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
1276 CPPUNIT_ASSERT_EQUAL(u
"Ma"_ustr
, xTextRange
->getString());
1279 CPPUNIT_TEST_FIXTURE(Test
, testFdo49893
)
1281 createSwDoc("fdo49893.rtf");
1282 // Image from shape was not loaded, invalid size of image after load
1283 uno::Reference
<drawing::XShape
> xShape
= getShape(2);
1284 CPPUNIT_ASSERT(xShape
.is());
1285 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(432)), xShape
->getSize().Height
);
1286 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(1296)), xShape
->getSize().Width
);
1289 CPPUNIT_TEST_FIXTURE(Test
, testFdo49893_3
)
1291 createSwDoc("fdo49893-3.rtf");
1292 // No artifacts (black lines in left top corner) as shape #3 are expected
1293 CPPUNIT_ASSERT_EQUAL(2, getShapes());
1295 // Correct wrapping for shape
1296 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH
,
1297 getProperty
<text::WrapTextMode
>(getShape(2), u
"Surround"_ustr
));
1300 CPPUNIT_TEST_FIXTURE(Test
, testWrapDistance
)
1302 createSwDoc("wrap-distance.rtf");
1303 // Custom shape, handled directly in RTFSdrImport.
1304 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1305 CPPUNIT_ASSERT_EQUAL(u
"com.sun.star.drawing.CustomShape"_ustr
, xShape
->getShapeType());
1306 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1),
1307 getProperty
<sal_Int32
>(xShape
, u
"TopMargin"_ustr
) / 1000);
1308 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2),
1309 getProperty
<sal_Int32
>(xShape
, u
"BottomMargin"_ustr
) / 1000);
1310 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3),
1311 getProperty
<sal_Int32
>(xShape
, u
"LeftMargin"_ustr
) / 1000);
1312 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4),
1313 getProperty
<sal_Int32
>(xShape
, u
"RightMargin"_ustr
) / 1000);
1315 // Picture, handled in GraphicImport, shared with DOCX.
1316 xShape
= getShape(2);
1317 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1),
1318 getProperty
<sal_Int32
>(xShape
, u
"TopMargin"_ustr
) / 1000);
1319 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2),
1320 getProperty
<sal_Int32
>(xShape
, u
"BottomMargin"_ustr
) / 1000);
1321 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3),
1322 getProperty
<sal_Int32
>(xShape
, u
"LeftMargin"_ustr
) / 1000);
1323 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4),
1324 getProperty
<sal_Int32
>(xShape
, u
"RightMargin"_ustr
) / 1000);
1327 CPPUNIT_TEST_FIXTURE(Test
, testTdf90260Par
)
1329 createSwDoc("hello.rtf");
1330 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1331 uno::Reference
<text::XTextRange
> xText
= xTextDocument
->getText();
1332 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1333 paste(u
"rtfimport/data/tdf90260-par.rtf", u
"com.sun.star.comp.Writer.RtfFilter"_ustr
, xEnd
);
1334 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
1337 CPPUNIT_TEST_FIXTURE(Test
, testTdf119599
)
1339 createSwDoc("tdf119599.rtf");
1340 uno::Reference
<beans::XPropertyState
> xRun(getRun(getParagraph(1), 1), uno::UNO_QUERY
);
1341 // This was beans::PropertyState_DIRECT_VALUE, changing the font size in
1342 // the style had no effect on the rendering result.
1343 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE
,
1344 xRun
->getPropertyState(u
"CharHeight"_ustr
));
1347 CPPUNIT_TEST_FIXTURE(Test
, testTdf90315
)
1349 createSwDoc("tdf90315.rtf");
1350 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
1351 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(),
1353 uno::Reference
<beans::XPropertySet
> xTextSection(xTextSections
->getByIndex(0), uno::UNO_QUERY
);
1354 // This was 0, but default should be 720 twips.
1355 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1270),
1356 getProperty
<sal_Int32
>(xTextSection
->getPropertyValue(u
"TextColumns"_ustr
),
1357 u
"AutomaticDistance"_ustr
));
1360 CPPUNIT_TEST_FIXTURE(Test
, testTdf59454
)
1362 createSwDoc("tdf59454.rtf");
1363 // This was 1, section break was ignored right before a table.
1364 CPPUNIT_ASSERT_EQUAL(2, getPages());
1367 CPPUNIT_TEST_FIXTURE(Test
, testTdf96308Tabpos
)
1369 createSwDoc("tdf96308-tabpos.rtf");
1370 // Get the tab stops of the second para in the B1 cell of the first table in the document.
1371 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1372 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1374 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1375 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName(u
"B1"_ustr
), uno::UNO_QUERY
);
1376 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
1377 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1378 xParaEnum
->nextElement();
1379 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1380 auto aTabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, u
"ParaTabStops"_ustr
);
1381 // This failed: tab stops were not deleted as direct formatting on the paragraph.
1382 CPPUNIT_ASSERT(!aTabStops
.hasElements());
1385 CPPUNIT_TEST_FIXTURE(Test
, testLndscpsxn
)
1387 createSwDoc("lndscpsxn.rtf");
1388 // Check landscape flag.
1389 CPPUNIT_ASSERT_EQUAL(4, getPages());
1391 uno::Reference
<container::XNameAccess
> pageStyles
= getStyles(u
"PageStyles"_ustr
);
1393 // get a page cursor
1394 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
1395 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(
1396 xModel
->getCurrentController(), uno::UNO_QUERY
);
1397 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(),
1400 // check that the first page has landscape flag
1401 xCursor
->jumpToFirstPage();
1402 OUString pageStyleName
= getProperty
<OUString
>(xCursor
, u
"PageStyleName"_ustr
);
1403 uno::Reference
<style::XStyle
> xStylePage(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1404 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStylePage
, u
"IsLandscape"_ustr
));
1406 // check that the second page has no landscape flag
1407 xCursor
->jumpToPage(2);
1408 pageStyleName
= getProperty
<OUString
>(xCursor
, u
"PageStyleName"_ustr
);
1409 xStylePage
.set(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1410 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xStylePage
, u
"IsLandscape"_ustr
));
1412 // check that the third page has landscape flag
1413 xCursor
->jumpToPage(3);
1414 pageStyleName
= getProperty
<OUString
>(xCursor
, u
"PageStyleName"_ustr
);
1415 xStylePage
.set(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1416 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStylePage
, u
"IsLandscape"_ustr
));
1418 // check that the last page has no landscape flag
1419 xCursor
->jumpToLastPage();
1420 pageStyleName
= getProperty
<OUString
>(xCursor
, u
"PageStyleName"_ustr
);
1421 xStylePage
.set(pageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
1422 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xStylePage
, u
"IsLandscape"_ustr
));
1425 CPPUNIT_TEST_FIXTURE(Test
, testTdf99498
)
1427 createSwDoc("tdf99498.rtf");
1428 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1429 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1432 // Table width was a tiny sub one char wide 145twips, it should now be a table wide
1433 // enough to see all the text in the first column without breaking into multiple lines
1434 CPPUNIT_ASSERT_EQUAL(sal_Int32(7056),
1435 getProperty
<sal_Int32
>(xTables
->getByIndex(0), u
"Width"_ustr
));
1438 CPPUNIT_TEST_FIXTURE(Test
, testClassificatonPaste
)
1440 createSwDoc("hello.rtf");
1441 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1442 uno::Reference
<text::XTextRange
> xText
= xTextDocument
->getText();
1443 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1445 // Not classified source, not classified destination: OK.
1446 paste(u
"rtfimport/data/classification-no.rtf", u
"com.sun.star.comp.Writer.RtfFilter"_ustr
,
1448 CPPUNIT_ASSERT_EQUAL(u
"classification-no"_ustr
, getParagraph(2)->getString());
1450 // Classified source, not classified destination: nothing should happen.
1451 OUString aOld
= xText
->getString();
1452 paste(u
"rtfimport/data/classification-yes.rtf", u
"com.sun.star.comp.Writer.RtfFilter"_ustr
,
1454 CPPUNIT_ASSERT_EQUAL(aOld
, xText
->getString());
1457 CPPUNIT_TEST_FIXTURE(Test
, testTdf90097
)
1459 createSwDoc("tdf90097.rtf");
1460 // Get the second child of the group shape.
1461 uno::Reference
<container::XIndexAccess
> xGroup(getShape(1), uno::UNO_QUERY
);
1462 uno::Reference
<beans::XPropertySet
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
1463 uno::Sequence
<uno::Sequence
<awt::Point
>> aPolyPolySequence
;
1464 xShape
->getPropertyValue(u
"PolyPolygon"_ustr
) >>= aPolyPolySequence
;
1465 const uno::Sequence
<awt::Point
>& rPolygon
= aPolyPolySequence
[0];
1467 // Vertical flip for the line shape was ignored, so Y coordinates were swapped.
1468 CPPUNIT_ASSERT(rPolygon
[0].Y
> rPolygon
[1].Y
);
1471 CPPUNIT_TEST_FIXTURE(Test
, testTdf91684
)
1473 createSwDoc("tdf91684.rtf");
1474 // Scaling of the group shape children were incorrect, this was 3203.
1475 // (Unit was assumed to be twips, but it was relative coordinates.)
1476 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1337), getShape(1)->getSize().Height
);
1479 CPPUNIT_TEST_FIXTURE(Test
, testFlip
)
1481 createSwDoc("flip.rtf");
1482 comphelper::SequenceAsHashMap aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(
1483 getShapeByName(u
"h-and-v"), u
"CustomShapeGeometry"_ustr
);
1484 // This resulted in a uno::RuntimeException, as MirroredX wasn't set at all, so could not extract void to boolean.
1485 CPPUNIT_ASSERT_EQUAL(true, aMap
[u
"MirroredX"_ustr
].get
<bool>());
1486 CPPUNIT_ASSERT_EQUAL(true, aMap
[u
"MirroredY"_ustr
].get
<bool>());
1488 aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShapeByName(u
"h-only"),
1489 u
"CustomShapeGeometry"_ustr
);
1490 CPPUNIT_ASSERT_EQUAL(true, aMap
[u
"MirroredX"_ustr
].get
<bool>());
1491 CPPUNIT_ASSERT(!aMap
[u
"MirroredY"_ustr
].hasValue());
1493 aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShapeByName(u
"v-only"),
1494 u
"CustomShapeGeometry"_ustr
);
1495 CPPUNIT_ASSERT(!aMap
[u
"MirroredX"_ustr
].hasValue());
1496 CPPUNIT_ASSERT_EQUAL(true, aMap
[u
"MirroredY"_ustr
].get
<bool>());
1498 aMap
= getProperty
<uno::Sequence
<beans::PropertyValue
>>(getShapeByName(u
"neither-h-nor-v"),
1499 u
"CustomShapeGeometry"_ustr
);
1500 CPPUNIT_ASSERT(!aMap
[u
"MirroredX"_ustr
].hasValue());
1501 CPPUNIT_ASSERT(!aMap
[u
"MirroredY"_ustr
].hasValue());
1504 CPPUNIT_TEST_FIXTURE(Test
, testTdf78506
)
1506 createSwDoc("tdf78506.rtf");
1507 uno::Reference
<beans::XPropertySet
> xPropertySet(
1508 getStyles(u
"NumberingStyles"_ustr
)->getByName(u
"WWNum1"_ustr
), uno::UNO_QUERY
);
1509 uno::Reference
<container::XIndexAccess
> xLevels(
1510 xPropertySet
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
1511 uno::Sequence
<beans::PropertyValue
> aProps
;
1512 xLevels
->getByIndex(0) >>= aProps
; // 1sd level
1514 for (int i
= 0; i
< aProps
.getLength(); ++i
)
1516 const beans::PropertyValue
& rProp
= aProps
[i
];
1518 if (rProp
.Name
== "Suffix")
1519 // This was '0', invalid \levelnumbers wasn't ignored.
1520 CPPUNIT_ASSERT(rProp
.Value
.get
<OUString
>().isEmpty());
1523 xmlDocUniquePtr pLayout
= parseLayoutDump();
1524 // Ensure that there is a tabstop in the pseudo-numbering (numbering::NONE followed by tabstop)
1525 assertXPath(pLayout
, "//SwFixPortion", 1);
1528 CPPUNIT_TEST_FIXTURE(Test
, testTdf117403
)
1530 createSwDoc("tdf117403.rtf");
1531 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1532 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1534 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1535 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName(u
"A1"_ustr
), uno::UNO_QUERY
);
1536 CPPUNIT_ASSERT(xCell
.is());
1537 table::BorderLine2
aExpected(static_cast<sal_Int32
>(COL_BLACK
), 0, 4, 0,
1538 table::BorderLineStyle::SOLID
, 4);
1539 // This failed, border was not imported, OuterLineWidth was 0 instead of 4.
1540 CPPUNIT_ASSERT_BORDER_EQUAL(aExpected
,
1541 getProperty
<table::BorderLine2
>(xCell
, u
"BottomBorder"_ustr
));
1544 CPPUNIT_TEST_FIXTURE(Test
, testImportHeaderFooter
)
1546 createSwDoc("tdf108055.rtf");
1547 // The RTF import sometimes added Header and Footer multiple Times
1548 // as well as added the Header to the document body.
1549 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1550 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(),
1552 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1554 // Check if any Header or Footer text snuck into the TextBody
1555 uno::Reference
<text::XTextRange
> paragraph
= getParagraph(1);
1556 OUString value
= paragraph
->getString();
1557 CPPUNIT_ASSERT_EQUAL(u
"First Page"_ustr
, value
);
1559 paragraph
= getParagraph(3);
1560 value
= paragraph
->getString();
1561 CPPUNIT_ASSERT_EQUAL(u
"Second Page"_ustr
, value
);
1563 paragraph
= getParagraph(5);
1564 value
= paragraph
->getString();
1565 CPPUNIT_ASSERT_EQUAL(u
"Third Page"_ustr
, value
);
1567 //Check if Headers/Footers only contain what they should in this document
1568 uno::Reference
<text::XText
> xHeaderText
= getProperty
<uno::Reference
<text::XText
>>(
1569 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), u
"HeaderTextFirst"_ustr
);
1570 OUString aActual
= xHeaderText
->getString();
1571 CPPUNIT_ASSERT_EQUAL(u
"First Page Header"_ustr
, aActual
);
1573 uno::Reference
<text::XText
> xHeaderTextLeft
= getProperty
<uno::Reference
<text::XText
>>(
1574 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), u
"HeaderTextLeft"_ustr
);
1575 aActual
= xHeaderTextLeft
->getString();
1576 CPPUNIT_ASSERT_EQUAL(u
"Header even"_ustr
, aActual
);
1578 uno::Reference
<text::XText
> xHeaderTextRight
= getProperty
<uno::Reference
<text::XText
>>(
1579 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), u
"HeaderTextRight"_ustr
);
1580 aActual
= xHeaderTextRight
->getString();
1581 CPPUNIT_ASSERT_EQUAL(u
"Header uneven"_ustr
, aActual
);
1583 uno::Reference
<text::XText
> xFooterText
= getProperty
<uno::Reference
<text::XText
>>(
1584 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), u
"FooterTextFirst"_ustr
);
1585 aActual
= xFooterText
->getString();
1586 CPPUNIT_ASSERT_EQUAL(u
"First Page Footer"_ustr
, aActual
);
1588 uno::Reference
<text::XText
> xFooterTextLeft
= getProperty
<uno::Reference
<text::XText
>>(
1589 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), u
"FooterTextLeft"_ustr
);
1590 aActual
= xFooterTextLeft
->getString();
1591 CPPUNIT_ASSERT_EQUAL(u
"Footer even"_ustr
, aActual
);
1593 uno::Reference
<text::XText
> xFooterTextRight
= getProperty
<uno::Reference
<text::XText
>>(
1594 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), u
"FooterTextRight"_ustr
);
1595 aActual
= xFooterTextRight
->getString();
1596 CPPUNIT_ASSERT_EQUAL(u
"Footer uneven"_ustr
, aActual
);
1599 CPPUNIT_TEST_FIXTURE(Test
, testTdf108947
)
1601 createSwDoc("tdf108947.rtf");
1602 //Check if Headers/Footers contain what they should in this document
1603 uno::Reference
<text::XText
> xHeaderTextRight
= getProperty
<uno::Reference
<text::XText
>>(
1604 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), u
"HeaderTextRight"_ustr
);
1605 OUString aActual
= xHeaderTextRight
->getString();
1606 CPPUNIT_ASSERT_EQUAL(u
""_ustr
, aActual
);
1608 //Document is very fragile, hence we need this guard.
1610 uno::Reference
<text::XText
> xHeaderTextLeft
= getProperty
<uno::Reference
<text::XText
>>(
1611 getStyles(u
"PageStyles"_ustr
)->getByName(u
"Standard"_ustr
), u
"HeaderTextLeft"_ustr
);
1612 aActual
= xHeaderTextLeft
->getString();
1613 CPPUNIT_ASSERT_EQUAL(u
"" SAL_NEWLINE_STRING
"Header Page 2 ?"_ustr
, aActual
);
1617 CPPUNIT_TEST_FIXTURE(Test
, testWatermark
)
1619 createSwDoc("watermark.rtf");
1620 Size
aExpectedSize(14965, 7482);
1621 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1622 awt::Size
aActualSize(xShape
->getSize());
1624 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Width()), aActualSize
.Width
);
1625 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Height()), aActualSize
.Height
);
1628 CPPUNIT_TEST_FIXTURE(Test
, testTdf104016
)
1630 createSwDoc("tdf104016.rtf");
1631 uno::Reference
<beans::XPropertyState
> xParagraph(getParagraph(1), uno::UNO_QUERY
);
1632 // This was beans::PropertyState_DIRECT_VALUE, leading to lack of
1633 // inheritance from numbering.
1634 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE
,
1635 xParagraph
->getPropertyState(u
"ParaLeftMargin"_ustr
));
1638 CPPUNIT_TEST_FIXTURE(Test
, testTdf115242
)
1640 createSwDoc("tdf115242.rtf");
1641 // This was 0, overridden left margin was lost by too aggressive style
1643 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2787),
1644 getProperty
<sal_Int32
>(getParagraph(1), u
"ParaLeftMargin"_ustr
));
1647 CPPUNIT_TEST_FIXTURE(Test
, testTdf153196
)
1649 createSwDoc("tdf153196.rtf");
1651 xmlDocUniquePtr pLayout
= parseLayoutDump();
1653 CPPUNIT_ASSERT_EQUAL(4, getPages());
1655 // TODO: Writer creates an empty page 1 here, which Word does not
1656 assertXPath(pLayout
, "/root/page[1]/footer", 0);
1657 assertXPath(pLayout
, "/root/page[2]/footer", 1);
1658 // the first page (2) has a page style applied, which has a follow page
1659 // style; the problem was that the follow page style had a footer.
1660 assertXPath(pLayout
, "/root/page[3]/footer", 0);
1661 assertXPath(pLayout
, "/root/page[4]/footer", 1);
1663 // TODO exporting this, wrongly produces "even" footer from stashed one
1664 // TODO importing that, wrongly creates a footer even without evenAndOddHeaders
1667 CPPUNIT_TEST_FIXTURE(Test
, testDefaultValues
)
1669 createSwDoc("default-values.rtf");
1670 // tdf#105910: control words without values must be treated as having default values,
1671 // instead of being silently ignored
1673 uno::Reference
<text::XTextRange
> paragraph
= getParagraph(1);
1675 uno::Reference
<text::XTextRange
> run
= getRun(paragraph
, 1, u
"scaleWidth50%"_ustr
);
1676 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1677 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1678 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1679 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1680 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1681 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1683 run
= getRun(paragraph
, 2, u
"scaleWidth100%"_ustr
);
1684 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1685 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1686 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1687 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1688 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1689 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1691 run
= getRun(paragraph
, 3, u
"fontSize25"_ustr
);
1692 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1693 CPPUNIT_ASSERT_EQUAL(double(25), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1694 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1695 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1696 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1697 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1699 run
= getRun(paragraph
, 4, u
"fontSize12"_ustr
);
1700 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1701 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1702 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1703 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1704 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1705 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1707 run
= getRun(paragraph
, 5, u
"textDown3pt"_ustr
);
1708 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1709 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1710 CPPUNIT_ASSERT_EQUAL(sal_Int32(-25), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1711 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1712 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1713 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1715 run
= getRun(paragraph
, 6, u
"textUp3pt"_ustr
);
1716 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1717 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1718 CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1719 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1720 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1721 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1723 run
= getRun(paragraph
, 7, u
"expand1pt"_ustr
);
1724 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1725 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1726 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1727 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1728 CPPUNIT_ASSERT_EQUAL(
1730 o3tl::toTwips(getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
), o3tl::Length::mm100
));
1731 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1733 run
= getRun(paragraph
, 8, u
"expand0pt"_ustr
);
1734 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1735 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1736 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1737 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1738 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1739 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1741 run
= getRun(paragraph
, 9, u
"expand1pt"_ustr
);
1742 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1743 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1744 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1745 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1746 CPPUNIT_ASSERT_EQUAL(
1748 o3tl::toTwips(getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
), o3tl::Length::mm100
));
1749 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1751 run
= getRun(paragraph
, 10, u
"expand0pt"_ustr
);
1752 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1753 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1754 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1755 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1756 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1757 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1759 run
= getRun(paragraph
, 11, u
"colorBlack"_ustr
);
1760 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1761 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1762 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1763 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1764 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1765 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_BLACK
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1767 run
= getRun(paragraph
, 12, u
"colorRed"_ustr
);
1768 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1769 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1770 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1771 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1772 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1773 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTRED
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1775 run
= getRun(paragraph
, 13, u
"colorGreen"_ustr
);
1776 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1777 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1778 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1779 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1780 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1781 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTGREEN
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1783 run
= getRun(paragraph
, 14, u
"colorBlue"_ustr
);
1784 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1785 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1786 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1787 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1788 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1789 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTBLUE
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1791 run
= getRun(paragraph
, 15, u
"colorAuto"_ustr
);
1792 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(run
, u
"CharScaleWidth"_ustr
));
1793 CPPUNIT_ASSERT_EQUAL(double(12), getProperty
<double>(run
, u
"CharHeight"_ustr
));
1794 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(run
, u
"CharEscapement"_ustr
));
1795 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(run
, u
"CharEscapementHeight"_ustr
));
1796 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(run
, u
"CharKerning"_ustr
));
1797 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO
), getProperty
<sal_Int32
>(run
, u
"CharColor"_ustr
));
1800 CPPUNIT_TEST_FIXTURE(Test
, testParaStyleBottomMargin
)
1802 createSwDoc("para-style-bottom-margin.rtf");
1803 uno::Reference
<beans::XPropertySet
> xPropertySet(
1804 getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Standard"_ustr
), uno::UNO_QUERY
);
1805 CPPUNIT_ASSERT_EQUAL(sal_Int32(353),
1806 getProperty
<sal_Int32
>(xPropertySet
, u
"ParaBottomMargin"_ustr
));
1807 CPPUNIT_ASSERT_EQUAL(
1808 style::LineSpacingMode::PROP
,
1809 getProperty
<style::LineSpacing
>(xPropertySet
, u
"ParaLineSpacing"_ustr
).Mode
);
1810 CPPUNIT_ASSERT_EQUAL(
1812 getProperty
<style::LineSpacing
>(xPropertySet
, u
"ParaLineSpacing"_ustr
).Height
);
1814 // The reason why this is 0 despite the default style containing \sa200
1815 // is that Word will actually interpret \basedonN
1816 // as "set style N and for every attribute of that style,
1817 // set an attribute with default value on the style"
1818 uno::Reference
<beans::XPropertySet
> xPropertySet1(
1819 getStyles(u
"ParagraphStyles"_ustr
)->getByName(u
"Contents 1"_ustr
), uno::UNO_QUERY
);
1820 CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
1821 getProperty
<sal_Int32
>(xPropertySet1
, u
"ParaBottomMargin"_ustr
));
1822 CPPUNIT_ASSERT_EQUAL(
1823 style::LineSpacingMode::PROP
,
1824 getProperty
<style::LineSpacing
>(xPropertySet1
, u
"ParaLineSpacing"_ustr
).Mode
);
1825 CPPUNIT_ASSERT_EQUAL(
1827 getProperty
<style::LineSpacing
>(xPropertySet1
, u
"ParaLineSpacing"_ustr
).Height
);
1828 auto const xPara(getParagraph(1));
1829 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xPara
, u
"ParaBottomMargin"_ustr
));
1830 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP
, // 0 or 3 ???
1831 getProperty
<style::LineSpacing
>(xPara
, u
"ParaLineSpacing"_ustr
).Mode
);
1832 CPPUNIT_ASSERT_EQUAL(sal_Int16(100),
1833 getProperty
<style::LineSpacing
>(xPara
, u
"ParaLineSpacing"_ustr
).Height
);
1836 CPPUNIT_TEST_FIXTURE(Test
, test158044Tdf
)
1838 createSwDoc("tdf158044.rtf");
1841 auto xPara(getParagraph(1));
1842 auto tabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, u
"ParaTabStops"_ustr
);
1844 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), tabStops
.getLength());
1848 auto xPara(getParagraph(2));
1849 auto fillColor
= getProperty
<Color
>(xPara
, u
"FillColor"_ustr
);
1850 auto fillStyle
= getProperty
<drawing::FillStyle
>(xPara
, u
"FillStyle"_ustr
);
1852 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, fillStyle
);
1853 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, fillColor
);
1857 auto xPara(getParagraph(3));
1858 auto adjust
= getProperty
<sal_Int16
>(xPara
, u
"ParaAdjust"_ustr
);
1860 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), adjust
);
1864 auto xPara(getParagraph(4));
1865 auto tabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, u
"ParaTabStops"_ustr
);
1867 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabStops
.getLength());
1871 auto xPara(getParagraph(5));
1872 auto fillColor
= getProperty
<Color
>(xPara
, u
"FillColor"_ustr
);
1873 auto fillStyle
= getProperty
<drawing::FillStyle
>(xPara
, u
"FillStyle"_ustr
);
1874 auto tabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, u
"ParaTabStops"_ustr
);
1876 CPPUNIT_ASSERT_LESS(sal_Int32(2), tabStops
.getLength());
1877 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, fillStyle
);
1878 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED
, fillColor
);
1882 auto xPara(getParagraph(6));
1883 auto fillStyle
= getProperty
<drawing::FillStyle
>(xPara
, u
"FillStyle"_ustr
);
1884 auto tabStops
= getProperty
<uno::Sequence
<style::TabStop
>>(xPara
, u
"ParaTabStops"_ustr
);
1886 CPPUNIT_ASSERT_LESS(sal_Int32(2), tabStops
.getLength());
1887 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, fillStyle
);
1891 CPPUNIT_TEST_FIXTURE(Test
, test148544Tdf
)
1893 createSwDoc("tdf148544.rtf");
1894 uno::Reference
<text::XTextTablesSupplier
> tablesSupplier(mxComponent
, uno::UNO_QUERY
);
1895 uno::Reference
<container::XNameAccess
> tables
= tablesSupplier
->getTextTables();
1896 uno::Reference
<text::XTextTable
> xTable1(tables
->getByName(u
"Table2"_ustr
), uno::UNO_QUERY
);
1897 const char* aCellNames
[] = { "B2", "C5", "F6", "F7", "F8", "F9", "F10", "F11" };
1898 for (tools::ULong nName
= 0; nName
< sizeof(aCellNames
) / sizeof(const char*); ++nName
)
1900 uno::Reference
<table::XCell
> xCell
1901 = xTable1
->getCellByName(OUString::createFromAscii(aCellNames
[nName
]));
1902 uno::Reference
<beans::XPropertySet
> xPropSet(xCell
, uno::UNO_QUERY_THROW
);
1904 const char* aBorderNames
[] = { "BottomBorder", "TopBorder", "RightBorder", "LeftBorder" };
1905 for (tools::ULong nBorder
= 0; nBorder
< sizeof(aBorderNames
) / sizeof(const char*);
1908 table::BorderLine bottomBorder
= getProperty
<table::BorderLine
>(
1909 xCell
, OUString::createFromAscii(aBorderNames
[nBorder
]));
1911 CPPUNIT_ASSERT(!bottomBorder
.InnerLineWidth
);
1912 CPPUNIT_ASSERT(!bottomBorder
.OuterLineWidth
);
1917 CPPUNIT_TEST_FIXTURE(Test
, testTdf163003
)
1919 createSwDoc("tdf163003.rtf");
1920 uno::Reference
<container::XNameAccess
> xParaStyles(getStyles(u
"ParagraphStyles"_ustr
));
1921 uno::Reference
<beans::XPropertySet
> xStyle1(xParaStyles
->getByName(u
"Standard"_ustr
),
1923 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStyle1
, u
"ParaHyphenationNoCaps"_ustr
));
1925 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(1)),
1926 getProperty
<sal_Int32
>(getShape(1), u
"VertOrientPosition"_ustr
));
1929 CPPUNIT_TEST_FIXTURE(Test
, testTdf152839
)
1931 createSwDoc("tdf152839.rtf");
1932 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1933 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1935 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1936 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable
->getCellNames().getLength());
1939 CPPUNIT_TEST_FIXTURE(Test
, test160553Tdf
)
1941 createSwDoc("tdf160553.rtf");
1942 // new section should create second page
1943 CPPUNIT_ASSERT_EQUAL(2, getPages());
1946 CPPUNIT_TEST_FIXTURE(Test
, test162198Tdf
)
1948 createSwDoc("tdf162198.rtf");
1949 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1950 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(),
1952 uno::Reference
<text::XTextTable
> xTable1(xTables
->getByIndex(0), uno::UNO_QUERY
);
1954 uno::Reference
<table::XCell
> xCell
= xTable1
->getCellByName(u
"A1"_ustr
);
1955 uno::Reference
<beans::XPropertySet
> xCellPropSet(xCell
, uno::UNO_QUERY_THROW
);
1956 sal_Int32 nLeftDistance
= getProperty
<sal_Int32
>(xCellPropSet
, u
"LeftBorderDistance"_ustr
);
1957 sal_Int32 nRightDistance
= getProperty
<sal_Int32
>(xCellPropSet
, u
"LeftBorderDistance"_ustr
);
1958 CPPUNIT_ASSERT_EQUAL_MESSAGE("left cell spacing to contents", sal_Int32(9), nLeftDistance
);
1959 CPPUNIT_ASSERT_EQUAL_MESSAGE("right cell spacing to contents", sal_Int32(9), nRightDistance
);
1962 // tests should only be added to rtfIMPORT *if* they fail round-tripping in rtfEXPORT
1963 } // end of anonymous namespace
1964 CPPUNIT_PLUGIN_IMPLEMENT();
1966 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */