Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : */
9 :
10 : #include <swmodeltestbase.hxx>
11 :
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>
51 :
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>
59 :
60 : #include <bordertest.hxx>
61 :
62 196 : class Test : public SwModelTestBase
63 : {
64 : public:
65 196 : Test() : SwModelTestBase("/sw/qa/extras/rtfimport/data/", "Rich Text Format")
66 : {
67 196 : }
68 :
69 196 : virtual void preTest(const char* filename) SAL_OVERRIDE
70 : {
71 196 : m_aSavedSettings = Application::GetSettings();
72 196 : if (OString(filename) == "fdo48023.rtf" || OString(filename) == "fdo72031.rtf")
73 : {
74 2 : AllSettings aSettings(m_aSavedSettings);
75 2 : aSettings.SetLanguageTag(LanguageTag("ru"));
76 2 : Application::SetSettings(aSettings);
77 : }
78 194 : else if (OString(filename) == "fdo44211.rtf")
79 : {
80 1 : AllSettings aSettings(m_aSavedSettings);
81 1 : aSettings.SetLanguageTag(LanguageTag("lt"));
82 1 : Application::SetSettings(aSettings);
83 : }
84 196 : }
85 :
86 196 : virtual void postTest(const char* filename) SAL_OVERRIDE
87 : {
88 196 : if (OString(filename) == "fdo48023.rtf" || OString(filename) == "fdo72031.rtf" || OString(filename) == "fdo44211.rtf")
89 3 : Application::SetSettings(m_aSavedSettings);
90 196 : }
91 :
92 : protected:
93 : /// Copy&paste helper.
94 9 : void paste(const OUString& aFilename, uno::Reference<text::XTextRange> xTextRange = uno::Reference<text::XTextRange>())
95 : {
96 9 : uno::Reference<document::XFilter> xFilter(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
97 18 : uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
98 9 : xImporter->setTargetDocument(mxComponent);
99 18 : uno::Sequence<beans::PropertyValue> aDescriptor(xTextRange.is() ? 3 : 2);
100 9 : aDescriptor[0].Name = "InputStream";
101 9 : SvStream* pStream = utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + aFilename, StreamMode::WRITE);
102 18 : uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
103 9 : aDescriptor[0].Value <<= xStream;
104 9 : aDescriptor[1].Name = "InsertMode";
105 9 : aDescriptor[1].Value <<= sal_True;
106 9 : if (xTextRange.is())
107 : {
108 8 : aDescriptor[2].Name = "TextInsertModeRange";
109 8 : aDescriptor[2].Value <<= xTextRange;
110 : }
111 18 : xFilter->filter(aDescriptor);
112 9 : }
113 : AllSettings m_aSavedSettings;
114 : };
115 :
116 : #if !defined(WNT)
117 :
118 12 : DECLARE_RTFIMPORT_TEST(testFdo45553, "fdo45553.rtf")
119 : {
120 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
121 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
122 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
123 4 : while (xParaEnum->hasMoreElements())
124 : {
125 2 : uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
126 4 : uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
127 6 : while (xRangeEnum->hasMoreElements())
128 : {
129 2 : uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY);
130 4 : OUString aStr = xRange->getString();
131 2 : if (aStr == "space-before")
132 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(120)), getProperty<sal_Int32>(xRange, "ParaTopMargin"));
133 1 : else if (aStr == "space-after")
134 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(240)), getProperty<sal_Int32>(xRange, "ParaBottomMargin"));
135 2 : }
136 3 : }
137 1 : }
138 :
139 12 : DECLARE_RTFIMPORT_TEST(testN192129, "n192129.rtf")
140 : {
141 : // We expect that the result will be 16x16px.
142 1 : Size aExpectedSize(16, 16);
143 1 : MapMode aMap(MAP_100TH_MM);
144 1 : aExpectedSize = Application::GetDefaultDevice()->PixelToLogic(aExpectedSize, aMap);
145 :
146 2 : uno::Reference<text::XTextGraphicObjectsSupplier> xTextGraphicObjectsSupplier(mxComponent, uno::UNO_QUERY);
147 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextGraphicObjectsSupplier->getGraphicObjects(), uno::UNO_QUERY);
148 2 : uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
149 1 : awt::Size aActualSize(xShape->getSize());
150 :
151 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Width()), aActualSize.Width);
152 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Height()), aActualSize.Height);
153 1 : }
154 :
155 12 : DECLARE_RTFIMPORT_TEST(testFdo45543, "fdo45543.rtf")
156 : {
157 1 : CPPUNIT_ASSERT_EQUAL(5, getLength());
158 1 : }
159 :
160 12 : DECLARE_RTFIMPORT_TEST(testN695479, "n695479.rtf")
161 : {
162 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
163 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
164 2 : uno::Reference<beans::XPropertySet> xPropertySet(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
165 :
166 : // Negative ABSH should mean fixed size.
167 1 : CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX, getProperty<sal_Int16>(xPropertySet, "SizeType"));
168 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(300)), getProperty<sal_Int32>(xPropertySet, "Height"));
169 :
170 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
171 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
172 1 : bool bFrameFound = false, bDrawFound = false;
173 4 : for (int i = 0; i < xDraws->getCount(); ++i)
174 : {
175 3 : uno::Reference<lang::XServiceInfo> xServiceInfo(xDraws->getByIndex(i), uno::UNO_QUERY);
176 3 : if (xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
177 : {
178 : // Both frames should be anchored to the first paragraph.
179 2 : bFrameFound = true;
180 2 : uno::Reference<text::XTextContent> xTextContent(xServiceInfo, uno::UNO_QUERY);
181 4 : uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
182 4 : uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY);
183 2 : CPPUNIT_ASSERT_EQUAL(OUString("plain"), xText->getString());
184 :
185 2 : if (i == 0)
186 : // Additionally, the frist frame should have double border at the bottom.
187 2 : CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::DOUBLE, getProperty<table::BorderLine2>(xPropertySet, "BottomBorder").LineStyle);
188 : }
189 1 : else if (xServiceInfo->supportsService("com.sun.star.drawing.LineShape"))
190 : {
191 : // The older "drawing objects" syntax should be recognized.
192 1 : bDrawFound = true;
193 1 : xPropertySet.set(xServiceInfo, uno::UNO_QUERY);
194 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xPropertySet, "HoriOrientRelation"));
195 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xPropertySet, "VertOrientRelation"));
196 : }
197 3 : }
198 1 : CPPUNIT_ASSERT(bFrameFound);
199 2 : CPPUNIT_ASSERT(bDrawFound);
200 1 : }
201 :
202 12 : DECLARE_RTFIMPORT_TEST(testFdo42465, "fdo42465.rtf")
203 : {
204 1 : CPPUNIT_ASSERT_EQUAL(3, getLength());
205 1 : }
206 :
207 12 : DECLARE_RTFIMPORT_TEST(testFdo45187, "fdo45187.rtf")
208 : {
209 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
210 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
211 : // There should be two shapes.
212 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
213 :
214 : // They should be anchored to different paragraphs.
215 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
216 2 : uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xTextDocument->getText(), uno::UNO_QUERY);
217 2 : uno::Reference<text::XTextRange> xAnchor0 = uno::Reference<text::XTextContent>(xDraws->getByIndex(0), uno::UNO_QUERY)->getAnchor();
218 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xTextRangeCompare->compareRegionStarts(xAnchor0, xAnchor1));
221 1 : }
222 :
223 12 : DECLARE_RTFIMPORT_TEST(testFdo46662, "fdo46662.rtf")
224 : {
225 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY);
226 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
227 2 : uno::Sequence<beans::PropertyValue> aProps;
228 1 : xLevels->getByIndex(1) >>= aProps; // 2nd level
229 :
230 13 : for (int i = 0; i < aProps.getLength(); ++i)
231 : {
232 12 : const beans::PropertyValue& rProp = aProps[i];
233 :
234 12 : if (rProp.Name == "ParentNumbering")
235 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(2), rProp.Value.get<sal_Int16>());
236 11 : else if (rProp.Name == "Suffix")
237 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get<OUString>().getLength());
238 1 : }
239 1 : }
240 :
241 12 : DECLARE_RTFIMPORT_TEST(testN750757, "n750757.rtf")
242 : {
243 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
244 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
245 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
246 :
247 1 : CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(xParaEnum->nextElement(), "ParaContextMargin")));
248 2 : CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xParaEnum->nextElement(), "ParaContextMargin")));
249 1 : }
250 :
251 12 : DECLARE_RTFIMPORT_TEST(testFdo45563, "fdo45563.rtf")
252 : {
253 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
254 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
255 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
256 1 : int i = 0;
257 6 : while (xParaEnum->hasMoreElements())
258 : {
259 4 : xParaEnum->nextElement();
260 4 : i++;
261 : }
262 2 : CPPUNIT_ASSERT_EQUAL(4, i);
263 1 : }
264 :
265 12 : DECLARE_RTFIMPORT_TEST(testFdo43965, "fdo43965.rtf")
266 : {
267 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
268 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
269 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
270 :
271 : // First paragraph: the parameter of \up was ignored
272 2 : uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
273 2 : uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
274 2 : uno::Reference<beans::XPropertySet> xPropertySet(xRangeEnum->nextElement(), uno::UNO_QUERY);
275 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(36), getProperty<sal_Int32>(xPropertySet, "CharEscapement"));
276 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xPropertySet, "CharEscapementHeight"));
277 :
278 : // Second paragraph: Word vs Writer border default problem
279 1 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty<table::BorderLine2>(xParaEnum->nextElement(), "TopBorder").LineWidth);
280 :
281 : // Finally, make sure that we have two pages
282 2 : CPPUNIT_ASSERT_EQUAL(2, getPages());
283 1 : }
284 :
285 12 : DECLARE_RTFIMPORT_TEST(testN751020, "n751020.rtf")
286 : {
287 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
288 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
289 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
290 1 : CPPUNIT_ASSERT(xParaEnum->hasMoreElements());
291 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(200)), getProperty<sal_Int32>(xParaEnum->nextElement(), "ParaBottomMargin"));
292 1 : }
293 :
294 12 : DECLARE_RTFIMPORT_TEST(testFdo79384, "fdo79384.rtf")
295 : {
296 1 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
297 :
298 1 : CPPUNIT_ASSERT_EQUAL(OUString("Маркеры спискамЫ", 31, RTL_TEXTENCODING_UTF8), xTextRange->getString());
299 1 : }
300 :
301 12 : DECLARE_RTFIMPORT_TEST(testFdo47326, "fdo47326.rtf")
302 : {
303 : // This was 15 only, as \super buffered text, then the contents of it got lost.
304 1 : CPPUNIT_ASSERT_EQUAL(19, getLength());
305 1 : }
306 :
307 12 : DECLARE_RTFIMPORT_TEST(testFdo47036, "fdo47036.rtf")
308 : {
309 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
310 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
311 1 : int nAtCharacter = 0;
312 4 : for (int i = 0; i < xDraws->getCount(); ++i)
313 : {
314 3 : if (getProperty<text::TextContentAnchorType>(xDraws->getByIndex(i), "AnchorType") == text::TextContentAnchorType_AT_CHARACTER)
315 1 : nAtCharacter++;
316 : }
317 : // The image at the document start was ignored.
318 1 : CPPUNIT_ASSERT_EQUAL(1, nAtCharacter);
319 :
320 : // There should be 2 textboxes, not 4
321 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
322 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
323 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
324 1 : }
325 :
326 12 : DECLARE_RTFIMPORT_TEST(testFdo46955, "fdo46955.rtf")
327 : {
328 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
329 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
330 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
331 3 : while (xParaEnum->hasMoreElements())
332 : {
333 1 : uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
334 2 : uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
335 3 : while (xRangeEnum->hasMoreElements())
336 1 : CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE, getProperty<sal_Int16>(xRangeEnum->nextElement(), "CharCaseMap"));
337 2 : }
338 1 : }
339 :
340 12 : DECLARE_RTFIMPORT_TEST(testFdo81892, "fdo81892.rtf")
341 : {
342 : // table was not centered
343 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
344 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
345 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
346 1 : CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(xTable, "HoriOrient"));
347 :
348 : // fdo#81893: paragraph with \page was not centered
349 2 : uno::Reference<text::XTextRange> xPara(getParagraph(2, "Performance"));
350 2 : CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xPara, "ParaAdjust")));
351 1 : }
352 :
353 12 : DECLARE_RTFIMPORT_TEST(testFdo45394, "fdo45394.rtf")
354 : {
355 1 : uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText");
356 2 : OUString aActual = xHeaderText->getString();
357 : // Encoding in the header was wrong.
358 2 : OUString aExpected("\xd0\x9f\xd0\x9a \xd0\xa0\xd0\x98\xd0\x9a", 11, RTL_TEXTENCODING_UTF8);
359 1 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
360 :
361 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
362 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
363 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
364 1 : }
365 :
366 12 : DECLARE_RTFIMPORT_TEST(testFdo48104, "fdo48104.rtf")
367 : {
368 1 : CPPUNIT_ASSERT_EQUAL(2, getPages());
369 1 : }
370 :
371 12 : DECLARE_RTFIMPORT_TEST(testFdo47107, "fdo47107.rtf")
372 : {
373 1 : uno::Reference<container::XNameAccess> xNumberingStyles(getStyles("NumberingStyles"));
374 : // Make sure numbered and bullet legacy syntax is recognized, this used to throw a NoSuchElementException
375 1 : xNumberingStyles->getByName("WWNum1");
376 1 : xNumberingStyles->getByName("WWNum2");
377 1 : }
378 :
379 12 : DECLARE_RTFIMPORT_TEST(testFdo45182, "fdo45182.rtf")
380 : {
381 1 : uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
382 2 : uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
383 2 : uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
384 : // Encoding in the footnote was wrong.
385 2 : OUString aExpected("\xc5\xbeivnost\xc3\xad\n", 11, RTL_TEXTENCODING_UTF8);
386 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
387 1 : }
388 :
389 12 : DECLARE_RTFIMPORT_TEST(testFdo44176, "fdo44176.rtf")
390 : {
391 1 : uno::Reference<container::XNameAccess> xPageStyles(getStyles("PageStyles"));
392 2 : uno::Reference<beans::XPropertySet> xFirstPage(xPageStyles->getByName("First Page"), uno::UNO_QUERY);
393 2 : uno::Reference<beans::XPropertySet> xDefault(xPageStyles->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
394 1 : sal_Int32 nFirstTop = 0, nDefaultTop = 0, nDefaultHeader = 0;
395 1 : xFirstPage->getPropertyValue("TopMargin") >>= nFirstTop;
396 1 : xDefault->getPropertyValue("TopMargin") >>= nDefaultTop;
397 1 : xDefault->getPropertyValue("HeaderHeight") >>= nDefaultHeader;
398 2 : CPPUNIT_ASSERT_EQUAL(nFirstTop, nDefaultTop + nDefaultHeader);
399 1 : }
400 :
401 12 : DECLARE_RTFIMPORT_TEST(testFdo39053, "fdo39053.rtf")
402 : {
403 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
404 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
405 1 : int nAsCharacter = 0;
406 2 : for (int i = 0; i < xDraws->getCount(); ++i)
407 1 : if (getProperty<text::TextContentAnchorType>(xDraws->getByIndex(i), "AnchorType") == text::TextContentAnchorType_AS_CHARACTER)
408 1 : nAsCharacter++;
409 : // The image in binary format was ignored.
410 2 : CPPUNIT_ASSERT_EQUAL(1, nAsCharacter);
411 1 : }
412 :
413 12 : DECLARE_RTFIMPORT_TEST(testFdo48356, "fdo48356.rtf")
414 : {
415 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
416 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
417 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
418 1 : int i = 0;
419 3 : while (xParaEnum->hasMoreElements())
420 : {
421 1 : xParaEnum->nextElement();
422 1 : i++;
423 : }
424 : // The document used to be imported as two paragraphs.
425 2 : CPPUNIT_ASSERT_EQUAL(1, i);
426 1 : }
427 :
428 12 : DECLARE_RTFIMPORT_TEST(testFdo48023, "fdo48023.rtf")
429 : {
430 1 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
431 :
432 : // Implicit encoding detection based on locale was missing
433 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
435 1 : }
436 :
437 12 : DECLARE_RTFIMPORT_TEST(testFdo48876, "fdo48876.rtf")
438 : {
439 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
440 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
441 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
442 1 : CPPUNIT_ASSERT(xParaEnum->hasMoreElements());
443 2 : CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::MINIMUM, getProperty<style::LineSpacing>(xParaEnum->nextElement(), "ParaLineSpacing").Mode);
444 1 : }
445 :
446 12 : DECLARE_RTFIMPORT_TEST(testFdo48193, "fdo48193.rtf")
447 : {
448 1 : CPPUNIT_ASSERT_EQUAL(7, getLength());
449 1 : }
450 :
451 12 : DECLARE_RTFIMPORT_TEST(testFdo44211, "fdo44211.rtf")
452 : {
453 1 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
454 :
455 2 : OUString aExpected("\xc4\x85\xc4\x8d\xc4\x99", 6, RTL_TEXTENCODING_UTF8);
456 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
457 1 : }
458 :
459 12 : DECLARE_RTFIMPORT_TEST(testFdo48037, "fdo48037.rtf")
460 : {
461 1 : uno::Reference<util::XNumberFormatsSupplier> xNumberSupplier(mxComponent, uno::UNO_QUERY_THROW);
462 2 : lang::Locale aUSLocale, aFRLocale;
463 1 : aUSLocale.Language = "en";
464 1 : aFRLocale.Language = "fr";
465 1 : sal_Int32 nExpected = xNumberSupplier->getNumberFormats()->addNewConverted("d MMMM yyyy", aUSLocale, aFRLocale);
466 :
467 2 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
468 2 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
469 2 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
470 2 : uno::Reference<beans::XPropertySet> xPropertySet(xFields->nextElement(), uno::UNO_QUERY);
471 1 : sal_Int32 nActual = 0;
472 1 : xPropertySet->getPropertyValue("NumberFormat") >>= nActual;
473 :
474 2 : CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
475 1 : }
476 :
477 12 : DECLARE_RTFIMPORT_TEST(testFdo85812, "fdo85812.rtf")
478 : {
479 1 : 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 1 : CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language);
482 1 : 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 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(2), 1, "CharGroup"), "CharLocale");
486 1 : CPPUNIT_ASSERT_EQUAL(OUString("ru"), locale.Language);
487 1 : CPPUNIT_ASSERT_EQUAL(OUString("RU"), locale.Country);
488 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(2), 2, "AfterChar"), "CharLocale");
489 1 : CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language);
490 1 : CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country);
491 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(3), 2, "AfterBookmark"), "CharLocale");
492 1 : CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language);
493 1 : CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country);
494 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(4), 1, "CharGroup"), "CharLocale");
495 1 : CPPUNIT_ASSERT_EQUAL(OUString("ru"), locale.Language);
496 1 : CPPUNIT_ASSERT_EQUAL(OUString("RU"), locale.Country);
497 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(4), 1, "CharGroup"), "CharLocaleComplex");
498 1 : CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language);
499 1 : CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale.Country);
500 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(4), 2, "AfterChar"), "CharLocale");
501 1 : CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language);
502 1 : CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country);
503 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(4), 2, "AfterChar"), "CharLocaleComplex");
504 1 : CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language);
505 1 : CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale.Country);
506 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(5), 2, "AfterBookmark"), "CharLocale");
507 1 : CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language);
508 1 : CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country);
509 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(5), 2, "AfterBookmark"), "CharLocaleComplex");
510 1 : CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language);
511 1 : CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale.Country);
512 : // \ltrch \rtlch works differently - it is sticky across groups
513 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(6), 1, "CharGroup"), "CharLocale");
514 1 : CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language);
515 1 : CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country);
516 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(6), 1, "CharGroup"), "CharLocaleComplex");
517 1 : CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language);
518 1 : CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale.Country);
519 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(6), 2, "AfterChar"), "CharLocale");
520 1 : CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language);
521 1 : CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country);
522 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(6), 2, "AfterChar"), "CharLocaleComplex");
523 1 : CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language);
524 1 : CPPUNIT_ASSERT_EQUAL(OUString("EG"), locale.Country);
525 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(7), 2, "AfterBookmark"), "CharLocale");
526 1 : CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language);
527 1 : CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country);
528 1 : locale = getProperty<lang::Locale>(getRun(getParagraph(7), 2, "AfterBookmark"), "CharLocaleComplex");
529 1 : CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language);
530 1 : CPPUNIT_ASSERT_EQUAL(OUString("EG"), locale.Country);
531 1 : }
532 :
533 12 : DECLARE_RTFIMPORT_TEST(testFdo47764, "fdo47764.rtf")
534 : {
535 : // \cbpat with zero argument should mean the auto (-1) color, not a default color (black)
536 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getParagraph(1), "ParaBackColor"));
537 1 : }
538 :
539 12 : DECLARE_RTFIMPORT_TEST(testFdo38786, "fdo38786.rtf")
540 : {
541 1 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
542 2 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
543 2 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
544 : // \chpgn was ignored, so exception was thrown
545 2 : xFields->nextElement();
546 1 : }
547 :
548 12 : DECLARE_RTFIMPORT_TEST(testN757651, "n757651.rtf")
549 : {
550 : // The bug was that due to buggy layout the text expanded to two pages.
551 1 : if (Application::GetDefaultDevice()->IsFontAvailable(OUString("Times New Roman")))
552 0 : CPPUNIT_ASSERT_EQUAL(1, getPages());
553 1 : }
554 :
555 12 : DECLARE_RTFIMPORT_TEST(testFdo49501, "fdo49501.rtf")
556 : {
557 1 : uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
558 :
559 1 : CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xStyle, "IsLandscape"));
560 1 : sal_Int32 nExpected(convertTwipToMm100(567));
561 1 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "LeftMargin"));
562 1 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "RightMargin"));
563 1 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "TopMargin"));
564 1 : CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int32>(xStyle, "BottomMargin"));
565 1 : }
566 :
567 12 : DECLARE_RTFIMPORT_TEST(testFdo49271, "fdo49271.rtf")
568 : {
569 1 : CPPUNIT_ASSERT_EQUAL(25.f, getProperty<float>(getParagraph(2), "CharHeight"));
570 1 : }
571 :
572 12 : DECLARE_RTFIMPORT_TEST(testFdo49692, "fdo49692.rtf")
573 : {
574 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
575 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
576 2 : uno::Sequence<beans::PropertyValue> aProps;
577 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
578 :
579 13 : for (int i = 0; i < aProps.getLength(); ++i)
580 : {
581 12 : const beans::PropertyValue& rProp = aProps[i];
582 :
583 12 : if (rProp.Name == "Suffix")
584 : {
585 1 : OUString aExpected(static_cast<sal_Unicode>(0x200B));
586 1 : CPPUNIT_ASSERT_EQUAL(aExpected, rProp.Value.get<OUString>());
587 : }
588 1 : }
589 1 : }
590 :
591 12 : DECLARE_RTFIMPORT_TEST(testFdo45190, "fdo45190.rtf")
592 : {
593 : // inherited \fi should be reset
594 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent"));
595 :
596 : // but direct one not
597 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-100)), getProperty<sal_Int32>(getParagraph(2), "ParaFirstLineIndent"));
598 1 : }
599 :
600 12 : DECLARE_RTFIMPORT_TEST(testFdo50539, "fdo50539.rtf")
601 : {
602 : // \chcbpat with zero argument should mean the auto (-1) color, not a default color (black)
603 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor"));
604 1 : }
605 :
606 12 : DECLARE_RTFIMPORT_TEST(testFdo50665, "fdo50665.rtf")
607 : {
608 : // Access the second run, which is a textfield
609 1 : 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 1 : CPPUNIT_ASSERT_EQUAL(OUString("Book Antiqua"), getProperty<OUString>(xRun, "CharFontName"));
612 1 : }
613 :
614 12 : DECLARE_RTFIMPORT_TEST(testFdo49659, "fdo49659.rtf")
615 : {
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 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
618 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
619 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
620 :
621 : // The graphic was also empty
622 2 : uno::Reference<beans::XPropertySet> xGraphic(getProperty< uno::Reference<beans::XPropertySet> >(getShape(1), "Graphic"), uno::UNO_QUERY);
623 2 : CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL, getProperty<sal_Int8>(xGraphic, "GraphicType"));
624 1 : }
625 :
626 12 : DECLARE_RTFIMPORT_TEST(testFdo46966, "fdo46966.rtf")
627 : {
628 : /*
629 : * The problem was the top margin was 1440 (1 inch), but it should be 720 (0.5 inch).
630 : *
631 : * xray ThisComponent.StyleFamilies.PageStyles.Default.TopMargin
632 : */
633 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
634 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(720)), getProperty<sal_Int32>(xPropertySet, "TopMargin"));
635 1 : }
636 :
637 12 : DECLARE_RTFIMPORT_TEST(testFdo52066, "fdo52066.rtf")
638 : {
639 : /*
640 : * The problem was that the height of the shape was too big.
641 : *
642 : * xray ThisComponent.DrawPage(0).Size.Height
643 : */
644 1 : uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
645 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(19)), xShape->getSize().Height);
646 1 : }
647 :
648 12 : DECLARE_RTFIMPORT_TEST(testFdo76633, "fdo76633.rtf")
649 : {
650 : // check that there is only a graphic object, not an additional rectangle
651 1 : uno::Reference<lang::XServiceInfo> xShape(getShape(1), uno::UNO_QUERY);
652 1 : CPPUNIT_ASSERT(xShape.is());
653 1 : CPPUNIT_ASSERT(xShape->supportsService("com.sun.star.text.TextGraphicObject"));
654 : try
655 : {
656 1 : uno::Reference<drawing::XShape> xShape2(getShape(2), uno::UNO_QUERY);
657 0 : CPPUNIT_FAIL("exception expected");
658 : }
659 1 : catch (lang::IndexOutOfBoundsException const&)
660 : {
661 : /* expected */
662 1 : }
663 1 : }
664 :
665 12 : DECLARE_RTFIMPORT_TEST(testFdo48033, "fdo48033.rtf")
666 : {
667 : /*
668 : * The problem was that the picture (48033) or OLE object (53594) was in the first cell,
669 : * instead of the second one.
670 : *
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
677 : */
678 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
679 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
680 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
681 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
682 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
683 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
684 2 : uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
685 2 : CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty<OUString>(getRun(xPara, 1), "TextPortionType"));
686 1 : }
687 :
688 12 : DECLARE_RTFIMPORT_TEST(testFdo53594, "fdo53594.rtf")
689 : {
690 : /*
691 : * The problem was that the picture (48033) or OLE object (53594) was in the first cell,
692 : * instead of the second one.
693 : *
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
700 : */
701 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
702 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
703 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
704 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
705 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
706 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
707 2 : uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
708 2 : CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty<OUString>(getRun(xPara, 1), "TextPortionType"));
709 1 : }
710 :
711 12 : DECLARE_RTFIMPORT_TEST(testFdo36089, "fdo36089.rtf")
712 : {
713 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(-50), getProperty<sal_Int16>(getRun(getParagraph(1), 2), "CharEscapement"));
714 1 : }
715 :
716 12 : DECLARE_RTFIMPORT_TEST(testFdo49892, "fdo49892.rtf")
717 : {
718 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
719 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
720 6 : for (int i = 0; i < xDraws->getCount(); ++i)
721 : {
722 5 : OUString aDescription = getProperty<OUString>(xDraws->getByIndex(i), "Description");
723 5 : if (aDescription == "red")
724 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
725 4 : else if (aDescription == "green")
726 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
727 3 : else if (aDescription == "blue")
728 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
729 2 : else if (aDescription == "rect")
730 : {
731 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(i), "HoriOrientRelation"));
732 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(i), "VertOrientRelation"));
733 : }
734 6 : }
735 1 : }
736 :
737 12 : DECLARE_RTFIMPORT_TEST(testFdo48446, "fdo48446.rtf")
738 : {
739 1 : OUString aExpected("\xd0\x98\xd0\xbc\xd1\x8f", 6, RTL_TEXTENCODING_UTF8);
740 1 : getParagraph(1, aExpected);
741 1 : }
742 :
743 12 : DECLARE_RTFIMPORT_TEST(testFdo47495, "fdo47495.rtf")
744 : {
745 : // Used to have 4 paragraphs, as a result the original bugdoc had 2 pages instead of 1.
746 1 : CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
747 1 : }
748 :
749 12 : DECLARE_RTFIMPORT_TEST(testAllGapsWord, "all_gaps_word.rtf")
750 : {
751 1 : BorderTest borderTest;
752 1 : BorderTest::testTheBorders(mxComponent, false);
753 1 : }
754 :
755 12 : DECLARE_RTFIMPORT_TEST(testFdo52052, "fdo52052.rtf")
756 : {
757 : // Make sure the textframe containing the text "third" appears on the 3rd page.
758 1 : CPPUNIT_ASSERT_EQUAL(OUString("third"), parseDump("/root/page[3]/body/txt/anchored/fly/txt/text()"));
759 1 : }
760 :
761 12 : DECLARE_RTFIMPORT_TEST(testInk, "ink.rtf")
762 : {
763 : /*
764 : * The problem was that the second segment had wrong command count and wrap type.
765 : *
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
771 : */
772 1 : uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(getShape(1), "CustomShapeGeometry");
773 2 : uno::Sequence<beans::PropertyValue> aPathProps;
774 4 : for (int i = 0; i < aProps.getLength(); ++i)
775 : {
776 3 : const beans::PropertyValue& rProp = aProps[i];
777 3 : if (rProp.Name == "Path")
778 1 : rProp.Value >>= aPathProps;
779 : }
780 2 : uno::Sequence<drawing::EnhancedCustomShapeSegment> aSegments;
781 3 : for (int i = 0; i < aPathProps.getLength(); ++i)
782 : {
783 2 : const beans::PropertyValue& rProp = aPathProps[i];
784 2 : if (rProp.Name == "Segments")
785 1 : rProp.Value >>= aSegments;
786 : }
787 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aSegments[1].Count);
788 2 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(getShape(1), "Surround"));
789 1 : }
790 :
791 12 : DECLARE_RTFIMPORT_TEST(testFdo52389, "fdo52389.rtf")
792 : {
793 : // The last '!' character at the end of the document was lost
794 1 : CPPUNIT_ASSERT_EQUAL(6, getLength());
795 1 : }
796 :
797 12 : DECLARE_RTFIMPORT_TEST(testFdo49655, "fdo49655.rtf")
798 : {
799 : /*
800 : * 49655 :
801 : * The problem was that the table was not imported due to the ' ' string in the middle of the table definition.
802 : *
803 : * xray ThisComponent.TextTables.Count 'was 0
804 : */
805 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
806 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
807 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
808 1 : }
809 :
810 12 : DECLARE_RTFIMPORT_TEST(testFdo62805, "fdo62805.rtf")
811 : {
812 : /*
813 : * 62805 :
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).
816 : */
817 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
818 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
819 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
820 1 : }
821 :
822 12 : DECLARE_RTFIMPORT_TEST(testFdo52475, "fdo52475.rtf")
823 : {
824 : // The problem was that \chcbpat0 resulted in no color, instead of COL_AUTO.
825 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 3), "CharBackColor"));
826 1 : }
827 :
828 12 : DECLARE_RTFIMPORT_TEST(testFdo55493, "fdo55493.rtf")
829 : {
830 : // The problem was that the width of the PNG was detected as 15,24cm, instead of 3.97cm
831 1 : uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
832 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3969), xShape->getSize().Width);
833 1 : }
834 :
835 12 : DECLARE_RTFIMPORT_TEST(testCopyPastePageStyle, "copypaste-pagestyle.rtf")
836 : {
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 1 : paste("copypaste-pagestyle-paste.rtf");
840 :
841 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
842 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), getProperty<sal_Int32>(xPropertySet, "Width")); // Was letter, i.e. 21590
843 1 : }
844 :
845 12 : DECLARE_RTFIMPORT_TEST(testCopyPasteFootnote, "copypaste-footnote.rtf")
846 : {
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 1 : uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
849 2 : uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
850 2 : uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
851 1 : paste("copypaste-footnote-paste.rtf", xTextRange);
852 :
853 2 : CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange->getString());
854 1 : }
855 :
856 12 : DECLARE_RTFIMPORT_TEST(testFdo61193, "hello.rtf")
857 : {
858 : // Pasting content that contained a footnote caused a crash.
859 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
860 2 : uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
861 2 : uno::Reference<text::XTextRange> xEnd = xText->getEnd();
862 2 : paste("fdo61193.rtf", xEnd);
863 1 : }
864 :
865 12 : DECLARE_RTFIMPORT_TEST(testShptxtPard, "shptxt-pard.rtf")
866 : {
867 : // The problem was that \pard inside \shptxt caused loss of shape text
868 1 : uno::Reference<text::XText> xText(getShape(1), uno::UNO_QUERY);
869 1 : CPPUNIT_ASSERT_EQUAL(OUString("shape text"), xText->getString());
870 1 : }
871 :
872 12 : DECLARE_RTFIMPORT_TEST(testDoDhgt, "do-dhgt.rtf")
873 : {
874 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
875 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
876 4 : for (int i = 0; i < xDraws->getCount(); ++i)
877 : {
878 3 : sal_Int32 nFillColor = getProperty<sal_Int32>(xDraws->getByIndex(i), "FillColor");
879 3 : if (nFillColor == 0xc0504d) // red
880 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
881 2 : else if (nFillColor == 0x9bbb59) // green
882 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
883 1 : else if (nFillColor == 0x4f81bd) // blue
884 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(xDraws->getByIndex(i), "ZOrder"));
885 1 : }
886 1 : }
887 :
888 12 : DECLARE_RTFIMPORT_TEST(testDplinehollow, "dplinehollow.rtf")
889 : {
890 1 : uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
891 1 : table::BorderLine2 line(getProperty<table::BorderLine2>(xPropertySet, "TopBorder"));
892 1 : CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, line.LineStyle);
893 1 : }
894 :
895 12 : DECLARE_RTFIMPORT_TEST(testLeftmarginDefault, "leftmargin-default.rtf")
896 : {
897 : // The default left/right margin was incorrect when the top margin was set to zero.
898 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2540), getProperty<sal_Int32>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "LeftMargin"));
899 1 : }
900 :
901 12 : DECLARE_RTFIMPORT_TEST(testDppolyline, "dppolyline.rtf")
902 : {
903 : // This was completely ignored, for now, just make sure we have all 4 lines.
904 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
905 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
906 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws->getCount());
907 1 : }
908 :
909 12 : DECLARE_RTFIMPORT_TEST(testFdo79319, "fdo79319.rtf")
910 : {
911 : // the thin horizontal rule was imported as a big fat rectangle
912 1 : uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
913 1 : 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)
916 : #if 0
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"));
921 : #endif
922 1 : }
923 :
924 12 : DECLARE_RTFIMPORT_TEST(testFdo56512, "fdo56512.rtf")
925 : {
926 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
927 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
928 2 : uno::Reference<text::XTextRange> xTextRange(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
929 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
931 1 : }
932 :
933 12 : DECLARE_RTFIMPORT_TEST(testFdo52989, "fdo52989.rtf")
934 : {
935 : // Same as n#192129, but for JPEG files.
936 1 : uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
937 2 : OString aMessage("xShape->getSize().Width() = ");
938 1 : aMessage += OString::number(xShape->getSize().Width);
939 :
940 : // This was 2, should be 423 (or 369?).
941 2 : CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xShape->getSize().Width >= 273);
942 1 : }
943 :
944 12 : DECLARE_RTFIMPORT_TEST(testFdo48442, "fdo48442.rtf")
945 : {
946 : // The problem was that \pvmrg is the default in RTF, but not in Writer.
947 1 : uno::Reference<drawing::XShape> xShape = getShape(1);
948 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xShape, "VertOrientRelation")); // was FRAME
949 1 : }
950 :
951 12 : DECLARE_RTFIMPORT_TEST(testFdo55525, "fdo55525.rtf")
952 : {
953 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
954 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
955 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
956 : // Negative left margin was ~missing, -191
957 1 : 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 2 : uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
960 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(896), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
961 1 : }
962 :
963 12 : DECLARE_RTFIMPORT_TEST(testFdo57708, "fdo57708.rtf")
964 : {
965 : // There were two issues: the doc was of 2 pages and the picture was missing.
966 1 : CPPUNIT_ASSERT_EQUAL(1, getPages());
967 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
968 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
969 : // Two objects: a picture and a textframe.
970 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
971 1 : }
972 :
973 12 : DECLARE_RTFIMPORT_TEST(testFdo54473, "fdo54473.rtf")
974 : {
975 : // The problem was that character styles were not imported due to a typo.
976 1 : CPPUNIT_ASSERT_EQUAL(OUString("Anot"), getProperty<OUString>(getRun(getParagraph(1), 1, "Text "), "CharStyleName"));
977 1 : CPPUNIT_ASSERT_EQUAL(OUString("ForeignTxt"), getProperty<OUString>(getRun(getParagraph(1), 3, "character "), "CharStyleName"));
978 1 : }
979 :
980 12 : DECLARE_RTFIMPORT_TEST(testFdo49934, "fdo49934.rtf")
981 : {
982 : // Column break without columns defined should be a page break, but it was just ignored.
983 1 : CPPUNIT_ASSERT_EQUAL(2, getPages());
984 1 : }
985 :
986 12 : DECLARE_RTFIMPORT_TEST(testFdo57886, "fdo57886.rtf")
987 : {
988 : // Was 'int from <?> to <?> <?>'.
989 1 : CPPUNIT_ASSERT_EQUAL(OUString("int from {firstlower} to {firstupper} {firstbody}"), getFormula(getRun(getParagraph(1), 1)));
990 1 : }
991 :
992 12 : DECLARE_RTFIMPORT_TEST(testFdo58076, "fdo58076.rtf")
993 : {
994 : // An additional section was created, so the default page style didn't have the custom margins.
995 1 : uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
996 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2251), getProperty<sal_Int32>(xStyle, "LeftMargin"));
997 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1752), getProperty<sal_Int32>(xStyle, "RightMargin"));
998 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty<sal_Int32>(xStyle, "TopMargin"));
999 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty<sal_Int32>(xStyle, "BottomMargin"));
1000 1 : }
1001 :
1002 12 : DECLARE_RTFIMPORT_TEST(testFdo57678, "fdo57678.rtf")
1003 : {
1004 : // Paragraphs of the two tables were not converted to tables.
1005 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1006 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1007 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
1008 1 : }
1009 :
1010 12 : DECLARE_RTFIMPORT_TEST(testFdo45183, "fdo45183.rtf")
1011 : {
1012 : // Was text::WrapTextMode_PARALLEL, i.e. shpfblwtxt didn't send the shape below text.
1013 1 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(getShape(1), "Surround"));
1014 :
1015 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1016 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(16237), getProperty<sal_Int32>(xTables->getByIndex(0), "Width"));
1019 1 : }
1020 :
1021 12 : DECLARE_RTFIMPORT_TEST(testFdo54612, "fdo54612.rtf")
1022 : {
1023 : // \dpptx without a \dppolycount caused a crash.
1024 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1025 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1026 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws->getCount());
1027 1 : }
1028 :
1029 12 : DECLARE_RTFIMPORT_TEST(testFdo58933, "fdo58933.rtf")
1030 : {
1031 : // The problem was that the table had an additional cell in its first line.
1032 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1033 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1034 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1035 : // This was 4.
1036 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getCellNames().getLength());
1037 1 : }
1038 :
1039 12 : DECLARE_RTFIMPORT_TEST(testFdo44053, "fdo44053.rtf")
1040 : {
1041 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1042 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1043 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1044 2 : uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
1045 : // The with of the table's A1 and A2 cell should equal.
1046 2 : CPPUNIT_ASSERT_EQUAL(getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position,
1047 2 : getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position);
1048 1 : }
1049 :
1050 12 : DECLARE_RTFIMPORT_TEST(testFdo48440, "fdo48440.rtf")
1051 : {
1052 : // Page break was ignored.
1053 1 : CPPUNIT_ASSERT_EQUAL(2, getPages());
1054 1 : }
1055 :
1056 12 : DECLARE_RTFIMPORT_TEST(testFdo58646line, "fdo58646line.rtf")
1057 : {
1058 : // \line symbol was ignored
1059 1 : getParagraph(1, "foo\nbar");
1060 1 : }
1061 :
1062 12 : DECLARE_RTFIMPORT_TEST(testFdo78502, "fdo78502.rtf")
1063 : {
1064 : // ";" separators were inserted as text
1065 1 : getParagraph(1, "foo");
1066 1 : }
1067 :
1068 12 : DECLARE_RTFIMPORT_TEST(testFdo58646, "fdo58646.rtf")
1069 : {
1070 : // Page break was ignored inside a continuous section, on title page.
1071 1 : CPPUNIT_ASSERT_EQUAL(2, getPages());
1072 1 : }
1073 :
1074 12 : DECLARE_RTFIMPORT_TEST(testFdo59419, "fdo59419.rtf")
1075 : {
1076 : // Junk to be ignored broke import of the table.
1077 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1078 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1079 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
1080 1 : }
1081 :
1082 12 : DECLARE_RTFIMPORT_TEST(testFdo58076_2, "fdo58076-2.rtf")
1083 : {
1084 : // Position of the picture wasn't correct.
1085 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(8345)), getProperty<sal_Int32>(getShape(1), "HoriOrientPosition"));
1086 1 : }
1087 :
1088 12 : DECLARE_RTFIMPORT_TEST(testFdo59953, "fdo59953.rtf")
1089 : {
1090 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1091 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1092 2 : 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 2 : uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
1095 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(7649), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
1096 1 : }
1097 :
1098 12 : DECLARE_RTFIMPORT_TEST(testFdo59638, "fdo59638.rtf")
1099 : {
1100 : // The problem was that w:lvlOverride inside w:num was ignores by dmapper.
1101 :
1102 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
1103 1 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
1104 1 : uno::Sequence<beans::PropertyValue> aProps;
1105 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
1106 :
1107 14 : for (int i = 0; i < aProps.getLength(); ++i)
1108 : {
1109 14 : const beans::PropertyValue& rProp = aProps[i];
1110 :
1111 14 : if (rProp.Name == "BulletChar")
1112 : {
1113 : // Was '*', should be 'o'.
1114 1 : CPPUNIT_ASSERT_EQUAL(OUString("\xEF\x82\xB7", 3, RTL_TEXTENCODING_UTF8), rProp.Value.get<OUString>());
1115 2 : return;
1116 : }
1117 : }
1118 0 : CPPUNIT_FAIL("no BulletChar property");
1119 : }
1120 :
1121 12 : DECLARE_RTFIMPORT_TEST(testFdo60722, "fdo60722.rtf")
1122 : {
1123 : // The problem was that the larger shape was over the smaller one, and not the other way around.
1124 1 : uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY);
1125 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xShape, "ZOrder"));
1126 1 : CPPUNIT_ASSERT_EQUAL(OUString("larger"), getProperty<OUString>(xShape, "Description"));
1127 :
1128 1 : xShape.set(getShape(2), uno::UNO_QUERY);
1129 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(xShape, "ZOrder"));
1130 1 : CPPUNIT_ASSERT_EQUAL(OUString("smaller"), getProperty<OUString>(xShape, "Description"));
1131 :
1132 : // Color of the line was blue, and it had zero width.
1133 1 : xShape.set(getShape(3), uno::UNO_QUERY);
1134 1 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty<sal_uInt32>(xShape, "LineWidth"));
1135 1 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty<sal_uInt32>(xShape, "LineColor"));
1136 1 : }
1137 :
1138 12 : DECLARE_RTFIMPORT_TEST(testDoDhgtOld, "do-dhgt-old.rtf")
1139 : {
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 1 : uno::Reference<text::XText> xShape(getShape(1), uno::UNO_QUERY);
1143 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xShape, "ZOrder"));
1144 1 : CPPUNIT_ASSERT_EQUAL(OUString("a"), xShape->getString());
1145 :
1146 1 : xShape.set(getShape(2), uno::UNO_QUERY);
1147 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(xShape, "ZOrder"));
1148 1 : CPPUNIT_ASSERT_EQUAL(COL_BLACK, getProperty<sal_uInt32>(xShape, "FillColor"));
1149 :
1150 1 : xShape.set(getShape(3), uno::UNO_QUERY);
1151 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(xShape, "ZOrder"));
1152 1 : CPPUNIT_ASSERT_EQUAL(OUString("b"), xShape->getString());
1153 1 : }
1154 :
1155 12 : DECLARE_RTFIMPORT_TEST(testFdo61909, "fdo61909.rtf")
1156 : {
1157 1 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
1158 : // Was the Writer default font.
1159 1 : CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty<OUString>(xTextRange, "CharFontName"));
1160 1 : CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(xTextRange, "CharBackColor"));
1161 1 : }
1162 :
1163 12 : DECLARE_RTFIMPORT_TEST(testFdo62288, "fdo62288.rtf")
1164 : {
1165 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1166 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1167 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1168 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
1169 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
1170 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
1171 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaLeftMargin"));
1174 1 : }
1175 :
1176 12 : DECLARE_RTFIMPORT_TEST(testFdo37716, "fdo37716.rtf")
1177 : {
1178 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
1179 2 : uno::Reference<container::XIndexAccess> xFrames(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
1180 : // \nowrap got ignored, so Surround was text::WrapTextMode_PARALLEL
1181 2 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_NONE, getProperty<text::WrapTextMode>(xFrames->getByIndex(0), "Surround"));
1182 1 : }
1183 :
1184 12 : DECLARE_RTFIMPORT_TEST(testFdo51916, "fdo51916.rtf")
1185 : {
1186 : // Complex nested table caused a crash.
1187 1 : }
1188 :
1189 12 : DECLARE_RTFIMPORT_TEST(testFdo63023, "fdo63023.rtf")
1190 : {
1191 1 : 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 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF99), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xHeaderText), 1), "CharBackColor"));
1194 1 : }
1195 :
1196 12 : DECLARE_RTFIMPORT_TEST(testFdo42109, "fdo42109.rtf")
1197 : {
1198 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1199 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1200 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1201 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 1), "TextPortionType"));
1204 1 : }
1205 :
1206 12 : DECLARE_RTFIMPORT_TEST(testFdo62977, "fdo62977.rtf")
1207 : {
1208 : // The middle character was imported as '?' instead of the proper unicode value.
1209 1 : getRun(getParagraph(1), 1, OUString("\xE5\xB9\xB4\xEF\xBC\x94\xE6\x9C\x88", 9, RTL_TEXTENCODING_UTF8));
1210 1 : }
1211 :
1212 12 : DECLARE_RTFIMPORT_TEST(testN818997, "n818997.rtf")
1213 : {
1214 : // \page was ignored between two \shp tokens.
1215 1 : CPPUNIT_ASSERT_EQUAL(2, getPages());
1216 1 : }
1217 :
1218 12 : DECLARE_RTFIMPORT_TEST(testFdo64671, "fdo64671.rtf")
1219 : {
1220 : // Additional '}' was inserted before the special character.
1221 1 : getRun(getParagraph(1), 1, OUString("\xC5\xBD", 2, RTL_TEXTENCODING_UTF8));
1222 1 : }
1223 :
1224 12 : DECLARE_RTFIMPORT_TEST(testPageBackground, "page-background.rtf")
1225 : {
1226 : // The problem was that \background was ignored.
1227 1 : uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
1228 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
1229 1 : }
1230 :
1231 12 : DECLARE_RTFIMPORT_TEST(testFdo81944, "fdo81944.rtf")
1232 : {
1233 : // font properties in style were not imported
1234 : uno::Reference<beans::XPropertySet> xPropertySet(
1235 1 : getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
1236 2 : uno::Reference<style::XStyle> xStyle(xPropertySet, uno::UNO_QUERY);
1237 1 : CPPUNIT_ASSERT_EQUAL(OUString("Segoe UI"), getProperty<OUString>(xStyle, "CharFontName"));
1238 1 : CPPUNIT_ASSERT_EQUAL(9.0f, getProperty<float>(xStyle, "CharHeight"));
1239 : // not sure if this should be set on Asian or Complex or both?
1240 1 : CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), getProperty<OUString>(xStyle, "CharFontNameComplex"));
1241 2 : CPPUNIT_ASSERT_EQUAL(11.0f, getProperty<float>(xStyle, "CharHeightComplex"));
1242 1 : }
1243 :
1244 12 : DECLARE_RTFIMPORT_TEST(testFdo62044, "fdo62044.rtf")
1245 : {
1246 : // The problem was that RTF import during copy&paste did not ignore existing paragraph styles.
1247 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
1248 2 : uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
1249 2 : uno::Reference<text::XTextRange> xEnd = xText->getEnd();
1250 1 : paste("fdo62044-paste.rtf", xEnd);
1251 :
1252 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
1253 2 : CPPUNIT_ASSERT_EQUAL(10.f, getProperty<float>(xPropertySet, "CharHeight")); // Was 18, i.e. reset back to original value.
1254 1 : }
1255 :
1256 12 : DECLARE_RTFIMPORT_TEST(testFdo70578, "fdo70578.rtf")
1257 : {
1258 : // Style without explicit \s0 was not imported as the default style
1259 : uno::Reference<beans::XPropertySet> xPropertySet(
1260 1 : getStyles("ParagraphStyles")->getByName("Subtitle"), uno::UNO_QUERY);
1261 2 : uno::Reference<style::XStyle> xStyle(xPropertySet, uno::UNO_QUERY);
1262 1 : CPPUNIT_ASSERT_EQUAL(OUString("Standard"), xStyle->getParentStyle());
1263 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "ParaTopMargin"));
1264 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
1265 1 : }
1266 :
1267 12 : DECLARE_RTFIMPORT_TEST(testPoshPosv, "posh-posv.rtf")
1268 : {
1269 1 : CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(getShape(1), "HoriOrient"));
1270 1 : CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty<sal_Int16>(getShape(1), "VertOrient"));
1271 1 : CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getShape(1), "FrameIsAutomaticHeight"));
1272 1 : }
1273 :
1274 12 : DECLARE_RTFIMPORT_TEST(testN825305, "n825305.rtf")
1275 : {
1276 : // The problem was that the textbox wasn't transparent, due to unimplemented fFilled == 0.
1277 1 : uno::Reference<beans::XPropertyState> xPropertyState(getShape(2), uno::UNO_QUERY);
1278 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(getShape(2), "BackColorTransparency"));
1279 1 : beans::PropertyState ePropertyState = xPropertyState->getPropertyState("BackColorTransparency");
1280 : // Was beans::PropertyState_DEFAULT_VALUE.
1281 1 : CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState);
1282 1 : }
1283 :
1284 12 : DECLARE_RTFIMPORT_TEST(testParaBottomMargin, "para-bottom-margin.rtf")
1285 : {
1286 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
1287 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
1288 :
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 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
1295 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
1296 1 : }
1297 :
1298 12 : DECLARE_RTFIMPORT_TEST(testN823655, "n823655.rtf")
1299 : {
1300 1 : uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(getShape(1), "CustomShapeGeometry");
1301 2 : uno::Sequence<beans::PropertyValue> aPathProps;
1302 4 : for (int i = 0; i < aProps.getLength(); ++i)
1303 : {
1304 3 : const beans::PropertyValue& rProp = aProps[i];
1305 3 : if (rProp.Name == "Path")
1306 1 : aPathProps = rProp.Value.get< uno::Sequence<beans::PropertyValue> >();
1307 : }
1308 2 : uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aCoordinates;
1309 3 : for (int i = 0; i < aPathProps.getLength(); ++i)
1310 : {
1311 2 : const beans::PropertyValue& rProp = aPathProps[i];
1312 2 : if (rProp.Name == "Coordinates")
1313 1 : aCoordinates = rProp.Value.get< uno::Sequence<drawing::EnhancedCustomShapeParameterPair> >();
1314 : }
1315 : // The first coordinate pair of this freeform shape was 286,0 instead of 0,286.
1316 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates[0].Second.Value.get<sal_Int32>());
1317 1 : }
1318 :
1319 12 : DECLARE_RTFIMPORT_TEST(testFdo66040, "fdo66040.rtf")
1320 : {
1321 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1322 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1323 : // This was 0 (no shapes were imported), we want two textframes.
1324 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
1325 :
1326 : // The second paragraph of the first shape should be actually a table, with "A" in its A1 cell.
1327 2 : uno::Reference<text::XTextRange> xTextRange(xDraws->getByIndex(0), uno::UNO_QUERY);
1328 2 : uno::Reference<text::XText> xText = xTextRange->getText();
1329 2 : uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
1330 1 : CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString());
1331 :
1332 : // Make sure the second shape has the correct position and size.
1333 2 : uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(1), uno::UNO_QUERY);
1334 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(14420), getProperty<sal_Int32>(xShape, "HoriOrientPosition"));
1335 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1032), getProperty<sal_Int32>(xShape, "VertOrientPosition"));
1336 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(14000), xShape->getSize().Width);
1337 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), xShape->getSize().Height);
1338 1 : }
1339 :
1340 12 : DECLARE_RTFIMPORT_TEST(testN823675, "n823675.rtf")
1341 : {
1342 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
1343 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
1344 2 : uno::Sequence<beans::PropertyValue> aProps;
1345 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
1346 2 : awt::FontDescriptor aFont;
1347 :
1348 17 : for (int i = 0; i < aProps.getLength(); ++i)
1349 : {
1350 16 : const beans::PropertyValue& rProp = aProps[i];
1351 :
1352 16 : if (rProp.Name == "BulletFont")
1353 1 : aFont = rProp.Value.get<awt::FontDescriptor>();
1354 : }
1355 : // This was empty, i.e. no font name was set for the bullet numbering.
1356 2 : CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), aFont.Name);
1357 1 : }
1358 :
1359 12 : DECLARE_RTFIMPORT_TEST(testFdo77996, "fdo77996.rtf")
1360 : {
1361 : // all styles were imported as name "0"
1362 1 : uno::Reference<container::XNameAccess> xChars(getStyles("CharacterStyles"));
1363 1 : CPPUNIT_ASSERT(!xChars->hasByName("0"));
1364 1 : CPPUNIT_ASSERT(xChars->hasByName("strong"));
1365 1 : CPPUNIT_ASSERT(xChars->hasByName("author"));
1366 2 : uno::Reference<container::XNameAccess> xParas(getStyles("ParagraphStyles"));
1367 1 : CPPUNIT_ASSERT(!xParas->hasByName("0"));
1368 1 : CPPUNIT_ASSERT(xParas->hasByName("extract2"));
1369 : // some document properties were lost
1370 2 : uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
1371 2 : uno::Reference<document::XDocumentProperties> xProps(xDocumentPropertiesSupplier->getDocumentProperties());
1372 1 : CPPUNIT_ASSERT_EQUAL(OUString("Aln Lin (Bei Jing)"), xProps->getAuthor());
1373 2 : 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 1 : CPPUNIT_ASSERT_EQUAL(aTitle, xProps->getTitle());
1375 2 : uno::Reference<beans::XPropertySet> xUDProps(xProps->getUserDefinedProperties(), uno::UNO_QUERY);
1376 1 : CPPUNIT_ASSERT_EQUAL(OUString("jay"), getProperty<OUString>(xUDProps, "Operator"));
1377 :
1378 : // fdo#80486 also check that the ftnsep doesn't insert paragraph breaks
1379 2 : getParagraph(1, aTitle);
1380 1 : }
1381 :
1382 12 : DECLARE_RTFIMPORT_TEST(testFdo47802, "fdo47802.rtf")
1383 : {
1384 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1385 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1386 : // Shape inside table was ignored.
1387 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
1388 1 : }
1389 :
1390 12 : DECLARE_RTFIMPORT_TEST(testFdo39001, "fdo39001.rtf")
1391 : {
1392 : // Document was of 4 pages, \sect at the end of the doc wasn't ignored.
1393 1 : CPPUNIT_ASSERT_EQUAL(3, getPages());
1394 1 : }
1395 :
1396 12 : DECLARE_RTFIMPORT_TEST(testGroupshape, "groupshape.rtf")
1397 : {
1398 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1399 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1400 : // There should be a single groupshape with 2 children.
1401 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
1402 2 : uno::Reference<drawing::XShapes> xGroupshape(xDraws->getByIndex(0), uno::UNO_QUERY);
1403 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape->getCount());
1404 1 : }
1405 :
1406 12 : DECLARE_RTFIMPORT_TEST(testGroupshape_notext, "groupshape-notext.rtf")
1407 : {
1408 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1409 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1410 : // There should be a single groupshape with 2 children.
1411 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
1412 2 : uno::Reference<drawing::XShapes> xGroupshape(xDraws->getByIndex(0), uno::UNO_QUERY);
1413 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape->getCount());
1414 1 : }
1415 :
1416 12 : DECLARE_RTFIMPORT_TEST(testFdo81033, "fdo81033.rtf")
1417 : {
1418 : // Number of tabstops in the paragraph should be 2, was 3.
1419 : uno::Sequence<style::TabStop> tabs(
1420 1 : getProperty< uno::Sequence<style::TabStop> >(getParagraph(1), "ParaTabStops"));
1421 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabs.getLength());
1422 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(5808), tabs[0].Position);
1423 1 : CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT, tabs[0].Alignment);
1424 1 : CPPUNIT_ASSERT_EQUAL(sal_Unicode(' '), tabs[0].FillChar);
1425 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(16002), tabs[1].Position);
1426 1 : CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT, tabs[1].Alignment);
1427 1 : CPPUNIT_ASSERT_EQUAL(sal_Unicode('_'), tabs[1].FillChar);
1428 1 : }
1429 :
1430 12 : DECLARE_RTFIMPORT_TEST(testFdo66565, "fdo66565.rtf")
1431 : {
1432 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1433 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1434 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1435 : // Cell width of A2 was 554, should be 453/14846*10000
1436 2 : uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
1437 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(304), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position);
1438 1 : }
1439 :
1440 12 : DECLARE_RTFIMPORT_TEST(testFdo54900, "fdo54900.rtf")
1441 : {
1442 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1443 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1444 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1445 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1446 : // Paragraph was aligned to left, should be center.
1447 2 : CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraphOfText(1, xCell->getText()), "ParaAdjust")));
1448 1 : }
1449 :
1450 12 : DECLARE_RTFIMPORT_TEST(testFdo64637, "fdo64637.rtf")
1451 : {
1452 : // The problem was that the custom "Company" property was added twice, the second invocation resulted in an exception.
1453 1 : uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
1454 2 : uno::Reference<beans::XPropertySet> xPropertySet(xDocumentPropertiesSupplier->getDocumentProperties()->getUserDefinedProperties(), uno::UNO_QUERY);
1455 2 : CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getProperty<OUString>(xPropertySet, "Company"));
1456 1 : }
1457 :
1458 12 : DECLARE_RTFIMPORT_TEST(testN820504, "n820504.rtf")
1459 : {
1460 : // The shape was anchored at-page instead of at-character (that's incorrect as Word only supports at-character and as-character).
1461 1 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
1462 1 : }
1463 :
1464 12 : DECLARE_RTFIMPORT_TEST(testFdo67365, "fdo67365.rtf")
1465 : {
1466 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1467 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1468 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1469 2 : uno::Reference<table::XTableRows> xRows = xTable->getRows();
1470 : // The table only had 3 rows.
1471 1 : 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 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(5290), getProperty< uno::Sequence<text::TableColumnSeparator> >(xRows->getByIndex(2), "TableColumnSeparators")[0].Position);
1474 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A2"), uno::UNO_QUERY);
1475 : // Paragraph was aligned to center, should be left.
1476 2 : CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraphOfText(1, xCell->getText()), "ParaAdjust")));
1477 1 : }
1478 :
1479 12 : DECLARE_RTFIMPORT_TEST(testFdo67498, "fdo67498.rtf")
1480 : {
1481 : // Left margin of the default page style wasn't set (was 2000).
1482 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(5954)), getProperty<sal_Int32>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "LeftMargin"));
1483 1 : }
1484 :
1485 12 : DECLARE_RTFIMPORT_TEST(testFdo47440, "fdo47440.rtf")
1486 : {
1487 : // Vertical and horizontal orientation of the picture wasn't imported (was text::RelOrientation::FRAME).
1488 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), "HoriOrientRelation"));
1489 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), "VertOrientRelation"));
1490 1 : }
1491 :
1492 12 : DECLARE_RTFIMPORT_TEST(testFdo53556, "fdo53556.rtf")
1493 : {
1494 : // This was drawing::FillStyle_SOLID, which resulted in being non-transparent, hiding text which would be visible.
1495 1 : CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(getShape(3), "FillStyle"));
1496 :
1497 : // This was a com.sun.star.drawing.CustomShape, which resulted in lack of word wrapping in the bugdoc.
1498 1 : uno::Reference<beans::XPropertySet> xShapeProperties(getShape(1), uno::UNO_QUERY);
1499 2 : uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xShapeProperties, uno::UNO_QUERY);
1500 2 : CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), xShapeDescriptor->getShapeType());
1501 1 : }
1502 :
1503 12 : DECLARE_RTFIMPORT_TEST(testFdo63428, "hello.rtf")
1504 : {
1505 : // Pasting content that contained an annotation caused a crash.
1506 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
1507 2 : uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
1508 2 : uno::Reference<text::XTextRange> xEnd = xText->getEnd();
1509 1 : paste("fdo63428.rtf", xEnd);
1510 :
1511 : // Additionally, commented range was imported as a normal comment.
1512 1 : CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(getRun(getParagraph(1), 2), "TextPortionType"));
1513 2 : CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(getRun(getParagraph(1), 4), "TextPortionType"));
1514 1 : }
1515 :
1516 12 : DECLARE_RTFIMPORT_TEST(testGroupshapeRotation, "groupshape-rotation.rtf")
1517 : {
1518 : // Rotation on groupshapes wasn't handled correctly, RotateAngle was 4500.
1519 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(315 * 100), getProperty<sal_Int32>(getShape(1), "RotateAngle"));
1520 1 : }
1521 :
1522 12 : DECLARE_RTFIMPORT_TEST(testFdo44715, "fdo44715.rtf")
1523 : {
1524 1 : uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
1525 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(getParagraphOfText(2, xCell->getText()), "CharHeight"));
1528 1 : }
1529 :
1530 12 : DECLARE_RTFIMPORT_TEST(testFdo68076, "fdo68076.rtf")
1531 : {
1532 : // Encoding of the last char was wrong (more 'o' than 'y').
1533 1 : OUString aExpected("\xD0\x9E\xD0\xB1\xD1\x8A\xD0\xB5\xD0\xBA\xD1\x82 \xE2\x80\x93 \xD1\x83", 19, RTL_TEXTENCODING_UTF8);
1534 1 : getParagraph(1, aExpected);
1535 1 : }
1536 :
1537 12 : DECLARE_RTFIMPORT_TEST(testFdo68291, "fdo68291.odt")
1538 : {
1539 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
1540 2 : uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
1541 2 : uno::Reference<text::XTextRange> xEnd = xText->getEnd();
1542 1 : paste("fdo68291-paste.rtf", xEnd);
1543 :
1544 : // This was "Standard", causing an unwanted page break on next paste.
1545 2 : CPPUNIT_ASSERT_EQUAL(uno::Any(), uno::Reference<beans::XPropertySet>(getParagraph(1), uno::UNO_QUERY)->getPropertyValue("PageDescName"));
1546 1 : }
1547 :
1548 12 : DECLARE_RTFIMPORT_TEST(testFdo69384, "hello.rtf")
1549 : {
1550 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
1551 2 : uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
1552 2 : uno::Reference<text::XTextRange> xEnd = xText->getEnd();
1553 1 : paste("fdo69384-paste.rtf", xEnd);
1554 :
1555 : // Import got interrupted in the middle of style sheet table import,
1556 : // resuling in missing styles and text.
1557 2 : getStyles("ParagraphStyles")->getByName("Text body justified");
1558 1 : }
1559 :
1560 12 : DECLARE_RTFIMPORT_TEST(testFdo70221, "fdo70221.rtf")
1561 : {
1562 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1563 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1564 : // The picture was imported twice.
1565 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
1566 1 : }
1567 :
1568 12 : DECLARE_RTFIMPORT_TEST(testCp1000018, "cp1000018.rtf")
1569 : {
1570 : // The problem was that the empty paragraph at the end of the footnote got
1571 : // lost during import.
1572 1 : uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
1573 2 : uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
1574 2 : uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
1575 2 : OUString aExpected("Footnote first line.\n");
1576 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
1577 1 : }
1578 :
1579 : #endif
1580 :
1581 12 : DECLARE_RTFIMPORT_TEST(testNestedTable, "rhbz1065629.rtf")
1582 : {
1583 : // nested table in second cell was missing
1584 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1585 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1586 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(1), uno::UNO_QUERY);
1587 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1588 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
1589 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
1590 2 : uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
1591 1 : CPPUNIT_ASSERT_EQUAL(OUString("Responsable Commercial:"), xPara->getString());
1592 1 : xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
1593 1 : xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY);
1594 1 : xParaEnum = xParaEnumAccess->createEnumeration();
1595 1 : xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
1596 1 : xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
1597 1 : CPPUNIT_ASSERT_EQUAL(OUString("Nom: John Doe"), xPara->getString());
1598 :
1599 : // outer table: background color, borders for B1/B2 cell
1600 1 : xTable.set(xTables->getByIndex(2), uno::UNO_QUERY);
1601 1 : xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
1602 1 : CPPUNIT_ASSERT(xCell.is());
1603 1 : table::BorderLine2 fullPtSolid(1, 0, 35, 0, table::BorderLineStyle::SOLID, 35);
1604 2 : CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid,
1605 1 : getProperty<table::BorderLine2>(xCell, "LeftBorder"));
1606 2 : CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid,
1607 1 : getProperty<table::BorderLine2>(xCell, "RightBorder"));
1608 2 : CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid,
1609 1 : getProperty<table::BorderLine2>(xCell, "TopBorder"));
1610 2 : CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid,
1611 1 : getProperty<table::BorderLine2>(xCell, "BottomBorder"));
1612 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xCC0000), getProperty<sal_Int32>(xCell, "BackColor"));
1613 1 : xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
1614 1 : CPPUNIT_ASSERT(xCell.is());
1615 1 : table::BorderLine2 halfPtSolid(/*0*/1, 0, 18, 0, table::BorderLineStyle::SOLID, 18);
1616 2 : CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid,
1617 1 : getProperty<table::BorderLine2>(xCell, "LeftBorder"));
1618 2 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffffff),
1619 1 : getProperty<sal_Int32>(xCell, "BackColor"));
1620 1 : xCell.set(xTable->getCellByName("B2"), uno::UNO_QUERY);
1621 1 : CPPUNIT_ASSERT(xCell.is());
1622 2 : CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid,
1623 1 : getProperty<table::BorderLine2>(xCell, "LeftBorder"));
1624 2 : CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid,
1625 1 : getProperty<table::BorderLine2>(xCell, "RightBorder"));
1626 2 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffffff),
1627 1 : getProperty<sal_Int32>(xCell, "BackColor"));
1628 :
1629 : // \sect at the end resulted in spurious page break
1630 2 : CPPUNIT_ASSERT_EQUAL(1, getPages());
1631 1 : }
1632 :
1633 12 : DECLARE_RTFIMPORT_TEST(testContSectionPageBreak, "cont-section-pagebreak.rtf")
1634 : {
1635 1 : uno::Reference<text::XTextRange> xParaSecond = getParagraph(2);
1636 1 : CPPUNIT_ASSERT_EQUAL(OUString("SECOND"), xParaSecond->getString());
1637 2 : CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE,
1638 1 : getProperty<style::BreakType>(xParaSecond, "BreakType"));
1639 2 : CPPUNIT_ASSERT_EQUAL(uno::Any(),
1640 1 : 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 2 : uno::Reference<text::XTextRange> xParaNext = getParagraph(3);
1644 1 : CPPUNIT_ASSERT_EQUAL(OUString(""), xParaNext->getString());
1645 2 : CPPUNIT_ASSERT_EQUAL(OUString("Converted1"),
1646 1 : getProperty<OUString>(xParaNext, "PageDescName"));
1647 2 : uno::Reference<text::XTextRange> xParaThird = getParagraph(4);
1648 1 : CPPUNIT_ASSERT_EQUAL(OUString("THIRD"), xParaThird->getString());
1649 2 : CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE,
1650 1 : getProperty<style::BreakType>(xParaThird, "BreakType"));
1651 2 : CPPUNIT_ASSERT_EQUAL(uno::Any(),
1652 1 : uno::Reference<beans::XPropertySet>(xParaThird, uno::UNO_QUERY)->getPropertyValue("PageDescName"));
1653 :
1654 2 : CPPUNIT_ASSERT_EQUAL(2, getPages());
1655 1 : }
1656 :
1657 12 : DECLARE_RTFIMPORT_TEST(testFooterPara, "footer-para.rtf")
1658 : {
1659 : // check that paragraph properties in footer are imported
1660 : uno::Reference<text::XText> xFooterText =
1661 1 : getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("First Page"), "FooterText");
1662 : uno::Reference<text::XTextContent> xParagraph =
1663 2 : getParagraphOrTable(1, xFooterText);
1664 2 : CPPUNIT_ASSERT_EQUAL(OUString("All Rights Reserved."),
1665 1 : uno::Reference<text::XTextRange>(xParagraph, uno::UNO_QUERY)->getString());
1666 2 : CPPUNIT_ASSERT_EQUAL((sal_Int16)style::ParagraphAdjust_CENTER,
1667 2 : getProperty</*style::ParagraphAdjust*/sal_Int16>(xParagraph, "ParaAdjust"));
1668 1 : }
1669 :
1670 12 : DECLARE_RTFIMPORT_TEST(testCp1000016, "hello.rtf")
1671 : {
1672 : // The single-line document had a second fake empty para on Windows.
1673 1 : bool bFound = true;
1674 : try
1675 : {
1676 2 : getParagraph(2);
1677 : }
1678 2 : catch (const container::NoSuchElementException&)
1679 : {
1680 1 : bFound = false;
1681 : }
1682 1 : CPPUNIT_ASSERT_EQUAL(false, bFound);
1683 1 : }
1684 :
1685 12 : DECLARE_RTFIMPORT_TEST(testFdo65090, "fdo65090.rtf")
1686 : {
1687 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1688 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1689 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1690 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength());
1693 1 : }
1694 :
1695 12 : DECLARE_RTFIMPORT_TEST(testTableBorderDefaults, "fdo68779.rtf")
1696 : {
1697 : // table borders without \brdrw were not imported
1698 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1699 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1700 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1701 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1702 1 : CPPUNIT_ASSERT(xCell.is());
1703 1 : table::BorderLine2 solid(1, 0, 26, 0, table::BorderLineStyle::SOLID, 26);
1704 2 : CPPUNIT_ASSERT_BORDER_EQUAL(solid,
1705 1 : getProperty<table::BorderLine2>(xCell, "LeftBorder"));
1706 2 : CPPUNIT_ASSERT_BORDER_EQUAL(solid,
1707 1 : getProperty<table::BorderLine2>(xCell, "RightBorder"));
1708 2 : CPPUNIT_ASSERT_BORDER_EQUAL(solid,
1709 1 : getProperty<table::BorderLine2>(xCell, "TopBorder"));
1710 2 : CPPUNIT_ASSERT_BORDER_EQUAL(solid,
1711 1 : getProperty<table::BorderLine2>(xCell, "BottomBorder"));
1712 :
1713 1 : xTable.set(xTables->getByIndex(1), uno::UNO_QUERY);
1714 1 : xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
1715 1 : CPPUNIT_ASSERT(xCell.is());
1716 1 : table::BorderLine2 dotted(1, 0, 26, 0, table::BorderLineStyle::DOTTED, 26);
1717 2 : CPPUNIT_ASSERT_BORDER_EQUAL(dotted,
1718 1 : getProperty<table::BorderLine2>(xCell, "LeftBorder"));
1719 2 : CPPUNIT_ASSERT_BORDER_EQUAL(dotted,
1720 1 : getProperty<table::BorderLine2>(xCell, "RightBorder"));
1721 2 : CPPUNIT_ASSERT_BORDER_EQUAL(dotted,
1722 1 : getProperty<table::BorderLine2>(xCell, "TopBorder"));
1723 2 : CPPUNIT_ASSERT_BORDER_EQUAL(dotted,
1724 1 : getProperty<table::BorderLine2>(xCell, "BottomBorder"));
1725 :
1726 1 : xTable.set(xTables->getByIndex(2), uno::UNO_QUERY);
1727 1 : xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
1728 1 : CPPUNIT_ASSERT(xCell.is());
1729 1 : table::BorderLine2 doubled(1, 26, 26, 26, table::BorderLineStyle::DOUBLE, 79);
1730 2 : CPPUNIT_ASSERT_BORDER_EQUAL(doubled,
1731 1 : getProperty<table::BorderLine2>(xCell, "LeftBorder"));
1732 2 : CPPUNIT_ASSERT_BORDER_EQUAL(doubled,
1733 1 : getProperty<table::BorderLine2>(xCell, "RightBorder"));
1734 2 : CPPUNIT_ASSERT_BORDER_EQUAL(doubled,
1735 1 : getProperty<table::BorderLine2>(xCell, "TopBorder"));
1736 2 : CPPUNIT_ASSERT_BORDER_EQUAL(doubled,
1737 1 : getProperty<table::BorderLine2>(xCell, "BottomBorder"));
1738 :
1739 1 : xTable.set(xTables->getByIndex(3), uno::UNO_QUERY);
1740 1 : xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
1741 1 : CPPUNIT_ASSERT(xCell.is());
1742 1 : table::BorderLine2 thinThickMG(1, 14, 26, 14, table::BorderLineStyle::THINTHICK_MEDIUMGAP, 53);
1743 2 : CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG,
1744 1 : getProperty<table::BorderLine2>(xCell, "LeftBorder"));
1745 2 : CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG,
1746 1 : getProperty<table::BorderLine2>(xCell, "RightBorder"));
1747 2 : CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG,
1748 1 : getProperty<table::BorderLine2>(xCell, "TopBorder"));
1749 2 : CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG,
1750 2 : getProperty<table::BorderLine2>(xCell, "BottomBorder"));
1751 1 : }
1752 :
1753 12 : DECLARE_RTFIMPORT_TEST(testShpzDhgt, "shpz-dhgt.rtf")
1754 : {
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 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), getProperty<sal_Int32>(getShape(1), "FillColor"));
1758 : // Second (front) should be green.
1759 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00ff00), getProperty<sal_Int32>(getShape(2), "FillColor"));
1760 1 : }
1761 :
1762 12 : DECLARE_RTFIMPORT_TEST(testBackground, "background.rtf")
1763 : {
1764 : // The first shape wasn't in the foreground.
1765 1 : CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(getShape(1), "Opaque")));
1766 1 : CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(getShape(2), "Opaque")));
1767 1 : }
1768 :
1769 12 : DECLARE_RTFIMPORT_TEST(testLevelfollow, "levelfollow.rtf")
1770 : {
1771 1 : uno::Reference<container::XIndexAccess> xNum1Levels = getProperty< uno::Reference<container::XIndexAccess> >(getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
1772 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(SvxNumberFormat::LISTTAB), comphelper::SequenceAsHashMap(xNum1Levels->getByIndex(0))["LabelFollowedBy"].get<sal_Int16>()); // first level, tab
1773 :
1774 2 : uno::Reference<container::XIndexAccess> xNum2Levels = getProperty< uno::Reference<container::XIndexAccess> >(getStyles("NumberingStyles")->getByName("WWNum2"), "NumberingRules");
1775 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(SvxNumberFormat::SPACE), comphelper::SequenceAsHashMap(xNum2Levels->getByIndex(0))["LabelFollowedBy"].get<sal_Int16>()); // first level, space
1776 :
1777 2 : uno::Reference<container::XIndexAccess> xNum3Levels = getProperty< uno::Reference<container::XIndexAccess> >(getStyles("NumberingStyles")->getByName("WWNum3"), "NumberingRules");
1778 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(SvxNumberFormat::NOTHING), comphelper::SequenceAsHashMap(xNum3Levels->getByIndex(0))["LabelFollowedBy"].get<sal_Int16>()); // first level, nothing
1779 1 : }
1780 :
1781 12 : DECLARE_RTFIMPORT_TEST(testCharColor, "char-color.rtf")
1782 : {
1783 : // This was -1: character color wasn't set.
1784 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x365F91), getProperty<sal_Int32>(getParagraph(1), "CharColor"));
1785 1 : }
1786 :
1787 12 : DECLARE_RTFIMPORT_TEST(testFdo69289, "fdo69289.rtf")
1788 : {
1789 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1790 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1791 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1792 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength());
1795 1 : }
1796 :
1797 12 : DECLARE_RTFIMPORT_TEST(testDptxbxRelation, "dptxbx-relation.rtf")
1798 : {
1799 : // This was FRAME, not PAGE_FRAME, even if dobxpage is in the document.
1800 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), "HoriOrientRelation"));
1801 1 : }
1802 :
1803 12 : DECLARE_RTFIMPORT_TEST(testDprectAnchor, "dprect-anchor.rtf")
1804 : {
1805 : // This was at-page, which is not something Word supports, so clearly an import error.
1806 1 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
1807 1 : }
1808 :
1809 12 : DECLARE_RTFIMPORT_TEST(testFdo76628, "fdo76628.rtf")
1810 : {
1811 1 : 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 1 : getParagraph(1, aExpected);
1814 :
1815 2 : uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText");
1816 2 : 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 2 : getParagraphOfText(1, xHeaderText, aExpectedHeader);
1819 1 : }
1820 :
1821 12 : DECLARE_RTFIMPORT_TEST(testFdo74823, "fdo74823.rtf")
1822 : {
1823 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1824 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1825 2 : 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 2 : uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
1828 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(5391), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[2].Position);
1829 1 : }
1830 :
1831 12 : DECLARE_RTFIMPORT_TEST(testFdo74599, "fdo74599.rtf")
1832 : {
1833 1 : 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 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), getProperty<sal_Int32>(xPropertySet, "CharColor"));
1836 1 : }
1837 :
1838 12 : DECLARE_RTFIMPORT_TEST(testFdo77267, "fdo77267.rtf")
1839 : {
1840 : // Paragraph was aligned to left, should be center.
1841 1 : CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
1842 1 : }
1843 :
1844 12 : DECLARE_RTFIMPORT_TEST(testFdo75735, "fdo75735.rtf")
1845 : {
1846 : // Number of tabstops in the second paragraph should be 3, was 6.
1847 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty< uno::Sequence<style::TabStop> >(getParagraph(2), "ParaTabStops").getLength());
1848 1 : }
1849 :
1850 12 : DECLARE_RTFIMPORT_TEST(testFontOverride, "font-override.rtf")
1851 : {
1852 : // This was "Times New Roman".
1853 1 : CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
1854 1 : }
1855 :
1856 12 : DECLARE_RTFIMPORT_TEST(testColumnBreak, "column-break.rtf")
1857 : {
1858 : // Column break at the very start of the document was ignored.
1859 1 : CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
1860 1 : }
1861 :
1862 12 : DECLARE_RTFIMPORT_TEST(testFdo73241, "fdo73241.rtf")
1863 : {
1864 : // This was 2, page break in table wasn't ignored.
1865 1 : CPPUNIT_ASSERT_EQUAL(1, getPages());
1866 1 : }
1867 :
1868 12 : DECLARE_RTFIMPORT_TEST(testFdo80905, "fdo80905.rtf")
1869 : {
1870 1 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
1871 2 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
1872 2 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
1873 1 : xFields->nextElement();
1874 : // The problem was that there was only one field in the document, but there should be true.
1875 2 : CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(xFields->hasMoreElements()));
1876 1 : }
1877 :
1878 12 : DECLARE_RTFIMPORT_TEST(testUnbalancedColumnsCompat, "unbalanced-columns-compat.rtf")
1879 : {
1880 1 : uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
1881 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
1884 1 : }
1885 :
1886 12 : DECLARE_RTFIMPORT_TEST(testOleInline, "ole-inline.rtf")
1887 : {
1888 : // Problem was that inline shape had at-page anchor.
1889 1 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
1890 1 : }
1891 :
1892 12 : DECLARE_RTFIMPORT_TEST(testFdo80742, "fdo80742.rtf")
1893 : {
1894 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("ParagraphStyles")->getByName("Heading 2"), uno::UNO_QUERY);
1895 : // This was 0, outline level was body text.
1896 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(xPropertySet, "OutlineLevel"));
1897 1 : }
1898 :
1899 12 : DECLARE_RTFIMPORT_TEST(testFdo82106, "fdo82106.rtf")
1900 : {
1901 : // Tab was missing after footnote not containing a tab.
1902 1 : getParagraph(2, "before\tafter");
1903 1 : }
1904 :
1905 12 : DECLARE_RTFIMPORT_TEST(testBehindDoc, "behind-doc.rtf")
1906 : {
1907 : // The problem was that "behind doc" didn't result in the shape being in the background, only in being wrapped as "through".
1908 1 : uno::Reference<drawing::XShape> xShape = getShape(1);
1909 1 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(xShape, "Surround"));
1910 : // This was true.
1911 1 : CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xShape, "Opaque"));
1912 1 : }
1913 :
1914 12 : DECLARE_RTFIMPORT_TEST(testFdo74229, "fdo74229.rtf")
1915 : {
1916 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1917 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1918 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1919 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1920 : // This was 0, due to ignoring RTF_TRGAPH.
1921 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(67)), getProperty<sal_Int32>(xCell, "RightBorderDistance"));
1922 1 : }
1923 :
1924 12 : DECLARE_RTFIMPORT_TEST(testFdo79959, "fdo79959.rtf")
1925 : {
1926 : // This was false, as the style was imported as " Test", i.e. no whitespace stripping.
1927 1 : CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(getStyles("ParagraphStyles")->hasByName("Test")));
1928 1 : }
1929 :
1930 12 : DECLARE_RTFIMPORT_TEST(testFdo82078, "fdo82078.rtf")
1931 : {
1932 : // This was awt::FontWeight::BOLD, i.e. the second run was bold, when it should be normal.
1933 1 : CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(getRun(getParagraph(1), 2), "CharWeight"));
1934 1 : }
1935 :
1936 12 : DECLARE_RTFIMPORT_TEST(testCsBold, "cs-bold.rtf")
1937 : {
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 1 : CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(getParagraph(1), 1), "CharWeight"));
1940 1 : }
1941 :
1942 12 : DECLARE_RTFIMPORT_TEST(testFdo82114, "fdo82114.rtf")
1943 : {
1944 1 : uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("Converted1"), "HeaderText");
1945 2 : OUString aActual = xHeaderText->getString();
1946 2 : OUString aExpected("First page header, section 2");
1947 : // This was 'Right page header, section 1'.
1948 2 : CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
1949 1 : }
1950 :
1951 12 : DECLARE_RTFIMPORT_TEST(testFdo44984, "fdo44984.rtf")
1952 : {
1953 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1954 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1955 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1956 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1957 : // This was Text, i.e. the checkbox field portion was missing.
1958 2 : CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStartEnd"), getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 1), "TextPortionType"));
1959 1 : }
1960 :
1961 12 : DECLARE_RTFIMPORT_TEST(testFdo84679, "fdo84679.rtf")
1962 : {
1963 : // The problem was that the paragraph in A1 had some bottom margin, but it should not.
1964 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1965 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1966 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1967 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1968 : // This was 282.
1969 2 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
1970 1 : }
1971 :
1972 12 : DECLARE_RTFIMPORT_TEST(testFdo82071, "fdo82071.rtf")
1973 : {
1974 : // The problem was that in TOC, chapter names were underlined, but they should not be.
1975 1 : uno::Reference<text::XTextRange> xRun = getRun(getParagraph(2), 1);
1976 : // Make sure we test the right text portion.
1977 1 : CPPUNIT_ASSERT_EQUAL(OUString("Chapter 1"), xRun->getString());
1978 : // This was awt::FontUnderline::SINGLE.
1979 1 : CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE, getProperty<sal_Int16>(xRun, "CharUnderline"));
1980 1 : }
1981 :
1982 12 : DECLARE_RTFIMPORT_TEST(testFdo83464, "fdo83464.rtf")
1983 : {
1984 : // Problem was that the text in the textfrme had wrong font.
1985 1 : uno::Reference<text::XTextRange> xFrameText(getShape(1), uno::UNO_QUERY);
1986 1 : CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xFrameText->getString());
1987 : // This was Times New Roman.
1988 1 : CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(getRun(getParagraphOfText(1, xFrameText->getText()), 1), "CharFontName"));
1989 1 : }
1990 :
1991 12 : DECLARE_RTFIMPORT_TEST(testFdo85179, "fdo85179.rtf")
1992 : {
1993 : // This was 0, border around the picture was ignored on import.
1994 : // 360: EMU -> MM100
1995 1 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(50800/360), getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineWidth);
1996 1 : }
1997 :
1998 12 : DECLARE_RTFIMPORT_TEST(testFdo86761, "fdo86761.rtf")
1999 : {
2000 : // This was 26, even if the picture should have no border, due to fLine=0.
2001 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineWidth);
2002 1 : }
2003 :
2004 12 : DECLARE_RTFIMPORT_TEST(testFdo82859, "fdo82859.rtf")
2005 : {
2006 : // This was 0: "0xffffff" was converted to 0, i.e. the background was black instead of the default.
2007 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), getProperty<sal_Int32>(getShape(1), "BackColor"));
2008 1 : }
2009 :
2010 12 : DECLARE_RTFIMPORT_TEST(testFdo82076, "fdo82076.rtf")
2011 : {
2012 : // Footnote position was wrong: should be at the end of the B1 cell.
2013 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
2014 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
2015 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
2016 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(OUString("Footnote"), getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 2), "TextPortionType"));
2019 1 : }
2020 :
2021 12 : DECLARE_RTFIMPORT_TEST(testFdo82512, "fdo82512.rtf")
2022 : {
2023 : // This was style::BreakType_NONE, column break was before the 3rd paragraph, not before the 2nd one.
2024 1 : CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
2025 1 : }
2026 :
2027 12 : DECLARE_RTFIMPORT_TEST(testUnbalancedColumns, "unbalanced-columns.rtf")
2028 : {
2029 1 : uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
2030 2 : 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 2 : CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
2033 1 : }
2034 :
2035 12 : DECLARE_RTFIMPORT_TEST(testFdo84685, "fdo84685.rtf")
2036 : {
2037 : // index mark was not imported
2038 : uno::Reference<text::XDocumentIndexMark> xMark(
2039 : getProperty<uno::Reference<text::XDocumentIndexMark>>(
2040 : getRun(getParagraph(1), 1),
2041 1 : "DocumentIndexMark"));
2042 1 : CPPUNIT_ASSERT(xMark.is());
2043 1 : 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 2 : "DocumentIndexMark"));
2049 1 : CPPUNIT_ASSERT(xTOCMark.is());
2050 2 : uno::Reference<lang::XServiceInfo> xTOCSI(xTOCMark, uno::UNO_QUERY);
2051 2 : CPPUNIT_ASSERT(xTOCSI->supportsService("com.sun.star.text.ContentIndexMark"));
2052 1 : }
2053 :
2054 12 : DECLARE_RTFIMPORT_TEST(testFdo83204, "fdo83204.rtf")
2055 : {
2056 : // This was Standard, \sN was ignored after \bkmkstart and \pard.
2057 1 : CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty<OUString>(getParagraph(1), "ParaStyleName"));
2058 1 : }
2059 :
2060 : // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
2061 12 : DECLARE_RTFIMPORT_TEST(testCp950listleveltext1, "cp950listleveltext1.rtf")
2062 : {
2063 : // suffix with Chinese only ( most common case generated by MSO2010 TC)
2064 1 : const sal_Unicode aExpectedSuffix[1] = { 0x3001 }; // This is a dot that is generally used as suffix of Chinese list number
2065 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY);
2066 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
2067 2 : uno::Sequence<beans::PropertyValue> aProps;
2068 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
2069 :
2070 2 : OUString aSuffix;
2071 13 : for (int i = 0; i < aProps.getLength(); ++i)
2072 : {
2073 12 : const beans::PropertyValue& rProp = aProps[i];
2074 :
2075 12 : if (rProp.Name == "Suffix")
2076 1 : aSuffix = rProp.Value.get<OUString>();
2077 : }
2078 : // Suffix was '\0' instead of ' '.
2079 2 : CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix,SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix);
2080 1 : }
2081 :
2082 : // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
2083 12 : DECLARE_RTFIMPORT_TEST(testCp950listleveltext2, "cp950listleveltext2.rtf")
2084 : {
2085 : // Prefix and suffix with Chinese only ( tweaked from default in MSO2010 TC)
2086 1 : const sal_Unicode aExpectedPrefix[2] = { 0x524d, 0x7f6e };
2087 1 : const sal_Unicode aExpectedSuffix[3] = { 0x3001, 0x5f8c, 0x7f6e };
2088 :
2089 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
2090 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
2091 2 : uno::Sequence<beans::PropertyValue> aProps;
2092 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
2093 :
2094 2 : OUString aSuffix,aPrefix;
2095 13 : for (int i = 0; i < aProps.getLength(); ++i)
2096 : {
2097 12 : const beans::PropertyValue& rProp = aProps[i];
2098 :
2099 12 : if (rProp.Name == "Suffix")
2100 1 : aSuffix = rProp.Value.get<OUString>();
2101 12 : if (rProp.Name == "Prefix")
2102 1 : aPrefix = rProp.Value.get<OUString>();
2103 : }
2104 : // Suffix was '\0' instead of ' '.
2105 1 : CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix,SAL_N_ELEMENTS(aExpectedPrefix)), aPrefix);
2106 2 : CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix,SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix);
2107 1 : }
2108 :
2109 :
2110 : // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 )
2111 12 : DECLARE_RTFIMPORT_TEST(testCp950listleveltext3, "cp950listleveltext3.rtf")
2112 : {
2113 : // Prefix and suffix that mix Chinese and English ( tweaked from default in MSO2010 TC)
2114 1 : const sal_Unicode aExpectedPrefix[4] = { 0x524d, 0x0061, 0x7f6e, 0x0062 };
2115 1 : const sal_Unicode aExpectedSuffix[6] = { 0x3001, 0x0063, 0x5f8c, 0x0064, 0x7f6e, 0x0065 };
2116 :
2117 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
2118 2 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
2119 2 : uno::Sequence<beans::PropertyValue> aProps;
2120 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
2121 :
2122 2 : OUString aSuffix,aPrefix;
2123 13 : for (int i = 0; i < aProps.getLength(); ++i)
2124 : {
2125 12 : const beans::PropertyValue& rProp = aProps[i];
2126 :
2127 12 : if (rProp.Name == "Suffix")
2128 1 : aSuffix = rProp.Value.get<OUString>();
2129 12 : if (rProp.Name == "Prefix")
2130 1 : aPrefix = rProp.Value.get<OUString>();
2131 : }
2132 : // Suffix was '\0' instead of ' '.
2133 1 : CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix,SAL_N_ELEMENTS(aExpectedPrefix)), aPrefix);
2134 2 : CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix,SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix);
2135 1 : }
2136 :
2137 12 : DECLARE_RTFIMPORT_TEST(testChtOutlineNumberingRtf, "chtoutline.rtf")
2138 : {
2139 1 : const sal_Unicode aExpectedPrefix[2] = { 0x7b2c, 0x0020 };
2140 1 : const sal_Unicode aExpectedSuffix[2] = { 0x0020, 0x7ae0 };
2141 1 : uno::Reference< text::XChapterNumberingSupplier > xChapterNumberingSupplier(mxComponent, uno::UNO_QUERY);
2142 2 : uno::Reference< container::XIndexAccess> xLevels(xChapterNumberingSupplier->getChapterNumberingRules());
2143 2 : uno::Sequence<beans::PropertyValue> aProps;
2144 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
2145 :
2146 2 : OUString aSuffix,aPrefix;
2147 14 : for (int i = 0; i < aProps.getLength(); ++i)
2148 : {
2149 13 : const beans::PropertyValue& rProp = aProps[i];
2150 :
2151 13 : if (rProp.Name == "Suffix")
2152 1 : aSuffix = rProp.Value.get<OUString>();
2153 13 : if (rProp.Name == "Prefix")
2154 1 : aPrefix = rProp.Value.get<OUString>();
2155 : }
2156 1 : CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix,SAL_N_ELEMENTS(aExpectedPrefix)), aPrefix);
2157 2 : CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix,SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix);
2158 1 : }
2159 :
2160 12 : DECLARE_RTFIMPORT_TEST(testFdo85889pc, "fdo85889-pc.rtf")
2161 : {
2162 1 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
2163 :
2164 2 : OUString aExpected("\xc2\xb1\xe2\x89\xa5\xe2\x89\xa4", 8, RTL_TEXTENCODING_UTF8);
2165 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
2166 1 : }
2167 :
2168 12 : DECLARE_RTFIMPORT_TEST(testFdo85889pca, "fdo85889-pca.rtf")
2169 : {
2170 1 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
2171 :
2172 2 : OUString aExpected("\xc2\xb1\xe2\x80\x97\xc2\xbe", 7, RTL_TEXTENCODING_UTF8);
2173 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
2174 1 : }
2175 :
2176 12 : DECLARE_RTFIMPORT_TEST(testFdo85889mac, "fdo85889-mac.rtf")
2177 : {
2178 1 : uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
2179 :
2180 2 : OUString aExpected("\xc3\x92\xc3\x9a\xc3\x9b", 6, RTL_TEXTENCODING_UTF8);
2181 2 : CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
2182 1 : }
2183 :
2184 12 : DECLARE_RTFIMPORT_TEST(testFdo72031, "fdo72031.rtf")
2185 : {
2186 1 : OUString aExpected("\xc3\x85", 2, RTL_TEXTENCODING_UTF8);
2187 1 : CPPUNIT_ASSERT_EQUAL(aExpected, getRun(getParagraph(1), 1)->getString());
2188 1 : }
2189 :
2190 12 : DECLARE_RTFIMPORT_TEST(testFdo86750, "fdo86750.rtf")
2191 : {
2192 : // This was 'HYPERLINK#anchor', the URL of the hyperlink had the field type as a prefix, leading to broken links.
2193 1 : CPPUNIT_ASSERT_EQUAL(OUString("#anchor"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL"));
2194 1 : }
2195 :
2196 12 : DECLARE_RTFIMPORT_TEST(testTdf88811, "tdf88811.rtf")
2197 : {
2198 : // The problem was that shapes anchored to the paragraph that is moved into a textframe were lost, so this was 2.
2199 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
2200 2 : uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
2201 2 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xDrawPage->getCount());
2202 1 : }
2203 :
2204 12 : DECLARE_RTFIMPORT_TEST(testFdo49893, "fdo49893.rtf")
2205 : {
2206 : // Image from shape was not loaded, invalid size of image after load
2207 1 : uno::Reference<drawing::XShape> xShape(getShape(2), uno::UNO_QUERY);
2208 1 : CPPUNIT_ASSERT(xShape.is());
2209 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(432)), xShape->getSize().Height);
2210 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(1296)), xShape->getSize().Width);
2211 1 : }
2212 :
2213 12 : DECLARE_RTFIMPORT_TEST(testFdo49893_2, "fdo49893-2.rtf")
2214 : {
2215 : // Ensure that header text exists on each page (especially on second page)
2216 1 : CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[1]/header/txt/text()"));
2217 1 : CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[2]/header/txt/text()"));
2218 1 : CPPUNIT_ASSERT_EQUAL(OUString("HEADER"), parseDump("/root/page[3]/header/txt/text()"));
2219 1 : }
2220 :
2221 12 : DECLARE_RTFIMPORT_TEST(testFdo89496, "fdo89496.rtf")
2222 : {
2223 : // Just ensure that document is loaded and shape exists
2224 1 : uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
2225 1 : CPPUNIT_ASSERT(xShape.is());
2226 1 : }
2227 :
2228 12 : DECLARE_RTFIMPORT_TEST(testFdo75614, "tdf75614.rtf")
2229 : {
2230 : // Text after the footnote was missing, so this resulted in a css::container::NoSuchElementException.
2231 1 : CPPUNIT_ASSERT_EQUAL(OUString("after."), getRun(getParagraph(1), 3)->getString());
2232 1 : }
2233 :
2234 12 : DECLARE_RTFIMPORT_TEST(mathtype, "mathtype.rtf")
2235 : {
2236 1 : OUString aFormula = getFormula(getRun(getParagraph(1), 1));
2237 1 : CPPUNIT_ASSERT(!aFormula.isEmpty());
2238 1 : }
2239 :
2240 12 : DECLARE_RTFIMPORT_TEST(testTdf86182, "tdf86182.rtf")
2241 : {
2242 : // Writing mode was the default, i.e. text::WritingMode2::CONTEXT.
2243 1 : CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>(getParagraph(1), "WritingMode"));
2244 1 : }
2245 :
2246 12 : DECLARE_RTFIMPORT_TEST(testWrapDistance, "wrap-distance.rtf")
2247 : {
2248 : // Custom shape, handled directly in RTFSdrImport.
2249 1 : uno::Reference<drawing::XShape> xShape = getShape(1);
2250 1 : CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), xShape->getShapeType());
2251 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), getProperty<sal_Int32>(xShape, "TopMargin") / 1000);
2252 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), getProperty<sal_Int32>(xShape, "BottomMargin") / 1000);
2253 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), getProperty<sal_Int32>(xShape, "LeftMargin") / 1000);
2254 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), getProperty<sal_Int32>(xShape, "RightMargin") / 1000);
2255 :
2256 : // Picture, handled in GraphicImport, shared with DOCX.
2257 1 : xShape = getShape(2);
2258 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), getProperty<sal_Int32>(xShape, "TopMargin") / 1000);
2259 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), getProperty<sal_Int32>(xShape, "BottomMargin") / 1000);
2260 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), getProperty<sal_Int32>(xShape, "LeftMargin") / 1000);
2261 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), getProperty<sal_Int32>(xShape, "RightMargin") / 1000);
2262 1 : }
2263 :
2264 12 : DECLARE_RTFIMPORT_TEST(testTdf91074, "tdf91074.rtf")
2265 : {
2266 : // The file failed to load, as the border color was imported using the LineColor UNO property.
2267 1 : uno::Reference<drawing::XShape> xShape = getShape(1);
2268 1 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_LIGHTRED), getProperty<table::BorderLine2>(xShape, "TopBorder").Color);
2269 1 : }
2270 :
2271 12 : DECLARE_RTFIMPORT_TEST(testTdf90260Nopar, "hello.rtf")
2272 : {
2273 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
2274 2 : uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
2275 2 : uno::Reference<text::XTextRange> xEnd = xText->getEnd();
2276 1 : paste("tdf90260-nopar.rtf", xEnd);
2277 2 : CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
2278 1 : }
2279 :
2280 12 : DECLARE_RTFIMPORT_TEST(testTdf90260Par, "hello.rtf")
2281 : {
2282 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
2283 2 : uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
2284 2 : uno::Reference<text::XTextRange> xEnd = xText->getEnd();
2285 1 : paste("tdf90260-par.rtf", xEnd);
2286 2 : CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
2287 1 : }
2288 :
2289 12 : DECLARE_RTFIMPORT_TEST(testTdf86814, "tdf86814.rtf")
2290 : {
2291 : // This was awt::FontWeight::NORMAL, i.e. the first run wasn't bold, when it should be bold (applied paragraph style with direct formatting).
2292 1 : CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(getParagraph(1), 1), "CharWeight"));
2293 1 : }
2294 :
2295 12 : DECLARE_RTFIMPORT_TEST(testTdf90315, "tdf90315.rtf")
2296 : {
2297 1 : uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
2298 2 : uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
2299 2 : uno::Reference<beans::XPropertySet> xTextSection(xTextSections->getByIndex(0), uno::UNO_QUERY);
2300 : // This was 0, but default should be 720 twips.
2301 2 : CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), getProperty<sal_Int32>(xTextSection->getPropertyValue("TextColumns"), "AutomaticDistance"));
2302 1 : }
2303 :
2304 4 : CPPUNIT_PLUGIN_IMPLEMENT();
2305 :
2306 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|