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/.
10 #include <swmodeltestbase.hxx>
12 #include <com/sun/star/awt/FontDescriptor.hpp>
13 #include <com/sun/star/awt/FontUnderline.hpp>
14 #include <com/sun/star/awt/FontWeight.hpp>
15 #include <com/sun/star/document/XFilter.hpp>
16 #include <com/sun/star/document/XImporter.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/drawing/LineStyle.hpp>
21 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
22 #include <com/sun/star/graphic/GraphicType.hpp>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/style/BreakType.hpp>
25 #include <com/sun/star/style/CaseMap.hpp>
26 #include <com/sun/star/style/LineSpacing.hpp>
27 #include <com/sun/star/style/LineSpacingMode.hpp>
28 #include <com/sun/star/style/ParagraphAdjust.hpp>
29 #include <com/sun/star/style/TabStop.hpp>
30 #include <com/sun/star/table/BorderLine2.hpp>
31 #include <com/sun/star/table/BorderLineStyle.hpp>
32 #include <com/sun/star/text/RelOrientation.hpp>
33 #include <com/sun/star/text/SizeType.hpp>
34 #include <com/sun/star/text/TableColumnSeparator.hpp>
35 #include <com/sun/star/text/TextContentAnchorType.hpp>
36 #include <com/sun/star/text/XDocumentIndexMark.hpp>
37 #include <com/sun/star/text/XFootnotesSupplier.hpp>
38 #include <com/sun/star/text/XPageCursor.hpp>
39 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
40 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
41 #include <com/sun/star/text/XTextFramesSupplier.hpp>
42 #include <com/sun/star/text/XTextRangeCompare.hpp>
43 #include <com/sun/star/text/XTextTablesSupplier.hpp>
44 #include <com/sun/star/text/XTextTable.hpp>
45 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
46 #include <com/sun/star/text/WrapTextMode.hpp>
47 #include <com/sun/star/text/HoriOrientation.hpp>
48 #include <com/sun/star/text/VertOrientation.hpp>
49 #include <com/sun/star/text/WritingMode2.hpp>
50 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
52 #include <rtl/ustring.hxx>
53 #include <vcl/outdev.hxx>
54 #include <vcl/svapp.hxx>
55 #include <vcl/settings.hxx>
56 #include <unotools/ucbstreamhelper.hxx>
57 #include <unotools/streamwrap.hxx>
58 #include <comphelper/sequenceashashmap.hxx>
60 #include <bordertest.hxx>
62 class Test
: public SwModelTestBase
65 Test() : SwModelTestBase("/sw/qa/extras/rtfimport/data/", "Rich Text Format")
69 virtual void preTest(const char* filename
) SAL_OVERRIDE
71 m_aSavedSettings
= Application::GetSettings();
72 if (OString(filename
) == "fdo48023.rtf" || OString(filename
) == "fdo72031.rtf")
74 AllSettings
aSettings(m_aSavedSettings
);
75 aSettings
.SetLanguageTag(LanguageTag("ru"));
76 Application::SetSettings(aSettings
);
78 else if (OString(filename
) == "fdo44211.rtf")
80 AllSettings
aSettings(m_aSavedSettings
);
81 aSettings
.SetLanguageTag(LanguageTag("lt"));
82 Application::SetSettings(aSettings
);
86 virtual void postTest(const char* filename
) SAL_OVERRIDE
88 if (OString(filename
) == "fdo48023.rtf" || OString(filename
) == "fdo72031.rtf" || OString(filename
) == "fdo44211.rtf")
89 Application::SetSettings(m_aSavedSettings
);
93 /// Copy&paste helper.
94 void paste(const OUString
& aFilename
, uno::Reference
<text::XTextRange
> xTextRange
= uno::Reference
<text::XTextRange
>())
96 uno::Reference
<document::XFilter
> xFilter(m_xSFactory
->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW
);
97 uno::Reference
<document::XImporter
> xImporter(xFilter
, uno::UNO_QUERY_THROW
);
98 xImporter
->setTargetDocument(mxComponent
);
99 uno::Sequence
<beans::PropertyValue
> aDescriptor(xTextRange
.is() ? 3 : 2);
100 aDescriptor
[0].Name
= "InputStream";
101 SvStream
* pStream
= utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + aFilename
, StreamMode::WRITE
);
102 uno::Reference
<io::XStream
> xStream(new utl::OStreamWrapper(*pStream
));
103 aDescriptor
[0].Value
<<= xStream
;
104 aDescriptor
[1].Name
= "InsertMode";
105 aDescriptor
[1].Value
<<= sal_True
;
108 aDescriptor
[2].Name
= "TextInsertModeRange";
109 aDescriptor
[2].Value
<<= xTextRange
;
111 xFilter
->filter(aDescriptor
);
113 AllSettings m_aSavedSettings
;
118 DECLARE_RTFIMPORT_TEST(testFdo45553
, "fdo45553.rtf")
120 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
121 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
122 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
123 while (xParaEnum
->hasMoreElements())
125 uno::Reference
<container::XEnumerationAccess
> xRangeEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
126 uno::Reference
<container::XEnumeration
> xRangeEnum
= xRangeEnumAccess
->createEnumeration();
127 while (xRangeEnum
->hasMoreElements())
129 uno::Reference
<text::XTextRange
> xRange(xRangeEnum
->nextElement(), uno::UNO_QUERY
);
130 OUString aStr
= xRange
->getString();
131 if (aStr
== "space-before")
132 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(120)), getProperty
<sal_Int32
>(xRange
, "ParaTopMargin"));
133 else if (aStr
== "space-after")
134 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(240)), getProperty
<sal_Int32
>(xRange
, "ParaBottomMargin"));
139 DECLARE_RTFIMPORT_TEST(testN192129
, "n192129.rtf")
141 // We expect that the result will be 16x16px.
142 Size
aExpectedSize(16, 16);
143 MapMode
aMap(MAP_100TH_MM
);
144 aExpectedSize
= Application::GetDefaultDevice()->PixelToLogic(aExpectedSize
, aMap
);
146 uno::Reference
<text::XTextGraphicObjectsSupplier
> xTextGraphicObjectsSupplier(mxComponent
, uno::UNO_QUERY
);
147 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextGraphicObjectsSupplier
->getGraphicObjects(), uno::UNO_QUERY
);
148 uno::Reference
<drawing::XShape
> xShape(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
149 awt::Size
aActualSize(xShape
->getSize());
151 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Width()), aActualSize
.Width
);
152 CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize
.Height()), aActualSize
.Height
);
155 DECLARE_RTFIMPORT_TEST(testFdo45543
, "fdo45543.rtf")
157 CPPUNIT_ASSERT_EQUAL(5, getLength());
160 DECLARE_RTFIMPORT_TEST(testN695479
, "n695479.rtf")
162 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
163 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
164 uno::Reference
<beans::XPropertySet
> xPropertySet(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
166 // Negative ABSH should mean fixed size.
167 CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX
, getProperty
<sal_Int16
>(xPropertySet
, "SizeType"));
168 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(300)), getProperty
<sal_Int32
>(xPropertySet
, "Height"));
170 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
171 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
172 bool bFrameFound
= false, bDrawFound
= false;
173 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
175 uno::Reference
<lang::XServiceInfo
> xServiceInfo(xDraws
->getByIndex(i
), uno::UNO_QUERY
);
176 if (xServiceInfo
->supportsService("com.sun.star.text.TextFrame"))
178 // Both frames should be anchored to the first paragraph.
180 uno::Reference
<text::XTextContent
> xTextContent(xServiceInfo
, uno::UNO_QUERY
);
181 uno::Reference
<text::XTextRange
> xRange(xTextContent
->getAnchor(), uno::UNO_QUERY
);
182 uno::Reference
<text::XText
> xText(xRange
->getText(), uno::UNO_QUERY
);
183 CPPUNIT_ASSERT_EQUAL(OUString("plain"), xText
->getString());
186 // Additionally, the frist frame should have double border at the bottom.
187 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::DOUBLE
, getProperty
<table::BorderLine2
>(xPropertySet
, "BottomBorder").LineStyle
);
189 else if (xServiceInfo
->supportsService("com.sun.star.drawing.LineShape"))
191 // The older "drawing objects" syntax should be recognized.
193 xPropertySet
.set(xServiceInfo
, uno::UNO_QUERY
);
194 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
, getProperty
<sal_Int16
>(xPropertySet
, "HoriOrientRelation"));
195 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xPropertySet
, "VertOrientRelation"));
198 CPPUNIT_ASSERT(bFrameFound
);
199 CPPUNIT_ASSERT(bDrawFound
);
202 DECLARE_RTFIMPORT_TEST(testFdo42465
, "fdo42465.rtf")
204 CPPUNIT_ASSERT_EQUAL(3, getLength());
207 DECLARE_RTFIMPORT_TEST(testFdo45187
, "fdo45187.rtf")
209 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
210 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
211 // There should be two shapes.
212 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws
->getCount());
214 // They should be anchored to different paragraphs.
215 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
216 uno::Reference
<text::XTextRangeCompare
> xTextRangeCompare(xTextDocument
->getText(), uno::UNO_QUERY
);
217 uno::Reference
<text::XTextRange
> xAnchor0
= uno::Reference
<text::XTextContent
>(xDraws
->getByIndex(0), uno::UNO_QUERY
)->getAnchor();
218 uno::Reference
<text::XTextRange
> xAnchor1
= uno::Reference
<text::XTextContent
>(xDraws
->getByIndex(1), uno::UNO_QUERY
)->getAnchor();
219 // Was 0 ("starts at the same position"), should be 1 ("starts before")
220 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xTextRangeCompare
->compareRegionStarts(xAnchor0
, xAnchor1
));
223 DECLARE_RTFIMPORT_TEST(testFdo46662
, "fdo46662.rtf")
225 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY
);
226 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
227 uno::Sequence
<beans::PropertyValue
> aProps
;
228 xLevels
->getByIndex(1) >>= aProps
; // 2nd level
230 for (int i
= 0; i
< aProps
.getLength(); ++i
)
232 const beans::PropertyValue
& rProp
= aProps
[i
];
234 if (rProp
.Name
== "ParentNumbering")
235 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), rProp
.Value
.get
<sal_Int16
>());
236 else if (rProp
.Name
== "Suffix")
237 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp
.Value
.get
<OUString
>().getLength());
241 DECLARE_RTFIMPORT_TEST(testN750757
, "n750757.rtf")
243 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
244 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
245 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
247 CPPUNIT_ASSERT_EQUAL(false, bool(getProperty
<sal_Bool
>(xParaEnum
->nextElement(), "ParaContextMargin")));
248 CPPUNIT_ASSERT_EQUAL(true, bool(getProperty
<sal_Bool
>(xParaEnum
->nextElement(), "ParaContextMargin")));
251 DECLARE_RTFIMPORT_TEST(testFdo45563
, "fdo45563.rtf")
253 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
254 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
255 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
257 while (xParaEnum
->hasMoreElements())
259 xParaEnum
->nextElement();
262 CPPUNIT_ASSERT_EQUAL(4, i
);
265 DECLARE_RTFIMPORT_TEST(testFdo43965
, "fdo43965.rtf")
267 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
268 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
269 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
271 // First paragraph: the parameter of \up was ignored
272 uno::Reference
<container::XEnumerationAccess
> xRangeEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
273 uno::Reference
<container::XEnumeration
> xRangeEnum
= xRangeEnumAccess
->createEnumeration();
274 uno::Reference
<beans::XPropertySet
> xPropertySet(xRangeEnum
->nextElement(), uno::UNO_QUERY
);
275 CPPUNIT_ASSERT_EQUAL(sal_Int32(36), getProperty
<sal_Int32
>(xPropertySet
, "CharEscapement"));
276 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(xPropertySet
, "CharEscapementHeight"));
278 // Second paragraph: Word vs Writer border default problem
279 CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty
<table::BorderLine2
>(xParaEnum
->nextElement(), "TopBorder").LineWidth
);
281 // Finally, make sure that we have two pages
282 CPPUNIT_ASSERT_EQUAL(2, getPages());
285 DECLARE_RTFIMPORT_TEST(testN751020
, "n751020.rtf")
287 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
288 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
289 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
290 CPPUNIT_ASSERT(xParaEnum
->hasMoreElements());
291 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(200)), getProperty
<sal_Int32
>(xParaEnum
->nextElement(), "ParaBottomMargin"));
294 DECLARE_RTFIMPORT_TEST(testFdo79384
, "fdo79384.rtf")
296 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
298 CPPUNIT_ASSERT_EQUAL(OUString("Маркеры спискамЫ", 31, RTL_TEXTENCODING_UTF8
), xTextRange
->getString());
301 DECLARE_RTFIMPORT_TEST(testFdo47326
, "fdo47326.rtf")
303 // This was 15 only, as \super buffered text, then the contents of it got lost.
304 CPPUNIT_ASSERT_EQUAL(19, getLength());
307 DECLARE_RTFIMPORT_TEST(testFdo47036
, "fdo47036.rtf")
309 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
310 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
311 int nAtCharacter
= 0;
312 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
314 if (getProperty
<text::TextContentAnchorType
>(xDraws
->getByIndex(i
), "AnchorType") == text::TextContentAnchorType_AT_CHARACTER
)
317 // The image at the document start was ignored.
318 CPPUNIT_ASSERT_EQUAL(1, nAtCharacter
);
320 // There should be 2 textboxes, not 4
321 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
322 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
323 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
326 DECLARE_RTFIMPORT_TEST(testFdo46955
, "fdo46955.rtf")
328 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
329 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
330 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
331 while (xParaEnum
->hasMoreElements())
333 uno::Reference
<container::XEnumerationAccess
> xRangeEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
334 uno::Reference
<container::XEnumeration
> xRangeEnum
= xRangeEnumAccess
->createEnumeration();
335 while (xRangeEnum
->hasMoreElements())
336 CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE
, getProperty
<sal_Int16
>(xRangeEnum
->nextElement(), "CharCaseMap"));
340 DECLARE_RTFIMPORT_TEST(testFdo81892
, "fdo81892.rtf")
342 // table was not centered
343 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
344 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
345 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
346 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER
, getProperty
<sal_Int16
>(xTable
, "HoriOrient"));
348 // fdo#81893: paragraph with \page was not centered
349 uno::Reference
<text::XTextRange
> xPara(getParagraph(2, "Performance"));
350 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(xPara
, "ParaAdjust")));
353 DECLARE_RTFIMPORT_TEST(testFdo45394
, "fdo45394.rtf")
355 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "HeaderText");
356 OUString aActual
= xHeaderText
->getString();
357 // Encoding in the header was wrong.
358 OUString
aExpected("\xd0\x9f\xd0\x9a \xd0\xa0\xd0\x98\xd0\x9a", 11, RTL_TEXTENCODING_UTF8
);
359 CPPUNIT_ASSERT_EQUAL(aExpected
, aActual
);
361 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
362 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
363 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess
->getCount());
366 DECLARE_RTFIMPORT_TEST(testFdo48104
, "fdo48104.rtf")
368 CPPUNIT_ASSERT_EQUAL(2, getPages());
371 DECLARE_RTFIMPORT_TEST(testFdo47107
, "fdo47107.rtf")
373 uno::Reference
<container::XNameAccess
> xNumberingStyles(getStyles("NumberingStyles"));
374 // Make sure numbered and bullet legacy syntax is recognized, this used to throw a NoSuchElementException
375 xNumberingStyles
->getByName("WWNum1");
376 xNumberingStyles
->getByName("WWNum2");
379 DECLARE_RTFIMPORT_TEST(testFdo45182
, "fdo45182.rtf")
381 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
382 uno::Reference
<container::XIndexAccess
> xFootnotes(xFootnotesSupplier
->getFootnotes(), uno::UNO_QUERY
);
383 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
384 // Encoding in the footnote was wrong.
385 OUString
aExpected("\xc5\xbeivnost\xc3\xad\n", 11, RTL_TEXTENCODING_UTF8
);
386 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
389 DECLARE_RTFIMPORT_TEST(testFdo44176
, "fdo44176.rtf")
391 uno::Reference
<container::XNameAccess
> xPageStyles(getStyles("PageStyles"));
392 uno::Reference
<beans::XPropertySet
> xFirstPage(xPageStyles
->getByName("First Page"), uno::UNO_QUERY
);
393 uno::Reference
<beans::XPropertySet
> xDefault(xPageStyles
->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
394 sal_Int32 nFirstTop
= 0, nDefaultTop
= 0, nDefaultHeader
= 0;
395 xFirstPage
->getPropertyValue("TopMargin") >>= nFirstTop
;
396 xDefault
->getPropertyValue("TopMargin") >>= nDefaultTop
;
397 xDefault
->getPropertyValue("HeaderHeight") >>= nDefaultHeader
;
398 CPPUNIT_ASSERT_EQUAL(nFirstTop
, nDefaultTop
+ nDefaultHeader
);
401 DECLARE_RTFIMPORT_TEST(testFdo39053
, "fdo39053.rtf")
403 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
404 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
405 int nAsCharacter
= 0;
406 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
407 if (getProperty
<text::TextContentAnchorType
>(xDraws
->getByIndex(i
), "AnchorType") == text::TextContentAnchorType_AS_CHARACTER
)
409 // The image in binary format was ignored.
410 CPPUNIT_ASSERT_EQUAL(1, nAsCharacter
);
413 DECLARE_RTFIMPORT_TEST(testFdo48356
, "fdo48356.rtf")
415 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
416 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
417 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
419 while (xParaEnum
->hasMoreElements())
421 xParaEnum
->nextElement();
424 // The document used to be imported as two paragraphs.
425 CPPUNIT_ASSERT_EQUAL(1, i
);
428 DECLARE_RTFIMPORT_TEST(testFdo48023
, "fdo48023.rtf")
430 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
432 // Implicit encoding detection based on locale was missing
433 OUString
aExpected("\xd0\x9f\xd1\x80\xd0\xbe\xd0\xb3\xd1\x80\xd0\xb0\xd0\xbc\xd0\xbc\xd0\xb8\xd1\x81\xd1\x82", 22, RTL_TEXTENCODING_UTF8
);
434 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
437 DECLARE_RTFIMPORT_TEST(testFdo48876
, "fdo48876.rtf")
439 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
440 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
441 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
442 CPPUNIT_ASSERT(xParaEnum
->hasMoreElements());
443 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::MINIMUM
, getProperty
<style::LineSpacing
>(xParaEnum
->nextElement(), "ParaLineSpacing").Mode
);
446 DECLARE_RTFIMPORT_TEST(testFdo48193
, "fdo48193.rtf")
448 CPPUNIT_ASSERT_EQUAL(7, getLength());
451 DECLARE_RTFIMPORT_TEST(testFdo44211
, "fdo44211.rtf")
453 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
455 OUString
aExpected("\xc4\x85\xc4\x8d\xc4\x99", 6, RTL_TEXTENCODING_UTF8
);
456 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
459 DECLARE_RTFIMPORT_TEST(testFdo48037
, "fdo48037.rtf")
461 uno::Reference
<util::XNumberFormatsSupplier
> xNumberSupplier(mxComponent
, uno::UNO_QUERY_THROW
);
462 lang::Locale aUSLocale
, aFRLocale
;
463 aUSLocale
.Language
= "en";
464 aFRLocale
.Language
= "fr";
465 sal_Int32 nExpected
= xNumberSupplier
->getNumberFormats()->addNewConverted("d MMMM yyyy", aUSLocale
, aFRLocale
);
467 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
468 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
469 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
470 uno::Reference
<beans::XPropertySet
> xPropertySet(xFields
->nextElement(), uno::UNO_QUERY
);
471 sal_Int32 nActual
= 0;
472 xPropertySet
->getPropertyValue("NumberFormat") >>= nActual
;
474 CPPUNIT_ASSERT_EQUAL(nExpected
, nActual
);
477 DECLARE_RTFIMPORT_TEST(testFdo85812
, "fdo85812.rtf")
479 lang::Locale
locale(getProperty
<lang::Locale
>(getRun(getParagraph(1), 1, "This "), "CharLocale"));
480 // the \lang inside the group was applied to CJK not Western
481 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
482 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
483 // further testing indicates that Word is doing really weird stuff
484 // \loch \hich \dbch is reset by opening a group
485 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(2), 1, "CharGroup"), "CharLocale");
486 CPPUNIT_ASSERT_EQUAL(OUString("ru"), locale
.Language
);
487 CPPUNIT_ASSERT_EQUAL(OUString("RU"), locale
.Country
);
488 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(2), 2, "AfterChar"), "CharLocale");
489 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
490 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
491 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(3), 2, "AfterBookmark"), "CharLocale");
492 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
493 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
494 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 1, "CharGroup"), "CharLocale");
495 CPPUNIT_ASSERT_EQUAL(OUString("ru"), locale
.Language
);
496 CPPUNIT_ASSERT_EQUAL(OUString("RU"), locale
.Country
);
497 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 1, "CharGroup"), "CharLocaleComplex");
498 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
499 CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale
.Country
);
500 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 2, "AfterChar"), "CharLocale");
501 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
502 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
503 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(4), 2, "AfterChar"), "CharLocaleComplex");
504 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
505 CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale
.Country
);
506 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(5), 2, "AfterBookmark"), "CharLocale");
507 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
508 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
509 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(5), 2, "AfterBookmark"), "CharLocaleComplex");
510 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
511 CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale
.Country
);
512 // \ltrch \rtlch works differently - it is sticky across groups
513 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 1, "CharGroup"), "CharLocale");
514 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
515 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
516 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 1, "CharGroup"), "CharLocaleComplex");
517 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
518 CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale
.Country
);
519 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 2, "AfterChar"), "CharLocale");
520 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
521 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
522 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(6), 2, "AfterChar"), "CharLocaleComplex");
523 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
524 CPPUNIT_ASSERT_EQUAL(OUString("EG"), locale
.Country
);
525 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(7), 2, "AfterBookmark"), "CharLocale");
526 CPPUNIT_ASSERT_EQUAL(OUString("en"), locale
.Language
);
527 CPPUNIT_ASSERT_EQUAL(OUString("US"), locale
.Country
);
528 locale
= getProperty
<lang::Locale
>(getRun(getParagraph(7), 2, "AfterBookmark"), "CharLocaleComplex");
529 CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale
.Language
);
530 CPPUNIT_ASSERT_EQUAL(OUString("EG"), locale
.Country
);
533 DECLARE_RTFIMPORT_TEST(testFdo47764
, "fdo47764.rtf")
535 // \cbpat with zero argument should mean the auto (-1) color, not a default color (black)
536 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(getParagraph(1), "ParaBackColor"));
539 DECLARE_RTFIMPORT_TEST(testFdo38786
, "fdo38786.rtf")
541 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
542 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
543 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
544 // \chpgn was ignored, so exception was thrown
545 xFields
->nextElement();
548 DECLARE_RTFIMPORT_TEST(testN757651
, "n757651.rtf")
550 // The bug was that due to buggy layout the text expanded to two pages.
551 if (Application::GetDefaultDevice()->IsFontAvailable(OUString("Times New Roman")))
552 CPPUNIT_ASSERT_EQUAL(1, getPages());
555 DECLARE_RTFIMPORT_TEST(testFdo49501
, "fdo49501.rtf")
557 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
559 CPPUNIT_ASSERT_EQUAL(sal_True
, getProperty
<sal_Bool
>(xStyle
, "IsLandscape"));
560 sal_Int32
nExpected(convertTwipToMm100(567));
561 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "LeftMargin"));
562 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "RightMargin"));
563 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "TopMargin"));
564 CPPUNIT_ASSERT_EQUAL(nExpected
, getProperty
<sal_Int32
>(xStyle
, "BottomMargin"));
567 DECLARE_RTFIMPORT_TEST(testFdo49271
, "fdo49271.rtf")
569 CPPUNIT_ASSERT_EQUAL(25.f
, getProperty
<float>(getParagraph(2), "CharHeight"));
572 DECLARE_RTFIMPORT_TEST(testFdo49692
, "fdo49692.rtf")
574 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
575 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
576 uno::Sequence
<beans::PropertyValue
> aProps
;
577 xLevels
->getByIndex(0) >>= aProps
; // 1st level
579 for (int i
= 0; i
< aProps
.getLength(); ++i
)
581 const beans::PropertyValue
& rProp
= aProps
[i
];
583 if (rProp
.Name
== "Suffix")
585 OUString
aExpected(static_cast<sal_Unicode
>(0x200B));
586 CPPUNIT_ASSERT_EQUAL(aExpected
, rProp
.Value
.get
<OUString
>());
591 DECLARE_RTFIMPORT_TEST(testFdo45190
, "fdo45190.rtf")
593 // inherited \fi should be reset
594 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(getParagraph(1), "ParaFirstLineIndent"));
596 // but direct one not
597 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-100)), getProperty
<sal_Int32
>(getParagraph(2), "ParaFirstLineIndent"));
600 DECLARE_RTFIMPORT_TEST(testFdo50539
, "fdo50539.rtf")
602 // \chcbpat with zero argument should mean the auto (-1) color, not a default color (black)
603 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(getRun(getParagraph(1), 1), "CharBackColor"));
606 DECLARE_RTFIMPORT_TEST(testFdo50665
, "fdo50665.rtf")
608 // Access the second run, which is a textfield
609 uno::Reference
<beans::XPropertySet
> xRun(getRun(getParagraph(1), 2), uno::UNO_QUERY
);
610 // This used to be the default, as character properties were ignored.
611 CPPUNIT_ASSERT_EQUAL(OUString("Book Antiqua"), getProperty
<OUString
>(xRun
, "CharFontName"));
614 DECLARE_RTFIMPORT_TEST(testFdo49659
, "fdo49659.rtf")
616 // Both tables were ignored: 1) was in the header, 2) was ignored due to missing empty par at the end of the doc
617 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
618 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
619 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
621 // The graphic was also empty
622 uno::Reference
<beans::XPropertySet
> xGraphic(getProperty
< uno::Reference
<beans::XPropertySet
> >(getShape(1), "Graphic"), uno::UNO_QUERY
);
623 CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL
, getProperty
<sal_Int8
>(xGraphic
, "GraphicType"));
626 DECLARE_RTFIMPORT_TEST(testFdo46966
, "fdo46966.rtf")
629 * The problem was the top margin was 1440 (1 inch), but it should be 720 (0.5 inch).
631 * xray ThisComponent.StyleFamilies.PageStyles.Default.TopMargin
633 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
634 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(720)), getProperty
<sal_Int32
>(xPropertySet
, "TopMargin"));
637 DECLARE_RTFIMPORT_TEST(testFdo52066
, "fdo52066.rtf")
640 * The problem was that the height of the shape was too big.
642 * xray ThisComponent.DrawPage(0).Size.Height
644 uno::Reference
<drawing::XShape
> xShape(getShape(1), uno::UNO_QUERY
);
645 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(19)), xShape
->getSize().Height
);
648 DECLARE_RTFIMPORT_TEST(testFdo76633
, "fdo76633.rtf")
650 // check that there is only a graphic object, not an additional rectangle
651 uno::Reference
<lang::XServiceInfo
> xShape(getShape(1), uno::UNO_QUERY
);
652 CPPUNIT_ASSERT(xShape
.is());
653 CPPUNIT_ASSERT(xShape
->supportsService("com.sun.star.text.TextGraphicObject"));
656 uno::Reference
<drawing::XShape
> xShape2(getShape(2), uno::UNO_QUERY
);
657 CPPUNIT_FAIL("exception expected");
659 catch (lang::IndexOutOfBoundsException
const&)
665 DECLARE_RTFIMPORT_TEST(testFdo48033
, "fdo48033.rtf")
668 * The problem was that the picture (48033) or OLE object (53594) was in the first cell,
669 * instead of the second one.
671 * oTable = ThisComponent.TextTables(0)
672 * oParas = oTable.getCellByName("B1").Text.createEnumeration
673 * oPara = oParas.nextElement
674 * oRuns = oPara.createEnumeration
675 * oRun = oRuns.nextElement
676 * xray oRun.TextPortionType ' Frame, was Text
678 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
679 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
680 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
681 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
682 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
683 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
684 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
685 CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty
<OUString
>(getRun(xPara
, 1), "TextPortionType"));
688 DECLARE_RTFIMPORT_TEST(testFdo53594
, "fdo53594.rtf")
691 * The problem was that the picture (48033) or OLE object (53594) was in the first cell,
692 * instead of the second one.
694 * oTable = ThisComponent.TextTables(0)
695 * oParas = oTable.getCellByName("B1").Text.createEnumeration
696 * oPara = oParas.nextElement
697 * oRuns = oPara.createEnumeration
698 * oRun = oRuns.nextElement
699 * xray oRun.TextPortionType ' Frame, was Text
701 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
702 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
703 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
704 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
705 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
706 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
707 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
708 CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty
<OUString
>(getRun(xPara
, 1), "TextPortionType"));
711 DECLARE_RTFIMPORT_TEST(testFdo36089
, "fdo36089.rtf")
713 CPPUNIT_ASSERT_EQUAL(sal_Int16(-50), getProperty
<sal_Int16
>(getRun(getParagraph(1), 2), "CharEscapement"));
716 DECLARE_RTFIMPORT_TEST(testFdo49892
, "fdo49892.rtf")
718 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
719 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
720 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
722 OUString aDescription
= getProperty
<OUString
>(xDraws
->getByIndex(i
), "Description");
723 if (aDescription
== "red")
724 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
725 else if (aDescription
== "green")
726 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
727 else if (aDescription
== "blue")
728 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
729 else if (aDescription
== "rect")
731 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xDraws
->getByIndex(i
), "HoriOrientRelation"));
732 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xDraws
->getByIndex(i
), "VertOrientRelation"));
737 DECLARE_RTFIMPORT_TEST(testFdo48446
, "fdo48446.rtf")
739 OUString
aExpected("\xd0\x98\xd0\xbc\xd1\x8f", 6, RTL_TEXTENCODING_UTF8
);
740 getParagraph(1, aExpected
);
743 DECLARE_RTFIMPORT_TEST(testFdo47495
, "fdo47495.rtf")
745 // Used to have 4 paragraphs, as a result the original bugdoc had 2 pages instead of 1.
746 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
749 DECLARE_RTFIMPORT_TEST(testAllGapsWord
, "all_gaps_word.rtf")
751 BorderTest borderTest
;
752 BorderTest::testTheBorders(mxComponent
, false);
755 DECLARE_RTFIMPORT_TEST(testFdo52052
, "fdo52052.rtf")
757 // Make sure the textframe containing the text "third" appears on the 3rd page.
758 CPPUNIT_ASSERT_EQUAL(OUString("third"), parseDump("/root/page[3]/body/txt/anchored/fly/txt/text()"));
761 DECLARE_RTFIMPORT_TEST(testInk
, "ink.rtf")
764 * The problem was that the second segment had wrong command count and wrap type.
766 * oShape = ThisComponent.DrawPage(0)
767 * oPathPropVec = oShape.CustomShapeGeometry(1).Value
768 * oSegments = oPathPropVec(1).Value
769 * msgbox oSegments(1).Count ' was 0x2000 | 10, should be 10
770 * msgbox oShape.Surround ' was 2, should be 1
772 uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(getShape(1), "CustomShapeGeometry");
773 uno::Sequence
<beans::PropertyValue
> aPathProps
;
774 for (int i
= 0; i
< aProps
.getLength(); ++i
)
776 const beans::PropertyValue
& rProp
= aProps
[i
];
777 if (rProp
.Name
== "Path")
778 rProp
.Value
>>= aPathProps
;
780 uno::Sequence
<drawing::EnhancedCustomShapeSegment
> aSegments
;
781 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
783 const beans::PropertyValue
& rProp
= aPathProps
[i
];
784 if (rProp
.Name
== "Segments")
785 rProp
.Value
>>= aSegments
;
787 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aSegments
[1].Count
);
788 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT
, getProperty
<text::WrapTextMode
>(getShape(1), "Surround"));
791 DECLARE_RTFIMPORT_TEST(testFdo52389
, "fdo52389.rtf")
793 // The last '!' character at the end of the document was lost
794 CPPUNIT_ASSERT_EQUAL(6, getLength());
797 DECLARE_RTFIMPORT_TEST(testFdo49655
, "fdo49655.rtf")
801 * The problem was that the table was not imported due to the ' ' string in the middle of the table definition.
803 * xray ThisComponent.TextTables.Count 'was 0
805 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
806 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
807 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess
->getCount());
810 DECLARE_RTFIMPORT_TEST(testFdo62805
, "fdo62805.rtf")
814 * The problem was that the table was not imported due to the absence of \pard after \row.
815 * The table was instead in a group (the '}' replace the \pard).
817 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
818 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
819 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess
->getCount());
822 DECLARE_RTFIMPORT_TEST(testFdo52475
, "fdo52475.rtf")
824 // The problem was that \chcbpat0 resulted in no color, instead of COL_AUTO.
825 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(getRun(getParagraph(1), 3), "CharBackColor"));
828 DECLARE_RTFIMPORT_TEST(testFdo55493
, "fdo55493.rtf")
830 // The problem was that the width of the PNG was detected as 15,24cm, instead of 3.97cm
831 uno::Reference
<drawing::XShape
> xShape(getShape(1), uno::UNO_QUERY
);
832 CPPUNIT_ASSERT_EQUAL(sal_Int32(3969), xShape
->getSize().Width
);
835 DECLARE_RTFIMPORT_TEST(testCopyPastePageStyle
, "copypaste-pagestyle.rtf")
837 // The problem was that RTF import during copy&paste did not ignore page styles.
838 // Once we have more copy&paste tests, makes sense to refactor this to some helper method.
839 paste("copypaste-pagestyle-paste.rtf");
841 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
842 CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), getProperty
<sal_Int32
>(xPropertySet
, "Width")); // Was letter, i.e. 21590
845 DECLARE_RTFIMPORT_TEST(testCopyPasteFootnote
, "copypaste-footnote.rtf")
847 // The RTF import did not handle the case when the position wasn't the main document XText, but something different, e.g. a footnote.
848 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
849 uno::Reference
<container::XIndexAccess
> xFootnotes(xFootnotesSupplier
->getFootnotes(), uno::UNO_QUERY
);
850 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
851 paste("copypaste-footnote-paste.rtf", xTextRange
);
853 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange
->getString());
856 DECLARE_RTFIMPORT_TEST(testFdo61193
, "hello.rtf")
858 // Pasting content that contained a footnote caused a crash.
859 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
860 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
861 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
862 paste("fdo61193.rtf", xEnd
);
865 DECLARE_RTFIMPORT_TEST(testShptxtPard
, "shptxt-pard.rtf")
867 // The problem was that \pard inside \shptxt caused loss of shape text
868 uno::Reference
<text::XText
> xText(getShape(1), uno::UNO_QUERY
);
869 CPPUNIT_ASSERT_EQUAL(OUString("shape text"), xText
->getString());
872 DECLARE_RTFIMPORT_TEST(testDoDhgt
, "do-dhgt.rtf")
874 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
875 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
876 for (int i
= 0; i
< xDraws
->getCount(); ++i
)
878 sal_Int32 nFillColor
= getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "FillColor");
879 if (nFillColor
== 0xc0504d) // red
880 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
881 else if (nFillColor
== 0x9bbb59) // green
882 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
883 else if (nFillColor
== 0x4f81bd) // blue
884 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xDraws
->getByIndex(i
), "ZOrder"));
888 DECLARE_RTFIMPORT_TEST(testDplinehollow
, "dplinehollow.rtf")
890 uno::Reference
<beans::XPropertySet
> xPropertySet(getShape(1), uno::UNO_QUERY
);
891 table::BorderLine2
line(getProperty
<table::BorderLine2
>(xPropertySet
, "TopBorder"));
892 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE
, line
.LineStyle
);
895 DECLARE_RTFIMPORT_TEST(testLeftmarginDefault
, "leftmargin-default.rtf")
897 // The default left/right margin was incorrect when the top margin was set to zero.
898 CPPUNIT_ASSERT_EQUAL(sal_Int32(2540), getProperty
<sal_Int32
>(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "LeftMargin"));
901 DECLARE_RTFIMPORT_TEST(testDppolyline
, "dppolyline.rtf")
903 // This was completely ignored, for now, just make sure we have all 4 lines.
904 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
905 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
906 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws
->getCount());
909 DECLARE_RTFIMPORT_TEST(testFdo79319
, "fdo79319.rtf")
911 // the thin horizontal rule was imported as a big fat rectangle
912 uno::Reference
<drawing::XShape
> xShape(getShape(1), uno::UNO_QUERY
);
913 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty
<sal_Int16
>(xShape
, "RelativeWidth"));
914 // FIXME the width/height numbers here are bogus; they should be 15238 / 53
915 // (as they are when opening the file in a full soffice)
917 CPPUNIT_ASSERT_EQUAL(sal_Int32(15238), xShape
->getSize().Width
);
918 CPPUNIT_ASSERT_EQUAL(sal_Int32(53), xShape
->getSize().Height
);
919 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER
, getProperty
<sal_Int16
>(xShape
, "VertOrient"));
920 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER
, getProperty
<sal_Int16
>(xShape
, "HoriOrient"));
924 DECLARE_RTFIMPORT_TEST(testFdo56512
, "fdo56512.rtf")
926 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
927 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
928 uno::Reference
<text::XTextRange
> xTextRange(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
929 OUString
aExpected("\xd7\xa2\xd7\x95\xd7\xa1\xd7\xa7 \xd7\x9e\xd7\x95\xd7\xa8\xd7\xa9\xd7\x94 ", 20, RTL_TEXTENCODING_UTF8
);
930 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
933 DECLARE_RTFIMPORT_TEST(testFdo52989
, "fdo52989.rtf")
935 // Same as n#192129, but for JPEG files.
936 uno::Reference
<drawing::XShape
> xShape(getShape(1), uno::UNO_QUERY
);
937 OString
aMessage("xShape->getSize().Width() = ");
938 aMessage
+= OString::number(xShape
->getSize().Width
);
940 // This was 2, should be 423 (or 369?).
941 CPPUNIT_ASSERT_MESSAGE(aMessage
.getStr(), xShape
->getSize().Width
>= 273);
944 DECLARE_RTFIMPORT_TEST(testFdo48442
, "fdo48442.rtf")
946 // The problem was that \pvmrg is the default in RTF, but not in Writer.
947 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
948 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
, getProperty
<sal_Int16
>(xShape
, "VertOrientRelation")); // was FRAME
951 DECLARE_RTFIMPORT_TEST(testFdo55525
, "fdo55525.rtf")
953 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
954 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
955 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
956 // Negative left margin was ~missing, -191
957 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty
<sal_Int32
>(xTable
, "LeftMargin"));
958 // Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
959 uno::Reference
<table::XTableRows
> xTableRows(xTable
->getRows(), uno::UNO_QUERY
);
960 CPPUNIT_ASSERT_EQUAL(sal_Int16(896), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators")[0].Position
);
963 DECLARE_RTFIMPORT_TEST(testFdo57708
, "fdo57708.rtf")
965 // There were two issues: the doc was of 2 pages and the picture was missing.
966 CPPUNIT_ASSERT_EQUAL(1, getPages());
967 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
968 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
969 // Two objects: a picture and a textframe.
970 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws
->getCount());
973 DECLARE_RTFIMPORT_TEST(testFdo54473
, "fdo54473.rtf")
975 // The problem was that character styles were not imported due to a typo.
976 CPPUNIT_ASSERT_EQUAL(OUString("Anot"), getProperty
<OUString
>(getRun(getParagraph(1), 1, "Text "), "CharStyleName"));
977 CPPUNIT_ASSERT_EQUAL(OUString("ForeignTxt"), getProperty
<OUString
>(getRun(getParagraph(1), 3, "character "), "CharStyleName"));
980 DECLARE_RTFIMPORT_TEST(testFdo49934
, "fdo49934.rtf")
982 // Column break without columns defined should be a page break, but it was just ignored.
983 CPPUNIT_ASSERT_EQUAL(2, getPages());
986 DECLARE_RTFIMPORT_TEST(testFdo57886
, "fdo57886.rtf")
988 // Was 'int from <?> to <?> <?>'.
989 CPPUNIT_ASSERT_EQUAL(OUString("int from {firstlower} to {firstupper} {firstbody}"), getFormula(getRun(getParagraph(1), 1)));
992 DECLARE_RTFIMPORT_TEST(testFdo58076
, "fdo58076.rtf")
994 // An additional section was created, so the default page style didn't have the custom margins.
995 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
996 CPPUNIT_ASSERT_EQUAL(sal_Int32(2251), getProperty
<sal_Int32
>(xStyle
, "LeftMargin"));
997 CPPUNIT_ASSERT_EQUAL(sal_Int32(1752), getProperty
<sal_Int32
>(xStyle
, "RightMargin"));
998 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty
<sal_Int32
>(xStyle
, "TopMargin"));
999 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty
<sal_Int32
>(xStyle
, "BottomMargin"));
1002 DECLARE_RTFIMPORT_TEST(testFdo57678
, "fdo57678.rtf")
1004 // Paragraphs of the two tables were not converted to tables.
1005 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1006 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1007 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
1010 DECLARE_RTFIMPORT_TEST(testFdo45183
, "fdo45183.rtf")
1012 // Was text::WrapTextMode_PARALLEL, i.e. shpfblwtxt didn't send the shape below text.
1013 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT
, getProperty
<text::WrapTextMode
>(getShape(1), "Surround"));
1015 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1016 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1017 // Was 247, resulting in a table having width almost zero and height of 10+ pages.
1018 CPPUNIT_ASSERT_EQUAL(sal_Int32(16237), getProperty
<sal_Int32
>(xTables
->getByIndex(0), "Width"));
1021 DECLARE_RTFIMPORT_TEST(testFdo54612
, "fdo54612.rtf")
1023 // \dpptx without a \dppolycount caused a crash.
1024 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1025 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1026 CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws
->getCount());
1029 DECLARE_RTFIMPORT_TEST(testFdo58933
, "fdo58933.rtf")
1031 // The problem was that the table had an additional cell in its first line.
1032 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1033 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1034 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1036 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable
->getCellNames().getLength());
1039 DECLARE_RTFIMPORT_TEST(testFdo44053
, "fdo44053.rtf")
1041 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1042 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1043 uno::Reference
<text::XTextTable
> xTextTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1044 uno::Reference
<table::XTableRows
> xTableRows(xTextTable
->getRows(), uno::UNO_QUERY
);
1045 // The with of the table's A1 and A2 cell should equal.
1046 CPPUNIT_ASSERT_EQUAL(getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators")[0].Position
,
1047 getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(1), "TableColumnSeparators")[0].Position
);
1050 DECLARE_RTFIMPORT_TEST(testFdo48440
, "fdo48440.rtf")
1052 // Page break was ignored.
1053 CPPUNIT_ASSERT_EQUAL(2, getPages());
1056 DECLARE_RTFIMPORT_TEST(testFdo58646line
, "fdo58646line.rtf")
1058 // \line symbol was ignored
1059 getParagraph(1, "foo\nbar");
1062 DECLARE_RTFIMPORT_TEST(testFdo78502
, "fdo78502.rtf")
1064 // ";" separators were inserted as text
1065 getParagraph(1, "foo");
1068 DECLARE_RTFIMPORT_TEST(testFdo58646
, "fdo58646.rtf")
1070 // Page break was ignored inside a continuous section, on title page.
1071 CPPUNIT_ASSERT_EQUAL(2, getPages());
1074 DECLARE_RTFIMPORT_TEST(testFdo59419
, "fdo59419.rtf")
1076 // Junk to be ignored broke import of the table.
1077 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1078 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1079 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables
->getCount());
1082 DECLARE_RTFIMPORT_TEST(testFdo58076_2
, "fdo58076-2.rtf")
1084 // Position of the picture wasn't correct.
1085 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(8345)), getProperty
<sal_Int32
>(getShape(1), "HoriOrientPosition"));
1088 DECLARE_RTFIMPORT_TEST(testFdo59953
, "fdo59953.rtf")
1090 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1091 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1092 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1093 // Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width)
1094 uno::Reference
<table::XTableRows
> xTableRows(xTable
->getRows(), uno::UNO_QUERY
);
1095 CPPUNIT_ASSERT_EQUAL(sal_Int16(7649), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators")[0].Position
);
1098 DECLARE_RTFIMPORT_TEST(testFdo59638
, "fdo59638.rtf")
1100 // The problem was that w:lvlOverride inside w:num was ignores by dmapper.
1102 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
1103 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
1104 uno::Sequence
<beans::PropertyValue
> aProps
;
1105 xLevels
->getByIndex(0) >>= aProps
; // 1st level
1107 for (int i
= 0; i
< aProps
.getLength(); ++i
)
1109 const beans::PropertyValue
& rProp
= aProps
[i
];
1111 if (rProp
.Name
== "BulletChar")
1113 // Was '*', should be 'o'.
1114 CPPUNIT_ASSERT_EQUAL(OUString("\xEF\x82\xB7", 3, RTL_TEXTENCODING_UTF8
), rProp
.Value
.get
<OUString
>());
1118 CPPUNIT_FAIL("no BulletChar property");
1121 DECLARE_RTFIMPORT_TEST(testFdo60722
, "fdo60722.rtf")
1123 // The problem was that the larger shape was over the smaller one, and not the other way around.
1124 uno::Reference
<beans::XPropertySet
> xShape(getShape(1), uno::UNO_QUERY
);
1125 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1126 CPPUNIT_ASSERT_EQUAL(OUString("larger"), getProperty
<OUString
>(xShape
, "Description"));
1128 xShape
.set(getShape(2), uno::UNO_QUERY
);
1129 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1130 CPPUNIT_ASSERT_EQUAL(OUString("smaller"), getProperty
<OUString
>(xShape
, "Description"));
1132 // Color of the line was blue, and it had zero width.
1133 xShape
.set(getShape(3), uno::UNO_QUERY
);
1134 CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty
<sal_uInt32
>(xShape
, "LineWidth"));
1135 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty
<sal_uInt32
>(xShape
, "LineColor"));
1138 DECLARE_RTFIMPORT_TEST(testDoDhgtOld
, "do-dhgt-old.rtf")
1140 // The file contains 3 shapes which have the same dhgt (z-order).
1141 // Test that the order is 1) a 2) black rectangle 3) b, and not something else
1142 uno::Reference
<text::XText
> xShape(getShape(1), uno::UNO_QUERY
);
1143 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1144 CPPUNIT_ASSERT_EQUAL(OUString("a"), xShape
->getString());
1146 xShape
.set(getShape(2), uno::UNO_QUERY
);
1147 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1148 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, getProperty
<sal_uInt32
>(xShape
, "FillColor"));
1150 xShape
.set(getShape(3), uno::UNO_QUERY
);
1151 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xShape
, "ZOrder"));
1152 CPPUNIT_ASSERT_EQUAL(OUString("b"), xShape
->getString());
1155 DECLARE_RTFIMPORT_TEST(testFdo61909
, "fdo61909.rtf")
1157 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
1158 // Was the Writer default font.
1159 CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty
<OUString
>(xTextRange
, "CharFontName"));
1160 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, getProperty
<sal_uInt32
>(xTextRange
, "CharBackColor"));
1163 DECLARE_RTFIMPORT_TEST(testFdo62288
, "fdo62288.rtf")
1165 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1166 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1167 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1168 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
1169 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
1170 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1171 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1172 // Margins were inherited from the previous cell, even there was a \pard there.
1173 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xPara
, "ParaLeftMargin"));
1176 DECLARE_RTFIMPORT_TEST(testFdo37716
, "fdo37716.rtf")
1178 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
1179 uno::Reference
<container::XIndexAccess
> xFrames(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
1180 // \nowrap got ignored, so Surround was text::WrapTextMode_PARALLEL
1181 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_NONE
, getProperty
<text::WrapTextMode
>(xFrames
->getByIndex(0), "Surround"));
1184 DECLARE_RTFIMPORT_TEST(testFdo51916
, "fdo51916.rtf")
1186 // Complex nested table caused a crash.
1189 DECLARE_RTFIMPORT_TEST(testFdo63023
, "fdo63023.rtf")
1191 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "HeaderText");
1192 // Back color was black (0) in the header, due to missing color table in the substream.
1193 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF99), getProperty
<sal_Int32
>(getRun(getParagraphOfText(1, xHeaderText
), 1), "CharBackColor"));
1196 DECLARE_RTFIMPORT_TEST(testFdo42109
, "fdo42109.rtf")
1198 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1199 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1200 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1201 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
1202 // Make sure the page number is imported as a field in the B1 cell.
1203 CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty
<OUString
>(getRun(getParagraphOfText(1, xCell
->getText()), 1), "TextPortionType"));
1206 DECLARE_RTFIMPORT_TEST(testFdo62977
, "fdo62977.rtf")
1208 // The middle character was imported as '?' instead of the proper unicode value.
1209 getRun(getParagraph(1), 1, OUString("\xE5\xB9\xB4\xEF\xBC\x94\xE6\x9C\x88", 9, RTL_TEXTENCODING_UTF8
));
1212 DECLARE_RTFIMPORT_TEST(testN818997
, "n818997.rtf")
1214 // \page was ignored between two \shp tokens.
1215 CPPUNIT_ASSERT_EQUAL(2, getPages());
1218 DECLARE_RTFIMPORT_TEST(testFdo64671
, "fdo64671.rtf")
1220 // Additional '}' was inserted before the special character.
1221 getRun(getParagraph(1), 1, OUString("\xC5\xBD", 2, RTL_TEXTENCODING_UTF8
));
1224 DECLARE_RTFIMPORT_TEST(testPageBackground
, "page-background.rtf")
1226 // The problem was that \background was ignored.
1227 uno::Reference
<beans::XPropertySet
> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
1228 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty
<sal_Int32
>(xPageStyle
, "BackColor"));
1231 DECLARE_RTFIMPORT_TEST(testFdo81944
, "fdo81944.rtf")
1233 // font properties in style were not imported
1234 uno::Reference
<beans::XPropertySet
> xPropertySet(
1235 getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY
);
1236 uno::Reference
<style::XStyle
> xStyle(xPropertySet
, uno::UNO_QUERY
);
1237 CPPUNIT_ASSERT_EQUAL(OUString("Segoe UI"), getProperty
<OUString
>(xStyle
, "CharFontName"));
1238 CPPUNIT_ASSERT_EQUAL(9.0f
, getProperty
<float>(xStyle
, "CharHeight"));
1239 // not sure if this should be set on Asian or Complex or both?
1240 CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), getProperty
<OUString
>(xStyle
, "CharFontNameComplex"));
1241 CPPUNIT_ASSERT_EQUAL(11.0f
, getProperty
<float>(xStyle
, "CharHeightComplex"));
1244 DECLARE_RTFIMPORT_TEST(testFdo62044
, "fdo62044.rtf")
1246 // The problem was that RTF import during copy&paste did not ignore existing paragraph styles.
1247 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1248 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
1249 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1250 paste("fdo62044-paste.rtf", xEnd
);
1252 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY
);
1253 CPPUNIT_ASSERT_EQUAL(10.f
, getProperty
<float>(xPropertySet
, "CharHeight")); // Was 18, i.e. reset back to original value.
1256 DECLARE_RTFIMPORT_TEST(testFdo70578
, "fdo70578.rtf")
1258 // Style without explicit \s0 was not imported as the default style
1259 uno::Reference
<beans::XPropertySet
> xPropertySet(
1260 getStyles("ParagraphStyles")->getByName("Subtitle"), uno::UNO_QUERY
);
1261 uno::Reference
<style::XStyle
> xStyle(xPropertySet
, uno::UNO_QUERY
);
1262 CPPUNIT_ASSERT_EQUAL(OUString("Standard"), xStyle
->getParentStyle());
1263 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xPropertySet
, "ParaTopMargin"));
1264 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xPropertySet
, "ParaBottomMargin"));
1267 DECLARE_RTFIMPORT_TEST(testPoshPosv
, "posh-posv.rtf")
1269 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER
, getProperty
<sal_Int16
>(getShape(1), "HoriOrient"));
1270 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER
, getProperty
<sal_Int16
>(getShape(1), "VertOrient"));
1271 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getShape(1), "FrameIsAutomaticHeight"));
1274 DECLARE_RTFIMPORT_TEST(testN825305
, "n825305.rtf")
1276 // The problem was that the textbox wasn't transparent, due to unimplemented fFilled == 0.
1277 uno::Reference
<beans::XPropertyState
> xPropertyState(getShape(2), uno::UNO_QUERY
);
1278 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(getShape(2), "BackColorTransparency"));
1279 beans::PropertyState ePropertyState
= xPropertyState
->getPropertyState("BackColorTransparency");
1280 // Was beans::PropertyState_DEFAULT_VALUE.
1281 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
, ePropertyState
);
1284 DECLARE_RTFIMPORT_TEST(testParaBottomMargin
, "para-bottom-margin.rtf")
1286 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY
);
1287 CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty
<sal_Int32
>(xPropertySet
, "ParaBottomMargin"));
1289 // This was 353, i.e. bottom margin of the paragraph was 0.35cm instead of 0.
1290 // The reason why this is 0 despite the default style containing \sa200
1291 // is that Word will actually interpret \sN (or \pard which apparently
1292 // implies \s0) as "set style N and for every attribute of that style,
1293 // set an attribute with default value on the paragraph"
1294 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(getParagraph(1), "ParaBottomMargin"));
1295 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(getParagraph(1), "ParaTopMargin"));
1298 DECLARE_RTFIMPORT_TEST(testN823655
, "n823655.rtf")
1300 uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(getShape(1), "CustomShapeGeometry");
1301 uno::Sequence
<beans::PropertyValue
> aPathProps
;
1302 for (int i
= 0; i
< aProps
.getLength(); ++i
)
1304 const beans::PropertyValue
& rProp
= aProps
[i
];
1305 if (rProp
.Name
== "Path")
1306 aPathProps
= rProp
.Value
.get
< uno::Sequence
<beans::PropertyValue
> >();
1308 uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> aCoordinates
;
1309 for (int i
= 0; i
< aPathProps
.getLength(); ++i
)
1311 const beans::PropertyValue
& rProp
= aPathProps
[i
];
1312 if (rProp
.Name
== "Coordinates")
1313 aCoordinates
= rProp
.Value
.get
< uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> >();
1315 // The first coordinate pair of this freeform shape was 286,0 instead of 0,286.
1316 CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates
[0].Second
.Value
.get
<sal_Int32
>());
1319 DECLARE_RTFIMPORT_TEST(testFdo66040
, "fdo66040.rtf")
1321 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1322 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1323 // This was 0 (no shapes were imported), we want two textframes.
1324 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws
->getCount());
1326 // The second paragraph of the first shape should be actually a table, with "A" in its A1 cell.
1327 uno::Reference
<text::XTextRange
> xTextRange(xDraws
->getByIndex(0), uno::UNO_QUERY
);
1328 uno::Reference
<text::XText
> xText
= xTextRange
->getText();
1329 uno::Reference
<text::XTextTable
> xTable(getParagraphOrTable(2, xText
), uno::UNO_QUERY
);
1330 CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference
<text::XTextRange
>(xTable
->getCellByName("A1"), uno::UNO_QUERY
)->getString());
1332 // Make sure the second shape has the correct position and size.
1333 uno::Reference
<drawing::XShape
> xShape(xDraws
->getByIndex(1), uno::UNO_QUERY
);
1334 CPPUNIT_ASSERT_EQUAL(sal_Int32(14420), getProperty
<sal_Int32
>(xShape
, "HoriOrientPosition"));
1335 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1032), getProperty
<sal_Int32
>(xShape
, "VertOrientPosition"));
1336 CPPUNIT_ASSERT_EQUAL(sal_Int32(14000), xShape
->getSize().Width
);
1337 CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), xShape
->getSize().Height
);
1340 DECLARE_RTFIMPORT_TEST(testN823675
, "n823675.rtf")
1342 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
1343 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
1344 uno::Sequence
<beans::PropertyValue
> aProps
;
1345 xLevels
->getByIndex(0) >>= aProps
; // 1st level
1346 awt::FontDescriptor aFont
;
1348 for (int i
= 0; i
< aProps
.getLength(); ++i
)
1350 const beans::PropertyValue
& rProp
= aProps
[i
];
1352 if (rProp
.Name
== "BulletFont")
1353 aFont
= rProp
.Value
.get
<awt::FontDescriptor
>();
1355 // This was empty, i.e. no font name was set for the bullet numbering.
1356 CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), aFont
.Name
);
1359 DECLARE_RTFIMPORT_TEST(testFdo77996
, "fdo77996.rtf")
1361 // all styles were imported as name "0"
1362 uno::Reference
<container::XNameAccess
> xChars(getStyles("CharacterStyles"));
1363 CPPUNIT_ASSERT(!xChars
->hasByName("0"));
1364 CPPUNIT_ASSERT(xChars
->hasByName("strong"));
1365 CPPUNIT_ASSERT(xChars
->hasByName("author"));
1366 uno::Reference
<container::XNameAccess
> xParas(getStyles("ParagraphStyles"));
1367 CPPUNIT_ASSERT(!xParas
->hasByName("0"));
1368 CPPUNIT_ASSERT(xParas
->hasByName("extract2"));
1369 // some document properties were lost
1370 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(mxComponent
, uno::UNO_QUERY
);
1371 uno::Reference
<document::XDocumentProperties
> xProps(xDocumentPropertiesSupplier
->getDocumentProperties());
1372 CPPUNIT_ASSERT_EQUAL(OUString("Aln Lin (Bei Jing)"), xProps
->getAuthor());
1373 OUString
aTitle("\xe5\x8e\xa6\xe9\x97\xa8\xe9\x92\xa8\xe4\xb8\x9a\xe8\x82\xa1\xe4\xbb\xbd\xe6\x9c\x89\xe9\x99\x90\xe5\x85\xac\xe5\x8f\xb8", 30, RTL_TEXTENCODING_UTF8
);
1374 CPPUNIT_ASSERT_EQUAL(aTitle
, xProps
->getTitle());
1375 uno::Reference
<beans::XPropertySet
> xUDProps(xProps
->getUserDefinedProperties(), uno::UNO_QUERY
);
1376 CPPUNIT_ASSERT_EQUAL(OUString("jay"), getProperty
<OUString
>(xUDProps
, "Operator"));
1378 // fdo#80486 also check that the ftnsep doesn't insert paragraph breaks
1379 getParagraph(1, aTitle
);
1382 DECLARE_RTFIMPORT_TEST(testFdo47802
, "fdo47802.rtf")
1384 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1385 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1386 // Shape inside table was ignored.
1387 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws
->getCount());
1390 DECLARE_RTFIMPORT_TEST(testFdo39001
, "fdo39001.rtf")
1392 // Document was of 4 pages, \sect at the end of the doc wasn't ignored.
1393 CPPUNIT_ASSERT_EQUAL(3, getPages());
1396 DECLARE_RTFIMPORT_TEST(testGroupshape
, "groupshape.rtf")
1398 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1399 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1400 // There should be a single groupshape with 2 children.
1401 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws
->getCount());
1402 uno::Reference
<drawing::XShapes
> xGroupshape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
1403 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape
->getCount());
1406 DECLARE_RTFIMPORT_TEST(testGroupshape_notext
, "groupshape-notext.rtf")
1408 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1409 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1410 // There should be a single groupshape with 2 children.
1411 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws
->getCount());
1412 uno::Reference
<drawing::XShapes
> xGroupshape(xDraws
->getByIndex(0), uno::UNO_QUERY
);
1413 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape
->getCount());
1416 DECLARE_RTFIMPORT_TEST(testFdo81033
, "fdo81033.rtf")
1418 // Number of tabstops in the paragraph should be 2, was 3.
1419 uno::Sequence
<style::TabStop
> tabs(
1420 getProperty
< uno::Sequence
<style::TabStop
> >(getParagraph(1), "ParaTabStops"));
1421 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabs
.getLength());
1422 CPPUNIT_ASSERT_EQUAL(sal_Int32(5808), tabs
[0].Position
);
1423 CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT
, tabs
[0].Alignment
);
1424 CPPUNIT_ASSERT_EQUAL(sal_Unicode(' '), tabs
[0].FillChar
);
1425 CPPUNIT_ASSERT_EQUAL(sal_Int32(16002), tabs
[1].Position
);
1426 CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT
, tabs
[1].Alignment
);
1427 CPPUNIT_ASSERT_EQUAL(sal_Unicode('_'), tabs
[1].FillChar
);
1430 DECLARE_RTFIMPORT_TEST(testFdo66565
, "fdo66565.rtf")
1432 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1433 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1434 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1435 // Cell width of A2 was 554, should be 453/14846*10000
1436 uno::Reference
<table::XTableRows
> xTableRows(xTable
->getRows(), uno::UNO_QUERY
);
1437 CPPUNIT_ASSERT_EQUAL(sal_Int16(304), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(1), "TableColumnSeparators")[0].Position
);
1440 DECLARE_RTFIMPORT_TEST(testFdo54900
, "fdo54900.rtf")
1442 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1443 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1444 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1445 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1446 // Paragraph was aligned to left, should be center.
1447 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(getParagraphOfText(1, xCell
->getText()), "ParaAdjust")));
1450 DECLARE_RTFIMPORT_TEST(testFdo64637
, "fdo64637.rtf")
1452 // The problem was that the custom "Company" property was added twice, the second invocation resulted in an exception.
1453 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(mxComponent
, uno::UNO_QUERY
);
1454 uno::Reference
<beans::XPropertySet
> xPropertySet(xDocumentPropertiesSupplier
->getDocumentProperties()->getUserDefinedProperties(), uno::UNO_QUERY
);
1455 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getProperty
<OUString
>(xPropertySet
, "Company"));
1458 DECLARE_RTFIMPORT_TEST(testN820504
, "n820504.rtf")
1460 // The shape was anchored at-page instead of at-character (that's incorrect as Word only supports at-character and as-character).
1461 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER
, getProperty
<text::TextContentAnchorType
>(getShape(1), "AnchorType"));
1464 DECLARE_RTFIMPORT_TEST(testFdo67365
, "fdo67365.rtf")
1466 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1467 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1468 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1469 uno::Reference
<table::XTableRows
> xRows
= xTable
->getRows();
1470 // The table only had 3 rows.
1471 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xRows
->getCount());
1472 // This was 4999, i.e. the two cells of the row had equal widths instead of a larger and a smaller cell.
1473 CPPUNIT_ASSERT_EQUAL(sal_Int16(5290), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xRows
->getByIndex(2), "TableColumnSeparators")[0].Position
);
1474 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A2"), uno::UNO_QUERY
);
1475 // Paragraph was aligned to center, should be left.
1476 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT
, static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(getParagraphOfText(1, xCell
->getText()), "ParaAdjust")));
1479 DECLARE_RTFIMPORT_TEST(testFdo67498
, "fdo67498.rtf")
1481 // Left margin of the default page style wasn't set (was 2000).
1482 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(5954)), getProperty
<sal_Int32
>(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "LeftMargin"));
1485 DECLARE_RTFIMPORT_TEST(testFdo47440
, "fdo47440.rtf")
1487 // Vertical and horizontal orientation of the picture wasn't imported (was text::RelOrientation::FRAME).
1488 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(getShape(1), "HoriOrientRelation"));
1489 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(getShape(1), "VertOrientRelation"));
1492 DECLARE_RTFIMPORT_TEST(testFdo53556
, "fdo53556.rtf")
1494 // This was drawing::FillStyle_SOLID, which resulted in being non-transparent, hiding text which would be visible.
1495 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, getProperty
<drawing::FillStyle
>(getShape(3), "FillStyle"));
1497 // This was a com.sun.star.drawing.CustomShape, which resulted in lack of word wrapping in the bugdoc.
1498 uno::Reference
<beans::XPropertySet
> xShapeProperties(getShape(1), uno::UNO_QUERY
);
1499 uno::Reference
<drawing::XShapeDescriptor
> xShapeDescriptor(xShapeProperties
, uno::UNO_QUERY
);
1500 CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), xShapeDescriptor
->getShapeType());
1503 DECLARE_RTFIMPORT_TEST(testFdo63428
, "hello.rtf")
1505 // Pasting content that contained an annotation caused a crash.
1506 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1507 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
1508 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1509 paste("fdo63428.rtf", xEnd
);
1511 // Additionally, commented range was imported as a normal comment.
1512 CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty
<OUString
>(getRun(getParagraph(1), 2), "TextPortionType"));
1513 CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty
<OUString
>(getRun(getParagraph(1), 4), "TextPortionType"));
1516 DECLARE_RTFIMPORT_TEST(testGroupshapeRotation
, "groupshape-rotation.rtf")
1518 // Rotation on groupshapes wasn't handled correctly, RotateAngle was 4500.
1519 CPPUNIT_ASSERT_EQUAL(sal_Int32(315 * 100), getProperty
<sal_Int32
>(getShape(1), "RotateAngle"));
1522 DECLARE_RTFIMPORT_TEST(testFdo44715
, "fdo44715.rtf")
1524 uno::Reference
<text::XTextTable
> xTable(getParagraphOrTable(1), uno::UNO_QUERY
);
1525 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1526 // Style information wasn't reset, which caused character height to be 16.
1527 CPPUNIT_ASSERT_EQUAL(12.f
, getProperty
<float>(getParagraphOfText(2, xCell
->getText()), "CharHeight"));
1530 DECLARE_RTFIMPORT_TEST(testFdo68076
, "fdo68076.rtf")
1532 // Encoding of the last char was wrong (more 'o' than 'y').
1533 OUString
aExpected("\xD0\x9E\xD0\xB1\xD1\x8A\xD0\xB5\xD0\xBA\xD1\x82 \xE2\x80\x93 \xD1\x83", 19, RTL_TEXTENCODING_UTF8
);
1534 getParagraph(1, aExpected
);
1537 DECLARE_RTFIMPORT_TEST(testFdo68291
, "fdo68291.odt")
1539 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1540 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
1541 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1542 paste("fdo68291-paste.rtf", xEnd
);
1544 // This was "Standard", causing an unwanted page break on next paste.
1545 CPPUNIT_ASSERT_EQUAL(uno::Any(), uno::Reference
<beans::XPropertySet
>(getParagraph(1), uno::UNO_QUERY
)->getPropertyValue("PageDescName"));
1548 DECLARE_RTFIMPORT_TEST(testFdo69384
, "hello.rtf")
1550 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1551 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
1552 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
1553 paste("fdo69384-paste.rtf", xEnd
);
1555 // Import got interrupted in the middle of style sheet table import,
1556 // resuling in missing styles and text.
1557 getStyles("ParagraphStyles")->getByName("Text body justified");
1560 DECLARE_RTFIMPORT_TEST(testFdo70221
, "fdo70221.rtf")
1562 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
1563 uno::Reference
<container::XIndexAccess
> xDraws(xDrawPageSupplier
->getDrawPage(), uno::UNO_QUERY
);
1564 // The picture was imported twice.
1565 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws
->getCount());
1568 DECLARE_RTFIMPORT_TEST(testCp1000018
, "cp1000018.rtf")
1570 // The problem was that the empty paragraph at the end of the footnote got
1571 // lost during import.
1572 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
1573 uno::Reference
<container::XIndexAccess
> xFootnotes(xFootnotesSupplier
->getFootnotes(), uno::UNO_QUERY
);
1574 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
1575 OUString
aExpected("Footnote first line.\n");
1576 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
1581 DECLARE_RTFIMPORT_TEST(testNestedTable
, "rhbz1065629.rtf")
1583 // nested table in second cell was missing
1584 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1585 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1586 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(1), uno::UNO_QUERY
);
1587 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1588 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
1589 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1590 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1591 CPPUNIT_ASSERT_EQUAL(OUString("Responsable Commercial:"), xPara
->getString());
1592 xCell
.set(xTable
->getCellByName("A2"), uno::UNO_QUERY
);
1593 xParaEnumAccess
.set(xCell
->getText(), uno::UNO_QUERY
);
1594 xParaEnum
= xParaEnumAccess
->createEnumeration();
1595 xPara
.set(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1596 xPara
.set(xParaEnum
->nextElement(), uno::UNO_QUERY
);
1597 CPPUNIT_ASSERT_EQUAL(OUString("Nom: John Doe"), xPara
->getString());
1599 // outer table: background color, borders for B1/B2 cell
1600 xTable
.set(xTables
->getByIndex(2), uno::UNO_QUERY
);
1601 xCell
.set(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1602 CPPUNIT_ASSERT(xCell
.is());
1603 table::BorderLine2
fullPtSolid(1, 0, 35, 0, table::BorderLineStyle::SOLID
, 35);
1604 CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid
,
1605 getProperty
<table::BorderLine2
>(xCell
, "LeftBorder"));
1606 CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid
,
1607 getProperty
<table::BorderLine2
>(xCell
, "RightBorder"));
1608 CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid
,
1609 getProperty
<table::BorderLine2
>(xCell
, "TopBorder"));
1610 CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid
,
1611 getProperty
<table::BorderLine2
>(xCell
, "BottomBorder"));
1612 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xCC0000), getProperty
<sal_Int32
>(xCell
, "BackColor"));
1613 xCell
.set(xTable
->getCellByName("A2"), uno::UNO_QUERY
);
1614 CPPUNIT_ASSERT(xCell
.is());
1615 table::BorderLine2
halfPtSolid(/*0*/1, 0, 18, 0, table::BorderLineStyle::SOLID
, 18);
1616 CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid
,
1617 getProperty
<table::BorderLine2
>(xCell
, "LeftBorder"));
1618 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0xffffffff),
1619 getProperty
<sal_Int32
>(xCell
, "BackColor"));
1620 xCell
.set(xTable
->getCellByName("B2"), uno::UNO_QUERY
);
1621 CPPUNIT_ASSERT(xCell
.is());
1622 CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid
,
1623 getProperty
<table::BorderLine2
>(xCell
, "LeftBorder"));
1624 CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid
,
1625 getProperty
<table::BorderLine2
>(xCell
, "RightBorder"));
1626 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0xffffffff),
1627 getProperty
<sal_Int32
>(xCell
, "BackColor"));
1629 // \sect at the end resulted in spurious page break
1630 CPPUNIT_ASSERT_EQUAL(1, getPages());
1633 DECLARE_RTFIMPORT_TEST(testContSectionPageBreak
, "cont-section-pagebreak.rtf")
1635 uno::Reference
<text::XTextRange
> xParaSecond
= getParagraph(2);
1636 CPPUNIT_ASSERT_EQUAL(OUString("SECOND"), xParaSecond
->getString());
1637 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
1638 getProperty
<style::BreakType
>(xParaSecond
, "BreakType"));
1639 CPPUNIT_ASSERT_EQUAL(uno::Any(),
1640 uno::Reference
<beans::XPropertySet
>(xParaSecond
, uno::UNO_QUERY
)->getPropertyValue("PageDescName"));
1641 // actually not sure how many paragraph there should be between
1642 // SECOND and THIRD - important is that the page break is on there
1643 uno::Reference
<text::XTextRange
> xParaNext
= getParagraph(3);
1644 CPPUNIT_ASSERT_EQUAL(OUString(""), xParaNext
->getString());
1645 CPPUNIT_ASSERT_EQUAL(OUString("Converted1"),
1646 getProperty
<OUString
>(xParaNext
, "PageDescName"));
1647 uno::Reference
<text::XTextRange
> xParaThird
= getParagraph(4);
1648 CPPUNIT_ASSERT_EQUAL(OUString("THIRD"), xParaThird
->getString());
1649 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
,
1650 getProperty
<style::BreakType
>(xParaThird
, "BreakType"));
1651 CPPUNIT_ASSERT_EQUAL(uno::Any(),
1652 uno::Reference
<beans::XPropertySet
>(xParaThird
, uno::UNO_QUERY
)->getPropertyValue("PageDescName"));
1654 CPPUNIT_ASSERT_EQUAL(2, getPages());
1657 DECLARE_RTFIMPORT_TEST(testFooterPara
, "footer-para.rtf")
1659 // check that paragraph properties in footer are imported
1660 uno::Reference
<text::XText
> xFooterText
=
1661 getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName("First Page"), "FooterText");
1662 uno::Reference
<text::XTextContent
> xParagraph
=
1663 getParagraphOrTable(1, xFooterText
);
1664 CPPUNIT_ASSERT_EQUAL(OUString("All Rights Reserved."),
1665 uno::Reference
<text::XTextRange
>(xParagraph
, uno::UNO_QUERY
)->getString());
1666 CPPUNIT_ASSERT_EQUAL((sal_Int16
)style::ParagraphAdjust_CENTER
,
1667 getProperty
</*style::ParagraphAdjust*/sal_Int16
>(xParagraph
, "ParaAdjust"));
1670 DECLARE_RTFIMPORT_TEST(testCp1000016
, "hello.rtf")
1672 // The single-line document had a second fake empty para on Windows.
1678 catch (const container::NoSuchElementException
&)
1682 CPPUNIT_ASSERT_EQUAL(false, bFound
);
1685 DECLARE_RTFIMPORT_TEST(testFdo65090
, "fdo65090.rtf")
1687 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1688 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1689 uno::Reference
<text::XTextTable
> xTextTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1690 uno::Reference
<table::XTableRows
> xTableRows(xTextTable
->getRows(), uno::UNO_QUERY
);
1691 // The first row had 3 cells, instead of a horizontally merged one and a normal one (2 -> 1 separator).
1692 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators").getLength());
1695 DECLARE_RTFIMPORT_TEST(testTableBorderDefaults
, "fdo68779.rtf")
1697 // table borders without \brdrw were not imported
1698 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1699 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1700 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1701 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1702 CPPUNIT_ASSERT(xCell
.is());
1703 table::BorderLine2
solid(1, 0, 26, 0, table::BorderLineStyle::SOLID
, 26);
1704 CPPUNIT_ASSERT_BORDER_EQUAL(solid
,
1705 getProperty
<table::BorderLine2
>(xCell
, "LeftBorder"));
1706 CPPUNIT_ASSERT_BORDER_EQUAL(solid
,
1707 getProperty
<table::BorderLine2
>(xCell
, "RightBorder"));
1708 CPPUNIT_ASSERT_BORDER_EQUAL(solid
,
1709 getProperty
<table::BorderLine2
>(xCell
, "TopBorder"));
1710 CPPUNIT_ASSERT_BORDER_EQUAL(solid
,
1711 getProperty
<table::BorderLine2
>(xCell
, "BottomBorder"));
1713 xTable
.set(xTables
->getByIndex(1), uno::UNO_QUERY
);
1714 xCell
.set(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1715 CPPUNIT_ASSERT(xCell
.is());
1716 table::BorderLine2
dotted(1, 0, 26, 0, table::BorderLineStyle::DOTTED
, 26);
1717 CPPUNIT_ASSERT_BORDER_EQUAL(dotted
,
1718 getProperty
<table::BorderLine2
>(xCell
, "LeftBorder"));
1719 CPPUNIT_ASSERT_BORDER_EQUAL(dotted
,
1720 getProperty
<table::BorderLine2
>(xCell
, "RightBorder"));
1721 CPPUNIT_ASSERT_BORDER_EQUAL(dotted
,
1722 getProperty
<table::BorderLine2
>(xCell
, "TopBorder"));
1723 CPPUNIT_ASSERT_BORDER_EQUAL(dotted
,
1724 getProperty
<table::BorderLine2
>(xCell
, "BottomBorder"));
1726 xTable
.set(xTables
->getByIndex(2), uno::UNO_QUERY
);
1727 xCell
.set(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1728 CPPUNIT_ASSERT(xCell
.is());
1729 table::BorderLine2
doubled(1, 26, 26, 26, table::BorderLineStyle::DOUBLE
, 79);
1730 CPPUNIT_ASSERT_BORDER_EQUAL(doubled
,
1731 getProperty
<table::BorderLine2
>(xCell
, "LeftBorder"));
1732 CPPUNIT_ASSERT_BORDER_EQUAL(doubled
,
1733 getProperty
<table::BorderLine2
>(xCell
, "RightBorder"));
1734 CPPUNIT_ASSERT_BORDER_EQUAL(doubled
,
1735 getProperty
<table::BorderLine2
>(xCell
, "TopBorder"));
1736 CPPUNIT_ASSERT_BORDER_EQUAL(doubled
,
1737 getProperty
<table::BorderLine2
>(xCell
, "BottomBorder"));
1739 xTable
.set(xTables
->getByIndex(3), uno::UNO_QUERY
);
1740 xCell
.set(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1741 CPPUNIT_ASSERT(xCell
.is());
1742 table::BorderLine2
thinThickMG(1, 14, 26, 14, table::BorderLineStyle::THINTHICK_MEDIUMGAP
, 53);
1743 CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG
,
1744 getProperty
<table::BorderLine2
>(xCell
, "LeftBorder"));
1745 CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG
,
1746 getProperty
<table::BorderLine2
>(xCell
, "RightBorder"));
1747 CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG
,
1748 getProperty
<table::BorderLine2
>(xCell
, "TopBorder"));
1749 CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG
,
1750 getProperty
<table::BorderLine2
>(xCell
, "BottomBorder"));
1753 DECLARE_RTFIMPORT_TEST(testShpzDhgt
, "shpz-dhgt.rtf")
1755 // Test that shpz has priority over dhght and not the other way around.
1756 // Drawpage is sorted by ZOrder, so first should be red (back).
1757 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), getProperty
<sal_Int32
>(getShape(1), "FillColor"));
1758 // Second (front) should be green.
1759 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00ff00), getProperty
<sal_Int32
>(getShape(2), "FillColor"));
1762 DECLARE_RTFIMPORT_TEST(testBackground
, "background.rtf")
1764 // The first shape wasn't in the foreground.
1765 CPPUNIT_ASSERT_EQUAL(true, bool(getProperty
<sal_Bool
>(getShape(1), "Opaque")));
1766 CPPUNIT_ASSERT_EQUAL(false, bool(getProperty
<sal_Bool
>(getShape(2), "Opaque")));
1769 DECLARE_RTFIMPORT_TEST(testLevelfollow
, "levelfollow.rtf")
1771 uno::Reference
<container::XIndexAccess
> xNum1Levels
= getProperty
< uno::Reference
<container::XIndexAccess
> >(getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
1772 CPPUNIT_ASSERT_EQUAL(sal_Int16(SvxNumberFormat::LISTTAB
), comphelper::SequenceAsHashMap(xNum1Levels
->getByIndex(0))["LabelFollowedBy"].get
<sal_Int16
>()); // first level, tab
1774 uno::Reference
<container::XIndexAccess
> xNum2Levels
= getProperty
< uno::Reference
<container::XIndexAccess
> >(getStyles("NumberingStyles")->getByName("WWNum2"), "NumberingRules");
1775 CPPUNIT_ASSERT_EQUAL(sal_Int16(SvxNumberFormat::SPACE
), comphelper::SequenceAsHashMap(xNum2Levels
->getByIndex(0))["LabelFollowedBy"].get
<sal_Int16
>()); // first level, space
1777 uno::Reference
<container::XIndexAccess
> xNum3Levels
= getProperty
< uno::Reference
<container::XIndexAccess
> >(getStyles("NumberingStyles")->getByName("WWNum3"), "NumberingRules");
1778 CPPUNIT_ASSERT_EQUAL(sal_Int16(SvxNumberFormat::NOTHING
), comphelper::SequenceAsHashMap(xNum3Levels
->getByIndex(0))["LabelFollowedBy"].get
<sal_Int16
>()); // first level, nothing
1781 DECLARE_RTFIMPORT_TEST(testCharColor
, "char-color.rtf")
1783 // This was -1: character color wasn't set.
1784 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x365F91), getProperty
<sal_Int32
>(getParagraph(1), "CharColor"));
1787 DECLARE_RTFIMPORT_TEST(testFdo69289
, "fdo69289.rtf")
1789 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1790 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1791 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1792 uno::Reference
<table::XTableRows
> xTableRows(xTable
->getRows(), uno::UNO_QUERY
);
1793 // There were only 2 cells (1 separators) in the table, should be 3 (2 separators).
1794 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators").getLength());
1797 DECLARE_RTFIMPORT_TEST(testDptxbxRelation
, "dptxbx-relation.rtf")
1799 // This was FRAME, not PAGE_FRAME, even if dobxpage is in the document.
1800 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(getShape(1), "HoriOrientRelation"));
1803 DECLARE_RTFIMPORT_TEST(testDprectAnchor
, "dprect-anchor.rtf")
1805 // This was at-page, which is not something Word supports, so clearly an import error.
1806 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER
, getProperty
<text::TextContentAnchorType
>(getShape(1), "AnchorType"));
1809 DECLARE_RTFIMPORT_TEST(testFdo76628
, "fdo76628.rtf")
1811 OUString
aExpected("\xd0\x9e\xd0\x91\xd0\xa0\xd0\x90\xd0\x97\xd0\x95\xd0\xa6", 14, RTL_TEXTENCODING_UTF8
);
1812 // Should be 'SAMPLE' in Russian, was garbage.
1813 getParagraph(1, aExpected
);
1815 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), "HeaderText");
1816 OUString
aExpectedHeader("\xd0\x9f\xd0\xbe\xd0\xb4\xd0\xb3\xd0\xbe\xd1\x82\xd0\xbe\xd0\xb2\xd0\xbb\xd0\xb5\xd0\xbd\xd0\xbe", 24, RTL_TEXTENCODING_UTF8
);
1817 // Should be 'prepared' in Russian, was garbage.
1818 getParagraphOfText(1, xHeaderText
, aExpectedHeader
);
1821 DECLARE_RTFIMPORT_TEST(testFdo74823
, "fdo74823.rtf")
1823 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1824 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1825 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1826 // Cell width of C2 was too large / column separator being 3749 too small (e.g. not set, around 3/7 of total width)
1827 uno::Reference
<table::XTableRows
> xTableRows(xTable
->getRows(), uno::UNO_QUERY
);
1828 CPPUNIT_ASSERT_EQUAL(sal_Int16(5391), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(1), "TableColumnSeparators")[2].Position
);
1831 DECLARE_RTFIMPORT_TEST(testFdo74599
, "fdo74599.rtf")
1833 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("ParagraphStyles")->getByName("Heading 3"), uno::UNO_QUERY
);
1834 // Writer default styles weren't disabled, so the color was gray, not default (black).
1835 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-1), getProperty
<sal_Int32
>(xPropertySet
, "CharColor"));
1838 DECLARE_RTFIMPORT_TEST(testFdo77267
, "fdo77267.rtf")
1840 // Paragraph was aligned to left, should be center.
1841 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(getParagraph(1), "ParaAdjust")));
1844 DECLARE_RTFIMPORT_TEST(testFdo75735
, "fdo75735.rtf")
1846 // Number of tabstops in the second paragraph should be 3, was 6.
1847 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty
< uno::Sequence
<style::TabStop
> >(getParagraph(2), "ParaTabStops").getLength());
1850 DECLARE_RTFIMPORT_TEST(testFontOverride
, "font-override.rtf")
1852 // This was "Times New Roman".
1853 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty
<OUString
>(getRun(getParagraph(1), 1), "CharFontName"));
1856 DECLARE_RTFIMPORT_TEST(testColumnBreak
, "column-break.rtf")
1858 // Column break at the very start of the document was ignored.
1859 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE
, getProperty
<style::BreakType
>(getParagraph(2), "BreakType"));
1862 DECLARE_RTFIMPORT_TEST(testFdo73241
, "fdo73241.rtf")
1864 // This was 2, page break in table wasn't ignored.
1865 CPPUNIT_ASSERT_EQUAL(1, getPages());
1868 DECLARE_RTFIMPORT_TEST(testFdo80905
, "fdo80905.rtf")
1870 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
1871 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
1872 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
1873 xFields
->nextElement();
1874 // The problem was that there was only one field in the document, but there should be true.
1875 CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(xFields
->hasMoreElements()));
1878 DECLARE_RTFIMPORT_TEST(testUnbalancedColumnsCompat
, "unbalanced-columns-compat.rtf")
1880 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
1881 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(), uno::UNO_QUERY
);
1882 // This was false, we ignored the relevant compat setting to make this non-last section unbalanced.
1883 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xTextSections
->getByIndex(0), "DontBalanceTextColumns"));
1886 DECLARE_RTFIMPORT_TEST(testOleInline
, "ole-inline.rtf")
1888 // Problem was that inline shape had at-page anchor.
1889 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER
, getProperty
<text::TextContentAnchorType
>(getShape(1), "AnchorType"));
1892 DECLARE_RTFIMPORT_TEST(testFdo80742
, "fdo80742.rtf")
1894 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("ParagraphStyles")->getByName("Heading 2"), uno::UNO_QUERY
);
1895 // This was 0, outline level was body text.
1896 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty
<sal_Int32
>(xPropertySet
, "OutlineLevel"));
1899 DECLARE_RTFIMPORT_TEST(testFdo82106
, "fdo82106.rtf")
1901 // Tab was missing after footnote not containing a tab.
1902 getParagraph(2, "before\tafter");
1905 DECLARE_RTFIMPORT_TEST(testBehindDoc
, "behind-doc.rtf")
1907 // The problem was that "behind doc" didn't result in the shape being in the background, only in being wrapped as "through".
1908 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1909 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT
, getProperty
<text::WrapTextMode
>(xShape
, "Surround"));
1911 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xShape
, "Opaque"));
1914 DECLARE_RTFIMPORT_TEST(testFdo74229
, "fdo74229.rtf")
1916 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1917 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1918 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1919 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1920 // This was 0, due to ignoring RTF_TRGAPH.
1921 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(67)), getProperty
<sal_Int32
>(xCell
, "RightBorderDistance"));
1924 DECLARE_RTFIMPORT_TEST(testFdo79959
, "fdo79959.rtf")
1926 // This was false, as the style was imported as " Test", i.e. no whitespace stripping.
1927 CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(getStyles("ParagraphStyles")->hasByName("Test")));
1930 DECLARE_RTFIMPORT_TEST(testFdo82078
, "fdo82078.rtf")
1932 // This was awt::FontWeight::BOLD, i.e. the second run was bold, when it should be normal.
1933 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL
, getProperty
<float>(getRun(getParagraph(1), 2), "CharWeight"));
1936 DECLARE_RTFIMPORT_TEST(testCsBold
, "cs-bold.rtf")
1938 // This was awt::FontWeight::NORMAL, i.e. the first run was bold, when it should be bold (applied character style without direct formatting).
1939 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD
, getProperty
<float>(getRun(getParagraph(1), 1), "CharWeight"));
1942 DECLARE_RTFIMPORT_TEST(testFdo82114
, "fdo82114.rtf")
1944 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName("Converted1"), "HeaderText");
1945 OUString aActual
= xHeaderText
->getString();
1946 OUString
aExpected("First page header, section 2");
1947 // This was 'Right page header, section 1'.
1948 CPPUNIT_ASSERT_EQUAL(aExpected
, aActual
);
1951 DECLARE_RTFIMPORT_TEST(testFdo44984
, "fdo44984.rtf")
1953 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1954 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1955 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1956 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1957 // This was Text, i.e. the checkbox field portion was missing.
1958 CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStartEnd"), getProperty
<OUString
>(getRun(getParagraphOfText(1, xCell
->getText()), 1), "TextPortionType"));
1961 DECLARE_RTFIMPORT_TEST(testFdo84679
, "fdo84679.rtf")
1963 // The problem was that the paragraph in A1 had some bottom margin, but it should not.
1964 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1965 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1966 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1967 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1969 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0), getProperty
<sal_Int32
>(getParagraphOfText(1, xCell
->getText()), "ParaBottomMargin"));
1972 DECLARE_RTFIMPORT_TEST(testFdo82071
, "fdo82071.rtf")
1974 // The problem was that in TOC, chapter names were underlined, but they should not be.
1975 uno::Reference
<text::XTextRange
> xRun
= getRun(getParagraph(2), 1);
1976 // Make sure we test the right text portion.
1977 CPPUNIT_ASSERT_EQUAL(OUString("Chapter 1"), xRun
->getString());
1978 // This was awt::FontUnderline::SINGLE.
1979 CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE
, getProperty
<sal_Int16
>(xRun
, "CharUnderline"));
1982 DECLARE_RTFIMPORT_TEST(testFdo83464
, "fdo83464.rtf")
1984 // Problem was that the text in the textfrme had wrong font.
1985 uno::Reference
<text::XTextRange
> xFrameText(getShape(1), uno::UNO_QUERY
);
1986 CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xFrameText
->getString());
1987 // This was Times New Roman.
1988 CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty
<OUString
>(getRun(getParagraphOfText(1, xFrameText
->getText()), 1), "CharFontName"));
1991 DECLARE_RTFIMPORT_TEST(testFdo85179
, "fdo85179.rtf")
1993 // This was 0, border around the picture was ignored on import.
1994 // 360: EMU -> MM100
1995 CPPUNIT_ASSERT_EQUAL(sal_uInt32(50800/360), getProperty
<table::BorderLine2
>(getShape(1), "TopBorder").LineWidth
);
1998 DECLARE_RTFIMPORT_TEST(testFdo86761
, "fdo86761.rtf")
2000 // This was 26, even if the picture should have no border, due to fLine=0.
2001 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32
>(0), getProperty
<table::BorderLine2
>(getShape(1), "TopBorder").LineWidth
);
2004 DECLARE_RTFIMPORT_TEST(testFdo82859
, "fdo82859.rtf")
2006 // This was 0: "0xffffff" was converted to 0, i.e. the background was black instead of the default.
2007 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-1), getProperty
<sal_Int32
>(getShape(1), "BackColor"));
2010 DECLARE_RTFIMPORT_TEST(testFdo82076
, "fdo82076.rtf")
2012 // Footnote position was wrong: should be at the end of the B1 cell.
2013 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
2014 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
2015 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
2016 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
2017 // This resulted in container::NoSuchElementException: the footnote was at the start of the A1 cell.
2018 CPPUNIT_ASSERT_EQUAL(OUString("Footnote"), getProperty
<OUString
>(getRun(getParagraphOfText(1, xCell
->getText()), 2), "TextPortionType"));
2021 DECLARE_RTFIMPORT_TEST(testFdo82512
, "fdo82512.rtf")
2023 // This was style::BreakType_NONE, column break was before the 3rd paragraph, not before the 2nd one.
2024 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE
, getProperty
<style::BreakType
>(getParagraph(2), "BreakType"));
2027 DECLARE_RTFIMPORT_TEST(testUnbalancedColumns
, "unbalanced-columns.rtf")
2029 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
2030 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(), uno::UNO_QUERY
);
2031 // This was false, last section was balanced, but it's unbalanced in Word.
2032 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xTextSections
->getByIndex(0), "DontBalanceTextColumns"));
2035 DECLARE_RTFIMPORT_TEST(testFdo84685
, "fdo84685.rtf")
2037 // index mark was not imported
2038 uno::Reference
<text::XDocumentIndexMark
> xMark(
2039 getProperty
<uno::Reference
<text::XDocumentIndexMark
>>(
2040 getRun(getParagraph(1), 1),
2041 "DocumentIndexMark"));
2042 CPPUNIT_ASSERT(xMark
.is());
2043 CPPUNIT_ASSERT_EQUAL(OUString("Key the 1st"), getProperty
<OUString
>(xMark
, "PrimaryKey"));
2044 // let's test toc entry too
2045 uno::Reference
<text::XDocumentIndexMark
> xTOCMark(
2046 getProperty
<uno::Reference
<text::XDocumentIndexMark
>>(
2047 getRun(getParagraph(2), 1),
2048 "DocumentIndexMark"));
2049 CPPUNIT_ASSERT(xTOCMark
.is());
2050 uno::Reference
<lang::XServiceInfo
> xTOCSI(xTOCMark
, uno::UNO_QUERY
);
2051 CPPUNIT_ASSERT(xTOCSI
->supportsService("com.sun.star.text.ContentIndexMark"));
2054 DECLARE_RTFIMPORT_TEST(testFdo83204
, "fdo83204.rtf")
2056 // This was Standard, \sN was ignored after \bkmkstart and \pard.
2057 CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty
<OUString
>(getParagraph(1), "ParaStyleName"));
2060 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
2061 DECLARE_RTFIMPORT_TEST(testCp950listleveltext1
, "cp950listleveltext1.rtf")
2063 // suffix with Chinese only ( most common case generated by MSO2010 TC)
2064 const sal_Unicode aExpectedSuffix
[1] = { 0x3001 }; // This is a dot that is generally used as suffix of Chinese list number
2065 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY
);
2066 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
2067 uno::Sequence
<beans::PropertyValue
> aProps
;
2068 xLevels
->getByIndex(0) >>= aProps
; // 1st level
2071 for (int i
= 0; i
< aProps
.getLength(); ++i
)
2073 const beans::PropertyValue
& rProp
= aProps
[i
];
2075 if (rProp
.Name
== "Suffix")
2076 aSuffix
= rProp
.Value
.get
<OUString
>();
2078 // Suffix was '\0' instead of ' '.
2079 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix
,SAL_N_ELEMENTS(aExpectedSuffix
)), aSuffix
);
2082 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
2083 DECLARE_RTFIMPORT_TEST(testCp950listleveltext2
, "cp950listleveltext2.rtf")
2085 // Prefix and suffix with Chinese only ( tweaked from default in MSO2010 TC)
2086 const sal_Unicode aExpectedPrefix
[2] = { 0x524d, 0x7f6e };
2087 const sal_Unicode aExpectedSuffix
[3] = { 0x3001, 0x5f8c, 0x7f6e };
2089 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
2090 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
2091 uno::Sequence
<beans::PropertyValue
> aProps
;
2092 xLevels
->getByIndex(0) >>= aProps
; // 1st level
2094 OUString aSuffix
,aPrefix
;
2095 for (int i
= 0; i
< aProps
.getLength(); ++i
)
2097 const beans::PropertyValue
& rProp
= aProps
[i
];
2099 if (rProp
.Name
== "Suffix")
2100 aSuffix
= rProp
.Value
.get
<OUString
>();
2101 if (rProp
.Name
== "Prefix")
2102 aPrefix
= rProp
.Value
.get
<OUString
>();
2104 // Suffix was '\0' instead of ' '.
2105 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix
,SAL_N_ELEMENTS(aExpectedPrefix
)), aPrefix
);
2106 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix
,SAL_N_ELEMENTS(aExpectedSuffix
)), aSuffix
);
2110 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 )
2111 DECLARE_RTFIMPORT_TEST(testCp950listleveltext3
, "cp950listleveltext3.rtf")
2113 // Prefix and suffix that mix Chinese and English ( tweaked from default in MSO2010 TC)
2114 const sal_Unicode aExpectedPrefix
[4] = { 0x524d, 0x0061, 0x7f6e, 0x0062 };
2115 const sal_Unicode aExpectedSuffix
[6] = { 0x3001, 0x0063, 0x5f8c, 0x0064, 0x7f6e, 0x0065 };
2117 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
2118 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
2119 uno::Sequence
<beans::PropertyValue
> aProps
;
2120 xLevels
->getByIndex(0) >>= aProps
; // 1st level
2122 OUString aSuffix
,aPrefix
;
2123 for (int i
= 0; i
< aProps
.getLength(); ++i
)
2125 const beans::PropertyValue
& rProp
= aProps
[i
];
2127 if (rProp
.Name
== "Suffix")
2128 aSuffix
= rProp
.Value
.get
<OUString
>();
2129 if (rProp
.Name
== "Prefix")
2130 aPrefix
= rProp
.Value
.get
<OUString
>();
2132 // Suffix was '\0' instead of ' '.
2133 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix
,SAL_N_ELEMENTS(aExpectedPrefix
)), aPrefix
);
2134 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix
,SAL_N_ELEMENTS(aExpectedSuffix
)), aSuffix
);
2137 DECLARE_RTFIMPORT_TEST(testChtOutlineNumberingRtf
, "chtoutline.rtf")
2139 const sal_Unicode aExpectedPrefix
[2] = { 0x7b2c, 0x0020 };
2140 const sal_Unicode aExpectedSuffix
[2] = { 0x0020, 0x7ae0 };
2141 uno::Reference
< text::XChapterNumberingSupplier
> xChapterNumberingSupplier(mxComponent
, uno::UNO_QUERY
);
2142 uno::Reference
< container::XIndexAccess
> xLevels(xChapterNumberingSupplier
->getChapterNumberingRules());
2143 uno::Sequence
<beans::PropertyValue
> aProps
;
2144 xLevels
->getByIndex(0) >>= aProps
; // 1st level
2146 OUString aSuffix
,aPrefix
;
2147 for (int i
= 0; i
< aProps
.getLength(); ++i
)
2149 const beans::PropertyValue
& rProp
= aProps
[i
];
2151 if (rProp
.Name
== "Suffix")
2152 aSuffix
= rProp
.Value
.get
<OUString
>();
2153 if (rProp
.Name
== "Prefix")
2154 aPrefix
= rProp
.Value
.get
<OUString
>();
2156 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix
,SAL_N_ELEMENTS(aExpectedPrefix
)), aPrefix
);
2157 CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix
,SAL_N_ELEMENTS(aExpectedSuffix
)), aSuffix
);
2160 DECLARE_RTFIMPORT_TEST(testFdo85889pc
, "fdo85889-pc.rtf")
2162 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
2164 OUString
aExpected("\xc2\xb1\xe2\x89\xa5\xe2\x89\xa4", 8, RTL_TEXTENCODING_UTF8
);
2165 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
2168 DECLARE_RTFIMPORT_TEST(testFdo85889pca
, "fdo85889-pca.rtf")
2170 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
2172 OUString
aExpected("\xc2\xb1\xe2\x80\x97\xc2\xbe", 7, RTL_TEXTENCODING_UTF8
);
2173 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
2176 DECLARE_RTFIMPORT_TEST(testTdf90046
, "tdf90046.rtf")
2178 // this was crashing on importing the footnote
2179 uno::Reference
<text::XFootnotesSupplier
> xFootnotesSupplier(mxComponent
, uno::UNO_QUERY
);
2180 uno::Reference
<container::XIndexAccess
> xFootnotes(xFootnotesSupplier
->getFootnotes(), uno::UNO_QUERY
);
2181 uno::Reference
<text::XTextRange
> xTextRange(xFootnotes
->getByIndex(0), uno::UNO_QUERY
);
2182 CPPUNIT_ASSERT_EQUAL(OUString("Ma"), xTextRange
->getString());
2185 DECLARE_RTFIMPORT_TEST(testFdo85889mac
, "fdo85889-mac.rtf")
2187 uno::Reference
<text::XTextRange
> xTextRange
= getRun(getParagraph(1), 1);
2189 OUString
aExpected("\xc3\x92\xc3\x9a\xc3\x9b", 6, RTL_TEXTENCODING_UTF8
);
2190 CPPUNIT_ASSERT_EQUAL(aExpected
, xTextRange
->getString());
2193 DECLARE_RTFIMPORT_TEST(testFdo72031
, "fdo72031.rtf")
2195 OUString
aExpected("\xc3\x85", 2, RTL_TEXTENCODING_UTF8
);
2196 CPPUNIT_ASSERT_EQUAL(aExpected
, getRun(getParagraph(1), 1)->getString());
2199 DECLARE_RTFIMPORT_TEST(testFdo86750
, "fdo86750.rtf")
2201 // This was 'HYPERLINK#anchor', the URL of the hyperlink had the field type as a prefix, leading to broken links.
2202 CPPUNIT_ASSERT_EQUAL(OUString("#anchor"), getProperty
<OUString
>(getRun(getParagraph(1), 1), "HyperLinkURL"));
2205 DECLARE_RTFIMPORT_TEST(testTdf88811
, "tdf88811.rtf")
2207 // The problem was that shapes anchored to the paragraph that is moved into a textframe were lost, so this was 2.
2208 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(mxComponent
, uno::UNO_QUERY
);
2209 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
2210 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xDrawPage
->getCount());
2213 DECLARE_RTFIMPORT_TEST(testFdo49893
, "fdo49893.rtf")
2215 // Image from shape was not loaded, invalid size of image after load
2216 uno::Reference
<drawing::XShape
> xShape(getShape(2), uno::UNO_QUERY
);
2217 CPPUNIT_ASSERT(xShape
.is());
2218 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(432)), xShape
->getSize().Height
);
2219 CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(1296)), xShape
->getSize().Width
);
2222 DECLARE_RTFIMPORT_TEST(testFdo49893_2
, "fdo49893-2.rtf")
2224 // Ensure that header text exists on each page (especially on second page)
2225 CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[1]/header/txt/text()"));
2226 CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[2]/header/txt/text()"));
2227 CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[3]/header/txt/text()"));
2230 DECLARE_RTFIMPORT_TEST(testFdo89496
, "fdo89496.rtf")
2232 // Just ensure that document is loaded and shape exists
2233 uno::Reference
<drawing::XShape
> xShape(getShape(1), uno::UNO_QUERY
);
2234 CPPUNIT_ASSERT(xShape
.is());
2237 DECLARE_RTFIMPORT_TEST(testFdo75614
, "tdf75614.rtf")
2239 // Text after the footnote was missing, so this resulted in a css::container::NoSuchElementException.
2240 CPPUNIT_ASSERT_EQUAL(OUString("after."), getRun(getParagraph(1), 3)->getString());
2243 DECLARE_RTFIMPORT_TEST(mathtype
, "mathtype.rtf")
2245 OUString aFormula
= getFormula(getRun(getParagraph(1), 1));
2246 CPPUNIT_ASSERT(!aFormula
.isEmpty());
2249 DECLARE_RTFIMPORT_TEST(testTdf86182
, "tdf86182.rtf")
2251 // Writing mode was the default, i.e. text::WritingMode2::CONTEXT.
2252 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB
, getProperty
<sal_Int16
>(getParagraph(1), "WritingMode"));
2255 DECLARE_RTFIMPORT_TEST(testWrapDistance
, "wrap-distance.rtf")
2257 // Custom shape, handled directly in RTFSdrImport.
2258 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
2259 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), xShape
->getShapeType());
2260 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), getProperty
<sal_Int32
>(xShape
, "TopMargin") / 1000);
2261 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), getProperty
<sal_Int32
>(xShape
, "BottomMargin") / 1000);
2262 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), getProperty
<sal_Int32
>(xShape
, "LeftMargin") / 1000);
2263 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), getProperty
<sal_Int32
>(xShape
, "RightMargin") / 1000);
2265 // Picture, handled in GraphicImport, shared with DOCX.
2266 xShape
= getShape(2);
2267 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), getProperty
<sal_Int32
>(xShape
, "TopMargin") / 1000);
2268 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), getProperty
<sal_Int32
>(xShape
, "BottomMargin") / 1000);
2269 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), getProperty
<sal_Int32
>(xShape
, "LeftMargin") / 1000);
2270 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), getProperty
<sal_Int32
>(xShape
, "RightMargin") / 1000);
2273 DECLARE_RTFIMPORT_TEST(testTdf91074
, "tdf91074.rtf")
2275 // The file failed to load, as the border color was imported using the LineColor UNO property.
2276 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
2277 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_LIGHTRED
), getProperty
<table::BorderLine2
>(xShape
, "TopBorder").Color
);
2280 DECLARE_RTFIMPORT_TEST(testTdf90260Nopar
, "hello.rtf")
2282 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
2283 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
2284 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
2285 paste("tdf90260-nopar.rtf", xEnd
);
2286 CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
2289 DECLARE_RTFIMPORT_TEST(testTdf90260Par
, "hello.rtf")
2291 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
2292 uno::Reference
<text::XTextRange
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
2293 uno::Reference
<text::XTextRange
> xEnd
= xText
->getEnd();
2294 paste("tdf90260-par.rtf", xEnd
);
2295 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
2298 DECLARE_RTFIMPORT_TEST(testTdf86814
, "tdf86814.rtf")
2300 // This was awt::FontWeight::NORMAL, i.e. the first run wasn't bold, when it should be bold (applied paragraph style with direct formatting).
2301 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD
, getProperty
<float>(getRun(getParagraph(1), 1), "CharWeight"));
2304 DECLARE_RTFIMPORT_TEST(testTdf90315
, "tdf90315.rtf")
2306 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
2307 uno::Reference
<container::XIndexAccess
> xTextSections(xTextSectionsSupplier
->getTextSections(), uno::UNO_QUERY
);
2308 uno::Reference
<beans::XPropertySet
> xTextSection(xTextSections
->getByIndex(0), uno::UNO_QUERY
);
2309 // This was 0, but default should be 720 twips.
2310 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1270), getProperty
<sal_Int32
>(xTextSection
->getPropertyValue("TextColumns"), "AutomaticDistance"));
2313 DECLARE_RTFIMPORT_TEST(testBinSkipping
, "bin-skipping.rtf")
2315 // before, it was importing '/nMUST NOT IMPORT'
2316 CPPUNIT_ASSERT_EQUAL(OUString("text"), getRun(getParagraph(1), 1)->getString());
2319 DECLARE_RTFIMPORT_TEST(testTdf92061
, "tdf92061.rtf")
2321 // This was "C", i.e. part of the footnote ended up in the body text.
2322 CPPUNIT_ASSERT_EQUAL(OUString("body-after"), getRun(getParagraph(1), 3)->getString());
2325 DECLARE_RTFIMPORT_TEST(testTdf92481
, "tdf92481.rtf")
2327 // This was 0, RTF_WIDOWCTRL was not imported.
2328 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int8
>(2), getProperty
<sal_Int8
>(getParagraph(1), "ParaWidows"));
2331 DECLARE_RTFIMPORT_TEST(testTdf94456
, "tdf94456.rtf")
2333 // Paragraph left margin and first line indent wasn't imported correctly.
2336 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(762), getProperty
<sal_Int32
>(getParagraph(1), "ParaLeftMargin"));
2338 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-762), getProperty
<sal_Int32
>(getParagraph(1), "ParaFirstLineIndent"));
2341 DECLARE_RTFIMPORT_TEST(testTdf94435
, "tdf94435.rtf")
2343 // This was style::ParagraphAdjust_LEFT, \ltrpar undone the effect of \qc.
2344 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(getParagraph(1), "ParaAdjust")));
2347 DECLARE_RTFIMPORT_TEST(testTdf59454
, "tdf59454.rtf")
2349 // This was 1, section break was ignored right before a table.
2350 CPPUNIT_ASSERT_EQUAL(2, getPages());
2353 CPPUNIT_PLUGIN_IMPLEMENT();
2355 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */