Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / extras / rtfexport / rtfexport4.cxx
blob56ff343487ef59ed881d716aedecebcb5d7c0591
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <swmodeltestbase.hxx>
12 #include <com/sun/star/awt/FontSlant.hpp>
13 #include <com/sun/star/table/ShadowFormat.hpp>
14 #include <com/sun/star/text/WritingMode2.hpp>
15 #include <com/sun/star/text/XDocumentIndex.hpp>
16 #include <com/sun/star/style/ParagraphAdjust.hpp>
17 #include <com/sun/star/style/TabStop.hpp>
18 #include <com/sun/star/text/VertOrientation.hpp>
19 #include <com/sun/star/text/XTextTable.hpp>
20 #include <o3tl/cppunittraitshelper.hxx>
22 #include <xmloff/odffields.hxx>
24 #include <docsh.hxx>
25 #include <unotxdoc.hxx>
26 #include <pam.hxx>
27 #include <fmtanchr.hxx>
28 #include <frameformats.hxx>
29 #include <formatlinebreak.hxx>
30 #include <wrtsh.hxx>
32 using namespace css;
34 /**
35 Split these tests into their own file because they are really really slow
38 class Test : public SwModelTestBase
40 public:
41 Test()
42 : SwModelTestBase("/sw/qa/extras/rtfexport/data/", "Rich Text Format")
47 DECLARE_RTFEXPORT_TEST(testCjklist12, "cjklist12.rtf")
49 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
50 CPPUNIT_ASSERT_EQUAL(style::NumberingType::AIU_HALFWIDTH_JA, numFormat);
53 DECLARE_RTFEXPORT_TEST(testCjklist13, "cjklist13.rtf")
55 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
56 CPPUNIT_ASSERT_EQUAL(style::NumberingType::IROHA_HALFWIDTH_JA, numFormat);
59 DECLARE_RTFEXPORT_TEST(testCjklist16, "cjklist16.rtf")
61 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
62 CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_TRADITIONAL_JA, numFormat);
65 DECLARE_RTFEXPORT_TEST(testCjklist20, "cjklist20.rtf")
67 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
68 CPPUNIT_ASSERT_EQUAL(style::NumberingType::AIU_FULLWIDTH_JA, numFormat);
71 DECLARE_RTFEXPORT_TEST(testCjklist21, "cjklist21.rtf")
73 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
74 CPPUNIT_ASSERT_EQUAL(style::NumberingType::IROHA_FULLWIDTH_JA, numFormat);
77 DECLARE_RTFEXPORT_TEST(testCjklist24, "cjklist24.rtf")
79 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
80 CPPUNIT_ASSERT_EQUAL(style::NumberingType::HANGUL_SYLLABLE_KO, numFormat);
83 DECLARE_RTFEXPORT_TEST(testCjklist25, "cjklist25.rtf")
85 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
86 CPPUNIT_ASSERT_EQUAL(style::NumberingType::HANGUL_JAMO_KO, numFormat);
89 DECLARE_RTFEXPORT_TEST(testCjklist30, "cjklist30.rtf")
91 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
92 CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH, numFormat);
95 DECLARE_RTFEXPORT_TEST(testCjklist31, "cjklist31.rtf")
97 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
98 CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat);
101 DECLARE_RTFEXPORT_TEST(test148518, "FORMDROPDOWN.rtf")
103 SwXTextDocument* const pTextDoc(dynamic_cast<SwXTextDocument*>(mxComponent.get()));
104 CPPUNIT_ASSERT(pTextDoc);
105 SwDoc* const pDoc(pTextDoc->GetDocShell()->GetDoc());
107 CPPUNIT_ASSERT(pDoc->getIDocumentMarkAccess()->getFieldmarksBegin()
108 != pDoc->getIDocumentMarkAccess()->getFieldmarksEnd());
109 ::sw::mark::IFieldmark* pFieldmark = dynamic_cast<::sw::mark::IFieldmark*>(
110 *pDoc->getIDocumentMarkAccess()->getFieldmarksBegin());
111 uno::Sequence<OUString> entries;
112 (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_LISTENTRY] >>= entries;
113 uno::Sequence<OUString> const expected{ OUString("x"), OUString("v"), OUString("d") };
114 CPPUNIT_ASSERT_EQUAL(expected, entries);
115 sal_Int32 result(-1);
116 (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_RESULT] >>= result;
117 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), result);
120 DECLARE_RTFEXPORT_TEST(test150269, "hidden-linebreaks.rtf")
122 uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 1, u"\n\n\n");
123 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xRun, "CharHidden"));
126 DECLARE_RTFEXPORT_TEST(test129758, "tdf129631_lostBorders3.rtf")
128 uno::Reference<container::XNameAccess> xStyles(getStyles("ParagraphStyles"));
129 uno::Reference<beans::XPropertySet> xStyle(xStyles->getByName("Border"), uno::UNO_QUERY);
130 // style has borders
131 table::BorderLine2 border;
132 border = getProperty<table::BorderLine2>(xStyle, "RightBorder");
133 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
134 CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth);
135 border = getProperty<table::BorderLine2>(xStyle, "LeftBorder");
136 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
137 CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth);
138 border = getProperty<table::BorderLine2>(xStyle, "TopBorder");
139 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
140 CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth);
141 border = getProperty<table::BorderLine2>(xStyle, "BottomBorder");
142 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
143 CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth);
144 // style applied
145 uno::Reference<beans::XPropertySet> xPara2(getParagraph(2), uno::UNO_QUERY);
146 CPPUNIT_ASSERT_EQUAL(OUString("Border"), getProperty<OUString>(xPara2, "ParaStyleName"));
147 // but no borders
148 border = getProperty<table::BorderLine2>(xPara2, "RightBorder");
149 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle);
150 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth);
151 border = getProperty<table::BorderLine2>(xPara2, "LeftBorder");
152 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle);
153 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth);
154 border = getProperty<table::BorderLine2>(xPara2, "TopBorder");
155 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle);
156 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth);
157 border = getProperty<table::BorderLine2>(xPara2, "BottomBorder");
158 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle);
159 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth);
160 // last paragraph: style applied, no override
161 uno::Reference<beans::XPropertySet> xPara4(getParagraph(4), uno::UNO_QUERY);
162 CPPUNIT_ASSERT_EQUAL(OUString("Border"), getProperty<OUString>(xPara4, "ParaStyleName"));
163 border = getProperty<table::BorderLine2>(xPara4, "RightBorder");
164 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
165 CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth);
166 border = getProperty<table::BorderLine2>(xPara4, "LeftBorder");
167 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
168 CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth);
169 border = getProperty<table::BorderLine2>(xPara4, "TopBorder");
170 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
171 CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth);
172 border = getProperty<table::BorderLine2>(xPara4, "BottomBorder");
173 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
174 CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth);
177 DECLARE_RTFEXPORT_TEST(test150382, "para-border.rtf")
179 uno::Reference<container::XNameAccess> xStyles(getStyles("ParagraphStyles"));
180 uno::Reference<beans::XPropertySet> xStyle(xStyles->getByName("Normal,Bordered"),
181 uno::UNO_QUERY);
182 // style has borders
183 table::BorderLine2 border;
184 border = getProperty<table::BorderLine2>(xStyle, "RightBorder");
185 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
186 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth);
187 CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color);
188 border = getProperty<table::BorderLine2>(xStyle, "LeftBorder");
189 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
190 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth);
191 CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color);
192 border = getProperty<table::BorderLine2>(xStyle, "TopBorder");
193 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
194 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth);
195 CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color);
196 border = getProperty<table::BorderLine2>(xStyle, "BottomBorder");
197 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
198 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth);
199 CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color);
200 // first paragraph: style applied, no override
201 uno::Reference<beans::XPropertySet> xPara1(getParagraph(1), uno::UNO_QUERY);
202 CPPUNIT_ASSERT_EQUAL(OUString("Normal,Bordered"),
203 getProperty<OUString>(xPara1, "ParaStyleName"));
204 border = getProperty<table::BorderLine2>(xPara1, "RightBorder");
205 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
206 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth);
207 CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color);
208 border = getProperty<table::BorderLine2>(xPara1, "LeftBorder");
209 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
210 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth);
211 CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color);
212 border = getProperty<table::BorderLine2>(xPara1, "TopBorder");
213 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
214 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth);
215 CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color);
216 border = getProperty<table::BorderLine2>(xPara1, "BottomBorder");
217 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle);
218 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth);
219 CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color);
220 // second paragraph: style applied
221 uno::Reference<beans::XPropertySet> xPara2(getParagraph(2), uno::UNO_QUERY);
222 CPPUNIT_ASSERT_EQUAL(OUString("Normal,Bordered"),
223 getProperty<OUString>(xPara2, "ParaStyleName"));
224 // but no borders
225 border = getProperty<table::BorderLine2>(xPara2, "RightBorder");
226 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle);
227 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth);
228 border = getProperty<table::BorderLine2>(xPara2, "LeftBorder");
229 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle);
230 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth);
231 border = getProperty<table::BorderLine2>(xPara2, "TopBorder");
232 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle);
233 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth);
234 border = getProperty<table::BorderLine2>(xPara2, "BottomBorder");
235 CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle);
236 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth);
239 DECLARE_RTFEXPORT_TEST(testAnchoredAtSamePosition, "anchor.fodt")
241 SwXTextDocument* const pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
242 SwDoc* const pDoc = pTextDoc->GetDocShell()->GetDoc();
244 CPPUNIT_ASSERT_EQUAL(OUString("foobar"), getParagraph(1)->getString());
246 auto& rFlys = *pDoc->GetSpzFrameFormats();
247 if (isExported())
248 { // 2, not 3: the form control becomes a field on export...
249 CPPUNIT_ASSERT_EQUAL(size_t(2), rFlys.size());
251 else
253 CPPUNIT_ASSERT_EQUAL(size_t(3), rFlys.size());
256 sal_Int32 const nIndex(isExported() ? 4 : 3);
257 CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_CHAR, rFlys[0]->GetAnchor().GetAnchorId());
258 CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12), rFlys[0]->GetAnchor().GetAnchorNode()->GetIndex());
259 CPPUNIT_ASSERT_EQUAL(nIndex, rFlys[0]->GetAnchor().GetAnchorContentOffset());
260 CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_CHAR, rFlys[1]->GetAnchor().GetAnchorId());
261 CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12), rFlys[1]->GetAnchor().GetAnchorNode()->GetIndex());
262 CPPUNIT_ASSERT_EQUAL(nIndex, rFlys[1]->GetAnchor().GetAnchorContentOffset());
265 DECLARE_RTFEXPORT_TEST(testRedlineInsdel, "redline-insdel.rtf")
267 uno::Reference<text::XTextRange> xParagraph = getParagraph(1);
269 uno::Reference<text::XTextRange> xRun = getRun(xParagraph, 1);
270 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(xRun, "TextPortionType"));
271 CPPUNIT_ASSERT_EQUAL(OUString("aaa"), xRun->getString());
273 xRun = getRun(xParagraph, 2);
274 CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty<OUString>(xRun, "TextPortionType"));
275 CPPUNIT_ASSERT_EQUAL(OUString("Delete"), getProperty<OUString>(xRun, "RedlineType"));
276 xRun = getRun(xParagraph, 3);
277 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(xRun, "TextPortionType"));
278 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xRun->getString());
279 xRun = getRun(xParagraph, 4);
280 CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty<OUString>(xRun, "TextPortionType"));
281 CPPUNIT_ASSERT_EQUAL(OUString("Delete"), getProperty<OUString>(xRun, "RedlineType"));
283 xRun = getRun(xParagraph, 5);
284 CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty<OUString>(xRun, "TextPortionType"));
285 CPPUNIT_ASSERT_EQUAL(OUString("Insert"), getProperty<OUString>(xRun, "RedlineType"));
286 xRun = getRun(xParagraph, 6);
287 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(xRun, "TextPortionType"));
288 CPPUNIT_ASSERT_EQUAL(OUString("BBB"), xRun->getString());
289 xRun = getRun(xParagraph, 7);
290 CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty<OUString>(xRun, "TextPortionType"));
291 CPPUNIT_ASSERT_EQUAL(OUString("Insert"), getProperty<OUString>(xRun, "RedlineType"));
293 xRun = getRun(xParagraph, 8);
294 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(xRun, "TextPortionType"));
295 CPPUNIT_ASSERT_EQUAL(OUString("ccc"), xRun->getString());
298 DECLARE_RTFEXPORT_TEST(testParaAdjustDistribute, "para-adjust-distribute.rtf")
300 // Without the accompanying fix in place, this test would have failed with
301 // 'Expected: 2; Actual : 0', i.e. the first paragraph's ParaAdjust was
302 // left, not block.
303 CPPUNIT_ASSERT_EQUAL(
304 style::ParagraphAdjust_BLOCK,
305 static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
306 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_BLOCK,
307 static_cast<style::ParagraphAdjust>(
308 getProperty<sal_Int16>(getParagraph(1), "ParaLastLineAdjust")));
310 CPPUNIT_ASSERT_EQUAL(
311 style::ParagraphAdjust_BLOCK,
312 static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(2), "ParaAdjust")));
313 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT,
314 static_cast<style::ParagraphAdjust>(
315 getProperty<sal_Int16>(getParagraph(2), "ParaLastLineAdjust")));
318 DECLARE_RTFEXPORT_TEST(testTdf129574, "mw00_table_of_contents_templates.doc")
320 uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
321 uno::Reference<container::XIndexAccess> xIndexes(xIndexSupplier->getDocumentIndexes());
322 uno::Reference<text::XDocumentIndex> xTOC(xIndexes->getByIndex(0), uno::UNO_QUERY);
323 CPPUNIT_ASSERT(xTOC.is());
324 uno::Reference<text::XTextRange> xTextRange(xTOC->getAnchor());
325 // table of contents contains 4 paragraphs
326 CPPUNIT_ASSERT_EQUAL(OUString("1.Koffice 1" SAL_NEWLINE_STRING "2.Kword 1" SAL_NEWLINE_STRING
327 "3.Kspread 1" SAL_NEWLINE_STRING "4.Kpresenter 1"),
328 xTextRange->getString());
331 DECLARE_RTFEXPORT_TEST(testCjklist34, "cjklist34.rtf")
333 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
334 CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW, numFormat);
337 CPPUNIT_TEST_FIXTURE(Test, testTabStopFillChars)
339 createSwDoc("tab-stop-fill-chars.rtf");
340 // tlmdot
341 auto aTabstops = getProperty<uno::Sequence<style::TabStop>>(getParagraph(1), "ParaTabStops");
342 CPPUNIT_ASSERT(aTabstops.hasElements());
343 CPPUNIT_ASSERT_EQUAL(u'·', aTabstops[0].FillChar);
345 // tlhyph
346 aTabstops = getProperty<uno::Sequence<style::TabStop>>(getParagraph(2), "ParaTabStops");
347 CPPUNIT_ASSERT(aTabstops.hasElements());
348 CPPUNIT_ASSERT_EQUAL(u'-', aTabstops[0].FillChar);
350 // tlth
351 aTabstops = getProperty<uno::Sequence<style::TabStop>>(getParagraph(3), "ParaTabStops");
352 CPPUNIT_ASSERT(aTabstops.hasElements());
353 CPPUNIT_ASSERT_EQUAL(u'_', aTabstops[0].FillChar);
355 // tleq
356 aTabstops = getProperty<uno::Sequence<style::TabStop>>(getParagraph(4), "ParaTabStops");
357 CPPUNIT_ASSERT(aTabstops.hasElements());
358 CPPUNIT_ASSERT_EQUAL(u' ', aTabstops[0].FillChar);
361 DECLARE_RTFEXPORT_TEST(testTdf146489, "tdf146489.rtf")
363 uno::Reference<text::XTextRange> xPara = getParagraph(2, "unnumbered");
364 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
367 DECLARE_RTFEXPORT_TEST(testCjklist38, "cjklist38.rtf")
369 sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
370 CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH, numFormat);
373 DECLARE_RTFEXPORT_TEST(testBtlrCell, "btlr-cell.rtf")
375 // Without the accompanying fix in place, this test would have failed, as
376 // the btlr text direction in the A1 cell was lost.
377 uno::Reference<text::XTextTablesSupplier> xSupplier(mxComponent, uno::UNO_QUERY);
378 uno::Reference<container::XNameAccess> xTables = xSupplier->getTextTables();
379 uno::Reference<text::XTextTable> xTable(xTables->getByName("Table1"), uno::UNO_QUERY);
380 uno::Reference<beans::XPropertySet> xA1(xTable->getCellByName("A1"), uno::UNO_QUERY);
381 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, getProperty<sal_Int16>(xA1, "WritingMode"));
383 uno::Reference<beans::XPropertySet> xB1(xTable->getCellByName("B1"), uno::UNO_QUERY);
384 auto nActual = getProperty<sal_Int16>(xB1, "WritingMode");
385 CPPUNIT_ASSERT(nActual == text::WritingMode2::LR_TB || nActual == text::WritingMode2::CONTEXT);
387 uno::Reference<beans::XPropertySet> xC1(xTable->getCellByName("C1"), uno::UNO_QUERY);
388 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty<sal_Int16>(xC1, "WritingMode"));
391 DECLARE_RTFEXPORT_TEST(testTdf114303, "tdf114303.rtf")
393 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::NONE,
394 getProperty<sal_Int16>(getShape(1), "HoriOrient"));
396 // Without the fix in place, this test would have failed with
397 // - Expected: 0
398 // - Actual : 1
399 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::NONE,
400 getProperty<sal_Int16>(getShape(1), "VertOrient"));
403 DECLARE_RTFEXPORT_TEST(testTbrlFrame, "tbrl-frame.odt")
405 CPPUNIT_ASSERT_EQUAL(1, getShapes());
406 CPPUNIT_ASSERT_EQUAL(1, getPages());
407 uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY);
408 auto nActual = getProperty<sal_Int16>(xShape, "WritingMode");
409 // Without the accompanying fix in place, this test would have failed with:
410 // - Expected: 2
411 // - Actual : 0
412 // i.e. custom writing mode was lost.
413 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, nActual);
416 DECLARE_RTFEXPORT_TEST(testBtlrFrame, "btlr-frame.odt")
418 CPPUNIT_ASSERT_EQUAL(1, getShapes());
419 CPPUNIT_ASSERT_EQUAL(1, getPages());
420 uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY);
421 auto nActual = getProperty<sal_Int16>(xShape, "WritingMode");
422 // Without the accompanying fix in place, this test would have failed with:
423 // - Expected: 5
424 // - Actual : 0
425 // i.e. custom writing mode was lost.
426 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, nActual);
429 DECLARE_RTFEXPORT_TEST(testTdf129578_lostBI, "tdf129578_lostBI.rtf")
431 CPPUNIT_ASSERT_EQUAL(150.f, getProperty<float>(getRun(getParagraph(1), 1), "CharWeightAsian"));
432 CPPUNIT_ASSERT_EQUAL(
433 awt::FontSlant_ITALIC,
434 getProperty<awt::FontSlant>(getRun(getParagraph(2), 1), "CharPostureAsian"));
437 DECLARE_RTFEXPORT_TEST(testTdf129631_lostBorders, "tdf129631_lostBorders.rtf")
439 uno::Reference<container::XNameAccess> paragraphStyles = getStyles("ParagraphStyles");
440 uno::Reference<beans::XPropertySet> xStyleProps(paragraphStyles->getByName("Border"),
441 uno::UNO_QUERY_THROW);
442 table::BorderLine2 aBorderLine = getProperty<table::BorderLine2>(xStyleProps, "RightBorder");
443 CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth);
444 CPPUNIT_ASSERT_EQUAL_MESSAGE(
445 "The border style has normal black borders", COL_BLACK,
446 Color(ColorTransparency, getProperty<table::BorderLine>(xStyleProps, "RightBorder").Color));
448 aBorderLine = getProperty<table::BorderLine2>(getParagraph(2), "RightBorder");
449 CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth);
450 CPPUNIT_ASSERT_EQUAL_MESSAGE(
451 "The second paragraph should have dark green borders", sal_Int32(432686),
452 getProperty<table::BorderLine>(getParagraph(2), "RightBorder").Color);
455 DECLARE_RTFEXPORT_TEST(testTdf129522_removeShadowStyle, "tdf129522_removeShadowStyle.odt")
457 CPPUNIT_ASSERT_EQUAL(1, getPages());
458 uno::Reference<container::XNameAccess> paragraphStyles = getStyles("ParagraphStyles");
459 uno::Reference<beans::XPropertySet> xStyleProps(paragraphStyles->getByName("Shadow"),
460 uno::UNO_QUERY_THROW);
461 table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xStyleProps, "ParaShadowFormat");
462 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
464 // Shadows were inherited regardless of whether the style disabled them.
465 xStyleProps.set(paragraphStyles->getByName("Shadow-removed"), uno::UNO_QUERY_THROW);
466 aShadow = getProperty<table::ShadowFormat>(xStyleProps, "ParaShadowFormat");
467 //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
469 uno::Reference<container::XNameAccess> characterStyles = getStyles("CharacterStyles");
470 xStyleProps.set(characterStyles->getByName("CharShadow"), uno::UNO_QUERY_THROW);
471 aShadow = getProperty<table::ShadowFormat>(xStyleProps, "CharShadowFormat");
472 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
474 xStyleProps.set(characterStyles->getByName("CharShadow-removed"), uno::UNO_QUERY_THROW);
475 aShadow = getProperty<table::ShadowFormat>(xStyleProps, "CharShadowFormat");
476 //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
478 uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 2, "style");
479 aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
480 //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
482 xRun.set(getRun(getParagraph(1), 4, "shadow"));
483 aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
484 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
485 table::BorderLine2 aBorderLine = getProperty<table::BorderLine2>(xRun, "CharRightBorder");
486 // MS formats can't have a shadow without a border.
487 // Char borders are all or none, so have to decide to add borders, or throw away shadow...
488 if (isExported())
489 CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth);
491 xRun.set(getRun(getParagraph(4), 2, "shadow"));
492 aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
493 //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
495 xRun.set(getRun(getParagraph(9), 2, "End of test"));
496 aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
497 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
498 aBorderLine = getProperty<table::BorderLine2>(xRun, "CharRightBorder");
499 CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth);
502 DECLARE_RTFEXPORT_TEST(testTdf136587_noStyleName, "tdf136587_noStyleName.rtf")
504 // An exception stopped all style definitions.
505 uno::Reference<container::XNameAccess> paragraphStyles = getStyles("ParagraphStyles");
506 uno::Reference<beans::XPropertySet> xStyleProps(paragraphStyles->getByName("Style15"),
507 uno::UNO_QUERY_THROW);
508 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER),
509 getProperty<sal_Int16>(xStyleProps, "ParaAdjust"));
511 // The problem was that the default style wasn't imported at all, so the fontsize was only 12.
512 xStyleProps.set(paragraphStyles->getByName("Default Paragraph Style"), uno::UNO_QUERY_THROW);
513 CPPUNIT_ASSERT_EQUAL(32.0f, getProperty<float>(xStyleProps, "CharHeight"));
516 CPPUNIT_TEST_FIXTURE(Test, testPageBorder)
518 createSwDoc("page-border.rtf");
519 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"),
520 uno::UNO_QUERY);
521 auto aTopBorder = getProperty<table::BorderLine2>(xPageStyle, "TopBorder");
522 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(18), aTopBorder.LineWidth);
524 auto aLeftBorder = getProperty<table::BorderLine2>(xPageStyle, "LeftBorder");
525 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(35), aLeftBorder.LineWidth);
527 auto aBottomBorder = getProperty<table::BorderLine2>(xPageStyle, "BottomBorder");
528 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(53), aBottomBorder.LineWidth);
530 auto aRightBorder = getProperty<table::BorderLine2>(xPageStyle, "RightBorder");
531 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(71), aRightBorder.LineWidth);
534 DECLARE_RTFEXPORT_TEST(testTbrlPage, "tbrl-page.rtf")
536 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"),
537 uno::UNO_QUERY);
538 auto nActual = getProperty<sal_Int16>(xPageStyle, "WritingMode");
539 // Without the accompanying fix in place, this test would have failed with:
540 // - Expected: 2
541 // - Actual : 0
542 // i.e. custom writing mode was lost.
543 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, nActual);
546 CPPUNIT_TEST_FIXTURE(Test, testTdf126309)
548 createSwDoc("tdf126309.rtf");
549 // Without the accompanying fix in place, this test would have failed, as
550 // the paragraph was aligned to left, not right.
551 CPPUNIT_ASSERT_EQUAL(
552 style::ParagraphAdjust_RIGHT,
553 static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
556 DECLARE_RTFEXPORT_TEST(testTdf116358, "tdf116358.rtf")
558 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
559 CPPUNIT_ASSERT(pTextDoc);
560 SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
561 CPPUNIT_ASSERT(pWrtShell);
563 // Insert a paragraph break
564 pWrtShell->SplitNode(false);
566 // Entire table should go to page 2, no remains on first page
567 xmlDocUniquePtr pDump = parseLayoutDump();
568 assertXPath(pDump, "/root/page[1]/body/tab", 0);
569 assertXPath(pDump, "/root/page[2]/body/tab", 1);
572 CPPUNIT_TEST_FIXTURE(Test, testGutterLeft)
574 createSwDoc("gutter-left.rtf");
575 saveAndReload("Rich Text Format");
576 uno::Reference<beans::XPropertySet> xPageStyle;
577 getStyles("PageStyles")->getByName("Standard") >>= xPageStyle;
578 sal_Int32 nGutterMargin{};
579 xPageStyle->getPropertyValue("GutterMargin") >>= nGutterMargin;
580 // Without the accompanying fix in place, this test would have failed with:
581 // - Expected: 1270
582 // - Actual : 0
583 // i.e. gutter margin was lost.
584 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), nGutterMargin);
587 CPPUNIT_TEST_FIXTURE(Test, testGutterTop)
589 createSwDoc("gutter-top.rtf");
590 saveAndReload("Rich Text Format");
591 uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
592 uno::Reference<beans::XPropertySet> xSettings(
593 xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
594 bool bGutterAtTop{};
595 xSettings->getPropertyValue("GutterAtTop") >>= bGutterAtTop;
596 // Without the accompanying fix in place, this test would have failed, because the gutter was
597 // at the left.
598 CPPUNIT_ASSERT(bGutterAtTop);
601 CPPUNIT_TEST_FIXTURE(Test, testClearingBreak)
603 auto verify = [this]() {
604 uno::Reference<container::XEnumerationAccess> xParagraph(getParagraph(1), uno::UNO_QUERY);
605 uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration();
606 xPortions->nextElement();
607 xPortions->nextElement();
608 // Without the accompanying fix in place, this test would have failed with:
609 // An uncaught exception of type com.sun.star.container.NoSuchElementException
610 // i.e. the first para was just a fly + text portion, the clearing break was lost.
611 uno::Reference<beans::XPropertySet> xPortion(xPortions->nextElement(), uno::UNO_QUERY);
612 OUString aPortionType;
613 xPortion->getPropertyValue("TextPortionType") >>= aPortionType;
614 CPPUNIT_ASSERT_EQUAL(OUString("LineBreak"), aPortionType);
615 uno::Reference<text::XTextContent> xLineBreak;
616 xPortion->getPropertyValue("LineBreak") >>= xLineBreak;
617 sal_Int16 eClear{};
618 uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY);
619 xLineBreakProps->getPropertyValue("Clear") >>= eClear;
620 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(SwLineBreakClear::ALL), eClear);
623 // Given a document with a clearing break:
624 // When loading that file:
625 createSwDoc("clearing-break.rtf");
626 // Then make sure that the clear property of the break is not ignored:
627 verify();
628 saveAndReload("Rich Text Format");
629 // Make sure that the clear property of the break is not ignored during export:
630 verify();
633 DECLARE_RTFEXPORT_TEST(testTdf95706, "tdf95706.rtf")
635 uno::Reference<text::XTextRange> xRun2
636 = getRun(getParagraph(2), 1, u"\u0104\u012e\u0100\u0106\u00c4");
637 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun2, "CharFontName"));
639 uno::Reference<text::XTextRange> xRun3
640 = getRun(getParagraph(3), 1, u"\u0154\u00c1\u00c2\u0102\u00c4");
641 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun3, "CharFontName"));
643 uno::Reference<text::XTextRange> xRun4
644 = getRun(getParagraph(4), 1, u"\u0410\u0411\u0412\u0413\u0414");
645 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun4, "CharFontName"));
647 uno::Reference<text::XTextRange> xRun5
648 = getRun(getParagraph(5), 1, u"\u0390\u0391\u0392\u0393\u0394");
649 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun5, "CharFontName"));
651 uno::Reference<text::XTextRange> xRun6
652 = getRun(getParagraph(6), 1, u"\u00c0\u00c1\u00c2\u00c3\u00c4");
653 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun6, "CharFontName"));
655 uno::Reference<text::XTextRange> xRun7
656 = getRun(getParagraph(7), 1, u"\u05b0\u05b1\u05b2\u05b3\u05b4");
657 // Do not check font for Hebrew: it can be substituted by smth able to handle these chars
658 //CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun7, "CharFontName"));
660 uno::Reference<text::XTextRange> xRun8
661 = getRun(getParagraph(8), 1, u"\u06c1\u0621\u0622\u0623\u0624");
662 // Do not check font for Arabic: it can be substituted by smth able to handle these chars
663 //CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun8, "CharFontName"));
665 uno::Reference<text::XTextRange> xRun9
666 = getRun(getParagraph(9), 1, u"\u00c0\u00c1\u00c2\u0102\u00c4");
667 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun9, "CharFontName"));
669 // Ensure strange font remains strange. No reason to check content: in this case it can vary on locale
670 uno::Reference<text::XTextRange> xRun10 = getRun(getParagraph(10), 1);
671 CPPUNIT_ASSERT_EQUAL(OUString("Arial BlaBlaBla"),
672 getProperty<OUString>(xRun10, "CharFontName"));
674 uno::Reference<text::XTextRange> xRun12
675 = getRun(getParagraph(12), 1, u"\u0390\u0391\u0392\u0393\u0394");
676 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun12, "CharFontName"));
678 uno::Reference<text::XTextRange> xRun13
679 = getRun(getParagraph(13), 1, u"\u0390\u0391\u0392\u0393\u0394");
680 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun13, "CharFontName"));
682 uno::Reference<text::XTextRange> xRun14 = getRun(getParagraph(14), 1);
683 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun14, "CharFontName"));
685 uno::Reference<text::XTextRange> xRun15
686 = getRun(getParagraph(15), 1, u"\u0104\u012e\u0100\u0106\u00c4");
687 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun15, "CharFontName"));
689 uno::Reference<text::XTextRange> xRun16
690 = getRun(getParagraph(16), 1, u"\u0104\u012e\u0100\u0106\u00c4");
691 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun16, "CharFontName"));
694 DECLARE_RTFEXPORT_TEST(testTdf95706_2, "tdf95706_2.rtf")
696 CPPUNIT_ASSERT_EQUAL(OUString("Arial"),
697 getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
698 CPPUNIT_ASSERT_EQUAL(OUString("Impact"),
699 getProperty<OUString>(getRun(getParagraph(2), 1), "CharFontName"));
700 CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"),
701 getProperty<OUString>(getRun(getParagraph(3), 1), "CharFontName"));
702 CPPUNIT_ASSERT_EQUAL(OUString("Tahoma"),
703 getProperty<OUString>(getRun(getParagraph(4), 1), "CharFontName"));
706 DECLARE_RTFEXPORT_TEST(testTdf111851, "tdf111851.rtf")
708 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
710 // No shading
711 uno::Reference<text::XTextRange> xCell1(xTable->getCellByName("A1"), uno::UNO_QUERY);
712 CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell1->getString());
713 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty<Color>(xCell1, "BackColor"));
715 uno::Reference<text::XTextRange> xCell2(xTable->getCellByName("B1"), uno::UNO_QUERY);
716 CPPUNIT_ASSERT_EQUAL(OUString("b"), xCell2->getString());
717 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty<Color>(xCell2, "BackColor"));
719 // Check some random not standard shading values and ensure some non-white background color
720 uno::Reference<text::XTextRange> xCell3(xTable->getCellByName("C1"), uno::UNO_QUERY);
721 CPPUNIT_ASSERT_EQUAL(OUString("c"), xCell3->getString());
722 Color nShadingColor3 = getProperty<Color>(xCell3, "BackColor");
723 CPPUNIT_ASSERT(COL_WHITE > nShadingColor3);
724 CPPUNIT_ASSERT(COL_BLACK < nShadingColor3);
726 uno::Reference<text::XTextRange> xCell4(xTable->getCellByName("D1"), uno::UNO_QUERY);
727 CPPUNIT_ASSERT_EQUAL(OUString("d"), xCell4->getString());
728 Color nShadingColor4 = getProperty<Color>(xCell4, "BackColor");
729 CPPUNIT_ASSERT(COL_WHITE > nShadingColor4);
730 CPPUNIT_ASSERT(COL_BLACK < nShadingColor4);
732 // Values 10000 and more - black
733 uno::Reference<text::XTextRange> xCell5(xTable->getCellByName("E1"), uno::UNO_QUERY);
734 CPPUNIT_ASSERT_EQUAL(OUString("e"), xCell5->getString());
735 CPPUNIT_ASSERT_EQUAL(COL_BLACK, getProperty<Color>(xCell5, "BackColor"));
737 uno::Reference<text::XTextRange> xCell6(xTable->getCellByName("F1"), uno::UNO_QUERY);
738 CPPUNIT_ASSERT_EQUAL(OUString("f"), xCell6->getString());
739 CPPUNIT_ASSERT_EQUAL(COL_BLACK, getProperty<Color>(xCell6, "BackColor"));
742 DECLARE_RTFEXPORT_TEST(testTdf139948, "tdf139948.rtf")
744 CPPUNIT_ASSERT_EQUAL(
745 sal_uInt32(0),
746 getProperty<table::BorderLine2>(getParagraph(1, "No border"), "TopBorder").LineWidth);
747 CPPUNIT_ASSERT_EQUAL(
748 sal_uInt32(0),
749 getProperty<table::BorderLine2>(getParagraph(2, "Border below"), "TopBorder").LineWidth);
750 CPPUNIT_ASSERT_EQUAL(
751 sal_uInt32(88),
752 getProperty<table::BorderLine2>(getParagraph(3, "Borders below and above"), "TopBorder")
753 .LineWidth);
754 CPPUNIT_ASSERT_EQUAL(
755 sal_uInt32(88),
756 getProperty<table::BorderLine2>(getParagraph(4, "Border above"), "TopBorder").LineWidth);
757 CPPUNIT_ASSERT_EQUAL(
758 sal_uInt32(0),
759 getProperty<table::BorderLine2>(getParagraph(5, "No border"), "TopBorder").LineWidth);
761 // And let's ensure that there are no other horizontal borders
762 CPPUNIT_ASSERT_EQUAL(
763 sal_uInt32(0), getProperty<table::BorderLine2>(getParagraph(1), "BottomBorder").LineWidth);
764 CPPUNIT_ASSERT_EQUAL(
765 sal_uInt32(0), getProperty<table::BorderLine2>(getParagraph(2), "BottomBorder").LineWidth);
766 CPPUNIT_ASSERT_EQUAL(
767 sal_uInt32(0), getProperty<table::BorderLine2>(getParagraph(3), "BottomBorder").LineWidth);
768 CPPUNIT_ASSERT_EQUAL(
769 sal_uInt32(0), getProperty<table::BorderLine2>(getParagraph(4), "BottomBorder").LineWidth);
770 CPPUNIT_ASSERT_EQUAL(
771 sal_uInt32(0), getProperty<table::BorderLine2>(getParagraph(5), "BottomBorder").LineWidth);
774 DECLARE_RTFEXPORT_TEST(testTdf103956, "tdf103956.rtf")
776 // Ensure that RTF tables without column width (\cellx or \cellx0) are displayed with some
777 // suitable width. Currently there is no good support for autofit for RTF docs, so ensure
778 // that table cells are somehow visible. Width for it is not clear, so here we will check
779 // table & cell widths are more than default minimal value of 41.
780 CPPUNIT_ASSERT_MESSAGE(
781 "Table #1 is too narrow!",
782 82 < parseDump("/root/page/body/tab[1]/row/infos/bounds", "width").toInt32());
783 CPPUNIT_ASSERT_MESSAGE(
784 "Table #1 cell#1 is too narrow!",
785 41 < parseDump("/root/page/body/tab[1]/row/cell[1]/infos/bounds", "width").toInt32());
786 CPPUNIT_ASSERT_MESSAGE(
787 "Table #1 cell#2 is too narrow!",
788 41 < parseDump("/root/page/body/tab[1]/row/cell[2]/infos/bounds", "width").toInt32());
790 CPPUNIT_ASSERT_MESSAGE(
791 "Table #2 is too narrow!",
792 82 < parseDump("/root/page/body/tab[2]/row/infos/bounds", "width").toInt32());
793 CPPUNIT_ASSERT_MESSAGE(
794 "Table #2 cell#1 is too narrow!",
795 41 < parseDump("/root/page/body/tab[2]/row/cell[1]/infos/bounds", "width").toInt32());
796 CPPUNIT_ASSERT_MESSAGE(
797 "Table #2 cell#2 is too narrow!",
798 41 < parseDump("/root/page/body/tab[2]/row/cell[2]/infos/bounds", "width").toInt32());
800 CPPUNIT_ASSERT_MESSAGE(
801 "Table #3 is too narrow!",
802 82 < parseDump("/root/page/body/tab[3]/row/infos/bounds", "width").toInt32());
803 CPPUNIT_ASSERT_MESSAGE(
804 "Table #3 cell#1 is too narrow!",
805 41 < parseDump("/root/page/body/tab[3]/row/cell[1]/infos/bounds", "width").toInt32());
806 CPPUNIT_ASSERT_MESSAGE(
807 "Table #3 cell#2 is too narrow!",
808 41 < parseDump("/root/page/body/tab[3]/row/cell[2]/infos/bounds", "width").toInt32());
811 DECLARE_RTFEXPORT_TEST(testTdf148515, "tdf148515.rtf")
813 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
815 uno::Reference<text::XTextRange> xCell1(xTable->getCellByName("A1"), uno::UNO_QUERY);
816 CPPUNIT_ASSERT_EQUAL(OUString("XXXXXX"), xCell1->getString());
817 CPPUNIT_ASSERT_EQUAL(
818 5.0f,
819 getProperty<float>(getRun(getParagraphOfText(1, xCell1->getText()), 1), "CharHeight"));
821 uno::Reference<text::XTextRange> xCell2(xTable->getCellByName("B1"), uno::UNO_QUERY);
822 CPPUNIT_ASSERT_EQUAL(OUString(""), xCell2->getString());
823 CPPUNIT_ASSERT_EQUAL(
824 5.0f,
825 getProperty<float>(getRun(getParagraphOfText(1, xCell2->getText()), 1), "CharHeight"));
827 CPPUNIT_ASSERT_EQUAL(10.f, getProperty<float>(getRun(getParagraph(2), 1), "CharHeight"));
830 CPPUNIT_PLUGIN_IMPLEMENT();
832 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */