Add Marathi autocorrect
[LibreOffice.git] / sw / qa / extras / odfexport / odfexport.cxx
blobd6e4c323ba582fcd5ceb5510346619cd683fcc31
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 <tools/color.hxx>
11 #include <algorithm>
12 #include <memory>
13 #include <swmodeltestbase.hxx>
15 #include <com/sun/star/awt/FontSlant.hpp>
16 #include <com/sun/star/awt/Gradient2.hpp>
17 #include <com/sun/star/container/XIndexReplace.hpp>
18 #include <com/sun/star/drawing/FillStyle.hpp>
19 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
20 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
21 #include <com/sun/star/drawing/XGraphicExportFilter.hpp>
22 #include <com/sun/star/drawing/BarCode.hpp>
23 #include <com/sun/star/drawing/BarCodeErrorCorrection.hpp>
24 #include <com/sun/star/table/ShadowFormat.hpp>
25 #include <com/sun/star/table/XCellRange.hpp>
26 #include <com/sun/star/text/RelOrientation.hpp>
27 #include <com/sun/star/text/XDocumentIndex.hpp>
28 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
29 #include <com/sun/star/graphic/XGraphic.hpp>
30 #include <officecfg/Office/Common.hxx>
31 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
32 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
33 #include <com/sun/star/text/XTextField.hpp>
34 #include <com/sun/star/text/WritingMode2.hpp>
35 #include <com/sun/star/util/XModifiable.hpp>
36 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
37 #include <com/sun/star/container/XIndexContainer.hpp>
38 #include <com/sun/star/document/XStorageBasedDocument.hpp>
39 #include <com/sun/star/text/XTextFramesSupplier.hpp>
40 #include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
41 #include <com/sun/star/text/XTextDocument.hpp>
42 #include <com/sun/star/util/XRefreshable.hpp>
43 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
44 #include <com/sun/star/text/XTextTable.hpp>
46 #include <comphelper/storagehelper.hxx>
47 #include <comphelper/fileformat.h>
48 #include <comphelper/propertysequence.hxx>
49 #include <comphelper/documentconstants.hxx>
50 #include <unotools/streamwrap.hxx>
51 #include <svl/PasswordHelper.hxx>
52 #include <comphelper/sequenceashashmap.hxx>
53 #include <vcl/filter/PDFiumLibrary.hxx>
54 #include <comphelper/scopeguard.hxx>
55 #include <basegfx/utils/gradienttools.hxx>
56 #include <docmodel/uno/UnoGradientTools.hxx>
58 #include <docufld.hxx> // for SwHiddenTextField::ParseIfFieldDefinition() method call
59 #include <unoprnms.hxx>
60 #include <sortedobjs.hxx>
61 #include <flyfrm.hxx>
62 #include <ftnidx.hxx>
63 #include <txtftn.hxx>
64 #include <unotxdoc.hxx>
65 #include <docsh.hxx>
66 #include <IDocumentLayoutAccess.hxx>
67 #include <rootfrm.hxx>
68 #include <o3tl/string_view.hxx>
70 namespace
72 class Test : public SwModelTestBase
74 public:
75 Test() : SwModelTestBase(u"/sw/qa/extras/odfexport/data/"_ustr, u"writer8"_ustr) {}
78 CPPUNIT_TEST_FIXTURE(Test, testMathObjectFlatExport)
80 comphelper::ScopeGuard g([this]() {
81 mpFilter = "writer8";
82 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
83 comphelper::ConfigurationChanges::create());
84 officecfg::Office::Common::Cache::Writer::OLE_Objects::set(20, pBatch);
85 return pBatch->commit();
86 });
87 mpFilter = "OpenDocument Text Flat XML"; // doesn't happen with ODF package
88 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
89 comphelper::ConfigurationChanges::create());
90 officecfg::Office::Common::Cache::Writer::OLE_Objects::set(1, pBatch);
91 pBatch->commit();
92 loadAndReload("2_MathType3.docx");
94 uno::Reference<util::XModifiable> xModifiable(mxComponent, uno::UNO_QUERY);
95 CPPUNIT_ASSERT(!xModifiable->isModified());
96 // see above, set the OLE cache to 1 for this test
97 // and the problem was that the formulas that were in the cache
98 // (the second one) were lost
99 OUString formula1(getFormula(getRun(getParagraph(1), 1)));
100 CPPUNIT_ASSERT_EQUAL(u" size 12{1+1=2} {}"_ustr, formula1);
101 OUString formula2(getFormula(getRun(getParagraph(2), 1)));
102 CPPUNIT_ASSERT_EQUAL(u" size 12{2+2=4} {}"_ustr, formula2);
105 DECLARE_ODFEXPORT_TEST(testTdf144319, "tdf144319.odt")
107 CPPUNIT_ASSERT_EQUAL(7, getShapes());
108 CPPUNIT_ASSERT_EQUAL(1, getPages());
109 OUString formula1(getFormula(getRun(getParagraph(3), 1)));
110 CPPUNIT_ASSERT_EQUAL(u"{ x = frac { { - b +- sqrt { b ^ 2 - 4 a c } } } { { 2 a } } }"_ustr, formula1);
111 OUString formula2(getFormula(getRun(getParagraph(4), 1)));
112 CPPUNIT_ASSERT_EQUAL(u"{ sum csup n csub { i = 1 } i ^ 3 = left ( frac { { n left ( { n + 1 } right ) } } { 2 } right ) ^ 2 }"_ustr, formula2);
113 OUString formula3(getFormula(getRun(getParagraph(5), 1)));
114 CPPUNIT_ASSERT_EQUAL(u"{ sum ^ n _ { i = 1 } i ^ 3 = left ( frac { { n left ( { n + 1 } right ) } } { 2 } right ) ^ 2 }"_ustr, formula3);
115 OUString formula4(getFormula(getRun(getParagraph(6), 1)));
116 CPPUNIT_ASSERT_EQUAL(u"{ sum ^ n _ { i = 1 } i ^ 3 = left ( frac { { n left ( { n + 1 } right ) } } { 2 } right ) ^ 2 }"_ustr, formula4);
118 // Without the fix in place, this test would have failed with
119 // - the property is of unexpected type or void: Model
120 OUString formula5(getFormula(getRun(getParagraph(7), 1)));
121 CPPUNIT_ASSERT_EQUAL(u"{ y ^ 2 { nitalic m p } = left ( { x ^ 3 + 7 } right ) { nitalic m p } }"_ustr, formula5);
124 void testTdf43569_CheckIfFieldParse()
127 OUString paramCondition;
128 OUString paramTrue;
129 OUString paramFalse;
131 SwHiddenTextField::ParseIfFieldDefinition(u"IF A B C", paramCondition, paramTrue, paramFalse);
133 CPPUNIT_ASSERT_EQUAL(u"A"_ustr, paramCondition);
134 CPPUNIT_ASSERT_EQUAL(u"B"_ustr, paramTrue);
135 CPPUNIT_ASSERT_EQUAL(u"C"_ustr, paramFalse);
139 OUString paramCondition;
140 OUString paramTrue;
141 OUString paramFalse;
143 SwHiddenTextField::ParseIfFieldDefinition(u" IF AAA BBB CCC ", paramCondition, paramTrue, paramFalse);
145 CPPUNIT_ASSERT_EQUAL(u"AAA"_ustr, paramCondition);
146 CPPUNIT_ASSERT_EQUAL(u"BBB"_ustr, paramTrue);
147 CPPUNIT_ASSERT_EQUAL(u"CCC"_ustr, paramFalse);
151 OUString paramCondition;
152 OUString paramTrue;
153 OUString paramFalse;
155 SwHiddenTextField::ParseIfFieldDefinition(u" IF AAA \"BBB\" \"CCC\" ", paramCondition, paramTrue, paramFalse);
157 CPPUNIT_ASSERT_EQUAL(u"AAA"_ustr, paramCondition);
158 CPPUNIT_ASSERT_EQUAL(u"BBB"_ustr, paramTrue);
159 CPPUNIT_ASSERT_EQUAL(u"CCC"_ustr, paramFalse);
162 // true-case and false-case have spaces inside
164 OUString paramCondition;
165 OUString paramTrue;
166 OUString paramFalse;
168 SwHiddenTextField::ParseIfFieldDefinition(u" IF A A A \"B B B\" \"C C C\" ", paramCondition, paramTrue, paramFalse);
170 CPPUNIT_ASSERT_EQUAL(u"A A A"_ustr, paramCondition);
171 CPPUNIT_ASSERT_EQUAL(u"B B B"_ustr, paramTrue);
172 CPPUNIT_ASSERT_EQUAL(u"C C C"_ustr, paramFalse);
175 // true-case and false-case have leading/trailing space
177 OUString paramCondition;
178 OUString paramTrue;
179 OUString paramFalse;
181 SwHiddenTextField::ParseIfFieldDefinition(u"IF A1 A2 A3 \"B1 B2 \" \" C1 C2\" ", paramCondition, paramTrue, paramFalse);
183 CPPUNIT_ASSERT_EQUAL(u"A1 A2 A3"_ustr, paramCondition);
184 CPPUNIT_ASSERT_EQUAL(u"B1 B2 "_ustr, paramTrue);
185 CPPUNIT_ASSERT_EQUAL(u" C1 C2"_ustr, paramFalse);
188 // true-case and false-case are empty
190 OUString paramCondition;
191 OUString paramTrue;
192 OUString paramFalse;
194 SwHiddenTextField::ParseIfFieldDefinition(u"IF condition \"\" \"\" ", paramCondition, paramTrue, paramFalse);
196 CPPUNIT_ASSERT_EQUAL(u"condition"_ustr, paramCondition);
197 CPPUNIT_ASSERT_EQUAL(u""_ustr, paramTrue);
198 CPPUNIT_ASSERT_EQUAL(u""_ustr, paramFalse);
202 // Input document contains only one IF-field,
203 // and it should be imported as com.sun.star.text.TextField.ConditionalText in any case,
204 // instead of insertion of the pair of two field-marks: <field:fieldmark-start> + <field:fieldmark-end>.
205 CPPUNIT_TEST_FIXTURE(Test, testTdf43569)
207 loadAndReload("tdf43569_conditionalfield.doc");
208 // check if our parser is valid
209 testTdf43569_CheckIfFieldParse();
211 // now check field creation during import
212 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
213 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
214 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
216 // at least one field should be detected
217 CPPUNIT_ASSERT(xFields->hasMoreElements());
220 CPPUNIT_TEST_FIXTURE(Test, testTdf130314)
222 loadAndReload("tdf130314.docx");
223 // Without the fix in place, this test would have hung
224 CPPUNIT_ASSERT_EQUAL(2, getPages());
227 CPPUNIT_TEST_FIXTURE(Test, testTdf133487)
229 loadAndReload("MadeByLO7.odt");
230 CPPUNIT_ASSERT_EQUAL(3, getShapes());
231 CPPUNIT_ASSERT_EQUAL(1, getPages());
232 xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
233 // shape in background has lowest index
234 assertXPath(pXmlDoc, "/office:document-content/office:body/office:text/text:p[2]/draw:custom-shape", "z-index", u"0");
235 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name = /office:document-content/office:body/office:text/text:p[2]/draw:custom-shape[@draw:z-index = '0']/attribute::draw:style-name]/style:graphic-properties", "run-through", u"background");
236 // shape in foreground, previously index 1
237 assertXPath(pXmlDoc, "/office:document-content/office:body/office:text/text:p[1]/draw:custom-shape", "z-index", u"2");
238 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name = /office:document-content/office:body/office:text/text:p[1]/draw:custom-shape[@draw:z-index = '2']/attribute::draw:style-name]/style:graphic-properties", "run-through", u"foreground");
239 // shape in foreground, previously index 0
240 assertXPath(pXmlDoc, "/office:document-content/office:body/office:text/text:p[3]/draw:custom-shape", "z-index", u"1");
241 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name = /office:document-content/office:body/office:text/text:p[3]/draw:custom-shape[@draw:z-index = '1']/attribute::draw:style-name]/style:graphic-properties", "run-through", u"foreground");
244 CPPUNIT_TEST_FIXTURE(Test, testTdf141467)
246 loadAndReload("Formcontrol needs high z-index.odt");
247 CPPUNIT_ASSERT_EQUAL(2, getShapes());
248 CPPUNIT_ASSERT_EQUAL(1, getPages());
249 xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
250 // shape in foreground has lowest index
251 assertXPath(pXmlDoc, "/office:document-content/office:body/office:text/text:p[2]/draw:custom-shape", "z-index", u"0");
252 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name = /office:document-content/office:body/office:text/text:p[2]/draw:custom-shape[@draw:z-index = '0']/attribute::draw:style-name]/style:graphic-properties", "run-through", u"foreground");
253 // form control, previously index 0
254 assertXPath(pXmlDoc, "/office:document-content/office:body/office:text/text:p[2]/draw:control", "z-index", u"1");
255 // no run-through on form's style
256 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name = /office:document-content/office:body/office:text/text:p[2]/draw:control[@draw:z-index = '1']/attribute::draw:style-name]/style:graphic-properties/attribute::run-through", 0);
259 DECLARE_ODFEXPORT_TEST(testTdf139126, "tdf139126.odt")
261 CPPUNIT_ASSERT_EQUAL(1, getPages());
262 uno::Reference<text::XTextTablesSupplier> xSupplier(mxComponent, uno::UNO_QUERY);
263 uno::Reference<container::XNameAccess> xTables = xSupplier->getTextTables();
264 uno::Reference<text::XTextTable> xTable(xTables->getByName(u"Table1"_ustr), uno::UNO_QUERY);
266 uno::Reference<text::XTextRange> xD2(xTable->getCellByName(u"D2"_ustr), uno::UNO_QUERY);
267 CPPUNIT_ASSERT_EQUAL(u"4.0"_ustr, xD2->getString());
269 // Without the fix in place, this test would have failed with
270 // - Expected: ** Expression is faulty **
271 // - Actual : 17976931348623200...
272 uno::Reference<text::XTextRange> xE2(xTable->getCellByName(u"E2"_ustr), uno::UNO_QUERY);
273 CPPUNIT_ASSERT_EQUAL(u"** Expression is faulty **"_ustr, xE2->getString());
276 CPPUNIT_TEST_FIXTURE(Test, testTdf125877)
278 loadAndReload("tdf95806.docx");
279 CPPUNIT_ASSERT_EQUAL(1, getPages());
280 uno::Reference<text::XTextTablesSupplier> xSupplier(mxComponent, uno::UNO_QUERY);
281 uno::Reference<container::XIndexAccess> xTables(xSupplier->getTextTables(), uno::UNO_QUERY);
283 // This was 0 (lost table during ODT export in footnotes)
284 // Note: fix also tdf#95806: painting table layout is correct
285 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
287 // floating table: there is a frame now
288 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
289 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
290 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
293 CPPUNIT_TEST_FIXTURE(Test, testTdf150149)
295 loadAndReload("tdf150149.fodt");
296 CPPUNIT_ASSERT_EQUAL(1, getPages());
297 xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
298 // This was 0 (lost table header in multi-column section)
299 assertXPath(pXmlDoc, "//table:table-header-rows", 1);
300 assertXPath(pXmlDoc, "//table:table-header-rows/table:table-row/table:table-cell", 3);
303 DECLARE_ODFEXPORT_TEST(testTdf103567, "tdf103567.odt")
305 CPPUNIT_ASSERT_EQUAL(1, getShapes());
306 CPPUNIT_ASSERT_EQUAL(1, getPages());
307 uno::Reference<drawing::XShape> const xShape(getShape(1));
309 // contour wrap polygon
310 css::drawing::PointSequenceSequence const pointss(
311 getProperty<css::drawing::PointSequenceSequence>(xShape, u"ContourPolyPolygon"_ustr));
312 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pointss.getLength());
313 // for some reason this property exists with 199 points if it wasn't
314 // imported, that would be a fail
315 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), pointss[0].getLength());
316 CPPUNIT_ASSERT_EQUAL(sal_Int32( 0), pointss[0][0].X);
317 CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss[0][0].Y);
318 CPPUNIT_ASSERT_EQUAL(sal_Int32( 0), pointss[0][1].X);
319 CPPUNIT_ASSERT_EQUAL(sal_Int32(1111), pointss[0][1].Y);
320 CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss[0][2].X);
321 CPPUNIT_ASSERT_EQUAL(sal_Int32(1111), pointss[0][2].Y);
322 CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss[0][3].X);
323 CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss[0][3].Y);
324 CPPUNIT_ASSERT_EQUAL(sal_Int32( 0), pointss[0][4].X);
325 CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss[0][4].Y);
327 // image map, one rectangle
328 uno::Reference<container::XIndexContainer> const xImageMap(
329 getProperty<uno::Reference<container::XIndexContainer>>(xShape, u"ImageMap"_ustr));
331 uno::Reference<beans::XPropertySet> const xEntry(xImageMap->getByIndex(0), uno::UNO_QUERY);
332 CPPUNIT_ASSERT_EQUAL(u"http://example.com/"_ustr, getProperty<OUString>(xEntry, u"URL"_ustr));
333 awt::Rectangle const rect(getProperty<awt::Rectangle>(xEntry, u"Boundary"_ustr));
334 CPPUNIT_ASSERT_EQUAL(sal_Int32( 726), rect.X);
335 CPPUNIT_ASSERT_EQUAL(sal_Int32(1718), rect.Y);
336 CPPUNIT_ASSERT_EQUAL(sal_Int32(1347), rect.Width);
337 CPPUNIT_ASSERT_EQUAL(sal_Int32( 408), rect.Height);
340 CPPUNIT_TEST_FIXTURE(Test, testUserFieldDecl)
342 loadAndReload("user-field-decl.odt");
343 CPPUNIT_ASSERT_EQUAL(1, getPages());
344 xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr);
345 // Without the accompanying fix in place, this test would have failed with 'Expected: 2;
346 // Actual: 1', i.e. the in-table field had no declaration (in the header), while the
347 // outside-table one had the declaration.
348 assertXPath(pXmlDoc, "//style:header/text:user-field-decls/text:user-field-decl", 2);
351 CPPUNIT_TEST_FIXTURE(Test, testUserFieldDeclFly)
353 loadAndReload("user-field-decl-fly.odt");
354 CPPUNIT_ASSERT_EQUAL(1, getShapes());
355 CPPUNIT_ASSERT_EQUAL(1, getPages());
356 xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr);
357 // Without the accompanying fix in place, this test would have failed with 'Expected: 2;
358 // Actual: 1', i.e. the in-textframe field had no declaration (in the header), while the
359 // outside-textframe one had the declaration.
360 assertXPath(pXmlDoc, "//style:header/text:user-field-decls/text:user-field-decl", 2);
363 CPPUNIT_TEST_FIXTURE(Test, testFramebackgrounds)
365 auto verify = [this]() {
366 CPPUNIT_ASSERT_EQUAL(16, getShapes());
367 CPPUNIT_ASSERT_EQUAL(1, getPages());
368 //Counting the Number of Frames and checking with the expected count
369 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
370 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
371 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), xIndexAccess->getCount());
372 uno::Reference<drawing::XShape> xTextFrame;
373 awt::Gradient aGradientxTextFrame;
374 //Frame 1
375 xTextFrame = getShape(1);
376 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
377 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
378 //Frame 2
379 xTextFrame = getShape(2);
380 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
381 CPPUNIT_ASSERT_EQUAL(Color(0x006600), getProperty<Color>(xTextFrame, u"FillColor"_ustr));
382 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
383 //Frame 3
384 xTextFrame = getShape(3);
385 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
386 CPPUNIT_ASSERT_EQUAL(Color(0x006600), getProperty<Color>(xTextFrame, u"FillColor"_ustr));
387 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
388 //Frame 4
389 xTextFrame = getShape(4);
390 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
391 CPPUNIT_ASSERT_EQUAL(Color(0x579D1C), getProperty<Color>(xTextFrame, u"FillColor"_ustr));
392 aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, u"FillTransparenceGradient"_ustr);
393 CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style);
394 //Frame 5
395 xTextFrame = getShape(5);
396 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
397 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
398 CPPUNIT_ASSERT_EQUAL(u"Subtle Tango Green"_ustr, getProperty<OUString>(xTextFrame, u"FillGradientName"_ustr));
399 //Frame 6
400 xTextFrame = getShape(6);
401 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
402 CPPUNIT_ASSERT_EQUAL(u"Subtle Tango Green"_ustr, getProperty<OUString>(xTextFrame, u"FillGradientName"_ustr));
403 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
404 //Frame 7
405 xTextFrame = getShape(7);
406 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
407 CPPUNIT_ASSERT_EQUAL(u"Subtle Tango Green"_ustr, getProperty<OUString>(xTextFrame, u"FillGradientName"_ustr));
408 aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, u"FillTransparenceGradient"_ustr);
409 CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style);
410 //Frame 8
411 xTextFrame = getShape(8);
412 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
413 CPPUNIT_ASSERT_EQUAL(u"Black 0 Degrees"_ustr, getProperty<OUString>(xTextFrame, u"FillHatchName"_ustr));
414 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTextFrame, u"FillBackground"_ustr));
415 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
416 //Frame 9
417 xTextFrame = getShape(9);
418 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
419 CPPUNIT_ASSERT_EQUAL(u"Black 0 Degrees"_ustr, getProperty<OUString>(xTextFrame, u"FillHatchName"_ustr));
420 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextFrame, u"FillBackground"_ustr));
421 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
422 //Frame 10
423 xTextFrame = getShape(10);
424 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
425 CPPUNIT_ASSERT_EQUAL(u"Black 0 Degrees"_ustr, getProperty<OUString>(xTextFrame, u"FillHatchName"_ustr));
426 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTextFrame, u"FillBackground"_ustr));
427 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
428 //Frame 11
429 xTextFrame = getShape(11);
430 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
431 CPPUNIT_ASSERT_EQUAL(u"Black 0 Degrees"_ustr, getProperty<OUString>(xTextFrame, u"FillHatchName"_ustr));
432 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextFrame, u"FillBackground"_ustr));
433 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
434 //Frame 12
435 xTextFrame = getShape(12);
436 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
437 CPPUNIT_ASSERT_EQUAL(u"Black 0 Degrees"_ustr, getProperty<OUString>(xTextFrame, u"FillHatchName"_ustr));
438 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTextFrame, u"FillBackground"_ustr));
439 aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, u"FillTransparenceGradient"_ustr);
440 CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style);
441 //Frame 13
442 xTextFrame = getShape(13);
443 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
444 CPPUNIT_ASSERT_EQUAL(u"Black 0 Degrees"_ustr, getProperty<OUString>(xTextFrame, u"FillHatchName"_ustr));
445 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextFrame, u"FillBackground"_ustr));
446 aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, u"FillTransparenceGradient"_ustr);
447 CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style);
448 //Frame 14
449 xTextFrame = getShape(14);
450 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
451 CPPUNIT_ASSERT_EQUAL(u"Sky"_ustr, getProperty<OUString>(xTextFrame, u"FillBitmapName"_ustr));
452 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
453 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapPositionOffsetX"_ustr));
454 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapPositionOffsetY"_ustr));
455 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapOffsetX"_ustr));
456 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapOffsetY"_ustr));
457 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextFrame, u"FillBitmapTile"_ustr));
458 //Frame 15
459 xTextFrame = getShape(15);
460 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
461 CPPUNIT_ASSERT_EQUAL(u"Sky"_ustr, getProperty<OUString>(xTextFrame, u"FillBitmapName"_ustr));
462 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty<sal_Int32>(xTextFrame, u"FillTransparence"_ustr));
463 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapPositionOffsetX"_ustr));
464 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapPositionOffsetY"_ustr));
465 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapOffsetX"_ustr));
466 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapOffsetY"_ustr));
467 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextFrame, u"FillBitmapTile"_ustr));
468 //Frame 16
469 xTextFrame = getShape(16);
470 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xTextFrame, u"FillStyle"_ustr));
471 CPPUNIT_ASSERT_EQUAL(u"Sky"_ustr, getProperty<OUString>(xTextFrame, u"FillBitmapName"_ustr));
472 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapPositionOffsetX"_ustr));
473 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapPositionOffsetY"_ustr));
474 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapOffsetX"_ustr));
475 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, u"FillBitmapOffsetY"_ustr));
476 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextFrame, u"FillBitmapTile"_ustr));
477 aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, u"FillTransparenceGradient"_ustr);
478 CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style);
481 createSwDoc("framebackgrounds.odt");
482 verify();
483 saveAndReload(mpFilter);
484 verify();
486 xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
487 // check that there are 3 background-image elements
488 assertXPath(pXmlDoc, "//style:style[@style:parent-style-name='Frame' and @style:family='graphic']/style:graphic-properties[@draw:fill='bitmap']/style:background-image[@style:repeat='stretch']", 3);
489 // tdf#90640: check that one of them is 55% opaque
490 assertXPath(pXmlDoc, "//style:style[@style:parent-style-name='Frame' and @style:family='graphic']/style:graphic-properties[@draw:fill='bitmap' and @fo:background-color='transparent' and @draw:opacity='55%']/style:background-image[@style:repeat='stretch' and @draw:opacity='55%']", 1);
491 // tdf#90640: check that one of them is 43% opaque
492 // (emulated - hopefully not with rounding errors)
493 assertXPath(pXmlDoc, "//style:style[@style:parent-style-name='Frame' and @style:family='graphic']/style:graphic-properties[@draw:fill='bitmap' and @fo:background-color='transparent' and @draw:opacity-name='Transparency_20_1']/style:background-image[@style:repeat='stretch' and @draw:opacity='43%']", 1);
496 CPPUNIT_TEST_FIXTURE(Test, testSHA1Correct)
497 { // tdf#114939 this has both an affected password as well as content.xml
498 const char* const sPass = "1012345678901234567890123456789012345678901234567890";
499 createSwDoc("sha1_correct.odt", sPass);
501 CPPUNIT_ASSERT_EQUAL(1, getPages());
502 getParagraph(1, u"012"_ustr);
504 saveAndReload(mpFilter, sPass);
506 CPPUNIT_ASSERT_EQUAL(1, getPages());
507 getParagraph(1, u"012"_ustr);
510 CPPUNIT_TEST_FIXTURE(Test, testSHA1Wrong)
511 { // tdf#114939 this has both an affected password as well as content.xml
512 const char* const sPass = "1012345678901234567890123456789012345678901234567890";
513 createSwDoc("sha1_wrong.odt", sPass);
515 CPPUNIT_ASSERT_EQUAL(1, getPages());
516 getParagraph(1, u"012"_ustr);
518 saveAndReload(mpFilter, sPass);
520 CPPUNIT_ASSERT_EQUAL(1, getPages());
521 getParagraph(1, u"012"_ustr);
524 CPPUNIT_TEST_FIXTURE(Test, testOOoxmlEmbedded)
526 loadAndReload("oooxml_embedded.sxw");
527 uno::Reference<text::XTextEmbeddedObjectsSupplier> xTEOSupplier(mxComponent, uno::UNO_QUERY);
528 uno::Reference<container::XNameAccess> xAccess(xTEOSupplier->getEmbeddedObjects());
529 uno::Sequence<OUString> aSeq(xAccess->getElementNames());
530 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aSeq.getLength());
531 uno::Reference<document::XEmbeddedObjectSupplier> xEOSupplier1(xAccess->getByName(u"Object1"_ustr), uno::UNO_QUERY);
532 uno::Reference<lang::XComponent> xObj1(xEOSupplier1->getEmbeddedObject());
533 uno::Reference<document::XEmbeddedObjectSupplier> xEOSupplier2(xAccess->getByName(u"Object2"_ustr), uno::UNO_QUERY);
534 uno::Reference<lang::XComponent> xObj2(xEOSupplier2->getEmbeddedObject());
535 uno::Reference<document::XEmbeddedObjectSupplier> xEOSupplier3(xAccess->getByName(u"Object3"_ustr), uno::UNO_QUERY);
536 uno::Reference<lang::XComponent> xObj3(xEOSupplier3->getEmbeddedObject());
537 uno::Reference<document::XEmbeddedObjectSupplier> xEOSupplier4(xAccess->getByName(u"Object4"_ustr), uno::UNO_QUERY);
538 uno::Reference<lang::XComponent> xObj4(xEOSupplier4->getEmbeddedObject());
539 //checking first object
540 uno::Reference<document::XStorageBasedDocument> xSBDoc1(xObj1, uno::UNO_QUERY);
541 uno::Reference<embed::XStorage> xStorage1(xSBDoc1->getDocumentStorage());
542 CPPUNIT_ASSERT_EQUAL(sal_Int32(SOFFICE_FILEFORMAT_8), comphelper::OStorageHelper::GetXStorageFormat(xStorage1));
543 //checking second object
544 uno::Reference<document::XStorageBasedDocument> xSBDoc2(xObj2, uno::UNO_QUERY);
545 uno::Reference<embed::XStorage> xStorage2(xSBDoc2->getDocumentStorage());
546 CPPUNIT_ASSERT_EQUAL(sal_Int32(SOFFICE_FILEFORMAT_8), comphelper::OStorageHelper::GetXStorageFormat(xStorage2));
547 //checking third object
548 uno::Reference<document::XStorageBasedDocument> xSBDoc3(xObj3, uno::UNO_QUERY);
549 uno::Reference<embed::XStorage> xStorage3(xSBDoc3->getDocumentStorage());
550 CPPUNIT_ASSERT_EQUAL(sal_Int32(SOFFICE_FILEFORMAT_8), comphelper::OStorageHelper::GetXStorageFormat(xStorage3));
551 //checking fourth object
552 uno::Reference<document::XStorageBasedDocument> xSBDoc4(xObj4, uno::UNO_QUERY);
553 uno::Reference<embed::XStorage> xStorage4(xSBDoc4->getDocumentStorage());
554 CPPUNIT_ASSERT_EQUAL(sal_Int32(SOFFICE_FILEFORMAT_8), comphelper::OStorageHelper::GetXStorageFormat(xStorage4));
557 DECLARE_ODFEXPORT_TEST(testTdf152710, "tdf152710.odt")
559 // Without this fix in place, this test would have crash at import time
560 CPPUNIT_ASSERT_EQUAL(2, getPages());
563 DECLARE_ODFEXPORT_TEST(testredlineTextFrame, "redlineTextFrame.odt")
565 CPPUNIT_ASSERT_EQUAL(2, getShapes());
566 CPPUNIT_ASSERT_EQUAL(1, getPages());
567 //Note this is for a crash test
568 //Counting the Number of Frames and checking with the expected count
569 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
570 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
571 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
574 DECLARE_ODFEXPORT_TEST(testTdf107292, "tdf107292.odt")
576 // tracked deletions at the same position were loaded in reverse order
577 CPPUNIT_ASSERT_EQUAL(1, getPages());
579 // Without this fix in place, this test would have failed with
580 // - Expected: Lorem ipsum dolor sit...
581 // - Actual : dolor ipsumLorem sit...
582 CPPUNIT_ASSERT_EQUAL(u"Lorem ipsum dolor sit..."_ustr, getParagraph(1)->getString());
585 DECLARE_ODFEXPORT_TEST(testTdf140437, "tdf140437.odt")
587 // Without the fix in place, the document would have failed to load
588 CPPUNIT_ASSERT_EQUAL(1, getPages());
590 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
591 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
592 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
594 // at least one field should be detected
595 CPPUNIT_ASSERT(xFields->hasMoreElements());
598 CPPUNIT_TEST_FIXTURE(Test, testTdf131621)
600 loadAndReload("tdf131621.ott");
601 CPPUNIT_ASSERT_EQUAL(12, getShapes());
602 //Crash test, Check number of pages
603 CPPUNIT_ASSERT_EQUAL( 1, getPages() );
606 CPPUNIT_TEST_FIXTURE(Test, testTdf135144)
608 loadAndReload("tdf135144.docx");
609 //Crashes at import time after roundtrip
610 CPPUNIT_ASSERT_EQUAL(3, getPages());
611 CPPUNIT_ASSERT_EQUAL(4, getShapes());
614 DECLARE_ODFEXPORT_TEST(testTdf130950, "tdf130950.odt")
616 //Crashes at import time
617 CPPUNIT_ASSERT_EQUAL(1, getPages());
618 CPPUNIT_ASSERT_EQUAL(2, getShapes());
621 DECLARE_ODFEXPORT_TEST(testFdo38244, "fdo38244.odt")
623 CPPUNIT_ASSERT_EQUAL(1, getPages());
624 // See ooxmlexport's testFdo38244().
626 // Test comment range feature.
627 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
628 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
629 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
630 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
631 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
632 xRunEnum->nextElement();
633 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
634 CPPUNIT_ASSERT_EQUAL(u"Annotation"_ustr, getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr));
635 xRunEnum->nextElement();
636 xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
637 CPPUNIT_ASSERT_EQUAL(u"AnnotationEnd"_ustr, getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr));
639 // Test properties
640 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
641 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
642 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
643 xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
644 CPPUNIT_ASSERT_EQUAL(u"__Fieldmark__4_1833023242"_ustr, getProperty<OUString>(xPropertySet, u"Name"_ustr));
645 CPPUNIT_ASSERT_EQUAL(u"M"_ustr, getProperty<OUString>(xPropertySet, u"Initials"_ustr));
648 CPPUNIT_TEST_FIXTURE(Test, testSenderInitials)
650 loadAndReload("sender-initials.fodt");
651 // Test sender-initial properties (both annotation metadata and text field)
652 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
653 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
654 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
655 // first 3 are annotations, last 2 are text fields
656 for (unsigned i = 0; i < 3; ++i)
658 uno::Reference<beans::XPropertySet> xPropertySet(xFields->nextElement(), uno::UNO_QUERY);
659 CPPUNIT_ASSERT_EQUAL(u"I"_ustr, getProperty<OUString>(xPropertySet, u"Initials"_ustr));
661 for (unsigned i = 0; i < 2; ++i)
663 uno::Reference<beans::XPropertySet> xPropertySet(xFields->nextElement(), uno::UNO_QUERY);
664 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPropertySet, u"IsFixed"_ustr));
665 CPPUNIT_ASSERT_EQUAL(u"I"_ustr, getProperty<OUString>(xPropertySet, u"Content"_ustr));
669 DECLARE_ODFEXPORT_TEST(testResolvedComment, "resolved-comment.odt")
671 CPPUNIT_ASSERT_EQUAL(1, getPages());
672 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
673 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
674 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
675 uno::Reference<beans::XPropertySet> xPropertySet(xFields->nextElement(), uno::UNO_QUERY);
676 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPropertySet, u"Resolved"_ustr));
677 xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
678 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPropertySet, u"Resolved"_ustr));
681 CPPUNIT_TEST_FIXTURE(Test, testTdf92379)
683 auto verify = [this]() {
684 // frame style fo:background-color was not imported
685 uno::Reference<container::XNameAccess> xStyles(getStyles(u"FrameStyles"_ustr));
686 uno::Reference<beans::XPropertySet> xStyle(xStyles->getByName(u"encarts"_ustr),
687 uno::UNO_QUERY);
688 CPPUNIT_ASSERT_EQUAL(Color(0xffcc99), getProperty<Color>(xStyle, u"BackColorRGB"_ustr));
689 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xStyle, u"BackColorTransparency"_ustr));
690 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xStyle, u"FillStyle"_ustr));
691 CPPUNIT_ASSERT_EQUAL(Color(0xffcc99), getProperty<Color>(xStyle, u"FillColor"_ustr));
692 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xStyle, u"FillTransparence"_ustr));
694 uno::Reference<beans::XPropertySet> xFrameStyle2(xStyles->getByName(u"Untitled1"_ustr),
695 uno::UNO_QUERY);
696 CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<Color>(xFrameStyle2, u"BackColorRGB"_ustr));
697 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xFrameStyle2, u"BackTransparent"_ustr));
698 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xFrameStyle2, u"BackColorTransparency"_ustr));
699 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xFrameStyle2, u"FillStyle"_ustr));
700 // unfortunately this is actually the pool default value, which would be hard to fix - but it isn't a problem because style is NONE
701 // CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xFrameStyle2, "FillColor"));
702 // CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xFrameStyle2, "FillTransparence"));
704 // paragraph style fo:background-color was wrongly inherited despite being
705 // overridden in derived style
706 uno::Reference<container::XNameAccess> xParaStyles(getStyles(u"ParagraphStyles"_ustr));
707 uno::Reference<beans::XPropertySet> xStyle1(xParaStyles->getByName(
708 u"Titre Avis expert"_ustr), uno::UNO_QUERY);
709 CPPUNIT_ASSERT_EQUAL(Color(0x661900), getProperty<Color>(xStyle1, u"ParaBackColor"_ustr));
710 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xStyle1, u"ParaBackTransparent"_ustr));
711 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xStyle1, u"FillStyle"_ustr));
712 CPPUNIT_ASSERT_EQUAL(Color(0x661900), getProperty<Color>(xStyle1, u"FillColor"_ustr));
713 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xStyle1, u"FillTransparence"_ustr));
714 CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<Color>(xStyle1, u"CharColor"_ustr));
716 uno::Reference<beans::XPropertySet> xStyle2(xParaStyles->getByName(
717 u"Avis expert questions"_ustr), uno::UNO_QUERY);
718 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty<Color>(xStyle2, u"ParaBackColor"_ustr));
719 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle2, u"ParaBackTransparent"_ustr));
720 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xStyle2, u"FillStyle"_ustr));
721 // unfortunately this is actually the pool default value, which would be hard to fix - but it isn't a problem because style is NONE
722 // CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xStyle2, "FillColor"));
723 // CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xStyle2, "FillTransparence"));
724 CPPUNIT_ASSERT_EQUAL(Color(0x661900), getProperty<Color>(xStyle2, u"CharColor"_ustr));
726 uno::Reference<beans::XPropertySet> xStyle31(xParaStyles->getByName(
727 u"avis expert questions non cadres"_ustr), uno::UNO_QUERY);
728 CPPUNIT_ASSERT_EQUAL(Color(0x801900), getProperty<Color>(xStyle31, u"ParaBackColor"_ustr));
729 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xStyle31, u"ParaBackTransparent"_ustr));
730 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xStyle31, u"FillStyle"_ustr));
731 CPPUNIT_ASSERT_EQUAL(Color(0x801900), getProperty<Color>(xStyle31, u"FillColor"_ustr));
732 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xStyle31, u"FillTransparence"_ustr));
733 CPPUNIT_ASSERT_EQUAL(Color(0x661900), getProperty<Color>(xStyle31, u"CharColor"_ustr));
735 uno::Reference<beans::XPropertySet> xStyle32(xParaStyles->getByName(
736 u"Avis expert rXponses"_ustr), uno::UNO_QUERY);
737 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty<Color>(xStyle32, u"ParaBackColor"_ustr));
738 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle32, u"ParaBackTransparent"_ustr));
739 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xStyle32, u"FillStyle"_ustr));
740 // unfortunately this is actually the pool default value, which would be hard to fix - but it isn't a problem because style is NONE
741 // CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xStyle32, "FillColor"));
742 // CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xStyle32, "FillTransparence"));
743 CPPUNIT_ASSERT_EQUAL(Color(0x461900), getProperty<Color>(xStyle32, u"CharColor"_ustr));
746 createSwDoc("tdf92379.fodt");
747 verify();
748 saveAndReload(mpFilter);
749 verify();
751 xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr);
752 // check that fo:background-color attribute is exported properly
753 assertXPath(pXmlDoc, "//style:style[@style:family='graphic' and @style:name='encarts']/style:graphic-properties[@fo:background-color='#ffcc99']", 1);
754 assertXPath(pXmlDoc, "//style:style[@style:family='graphic' and @style:name='Untitled1']/style:graphic-properties[@fo:background-color='transparent']", 1);
756 // check that fo:background-color attribute is exported properly
757 assertXPath(pXmlDoc, "//style:style[@style:family='paragraph' and @style:display-name='Titre Avis expert']/style:paragraph-properties[@fo:background-color='#661900']", 1);
758 assertXPath(pXmlDoc, "//style:style[@style:family='paragraph' and @style:display-name='Avis expert questions']/style:paragraph-properties[@fo:background-color='transparent']", 1);
759 assertXPath(pXmlDoc, "//style:style[@style:family='paragraph' and @style:display-name='avis expert questions non cadres']/style:paragraph-properties[@fo:background-color='#801900']", 1);
760 assertXPath(pXmlDoc, "//style:style[@style:family='paragraph' and @style:display-name='Avis expert rXponses']/style:paragraph-properties[@fo:background-color='transparent']", 1);
763 DECLARE_ODFEXPORT_TEST(testFdo79358, "fdo79358.odt")
765 CPPUNIT_ASSERT_EQUAL(1, getPages());
766 // the boolean properties of the index were not exported properly
767 uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
768 uno::Reference<container::XIndexAccess> xIndexes = xIndexSupplier->getDocumentIndexes();
769 uno::Reference<text::XDocumentIndex> xTOCIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
770 uno::Reference<beans::XPropertySet> xTOCProps(xTOCIndex, uno::UNO_QUERY);
771 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTOCProps, u"CreateFromOutline"_ustr));
772 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTOCProps, u"CreateFromMarks"_ustr));
773 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTOCProps, u"CreateFromLevelParagraphStyles"_ustr));
774 // check that the source styles are preserved too while at it
775 uno::Reference<container::XIndexReplace> xLevels(
776 getProperty< uno::Reference<container::XIndexReplace> >(xTOCProps,
777 u"LevelParagraphStyles"_ustr));
778 uno::Sequence<OUString> seq { u"Heading"_ustr };
779 CPPUNIT_ASSERT_EQUAL(uno::Any(seq), xLevels->getByIndex(1));
780 CPPUNIT_ASSERT_EQUAL(uno::Any(uno::Sequence<OUString>()), xLevels->getByIndex(2));
783 DECLARE_ODFEXPORT_TEST(testTextframeGradient, "textframe-gradient.odt")
785 CPPUNIT_ASSERT_EQUAL(2, getShapes());
786 CPPUNIT_ASSERT_EQUAL(1, getPages());
787 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
788 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
789 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
791 uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
792 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, u"FillStyle"_ustr));
793 awt::Gradient2 aGradient = getProperty<awt::Gradient2>(xFrame, u"FillGradient"_ustr);
795 // MCGR: Use the completely imported gradient to check for correctness
796 basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
798 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
799 CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset());
800 CPPUNIT_ASSERT_EQUAL(Color(0xc0504d), Color(aColorStops[0].getStopColor()));
801 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
802 CPPUNIT_ASSERT_EQUAL(Color(0xd99594), Color(aColorStops[1].getStopColor()));
803 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
805 xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
806 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, u"FillStyle"_ustr));
807 aGradient = getProperty<awt::Gradient2>(xFrame, u"FillGradient"_ustr);
809 // MCGR: Use the completely imported gradient to check for correctness
810 aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
812 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
813 CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset());
814 CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(aColorStops[0].getStopColor()));
815 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
816 CPPUNIT_ASSERT_EQUAL(COL_GRAY7, Color(aColorStops[1].getStopColor()));
817 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
820 CPPUNIT_TEST_FIXTURE(Test, testDuplicateCrossRefHeadingBookmark)
822 loadAndReload("CrossRefHeadingBookmark.fodt");
823 // the file contains invalid duplicate heading cross reference bookmarks
824 // but we have to round trip them, tdf#94804
826 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent,
827 uno::UNO_QUERY);
828 uno::Reference<container::XNameAccess> xBookmarks =
829 xBookmarksSupplier->getBookmarks();
830 uno::Reference<text::XTextContent> xBookmark1(
831 xBookmarks->getByName(u"__RefHeading__8284_1826734303"_ustr), uno::UNO_QUERY);
832 CPPUNIT_ASSERT(xBookmark1.is());
833 CPPUNIT_ASSERT_THROW(xBookmarks->getByName(u"__RefHeading__1673_25705824"_ustr), container::NoSuchElementException);
835 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
836 uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh();
838 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
839 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
840 uno::Any aField1 = xFields->nextElement();
841 uno::Reference<text::XTextField> xField1(aField1, uno::UNO_QUERY);
842 CPPUNIT_ASSERT_EQUAL(u"1.1"_ustr, xField1->getPresentation(false));
843 uno::Any aField2 = xFields->nextElement();
844 uno::Reference<text::XTextField> xField2(aField2, uno::UNO_QUERY);
845 CPPUNIT_ASSERT_EQUAL(u"1.1"_ustr, xField2->getPresentation(false));
848 DECLARE_ODFEXPORT_TEST(testFdo60769, "fdo60769.odt")
850 CPPUNIT_ASSERT_EQUAL(1, getPages());
851 // Test multi-paragraph comment range feature.
852 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
853 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
854 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
855 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
856 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
857 while (xRunEnum->hasMoreElements())
859 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
860 OUString aType = getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr);
861 // First paragraph: no field end, no anchor
862 CPPUNIT_ASSERT(aType == "Text" || aType == "Annotation");
865 xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
866 while (xRunEnum->hasMoreElements())
868 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
869 OUString aType = getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr);
870 // Second paragraph: no field start
871 CPPUNIT_ASSERT(aType == "Text" || aType == "AnnotationEnd");
875 DECLARE_ODFEXPORT_TEST(testTdf115815, "tdf115815.odt")
877 CPPUNIT_ASSERT_EQUAL(1, getPages());
878 // Test comment range feature on tracked deletion.
879 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
880 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
881 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
882 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
883 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
884 bool bAnnotationStart = false;
885 bool bBeforeAnnotation = true;
886 OUString sTextBeforeAnnotation;
887 while (xRunEnum->hasMoreElements())
889 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
890 OUString aType = getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr);
891 // there is no AnnotationEnd with preceding AnnotationStart,
892 // i.e. annotation with lost range
893 CPPUNIT_ASSERT(aType != "AnnotationEnd" || !bAnnotationStart);
895 bAnnotationStart = (aType == "Annotation");
897 // collect paragraph text before the first annotation
898 if (bBeforeAnnotation)
900 if (bAnnotationStart)
901 bBeforeAnnotation = false;
902 else if (aType == "Text")
904 uno::Reference<text::XTextRange> xRun(xPropertySet, uno::UNO_QUERY);
905 sTextBeforeAnnotation += xRun->getString();
910 // This was "Lorem ipsum" (collapsed annotation range)
911 CPPUNIT_ASSERT_EQUAL(u"Lorem "_ustr, sTextBeforeAnnotation);
914 CPPUNIT_TEST_FIXTURE(Test, testFdo58949)
916 comphelper::ScopeGuard g([]() {
917 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
918 comphelper::ConfigurationChanges::create());
919 officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(true, pBatch);
920 pBatch->commit();
923 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
924 comphelper::ConfigurationChanges::create());
925 officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(false, pBatch);
926 pBatch->commit();
927 loadAndReload("fdo58949.docx");
930 * The problem was that the exporter didn't insert "Obj102" to the
931 * resulting zip file. No idea how to check for "broken" (missing OLE data
932 * and replacement image) OLE objects using UNO, so we'll check the zip file directly.
935 save(u"writer8"_ustr);
937 uno::Sequence<uno::Any> aArgs{ uno::Any(maTempFile.GetURL()) };
938 uno::Reference<container::XNameAccess> xNameAccess(m_xSFactory->createInstanceWithArguments(u"com.sun.star.packages.zip.ZipFileAccess"_ustr, aArgs), uno::UNO_QUERY);
939 const css::uno::Sequence<OUString> aNames(xNameAccess->getElementNames());
940 // The exported document must have three objects named ObjNNN. The names are assigned in
941 // OLEHandler::copyOLEOStream using a static counter, and actual numbers depend on previous
942 // tests; so just count the matching names here.
943 int nMatches = 0;
944 for (const OUString& sName : aNames)
946 OUString sRest;
947 if (sName.startsWith("Obj", &sRest))
949 // all following characters must be decimal digits; minimal value is 100
950 bool bMatch = sRest.getLength() >= 3
951 && std::all_of(sRest.getStr(), sRest.getStr() + sRest.getLength(),
952 [](sal_Unicode ch) { return ch >= '0' && ch <= '9'; });
953 if (bMatch)
954 ++nMatches;
957 CPPUNIT_ASSERT_EQUAL(3, nMatches);
960 CPPUNIT_TEST_FIXTURE(Test, testTdf134987)
962 loadAndReload("tdf134987.docx");
963 uno::Reference<text::XTextEmbeddedObjectsSupplier> xTEOSupplier(mxComponent, uno::UNO_QUERY);
964 uno::Reference<container::XNameAccess> xAccess(xTEOSupplier->getEmbeddedObjects());
965 uno::Sequence<OUString> aSeq(xAccess->getElementNames());
966 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aSeq.getLength());
968 OUString aMediaType;
969 // checking first object (formula)
971 uno::Reference<document::XEmbeddedObjectSupplier> xEOSupplier(xAccess->getByName(u"Object1"_ustr), uno::UNO_QUERY);
972 uno::Reference<lang::XComponent> xObj(xEOSupplier->getEmbeddedObject());
973 CPPUNIT_ASSERT(xObj.is());
975 uno::Reference<document::XStorageBasedDocument> xSBDoc(xObj, uno::UNO_QUERY);
976 uno::Reference<embed::XStorage> xStorage(xSBDoc->getDocumentStorage());
977 CPPUNIT_ASSERT(xStorage.is());
979 uno::Reference< beans::XPropertySet > xStorProps(xStorage, uno::UNO_QUERY_THROW);
980 CPPUNIT_ASSERT(xStorProps->getPropertyValue(u"MediaType"_ustr) >>= aMediaType);
981 CPPUNIT_ASSERT(aMediaType.equalsIgnoreAsciiCase(MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_ASCII));
983 // checking second object (chart)
985 uno::Reference<document::XEmbeddedObjectSupplier> xEOSupplier(xAccess->getByName(u"Diagram 1"_ustr), uno::UNO_QUERY);
986 uno::Reference<lang::XComponent> xObj(xEOSupplier->getEmbeddedObject());
987 CPPUNIT_ASSERT(xObj.is());
989 uno::Reference<document::XStorageBasedDocument> xSBDoc(xObj, uno::UNO_QUERY);
990 uno::Reference<embed::XStorage> xStorage(xSBDoc->getDocumentStorage());
991 CPPUNIT_ASSERT(xStorage.is());
993 uno::Reference< beans::XPropertySet > xStorProps(xStorage, uno::UNO_QUERY_THROW);
994 CPPUNIT_ASSERT(xStorProps->getPropertyValue(u"MediaType"_ustr) >>= aMediaType);
995 CPPUNIT_ASSERT(aMediaType.equalsIgnoreAsciiCase(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII));
997 // checking third object (chart)
999 uno::Reference<document::XEmbeddedObjectSupplier> xEOSupplier(xAccess->getByName(u"Diagram 2"_ustr), uno::UNO_QUERY);
1000 uno::Reference<lang::XComponent> xObj(xEOSupplier->getEmbeddedObject());
1001 CPPUNIT_ASSERT(xObj.is());
1003 uno::Reference<document::XStorageBasedDocument> xSBDoc(xObj, uno::UNO_QUERY);
1004 uno::Reference<embed::XStorage> xStorage(xSBDoc->getDocumentStorage());
1005 CPPUNIT_ASSERT(xStorage.is());
1007 uno::Reference< beans::XPropertySet > xStorProps(xStorage, uno::UNO_QUERY_THROW);
1008 CPPUNIT_ASSERT(xStorProps->getPropertyValue(u"MediaType"_ustr) >>= aMediaType);
1009 CPPUNIT_ASSERT(aMediaType.equalsIgnoreAsciiCase(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII));
1013 DECLARE_ODFEXPORT_TEST(testStylePageNumber, "ooo321_stylepagenumber.odt")
1015 CPPUNIT_ASSERT_EQUAL(5, getPages());
1016 uno::Reference<text::XTextContent> xTable1(getParagraphOrTable(1));
1017 // actually no break attribute is written in this case
1018 // CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, getProperty<style::BreakType>(xTable1, "BreakType"));
1019 CPPUNIT_ASSERT_EQUAL(u"Left Page"_ustr, getProperty<OUString>(xTable1, u"PageDescName"_ustr));
1020 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty<sal_Int16>(xTable1, u"PageNumberOffset"_ustr));
1022 uno::Reference<text::XTextContent> xPara1(getParagraphOrTable(2));
1023 CPPUNIT_ASSERT_EQUAL(u"Right Page"_ustr, getProperty<OUString>(xPara1, u"PageDescName"_ustr));
1024 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty<sal_Int16>(xPara1, u"PageNumberOffset"_ustr));
1026 // i#114163 tdf#77111: OOo < 3.3 bug, it wrote "auto" as "0" for tables
1027 uno::Reference<beans::XPropertySet> xTable0(getParagraphOrTable(3), uno::UNO_QUERY);
1028 CPPUNIT_ASSERT_EQUAL(u"Left Page"_ustr, getProperty<OUString>(xTable0, u"PageDescName"_ustr));
1029 CPPUNIT_ASSERT_EQUAL(uno::Any(), xTable0->getPropertyValue(u"PageNumberOffset"_ustr));
1031 uno::Reference<beans::XPropertySet> xPara0(getParagraphOrTable(4), uno::UNO_QUERY);
1032 CPPUNIT_ASSERT_EQUAL(u"Right Page"_ustr, getProperty<OUString>(xPara0, u"PageDescName"_ustr));
1033 CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara0->getPropertyValue(u"PageNumberOffset"_ustr));
1035 uno::Reference<container::XNameAccess> xParaStyles = getStyles(u"ParagraphStyles"_ustr);
1036 uno::Reference<beans::XPropertySet> xStyle1(xParaStyles->getByName(u"stylewithbreak1"_ustr), uno::UNO_QUERY);
1037 CPPUNIT_ASSERT_EQUAL(u"Right Page"_ustr, getProperty<OUString>(xStyle1, u"PageDescName"_ustr));
1038 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty<sal_Int16>(xStyle1, u"PageNumberOffset"_ustr));
1040 uno::Reference<beans::XPropertySet> xStyle0(xParaStyles->getByName(u"stylewithbreak0"_ustr), uno::UNO_QUERY);
1041 CPPUNIT_ASSERT_EQUAL(u"First Page"_ustr, getProperty<OUString>(xStyle0, u"PageDescName"_ustr));
1042 CPPUNIT_ASSERT_EQUAL(uno::Any(), xStyle0->getPropertyValue(u"PageNumberOffset"_ustr));
1045 DECLARE_ODFEXPORT_TEST(testCharacterBorder, "charborder.odt")
1047 CPPUNIT_ASSERT_EQUAL(1, getPages());
1048 // Make sure paragraph and character attributes don't interfere
1049 // First paragraph has a paragraph border and a character border included by the paragraph style
1051 // Paragraph border of first paragraph
1053 const table::BorderLine2 aFirstParTopBorder(0x6666FF,2,26,26,7,55);
1054 const sal_Int32 aFirstParTopPadding(150);
1055 uno::Reference<beans::XPropertySet> xSet(getParagraph(1), uno::UNO_QUERY);
1057 // Top border
1058 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder, getProperty<table::BorderLine2>(xSet,u"TopBorder"_ustr));
1059 CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding, getProperty<sal_Int32>(xSet,u"TopBorderDistance"_ustr));
1061 // Bottom border (same as top border)
1062 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder, getProperty<table::BorderLine2>(xSet,u"BottomBorder"_ustr));
1063 CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding, getProperty<sal_Int32>(xSet,u"BottomBorderDistance"_ustr));
1065 // Left border (same as top border)
1066 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder, getProperty<table::BorderLine2>(xSet,u"LeftBorder"_ustr));
1067 CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding, getProperty<sal_Int32>(xSet,u"LeftBorderDistance"_ustr));
1069 // Right border (same as top border)
1070 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder, getProperty<table::BorderLine2>(xSet,u"RightBorder"_ustr));
1071 CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding, getProperty<sal_Int32>(xSet,u"RightBorderDistance"_ustr));
1073 // Shadow
1074 const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xSet,u"ParaShadowFormat"_ustr);
1075 CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(ColorTransparency, aShadow.Color));
1076 CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(aShadow.IsTransparent));
1077 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation(0), aShadow.Location);
1078 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aShadow.ShadowWidth);
1081 // Character border for first paragraph
1083 const table::BorderLine2 aFirstParCharTopBorder(0xFF3333,0,37,0,2,37);
1084 const sal_Int32 aFirstParCharTopPadding(450);
1085 uno::Reference<beans::XPropertySet> xSet(getParagraph(1), uno::UNO_QUERY);
1087 // Top border
1088 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,u"CharTopBorder"_ustr));
1089 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,u"CharTopBorderDistance"_ustr));
1091 // Bottom border (same as top border)
1092 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,u"CharBottomBorder"_ustr));
1093 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,u"CharBottomBorderDistance"_ustr));
1095 // Left border (same as top border)
1096 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,u"CharLeftBorder"_ustr));
1097 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,u"CharLeftBorderDistance"_ustr));
1099 // Right border (same as top border)
1100 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,u"CharRightBorder"_ustr));
1101 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,u"CharRightBorderDistance"_ustr));
1103 // Shadow
1104 const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xSet,u"CharShadowFormat"_ustr);
1105 CPPUNIT_ASSERT_EQUAL(Color(0xFF3333), Color(ColorTransparency, aShadow.Color));
1106 CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(aShadow.IsTransparent));
1107 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation(2), aShadow.Location);
1108 CPPUNIT_ASSERT_EQUAL(sal_Int16(280), aShadow.ShadowWidth);
1110 // Check autostyle
1112 uno::Reference< style::XAutoStyleFamily > xAutoStyleFamily(getAutoStyles(u"ParagraphStyles"_ustr));
1113 uno::Reference < container::XEnumeration > xAutoStylesEnum( xAutoStyleFamily->createEnumeration() );
1114 CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(xAutoStylesEnum->hasMoreElements()));
1116 // Top border
1117 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,u"CharTopBorder"_ustr));
1118 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,u"CharTopBorderDistance"_ustr));
1120 // Bottom border
1121 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,u"CharBottomBorder"_ustr));
1122 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,u"CharBottomBorderDistance"_ustr));
1124 // Left border
1125 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,u"CharLeftBorder"_ustr));
1126 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,u"CharLeftBorderDistance"_ustr));
1128 // Right border
1129 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,u"CharRightBorder"_ustr));
1130 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,u"CharRightBorderDistance"_ustr));
1134 // Second paragraph's second text portion has a character style named CharDiffBor
1135 // This style includes border with different sides
1138 table::BorderLine2 aBorderArray[4] =
1140 table::BorderLine2(0xFF3333,0,37,0,14,37), // Top (fine dashed line)
1141 table::BorderLine2(0x99FF66,26,26,53,11,106), // Bottom
1142 table::BorderLine2(0x6666FF,9,26,9,12,71), // Left
1143 table::BorderLine2(0,0,0,0,table::BorderLineStyle::NONE,0) // Right
1146 sal_Int32 aDistances[4] = { 400 /*Top*/, 300 /*Bottom*/, 250 /*Left*/, 0 /*Right*/ };
1148 // Get second text portion of second paragraph
1149 uno::Reference < beans::XPropertySet > xSet( getRun(getParagraph(2),2), uno::UNO_QUERY );
1151 // Top border
1152 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[0], getProperty<table::BorderLine2>(xSet,u"CharTopBorder"_ustr));
1153 CPPUNIT_ASSERT_EQUAL(aDistances[0], getProperty<sal_Int32>(xSet,u"CharTopBorderDistance"_ustr));
1155 // Bottom border
1156 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[1], getProperty<table::BorderLine2>(xSet,u"CharBottomBorder"_ustr));
1157 CPPUNIT_ASSERT_EQUAL(aDistances[1], getProperty<sal_Int32>(xSet,u"CharBottomBorderDistance"_ustr));
1159 // Left border
1160 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[2], getProperty<table::BorderLine2>(xSet,u"CharLeftBorder"_ustr));
1161 CPPUNIT_ASSERT_EQUAL(aDistances[2], getProperty<sal_Int32>(xSet,u"CharLeftBorderDistance"_ustr));
1163 // Right border
1164 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[3], getProperty<table::BorderLine2>(xSet,u"CharRightBorder"_ustr));
1165 CPPUNIT_ASSERT_EQUAL(aDistances[3], getProperty<sal_Int32>(xSet,u"CharRightBorderDistance"_ustr));
1167 // Shadow
1168 const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xSet,u"CharShadowFormat"_ustr);
1169 CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(ColorTransparency, aShadow.Color));
1170 CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(aShadow.IsTransparent));
1171 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation(3), aShadow.Location);
1172 CPPUNIT_ASSERT_EQUAL(sal_Int16(79), aShadow.ShadowWidth);
1174 // Check character style
1176 uno::Reference< container::XNameAccess > xStyleFamily = getStyles(u"CharacterStyles"_ustr);
1177 uno::Reference < beans::XPropertySet > xStyleSet(xStyleFamily->getByName(u"CharDiffBor"_ustr), uno::UNO_QUERY);
1179 // Top border
1180 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[0], getProperty<table::BorderLine2>(xStyleSet,u"CharTopBorder"_ustr));
1181 CPPUNIT_ASSERT_EQUAL(aDistances[0], getProperty<sal_Int32>(xStyleSet,u"CharTopBorderDistance"_ustr));
1183 // Bottom border
1184 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[1], getProperty<table::BorderLine2>(xStyleSet,u"CharBottomBorder"_ustr));
1185 CPPUNIT_ASSERT_EQUAL(aDistances[1], getProperty<sal_Int32>(xStyleSet,u"CharBottomBorderDistance"_ustr));
1187 // Left border
1188 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[2], getProperty<table::BorderLine2>(xStyleSet,u"CharLeftBorder"_ustr));
1189 CPPUNIT_ASSERT_EQUAL(aDistances[2], getProperty<sal_Int32>(xStyleSet,u"CharLeftBorderDistance"_ustr));
1191 // Right border
1192 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[3], getProperty<table::BorderLine2>(xStyleSet,u"CharRightBorder"_ustr));
1193 CPPUNIT_ASSERT_EQUAL(aDistances[3], getProperty<sal_Int32>(xStyleSet,u"CharRightBorderDistance"_ustr));
1198 CPPUNIT_TEST_FIXTURE(Test, testProtectionKey)
1200 auto verify = [this]() {
1201 static OUString constexpr password(u"1012345678901234567890123456789012345678901234567890"_ustr);
1203 // check 1 invalid OOo legacy password and 3 valid ODF 1.2 passwords
1204 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
1205 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
1206 uno::Reference<beans::XPropertySet> xSect0(xSections->getByIndex(0), uno::UNO_QUERY);
1207 uno::Sequence<sal_Int8> const key0(getProperty<uno::Sequence<sal_Int8>>(xSect0, u"ProtectionKey"_ustr));
1208 CPPUNIT_ASSERT(SvPasswordHelper::CompareHashPassword(key0, password));
1209 uno::Reference<beans::XPropertySet> xSect1(xSections->getByIndex(1), uno::UNO_QUERY);
1210 uno::Sequence<sal_Int8> const key1(getProperty<uno::Sequence<sal_Int8>>(xSect1, u"ProtectionKey"_ustr));
1211 CPPUNIT_ASSERT(SvPasswordHelper::CompareHashPassword(key1, password));
1212 uno::Reference<beans::XPropertySet> xSect2(xSections->getByIndex(2), uno::UNO_QUERY);
1213 uno::Sequence<sal_Int8> const key2(getProperty<uno::Sequence<sal_Int8>>(xSect2, u"ProtectionKey"_ustr));
1214 CPPUNIT_ASSERT(SvPasswordHelper::CompareHashPassword(key2, password));
1215 uno::Reference<beans::XPropertySet> xSect3(xSections->getByIndex(3), uno::UNO_QUERY);
1216 uno::Sequence<sal_Int8> const key3(getProperty<uno::Sequence<sal_Int8>>(xSect3, u"ProtectionKey"_ustr));
1217 CPPUNIT_ASSERT(SvPasswordHelper::CompareHashPassword(key3, password));
1220 createSwDoc("protection-key.fodt");
1221 verify();
1222 saveAndReload(mpFilter);
1223 verify();
1225 // we can't assume that the user entered the password; check that we
1226 // round-trip the password as-is
1227 xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
1228 assertXPath(pXmlDoc, "//text:section[@text:name='Section0' and @text:protected='true' and @text:protection-key='vbnhxyBKtPHCA1wB21zG1Oha8ZA=']");
1229 assertXPath(pXmlDoc, "//text:section[@text:name='Section1' and @text:protected='true' and @text:protection-key='nLHas0RIwepGDaH4c2hpyIUvIS8=']");
1230 assertXPath(pXmlDoc, "//text:section[@text:name='Section2' and @text:protected='true' and @text:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha256' and @text:protection-key='1tnJohagR2T0yF/v69hLPuumSTsj32CumW97nkKGuSQ=']");
1231 assertXPath(pXmlDoc, "//text:section[@text:name='Section3' and @text:protected='true' and @text:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha256' and @text:protection-key='1tnJohagR2T0yF/v69hLPuumSTsj32CumW97nkKGuSQ=']");
1234 CPPUNIT_TEST_FIXTURE(Test, testTdf128188)
1236 loadAndReload("footnote-collect-at-end-of-section.fodt");
1237 SwDoc* pDoc = getSwDoc();
1238 SwFootnoteIdxs const& rFootnotes(pDoc->GetFootnoteIdxs());
1239 // Section1
1240 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes[0]->GetFootnote().GetNumber());
1241 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes[0]->GetFootnote().GetNumberRLHidden());
1242 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), rFootnotes[1]->GetFootnote().GetNumber());
1243 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), rFootnotes[1]->GetFootnote().GetNumberRLHidden());
1244 // Section2
1245 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes[2]->GetFootnote().GetNumber());
1246 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes[2]->GetFootnote().GetNumberRLHidden());
1247 // deleted
1248 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), rFootnotes[3]->GetFootnote().GetNumber());
1249 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes[3]->GetFootnote().GetNumberRLHidden());
1250 // deleted
1251 CPPUNIT_ASSERT_EQUAL(sal_uInt16(3), rFootnotes[4]->GetFootnote().GetNumber());
1252 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes[4]->GetFootnote().GetNumberRLHidden());
1253 CPPUNIT_ASSERT_EQUAL(sal_uInt16(4), rFootnotes[5]->GetFootnote().GetNumber());
1254 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), rFootnotes[5]->GetFootnote().GetNumberRLHidden());
1257 DECLARE_ODFEXPORT_TEST(testFdo43807, "fdo43807.odt")
1259 CPPUNIT_ASSERT_EQUAL(1, getPages());
1260 uno::Reference<beans::XPropertySet> xSet(getParagraph(1), uno::UNO_QUERY);
1261 CPPUNIT_ASSERT_EQUAL(u"Drop Caps"_ustr,getProperty<OUString>(xSet,u"DropCapCharStyleName"_ustr));
1263 xSet.set(getParagraph(2), uno::UNO_QUERY);
1264 CPPUNIT_ASSERT_EQUAL(u"User Defined Drop Caps"_ustr,getProperty<OUString>(xSet,u"DropCapCharStyleName"_ustr));
1267 CPPUNIT_TEST_FIXTURE(Test, testTdf103091)
1269 loadAndReload("tdf103091.fodt");
1270 // check that all conditional paragraph style conditions are imported
1271 uno::Reference<container::XNameAccess> xParaStyles(getStyles(u"ParagraphStyles"_ustr));
1272 uno::Reference<beans::XPropertySet> xStyle1(xParaStyles->getByName(
1273 u"Text body"_ustr), uno::UNO_QUERY);
1274 auto conditions(getProperty<uno::Sequence<beans::NamedValue>>(xStyle1, u"ParaStyleConditions"_ustr));
1276 CPPUNIT_ASSERT_EQUAL(sal_Int32(28), conditions.getLength());
1277 CPPUNIT_ASSERT_EQUAL(u"TableHeader"_ustr, conditions[0].Name);
1278 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Addressee"_ustr), conditions[0].Value);
1279 CPPUNIT_ASSERT_EQUAL(u"Table"_ustr, conditions[1].Name);
1280 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Bibliography 1"_ustr), conditions[1].Value);
1281 CPPUNIT_ASSERT_EQUAL(u"Frame"_ustr, conditions[2].Name);
1282 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Bibliography Heading"_ustr), conditions[2].Value);
1283 CPPUNIT_ASSERT_EQUAL(u"Section"_ustr, conditions[3].Name);
1284 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Caption"_ustr), conditions[3].Value);
1285 CPPUNIT_ASSERT_EQUAL(u"Footnote"_ustr, conditions[4].Name);
1286 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Salutation"_ustr), conditions[4].Value);
1287 CPPUNIT_ASSERT_EQUAL(u"Endnote"_ustr, conditions[5].Name);
1288 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents 1"_ustr), conditions[5].Value);
1289 CPPUNIT_ASSERT_EQUAL(u"Header"_ustr, conditions[6].Name);
1290 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents 2"_ustr), conditions[6].Value);
1291 CPPUNIT_ASSERT_EQUAL(u"Footer"_ustr, conditions[7].Name);
1292 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents 3"_ustr), conditions[7].Value);
1293 CPPUNIT_ASSERT_EQUAL(u"OutlineLevel1"_ustr, conditions[8].Name);
1294 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents 4"_ustr), conditions[8].Value);
1295 CPPUNIT_ASSERT_EQUAL(u"OutlineLevel2"_ustr, conditions[9].Name);
1296 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents 5"_ustr), conditions[9].Value);
1297 CPPUNIT_ASSERT_EQUAL(u"OutlineLevel3"_ustr, conditions[10].Name);
1298 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents 6"_ustr), conditions[10].Value);
1299 CPPUNIT_ASSERT_EQUAL(u"OutlineLevel4"_ustr, conditions[11].Name);
1300 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents 7"_ustr), conditions[11].Value);
1301 CPPUNIT_ASSERT_EQUAL(u"OutlineLevel5"_ustr, conditions[12].Name);
1302 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents 8"_ustr), conditions[12].Value);
1303 CPPUNIT_ASSERT_EQUAL(u"OutlineLevel6"_ustr, conditions[13].Name);
1304 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents 9"_ustr), conditions[13].Value);
1305 CPPUNIT_ASSERT_EQUAL(u"OutlineLevel7"_ustr, conditions[14].Name);
1306 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents 10"_ustr), conditions[14].Value);
1307 CPPUNIT_ASSERT_EQUAL(u"OutlineLevel8"_ustr, conditions[15].Name);
1308 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Contents Heading"_ustr), conditions[15].Value);
1309 CPPUNIT_ASSERT_EQUAL(u"OutlineLevel9"_ustr, conditions[16].Name);
1310 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Standard"_ustr), conditions[16].Value);
1311 CPPUNIT_ASSERT_EQUAL(u"OutlineLevel10"_ustr, conditions[17].Name);
1312 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Drawing"_ustr), conditions[17].Value);
1313 CPPUNIT_ASSERT_EQUAL(u"NumberingLevel1"_ustr, conditions[18].Name);
1314 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Endnote"_ustr), conditions[18].Value);
1315 CPPUNIT_ASSERT_EQUAL(u"NumberingLevel2"_ustr, conditions[19].Name);
1316 CPPUNIT_ASSERT_EQUAL(uno::Any(u"First line indent"_ustr), conditions[19].Value);
1317 CPPUNIT_ASSERT_EQUAL(u"NumberingLevel3"_ustr, conditions[20].Name);
1318 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Footer"_ustr), conditions[20].Value);
1319 CPPUNIT_ASSERT_EQUAL(u"NumberingLevel4"_ustr, conditions[21].Name);
1320 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Footer left"_ustr), conditions[21].Value);
1321 CPPUNIT_ASSERT_EQUAL(u"NumberingLevel5"_ustr, conditions[22].Name);
1322 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Footer right"_ustr), conditions[22].Value);
1323 CPPUNIT_ASSERT_EQUAL(u"NumberingLevel6"_ustr, conditions[23].Name);
1324 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Footnote"_ustr), conditions[23].Value);
1325 CPPUNIT_ASSERT_EQUAL(u"NumberingLevel7"_ustr, conditions[24].Name);
1326 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Frame contents"_ustr), conditions[24].Value);
1327 CPPUNIT_ASSERT_EQUAL(u"NumberingLevel8"_ustr, conditions[25].Name);
1328 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Hanging indent"_ustr), conditions[25].Value);
1329 CPPUNIT_ASSERT_EQUAL(u"NumberingLevel9"_ustr, conditions[26].Name);
1330 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Header"_ustr), conditions[26].Value);
1331 CPPUNIT_ASSERT_EQUAL(u"NumberingLevel10"_ustr, conditions[27].Name);
1332 CPPUNIT_ASSERT_EQUAL(uno::Any(u"Header left"_ustr), conditions[27].Value);
1335 DECLARE_ODFEXPORT_TEST(testTextframeTransparentShadow, "textframe-transparent-shadow.odt")
1337 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1338 CPPUNIT_ASSERT_EQUAL(1, getPages());
1339 uno::Reference<drawing::XShape> xPicture = getShape(1);
1340 // ODF stores opacity of 75%, that means 25% transparency.
1341 CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty<sal_Int32>(xPicture, u"ShadowTransparence"_ustr));
1344 DECLARE_ODFEXPORT_TEST(testRelhPage, "relh-page.odt")
1346 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1347 CPPUNIT_ASSERT_EQUAL(1, getPages());
1348 uno::Reference<drawing::XShape> xTextFrame = getShape(1);
1349 // This was text::RelOrientation::FRAME (the default), RelativeHeightRelation was not handled in xmloff.
1350 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, u"RelativeHeightRelation"_ustr));
1351 // Make sure rel-height-rel doesn't affect width.
1352 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, u"RelativeWidthRelation"_ustr));
1354 // This was 2601, 20% height was relative from margin, not page.
1355 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1356 CPPUNIT_ASSERT_EQUAL(sal_Int32(3168), getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds", "height").toInt32());
1359 DECLARE_ODFEXPORT_TEST(testRelhPageTdf80282, "relh-page-tdf80282.odt")
1361 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1362 CPPUNIT_ASSERT_EQUAL(1, getPages());
1363 uno::Reference<drawing::XShape> xTextFrame = getShape(1);
1364 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1365 assertXPath(pXmlDoc, "//anchored/fly/infos/bounds", "height", u"8391");
1366 assertXPath(pXmlDoc, "//anchored/fly/infos/bounds", "width", u"5953");
1369 DECLARE_ODFEXPORT_TEST(testRelwPage, "relw-page.odt")
1371 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1372 CPPUNIT_ASSERT_EQUAL(1, getPages());
1373 uno::Reference<drawing::XShape> xTextFrame = getShape(1);
1374 // This was text::RelOrientation::FRAME (the default), RelativeWidthRelation was not handled in xmloff.
1375 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, u"RelativeWidthRelation"_ustr));
1376 // Make sure rel-width-rel doesn't affect height.
1377 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, u"RelativeHeightRelation"_ustr));
1379 // This was 3762, 40% width was relative from margin, not page.
1380 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1381 CPPUNIT_ASSERT_EQUAL(sal_Int32(4896), getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds", "width").toInt32());
1384 DECLARE_ODFEXPORT_TEST(testTextFrameVertAdjust, "textframe-vertadjust.odt")
1386 CPPUNIT_ASSERT_EQUAL(3, getShapes());
1387 CPPUNIT_ASSERT_EQUAL(1, getPages());
1388 // Test import/export of new frame attribute called TextVerticalAdjust
1390 // 1st frame's context is adjusted to the top
1391 uno::Reference<beans::XPropertySet> xFrame(getTextFrameByName(u"Rectangle 1"_ustr), uno::UNO_QUERY);
1392 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xFrame, u"TextVerticalAdjust"_ustr));
1393 // 2nd frame's context is adjusted to the center
1394 xFrame.set(getTextFrameByName(u"Rectangle 2"_ustr), uno::UNO_QUERY);
1395 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_CENTER, getProperty<drawing::TextVerticalAdjust>(xFrame, u"TextVerticalAdjust"_ustr));
1396 // 3rd frame's context is adjusted to the bottom
1397 xFrame.set(getTextFrameByName(u"Rectangle 3"_ustr), uno::UNO_QUERY);
1398 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM, getProperty<drawing::TextVerticalAdjust>(xFrame, u"TextVerticalAdjust"_ustr));
1401 DECLARE_ODFEXPORT_TEST(testTdf111891_frameVertStyle, "tdf111891_frameVertStyle.odt")
1403 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1404 CPPUNIT_ASSERT_EQUAL(1, getPages());
1405 uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY);
1406 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM, getProperty<drawing::TextVerticalAdjust>(xFrame, u"TextVerticalAdjust"_ustr));
1409 DECLARE_ODFEXPORT_TEST(testShapeRelsize, "shape-relsize.odt")
1411 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1412 CPPUNIT_ASSERT_EQUAL(1, getPages());
1413 uno::Reference<drawing::XShape> xShape = getShape(1);
1414 // These were all 0, as style:rel-width/height was ignored on import for shapes.
1415 CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(xShape, u"RelativeWidth"_ustr));
1416 CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(xShape, u"RelativeHeight"_ustr));
1418 // Relation was "page" for both width and height, should be "paragraph" for width.
1419 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, u"RelativeWidthRelation"_ustr));
1420 // And make sure that height stays "page".
1421 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, u"RelativeHeightRelation"_ustr));
1424 CPPUNIT_TEST_FIXTURE(Test, testTextboxRoundedCorners)
1426 auto verify = [this]() {
1427 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1428 CPPUNIT_ASSERT_EQUAL(1, getPages());
1429 uno::Reference<drawing::XShape> xShape = getShape(1);
1430 comphelper::SequenceAsHashMap aCustomShapeGeometry(getProperty< uno::Sequence<beans::PropertyValue> >(xShape, u"CustomShapeGeometry"_ustr));
1432 // Test that the shape is a rounded rectangle.
1433 CPPUNIT_ASSERT_EQUAL(u"round-rectangle"_ustr, aCustomShapeGeometry[u"Type"_ustr].get<OUString>());
1435 // The shape text should start with a table, with "a" in its A1 cell.
1436 uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
1437 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY);
1438 uno::Reference<text::XTextRange> xCell(xTable->getCellByName(u"A1"_ustr), uno::UNO_QUERY);
1439 CPPUNIT_ASSERT_EQUAL(u"a"_ustr, xCell->getString());
1442 createSwDoc("textbox-rounded-corners.odt");
1443 verify();
1444 saveAndReload(mpFilter);
1445 verify();
1447 // Table inside a textbox should be in the extension namespace.
1448 xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
1449 // This failed, as draw:custom-shape had a table:table child.
1450 assertXPath(pXmlDoc, "//draw:custom-shape/loext:table", "name", u"Table1");
1453 // test that import whitespace collapsing is compatible with old docs
1454 DECLARE_ODFEXPORT_TEST(testWhitespace, "whitespace.odt")
1456 CPPUNIT_ASSERT_EQUAL(4, getShapes());
1457 CPPUNIT_ASSERT_EQUAL(1, getPages());
1458 uno::Reference<container::XEnumerationAccess> xPara;
1459 uno::Reference<container::XEnumeration> xPortions;
1460 uno::Reference<text::XTextRange> xPortion;
1461 xPara.set(getParagraphOrTable(1), uno::UNO_QUERY);
1462 xPortions.set(xPara->createEnumeration());
1463 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1464 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1465 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1466 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1467 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1468 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xPortion->getString());
1469 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1470 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1471 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1472 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1474 xPara.set(getParagraphOrTable(2), uno::UNO_QUERY);
1475 xPortions.set(xPara->createEnumeration());
1476 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1477 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1478 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1479 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1480 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1481 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xPortion->getString());
1482 CPPUNIT_ASSERT_EQUAL(u"http://example.com/"_ustr, getProperty<OUString>(xPortion, u"HyperLinkURL"_ustr));
1483 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1484 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1485 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1486 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1488 xPara.set(getParagraphOrTable(3), uno::UNO_QUERY);
1489 xPortions.set(xPara->createEnumeration());
1490 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1491 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1492 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1493 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1494 CPPUNIT_ASSERT_EQUAL(u"Ruby"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1495 CPPUNIT_ASSERT_EQUAL(OUString(), xPortion->getString());
1496 CPPUNIT_ASSERT_EQUAL(u"foo"_ustr, getProperty<OUString>(xPortion, u"RubyText"_ustr));
1497 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1498 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1499 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xPortion->getString());
1500 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1501 CPPUNIT_ASSERT_EQUAL(u"Ruby"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1502 CPPUNIT_ASSERT_EQUAL(OUString(), xPortion->getString());
1503 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1504 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1505 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1506 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1508 xPara.set(getParagraphOrTable(4), uno::UNO_QUERY);
1509 xPortions.set(xPara->createEnumeration());
1510 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1511 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1512 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1513 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1514 CPPUNIT_ASSERT_EQUAL(u"InContentMetadata"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1516 // what a stupid idea to require recursively enumerating this
1517 uno::Reference<container::XEnumerationAccess> xMeta(
1518 getProperty<uno::Reference<text::XTextContent>>(xPortion, u"InContentMetadata"_ustr), uno::UNO_QUERY);
1519 uno::Reference<container::XEnumeration> xMetaPortions =
1520 xMeta->createEnumeration();
1521 uno::Reference<text::XTextRange> xMP(xMetaPortions->nextElement(), uno::UNO_QUERY);
1522 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xMP, u"TextPortionType"_ustr));
1523 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xMP->getString());
1524 CPPUNIT_ASSERT(!xMetaPortions->hasMoreElements());
1526 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1527 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1528 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1529 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1531 xPara.set(getParagraphOrTable(5), uno::UNO_QUERY);
1532 xPortions.set(xPara->createEnumeration());
1533 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1534 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1535 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1536 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1537 CPPUNIT_ASSERT_EQUAL(u"TextField"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1539 // what a stupid idea to require recursively enumerating this
1540 uno::Reference<container::XEnumerationAccess> xMeta(
1541 getProperty<uno::Reference<text::XTextContent>>(xPortion, u"TextField"_ustr), uno::UNO_QUERY);
1542 uno::Reference<container::XEnumeration> xMetaPortions =
1543 xMeta->createEnumeration();
1544 uno::Reference<text::XTextRange> xMP(xMetaPortions->nextElement(), uno::UNO_QUERY);
1545 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xMP, u"TextPortionType"_ustr));
1546 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xMP->getString());
1547 CPPUNIT_ASSERT(!xMetaPortions->hasMoreElements());
1549 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1550 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1551 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1552 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1554 xPara.set(getParagraphOrTable(7), uno::UNO_QUERY);
1555 xPortions.set(xPara->createEnumeration());
1556 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1557 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1558 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1559 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1560 CPPUNIT_ASSERT_EQUAL(u"Frame"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1561 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1562 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1563 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1564 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1566 xPara.set(getParagraphOrTable(8), uno::UNO_QUERY);
1567 xPortions.set(xPara->createEnumeration());
1568 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1569 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1570 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1571 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1572 CPPUNIT_ASSERT_EQUAL(u"Frame"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1573 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1574 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1575 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1576 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1578 xPara.set(getParagraphOrTable(9), uno::UNO_QUERY);
1579 xPortions.set(xPara->createEnumeration());
1580 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1581 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1582 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1583 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1584 CPPUNIT_ASSERT_EQUAL(u"Frame"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1585 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1586 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1587 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1588 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1590 xPara.set(getParagraphOrTable(10), uno::UNO_QUERY);
1591 uno::Reference<container::XContentEnumerationAccess> xCEA(xPara, uno::UNO_QUERY);
1592 uno::Reference<container::XEnumeration> xFrames(
1593 xCEA->createContentEnumeration(u"com.sun.star.text.TextContent"_ustr));
1594 xFrames->nextElement(); // one at-paragraph frame
1595 CPPUNIT_ASSERT(!xFrames->hasMoreElements());
1596 xPortions.set(xPara->createEnumeration());
1597 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1598 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1599 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1600 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1602 xPara.set(getParagraphOrTable(11), uno::UNO_QUERY);
1603 xPortions.set(xPara->createEnumeration());
1604 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1605 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1606 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1607 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1608 CPPUNIT_ASSERT_EQUAL(u"Footnote"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1609 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1610 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1611 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1612 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1614 xPara.set(getParagraphOrTable(12), uno::UNO_QUERY);
1615 xPortions.set(xPara->createEnumeration());
1616 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1617 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1618 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1619 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1620 CPPUNIT_ASSERT_EQUAL(u"TextField"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1621 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1622 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1623 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1624 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1626 xPara.set(getParagraphOrTable(13), uno::UNO_QUERY);
1627 xPortions.set(xPara->createEnumeration());
1628 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1629 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1630 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1631 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1632 CPPUNIT_ASSERT_EQUAL(u"Annotation"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1633 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1634 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1635 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xPortion->getString());
1636 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1637 CPPUNIT_ASSERT_EQUAL(u"AnnotationEnd"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1638 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1639 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1640 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1641 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1643 xPara.set(getParagraphOrTable(15), uno::UNO_QUERY);
1644 xPortions.set(xPara->createEnumeration());
1645 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1646 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1647 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1648 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1649 CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1650 CPPUNIT_ASSERT(getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1651 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1652 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1653 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1654 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1656 xPara.set(getParagraphOrTable(16), uno::UNO_QUERY);
1657 xPortions.set(xPara->createEnumeration());
1658 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1659 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1660 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1661 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1662 CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1663 CPPUNIT_ASSERT(!getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1664 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1665 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1666 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xPortion->getString());
1667 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1668 CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1669 CPPUNIT_ASSERT(!getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1670 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1671 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1672 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1673 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1675 xPara.set(getParagraphOrTable(17), uno::UNO_QUERY);
1676 xPortions.set(xPara->createEnumeration());
1677 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1678 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1679 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1680 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1681 CPPUNIT_ASSERT_EQUAL(u"Redline"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1682 CPPUNIT_ASSERT(!getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1683 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1684 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1685 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xPortion->getString());
1686 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1687 CPPUNIT_ASSERT_EQUAL(u"Redline"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1688 CPPUNIT_ASSERT(!getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1689 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1690 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1691 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1692 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1694 xPara.set(getParagraphOrTable(18), uno::UNO_QUERY);
1695 xPortions.set(xPara->createEnumeration());
1696 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1697 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1698 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1699 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1700 CPPUNIT_ASSERT_EQUAL(u"Redline"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1701 CPPUNIT_ASSERT(!getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1702 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1703 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1704 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xPortion->getString());
1705 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1706 CPPUNIT_ASSERT_EQUAL(u"Redline"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1707 CPPUNIT_ASSERT(!getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1708 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1709 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1710 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1711 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1713 xPara.set(getParagraphOrTable(19), uno::UNO_QUERY);
1714 xPortions.set(xPara->createEnumeration());
1715 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1716 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1717 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1718 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1719 CPPUNIT_ASSERT_EQUAL(u"ReferenceMark"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1720 CPPUNIT_ASSERT(getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1721 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1722 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1723 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1724 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1726 xPara.set(getParagraphOrTable(20), uno::UNO_QUERY);
1727 xPortions.set(xPara->createEnumeration());
1728 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1729 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1730 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1731 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1732 CPPUNIT_ASSERT_EQUAL(u"ReferenceMark"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1733 CPPUNIT_ASSERT(!getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1734 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1735 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1736 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xPortion->getString());
1737 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1738 CPPUNIT_ASSERT_EQUAL(u"ReferenceMark"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1739 CPPUNIT_ASSERT(!getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1740 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1741 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1742 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1743 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1745 xPara.set(getParagraphOrTable(21), uno::UNO_QUERY);
1746 xPortions.set(xPara->createEnumeration());
1747 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1748 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1749 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1750 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1751 CPPUNIT_ASSERT_EQUAL(u"DocumentIndexMark"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1752 CPPUNIT_ASSERT(getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1753 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1754 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1755 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1756 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1758 xPara.set(getParagraphOrTable(22), uno::UNO_QUERY);
1759 xPortions.set(xPara->createEnumeration());
1760 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1761 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1762 CPPUNIT_ASSERT_EQUAL(u"X "_ustr, xPortion->getString());
1763 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1764 CPPUNIT_ASSERT_EQUAL(u"DocumentIndexMark"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1765 CPPUNIT_ASSERT(!getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1766 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1767 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1768 CPPUNIT_ASSERT_EQUAL(u" "_ustr, xPortion->getString());
1769 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1770 CPPUNIT_ASSERT_EQUAL(u"DocumentIndexMark"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1771 CPPUNIT_ASSERT(!getProperty<bool>(xPortion, u"IsCollapsed"_ustr));
1772 xPortion.set(xPortions->nextElement(), uno::UNO_QUERY);
1773 CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(xPortion, u"TextPortionType"_ustr));
1774 CPPUNIT_ASSERT_EQUAL(u" X"_ustr, xPortion->getString());
1775 CPPUNIT_ASSERT(!xPortions->hasMoreElements());
1778 DECLARE_ODFEXPORT_TEST(testTdf136645, "tdf136645.odt")
1780 CPPUNIT_ASSERT_EQUAL(1, getPages());
1781 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1783 // Without the fix in place, this would have failed with
1784 //- Expected: 2640
1785 //- Actual : 3000
1786 CPPUNIT_ASSERT_EQUAL(sal_Int32(2640), getXPath(pXmlDoc, "/root/page/body/section/column[1]/body/infos/bounds", "width").toInt32());
1788 //- Expected: 6000
1789 //- Actual : 6360
1790 CPPUNIT_ASSERT_EQUAL(sal_Int32(6000), getXPath(pXmlDoc, "/root/page/body/section/column[2]/body/infos/bounds", "width").toInt32());
1793 DECLARE_ODFEXPORT_TEST(testBtlrCell, "btlr-cell.odt")
1795 CPPUNIT_ASSERT_EQUAL(1, getPages());
1796 // Without the accompanying fix in place, this test would have failed, as
1797 // the btlr text direction in the A1 cell was lost on ODF import and
1798 // export.
1799 uno::Reference<text::XTextTablesSupplier> xSupplier(mxComponent, uno::UNO_QUERY);
1800 uno::Reference<container::XNameAccess> xTables = xSupplier->getTextTables();
1801 uno::Reference<text::XTextTable> xTable(xTables->getByName(u"Table1"_ustr), uno::UNO_QUERY);
1802 uno::Reference<beans::XPropertySet> xA1(xTable->getCellByName(u"A1"_ustr), uno::UNO_QUERY);
1803 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, getProperty<sal_Int16>(xA1, u"WritingMode"_ustr));
1805 uno::Reference<beans::XPropertySet> xB1(xTable->getCellByName(u"B1"_ustr), uno::UNO_QUERY);
1806 auto nActual = getProperty<sal_Int16>(xB1, u"WritingMode"_ustr);
1807 CPPUNIT_ASSERT(nActual == text::WritingMode2::LR_TB || nActual == text::WritingMode2::CONTEXT);
1809 uno::Reference<beans::XPropertySet> xC1(xTable->getCellByName(u"C1"_ustr), uno::UNO_QUERY);
1810 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty<sal_Int16>(xC1, u"WritingMode"_ustr));
1813 CPPUNIT_TEST_FIXTURE(Test, testBtlrFrame)
1815 auto verify = [this](bool bIsExport = false) {
1816 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1817 CPPUNIT_ASSERT_EQUAL(1, getPages());
1818 // Without the accompanying fix in place, this test would have failed, as
1819 // the btlr text direction in the text frame was lost on ODF import and
1820 // export.
1821 uno::Reference<beans::XPropertySet> xTextFrame(getShape(1), uno::UNO_QUERY);
1822 CPPUNIT_ASSERT(xTextFrame.is());
1824 auto nActual = getProperty<sal_Int16>(xTextFrame, u"WritingMode"_ustr);
1825 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, nActual);
1827 // Without the accompanying fix in place, this test would have failed, as the fly frame had
1828 // mbVertical==true, but mbVertLRBT==false, even if the writing direction in the doc model was
1829 // btlr.
1830 SwDoc* pDoc = getSwDoc();
1832 SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
1833 CPPUNIT_ASSERT(pLayout);
1835 SwFrame* pPageFrame = pLayout->GetLower();
1836 CPPUNIT_ASSERT(pPageFrame);
1837 CPPUNIT_ASSERT(pPageFrame->IsPageFrame());
1839 SwFrame* pBodyFrame = pPageFrame->GetLower();
1840 CPPUNIT_ASSERT(pBodyFrame);
1841 CPPUNIT_ASSERT(pBodyFrame->IsBodyFrame());
1843 SwFrame* pBodyTextFrame = pBodyFrame->GetLower();
1844 CPPUNIT_ASSERT(pBodyTextFrame);
1845 CPPUNIT_ASSERT(pBodyTextFrame->IsTextFrame());
1847 CPPUNIT_ASSERT(pBodyTextFrame->GetDrawObjs());
1848 const SwSortedObjs& rAnchored = *pBodyTextFrame->GetDrawObjs();
1849 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rAnchored.size());
1851 auto* pFlyFrame = dynamic_cast<SwFlyFrame*>(rAnchored[0]);
1852 CPPUNIT_ASSERT(pFlyFrame);
1853 CPPUNIT_ASSERT(pFlyFrame->IsVertLRBT());
1855 if (!bIsExport)
1856 // Not yet exported, don't modify the doc model for test purposes.
1857 return;
1859 // Make sure that btlr -> tbrl transition clears the "BT" flag.
1860 xTextFrame->setPropertyValue(u"WritingMode"_ustr, uno::Any(text::WritingMode2::TB_LR));
1861 pFlyFrame = dynamic_cast<SwFlyFrame*>(rAnchored[0]);
1862 CPPUNIT_ASSERT(pFlyFrame);
1863 CPPUNIT_ASSERT(!pFlyFrame->IsVertLRBT());
1866 createSwDoc("btlr-frame.odt");
1867 verify();
1868 saveAndReload(mpFilter);
1869 verify(/*bIsExport*/ true);
1872 CPPUNIT_TEST_FIXTURE(Test, testTdf129520)
1874 loadAndReload("tdf129520.docx");
1875 CPPUNIT_ASSERT_EQUAL(1, getPages());
1876 CPPUNIT_ASSERT_EQUAL(u"M"_ustr, getParagraph(1)->getString());
1878 // Without this fix in place, this test would have failed with
1879 // - Expected: Ma
1880 // - Actual :
1881 CPPUNIT_ASSERT_EQUAL(u"Ma"_ustr, getParagraph(2)->getString());
1882 CPPUNIT_ASSERT_EQUAL(u"1815"_ustr, getParagraph(3)->getString());
1885 DECLARE_ODFEXPORT_TEST(testFdo86963, "fdo86963.odt")
1887 CPPUNIT_ASSERT_EQUAL(1, getPages());
1888 // Export of this document failed with beans::UnknownPropertyException.
1889 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1892 DECLARE_ODFEXPORT_TEST(testTdf135338_firstLeftPageFooter, "tdf135338_firstLeftPageFooter.odt")
1894 CPPUNIT_ASSERT_EQUAL(6, getPages());
1895 // The first page is a left page only style, but it should still show the first page footer
1896 // instead of the left footer text "EVEN/LEFT (Left page only)"
1897 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1898 assertXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()", u"First (Left page only)");
1901 DECLARE_ODFEXPORT_TEST(testGerrit13858, "gerrit13858.odt")
1903 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1904 CPPUNIT_ASSERT_EQUAL(1, getPages());
1905 // Just make sure the output is valid.
1907 DECLARE_ODFEXPORT_TEST(testOdtBorderTypes, "border_types.odt")
1909 CPPUNIT_ASSERT_EQUAL(1, getPages());
1910 static const sal_Int32 lineStyles[] = { 0, 1, 2, 14, 16, 17, 3, 15 };
1911 uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
1912 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(textDocument->getText(), uno::UNO_QUERY);
1913 // list of paragraphs
1914 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
1917 uno::Reference<lang::XServiceInfo> xServiceInfo;
1918 if (xParaEnum->nextElement() >>= xServiceInfo)
1920 if (xServiceInfo->supportsService(u"com.sun.star.text.TextTable"_ustr))
1922 uno::Reference<table::XCellRange> const xCellRange(xServiceInfo, uno::UNO_QUERY_THROW);
1924 for (sal_Int32 row = 0; row < 15; row += 2)
1926 uno::Reference<table::XCell> xCell = xCellRange->getCellByPosition(1, row);
1927 uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW);
1929 uno::Any aTopBorder = xPropSet->getPropertyValue(u"TopBorder"_ustr);
1930 table::BorderLine2 aTopBorderLine;
1931 if (aTopBorder >>= aTopBorderLine)
1933 sal_Int32 lineStyle = aTopBorderLine.LineStyle;
1934 CPPUNIT_ASSERT_EQUAL(lineStyles[row / 2], lineStyle);
1936 } //end of the 'for' loop
1939 } while (xParaEnum->hasMoreElements());
1942 DECLARE_ODFEXPORT_TEST(testMasterPageWithDrawingPage, "sw_hatch.odt")
1944 CPPUNIT_ASSERT_EQUAL(1, getPages());
1945 uno::Reference<container::XNameAccess> xStyles(getStyles(u"PageStyles"_ustr));
1946 uno::Reference<beans::XPropertySet> xStyle(xStyles->getByName(u"Standard"_ustr), uno::UNO_QUERY);
1947 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xStyle, u"FillStyle"_ustr));
1948 CPPUNIT_ASSERT_EQUAL(u"Blue -45 Degrees"_ustr, getProperty<OUString>(xStyle, u"FillHatchName"_ustr));
1949 CPPUNIT_ASSERT(!getProperty<sal_Bool>(xStyle, u"FillBackground"_ustr));
1950 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xStyle, u"FillTransparence"_ustr));
1953 CPPUNIT_TEST_FIXTURE(Test, testPageStyleBackgroundFullSizeOOo)
1955 loadAndReload("pagestyle_background_ooo33.odt");
1956 CPPUNIT_ASSERT_EQUAL(3, getPages());
1957 xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr);
1958 // Standard
1959 assertXPath(pXmlDoc,
1960 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1961 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
1962 "]/style:drawing-page-properties", "background-size", u"border");
1963 assertXPath(pXmlDoc,
1964 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1965 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
1966 "]/style:drawing-page-properties", "fill", u"solid");
1967 assertXPath(pXmlDoc,
1968 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1969 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
1970 "]/style:drawing-page-properties", "fill-color", u"#99ccff");
1971 assertXPath(pXmlDoc,
1972 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1973 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
1974 "]/style:drawing-page-properties", "opacity", u"100%");
1975 // Endnote
1976 assertXPath(pXmlDoc,
1977 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1978 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
1979 "]/style:drawing-page-properties", "background-size", u"border");
1980 assertXPath(pXmlDoc,
1981 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1982 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
1983 "]/style:drawing-page-properties", "fill", u"bitmap");
1984 assertXPath(pXmlDoc,
1985 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1986 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
1987 "]/style:drawing-page-properties", "repeat", u"repeat");
1988 assertXPath(pXmlDoc,
1989 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1990 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
1991 "]/style:drawing-page-properties", "fill-image-ref-point", u"top-left");
1992 // Footnote
1993 assertXPath(pXmlDoc,
1994 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1995 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
1996 "]/style:drawing-page-properties", "background-size", u"border");
1997 assertXPath(pXmlDoc,
1998 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1999 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2000 "]/style:drawing-page-properties", "fill", u"bitmap");
2001 assertXPath(pXmlDoc,
2002 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2003 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2004 "]/style:drawing-page-properties", "repeat", u"stretch");
2005 assertXPath(pXmlDoc,
2006 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2007 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2008 "]/style:drawing-page-properties", "fill-image-ref-point", u"top-left");
2011 CPPUNIT_TEST_FIXTURE(Test, testPageStyleBackgroundFullSizeLO64)
2013 loadAndReload("pagestyle_background_lo64.odt");
2014 CPPUNIT_ASSERT_EQUAL(6, getPages());
2015 xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr);
2016 // Standard
2017 assertXPath(pXmlDoc,
2018 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2019 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2020 "]/style:drawing-page-properties", "background-size", u"full");
2021 assertXPath(pXmlDoc,
2022 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2023 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2024 "]/style:drawing-page-properties", "fill", u"solid");
2025 assertXPath(pXmlDoc,
2026 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2027 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2028 "]/style:drawing-page-properties", "fill-color", u"#99ccff");
2029 assertXPath(pXmlDoc,
2030 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2031 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2032 "]/style:drawing-page-properties", "opacity", u"100%");
2033 // Endnote
2034 assertXPath(pXmlDoc,
2035 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2036 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2037 "]/style:drawing-page-properties", "background-size", u"full");
2038 assertXPath(pXmlDoc,
2039 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2040 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2041 "]/style:drawing-page-properties", "fill", u"bitmap");
2042 assertXPath(pXmlDoc,
2043 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2044 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2045 "]/style:drawing-page-properties", "repeat", u"repeat");
2046 assertXPath(pXmlDoc,
2047 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2048 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2049 "]/style:drawing-page-properties", "fill-image-ref-point", u"top-left");
2050 // Footnote
2051 assertXPath(pXmlDoc,
2052 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2053 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2054 "]/style:drawing-page-properties", "background-size", u"border");
2055 assertXPath(pXmlDoc,
2056 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2057 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2058 "]/style:drawing-page-properties", "fill", u"bitmap");
2059 assertXPath(pXmlDoc,
2060 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2061 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2062 "]/style:drawing-page-properties", "repeat", u"stretch");
2063 assertXPath(pXmlDoc,
2064 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2065 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2066 "]/style:drawing-page-properties", "fill-image-ref-point", u"top-left");
2067 // Landscape
2068 assertXPath(pXmlDoc,
2069 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2070 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2071 "]/style:drawing-page-properties", "background-size", u"border");
2072 assertXPath(pXmlDoc,
2073 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2074 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2075 "]/style:drawing-page-properties", "fill", u"bitmap");
2076 assertXPath(pXmlDoc,
2077 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2078 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2079 "]/style:drawing-page-properties", "repeat", u"no-repeat");
2080 assertXPath(pXmlDoc,
2081 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2082 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2083 "]/style:drawing-page-properties", "fill-image-ref-point", u"top-left");
2084 // Index
2085 assertXPath(pXmlDoc,
2086 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2087 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2088 "]/style:drawing-page-properties", "background-size", u"full");
2089 assertXPath(pXmlDoc,
2090 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2091 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2092 "]/style:drawing-page-properties", "fill", u"gradient");
2093 assertXPath(pXmlDoc,
2094 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2095 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2096 "]/style:drawing-page-properties", "gradient-step-count", u"0");
2097 assertXPath(pXmlDoc,
2098 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2099 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2100 "]/style:drawing-page-properties", "opacity", u"100%");
2101 // First Page
2102 assertXPath(pXmlDoc,
2103 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2104 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2105 "]/style:drawing-page-properties", "background-size", u"full");
2106 assertXPath(pXmlDoc,
2107 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2108 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2109 "]/style:drawing-page-properties", "fill", u"hatch");
2110 assertXPath(pXmlDoc,
2111 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2112 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2113 "]/style:drawing-page-properties", "fill-hatch-solid", u"false");
2114 assertXPath(pXmlDoc,
2115 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2116 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2117 "]/style:drawing-page-properties", "opacity", u"100%");
2120 CPPUNIT_TEST_FIXTURE(Test, testPageStyleBackgroundFullSizeLO70)
2122 loadAndReload("pagestyle_background_lo70.odt");
2123 CPPUNIT_ASSERT_EQUAL(6, getPages());
2124 xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr);
2125 // Standard
2126 assertXPath(pXmlDoc,
2127 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2128 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2129 "]/style:drawing-page-properties", "background-size", u"full");
2130 assertXPath(pXmlDoc,
2131 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2132 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2133 "]/style:drawing-page-properties", "fill", u"solid");
2134 assertXPath(pXmlDoc,
2135 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2136 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2137 "]/style:drawing-page-properties", "fill-color", u"#99ccff");
2138 assertXPath(pXmlDoc,
2139 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2140 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2141 "]/style:drawing-page-properties", "opacity", u"100%");
2142 // Endnote
2143 assertXPath(pXmlDoc,
2144 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2145 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2146 "]/style:drawing-page-properties", "background-size", u"full");
2147 assertXPath(pXmlDoc,
2148 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2149 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2150 "]/style:drawing-page-properties", "fill", u"bitmap");
2151 assertXPath(pXmlDoc,
2152 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2153 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2154 "]/style:drawing-page-properties", "repeat", u"repeat");
2155 assertXPath(pXmlDoc,
2156 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2157 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2158 "]/style:drawing-page-properties", "fill-image-ref-point", u"top-left");
2159 // Footnote
2160 assertXPath(pXmlDoc,
2161 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2162 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2163 "]/style:drawing-page-properties", "background-size", u"border");
2164 assertXPath(pXmlDoc,
2165 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2166 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2167 "]/style:drawing-page-properties", "fill", u"bitmap");
2168 assertXPath(pXmlDoc,
2169 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2170 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2171 "]/style:drawing-page-properties", "repeat", u"stretch");
2172 assertXPath(pXmlDoc,
2173 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2174 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2175 "]/style:drawing-page-properties", "fill-image-ref-point", u"top-left");
2176 // Landscape
2177 assertXPath(pXmlDoc,
2178 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2179 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2180 "]/style:drawing-page-properties", "background-size", u"border");
2181 assertXPath(pXmlDoc,
2182 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2183 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2184 "]/style:drawing-page-properties", "fill", u"bitmap");
2185 assertXPath(pXmlDoc,
2186 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2187 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2188 "]/style:drawing-page-properties", "repeat", u"no-repeat");
2189 assertXPath(pXmlDoc,
2190 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2191 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2192 "]/style:drawing-page-properties", "fill-image-ref-point", u"top-left");
2193 // Index
2194 assertXPath(pXmlDoc,
2195 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2196 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2197 "]/style:drawing-page-properties", "background-size", u"full");
2198 assertXPath(pXmlDoc,
2199 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2200 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2201 "]/style:drawing-page-properties", "fill", u"gradient");
2202 assertXPath(pXmlDoc,
2203 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2204 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2205 "]/style:drawing-page-properties", "gradient-step-count", u"0");
2206 assertXPath(pXmlDoc,
2207 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2208 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2209 "]/style:drawing-page-properties", "opacity", u"100%");
2210 // First Page
2211 assertXPath(pXmlDoc,
2212 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2213 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2214 "]/style:drawing-page-properties", "background-size", u"full");
2215 assertXPath(pXmlDoc,
2216 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2217 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2218 "]/style:drawing-page-properties", "fill", u"hatch");
2219 assertXPath(pXmlDoc,
2220 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2221 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2222 "]/style:drawing-page-properties", "fill-hatch-solid", u"false");
2223 assertXPath(pXmlDoc,
2224 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2225 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2226 "]/style:drawing-page-properties", "opacity", u"100%");
2229 CPPUNIT_TEST_FIXTURE(Test, testFillBitmapUnused)
2231 loadAndReload("fillbitmap3.odt");
2232 CPPUNIT_ASSERT_EQUAL(4, getShapes());
2233 CPPUNIT_ASSERT_EQUAL(1, getPages());
2234 // nav_5f_home and all its references are completely gone
2235 xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr);
2237 // paragraph style
2238 assertXPath(pXmlDoc,
2239 "/office:document-styles/office:styles/style:style[@style:name='Text_20_body']/loext:graphic-properties", "fill", u"solid");
2240 assertXPath(pXmlDoc,
2241 "/office:document-styles/office:styles/style:style[@style:name='Text_20_body']/loext:graphic-properties", "fill-color", u"#c0c0c0");
2242 assertXPath(pXmlDoc,
2243 "/office:document-styles/office:styles/style:style[@style:name='Text_20_body']/loext:graphic-properties[@draw:fill-image-name]", 0);
2245 // page style page-layout
2246 assertXPath(pXmlDoc,
2247 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:page-layout-properties", "fill", u"bitmap");
2248 assertXPath(pXmlDoc,
2249 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:page-layout-properties", "fill-image-name", u"nav_5f_up");
2250 assertXPath(pXmlDoc,
2251 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:header-style/style:header-footer-properties", "fill", u"bitmap");
2252 assertXPath(pXmlDoc,
2253 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:header-style/style:header-footer-properties", "fill-image-name", u"nav_5f_up");
2254 assertXPath(pXmlDoc,
2255 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:footer-style/style:header-footer-properties", "fill", u"bitmap");
2256 assertXPath(pXmlDoc,
2257 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:footer-style/style:header-footer-properties", "fill-image-name", u"nav_5f_up");
2259 assertXPath(pXmlDoc,
2260 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:page-layout-properties", "fill", u"solid");
2261 assertXPath(pXmlDoc,
2262 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:page-layout-properties[@draw:fill-image-name]", 0);
2263 assertXPath(pXmlDoc,
2264 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:header-style/style:header-footer-properties", "fill", u"solid");
2265 assertXPath(pXmlDoc,
2266 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:header-style/style:header-footer-properties[@draw:fill-image-name]", 0);
2267 assertXPath(pXmlDoc,
2268 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:footer-style/style:header-footer-properties", "fill", u"solid");
2269 assertXPath(pXmlDoc,
2270 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:footer-style/style:header-footer-properties[@draw:fill-image-name]", 0);
2272 // page style drawing-page
2273 assertXPath(pXmlDoc,
2274 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp1']/style:drawing-page-properties", "fill", u"bitmap");
2275 assertXPath(pXmlDoc,
2276 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp1']/style:drawing-page-properties", "fill-image-name", u"nav_5f_up");
2277 assertXPath(pXmlDoc,
2278 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/style:drawing-page-properties", "fill", u"solid");
2279 assertXPath(pXmlDoc,
2280 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/style:drawing-page-properties", "fill-color", u"#c0c0c0");
2281 assertXPath(pXmlDoc,
2282 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/style:drawing-page-properties[@draw:fill-image-name]", 0);
2284 // the named items
2285 assertXPath(pXmlDoc,
2286 "/office:document-styles/office:styles/draw:fill-image", 1);
2287 assertXPath(pXmlDoc,
2288 "/office:document-styles/office:styles/draw:fill-image", "name", u"nav_5f_up");
2291 DECLARE_ODFEXPORT_TEST(testCellUserDefineAttr, "userdefattr-tablecell.odt")
2293 CPPUNIT_ASSERT_EQUAL(1, getPages());
2294 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
2295 uno::Reference<table::XCell> const xCellA1(xTable->getCellByName(u"A1"_ustr), uno::UNO_SET_THROW);
2296 uno::Reference<table::XCell> const xCellB1(xTable->getCellByName(u"B1"_ustr), uno::UNO_SET_THROW);
2297 uno::Reference<table::XCell> const xCellC1(xTable->getCellByName(u"C1"_ustr), uno::UNO_SET_THROW);
2298 getUserDefineAttribute(uno::Any(xCellA1), u"proName"_ustr, u"v1"_ustr);
2299 getUserDefineAttribute(uno::Any(xCellB1), u"proName"_ustr, u"v2"_ustr);
2300 getUserDefineAttribute(uno::Any(xCellC1), u"proName"_ustr, u"v3"_ustr);
2303 CPPUNIT_TEST_FIXTURE(Test, testEmbeddedPdf)
2305 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
2306 if (!pPdfium)
2308 return;
2311 auto verify = [this]() {
2312 CPPUNIT_ASSERT_EQUAL(1, getShapes());
2313 CPPUNIT_ASSERT_EQUAL(1, getPages());
2314 uno::Reference<drawing::XShape> xShape = getShape(1);
2315 // This failed, pdf+png replacement graphics pair didn't survive an ODT roundtrip.
2316 auto xReplacementGraphic = getProperty<uno::Reference<graphic::XGraphic>>(xShape, u"ReplacementGraphic"_ustr);
2317 CPPUNIT_ASSERT(xReplacementGraphic.is());
2319 auto xGraphic = getProperty<uno::Reference<graphic::XGraphic>>(xShape, u"Graphic"_ustr);
2320 CPPUNIT_ASSERT(xGraphic.is());
2321 // This was image/x-vclgraphic, not exposing the info that the image is a PDF one.
2322 CPPUNIT_ASSERT_EQUAL(u"application/pdf"_ustr, getProperty<OUString>(xGraphic, u"MimeType"_ustr));
2325 createSwDoc("embedded-pdf.odt");
2326 verify();
2327 saveAndReload(mpFilter);
2328 verify();
2330 uno::Sequence<uno::Any> aArgs{ uno::Any(maTempFile.GetURL()) };
2331 uno::Reference<container::XNameAccess> xNameAccess(m_xSFactory->createInstanceWithArguments(u"com.sun.star.packages.zip.ZipFileAccess"_ustr, aArgs), uno::UNO_QUERY);
2332 bool bHasBitmap = false;
2333 const uno::Sequence<OUString> aNames = xNameAccess->getElementNames();
2334 for (const auto& rElementName : aNames)
2336 if (rElementName.startsWith("Pictures") && rElementName.endsWith("png"))
2338 bHasBitmap = true;
2339 break;
2342 // This failed, replacement was an svm file.
2343 CPPUNIT_ASSERT(bHasBitmap);
2346 DECLARE_ODFEXPORT_TEST(testTableStyles1, "table_styles_1.odt")
2348 CPPUNIT_ASSERT_EQUAL(1, getPages());
2349 // Table styles basic graphic test.
2350 // Doesn't cover all attributes.
2351 uno::Reference<style::XStyleFamiliesSupplier> XFamiliesSupplier(mxComponent, uno::UNO_QUERY);
2352 uno::Reference<container::XNameAccess> xFamilies(XFamiliesSupplier->getStyleFamilies());
2353 uno::Reference<container::XNameAccess> xCellFamily(xFamilies->getByName(u"CellStyles"_ustr), uno::UNO_QUERY);
2354 uno::Reference<beans::XPropertySet> xCell1Style;
2355 xCellFamily->getByName(u"Test style.1"_ustr) >>= xCell1Style;
2357 sal_Int32 nInt32 = 0xF0F0F0;
2358 table::BorderLine2 oBorder;
2360 CPPUNIT_ASSERT_EQUAL(Color(0xCC0000), getProperty<Color>(xCell1Style, u"BackColor"_ustr));
2361 xCell1Style->getPropertyValue(u"WritingMode"_ustr) >>= nInt32;
2362 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), nInt32);
2363 xCell1Style->getPropertyValue(u"VertOrient"_ustr) >>= nInt32;
2364 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32);
2365 xCell1Style->getPropertyValue(u"BorderDistance"_ustr) >>= nInt32;
2366 CPPUNIT_ASSERT_EQUAL(sal_Int32(97), nInt32);
2367 xCell1Style->getPropertyValue(u"LeftBorderDistance"_ustr) >>= nInt32;
2368 CPPUNIT_ASSERT_EQUAL(sal_Int32(97), nInt32);
2369 xCell1Style->getPropertyValue(u"RightBorderDistance"_ustr) >>= nInt32;
2370 CPPUNIT_ASSERT_EQUAL(sal_Int32(97), nInt32);
2371 xCell1Style->getPropertyValue(u"TopBorderDistance"_ustr) >>= nInt32;
2372 CPPUNIT_ASSERT_EQUAL(sal_Int32(97), nInt32);
2373 xCell1Style->getPropertyValue(u"BottomBorderDistance"_ustr) >>= nInt32;
2374 CPPUNIT_ASSERT_EQUAL(sal_Int32(97), nInt32);
2375 xCell1Style->getPropertyValue(u"RightBorder"_ustr) >>= oBorder;
2376 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), oBorder.Color);
2377 xCell1Style->getPropertyValue(u"LeftBorder"_ustr) >>= oBorder;
2378 CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(ColorTransparency, oBorder.Color));
2379 xCell1Style->getPropertyValue(u"TopBorder"_ustr) >>= oBorder;
2380 CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(ColorTransparency, oBorder.Color));
2381 xCell1Style->getPropertyValue(u"BottomBorder"_ustr) >>= oBorder;
2382 CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(ColorTransparency, oBorder.Color));
2385 DECLARE_ODFEXPORT_TEST(testTableStyles2, "table_styles_2.odt")
2387 CPPUNIT_ASSERT_EQUAL(1, getPages());
2388 // Table styles paragraph and char tests
2389 // Doesn't cover all attributes.
2390 // Problem: underline for table autoformat doesn't work.
2391 uno::Reference<style::XStyleFamiliesSupplier> XFamiliesSupplier(mxComponent, uno::UNO_QUERY);
2392 uno::Reference<container::XNameAccess> xFamilies(XFamiliesSupplier->getStyleFamilies());
2393 uno::Reference<container::XNameAccess> xTableFamily(xFamilies->getByName(u"TableStyles"_ustr), uno::UNO_QUERY);
2394 uno::Reference<container::XNameAccess> xTableStyle(xTableFamily->getByName(u"Test style2"_ustr), uno::UNO_QUERY);
2395 uno::Reference<beans::XPropertySet> xCell1Style;
2397 float fFloat = 0.;
2398 bool bBool = true;
2399 sal_Int16 nInt16 = 0xF0;
2400 sal_Int32 nInt32 = 0xF0F0F0;
2401 OUString sString;
2402 awt::FontSlant eCharPosture;
2404 // cell 1
2405 xTableStyle->getByName(u"first-row-start-column"_ustr) >>= xCell1Style;
2406 xCell1Style->getPropertyValue(u"ParaAdjust"_ustr) >>= nInt32;
2407 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32);
2408 CPPUNIT_ASSERT_EQUAL(Color(0xFF6600), getProperty<Color>(xCell1Style, u"CharColor"_ustr));
2409 xCell1Style->getPropertyValue(u"CharContoured"_ustr) >>= bBool;
2410 CPPUNIT_ASSERT_EQUAL(false, bBool);
2411 xCell1Style->getPropertyValue(u"CharShadowed"_ustr) >>= bBool;
2412 CPPUNIT_ASSERT_EQUAL(true, bBool);
2413 xCell1Style->getPropertyValue(u"CharStrikeout"_ustr) >>= nInt32;
2414 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nInt32);
2415 xCell1Style->getPropertyValue(u"CharUnderline"_ustr) >>= nInt32;
2416 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32);
2417 // underline color is not working for table autoformats
2418 // xCell1Style->getPropertyValue("CharUnderlineHasColor") >>= bBool;
2419 // CPPUNIT_ASSERT_EQUAL(bool(false), bBool);
2420 // xCell1Style->getPropertyValue("CharUnderlineColor") >>= nInt64;
2421 // CPPUNIT_ASSERT_EQUAL(sal_Int64(-1), nInt64);
2422 // standard font
2423 xCell1Style->getPropertyValue(u"CharHeight"_ustr) >>= fFloat;
2424 CPPUNIT_ASSERT_EQUAL(float(18.), fFloat);
2425 xCell1Style->getPropertyValue(u"CharWeight"_ustr) >>= fFloat;
2426 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat);
2427 xCell1Style->getPropertyValue(u"CharPosture"_ustr) >>= eCharPosture;
2428 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, eCharPosture);
2429 xCell1Style->getPropertyValue(u"CharFontName"_ustr) >>= sString;
2430 CPPUNIT_ASSERT_EQUAL(u"Courier"_ustr, sString);
2431 xCell1Style->getPropertyValue(u"CharFontStyleName"_ustr) >>= sString;
2432 CPPUNIT_ASSERT_EQUAL(OUString(), sString);
2433 xCell1Style->getPropertyValue(u"CharFontFamily"_ustr) >>= nInt16;
2434 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16);
2435 xCell1Style->getPropertyValue(u"CharFontPitch"_ustr) >>= nInt16;
2436 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nInt16);
2437 // cjk font
2438 xCell1Style->getPropertyValue(u"CharHeightAsian"_ustr) >>= fFloat;
2439 CPPUNIT_ASSERT_EQUAL(float(18.), fFloat);
2440 xCell1Style->getPropertyValue(u"CharWeightAsian"_ustr) >>= fFloat;
2441 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat);
2442 xCell1Style->getPropertyValue(u"CharPostureAsian"_ustr) >>= eCharPosture;
2443 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, eCharPosture);
2444 xCell1Style->getPropertyValue(u"CharFontNameAsian"_ustr) >>= sString;
2445 CPPUNIT_ASSERT_EQUAL(u"Courier"_ustr, sString);
2446 xCell1Style->getPropertyValue(u"CharFontStyleNameAsian"_ustr) >>= sString;
2447 CPPUNIT_ASSERT_EQUAL(u"Regularna"_ustr, sString);
2448 xCell1Style->getPropertyValue(u"CharFontFamilyAsian"_ustr) >>= nInt16;
2449 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16);
2450 xCell1Style->getPropertyValue(u"CharFontPitchAsian"_ustr) >>= nInt16;
2451 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nInt16);
2452 // ctl font
2453 xCell1Style->getPropertyValue(u"CharHeightComplex"_ustr) >>= fFloat;
2454 CPPUNIT_ASSERT_EQUAL(float(18.), fFloat);
2455 xCell1Style->getPropertyValue(u"CharWeightComplex"_ustr) >>= fFloat;
2456 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat);
2457 xCell1Style->getPropertyValue(u"CharPostureComplex"_ustr) >>= eCharPosture;
2458 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, eCharPosture);
2459 xCell1Style->getPropertyValue(u"CharFontNameComplex"_ustr) >>= sString;
2460 CPPUNIT_ASSERT_EQUAL(u"Courier"_ustr, sString);
2461 xCell1Style->getPropertyValue(u"CharFontStyleNameComplex"_ustr) >>= sString;
2462 CPPUNIT_ASSERT_EQUAL(u"Regularna"_ustr, sString);
2463 xCell1Style->getPropertyValue(u"CharFontFamilyComplex"_ustr) >>= nInt16;
2464 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16);
2465 xCell1Style->getPropertyValue(u"CharFontPitchComplex"_ustr) >>= nInt16;
2466 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nInt16);
2468 // cell 2
2469 xTableStyle->getByName(u"first-row"_ustr) >>= xCell1Style;
2470 xCell1Style->getPropertyValue(u"ParaAdjust"_ustr) >>= nInt32;
2471 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nInt32);
2472 CPPUNIT_ASSERT_EQUAL(Color(0x9900FF), getProperty<Color>(xCell1Style, u"CharColor"_ustr));
2473 xCell1Style->getPropertyValue(u"CharContoured"_ustr) >>= bBool;
2474 CPPUNIT_ASSERT_EQUAL(true, bBool);
2475 xCell1Style->getPropertyValue(u"CharShadowed"_ustr) >>= bBool;
2476 CPPUNIT_ASSERT_EQUAL(false, bBool);
2477 xCell1Style->getPropertyValue(u"CharStrikeout"_ustr) >>= nInt32;
2478 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32);
2479 xCell1Style->getPropertyValue(u"CharUnderline"_ustr) >>= nInt32;
2480 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nInt32);
2481 // underline color test place
2482 // standard font
2483 xCell1Style->getPropertyValue(u"CharHeight"_ustr) >>= fFloat;
2484 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat);
2485 xCell1Style->getPropertyValue(u"CharWeight"_ustr) >>= fFloat;
2486 CPPUNIT_ASSERT_EQUAL(float(150.), fFloat);
2487 xCell1Style->getPropertyValue(u"CharPosture"_ustr) >>= eCharPosture;
2488 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, eCharPosture);
2489 xCell1Style->getPropertyValue(u"CharFontName"_ustr) >>= sString;
2490 CPPUNIT_ASSERT_EQUAL(u"Liberation Serif"_ustr, sString);
2491 xCell1Style->getPropertyValue(u"CharFontStyleName"_ustr) >>= sString;
2492 CPPUNIT_ASSERT_EQUAL(OUString(), sString);
2493 xCell1Style->getPropertyValue(u"CharFontFamily"_ustr) >>= nInt16;
2494 CPPUNIT_ASSERT_EQUAL(sal_Int16(3), nInt16);
2495 xCell1Style->getPropertyValue(u"CharFontPitch"_ustr) >>= nInt16;
2496 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16);
2497 // cjk font
2498 xCell1Style->getPropertyValue(u"CharHeightAsian"_ustr) >>= fFloat;
2499 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat);
2500 xCell1Style->getPropertyValue(u"CharWeightAsian"_ustr) >>= fFloat;
2501 CPPUNIT_ASSERT_EQUAL(float(150.), fFloat);
2502 xCell1Style->getPropertyValue(u"CharPostureAsian"_ustr) >>= eCharPosture;
2503 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, eCharPosture);
2504 xCell1Style->getPropertyValue(u"CharFontNameAsian"_ustr) >>= sString;
2505 CPPUNIT_ASSERT_EQUAL(u"Liberation Serif"_ustr, sString);
2506 xCell1Style->getPropertyValue(u"CharFontStyleNameAsian"_ustr) >>= sString;
2507 CPPUNIT_ASSERT_EQUAL(u"Pogrubiona"_ustr, sString);
2508 xCell1Style->getPropertyValue(u"CharFontFamilyAsian"_ustr) >>= nInt16;
2509 CPPUNIT_ASSERT_EQUAL(sal_Int16(3), nInt16);
2510 xCell1Style->getPropertyValue(u"CharFontPitchAsian"_ustr) >>= nInt16;
2511 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16);
2512 // ctl font
2513 xCell1Style->getPropertyValue(u"CharHeightComplex"_ustr) >>= fFloat;
2514 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat);
2515 xCell1Style->getPropertyValue(u"CharWeightComplex"_ustr) >>= fFloat;
2516 CPPUNIT_ASSERT_EQUAL(float(150.), fFloat);
2517 xCell1Style->getPropertyValue(u"CharPostureComplex"_ustr) >>= eCharPosture;
2518 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, eCharPosture);
2519 xCell1Style->getPropertyValue(u"CharFontNameComplex"_ustr) >>= sString;
2520 CPPUNIT_ASSERT_EQUAL(u"Liberation Serif"_ustr, sString);
2521 xCell1Style->getPropertyValue(u"CharFontStyleNameComplex"_ustr) >>= sString;
2522 CPPUNIT_ASSERT_EQUAL(u"Pogrubiona"_ustr, sString);
2523 xCell1Style->getPropertyValue(u"CharFontFamilyComplex"_ustr) >>= nInt16;
2524 CPPUNIT_ASSERT_EQUAL(sal_Int16(3), nInt16);
2525 xCell1Style->getPropertyValue(u"CharFontPitchComplex"_ustr) >>= nInt16;
2526 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16);
2528 // cell 3
2529 xTableStyle->getByName(u"first-row-even-column"_ustr) >>= xCell1Style;
2530 xCell1Style->getPropertyValue(u"ParaAdjust"_ustr) >>= nInt32;
2531 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nInt32);
2532 CPPUNIT_ASSERT_EQUAL(COL_BLACK, getProperty<Color>(xCell1Style, u"CharColor"_ustr));
2533 xCell1Style->getPropertyValue(u"CharContoured"_ustr) >>= bBool;
2534 CPPUNIT_ASSERT_EQUAL(true, bBool);
2535 xCell1Style->getPropertyValue(u"CharShadowed"_ustr) >>= bBool;
2536 CPPUNIT_ASSERT_EQUAL(true, bBool);
2537 xCell1Style->getPropertyValue(u"CharStrikeout"_ustr) >>= nInt32;
2538 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32);
2539 xCell1Style->getPropertyValue(u"CharUnderline"_ustr) >>= nInt32;
2540 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), nInt32);
2541 // underline color test place
2542 // standard font
2543 xCell1Style->getPropertyValue(u"CharHeight"_ustr) >>= fFloat;
2544 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat);
2545 xCell1Style->getPropertyValue(u"CharWeight"_ustr) >>= fFloat;
2546 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat);
2547 xCell1Style->getPropertyValue(u"CharPosture"_ustr) >>= eCharPosture;
2548 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, eCharPosture);
2549 xCell1Style->getPropertyValue(u"CharFontName"_ustr) >>= sString;
2550 CPPUNIT_ASSERT_EQUAL(u"Open Sans"_ustr, sString);
2551 xCell1Style->getPropertyValue(u"CharFontStyleName"_ustr) >>= sString;
2552 CPPUNIT_ASSERT_EQUAL(OUString(), sString);
2553 xCell1Style->getPropertyValue(u"CharFontFamily"_ustr) >>= nInt16;
2554 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nInt16);
2555 xCell1Style->getPropertyValue(u"CharFontPitch"_ustr) >>= nInt16;
2556 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16);
2557 // cjk font
2558 xCell1Style->getPropertyValue(u"CharHeightAsian"_ustr) >>= fFloat;
2559 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat);
2560 xCell1Style->getPropertyValue(u"CharWeightAsian"_ustr) >>= fFloat;
2561 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat);
2562 xCell1Style->getPropertyValue(u"CharPostureAsian"_ustr) >>= eCharPosture;
2563 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, eCharPosture);
2564 xCell1Style->getPropertyValue(u"CharFontNameAsian"_ustr) >>= sString;
2565 CPPUNIT_ASSERT_EQUAL(u"Open Sans"_ustr, sString);
2566 xCell1Style->getPropertyValue(u"CharFontStyleNameAsian"_ustr) >>= sString;
2567 CPPUNIT_ASSERT_EQUAL(u"Kursywa"_ustr, sString);
2568 xCell1Style->getPropertyValue(u"CharFontFamilyAsian"_ustr) >>= nInt16;
2569 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nInt16);
2570 xCell1Style->getPropertyValue(u"CharFontPitchAsian"_ustr) >>= nInt16;
2571 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16);
2572 // ctl font
2573 xCell1Style->getPropertyValue(u"CharHeightComplex"_ustr) >>= fFloat;
2574 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat);
2575 xCell1Style->getPropertyValue(u"CharWeightComplex"_ustr) >>= fFloat;
2576 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat);
2577 xCell1Style->getPropertyValue(u"CharPostureComplex"_ustr) >>= eCharPosture;
2578 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, eCharPosture);
2579 xCell1Style->getPropertyValue(u"CharFontNameComplex"_ustr) >>= sString;
2580 CPPUNIT_ASSERT_EQUAL(u"Open Sans"_ustr, sString);
2581 xCell1Style->getPropertyValue(u"CharFontStyleNameComplex"_ustr) >>= sString;
2582 CPPUNIT_ASSERT_EQUAL(u"Kursywa"_ustr, sString);
2583 xCell1Style->getPropertyValue(u"CharFontFamilyComplex"_ustr) >>= nInt16;
2584 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nInt16);
2585 xCell1Style->getPropertyValue(u"CharFontPitchComplex"_ustr) >>= nInt16;
2586 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16);
2589 CPPUNIT_TEST_FIXTURE(Test, testTableStyles3)
2591 loadAndReload("table_styles_3.odt");
2592 CPPUNIT_ASSERT_EQUAL(1, getPages());
2593 // This test checks if default valued attributes aren't exported.
2594 xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr);
2596 // <style:paragraph-properties>
2597 // For this element the only exported attributes are: "border-left", "border-bottom"
2598 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "background-color");
2599 // border-left place
2600 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "border-right");
2601 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "border-top");
2602 // border-bottom place
2603 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding");
2604 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-left");
2605 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-right");
2606 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-top");
2607 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-bottom");
2608 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "writing-mode");
2610 // <style:paragraph-properties> should be absent, because it has only "text-align" attribute, which shouldn't be exported.
2611 // Assume that style:paragraph-properties and style:text-properties exists.
2612 assertXPathChildren(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']", 2);
2614 // <style:text-properties>
2615 // For this element the only exported attributes are: "use-window-font-color place", "font-size-asian", "font-name-asian", "font-family-asian", "font-name-complex", "font-family-complex"
2616 // use-window-font-color place
2617 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-shadow");
2618 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-outline");
2619 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-line-through-style");
2620 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-line-through-type");
2621 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-underline-style");
2622 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-underline-color");
2623 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-size");
2624 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-weight");
2625 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style");
2626 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-name");
2627 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family");
2628 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-name");
2629 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family-generic");
2630 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-pitch");
2631 // font-size-asian place
2632 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-weight-asian");
2633 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-asian");
2634 // font-name-asian place
2635 // font-family-asian place
2636 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-name-asian");
2637 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family-generic-asian");
2638 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-pitch-asian");
2639 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-size-complex");
2640 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-weight-complex");
2641 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-complex");
2642 // font-name-complex place
2643 // font-family-complex place
2644 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-name-complex");
2645 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family-generic-complex");
2646 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-pitch-complex");
2650 CPPUNIT_TEST_FIXTURE(Test, testTableStyles4)
2652 createSwDoc("table_styles_4.odt");
2653 // Test if loaded styles overwrite existing styles
2654 uno::Reference<style::XStyleFamiliesSupplier> XFamiliesSupplier(mxComponent, uno::UNO_QUERY);
2655 uno::Reference<container::XNameAccess> xFamilies(XFamiliesSupplier->getStyleFamilies());
2656 uno::Reference<container::XNameAccess> xTableFamily(xFamilies->getByName(u"TableStyles"_ustr), uno::UNO_QUERY);
2657 uno::Reference<container::XNameAccess> xTableStyle(xTableFamily->getByName(u"Green"_ustr), uno::UNO_QUERY);
2658 uno::Reference<beans::XPropertySet> xCell1Style;
2660 xTableStyle->getByName(u"first-row-start-column"_ustr) >>= xCell1Style;
2661 CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, getProperty<Color>(xCell1Style, u"BackColor"_ustr));
2664 CPPUNIT_TEST_FIXTURE(Test, testTableStyles5)
2666 loadAndReload("table_styles_5.odt");
2667 CPPUNIT_ASSERT_EQUAL(1, getPages());
2668 // Test if cell styles doesn't have a style:parent-style-name attribute.
2669 xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr);
2671 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.1']", "parent-style-name");
2672 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.2']", "parent-style-name");
2673 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.3']", "parent-style-name");
2674 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.4']", "parent-style-name");
2675 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.5']", "parent-style-name");
2676 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.6']", "parent-style-name");
2677 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.7']", "parent-style-name");
2678 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.8']", "parent-style-name");
2679 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.9']", "parent-style-name");
2680 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.10']", "parent-style-name");
2681 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.11']", "parent-style-name");
2682 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.12']", "parent-style-name");
2683 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.13']", "parent-style-name");
2684 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.14']", "parent-style-name");
2685 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.15']", "parent-style-name");
2686 assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.16']", "parent-style-name");
2690 CPPUNIT_TEST_FIXTURE(Test, testTdf145226)
2692 loadAndReload("tdf145226.fodt");
2693 CPPUNIT_ASSERT_EQUAL(1, getPages());
2694 xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
2696 assertXPathNoAttribute(pXmlDoc, "/office:document-content/office:body/office:text/table:table/table:table-row[1]", "style-name");
2697 assertXPathNoAttribute(pXmlDoc, "/office:document-content/office:body/office:text/table:table/table:table-row[2]", "style-name");
2698 assertXPathNoAttribute(pXmlDoc, "/office:document-content/office:body/office:text/table:table/table:table-row[3]", "style-name");
2699 assertXPathNoAttribute(pXmlDoc, "/office:document-content/office:body/office:text/table:table/table:table-row[4]", "style-name");
2702 DECLARE_ODFEXPORT_TEST(testTdf101710, "tdf101710.odt")
2704 CPPUNIT_ASSERT_EQUAL(1, getPages());
2705 // Test that number format of cell styles can be imported and exported.
2706 uno::Reference<beans::XPropertySet> xStyle(getStyles(u"CellStyles"_ustr)->getByName(u"Test Style.11"_ustr), uno::UNO_QUERY);
2707 CPPUNIT_ASSERT_EQUAL(sal_uInt32(10104), getProperty<sal_uInt32>(xStyle, u"NumberFormat"_ustr));
2710 CPPUNIT_TEST_FIXTURE(Test, testTdf129568)
2712 loadAndReload("tdf129568.fodt");
2713 // Test that export doesn't fail, and that style is imported and in use.
2714 uno::Reference<style::XStyle> xStyle(getStyles(u"CellStyles"_ustr)->getByName(u"Default Style.1"_ustr), uno::UNO_QUERY);
2715 CPPUNIT_ASSERT(xStyle->isInUse());
2716 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getProperty<Color>(xStyle, u"BackColor"_ustr));
2719 CPPUNIT_TEST_FIXTURE(Test, testTdf129568ui)
2721 loadAndReload("tdf129568-ui.fodt");
2722 // Same as above, but styles referenced by UI name.
2723 uno::Reference<style::XStyle> xStyle(getStyles(u"CellStyles"_ustr)->getByName(u"Default Style.1"_ustr), uno::UNO_QUERY);
2724 CPPUNIT_ASSERT(xStyle->isInUse());
2725 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getProperty<Color>(xStyle, u"BackColor"_ustr));
2728 DECLARE_ODFEXPORT_TEST(testTdf132642_keepWithNextTable, "tdf132642_keepWithNextTable.odt")
2730 // Since the row is very big, it should split over two pages.
2731 // Since up to this point we haven't tried to make it match MS formats, it should start on page 1.
2732 CPPUNIT_ASSERT_EQUAL_MESSAGE("Row splits over 2 pages", 2, getPages());
2735 DECLARE_ODFEXPORT_TEST(testArabicZeroNumberingRTF, "arabic-zero-numbering.rtf")
2737 auto xNumberingRules = getProperty<uno::Reference<container::XIndexAccess>>(
2738 getParagraph(1), u"NumberingRules"_ustr);
2739 comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
2740 // Without the accompanying fix in place, this test would have failed with:
2741 // - Expected: 64
2742 // - Actual : 4
2743 // i.e. numbering type was ARABIC, not ARABIC_ZERO.
2744 CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO),
2745 aMap[u"NumberingType"_ustr].get<sal_uInt16>());
2749 DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.docx")
2751 auto xNumberingRules
2752 = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), u"NumberingRules"_ustr);
2753 comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
2754 // Without the accompanying fix in place, this test would have failed with:
2755 // - Expected: 64
2756 // - Actual : 4
2757 // i.e. numbering type was ARABIC, not ARABIC_ZERO.
2758 CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO),
2759 aMap[u"NumberingType"_ustr].get<sal_uInt16>());
2762 DECLARE_ODFEXPORT_TEST(testArabicZero3Numbering, "arabic-zero3-numbering.docx")
2764 auto xNumberingRules
2765 = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), u"NumberingRules"_ustr);
2766 comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
2767 // Without the accompanying fix in place, this test would have failed with:
2768 // - Expected: 65
2769 // - Actual : 4
2770 // i.e. numbering type was ARABIC, not ARABIC_ZERO3.
2771 CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO3),
2772 aMap[u"NumberingType"_ustr].get<sal_uInt16>());
2775 DECLARE_ODFEXPORT_TEST(testArabicZero4Numbering, "arabic-zero4-numbering.docx")
2777 auto xNumberingRules
2778 = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), u"NumberingRules"_ustr);
2779 comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
2780 // Without the accompanying fix in place, this test would have failed with:
2781 // - Expected: 66
2782 // - Actual : 4
2783 // i.e. numbering type was ARABIC, not ARABIC_ZERO4.
2784 CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO4),
2785 aMap[u"NumberingType"_ustr].get<sal_uInt16>());
2788 DECLARE_ODFEXPORT_TEST(testArabicZero5Numbering, "arabic-zero5-numbering.docx")
2790 auto xNumberingRules
2791 = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), u"NumberingRules"_ustr);
2792 comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
2793 // Without the accompanying fix in place, this test would have failed with:
2794 // - Expected: 67
2795 // - Actual : 4
2796 // i.e. numbering type was ARABIC, not ARABIC_ZERO5.
2797 CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO5),
2798 aMap[u"NumberingType"_ustr].get<sal_uInt16>());
2801 CPPUNIT_TEST_FIXTURE(Test, testImageMimetype)
2803 loadAndReload("image-mimetype.odt");
2804 CPPUNIT_ASSERT_EQUAL(1, getShapes());
2805 CPPUNIT_ASSERT_EQUAL(1, getPages());
2806 // Test that the loext:mimetype attribute is written for exported images, tdf#109202
2807 xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
2808 // Original image (svg)
2809 assertXPath(pXmlDoc, "/office:document-content/office:body/office:text/text:p/draw:frame/draw:image[@draw:mime-type='image/svg+xml']");
2812 } // end of anonymous namespace
2813 CPPUNIT_PLUGIN_IMPLEMENT();
2814 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */