1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 #include <swmodeltestbase.hxx>
14 #include <com/sun/star/awt/FontSlant.hpp>
15 #include <com/sun/star/awt/Gradient2.hpp>
16 #include <com/sun/star/container/XIndexReplace.hpp>
17 #include <com/sun/star/drawing/FillStyle.hpp>
18 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
19 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
20 #include <com/sun/star/drawing/XGraphicExportFilter.hpp>
21 #include <com/sun/star/drawing/BarCode.hpp>
22 #include <com/sun/star/drawing/BarCodeErrorCorrection.hpp>
23 #include <com/sun/star/table/ShadowFormat.hpp>
24 #include <com/sun/star/table/XCellRange.hpp>
25 #include <com/sun/star/text/RelOrientation.hpp>
26 #include <com/sun/star/text/XDocumentIndex.hpp>
27 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
28 #include <com/sun/star/graphic/XGraphic.hpp>
29 #include <officecfg/Office/Common.hxx>
30 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
31 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
32 #include <com/sun/star/text/XTextField.hpp>
33 #include <com/sun/star/text/WritingMode2.hpp>
34 #include <com/sun/star/util/XModifiable.hpp>
35 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
36 #include <com/sun/star/container/XIndexContainer.hpp>
37 #include <com/sun/star/document/XStorageBasedDocument.hpp>
38 #include <com/sun/star/text/XTextFramesSupplier.hpp>
39 #include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
40 #include <com/sun/star/text/XTextDocument.hpp>
41 #include <com/sun/star/util/XRefreshable.hpp>
42 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
43 #include <com/sun/star/text/XTextTable.hpp>
45 #include <comphelper/storagehelper.hxx>
46 #include <comphelper/fileformat.h>
47 #include <comphelper/propertysequence.hxx>
48 #include <comphelper/documentconstants.hxx>
49 #include <unotools/streamwrap.hxx>
50 #include <svl/PasswordHelper.hxx>
51 #include <comphelper/sequenceashashmap.hxx>
52 #include <vcl/filter/PDFiumLibrary.hxx>
53 #include <comphelper/scopeguard.hxx>
54 #include <basegfx/utils/gradienttools.hxx>
55 #include <docmodel/uno/UnoGradientTools.hxx>
57 #include <docufld.hxx> // for SwHiddenTextField::ParseIfFieldDefinition() method call
58 #include <unoprnms.hxx>
59 #include <sortedobjs.hxx>
63 #include <unotxdoc.hxx>
65 #include <IDocumentLayoutAccess.hxx>
66 #include <rootfrm.hxx>
67 #include <o3tl/string_view.hxx>
69 class Test
: public SwModelTestBase
72 Test() : SwModelTestBase("/sw/qa/extras/odfexport/data/", "writer8") {}
75 CPPUNIT_TEST_FIXTURE(Test
, testMathObjectFlatExport
)
77 comphelper::ScopeGuard
g([this]() {
79 std::shared_ptr
<comphelper::ConfigurationChanges
> pBatch(
80 comphelper::ConfigurationChanges::create());
81 officecfg::Office::Common::Cache::Writer::OLE_Objects::set(20, pBatch
);
82 return pBatch
->commit();
84 mpFilter
= "OpenDocument Text Flat XML"; // doesn't happen with ODF package
85 std::shared_ptr
<comphelper::ConfigurationChanges
> pBatch(
86 comphelper::ConfigurationChanges::create());
87 officecfg::Office::Common::Cache::Writer::OLE_Objects::set(1, pBatch
);
89 loadAndReload("2_MathType3.docx");
91 uno::Reference
<util::XModifiable
> xModifiable(mxComponent
, uno::UNO_QUERY
);
92 CPPUNIT_ASSERT(!xModifiable
->isModified());
93 // see preTest(), set the OLE cache to 1 for this test
94 // and the problem was that the formulas that were in the cache
95 // (the second one) were lost
96 OUString
formula1(getFormula(getRun(getParagraph(1), 1)));
97 CPPUNIT_ASSERT_EQUAL(OUString(" size 12{1+1=2} {}"), formula1
);
98 OUString
formula2(getFormula(getRun(getParagraph(2), 1)));
99 CPPUNIT_ASSERT_EQUAL(OUString(" size 12{2+2=4} {}"), formula2
);
102 DECLARE_ODFEXPORT_TEST(testTdf144319
, "tdf144319.odt")
104 CPPUNIT_ASSERT_EQUAL(7, getShapes());
105 CPPUNIT_ASSERT_EQUAL(1, getPages());
106 OUString
formula1(getFormula(getRun(getParagraph(3), 1)));
107 CPPUNIT_ASSERT_EQUAL(OUString("{ x = frac { { - b +- sqrt { b ^ 2 - 4 a c } } } { { 2 a } } }"), formula1
);
108 OUString
formula2(getFormula(getRun(getParagraph(4), 1)));
109 CPPUNIT_ASSERT_EQUAL(OUString("{ sum csup n csub { i = 1 } i ^ 3 = left ( frac { { n left ( { n + 1 } right ) } } { 2 } right ) ^ 2 }"), formula2
);
110 OUString
formula3(getFormula(getRun(getParagraph(5), 1)));
111 CPPUNIT_ASSERT_EQUAL(OUString("{ sum ^ n _ { i = 1 } i ^ 3 = left ( frac { { n left ( { n + 1 } right ) } } { 2 } right ) ^ 2 }"), formula3
);
112 OUString
formula4(getFormula(getRun(getParagraph(6), 1)));
113 CPPUNIT_ASSERT_EQUAL(OUString("{ sum ^ n _ { i = 1 } i ^ 3 = left ( frac { { n left ( { n + 1 } right ) } } { 2 } right ) ^ 2 }"), formula4
);
115 // Without the fix in place, this test would have failed with
116 // - the property is of unexpected type or void: Model
117 OUString
formula5(getFormula(getRun(getParagraph(7), 1)));
118 CPPUNIT_ASSERT_EQUAL(OUString("{ y ^ 2 { nitalic m p } = left ( { x ^ 3 + 7 } right ) { nitalic m p } }"), formula5
);
121 static void testTdf43569_CheckIfFieldParse()
124 OUString paramCondition
;
128 SwHiddenTextField::ParseIfFieldDefinition(u
"IF A B C", paramCondition
, paramTrue
, paramFalse
);
130 CPPUNIT_ASSERT_EQUAL(OUString("A"), paramCondition
);
131 CPPUNIT_ASSERT_EQUAL(OUString("B"), paramTrue
);
132 CPPUNIT_ASSERT_EQUAL(OUString("C"), paramFalse
);
136 OUString paramCondition
;
140 SwHiddenTextField::ParseIfFieldDefinition(u
" IF AAA BBB CCC ", paramCondition
, paramTrue
, paramFalse
);
142 CPPUNIT_ASSERT_EQUAL(OUString("AAA"), paramCondition
);
143 CPPUNIT_ASSERT_EQUAL(OUString("BBB"), paramTrue
);
144 CPPUNIT_ASSERT_EQUAL(OUString("CCC"), paramFalse
);
148 OUString paramCondition
;
152 SwHiddenTextField::ParseIfFieldDefinition(u
" IF AAA \"BBB\" \"CCC\" ", paramCondition
, paramTrue
, paramFalse
);
154 CPPUNIT_ASSERT_EQUAL(OUString("AAA"), paramCondition
);
155 CPPUNIT_ASSERT_EQUAL(OUString("BBB"), paramTrue
);
156 CPPUNIT_ASSERT_EQUAL(OUString("CCC"), paramFalse
);
159 // true-case and false-case have spaces inside
161 OUString paramCondition
;
165 SwHiddenTextField::ParseIfFieldDefinition(u
" IF A A A \"B B B\" \"C C C\" ", paramCondition
, paramTrue
, paramFalse
);
167 CPPUNIT_ASSERT_EQUAL(OUString("A A A"), paramCondition
);
168 CPPUNIT_ASSERT_EQUAL(OUString("B B B"), paramTrue
);
169 CPPUNIT_ASSERT_EQUAL(OUString("C C C"), paramFalse
);
172 // true-case and false-case have leading/trailing space
174 OUString paramCondition
;
178 SwHiddenTextField::ParseIfFieldDefinition(u
"IF A1 A2 A3 \"B1 B2 \" \" C1 C2\" ", paramCondition
, paramTrue
, paramFalse
);
180 CPPUNIT_ASSERT_EQUAL(OUString("A1 A2 A3"), paramCondition
);
181 CPPUNIT_ASSERT_EQUAL(OUString("B1 B2 "), paramTrue
);
182 CPPUNIT_ASSERT_EQUAL(OUString(" C1 C2"), paramFalse
);
185 // true-case and false-case are empty
187 OUString paramCondition
;
191 SwHiddenTextField::ParseIfFieldDefinition(u
"IF condition \"\" \"\" ", paramCondition
, paramTrue
, paramFalse
);
193 CPPUNIT_ASSERT_EQUAL(OUString("condition"), paramCondition
);
194 CPPUNIT_ASSERT_EQUAL(OUString(""), paramTrue
);
195 CPPUNIT_ASSERT_EQUAL(OUString(""), paramFalse
);
199 // Input document contains only one IF-field,
200 // and it should be imported as com.sun.star.text.TextField.ConditionalText in any case,
201 // instead of insertion of the pair of two field-marks: <field:fieldmark-start> + <field:fieldmark-end>.
202 CPPUNIT_TEST_FIXTURE(Test
, testTdf43569
)
204 loadAndReload("tdf43569_conditionalfield.doc");
205 // check if our parser is valid
206 testTdf43569_CheckIfFieldParse();
208 // now check field creation during import
209 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
210 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
211 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
213 // at least one field should be detected
214 CPPUNIT_ASSERT(xFields
->hasMoreElements());
217 CPPUNIT_TEST_FIXTURE(Test
, testTdf130314
)
219 loadAndReload("tdf130314.docx");
220 // Without the fix in place, this test would have hung
221 CPPUNIT_ASSERT_EQUAL(2, getPages());
224 CPPUNIT_TEST_FIXTURE(Test
, testTdf133487
)
226 loadAndReload("MadeByLO7.odt");
227 CPPUNIT_ASSERT_EQUAL(3, getShapes());
228 CPPUNIT_ASSERT_EQUAL(1, getPages());
229 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
230 // shape in background has lowest index
231 assertXPath(pXmlDoc
, "/office:document-content/office:body/office:text/text:p[2]/draw:custom-shape", "z-index", "0");
232 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", "background");
233 // shape in foreground, previously index 1
234 assertXPath(pXmlDoc
, "/office:document-content/office:body/office:text/text:p[1]/draw:custom-shape", "z-index", "2");
235 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", "foreground");
236 // shape in foreground, previously index 0
237 assertXPath(pXmlDoc
, "/office:document-content/office:body/office:text/text:p[3]/draw:custom-shape", "z-index", "1");
238 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", "foreground");
241 CPPUNIT_TEST_FIXTURE(Test
, testTdf141467
)
243 loadAndReload("Formcontrol needs high z-index.odt");
244 CPPUNIT_ASSERT_EQUAL(2, getShapes());
245 CPPUNIT_ASSERT_EQUAL(1, getPages());
246 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
247 // shape in foreground has lowest index
248 assertXPath(pXmlDoc
, "/office:document-content/office:body/office:text/text:p[2]/draw:custom-shape", "z-index", "0");
249 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", "foreground");
250 // form control, previously index 0
251 assertXPath(pXmlDoc
, "/office:document-content/office:body/office:text/text:p[2]/draw:control", "z-index", "1");
252 // no run-through on form's style
253 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);
256 DECLARE_ODFEXPORT_TEST(testTdf139126
, "tdf139126.odt")
258 CPPUNIT_ASSERT_EQUAL(1, getPages());
259 uno::Reference
<text::XTextTablesSupplier
> xSupplier(mxComponent
, uno::UNO_QUERY
);
260 uno::Reference
<container::XNameAccess
> xTables
= xSupplier
->getTextTables();
261 uno::Reference
<text::XTextTable
> xTable(xTables
->getByName("Table1"), uno::UNO_QUERY
);
263 uno::Reference
<text::XTextRange
> xD2(xTable
->getCellByName("D2"), uno::UNO_QUERY
);
264 CPPUNIT_ASSERT_EQUAL(OUString("4.0"), xD2
->getString());
266 // Without the fix in place, this test would have failed with
267 // - Expected: ** Expression is faulty **
268 // - Actual : 17976931348623200...
269 uno::Reference
<text::XTextRange
> xE2(xTable
->getCellByName("E2"), uno::UNO_QUERY
);
270 CPPUNIT_ASSERT_EQUAL(OUString("** Expression is faulty **"), xE2
->getString());
273 CPPUNIT_TEST_FIXTURE(Test
, testTdf125877
)
275 loadAndReload("tdf95806.docx");
276 CPPUNIT_ASSERT_EQUAL(1, getPages());
277 uno::Reference
<text::XTextTablesSupplier
> xSupplier(mxComponent
, uno::UNO_QUERY
);
278 uno::Reference
<container::XIndexAccess
> xTables(xSupplier
->getTextTables(), uno::UNO_QUERY
);
280 // This was 0 (lost table during ODT export in footnotes)
281 // Note: fix also tdf#95806: painting table layout is correct
282 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables
->getCount());
284 // floating table: there is a frame now
285 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
286 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
287 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess
->getCount());
290 CPPUNIT_TEST_FIXTURE(Test
, testTdf150149
)
292 loadAndReload("tdf150149.fodt");
293 CPPUNIT_ASSERT_EQUAL(1, getPages());
294 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
295 // This was 0 (lost table header in multi-column section)
296 assertXPath(pXmlDoc
, "//table:table-header-rows", 1);
297 assertXPath(pXmlDoc
, "//table:table-header-rows/table:table-row/table:table-cell", 3);
300 DECLARE_ODFEXPORT_TEST(testTdf103567
, "tdf103567.odt")
302 CPPUNIT_ASSERT_EQUAL(1, getShapes());
303 CPPUNIT_ASSERT_EQUAL(1, getPages());
304 uno::Reference
<drawing::XShape
> const xShape(getShape(1));
306 // contour wrap polygon
307 css::drawing::PointSequenceSequence
const pointss(
308 getProperty
<css::drawing::PointSequenceSequence
>(xShape
, "ContourPolyPolygon"));
309 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pointss
.getLength());
310 // for some reason this property exists with 199 points if it wasn't
311 // imported, that would be a fail
312 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), pointss
[0].getLength());
313 CPPUNIT_ASSERT_EQUAL(sal_Int32( 0), pointss
[0][0].X
);
314 CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss
[0][0].Y
);
315 CPPUNIT_ASSERT_EQUAL(sal_Int32( 0), pointss
[0][1].X
);
316 CPPUNIT_ASSERT_EQUAL(sal_Int32(1111), pointss
[0][1].Y
);
317 CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss
[0][2].X
);
318 CPPUNIT_ASSERT_EQUAL(sal_Int32(1111), pointss
[0][2].Y
);
319 CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss
[0][3].X
);
320 CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss
[0][3].Y
);
321 CPPUNIT_ASSERT_EQUAL(sal_Int32( 0), pointss
[0][4].X
);
322 CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss
[0][4].Y
);
324 // image map, one rectangle
325 uno::Reference
<container::XIndexContainer
> const xImageMap(
326 getProperty
<uno::Reference
<container::XIndexContainer
>>(xShape
, "ImageMap"));
328 uno::Reference
<beans::XPropertySet
> const xEntry(xImageMap
->getByIndex(0), uno::UNO_QUERY
);
329 CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/"), getProperty
<OUString
>(xEntry
, "URL"));
330 awt::Rectangle
const rect(getProperty
<awt::Rectangle
>(xEntry
, "Boundary"));
331 CPPUNIT_ASSERT_EQUAL(sal_Int32( 726), rect
.X
);
332 CPPUNIT_ASSERT_EQUAL(sal_Int32(1718), rect
.Y
);
333 CPPUNIT_ASSERT_EQUAL(sal_Int32(1347), rect
.Width
);
334 CPPUNIT_ASSERT_EQUAL(sal_Int32( 408), rect
.Height
);
337 CPPUNIT_TEST_FIXTURE(Test
, testUserFieldDecl
)
339 loadAndReload("user-field-decl.odt");
340 CPPUNIT_ASSERT_EQUAL(1, getPages());
341 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
342 // Without the accompanying fix in place, this test would have failed with 'Expected: 2;
343 // Actual: 1', i.e. the in-table field had no declaration (in the header), while the
344 // outside-table one had the declaration.
345 assertXPath(pXmlDoc
, "//style:header/text:user-field-decls/text:user-field-decl", 2);
348 CPPUNIT_TEST_FIXTURE(Test
, testUserFieldDeclFly
)
350 loadAndReload("user-field-decl-fly.odt");
351 CPPUNIT_ASSERT_EQUAL(1, getShapes());
352 CPPUNIT_ASSERT_EQUAL(1, getPages());
353 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
354 // Without the accompanying fix in place, this test would have failed with 'Expected: 2;
355 // Actual: 1', i.e. the in-textframe field had no declaration (in the header), while the
356 // outside-textframe one had the declaration.
357 assertXPath(pXmlDoc
, "//style:header/text:user-field-decls/text:user-field-decl", 2);
360 DECLARE_ODFEXPORT_TEST(testFramebackgrounds
, "framebackgrounds.odt")
362 CPPUNIT_ASSERT_EQUAL(16, getShapes());
363 CPPUNIT_ASSERT_EQUAL(1, getPages());
364 //Counting the Number of Frames and checking with the expected count
365 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
366 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
367 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), xIndexAccess
->getCount());
368 uno::Reference
<drawing::XShape
> xTextFrame
;
369 awt::Gradient aGradientxTextFrame
;
371 xTextFrame
= getShape(1);
372 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
373 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
375 xTextFrame
= getShape(2);
376 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
377 CPPUNIT_ASSERT_EQUAL(Color(0x006600), getProperty
<Color
>(xTextFrame
, "FillColor"));
378 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
380 xTextFrame
= getShape(3);
381 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
382 CPPUNIT_ASSERT_EQUAL(Color(0x006600), getProperty
<Color
>(xTextFrame
, "FillColor"));
383 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
385 xTextFrame
= getShape(4);
386 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
387 CPPUNIT_ASSERT_EQUAL(Color(0x579D1C), getProperty
<Color
>(xTextFrame
, "FillColor"));
388 aGradientxTextFrame
= getProperty
<awt::Gradient
>(xTextFrame
, "FillTransparenceGradient");
389 CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR
, aGradientxTextFrame
.Style
);
391 xTextFrame
= getShape(5);
392 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
393 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
394 CPPUNIT_ASSERT_EQUAL(OUString("Subtle Tango Green"), getProperty
<OUString
>(xTextFrame
, "FillGradientName"));
396 xTextFrame
= getShape(6);
397 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
398 CPPUNIT_ASSERT_EQUAL(OUString("Subtle Tango Green"), getProperty
<OUString
>(xTextFrame
, "FillGradientName"));
399 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
401 xTextFrame
= getShape(7);
402 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
403 CPPUNIT_ASSERT_EQUAL(OUString("Subtle Tango Green"), getProperty
<OUString
>(xTextFrame
, "FillGradientName"));
404 aGradientxTextFrame
= getProperty
<awt::Gradient
>(xTextFrame
, "FillTransparenceGradient");
405 CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR
, aGradientxTextFrame
.Style
);
407 xTextFrame
= getShape(8);
408 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
409 CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty
<OUString
>(xTextFrame
, "FillHatchName"));
410 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xTextFrame
, "FillBackground"));
411 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
413 xTextFrame
= getShape(9);
414 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
415 CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty
<OUString
>(xTextFrame
, "FillHatchName"));
416 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xTextFrame
, "FillBackground"));
417 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
419 xTextFrame
= getShape(10);
420 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
421 CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty
<OUString
>(xTextFrame
, "FillHatchName"));
422 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xTextFrame
, "FillBackground"));
423 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
425 xTextFrame
= getShape(11);
426 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
427 CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty
<OUString
>(xTextFrame
, "FillHatchName"));
428 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xTextFrame
, "FillBackground"));
429 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
431 xTextFrame
= getShape(12);
432 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
433 CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty
<OUString
>(xTextFrame
, "FillHatchName"));
434 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xTextFrame
, "FillBackground"));
435 aGradientxTextFrame
= getProperty
<awt::Gradient
>(xTextFrame
, "FillTransparenceGradient");
436 CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR
, aGradientxTextFrame
.Style
);
438 xTextFrame
= getShape(13);
439 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
440 CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty
<OUString
>(xTextFrame
, "FillHatchName"));
441 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xTextFrame
, "FillBackground"));
442 aGradientxTextFrame
= getProperty
<awt::Gradient
>(xTextFrame
, "FillTransparenceGradient");
443 CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR
, aGradientxTextFrame
.Style
);
445 xTextFrame
= getShape(14);
446 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
447 CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty
<OUString
>(xTextFrame
, "FillBitmapName"));
448 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
449 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapPositionOffsetX"));
450 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapPositionOffsetY"));
451 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapOffsetX"));
452 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapOffsetY"));
453 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xTextFrame
, "FillBitmapTile"));
455 xTextFrame
= getShape(15);
456 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
457 CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty
<OUString
>(xTextFrame
, "FillBitmapName"));
458 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty
<sal_Int32
>(xTextFrame
, "FillTransparence"));
459 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapPositionOffsetX"));
460 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapPositionOffsetY"));
461 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapOffsetX"));
462 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapOffsetY"));
463 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xTextFrame
, "FillBitmapTile"));
465 xTextFrame
= getShape(16);
466 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, getProperty
<drawing::FillStyle
>(xTextFrame
, "FillStyle"));
467 CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty
<OUString
>(xTextFrame
, "FillBitmapName"));
468 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapPositionOffsetX"));
469 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapPositionOffsetY"));
470 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapOffsetX"));
471 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xTextFrame
, "FillBitmapOffsetY"));
472 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xTextFrame
, "FillBitmapTile"));
473 aGradientxTextFrame
= getProperty
<awt::Gradient
>(xTextFrame
, "FillTransparenceGradient");
474 CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR
, aGradientxTextFrame
.Style
);
478 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
479 // check that there are 3 background-image elements
480 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);
481 // tdf#90640: check that one of them is 55% opaque
482 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);
483 // tdf#90640: check that one of them is 43% opaque
484 // (emulated - hopefully not with rounding errors)
485 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);
489 DECLARE_SW_ROUNDTRIP_TEST(testSHA1Correct
, "sha1_correct.odt", "1012345678901234567890123456789012345678901234567890", Test
)
490 { // tdf#114939 this has both an affected password as well as content.xml
491 CPPUNIT_ASSERT_EQUAL(1, getPages());
492 getParagraph(1, "012");
495 DECLARE_SW_ROUNDTRIP_TEST(testSHA1Wrong
, "sha1_wrong.odt", "1012345678901234567890123456789012345678901234567890", Test
)
496 { // tdf#114939 this has both an affected password as well as content.xml
497 CPPUNIT_ASSERT_EQUAL(1, getPages());
498 getParagraph(1, "012");
501 CPPUNIT_TEST_FIXTURE(Test
, testOOoxmlEmbedded
)
503 loadAndReload("oooxml_embedded.sxw");
504 uno::Reference
<text::XTextEmbeddedObjectsSupplier
> xTEOSupplier(mxComponent
, uno::UNO_QUERY
);
505 uno::Reference
<container::XNameAccess
> xAccess(xTEOSupplier
->getEmbeddedObjects());
506 uno::Sequence
<OUString
> aSeq(xAccess
->getElementNames());
507 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aSeq
.getLength());
508 uno::Reference
<document::XEmbeddedObjectSupplier
> xEOSupplier1(xAccess
->getByName("Object1"), uno::UNO_QUERY
);
509 uno::Reference
<lang::XComponent
> xObj1(xEOSupplier1
->getEmbeddedObject());
510 uno::Reference
<document::XEmbeddedObjectSupplier
> xEOSupplier2(xAccess
->getByName("Object2"), uno::UNO_QUERY
);
511 uno::Reference
<lang::XComponent
> xObj2(xEOSupplier2
->getEmbeddedObject());
512 uno::Reference
<document::XEmbeddedObjectSupplier
> xEOSupplier3(xAccess
->getByName("Object3"), uno::UNO_QUERY
);
513 uno::Reference
<lang::XComponent
> xObj3(xEOSupplier3
->getEmbeddedObject());
514 uno::Reference
<document::XEmbeddedObjectSupplier
> xEOSupplier4(xAccess
->getByName("Object4"), uno::UNO_QUERY
);
515 uno::Reference
<lang::XComponent
> xObj4(xEOSupplier4
->getEmbeddedObject());
516 //checking first object
517 uno::Reference
<document::XStorageBasedDocument
> xSBDoc1(xObj1
, uno::UNO_QUERY
);
518 uno::Reference
<embed::XStorage
> xStorage1(xSBDoc1
->getDocumentStorage());
519 CPPUNIT_ASSERT_EQUAL(sal_Int32(SOFFICE_FILEFORMAT_8
), comphelper::OStorageHelper::GetXStorageFormat(xStorage1
));
520 //checking second object
521 uno::Reference
<document::XStorageBasedDocument
> xSBDoc2(xObj2
, uno::UNO_QUERY
);
522 uno::Reference
<embed::XStorage
> xStorage2(xSBDoc2
->getDocumentStorage());
523 CPPUNIT_ASSERT_EQUAL(sal_Int32(SOFFICE_FILEFORMAT_8
), comphelper::OStorageHelper::GetXStorageFormat(xStorage2
));
524 //checking third object
525 uno::Reference
<document::XStorageBasedDocument
> xSBDoc3(xObj3
, uno::UNO_QUERY
);
526 uno::Reference
<embed::XStorage
> xStorage3(xSBDoc3
->getDocumentStorage());
527 CPPUNIT_ASSERT_EQUAL(sal_Int32(SOFFICE_FILEFORMAT_8
), comphelper::OStorageHelper::GetXStorageFormat(xStorage3
));
528 //checking fourth object
529 uno::Reference
<document::XStorageBasedDocument
> xSBDoc4(xObj4
, uno::UNO_QUERY
);
530 uno::Reference
<embed::XStorage
> xStorage4(xSBDoc4
->getDocumentStorage());
531 CPPUNIT_ASSERT_EQUAL(sal_Int32(SOFFICE_FILEFORMAT_8
), comphelper::OStorageHelper::GetXStorageFormat(xStorage4
));
534 DECLARE_ODFEXPORT_TEST(testTdf152710
, "tdf152710.odt")
536 // Without this fix in place, this test would have crash at import time
537 CPPUNIT_ASSERT_EQUAL(2, getPages());
540 DECLARE_ODFEXPORT_TEST(testredlineTextFrame
, "redlineTextFrame.odt")
542 CPPUNIT_ASSERT_EQUAL(2, getShapes());
543 CPPUNIT_ASSERT_EQUAL(1, getPages());
544 //Note this is for a crash test
545 //Counting the Number of Frames and checking with the expected count
546 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
547 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
548 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess
->getCount());
551 DECLARE_ODFEXPORT_TEST(testTdf107292
, "tdf107292.odt")
553 // tracked deletions at the same position were loaded in reverse order
554 CPPUNIT_ASSERT_EQUAL(1, getPages());
556 // Without this fix in place, this test would have failed with
557 // - Expected: Lorem ipsum dolor sit...
558 // - Actual : dolor ipsumLorem sit...
559 CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum dolor sit..."), getParagraph(1)->getString());
562 DECLARE_ODFEXPORT_TEST(testTdf140437
, "tdf140437.odt")
564 // Without the fix in place, the document would have failed to load
565 CPPUNIT_ASSERT_EQUAL(1, getPages());
567 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
568 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
569 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
571 // at least one field should be detected
572 CPPUNIT_ASSERT(xFields
->hasMoreElements());
575 CPPUNIT_TEST_FIXTURE(Test
, testTdf131621
)
577 loadAndReload("tdf131621.ott");
578 CPPUNIT_ASSERT_EQUAL(12, getShapes());
579 //Crash test, Check number of pages
580 CPPUNIT_ASSERT_EQUAL( 1, getPages() );
583 CPPUNIT_TEST_FIXTURE(Test
, testTdf135144
)
585 loadAndReload("tdf135144.docx");
586 //Crashes at import time after roundtrip
587 CPPUNIT_ASSERT_EQUAL(3, getPages());
588 CPPUNIT_ASSERT_EQUAL(4, getShapes());
591 DECLARE_ODFEXPORT_TEST(testTdf130950
, "tdf130950.odt")
593 //Crashes at import time
594 CPPUNIT_ASSERT_EQUAL(1, getPages());
595 CPPUNIT_ASSERT_EQUAL(2, getShapes());
598 DECLARE_ODFEXPORT_TEST(testFdo38244
, "fdo38244.odt")
600 CPPUNIT_ASSERT_EQUAL(1, getPages());
601 // See ooxmlexport's testFdo38244().
603 // Test comment range feature.
604 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
605 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
606 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
607 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
608 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
609 xRunEnum
->nextElement();
610 uno::Reference
<beans::XPropertySet
> xPropertySet(xRunEnum
->nextElement(), uno::UNO_QUERY
);
611 CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty
<OUString
>(xPropertySet
, "TextPortionType"));
612 xRunEnum
->nextElement();
613 xPropertySet
.set(xRunEnum
->nextElement(), uno::UNO_QUERY
);
614 CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty
<OUString
>(xPropertySet
, "TextPortionType"));
617 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
618 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
619 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
620 xPropertySet
.set(xFields
->nextElement(), uno::UNO_QUERY
);
621 CPPUNIT_ASSERT_EQUAL(OUString("__Fieldmark__4_1833023242"), getProperty
<OUString
>(xPropertySet
, "Name"));
622 CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty
<OUString
>(xPropertySet
, "Initials"));
625 CPPUNIT_TEST_FIXTURE(Test
, testSenderInitials
)
627 loadAndReload("sender-initials.fodt");
628 // Test sender-initial properties (both annotation metadata and text field)
629 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
630 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
631 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
632 // first 3 are annotations, last 2 are text fields
633 for (unsigned i
= 0; i
< 3; ++i
)
635 uno::Reference
<beans::XPropertySet
> xPropertySet(xFields
->nextElement(), uno::UNO_QUERY
);
636 CPPUNIT_ASSERT_EQUAL(OUString("I"), getProperty
<OUString
>(xPropertySet
, "Initials"));
638 for (unsigned i
= 0; i
< 2; ++i
)
640 uno::Reference
<beans::XPropertySet
> xPropertySet(xFields
->nextElement(), uno::UNO_QUERY
);
641 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xPropertySet
, "IsFixed"));
642 CPPUNIT_ASSERT_EQUAL(OUString("I"), getProperty
<OUString
>(xPropertySet
, "Content"));
646 DECLARE_ODFEXPORT_TEST(testResolvedComment
, "resolved-comment.odt")
648 CPPUNIT_ASSERT_EQUAL(1, getPages());
649 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
650 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
651 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
652 uno::Reference
<beans::XPropertySet
> xPropertySet(xFields
->nextElement(), uno::UNO_QUERY
);
653 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xPropertySet
, "Resolved"));
654 xPropertySet
.set(xFields
->nextElement(), uno::UNO_QUERY
);
655 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xPropertySet
, "Resolved"));
658 CPPUNIT_TEST_FIXTURE(Test
, testTdf92379
)
660 loadAndReload("tdf92379.fodt");
661 // frame style fo:background-color was not imported
662 uno::Reference
<container::XNameAccess
> xStyles(getStyles("FrameStyles"));
663 uno::Reference
<beans::XPropertySet
> xStyle(xStyles
->getByName("encarts"),
665 CPPUNIT_ASSERT_EQUAL(Color(0xffcc99), getProperty
<Color
>(xStyle
, "BackColorRGB"));
666 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xStyle
, "BackColorTransparency"));
667 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xStyle
, "FillStyle"));
668 CPPUNIT_ASSERT_EQUAL(Color(0xffcc99), getProperty
<Color
>(xStyle
, "FillColor"));
669 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(xStyle
, "FillTransparence"));
671 uno::Reference
<beans::XPropertySet
> xFrameStyle2(xStyles
->getByName("Untitled1"),
673 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, getProperty
<Color
>(xFrameStyle2
, "BackColorRGB"));
674 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xFrameStyle2
, "BackTransparent"));
675 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty
<sal_Int32
>(xFrameStyle2
, "BackColorTransparency"));
676 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, getProperty
<drawing::FillStyle
>(xFrameStyle2
, "FillStyle"));
677 // unfortunately this is actually the pool default value, which would be hard to fix - but it isn't a problem because style is NONE
678 // CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xFrameStyle2, "FillColor"));
679 // CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xFrameStyle2, "FillTransparence"));
683 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
684 // check that fo:background-color attribute is exported properly
685 assertXPath(pXmlDoc
, "//style:style[@style:family='graphic' and @style:name='encarts']/style:graphic-properties[@fo:background-color='#ffcc99']", 1);
686 assertXPath(pXmlDoc
, "//style:style[@style:family='graphic' and @style:name='Untitled1']/style:graphic-properties[@fo:background-color='transparent']", 1);
689 // paragraph style fo:background-color was wrongly inherited despite being
690 // overridden in derived style
691 uno::Reference
<container::XNameAccess
> xParaStyles(getStyles("ParagraphStyles"));
692 uno::Reference
<beans::XPropertySet
> xStyle1(xParaStyles
->getByName(
693 "Titre Avis expert"), uno::UNO_QUERY
);
694 CPPUNIT_ASSERT_EQUAL(Color(0x661900), getProperty
<Color
>(xStyle1
, "ParaBackColor"));
695 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xStyle1
, "ParaBackTransparent"));
696 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xStyle1
, "FillStyle"));
697 CPPUNIT_ASSERT_EQUAL(Color(0x661900), getProperty
<Color
>(xStyle1
, "FillColor"));
698 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(xStyle1
, "FillTransparence"));
699 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, getProperty
<Color
>(xStyle1
, "CharColor"));
701 uno::Reference
<beans::XPropertySet
> xStyle2(xParaStyles
->getByName(
702 "Avis expert questions"), uno::UNO_QUERY
);
703 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT
, getProperty
<Color
>(xStyle2
, "ParaBackColor"));
704 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStyle2
, "ParaBackTransparent"));
705 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, getProperty
<drawing::FillStyle
>(xStyle2
, "FillStyle"));
706 // unfortunately this is actually the pool default value, which would be hard to fix - but it isn't a problem because style is NONE
707 // CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xStyle2, "FillColor"));
708 // CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xStyle2, "FillTransparence"));
709 CPPUNIT_ASSERT_EQUAL(Color(0x661900), getProperty
<Color
>(xStyle2
, "CharColor"));
711 uno::Reference
<beans::XPropertySet
> xStyle31(xParaStyles
->getByName(
712 "avis expert questions non cadres"), uno::UNO_QUERY
);
713 CPPUNIT_ASSERT_EQUAL(Color(0x801900), getProperty
<Color
>(xStyle31
, "ParaBackColor"));
714 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xStyle31
, "ParaBackTransparent"));
715 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(xStyle31
, "FillStyle"));
716 CPPUNIT_ASSERT_EQUAL(Color(0x801900), getProperty
<Color
>(xStyle31
, "FillColor"));
717 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(xStyle31
, "FillTransparence"));
718 CPPUNIT_ASSERT_EQUAL(Color(0x661900), getProperty
<Color
>(xStyle31
, "CharColor"));
720 uno::Reference
<beans::XPropertySet
> xStyle32(xParaStyles
->getByName(
721 "Avis expert rXponses"), uno::UNO_QUERY
);
722 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT
, getProperty
<Color
>(xStyle32
, "ParaBackColor"));
723 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xStyle32
, "ParaBackTransparent"));
724 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, getProperty
<drawing::FillStyle
>(xStyle32
, "FillStyle"));
725 // unfortunately this is actually the pool default value, which would be hard to fix - but it isn't a problem because style is NONE
726 // CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xStyle32, "FillColor"));
727 // CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xStyle32, "FillTransparence"));
728 CPPUNIT_ASSERT_EQUAL(Color(0x461900), getProperty
<Color
>(xStyle32
, "CharColor"));
732 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
733 // check that fo:background-color attribute is exported properly
734 assertXPath(pXmlDoc
, "//style:style[@style:family='paragraph' and @style:display-name='Titre Avis expert']/style:paragraph-properties[@fo:background-color='#661900']", 1);
735 assertXPath(pXmlDoc
, "//style:style[@style:family='paragraph' and @style:display-name='Avis expert questions']/style:paragraph-properties[@fo:background-color='transparent']", 1);
736 assertXPath(pXmlDoc
, "//style:style[@style:family='paragraph' and @style:display-name='avis expert questions non cadres']/style:paragraph-properties[@fo:background-color='#801900']", 1);
737 assertXPath(pXmlDoc
, "//style:style[@style:family='paragraph' and @style:display-name='Avis expert rXponses']/style:paragraph-properties[@fo:background-color='transparent']", 1);
741 DECLARE_ODFEXPORT_TEST(testFdo79358
, "fdo79358.odt")
743 CPPUNIT_ASSERT_EQUAL(1, getPages());
744 // the boolean properties of the index were not exported properly
745 uno::Reference
<text::XDocumentIndexesSupplier
> xIndexSupplier(mxComponent
, uno::UNO_QUERY
);
746 uno::Reference
<container::XIndexAccess
> xIndexes
= xIndexSupplier
->getDocumentIndexes();
747 uno::Reference
<text::XDocumentIndex
> xTOCIndex(xIndexes
->getByIndex(0), uno::UNO_QUERY
);
748 uno::Reference
<beans::XPropertySet
> xTOCProps(xTOCIndex
, uno::UNO_QUERY
);
749 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xTOCProps
, "CreateFromOutline"));
750 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xTOCProps
, "CreateFromMarks"));
751 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xTOCProps
, "CreateFromLevelParagraphStyles"));
752 // check that the source styles are preserved too while at it
753 uno::Reference
<container::XIndexReplace
> xLevels(
754 getProperty
< uno::Reference
<container::XIndexReplace
> >(xTOCProps
,
755 "LevelParagraphStyles"));
756 uno::Sequence
<OUString
> seq
{ "Heading" };
757 CPPUNIT_ASSERT_EQUAL(uno::Any(seq
), xLevels
->getByIndex(1));
758 CPPUNIT_ASSERT_EQUAL(uno::Any(uno::Sequence
<OUString
>()), xLevels
->getByIndex(2));
761 DECLARE_ODFEXPORT_TEST(testFirstHeaderFooter
, "first-header-footer.odt")
763 CPPUNIT_ASSERT_EQUAL(6, getPages());
764 // Test import and export of the header-first token.
766 // The document has 6 pages, two page styles for the first and second half of pages.
767 CPPUNIT_ASSERT_EQUAL(OUString("First header"), parseDump("/root/page[1]/header/txt/text()"));
768 CPPUNIT_ASSERT_EQUAL(OUString("First footer"), parseDump("/root/page[1]/footer/txt/text()"));
769 CPPUNIT_ASSERT_EQUAL(OUString("Left header"), parseDump("/root/page[2]/header/txt/text()"));
770 CPPUNIT_ASSERT_EQUAL(OUString("Left footer"), parseDump("/root/page[2]/footer/txt/text()"));
771 CPPUNIT_ASSERT_EQUAL(OUString("Right header"), parseDump("/root/page[3]/header/txt/text()"));
772 CPPUNIT_ASSERT_EQUAL(OUString("Right footer"), parseDump("/root/page[3]/footer/txt/text()"));
773 CPPUNIT_ASSERT_EQUAL(OUString("First header2"), parseDump("/root/page[4]/header/txt/text()"));
774 CPPUNIT_ASSERT_EQUAL(OUString("First footer2"), parseDump("/root/page[4]/footer/txt/text()"));
775 CPPUNIT_ASSERT_EQUAL(OUString("Right header2"), parseDump("/root/page[5]/header/txt/text()"));
776 CPPUNIT_ASSERT_EQUAL(OUString("Right footer2"), parseDump("/root/page[5]/footer/txt/text()"));
777 CPPUNIT_ASSERT_EQUAL(OUString("Left header2"), parseDump("/root/page[6]/header/txt/text()"));
778 CPPUNIT_ASSERT_EQUAL(OUString("Left footer2"), parseDump("/root/page[6]/footer/txt/text()"));
781 DECLARE_ODFEXPORT_TEST(testTextframeGradient
, "textframe-gradient.odt")
783 CPPUNIT_ASSERT_EQUAL(2, getShapes());
784 CPPUNIT_ASSERT_EQUAL(1, getPages());
785 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
786 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
787 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess
->getCount());
789 uno::Reference
<beans::XPropertySet
> xFrame(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
790 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT
, getProperty
<drawing::FillStyle
>(xFrame
, "FillStyle"));
791 awt::Gradient2 aGradient
= getProperty
<awt::Gradient2
>(xFrame
, "FillGradient");
793 // MCGR: Use the completely imported gradient to check for correctness
794 basegfx::BColorStops aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
796 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
797 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
798 CPPUNIT_ASSERT_EQUAL(aColorStops
[0].getStopColor(), basegfx::BColor(0.75294117647058822, 0.31372549019607843, 0.30196078431372547));
799 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
800 CPPUNIT_ASSERT_EQUAL(aColorStops
[1].getStopColor(), basegfx::BColor(0.85098039215686272, 0.58431372549019611, 0.58039215686274515));
801 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL
, aGradient
.Style
);
803 xFrame
.set(xIndexAccess
->getByIndex(1), uno::UNO_QUERY
);
804 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT
, getProperty
<drawing::FillStyle
>(xFrame
, "FillStyle"));
805 aGradient
= getProperty
<awt::Gradient2
>(xFrame
, "FillGradient");
807 // MCGR: Use the completely imported gradient to check for correctness
808 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
810 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops
.size());
811 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
812 CPPUNIT_ASSERT_EQUAL(aColorStops
[0].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
813 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 1.0));
814 CPPUNIT_ASSERT_EQUAL(aColorStops
[1].getStopColor(), basegfx::BColor(0.40000000000000002, 0.40000000000000002, 0.40000000000000002));
815 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL
, aGradient
.Style
);
818 CPPUNIT_TEST_FIXTURE(Test
, testDuplicateCrossRefHeadingBookmark
)
820 loadAndReload("CrossRefHeadingBookmark.fodt");
821 // the file contains invalid duplicate heading cross reference bookmarks
822 // but we have to round trip them, tdf#94804
824 uno::Reference
<text::XBookmarksSupplier
> xBookmarksSupplier(mxComponent
,
826 uno::Reference
<container::XNameAccess
> xBookmarks
=
827 xBookmarksSupplier
->getBookmarks();
828 uno::Reference
<text::XTextContent
> xBookmark1(
829 xBookmarks
->getByName("__RefHeading__8284_1826734303"), uno::UNO_QUERY
);
830 CPPUNIT_ASSERT(xBookmark1
.is());
831 CPPUNIT_ASSERT_THROW(xBookmarks
->getByName("__RefHeading__1673_25705824"), container::NoSuchElementException
);
833 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
834 uno::Reference
<util::XRefreshable
>(xTextFieldsSupplier
->getTextFields(), uno::UNO_QUERY_THROW
)->refresh();
836 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
837 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
838 uno::Any aField1
= xFields
->nextElement();
839 uno::Reference
<text::XTextField
> xField1(aField1
, uno::UNO_QUERY
);
840 CPPUNIT_ASSERT_EQUAL(OUString("1.1"), xField1
->getPresentation(false));
841 uno::Any aField2
= xFields
->nextElement();
842 uno::Reference
<text::XTextField
> xField2(aField2
, uno::UNO_QUERY
);
843 CPPUNIT_ASSERT_EQUAL(OUString("1.1"), xField2
->getPresentation(false));
846 DECLARE_ODFEXPORT_TEST(testFdo60769
, "fdo60769.odt")
848 CPPUNIT_ASSERT_EQUAL(1, getPages());
849 // Test multi-paragraph comment range feature.
850 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
851 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
852 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
853 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
854 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
855 while (xRunEnum
->hasMoreElements())
857 uno::Reference
<beans::XPropertySet
> xPropertySet(xRunEnum
->nextElement(), uno::UNO_QUERY
);
858 OUString aType
= getProperty
<OUString
>(xPropertySet
, "TextPortionType");
859 // First paragraph: no field end, no anchor
860 CPPUNIT_ASSERT(aType
== "Text" || aType
== "Annotation");
863 xRunEnumAccess
.set(xParaEnum
->nextElement(), uno::UNO_QUERY
);
864 while (xRunEnum
->hasMoreElements())
866 uno::Reference
<beans::XPropertySet
> xPropertySet(xRunEnum
->nextElement(), uno::UNO_QUERY
);
867 OUString aType
= getProperty
<OUString
>(xPropertySet
, "TextPortionType");
868 // Second paragraph: no field start
869 CPPUNIT_ASSERT(aType
== "Text" || aType
== "AnnotationEnd");
873 DECLARE_ODFEXPORT_TEST(testTdf115815
, "tdf115815.odt")
875 CPPUNIT_ASSERT_EQUAL(1, getPages());
876 // Test comment range feature on tracked deletion.
877 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
878 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
879 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
880 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
881 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
882 bool bAnnotationStart
= false;
883 bool bBeforeAnnotation
= true;
884 OUString sTextBeforeAnnotation
;
885 while (xRunEnum
->hasMoreElements())
887 uno::Reference
<beans::XPropertySet
> xPropertySet(xRunEnum
->nextElement(), uno::UNO_QUERY
);
888 OUString aType
= getProperty
<OUString
>(xPropertySet
, "TextPortionType");
889 // there is no AnnotationEnd with preceding AnnotationStart,
890 // i.e. annotation with lost range
891 CPPUNIT_ASSERT(aType
!= "AnnotationEnd" || !bAnnotationStart
);
893 bAnnotationStart
= (aType
== "Annotation");
895 // collect paragraph text before the first annotation
896 if (bBeforeAnnotation
)
898 if (bAnnotationStart
)
899 bBeforeAnnotation
= false;
900 else if (aType
== "Text")
902 uno::Reference
<text::XTextRange
> xRun(xPropertySet
, uno::UNO_QUERY
);
903 sTextBeforeAnnotation
+= xRun
->getString();
908 // This was "Lorem ipsum" (collapsed annotation range)
909 CPPUNIT_ASSERT_EQUAL(OUString("Lorem "), sTextBeforeAnnotation
);
912 CPPUNIT_TEST_FIXTURE(Test
, testFdo58949
)
914 comphelper::ScopeGuard
g([]() {
915 std::shared_ptr
<comphelper::ConfigurationChanges
> pBatch(
916 comphelper::ConfigurationChanges::create());
917 officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(true, pBatch
);
921 std::shared_ptr
<comphelper::ConfigurationChanges
> pBatch(
922 comphelper::ConfigurationChanges::create());
923 officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(false, pBatch
);
925 loadAndReload("fdo58949.docx");
928 * The problem was that the exporter didn't insert "Obj102" to the
929 * resulting zip file. No idea how to check for "broken" (missing OLE data
930 * and replacement image) OLE objects using UNO, so we'll check the zip file directly.
935 uno::Sequence
<uno::Any
> aArgs
{ uno::Any(maTempFile
.GetURL()) };
936 uno::Reference
<container::XNameAccess
> xNameAccess(m_xSFactory
->createInstanceWithArguments("com.sun.star.packages.zip.ZipFileAccess", aArgs
), uno::UNO_QUERY
);
937 const css::uno::Sequence
<OUString
> aNames(xNameAccess
->getElementNames());
938 // The exported document must have three objects named ObjNNN. The names are assigned in
939 // OLEHandler::copyOLEOStream using a static counter, and actual numbers depend on previous
940 // tests; so just count the matching names here.
942 for (const OUString
& sName
: aNames
)
945 if (sName
.startsWith("Obj", &sRest
))
947 // all following characters must be decimal digits; minimal value is 100
948 bool bMatch
= sRest
.getLength() >= 3
949 && std::all_of(sRest
.getStr(), sRest
.getStr() + sRest
.getLength(),
950 [](sal_Unicode ch
) { return ch
>= '0' && ch
<= '9'; });
955 CPPUNIT_ASSERT_EQUAL(3, nMatches
);
958 CPPUNIT_TEST_FIXTURE(Test
, testTdf134987
)
960 loadAndReload("tdf134987.docx");
961 uno::Reference
<text::XTextEmbeddedObjectsSupplier
> xTEOSupplier(mxComponent
, uno::UNO_QUERY
);
962 uno::Reference
<container::XNameAccess
> xAccess(xTEOSupplier
->getEmbeddedObjects());
963 uno::Sequence
<OUString
> aSeq(xAccess
->getElementNames());
964 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aSeq
.getLength());
967 // checking first object (formula)
969 uno::Reference
<document::XEmbeddedObjectSupplier
> xEOSupplier(xAccess
->getByName("Object1"), uno::UNO_QUERY
);
970 uno::Reference
<lang::XComponent
> xObj(xEOSupplier
->getEmbeddedObject());
971 CPPUNIT_ASSERT(xObj
.is());
973 uno::Reference
<document::XStorageBasedDocument
> xSBDoc(xObj
, uno::UNO_QUERY
);
974 uno::Reference
<embed::XStorage
> xStorage(xSBDoc
->getDocumentStorage());
975 CPPUNIT_ASSERT(xStorage
.is());
977 uno::Reference
< beans::XPropertySet
> xStorProps(xStorage
, uno::UNO_QUERY_THROW
);
978 CPPUNIT_ASSERT(xStorProps
->getPropertyValue("MediaType") >>= aMediaType
);
979 CPPUNIT_ASSERT(aMediaType
.equalsIgnoreAsciiCase(MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_ASCII
));
981 // checking second object (chart)
983 uno::Reference
<document::XEmbeddedObjectSupplier
> xEOSupplier(xAccess
->getByName("Diagram 1"), uno::UNO_QUERY
);
984 uno::Reference
<lang::XComponent
> xObj(xEOSupplier
->getEmbeddedObject());
985 CPPUNIT_ASSERT(xObj
.is());
987 uno::Reference
<document::XStorageBasedDocument
> xSBDoc(xObj
, uno::UNO_QUERY
);
988 uno::Reference
<embed::XStorage
> xStorage(xSBDoc
->getDocumentStorage());
989 CPPUNIT_ASSERT(xStorage
.is());
991 uno::Reference
< beans::XPropertySet
> xStorProps(xStorage
, uno::UNO_QUERY_THROW
);
992 CPPUNIT_ASSERT(xStorProps
->getPropertyValue("MediaType") >>= aMediaType
);
993 CPPUNIT_ASSERT(aMediaType
.equalsIgnoreAsciiCase(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII
));
995 // checking third object (chart)
997 uno::Reference
<document::XEmbeddedObjectSupplier
> xEOSupplier(xAccess
->getByName("Diagram 2"), uno::UNO_QUERY
);
998 uno::Reference
<lang::XComponent
> xObj(xEOSupplier
->getEmbeddedObject());
999 CPPUNIT_ASSERT(xObj
.is());
1001 uno::Reference
<document::XStorageBasedDocument
> xSBDoc(xObj
, uno::UNO_QUERY
);
1002 uno::Reference
<embed::XStorage
> xStorage(xSBDoc
->getDocumentStorage());
1003 CPPUNIT_ASSERT(xStorage
.is());
1005 uno::Reference
< beans::XPropertySet
> xStorProps(xStorage
, uno::UNO_QUERY_THROW
);
1006 CPPUNIT_ASSERT(xStorProps
->getPropertyValue("MediaType") >>= aMediaType
);
1007 CPPUNIT_ASSERT(aMediaType
.equalsIgnoreAsciiCase(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII
));
1011 DECLARE_ODFEXPORT_TEST(testStylePageNumber
, "ooo321_stylepagenumber.odt")
1013 CPPUNIT_ASSERT_EQUAL(5, getPages());
1014 uno::Reference
<text::XTextContent
> xTable1(getParagraphOrTable(1));
1015 // actually no break attribute is written in this case
1016 // CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, getProperty<style::BreakType>(xTable1, "BreakType"));
1017 CPPUNIT_ASSERT_EQUAL(OUString("Left Page"), getProperty
<OUString
>(xTable1
, "PageDescName"));
1018 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty
<sal_Int16
>(xTable1
, "PageNumberOffset"));
1020 uno::Reference
<text::XTextContent
> xPara1(getParagraphOrTable(2));
1021 CPPUNIT_ASSERT_EQUAL(OUString("Right Page"), getProperty
<OUString
>(xPara1
, "PageDescName"));
1022 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty
<sal_Int16
>(xPara1
, "PageNumberOffset"));
1024 // i#114163 tdf#77111: OOo < 3.3 bug, it wrote "auto" as "0" for tables
1025 uno::Reference
<beans::XPropertySet
> xTable0(getParagraphOrTable(3), uno::UNO_QUERY
);
1026 CPPUNIT_ASSERT_EQUAL(OUString("Left Page"), getProperty
<OUString
>(xTable0
, "PageDescName"));
1027 CPPUNIT_ASSERT_EQUAL(uno::Any(), xTable0
->getPropertyValue("PageNumberOffset"));
1029 uno::Reference
<beans::XPropertySet
> xPara0(getParagraphOrTable(4), uno::UNO_QUERY
);
1030 CPPUNIT_ASSERT_EQUAL(OUString("Right Page"), getProperty
<OUString
>(xPara0
, "PageDescName"));
1031 CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara0
->getPropertyValue("PageNumberOffset"));
1033 uno::Reference
<container::XNameAccess
> xParaStyles
= getStyles("ParagraphStyles");
1034 uno::Reference
<beans::XPropertySet
> xStyle1(xParaStyles
->getByName("stylewithbreak1"), uno::UNO_QUERY
);
1035 CPPUNIT_ASSERT_EQUAL(OUString("Right Page"), getProperty
<OUString
>(xStyle1
, "PageDescName"));
1036 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty
<sal_Int16
>(xStyle1
, "PageNumberOffset"));
1038 uno::Reference
<beans::XPropertySet
> xStyle0(xParaStyles
->getByName("stylewithbreak0"), uno::UNO_QUERY
);
1039 CPPUNIT_ASSERT_EQUAL(OUString("First Page"), getProperty
<OUString
>(xStyle0
, "PageDescName"));
1040 CPPUNIT_ASSERT_EQUAL(uno::Any(), xStyle0
->getPropertyValue("PageNumberOffset"));
1043 DECLARE_ODFEXPORT_TEST(testCharacterBorder
, "charborder.odt")
1045 CPPUNIT_ASSERT_EQUAL(1, getPages());
1046 // Make sure paragraph and character attributes don't interfere
1047 // First paragraph has a paragraph border and a character border included by the paragraph style
1049 // Paragraph border of first paragraph
1051 const table::BorderLine2
aFirstParTopBorder(0x6666FF,2,26,26,7,55);
1052 const sal_Int32
aFirstParTopPadding(150);
1053 uno::Reference
<beans::XPropertySet
> xSet(getParagraph(1), uno::UNO_QUERY
);
1056 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"TopBorder"));
1057 CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding
, getProperty
<sal_Int32
>(xSet
,"TopBorderDistance"));
1059 // Bottom border (same as top border)
1060 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"BottomBorder"));
1061 CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding
, getProperty
<sal_Int32
>(xSet
,"BottomBorderDistance"));
1063 // Left border (same as top border)
1064 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"LeftBorder"));
1065 CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding
, getProperty
<sal_Int32
>(xSet
,"LeftBorderDistance"));
1067 // Right border (same as top border)
1068 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"RightBorder"));
1069 CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding
, getProperty
<sal_Int32
>(xSet
,"RightBorderDistance"));
1072 const table::ShadowFormat aShadow
= getProperty
<table::ShadowFormat
>(xSet
,"ParaShadowFormat");
1073 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, Color(ColorTransparency
, aShadow
.Color
));
1074 CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(aShadow
.IsTransparent
));
1075 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation(0), aShadow
.Location
);
1076 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aShadow
.ShadowWidth
);
1079 // Character border for first paragraph
1081 const table::BorderLine2
aFirstParCharTopBorder(0xFF3333,0,37,0,2,37);
1082 const sal_Int32
aFirstParCharTopPadding(450);
1083 uno::Reference
<beans::XPropertySet
> xSet(getParagraph(1), uno::UNO_QUERY
);
1086 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"CharTopBorder"));
1087 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding
, getProperty
<sal_Int32
>(xSet
,"CharTopBorderDistance"));
1089 // Bottom border (same as top border)
1090 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"CharBottomBorder"));
1091 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding
, getProperty
<sal_Int32
>(xSet
,"CharBottomBorderDistance"));
1093 // Left border (same as top border)
1094 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"CharLeftBorder"));
1095 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding
, getProperty
<sal_Int32
>(xSet
,"CharLeftBorderDistance"));
1097 // Right border (same as top border)
1098 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"CharRightBorder"));
1099 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding
, getProperty
<sal_Int32
>(xSet
,"CharRightBorderDistance"));
1102 const table::ShadowFormat aShadow
= getProperty
<table::ShadowFormat
>(xSet
,"CharShadowFormat");
1103 CPPUNIT_ASSERT_EQUAL(Color(0xFF3333), Color(ColorTransparency
, aShadow
.Color
));
1104 CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(aShadow
.IsTransparent
));
1105 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation(2), aShadow
.Location
);
1106 CPPUNIT_ASSERT_EQUAL(sal_Int16(280), aShadow
.ShadowWidth
);
1110 uno::Reference
< style::XAutoStyleFamily
> xAutoStyleFamily(getAutoStyles("ParagraphStyles"));
1111 uno::Reference
< container::XEnumeration
> xAutoStylesEnum( xAutoStyleFamily
->createEnumeration() );
1112 CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(xAutoStylesEnum
->hasMoreElements()));
1115 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"CharTopBorder"));
1116 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding
, getProperty
<sal_Int32
>(xSet
,"CharTopBorderDistance"));
1119 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"CharBottomBorder"));
1120 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding
, getProperty
<sal_Int32
>(xSet
,"CharBottomBorderDistance"));
1123 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"CharLeftBorder"));
1124 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding
, getProperty
<sal_Int32
>(xSet
,"CharLeftBorderDistance"));
1127 CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder
, getProperty
<table::BorderLine2
>(xSet
,"CharRightBorder"));
1128 CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding
, getProperty
<sal_Int32
>(xSet
,"CharRightBorderDistance"));
1132 // Second paragraph's second text portion has a character style named CharDiffBor
1133 // This style includes border with different sides
1136 table::BorderLine2 aBorderArray
[4] =
1138 table::BorderLine2(0xFF3333,0,37,0,14,37), // Top (fine dashed line)
1139 table::BorderLine2(0x99FF66,26,26,53,11,106), // Bottom
1140 table::BorderLine2(0x6666FF,9,26,9,12,71), // Left
1141 table::BorderLine2(0,0,0,0,table::BorderLineStyle::NONE
,0) // Right
1144 sal_Int32 aDistances
[4] = { 400 /*Top*/, 300 /*Bottom*/, 250 /*Left*/, 0 /*Right*/ };
1146 // Get second text portion of second paragraph
1147 uno::Reference
< beans::XPropertySet
> xSet( getRun(getParagraph(2),2), uno::UNO_QUERY
);
1150 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray
[0], getProperty
<table::BorderLine2
>(xSet
,"CharTopBorder"));
1151 CPPUNIT_ASSERT_EQUAL(aDistances
[0], getProperty
<sal_Int32
>(xSet
,"CharTopBorderDistance"));
1154 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray
[1], getProperty
<table::BorderLine2
>(xSet
,"CharBottomBorder"));
1155 CPPUNIT_ASSERT_EQUAL(aDistances
[1], getProperty
<sal_Int32
>(xSet
,"CharBottomBorderDistance"));
1158 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray
[2], getProperty
<table::BorderLine2
>(xSet
,"CharLeftBorder"));
1159 CPPUNIT_ASSERT_EQUAL(aDistances
[2], getProperty
<sal_Int32
>(xSet
,"CharLeftBorderDistance"));
1162 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray
[3], getProperty
<table::BorderLine2
>(xSet
,"CharRightBorder"));
1163 CPPUNIT_ASSERT_EQUAL(aDistances
[3], getProperty
<sal_Int32
>(xSet
,"CharRightBorderDistance"));
1166 const table::ShadowFormat aShadow
= getProperty
<table::ShadowFormat
>(xSet
,"CharShadowFormat");
1167 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, Color(ColorTransparency
, aShadow
.Color
));
1168 CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(aShadow
.IsTransparent
));
1169 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation(3), aShadow
.Location
);
1170 CPPUNIT_ASSERT_EQUAL(sal_Int16(79), aShadow
.ShadowWidth
);
1172 // Check character style
1174 uno::Reference
< container::XNameAccess
> xStyleFamily
= getStyles("CharacterStyles");
1175 uno::Reference
< beans::XPropertySet
> xStyleSet(xStyleFamily
->getByName("CharDiffBor"), uno::UNO_QUERY
);
1178 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray
[0], getProperty
<table::BorderLine2
>(xStyleSet
,"CharTopBorder"));
1179 CPPUNIT_ASSERT_EQUAL(aDistances
[0], getProperty
<sal_Int32
>(xStyleSet
,"CharTopBorderDistance"));
1182 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray
[1], getProperty
<table::BorderLine2
>(xStyleSet
,"CharBottomBorder"));
1183 CPPUNIT_ASSERT_EQUAL(aDistances
[1], getProperty
<sal_Int32
>(xStyleSet
,"CharBottomBorderDistance"));
1186 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray
[2], getProperty
<table::BorderLine2
>(xStyleSet
,"CharLeftBorder"));
1187 CPPUNIT_ASSERT_EQUAL(aDistances
[2], getProperty
<sal_Int32
>(xStyleSet
,"CharLeftBorderDistance"));
1190 CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray
[3], getProperty
<table::BorderLine2
>(xStyleSet
,"CharRightBorder"));
1191 CPPUNIT_ASSERT_EQUAL(aDistances
[3], getProperty
<sal_Int32
>(xStyleSet
,"CharRightBorderDistance"));
1196 CPPUNIT_TEST_FIXTURE(Test
, testProtectionKey
)
1198 loadAndReload("protection-key.fodt");
1199 OUString
const password("1012345678901234567890123456789012345678901234567890");
1201 // check 1 invalid OOo legacy password and 3 valid ODF 1.2 passwords
1202 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
1203 uno::Reference
<container::XIndexAccess
> xSections(xTextSectionsSupplier
->getTextSections(), uno::UNO_QUERY
);
1204 uno::Reference
<beans::XPropertySet
> xSect0(xSections
->getByIndex(0), uno::UNO_QUERY
);
1205 uno::Sequence
<sal_Int8
> const key0(getProperty
<uno::Sequence
<sal_Int8
>>(xSect0
, "ProtectionKey"));
1206 CPPUNIT_ASSERT(SvPasswordHelper::CompareHashPassword(key0
, password
));
1207 uno::Reference
<beans::XPropertySet
> xSect1(xSections
->getByIndex(1), uno::UNO_QUERY
);
1208 uno::Sequence
<sal_Int8
> const key1(getProperty
<uno::Sequence
<sal_Int8
>>(xSect1
, "ProtectionKey"));
1209 CPPUNIT_ASSERT(SvPasswordHelper::CompareHashPassword(key1
, password
));
1210 uno::Reference
<beans::XPropertySet
> xSect2(xSections
->getByIndex(2), uno::UNO_QUERY
);
1211 uno::Sequence
<sal_Int8
> const key2(getProperty
<uno::Sequence
<sal_Int8
>>(xSect2
, "ProtectionKey"));
1212 CPPUNIT_ASSERT(SvPasswordHelper::CompareHashPassword(key2
, password
));
1213 uno::Reference
<beans::XPropertySet
> xSect3(xSections
->getByIndex(3), uno::UNO_QUERY
);
1214 uno::Sequence
<sal_Int8
> const key3(getProperty
<uno::Sequence
<sal_Int8
>>(xSect3
, "ProtectionKey"));
1215 CPPUNIT_ASSERT(SvPasswordHelper::CompareHashPassword(key3
, password
));
1217 // we can't assume that the user entered the password; check that we
1218 // round-trip the password as-is
1221 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
1222 assertXPath(pXmlDoc
, "//text:section[@text:name='Section0' and @text:protected='true' and @text:protection-key='vbnhxyBKtPHCA1wB21zG1Oha8ZA=']");
1223 assertXPath(pXmlDoc
, "//text:section[@text:name='Section1' and @text:protected='true' and @text:protection-key='nLHas0RIwepGDaH4c2hpyIUvIS8=']");
1224 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=']");
1225 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=']");
1229 CPPUNIT_TEST_FIXTURE(Test
, testTdf128188
)
1231 loadAndReload("footnote-collect-at-end-of-section.fodt");
1232 SwDoc
*const pDoc
= dynamic_cast<SwXTextDocument
&>(*mxComponent
).GetDocShell()->GetDoc();
1233 CPPUNIT_ASSERT(pDoc
);
1234 SwFootnoteIdxs
const& rFootnotes(pDoc
->GetFootnoteIdxs());
1236 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes
[0]->GetFootnote().GetNumber());
1237 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes
[0]->GetFootnote().GetNumberRLHidden());
1238 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), rFootnotes
[1]->GetFootnote().GetNumber());
1239 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), rFootnotes
[1]->GetFootnote().GetNumberRLHidden());
1241 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes
[2]->GetFootnote().GetNumber());
1242 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes
[2]->GetFootnote().GetNumberRLHidden());
1244 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), rFootnotes
[3]->GetFootnote().GetNumber());
1245 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes
[3]->GetFootnote().GetNumberRLHidden());
1247 CPPUNIT_ASSERT_EQUAL(sal_uInt16(3), rFootnotes
[4]->GetFootnote().GetNumber());
1248 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rFootnotes
[4]->GetFootnote().GetNumberRLHidden());
1249 CPPUNIT_ASSERT_EQUAL(sal_uInt16(4), rFootnotes
[5]->GetFootnote().GetNumber());
1250 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), rFootnotes
[5]->GetFootnote().GetNumberRLHidden());
1253 DECLARE_ODFEXPORT_TEST(testFdo43807
, "fdo43807.odt")
1255 CPPUNIT_ASSERT_EQUAL(1, getPages());
1256 uno::Reference
<beans::XPropertySet
> xSet(getParagraph(1), uno::UNO_QUERY
);
1257 CPPUNIT_ASSERT_EQUAL(OUString("Drop Caps"),getProperty
<OUString
>(xSet
,"DropCapCharStyleName"));
1259 xSet
.set(getParagraph(2), uno::UNO_QUERY
);
1260 CPPUNIT_ASSERT_EQUAL(OUString("User Defined Drop Caps"),getProperty
<OUString
>(xSet
,"DropCapCharStyleName"));
1263 CPPUNIT_TEST_FIXTURE(Test
, testTdf103091
)
1265 loadAndReload("tdf103091.fodt");
1266 // check that all conditional paragraph style conditions are imported
1267 uno::Reference
<container::XNameAccess
> xParaStyles(getStyles("ParagraphStyles"));
1268 uno::Reference
<beans::XPropertySet
> xStyle1(xParaStyles
->getByName(
1269 "Text body"), uno::UNO_QUERY
);
1270 auto conditions(getProperty
<uno::Sequence
<beans::NamedValue
>>(xStyle1
, "ParaStyleConditions"));
1272 CPPUNIT_ASSERT_EQUAL(sal_Int32(28), conditions
.getLength());
1273 CPPUNIT_ASSERT_EQUAL(OUString("TableHeader"), conditions
[0].Name
);
1274 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Addressee")), conditions
[0].Value
);
1275 CPPUNIT_ASSERT_EQUAL(OUString("Table"), conditions
[1].Name
);
1276 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Bibliography 1")), conditions
[1].Value
);
1277 CPPUNIT_ASSERT_EQUAL(OUString("Frame"), conditions
[2].Name
);
1278 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Bibliography Heading")), conditions
[2].Value
);
1279 CPPUNIT_ASSERT_EQUAL(OUString("Section"), conditions
[3].Name
);
1280 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Caption")), conditions
[3].Value
);
1281 CPPUNIT_ASSERT_EQUAL(OUString("Footnote"), conditions
[4].Name
);
1282 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Salutation")), conditions
[4].Value
);
1283 CPPUNIT_ASSERT_EQUAL(OUString("Endnote"), conditions
[5].Name
);
1284 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents 1")), conditions
[5].Value
);
1285 CPPUNIT_ASSERT_EQUAL(OUString("Header"), conditions
[6].Name
);
1286 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents 2")), conditions
[6].Value
);
1287 CPPUNIT_ASSERT_EQUAL(OUString("Footer"), conditions
[7].Name
);
1288 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents 3")), conditions
[7].Value
);
1289 CPPUNIT_ASSERT_EQUAL(OUString("OutlineLevel1"), conditions
[8].Name
);
1290 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents 4")), conditions
[8].Value
);
1291 CPPUNIT_ASSERT_EQUAL(OUString("OutlineLevel2"), conditions
[9].Name
);
1292 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents 5")), conditions
[9].Value
);
1293 CPPUNIT_ASSERT_EQUAL(OUString("OutlineLevel3"), conditions
[10].Name
);
1294 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents 6")), conditions
[10].Value
);
1295 CPPUNIT_ASSERT_EQUAL(OUString("OutlineLevel4"), conditions
[11].Name
);
1296 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents 7")), conditions
[11].Value
);
1297 CPPUNIT_ASSERT_EQUAL(OUString("OutlineLevel5"), conditions
[12].Name
);
1298 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents 8")), conditions
[12].Value
);
1299 CPPUNIT_ASSERT_EQUAL(OUString("OutlineLevel6"), conditions
[13].Name
);
1300 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents 9")), conditions
[13].Value
);
1301 CPPUNIT_ASSERT_EQUAL(OUString("OutlineLevel7"), conditions
[14].Name
);
1302 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents 10")), conditions
[14].Value
);
1303 CPPUNIT_ASSERT_EQUAL(OUString("OutlineLevel8"), conditions
[15].Name
);
1304 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Contents Heading")), conditions
[15].Value
);
1305 CPPUNIT_ASSERT_EQUAL(OUString("OutlineLevel9"), conditions
[16].Name
);
1306 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Standard")), conditions
[16].Value
);
1307 CPPUNIT_ASSERT_EQUAL(OUString("OutlineLevel10"), conditions
[17].Name
);
1308 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Drawing")), conditions
[17].Value
);
1309 CPPUNIT_ASSERT_EQUAL(OUString("NumberingLevel1"), conditions
[18].Name
);
1310 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Endnote")), conditions
[18].Value
);
1311 CPPUNIT_ASSERT_EQUAL(OUString("NumberingLevel2"), conditions
[19].Name
);
1312 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("First line indent")), conditions
[19].Value
);
1313 CPPUNIT_ASSERT_EQUAL(OUString("NumberingLevel3"), conditions
[20].Name
);
1314 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Footer")), conditions
[20].Value
);
1315 CPPUNIT_ASSERT_EQUAL(OUString("NumberingLevel4"), conditions
[21].Name
);
1316 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Footer left")), conditions
[21].Value
);
1317 CPPUNIT_ASSERT_EQUAL(OUString("NumberingLevel5"), conditions
[22].Name
);
1318 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Footer right")), conditions
[22].Value
);
1319 CPPUNIT_ASSERT_EQUAL(OUString("NumberingLevel6"), conditions
[23].Name
);
1320 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Footnote")), conditions
[23].Value
);
1321 CPPUNIT_ASSERT_EQUAL(OUString("NumberingLevel7"), conditions
[24].Name
);
1322 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Frame contents")), conditions
[24].Value
);
1323 CPPUNIT_ASSERT_EQUAL(OUString("NumberingLevel8"), conditions
[25].Name
);
1324 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Hanging indent")), conditions
[25].Value
);
1325 CPPUNIT_ASSERT_EQUAL(OUString("NumberingLevel9"), conditions
[26].Name
);
1326 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Header")), conditions
[26].Value
);
1327 CPPUNIT_ASSERT_EQUAL(OUString("NumberingLevel10"), conditions
[27].Name
);
1328 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Header left")), conditions
[27].Value
);
1331 DECLARE_ODFEXPORT_TEST(testTextframeTransparentShadow
, "textframe-transparent-shadow.odt")
1333 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1334 CPPUNIT_ASSERT_EQUAL(1, getPages());
1335 uno::Reference
<drawing::XShape
> xPicture
= getShape(1);
1336 // ODF stores opacity of 75%, that means 25% transparency.
1337 CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty
<sal_Int32
>(xPicture
, "ShadowTransparence"));
1340 DECLARE_ODFEXPORT_TEST(testRelhPage
, "relh-page.odt")
1342 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1343 CPPUNIT_ASSERT_EQUAL(1, getPages());
1344 uno::Reference
<drawing::XShape
> xTextFrame
= getShape(1);
1345 // This was text::RelOrientation::FRAME (the default), RelativeHeightRelation was not handled in xmloff.
1346 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xTextFrame
, "RelativeHeightRelation"));
1347 // Make sure rel-height-rel doesn't affect width.
1348 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME
, getProperty
<sal_Int16
>(xTextFrame
, "RelativeWidthRelation"));
1350 // This was 2601, 20% height was relative from margin, not page.
1351 CPPUNIT_ASSERT_EQUAL(sal_Int32(3168), parseDump("/root/page/body/txt/anchored/fly/infos/bounds", "height").toInt32());
1354 DECLARE_ODFEXPORT_TEST(testRelhPageTdf80282
, "relh-page-tdf80282.odt")
1356 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1357 CPPUNIT_ASSERT_EQUAL(1, getPages());
1358 uno::Reference
<drawing::XShape
> xTextFrame
= getShape(1);
1359 CPPUNIT_ASSERT_EQUAL_MESSAGE("Height", sal_Int32(8391), parseDump("//anchored/fly/infos/bounds", "height").toInt32());
1360 CPPUNIT_ASSERT_EQUAL_MESSAGE("Width", sal_Int32(5953), parseDump("//anchored/fly/infos/bounds", "width").toInt32());
1363 DECLARE_ODFEXPORT_TEST(testRelwPage
, "relw-page.odt")
1365 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1366 CPPUNIT_ASSERT_EQUAL(1, getPages());
1367 uno::Reference
<drawing::XShape
> xTextFrame
= getShape(1);
1368 // This was text::RelOrientation::FRAME (the default), RelativeWidthRelation was not handled in xmloff.
1369 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xTextFrame
, "RelativeWidthRelation"));
1370 // Make sure rel-width-rel doesn't affect height.
1371 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME
, getProperty
<sal_Int16
>(xTextFrame
, "RelativeHeightRelation"));
1373 // This was 3762, 40% width was relative from margin, not page.
1374 CPPUNIT_ASSERT_EQUAL(sal_Int32(4896), parseDump("/root/page/body/txt/anchored/fly/infos/bounds", "width").toInt32());
1377 DECLARE_ODFEXPORT_TEST(testTextFrameVertAdjust
, "textframe-vertadjust.odt")
1379 CPPUNIT_ASSERT_EQUAL(3, getShapes());
1380 CPPUNIT_ASSERT_EQUAL(1, getPages());
1381 // Test import/export of new frame attribute called TextVerticalAdjust
1383 // 1st frame's context is adjusted to the top
1384 uno::Reference
<beans::XPropertySet
> xFrame(getTextFrameByName("Rectangle 1"), uno::UNO_QUERY
);
1385 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP
, getProperty
<drawing::TextVerticalAdjust
>(xFrame
, "TextVerticalAdjust"));
1386 // 2nd frame's context is adjusted to the center
1387 xFrame
.set(getTextFrameByName("Rectangle 2"), uno::UNO_QUERY
);
1388 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_CENTER
, getProperty
<drawing::TextVerticalAdjust
>(xFrame
, "TextVerticalAdjust"));
1389 // 3rd frame's context is adjusted to the bottom
1390 xFrame
.set(getTextFrameByName("Rectangle 3"), uno::UNO_QUERY
);
1391 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM
, getProperty
<drawing::TextVerticalAdjust
>(xFrame
, "TextVerticalAdjust"));
1394 DECLARE_ODFEXPORT_TEST(testTdf111891_frameVertStyle
, "tdf111891_frameVertStyle.odt")
1396 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1397 CPPUNIT_ASSERT_EQUAL(1, getPages());
1398 uno::Reference
<beans::XPropertySet
> xFrame(getShape(1), uno::UNO_QUERY
);
1399 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM
, getProperty
<drawing::TextVerticalAdjust
>(xFrame
, "TextVerticalAdjust"));
1402 DECLARE_ODFEXPORT_TEST(testShapeRelsize
, "shape-relsize.odt")
1404 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1405 CPPUNIT_ASSERT_EQUAL(1, getPages());
1406 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1407 // These were all 0, as style:rel-width/height was ignored on import for shapes.
1408 CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty
<sal_Int16
>(xShape
, "RelativeWidth"));
1409 CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty
<sal_Int16
>(xShape
, "RelativeHeight"));
1411 // Relation was "page" for both width and height, should be "paragraph" for width.
1412 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME
, getProperty
<sal_Int16
>(xShape
, "RelativeWidthRelation"));
1413 // And make sure that height stays "page".
1414 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME
, getProperty
<sal_Int16
>(xShape
, "RelativeHeightRelation"));
1417 DECLARE_ODFEXPORT_TEST(testTextboxRoundedCorners
, "textbox-rounded-corners.odt")
1419 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1420 CPPUNIT_ASSERT_EQUAL(1, getPages());
1421 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1422 comphelper::SequenceAsHashMap
aCustomShapeGeometry(getProperty
< uno::Sequence
<beans::PropertyValue
> >(xShape
, "CustomShapeGeometry"));
1424 // Test that the shape is a rounded rectangle.
1425 CPPUNIT_ASSERT_EQUAL(OUString("round-rectangle"), aCustomShapeGeometry
["Type"].get
<OUString
>());
1427 // The shape text should start with a table, with "a" in its A1 cell.
1428 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY_THROW
)->getText();
1429 uno::Reference
<text::XTextTable
> xTable(getParagraphOrTable(1, xText
), uno::UNO_QUERY
);
1430 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1431 CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell
->getString());
1433 // Table inside a textbox should be in the extension namespace.
1436 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
1437 // This failed, as draw:custom-shape had a table:table child.
1438 assertXPath(pXmlDoc
, "//draw:custom-shape/loext:table", "name", "Table1");
1442 // test that import whitespace collapsing is compatible with old docs
1443 DECLARE_ODFEXPORT_TEST(testWhitespace
, "whitespace.odt")
1445 CPPUNIT_ASSERT_EQUAL(4, getShapes());
1446 CPPUNIT_ASSERT_EQUAL(1, getPages());
1447 uno::Reference
<container::XEnumerationAccess
> xPara
;
1448 uno::Reference
<container::XEnumeration
> xPortions
;
1449 uno::Reference
<text::XTextRange
> xPortion
;
1450 xPara
.set(getParagraphOrTable(1), uno::UNO_QUERY
);
1451 xPortions
.set(xPara
->createEnumeration());
1452 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1453 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1454 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1455 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1456 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1457 CPPUNIT_ASSERT_EQUAL(OUString(" "), xPortion
->getString());
1458 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1459 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1460 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1461 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1463 xPara
.set(getParagraphOrTable(2), uno::UNO_QUERY
);
1464 xPortions
.set(xPara
->createEnumeration());
1465 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1466 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1467 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1468 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1469 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1470 CPPUNIT_ASSERT_EQUAL(OUString(" "), xPortion
->getString());
1471 CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/"), getProperty
<OUString
>(xPortion
, "HyperLinkURL"));
1472 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1473 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1474 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1475 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1477 xPara
.set(getParagraphOrTable(3), uno::UNO_QUERY
);
1478 xPortions
.set(xPara
->createEnumeration());
1479 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1480 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1481 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1482 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1483 CPPUNIT_ASSERT_EQUAL(OUString("Ruby"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1484 CPPUNIT_ASSERT_EQUAL(OUString(), xPortion
->getString());
1485 CPPUNIT_ASSERT_EQUAL(OUString("foo"), getProperty
<OUString
>(xPortion
, "RubyText"));
1486 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1487 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1488 CPPUNIT_ASSERT_EQUAL(OUString(" "), xPortion
->getString());
1489 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1490 CPPUNIT_ASSERT_EQUAL(OUString("Ruby"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1491 CPPUNIT_ASSERT_EQUAL(OUString(), xPortion
->getString());
1492 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1493 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1494 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1495 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1497 xPara
.set(getParagraphOrTable(4), uno::UNO_QUERY
);
1498 xPortions
.set(xPara
->createEnumeration());
1499 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1500 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1501 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1502 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1503 CPPUNIT_ASSERT_EQUAL(OUString("InContentMetadata"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1505 // what a stupid idea to require recursively enumerating this
1506 uno::Reference
<container::XEnumerationAccess
> xMeta(
1507 getProperty
<uno::Reference
<text::XTextContent
>>(xPortion
, "InContentMetadata"), uno::UNO_QUERY
);
1508 uno::Reference
<container::XEnumeration
> xMetaPortions
=
1509 xMeta
->createEnumeration();
1510 uno::Reference
<text::XTextRange
> xMP(xMetaPortions
->nextElement(), uno::UNO_QUERY
);
1511 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xMP
, "TextPortionType"));
1512 CPPUNIT_ASSERT_EQUAL(OUString(" "), xMP
->getString());
1513 CPPUNIT_ASSERT(!xMetaPortions
->hasMoreElements());
1515 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1516 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1517 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1518 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1520 xPara
.set(getParagraphOrTable(5), uno::UNO_QUERY
);
1521 xPortions
.set(xPara
->createEnumeration());
1522 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1523 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1524 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1525 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1526 CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1528 // what a stupid idea to require recursively enumerating this
1529 uno::Reference
<container::XEnumerationAccess
> xMeta(
1530 getProperty
<uno::Reference
<text::XTextContent
>>(xPortion
, "TextField"), uno::UNO_QUERY
);
1531 uno::Reference
<container::XEnumeration
> xMetaPortions
=
1532 xMeta
->createEnumeration();
1533 uno::Reference
<text::XTextRange
> xMP(xMetaPortions
->nextElement(), uno::UNO_QUERY
);
1534 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xMP
, "TextPortionType"));
1535 CPPUNIT_ASSERT_EQUAL(OUString(" "), xMP
->getString());
1536 CPPUNIT_ASSERT(!xMetaPortions
->hasMoreElements());
1538 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1539 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1540 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1541 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1543 xPara
.set(getParagraphOrTable(7), uno::UNO_QUERY
);
1544 xPortions
.set(xPara
->createEnumeration());
1545 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1546 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1547 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1548 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1549 CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1550 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1551 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1552 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1553 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1555 xPara
.set(getParagraphOrTable(8), uno::UNO_QUERY
);
1556 xPortions
.set(xPara
->createEnumeration());
1557 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1558 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1559 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1560 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1561 CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1562 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1563 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1564 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1565 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1567 xPara
.set(getParagraphOrTable(9), uno::UNO_QUERY
);
1568 xPortions
.set(xPara
->createEnumeration());
1569 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1570 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1571 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1572 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1573 CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1574 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1575 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1576 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1577 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1579 xPara
.set(getParagraphOrTable(10), uno::UNO_QUERY
);
1580 uno::Reference
<container::XContentEnumerationAccess
> xCEA(xPara
, uno::UNO_QUERY
);
1581 uno::Reference
<container::XEnumeration
> xFrames(
1582 xCEA
->createContentEnumeration("com.sun.star.text.TextContent"));
1583 xFrames
->nextElement(); // one at-paragraph frame
1584 CPPUNIT_ASSERT(!xFrames
->hasMoreElements());
1585 xPortions
.set(xPara
->createEnumeration());
1586 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1587 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1588 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1589 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1591 xPara
.set(getParagraphOrTable(11), uno::UNO_QUERY
);
1592 xPortions
.set(xPara
->createEnumeration());
1593 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1594 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1595 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1596 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1597 CPPUNIT_ASSERT_EQUAL(OUString("Footnote"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1598 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1599 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1600 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1601 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1603 xPara
.set(getParagraphOrTable(12), uno::UNO_QUERY
);
1604 xPortions
.set(xPara
->createEnumeration());
1605 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1606 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1607 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1608 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1609 CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1610 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1611 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1612 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1613 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1615 xPara
.set(getParagraphOrTable(13), uno::UNO_QUERY
);
1616 xPortions
.set(xPara
->createEnumeration());
1617 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1618 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1619 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1620 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1621 CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1622 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1623 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1624 CPPUNIT_ASSERT_EQUAL(OUString(" "), xPortion
->getString());
1625 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1626 CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1627 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1628 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1629 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1630 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1632 xPara
.set(getParagraphOrTable(15), uno::UNO_QUERY
);
1633 xPortions
.set(xPara
->createEnumeration());
1634 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1635 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1636 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1637 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1638 CPPUNIT_ASSERT_EQUAL(OUString("Bookmark"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1639 CPPUNIT_ASSERT(getProperty
<bool>(xPortion
, "IsCollapsed"));
1640 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1641 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1642 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1643 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1645 xPara
.set(getParagraphOrTable(16), uno::UNO_QUERY
);
1646 xPortions
.set(xPara
->createEnumeration());
1647 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1648 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1649 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1650 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1651 CPPUNIT_ASSERT_EQUAL(OUString("Bookmark"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1652 CPPUNIT_ASSERT(!getProperty
<bool>(xPortion
, "IsCollapsed"));
1653 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1654 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1655 CPPUNIT_ASSERT_EQUAL(OUString(" "), xPortion
->getString());
1656 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1657 CPPUNIT_ASSERT_EQUAL(OUString("Bookmark"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1658 CPPUNIT_ASSERT(!getProperty
<bool>(xPortion
, "IsCollapsed"));
1659 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1660 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1661 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1662 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1664 xPara
.set(getParagraphOrTable(17), uno::UNO_QUERY
);
1665 xPortions
.set(xPara
->createEnumeration());
1666 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1667 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1668 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1669 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1670 CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1671 CPPUNIT_ASSERT(!getProperty
<bool>(xPortion
, "IsCollapsed"));
1672 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1673 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1674 CPPUNIT_ASSERT_EQUAL(OUString(" "), xPortion
->getString());
1675 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1676 CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1677 CPPUNIT_ASSERT(!getProperty
<bool>(xPortion
, "IsCollapsed"));
1678 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1679 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1680 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1681 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1683 xPara
.set(getParagraphOrTable(18), uno::UNO_QUERY
);
1684 xPortions
.set(xPara
->createEnumeration());
1685 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1686 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1687 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1688 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1689 CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1690 CPPUNIT_ASSERT(!getProperty
<bool>(xPortion
, "IsCollapsed"));
1691 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1692 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1693 CPPUNIT_ASSERT_EQUAL(OUString(" "), xPortion
->getString());
1694 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1695 CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1696 CPPUNIT_ASSERT(!getProperty
<bool>(xPortion
, "IsCollapsed"));
1697 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1698 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1699 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1700 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1702 xPara
.set(getParagraphOrTable(19), uno::UNO_QUERY
);
1703 xPortions
.set(xPara
->createEnumeration());
1704 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1705 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1706 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1707 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1708 CPPUNIT_ASSERT_EQUAL(OUString("ReferenceMark"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1709 CPPUNIT_ASSERT(getProperty
<bool>(xPortion
, "IsCollapsed"));
1710 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1711 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1712 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1713 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1715 xPara
.set(getParagraphOrTable(20), uno::UNO_QUERY
);
1716 xPortions
.set(xPara
->createEnumeration());
1717 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1718 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1719 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1720 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1721 CPPUNIT_ASSERT_EQUAL(OUString("ReferenceMark"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1722 CPPUNIT_ASSERT(!getProperty
<bool>(xPortion
, "IsCollapsed"));
1723 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1724 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1725 CPPUNIT_ASSERT_EQUAL(OUString(" "), xPortion
->getString());
1726 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1727 CPPUNIT_ASSERT_EQUAL(OUString("ReferenceMark"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1728 CPPUNIT_ASSERT(!getProperty
<bool>(xPortion
, "IsCollapsed"));
1729 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1730 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1731 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1732 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1734 xPara
.set(getParagraphOrTable(21), uno::UNO_QUERY
);
1735 xPortions
.set(xPara
->createEnumeration());
1736 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1737 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1738 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1739 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1740 CPPUNIT_ASSERT_EQUAL(OUString("DocumentIndexMark"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1741 CPPUNIT_ASSERT(getProperty
<bool>(xPortion
, "IsCollapsed"));
1742 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1743 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1744 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1745 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1747 xPara
.set(getParagraphOrTable(22), uno::UNO_QUERY
);
1748 xPortions
.set(xPara
->createEnumeration());
1749 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1750 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1751 CPPUNIT_ASSERT_EQUAL(OUString("X "), xPortion
->getString());
1752 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1753 CPPUNIT_ASSERT_EQUAL(OUString("DocumentIndexMark"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1754 CPPUNIT_ASSERT(!getProperty
<bool>(xPortion
, "IsCollapsed"));
1755 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1756 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1757 CPPUNIT_ASSERT_EQUAL(OUString(" "), xPortion
->getString());
1758 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1759 CPPUNIT_ASSERT_EQUAL(OUString("DocumentIndexMark"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1760 CPPUNIT_ASSERT(!getProperty
<bool>(xPortion
, "IsCollapsed"));
1761 xPortion
.set(xPortions
->nextElement(), uno::UNO_QUERY
);
1762 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(xPortion
, "TextPortionType"));
1763 CPPUNIT_ASSERT_EQUAL(OUString(" X"), xPortion
->getString());
1764 CPPUNIT_ASSERT(!xPortions
->hasMoreElements());
1767 DECLARE_ODFEXPORT_TEST(testTdf136645
, "tdf136645.odt")
1769 CPPUNIT_ASSERT_EQUAL(1, getPages());
1771 // Without the fix in place, this would have failed with
1774 CPPUNIT_ASSERT_EQUAL(sal_Int32(2640), parseDump("/root/page/body/section/column[1]/body/infos/bounds", "width").toInt32());
1778 CPPUNIT_ASSERT_EQUAL(sal_Int32(6000), parseDump("/root/page/body/section/column[2]/body/infos/bounds", "width").toInt32());
1781 DECLARE_ODFEXPORT_TEST(testBtlrCell
, "btlr-cell.odt")
1783 CPPUNIT_ASSERT_EQUAL(1, getPages());
1784 // Without the accompanying fix in place, this test would have failed, as
1785 // the btlr text direction in the A1 cell was lost on ODF import and
1787 uno::Reference
<text::XTextTablesSupplier
> xSupplier(mxComponent
, uno::UNO_QUERY
);
1788 uno::Reference
<container::XNameAccess
> xTables
= xSupplier
->getTextTables();
1789 uno::Reference
<text::XTextTable
> xTable(xTables
->getByName("Table1"), uno::UNO_QUERY
);
1790 uno::Reference
<beans::XPropertySet
> xA1(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1791 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR
, getProperty
<sal_Int16
>(xA1
, "WritingMode"));
1793 uno::Reference
<beans::XPropertySet
> xB1(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
1794 auto nActual
= getProperty
<sal_Int16
>(xB1
, "WritingMode");
1795 CPPUNIT_ASSERT(nActual
== text::WritingMode2::LR_TB
|| nActual
== text::WritingMode2::CONTEXT
);
1797 uno::Reference
<beans::XPropertySet
> xC1(xTable
->getCellByName("C1"), uno::UNO_QUERY
);
1798 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL
, getProperty
<sal_Int16
>(xC1
, "WritingMode"));
1801 DECLARE_ODFEXPORT_TEST(testBtlrFrame
, "btlr-frame.odt")
1803 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1804 CPPUNIT_ASSERT_EQUAL(1, getPages());
1805 // Without the accompanying fix in place, this test would have failed, as
1806 // the btlr text direction in the text frame was lost on ODF import and
1808 uno::Reference
<beans::XPropertySet
> xTextFrame(getShape(1), uno::UNO_QUERY
);
1809 CPPUNIT_ASSERT(xTextFrame
.is());
1811 auto nActual
= getProperty
<sal_Int16
>(xTextFrame
, "WritingMode");
1812 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR
, nActual
);
1814 // Without the accompanying fix in place, this test would have failed, as the fly frame had
1815 // mbVertical==true, but mbVertLRBT==false, even if the writing direction in the doc model was
1817 SwXTextDocument
* pTextDoc
= dynamic_cast<SwXTextDocument
*>(mxComponent
.get());
1818 CPPUNIT_ASSERT(pTextDoc
);
1820 SwDoc
* pDoc
= pTextDoc
->GetDocShell()->GetDoc();
1821 CPPUNIT_ASSERT(pDoc
);
1823 SwRootFrame
* pLayout
= pDoc
->getIDocumentLayoutAccess().GetCurrentLayout();
1824 CPPUNIT_ASSERT(pLayout
);
1826 SwFrame
* pPageFrame
= pLayout
->GetLower();
1827 CPPUNIT_ASSERT(pPageFrame
);
1828 CPPUNIT_ASSERT(pPageFrame
->IsPageFrame());
1830 SwFrame
* pBodyFrame
= pPageFrame
->GetLower();
1831 CPPUNIT_ASSERT(pBodyFrame
);
1832 CPPUNIT_ASSERT(pBodyFrame
->IsBodyFrame());
1834 SwFrame
* pBodyTextFrame
= pBodyFrame
->GetLower();
1835 CPPUNIT_ASSERT(pBodyTextFrame
);
1836 CPPUNIT_ASSERT(pBodyTextFrame
->IsTextFrame());
1838 CPPUNIT_ASSERT(pBodyTextFrame
->GetDrawObjs());
1839 const SwSortedObjs
& rAnchored
= *pBodyTextFrame
->GetDrawObjs();
1840 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rAnchored
.size());
1842 auto* pFlyFrame
= dynamic_cast<SwFlyFrame
*>(rAnchored
[0]);
1843 CPPUNIT_ASSERT(pFlyFrame
);
1844 CPPUNIT_ASSERT(pFlyFrame
->IsVertLRBT());
1847 // Not yet exported, don't modify the doc model for test purposes.
1850 // Make sure that btlr -> tbrl transition clears the "BT" flag.
1851 xTextFrame
->setPropertyValue("WritingMode", uno::Any(text::WritingMode2::TB_LR
));
1852 pFlyFrame
= dynamic_cast<SwFlyFrame
*>(rAnchored
[0]);
1853 CPPUNIT_ASSERT(pFlyFrame
);
1854 CPPUNIT_ASSERT(!pFlyFrame
->IsVertLRBT());
1857 CPPUNIT_TEST_FIXTURE(Test
, testTdf129520
)
1859 loadAndReload("tdf129520.docx");
1860 CPPUNIT_ASSERT_EQUAL(1, getPages());
1861 CPPUNIT_ASSERT_EQUAL(OUString("M"), getParagraph(1)->getString());
1863 // Without this fix in place, this test would have failed with
1866 CPPUNIT_ASSERT_EQUAL(OUString("Ma"), getParagraph(2)->getString());
1867 CPPUNIT_ASSERT_EQUAL(OUString("1815"), getParagraph(3)->getString());
1870 DECLARE_ODFEXPORT_TEST(testFdo86963
, "fdo86963.odt")
1872 CPPUNIT_ASSERT_EQUAL(1, getPages());
1873 // Export of this document failed with beans::UnknownPropertyException.
1874 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1877 // Check for correct header/footer with special first page with TOC inside:
1878 // - DECLARE_ODFEXPORT_TEST(testTdf118393, "tdf118393.odt")
1879 // - DECLARE_OOXMLEXPORT_TEST(testTdf118393, "tdf118393.odt")
1880 DECLARE_ODFEXPORT_TEST(testTdf118393
, "tdf118393.odt")
1882 CPPUNIT_ASSERT_EQUAL( 7, getPages() );
1884 // First page has no header/footer
1886 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
1889 assertXPath(pXmlDoc
, "/root/page[1]/header", 0);
1890 assertXPath(pXmlDoc
, "/root/page[1]/footer", 0);
1892 // check second page in the same way
1893 assertXPath(pXmlDoc
, "/root/page[2]/header");
1894 assertXPath(pXmlDoc
, "/root/page[2]/footer");
1897 // All other pages should have header/footer
1899 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/header/txt/text()"));
1900 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/footer/txt/text()"));
1902 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/header/txt/text()"));
1903 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/footer/txt/text()"));
1905 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/header/txt/text()"));
1906 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/footer/txt/text()"));
1908 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/header/txt/text()"));
1909 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/footer/txt/text()"));
1911 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/header/txt/text()"));
1912 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/footer/txt/text()"));
1914 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/header/txt/text()"));
1915 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/footer/txt/text()"));
1918 DECLARE_ODFEXPORT_TEST(testTdf135338_firstLeftPageFooter
, "tdf135338_firstLeftPageFooter.odt")
1920 CPPUNIT_ASSERT_EQUAL(6, getPages());
1921 // The first page is a left page only style, but it should still show the first page footer
1922 // instead of the left footer text "EVEN/LEFT (Left page only)"
1923 CPPUNIT_ASSERT_EQUAL(OUString("First (Left page only)"), parseDump("/root/page[2]/footer/txt/text()"));
1926 DECLARE_ODFEXPORT_TEST(testGerrit13858
, "gerrit13858.odt")
1928 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1929 CPPUNIT_ASSERT_EQUAL(1, getPages());
1930 // Just make sure the output is valid.
1932 DECLARE_ODFEXPORT_TEST(testOdtBorderTypes
, "border_types.odt")
1934 CPPUNIT_ASSERT_EQUAL(1, getPages());
1935 static const sal_Int32 lineStyles
[] = { 0, 1, 2, 14, 16, 17, 3, 15 };
1936 uno::Reference
<text::XTextDocument
> textDocument(mxComponent
, uno::UNO_QUERY
);
1937 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(textDocument
->getText(), uno::UNO_QUERY
);
1938 // list of paragraphs
1939 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
1942 uno::Reference
<lang::XServiceInfo
> xServiceInfo
;
1943 if (xParaEnum
->nextElement() >>= xServiceInfo
)
1945 if (xServiceInfo
->supportsService("com.sun.star.text.TextTable"))
1947 uno::Reference
<table::XCellRange
> const xCellRange(xServiceInfo
, uno::UNO_QUERY_THROW
);
1949 for (sal_Int32 row
= 0; row
< 15; row
+= 2)
1951 uno::Reference
<table::XCell
> xCell
= xCellRange
->getCellByPosition(1, row
);
1952 uno::Reference
< beans::XPropertySet
> xPropSet(xCell
, uno::UNO_QUERY_THROW
);
1954 uno::Any aTopBorder
= xPropSet
->getPropertyValue("TopBorder");
1955 table::BorderLine2 aTopBorderLine
;
1956 if (aTopBorder
>>= aTopBorderLine
)
1958 sal_Int32 lineStyle
= aTopBorderLine
.LineStyle
;
1959 CPPUNIT_ASSERT_EQUAL(lineStyles
[row
/ 2], lineStyle
);
1961 } //end of the 'for' loop
1964 } while (xParaEnum
->hasMoreElements());
1967 DECLARE_ODFEXPORT_TEST(testMasterPageWithDrawingPage
, "sw_hatch.odt")
1969 CPPUNIT_ASSERT_EQUAL(1, getPages());
1970 uno::Reference
<container::XNameAccess
> xStyles(getStyles("PageStyles"));
1971 uno::Reference
<beans::XPropertySet
> xStyle(xStyles
->getByName("Standard"), uno::UNO_QUERY
);
1972 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH
, getProperty
<drawing::FillStyle
>(xStyle
, "FillStyle"));
1973 CPPUNIT_ASSERT_EQUAL(OUString("Blue -45 Degrees"), getProperty
<OUString
>(xStyle
, "FillHatchName"));
1974 CPPUNIT_ASSERT(!getProperty
<sal_Bool
>(xStyle
, "FillBackground"));
1975 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(xStyle
, "FillTransparence"));
1978 CPPUNIT_TEST_FIXTURE(Test
, testPageStyleBackgroundFullSizeOOo
)
1980 loadAndReload("pagestyle_background_ooo33.odt");
1981 CPPUNIT_ASSERT_EQUAL(3, getPages());
1982 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
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='Standard']/attribute::draw:style-name"
1987 "]/style:drawing-page-properties", "background-size", "border");
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='Standard']/attribute::draw:style-name"
1991 "]/style:drawing-page-properties", "fill", "solid");
1992 assertXPath(pXmlDoc
,
1993 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1994 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
1995 "]/style:drawing-page-properties", "fill-color", "#99ccff");
1996 assertXPath(pXmlDoc
,
1997 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
1998 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
1999 "]/style:drawing-page-properties", "opacity", "100%");
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='Endnote']/attribute::draw:style-name"
2004 "]/style:drawing-page-properties", "background-size", "border");
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='Endnote']/attribute::draw:style-name"
2008 "]/style:drawing-page-properties", "fill", "bitmap");
2009 assertXPath(pXmlDoc
,
2010 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2011 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2012 "]/style:drawing-page-properties", "repeat", "repeat");
2013 assertXPath(pXmlDoc
,
2014 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2015 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2016 "]/style:drawing-page-properties", "fill-image-ref-point", "top-left");
2018 assertXPath(pXmlDoc
,
2019 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2020 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2021 "]/style:drawing-page-properties", "background-size", "border");
2022 assertXPath(pXmlDoc
,
2023 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2024 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2025 "]/style:drawing-page-properties", "fill", "bitmap");
2026 assertXPath(pXmlDoc
,
2027 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2028 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2029 "]/style:drawing-page-properties", "repeat", "stretch");
2030 assertXPath(pXmlDoc
,
2031 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2032 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2033 "]/style:drawing-page-properties", "fill-image-ref-point", "top-left");
2036 CPPUNIT_TEST_FIXTURE(Test
, testPageStyleBackgroundFullSizeLO64
)
2038 loadAndReload("pagestyle_background_lo64.odt");
2039 CPPUNIT_ASSERT_EQUAL(6, getPages());
2040 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
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='Standard']/attribute::draw:style-name"
2045 "]/style:drawing-page-properties", "background-size", "full");
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='Standard']/attribute::draw:style-name"
2049 "]/style:drawing-page-properties", "fill", "solid");
2050 assertXPath(pXmlDoc
,
2051 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2052 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2053 "]/style:drawing-page-properties", "fill-color", "#99ccff");
2054 assertXPath(pXmlDoc
,
2055 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2056 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2057 "]/style:drawing-page-properties", "opacity", "100%");
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='Endnote']/attribute::draw:style-name"
2062 "]/style:drawing-page-properties", "background-size", "full");
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='Endnote']/attribute::draw:style-name"
2066 "]/style:drawing-page-properties", "fill", "bitmap");
2067 assertXPath(pXmlDoc
,
2068 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2069 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2070 "]/style:drawing-page-properties", "repeat", "repeat");
2071 assertXPath(pXmlDoc
,
2072 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2073 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2074 "]/style:drawing-page-properties", "fill-image-ref-point", "top-left");
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='Footnote']/attribute::draw:style-name"
2079 "]/style:drawing-page-properties", "background-size", "border");
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='Footnote']/attribute::draw:style-name"
2083 "]/style:drawing-page-properties", "fill", "bitmap");
2084 assertXPath(pXmlDoc
,
2085 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2086 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2087 "]/style:drawing-page-properties", "repeat", "stretch");
2088 assertXPath(pXmlDoc
,
2089 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2090 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2091 "]/style:drawing-page-properties", "fill-image-ref-point", "top-left");
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='Landscape']/attribute::draw:style-name"
2096 "]/style:drawing-page-properties", "background-size", "border");
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='Landscape']/attribute::draw:style-name"
2100 "]/style:drawing-page-properties", "fill", "bitmap");
2101 assertXPath(pXmlDoc
,
2102 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2103 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2104 "]/style:drawing-page-properties", "repeat", "no-repeat");
2105 assertXPath(pXmlDoc
,
2106 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2107 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2108 "]/style:drawing-page-properties", "fill-image-ref-point", "top-left");
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='Index']/attribute::draw:style-name"
2113 "]/style:drawing-page-properties", "background-size", "full");
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='Index']/attribute::draw:style-name"
2117 "]/style:drawing-page-properties", "fill", "gradient");
2118 assertXPath(pXmlDoc
,
2119 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2120 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2121 "]/style:drawing-page-properties", "gradient-step-count", "0");
2122 assertXPath(pXmlDoc
,
2123 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2124 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2125 "]/style:drawing-page-properties", "opacity", "100%");
2127 assertXPath(pXmlDoc
,
2128 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2129 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2130 "]/style:drawing-page-properties", "background-size", "full");
2131 assertXPath(pXmlDoc
,
2132 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2133 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2134 "]/style:drawing-page-properties", "fill", "hatch");
2135 assertXPath(pXmlDoc
,
2136 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2137 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2138 "]/style:drawing-page-properties", "fill-hatch-solid", "false");
2139 assertXPath(pXmlDoc
,
2140 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2141 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2142 "]/style:drawing-page-properties", "opacity", "100%");
2145 CPPUNIT_TEST_FIXTURE(Test
, testPageStyleBackgroundFullSizeLO70
)
2147 loadAndReload("pagestyle_background_lo70.odt");
2148 CPPUNIT_ASSERT_EQUAL(6, getPages());
2149 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
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='Standard']/attribute::draw:style-name"
2154 "]/style:drawing-page-properties", "background-size", "full");
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='Standard']/attribute::draw:style-name"
2158 "]/style:drawing-page-properties", "fill", "solid");
2159 assertXPath(pXmlDoc
,
2160 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2161 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2162 "]/style:drawing-page-properties", "fill-color", "#99ccff");
2163 assertXPath(pXmlDoc
,
2164 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2165 "/office:document-styles/office:master-styles/style:master-page[@style:name='Standard']/attribute::draw:style-name"
2166 "]/style:drawing-page-properties", "opacity", "100%");
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='Endnote']/attribute::draw:style-name"
2171 "]/style:drawing-page-properties", "background-size", "full");
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='Endnote']/attribute::draw:style-name"
2175 "]/style:drawing-page-properties", "fill", "bitmap");
2176 assertXPath(pXmlDoc
,
2177 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2178 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2179 "]/style:drawing-page-properties", "repeat", "repeat");
2180 assertXPath(pXmlDoc
,
2181 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2182 "/office:document-styles/office:master-styles/style:master-page[@style:name='Endnote']/attribute::draw:style-name"
2183 "]/style:drawing-page-properties", "fill-image-ref-point", "top-left");
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='Footnote']/attribute::draw:style-name"
2188 "]/style:drawing-page-properties", "background-size", "border");
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='Footnote']/attribute::draw:style-name"
2192 "]/style:drawing-page-properties", "fill", "bitmap");
2193 assertXPath(pXmlDoc
,
2194 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2195 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2196 "]/style:drawing-page-properties", "repeat", "stretch");
2197 assertXPath(pXmlDoc
,
2198 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2199 "/office:document-styles/office:master-styles/style:master-page[@style:name='Footnote']/attribute::draw:style-name"
2200 "]/style:drawing-page-properties", "fill-image-ref-point", "top-left");
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='Landscape']/attribute::draw:style-name"
2205 "]/style:drawing-page-properties", "background-size", "border");
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='Landscape']/attribute::draw:style-name"
2209 "]/style:drawing-page-properties", "fill", "bitmap");
2210 assertXPath(pXmlDoc
,
2211 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2212 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2213 "]/style:drawing-page-properties", "repeat", "no-repeat");
2214 assertXPath(pXmlDoc
,
2215 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2216 "/office:document-styles/office:master-styles/style:master-page[@style:name='Landscape']/attribute::draw:style-name"
2217 "]/style:drawing-page-properties", "fill-image-ref-point", "top-left");
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='Index']/attribute::draw:style-name"
2222 "]/style:drawing-page-properties", "background-size", "full");
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='Index']/attribute::draw:style-name"
2226 "]/style:drawing-page-properties", "fill", "gradient");
2227 assertXPath(pXmlDoc
,
2228 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2229 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2230 "]/style:drawing-page-properties", "gradient-step-count", "0");
2231 assertXPath(pXmlDoc
,
2232 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2233 "/office:document-styles/office:master-styles/style:master-page[@style:name='Index']/attribute::draw:style-name"
2234 "]/style:drawing-page-properties", "opacity", "100%");
2236 assertXPath(pXmlDoc
,
2237 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2238 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2239 "]/style:drawing-page-properties", "background-size", "full");
2240 assertXPath(pXmlDoc
,
2241 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2242 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2243 "]/style:drawing-page-properties", "fill", "hatch");
2244 assertXPath(pXmlDoc
,
2245 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2246 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2247 "]/style:drawing-page-properties", "fill-hatch-solid", "false");
2248 assertXPath(pXmlDoc
,
2249 "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
2250 "/office:document-styles/office:master-styles/style:master-page[@style:name='First_20_Page']/attribute::draw:style-name"
2251 "]/style:drawing-page-properties", "opacity", "100%");
2254 CPPUNIT_TEST_FIXTURE(Test
, testFillBitmapUnused
)
2256 loadAndReload("fillbitmap3.odt");
2257 CPPUNIT_ASSERT_EQUAL(4, getShapes());
2258 CPPUNIT_ASSERT_EQUAL(1, getPages());
2259 // nav_5f_home and all its references are completely gone
2260 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
2263 assertXPath(pXmlDoc
,
2264 "/office:document-styles/office:styles/style:style[@style:name='Text_20_body']/loext:graphic-properties", "fill", "solid");
2265 assertXPath(pXmlDoc
,
2266 "/office:document-styles/office:styles/style:style[@style:name='Text_20_body']/loext:graphic-properties", "fill-color", "#c0c0c0");
2267 assertXPath(pXmlDoc
,
2268 "/office:document-styles/office:styles/style:style[@style:name='Text_20_body']/loext:graphic-properties[@draw:fill-image-name]", 0);
2270 // page style page-layout
2271 assertXPath(pXmlDoc
,
2272 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:page-layout-properties", "fill", "bitmap");
2273 assertXPath(pXmlDoc
,
2274 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:page-layout-properties", "fill-image-name", "nav_5f_up");
2275 assertXPath(pXmlDoc
,
2276 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:header-style/style:header-footer-properties", "fill", "bitmap");
2277 assertXPath(pXmlDoc
,
2278 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:header-style/style:header-footer-properties", "fill-image-name", "nav_5f_up");
2279 assertXPath(pXmlDoc
,
2280 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:footer-style/style:header-footer-properties", "fill", "bitmap");
2281 assertXPath(pXmlDoc
,
2282 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm1']/style:footer-style/style:header-footer-properties", "fill-image-name", "nav_5f_up");
2284 assertXPath(pXmlDoc
,
2285 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:page-layout-properties", "fill", "solid");
2286 assertXPath(pXmlDoc
,
2287 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:page-layout-properties[@draw:fill-image-name]", 0);
2288 assertXPath(pXmlDoc
,
2289 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:header-style/style:header-footer-properties", "fill", "solid");
2290 assertXPath(pXmlDoc
,
2291 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:header-style/style:header-footer-properties[@draw:fill-image-name]", 0);
2292 assertXPath(pXmlDoc
,
2293 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:footer-style/style:header-footer-properties", "fill", "solid");
2294 assertXPath(pXmlDoc
,
2295 "/office:document-styles/office:automatic-styles/style:page-layout[@style:name='Mpm2']/style:footer-style/style:header-footer-properties[@draw:fill-image-name]", 0);
2297 // page style drawing-page
2298 assertXPath(pXmlDoc
,
2299 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp1']/style:drawing-page-properties", "fill", "bitmap");
2300 assertXPath(pXmlDoc
,
2301 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp1']/style:drawing-page-properties", "fill-image-name", "nav_5f_up");
2302 assertXPath(pXmlDoc
,
2303 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/style:drawing-page-properties", "fill", "solid");
2304 assertXPath(pXmlDoc
,
2305 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/style:drawing-page-properties", "fill-color", "#c0c0c0");
2306 assertXPath(pXmlDoc
,
2307 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/style:drawing-page-properties[@draw:fill-image-name]", 0);
2310 assertXPath(pXmlDoc
,
2311 "/office:document-styles/office:styles/draw:fill-image", 1);
2312 assertXPath(pXmlDoc
,
2313 "/office:document-styles/office:styles/draw:fill-image", "name", "nav_5f_up");
2316 DECLARE_ODFEXPORT_TEST(testCellUserDefineAttr
, "userdefattr-tablecell.odt")
2318 CPPUNIT_ASSERT_EQUAL(1, getPages());
2319 uno::Reference
<text::XTextTable
> xTable(getParagraphOrTable(1), uno::UNO_QUERY
);
2320 uno::Reference
<table::XCell
> const xCellA1(xTable
->getCellByName("A1"), uno::UNO_SET_THROW
);
2321 uno::Reference
<table::XCell
> const xCellB1(xTable
->getCellByName("B1"), uno::UNO_SET_THROW
);
2322 uno::Reference
<table::XCell
> const xCellC1(xTable
->getCellByName("C1"), uno::UNO_SET_THROW
);
2323 getUserDefineAttribute(uno::Any(xCellA1
), "proName", "v1");
2324 getUserDefineAttribute(uno::Any(xCellB1
), "proName", "v2");
2325 getUserDefineAttribute(uno::Any(xCellC1
), "proName", "v3");
2328 DECLARE_ODFEXPORT_TEST(testEmbeddedPdf
, "embedded-pdf.odt")
2330 auto pPdfium
= vcl::pdf::PDFiumLibrary::get();
2336 CPPUNIT_ASSERT_EQUAL(1, getShapes());
2337 CPPUNIT_ASSERT_EQUAL(1, getPages());
2338 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
2339 // This failed, pdf+png replacement graphics pair didn't survive an ODT roundtrip.
2340 auto xReplacementGraphic
= getProperty
<uno::Reference
<graphic::XGraphic
>>(xShape
, "ReplacementGraphic");
2341 CPPUNIT_ASSERT(xReplacementGraphic
.is());
2343 auto xGraphic
= getProperty
<uno::Reference
<graphic::XGraphic
>>(xShape
, "Graphic");
2344 CPPUNIT_ASSERT(xGraphic
.is());
2345 // This was image/x-vclgraphic, not exposing the info that the image is a PDF one.
2346 CPPUNIT_ASSERT_EQUAL(OUString("application/pdf"), getProperty
<OUString
>(xGraphic
, "MimeType"));
2350 uno::Sequence
<uno::Any
> aArgs
{ uno::Any(maTempFile
.GetURL()) };
2351 uno::Reference
<container::XNameAccess
> xNameAccess(m_xSFactory
->createInstanceWithArguments("com.sun.star.packages.zip.ZipFileAccess", aArgs
), uno::UNO_QUERY
);
2352 bool bHasBitmap
= false;
2353 const uno::Sequence
<OUString
> aNames
= xNameAccess
->getElementNames();
2354 for (const auto& rElementName
: aNames
)
2356 if (rElementName
.startsWith("Pictures") && rElementName
.endsWith("png"))
2362 // This failed, replacement was an svm file.
2363 CPPUNIT_ASSERT(bHasBitmap
);
2367 DECLARE_ODFEXPORT_TEST(testTableStyles1
, "table_styles_1.odt")
2369 CPPUNIT_ASSERT_EQUAL(1, getPages());
2370 // Table styles basic graphic test.
2371 // Doesn't cover all attributes.
2372 uno::Reference
<style::XStyleFamiliesSupplier
> XFamiliesSupplier(mxComponent
, uno::UNO_QUERY
);
2373 uno::Reference
<container::XNameAccess
> xFamilies(XFamiliesSupplier
->getStyleFamilies());
2374 uno::Reference
<container::XNameAccess
> xCellFamily(xFamilies
->getByName("CellStyles"), uno::UNO_QUERY
);
2375 uno::Reference
<beans::XPropertySet
> xCell1Style
;
2376 xCellFamily
->getByName("Test style.1") >>= xCell1Style
;
2378 sal_Int32 nInt32
= 0xF0F0F0;
2379 table::BorderLine2 oBorder
;
2381 CPPUNIT_ASSERT_EQUAL(Color(0xCC0000), getProperty
<Color
>(xCell1Style
, "BackColor"));
2382 xCell1Style
->getPropertyValue("WritingMode") >>= nInt32
;
2383 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), nInt32
);
2384 xCell1Style
->getPropertyValue("VertOrient") >>= nInt32
;
2385 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32
);
2386 xCell1Style
->getPropertyValue("BorderDistance") >>= nInt32
;
2387 CPPUNIT_ASSERT_EQUAL(sal_Int32(97), nInt32
);
2388 xCell1Style
->getPropertyValue("LeftBorderDistance") >>= nInt32
;
2389 CPPUNIT_ASSERT_EQUAL(sal_Int32(97), nInt32
);
2390 xCell1Style
->getPropertyValue("RightBorderDistance") >>= nInt32
;
2391 CPPUNIT_ASSERT_EQUAL(sal_Int32(97), nInt32
);
2392 xCell1Style
->getPropertyValue("TopBorderDistance") >>= nInt32
;
2393 CPPUNIT_ASSERT_EQUAL(sal_Int32(97), nInt32
);
2394 xCell1Style
->getPropertyValue("BottomBorderDistance") >>= nInt32
;
2395 CPPUNIT_ASSERT_EQUAL(sal_Int32(97), nInt32
);
2396 xCell1Style
->getPropertyValue("RightBorder") >>= oBorder
;
2397 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), oBorder
.Color
);
2398 xCell1Style
->getPropertyValue("LeftBorder") >>= oBorder
;
2399 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, Color(ColorTransparency
, oBorder
.Color
));
2400 xCell1Style
->getPropertyValue("TopBorder") >>= oBorder
;
2401 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, Color(ColorTransparency
, oBorder
.Color
));
2402 xCell1Style
->getPropertyValue("BottomBorder") >>= oBorder
;
2403 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, Color(ColorTransparency
, oBorder
.Color
));
2406 DECLARE_ODFEXPORT_TEST(testTableStyles2
, "table_styles_2.odt")
2408 CPPUNIT_ASSERT_EQUAL(1, getPages());
2409 // Table styles paragraph and char tests
2410 // Doesn't cover all attributes.
2411 // Problem: underline for table autoformat doesn't work.
2412 uno::Reference
<style::XStyleFamiliesSupplier
> XFamiliesSupplier(mxComponent
, uno::UNO_QUERY
);
2413 uno::Reference
<container::XNameAccess
> xFamilies(XFamiliesSupplier
->getStyleFamilies());
2414 uno::Reference
<container::XNameAccess
> xTableFamily(xFamilies
->getByName("TableStyles"), uno::UNO_QUERY
);
2415 uno::Reference
<container::XNameAccess
> xTableStyle(xTableFamily
->getByName("Test style2"), uno::UNO_QUERY
);
2416 uno::Reference
<beans::XPropertySet
> xCell1Style
;
2420 sal_Int16 nInt16
= 0xF0;
2421 sal_Int32 nInt32
= 0xF0F0F0;
2423 awt::FontSlant eCharPosture
;
2426 xTableStyle
->getByName("first-row-start-column") >>= xCell1Style
;
2427 xCell1Style
->getPropertyValue("ParaAdjust") >>= nInt32
;
2428 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32
);
2429 CPPUNIT_ASSERT_EQUAL(Color(0xFF6600), getProperty
<Color
>(xCell1Style
, "CharColor"));
2430 xCell1Style
->getPropertyValue("CharContoured") >>= bBool
;
2431 CPPUNIT_ASSERT_EQUAL(false, bBool
);
2432 xCell1Style
->getPropertyValue("CharShadowed") >>= bBool
;
2433 CPPUNIT_ASSERT_EQUAL(true, bBool
);
2434 xCell1Style
->getPropertyValue("CharStrikeout") >>= nInt32
;
2435 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nInt32
);
2436 xCell1Style
->getPropertyValue("CharUnderline") >>= nInt32
;
2437 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32
);
2438 // underline color is not working for table autoformats
2439 // xCell1Style->getPropertyValue("CharUnderlineHasColor") >>= bBool;
2440 // CPPUNIT_ASSERT_EQUAL(bool(false), bBool);
2441 // xCell1Style->getPropertyValue("CharUnderlineColor") >>= nInt64;
2442 // CPPUNIT_ASSERT_EQUAL(sal_Int64(-1), nInt64);
2444 xCell1Style
->getPropertyValue("CharHeight") >>= fFloat
;
2445 CPPUNIT_ASSERT_EQUAL(float(18.), fFloat
);
2446 xCell1Style
->getPropertyValue("CharWeight") >>= fFloat
;
2447 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat
);
2448 xCell1Style
->getPropertyValue("CharPosture") >>= eCharPosture
;
2449 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE
, eCharPosture
);
2450 xCell1Style
->getPropertyValue("CharFontName") >>= sString
;
2451 CPPUNIT_ASSERT_EQUAL(OUString("Courier"), sString
);
2452 xCell1Style
->getPropertyValue("CharFontStyleName") >>= sString
;
2453 CPPUNIT_ASSERT_EQUAL(OUString(), sString
);
2454 xCell1Style
->getPropertyValue("CharFontFamily") >>= nInt16
;
2455 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16
);
2456 xCell1Style
->getPropertyValue("CharFontPitch") >>= nInt16
;
2457 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nInt16
);
2459 xCell1Style
->getPropertyValue("CharHeightAsian") >>= fFloat
;
2460 CPPUNIT_ASSERT_EQUAL(float(18.), fFloat
);
2461 xCell1Style
->getPropertyValue("CharWeightAsian") >>= fFloat
;
2462 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat
);
2463 xCell1Style
->getPropertyValue("CharPostureAsian") >>= eCharPosture
;
2464 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE
, eCharPosture
);
2465 xCell1Style
->getPropertyValue("CharFontNameAsian") >>= sString
;
2466 CPPUNIT_ASSERT_EQUAL(OUString("Courier"), sString
);
2467 xCell1Style
->getPropertyValue("CharFontStyleNameAsian") >>= sString
;
2468 CPPUNIT_ASSERT_EQUAL(OUString("Regularna"), sString
);
2469 xCell1Style
->getPropertyValue("CharFontFamilyAsian") >>= nInt16
;
2470 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16
);
2471 xCell1Style
->getPropertyValue("CharFontPitchAsian") >>= nInt16
;
2472 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nInt16
);
2474 xCell1Style
->getPropertyValue("CharHeightComplex") >>= fFloat
;
2475 CPPUNIT_ASSERT_EQUAL(float(18.), fFloat
);
2476 xCell1Style
->getPropertyValue("CharWeightComplex") >>= fFloat
;
2477 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat
);
2478 xCell1Style
->getPropertyValue("CharPostureComplex") >>= eCharPosture
;
2479 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE
, eCharPosture
);
2480 xCell1Style
->getPropertyValue("CharFontNameComplex") >>= sString
;
2481 CPPUNIT_ASSERT_EQUAL(OUString("Courier"), sString
);
2482 xCell1Style
->getPropertyValue("CharFontStyleNameComplex") >>= sString
;
2483 CPPUNIT_ASSERT_EQUAL(OUString("Regularna"), sString
);
2484 xCell1Style
->getPropertyValue("CharFontFamilyComplex") >>= nInt16
;
2485 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16
);
2486 xCell1Style
->getPropertyValue("CharFontPitchComplex") >>= nInt16
;
2487 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nInt16
);
2490 xTableStyle
->getByName("first-row") >>= xCell1Style
;
2491 xCell1Style
->getPropertyValue("ParaAdjust") >>= nInt32
;
2492 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nInt32
);
2493 CPPUNIT_ASSERT_EQUAL(Color(0x9900FF), getProperty
<Color
>(xCell1Style
, "CharColor"));
2494 xCell1Style
->getPropertyValue("CharContoured") >>= bBool
;
2495 CPPUNIT_ASSERT_EQUAL(true, bBool
);
2496 xCell1Style
->getPropertyValue("CharShadowed") >>= bBool
;
2497 CPPUNIT_ASSERT_EQUAL(false, bBool
);
2498 xCell1Style
->getPropertyValue("CharStrikeout") >>= nInt32
;
2499 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32
);
2500 xCell1Style
->getPropertyValue("CharUnderline") >>= nInt32
;
2501 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nInt32
);
2502 // underline color test place
2504 xCell1Style
->getPropertyValue("CharHeight") >>= fFloat
;
2505 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat
);
2506 xCell1Style
->getPropertyValue("CharWeight") >>= fFloat
;
2507 CPPUNIT_ASSERT_EQUAL(float(150.), fFloat
);
2508 xCell1Style
->getPropertyValue("CharPosture") >>= eCharPosture
;
2509 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE
, eCharPosture
);
2510 xCell1Style
->getPropertyValue("CharFontName") >>= sString
;
2511 CPPUNIT_ASSERT_EQUAL(OUString("Liberation Serif"), sString
);
2512 xCell1Style
->getPropertyValue("CharFontStyleName") >>= sString
;
2513 CPPUNIT_ASSERT_EQUAL(OUString(), sString
);
2514 xCell1Style
->getPropertyValue("CharFontFamily") >>= nInt16
;
2515 CPPUNIT_ASSERT_EQUAL(sal_Int16(3), nInt16
);
2516 xCell1Style
->getPropertyValue("CharFontPitch") >>= nInt16
;
2517 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16
);
2519 xCell1Style
->getPropertyValue("CharHeightAsian") >>= fFloat
;
2520 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat
);
2521 xCell1Style
->getPropertyValue("CharWeightAsian") >>= fFloat
;
2522 CPPUNIT_ASSERT_EQUAL(float(150.), fFloat
);
2523 xCell1Style
->getPropertyValue("CharPostureAsian") >>= eCharPosture
;
2524 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE
, eCharPosture
);
2525 xCell1Style
->getPropertyValue("CharFontNameAsian") >>= sString
;
2526 CPPUNIT_ASSERT_EQUAL(OUString("Liberation Serif"), sString
);
2527 xCell1Style
->getPropertyValue("CharFontStyleNameAsian") >>= sString
;
2528 CPPUNIT_ASSERT_EQUAL(OUString("Pogrubiona"), sString
);
2529 xCell1Style
->getPropertyValue("CharFontFamilyAsian") >>= nInt16
;
2530 CPPUNIT_ASSERT_EQUAL(sal_Int16(3), nInt16
);
2531 xCell1Style
->getPropertyValue("CharFontPitchAsian") >>= nInt16
;
2532 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16
);
2534 xCell1Style
->getPropertyValue("CharHeightComplex") >>= fFloat
;
2535 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat
);
2536 xCell1Style
->getPropertyValue("CharWeightComplex") >>= fFloat
;
2537 CPPUNIT_ASSERT_EQUAL(float(150.), fFloat
);
2538 xCell1Style
->getPropertyValue("CharPostureComplex") >>= eCharPosture
;
2539 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE
, eCharPosture
);
2540 xCell1Style
->getPropertyValue("CharFontNameComplex") >>= sString
;
2541 CPPUNIT_ASSERT_EQUAL(OUString("Liberation Serif"), sString
);
2542 xCell1Style
->getPropertyValue("CharFontStyleNameComplex") >>= sString
;
2543 CPPUNIT_ASSERT_EQUAL(OUString("Pogrubiona"), sString
);
2544 xCell1Style
->getPropertyValue("CharFontFamilyComplex") >>= nInt16
;
2545 CPPUNIT_ASSERT_EQUAL(sal_Int16(3), nInt16
);
2546 xCell1Style
->getPropertyValue("CharFontPitchComplex") >>= nInt16
;
2547 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16
);
2550 xTableStyle
->getByName("first-row-even-column") >>= xCell1Style
;
2551 xCell1Style
->getPropertyValue("ParaAdjust") >>= nInt32
;
2552 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nInt32
);
2553 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, getProperty
<Color
>(xCell1Style
, "CharColor"));
2554 xCell1Style
->getPropertyValue("CharContoured") >>= bBool
;
2555 CPPUNIT_ASSERT_EQUAL(true, bBool
);
2556 xCell1Style
->getPropertyValue("CharShadowed") >>= bBool
;
2557 CPPUNIT_ASSERT_EQUAL(true, bBool
);
2558 xCell1Style
->getPropertyValue("CharStrikeout") >>= nInt32
;
2559 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32
);
2560 xCell1Style
->getPropertyValue("CharUnderline") >>= nInt32
;
2561 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), nInt32
);
2562 // underline color test place
2564 xCell1Style
->getPropertyValue("CharHeight") >>= fFloat
;
2565 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat
);
2566 xCell1Style
->getPropertyValue("CharWeight") >>= fFloat
;
2567 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat
);
2568 xCell1Style
->getPropertyValue("CharPosture") >>= eCharPosture
;
2569 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC
, eCharPosture
);
2570 xCell1Style
->getPropertyValue("CharFontName") >>= sString
;
2571 CPPUNIT_ASSERT_EQUAL(OUString("Open Sans"), sString
);
2572 xCell1Style
->getPropertyValue("CharFontStyleName") >>= sString
;
2573 CPPUNIT_ASSERT_EQUAL(OUString(), sString
);
2574 xCell1Style
->getPropertyValue("CharFontFamily") >>= nInt16
;
2575 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nInt16
);
2576 xCell1Style
->getPropertyValue("CharFontPitch") >>= nInt16
;
2577 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16
);
2579 xCell1Style
->getPropertyValue("CharHeightAsian") >>= fFloat
;
2580 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat
);
2581 xCell1Style
->getPropertyValue("CharWeightAsian") >>= fFloat
;
2582 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat
);
2583 xCell1Style
->getPropertyValue("CharPostureAsian") >>= eCharPosture
;
2584 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC
, eCharPosture
);
2585 xCell1Style
->getPropertyValue("CharFontNameAsian") >>= sString
;
2586 CPPUNIT_ASSERT_EQUAL(OUString("Open Sans"), sString
);
2587 xCell1Style
->getPropertyValue("CharFontStyleNameAsian") >>= sString
;
2588 CPPUNIT_ASSERT_EQUAL(OUString("Kursywa"), sString
);
2589 xCell1Style
->getPropertyValue("CharFontFamilyAsian") >>= nInt16
;
2590 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nInt16
);
2591 xCell1Style
->getPropertyValue("CharFontPitchAsian") >>= nInt16
;
2592 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16
);
2594 xCell1Style
->getPropertyValue("CharHeightComplex") >>= fFloat
;
2595 CPPUNIT_ASSERT_EQUAL(float(12.), fFloat
);
2596 xCell1Style
->getPropertyValue("CharWeightComplex") >>= fFloat
;
2597 CPPUNIT_ASSERT_EQUAL(float(100.), fFloat
);
2598 xCell1Style
->getPropertyValue("CharPostureComplex") >>= eCharPosture
;
2599 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC
, eCharPosture
);
2600 xCell1Style
->getPropertyValue("CharFontNameComplex") >>= sString
;
2601 CPPUNIT_ASSERT_EQUAL(OUString("Open Sans"), sString
);
2602 xCell1Style
->getPropertyValue("CharFontStyleNameComplex") >>= sString
;
2603 CPPUNIT_ASSERT_EQUAL(OUString("Kursywa"), sString
);
2604 xCell1Style
->getPropertyValue("CharFontFamilyComplex") >>= nInt16
;
2605 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nInt16
);
2606 xCell1Style
->getPropertyValue("CharFontPitchComplex") >>= nInt16
;
2607 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16
);
2610 CPPUNIT_TEST_FIXTURE(Test
, testTableStyles3
)
2612 loadAndReload("table_styles_3.odt");
2613 CPPUNIT_ASSERT_EQUAL(1, getPages());
2614 // This test checks if default valued attributes aren't exported.
2615 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
2617 // <style:paragraph-properties>
2618 // For this element the only exported attributes are: "border-left", "border-bottom"
2619 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "background-color");
2620 // border-left place
2621 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "border-right");
2622 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "border-top");
2623 // border-bottom place
2624 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding");
2625 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-left");
2626 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-right");
2627 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-top");
2628 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-bottom");
2629 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "writing-mode");
2631 // <style:paragraph-properties> should be absent, because it has only "text-align" attribute, which shouldn't be exported.
2632 // Assume that style:paragraph-properties and style:text-properties exists.
2633 assertXPathChildren(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']", 2);
2635 // <style:text-properties>
2636 // 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"
2637 // use-window-font-color place
2638 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-shadow");
2639 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-outline");
2640 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-line-through-style");
2641 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-line-through-type");
2642 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-underline-style");
2643 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-underline-color");
2644 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-size");
2645 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-weight");
2646 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style");
2647 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-name");
2648 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family");
2649 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-name");
2650 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family-generic");
2651 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-pitch");
2652 // font-size-asian place
2653 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-weight-asian");
2654 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-asian");
2655 // font-name-asian place
2656 // font-family-asian place
2657 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-name-asian");
2658 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family-generic-asian");
2659 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-pitch-asian");
2660 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-size-complex");
2661 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-weight-complex");
2662 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-complex");
2663 // font-name-complex place
2664 // font-family-complex place
2665 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-name-complex");
2666 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family-generic-complex");
2667 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-pitch-complex");
2671 CPPUNIT_TEST_FIXTURE(Test
, testTableStyles4
)
2673 createSwDoc("table_styles_4.odt");
2674 // Test if loaded styles overwrite existing styles
2675 uno::Reference
<style::XStyleFamiliesSupplier
> XFamiliesSupplier(mxComponent
, uno::UNO_QUERY
);
2676 uno::Reference
<container::XNameAccess
> xFamilies(XFamiliesSupplier
->getStyleFamilies());
2677 uno::Reference
<container::XNameAccess
> xTableFamily(xFamilies
->getByName("TableStyles"), uno::UNO_QUERY
);
2678 uno::Reference
<container::XNameAccess
> xTableStyle(xTableFamily
->getByName("Green"), uno::UNO_QUERY
);
2679 uno::Reference
<beans::XPropertySet
> xCell1Style
;
2681 xTableStyle
->getByName("first-row-start-column") >>= xCell1Style
;
2682 CPPUNIT_ASSERT_EQUAL(Color(0x00ff00), getProperty
<Color
>(xCell1Style
, "BackColor"));
2685 CPPUNIT_TEST_FIXTURE(Test
, testTableStyles5
)
2687 loadAndReload("table_styles_5.odt");
2688 CPPUNIT_ASSERT_EQUAL(1, getPages());
2689 // Test if cell styles doesn't have a style:parent-style-name attribute.
2690 xmlDocUniquePtr pXmlDoc
= parseExport("styles.xml");
2692 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.1']", "parent-style-name");
2693 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.2']", "parent-style-name");
2694 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.3']", "parent-style-name");
2695 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.4']", "parent-style-name");
2696 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.5']", "parent-style-name");
2697 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.6']", "parent-style-name");
2698 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.7']", "parent-style-name");
2699 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.8']", "parent-style-name");
2700 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.9']", "parent-style-name");
2701 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.10']", "parent-style-name");
2702 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.11']", "parent-style-name");
2703 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.12']", "parent-style-name");
2704 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.13']", "parent-style-name");
2705 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.14']", "parent-style-name");
2706 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.15']", "parent-style-name");
2707 assertXPathNoAttribute(pXmlDoc
, "/office:document-styles/office:styles/style:style[@style:display-name='Test style.16']", "parent-style-name");
2711 CPPUNIT_TEST_FIXTURE(Test
, testTdf145226
)
2713 loadAndReload("tdf145226.fodt");
2714 CPPUNIT_ASSERT_EQUAL(1, getPages());
2715 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
2717 assertXPathNoAttribute(pXmlDoc
, "/office:document-content/office:body/office:text/table:table/table:table-row[1]", "style-name");
2718 assertXPathNoAttribute(pXmlDoc
, "/office:document-content/office:body/office:text/table:table/table:table-row[2]", "style-name");
2719 assertXPathNoAttribute(pXmlDoc
, "/office:document-content/office:body/office:text/table:table/table:table-row[3]", "style-name");
2720 assertXPathNoAttribute(pXmlDoc
, "/office:document-content/office:body/office:text/table:table/table:table-row[4]", "style-name");
2723 DECLARE_ODFEXPORT_TEST(testTdf101710
, "tdf101710.odt")
2725 CPPUNIT_ASSERT_EQUAL(1, getPages());
2726 // Test that number format of cell styles can be imported and exported.
2727 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("CellStyles")->getByName("Test Style.11"), uno::UNO_QUERY
);
2728 CPPUNIT_ASSERT_EQUAL(sal_uInt32(10104), getProperty
<sal_uInt32
>(xStyle
, "NumberFormat"));
2731 CPPUNIT_TEST_FIXTURE(Test
, testTdf129568
)
2733 loadAndReload("tdf129568.fodt");
2734 // Test that export doesn't fail, and that style is imported and in use.
2735 uno::Reference
<style::XStyle
> xStyle(getStyles("CellStyles")->getByName("Default Style.1"), uno::UNO_QUERY
);
2736 CPPUNIT_ASSERT(xStyle
->isInUse());
2737 CPPUNIT_ASSERT_EQUAL(Color(0xffff00), getProperty
<Color
>(xStyle
, "BackColor"));
2740 CPPUNIT_TEST_FIXTURE(Test
, testTdf129568ui
)
2742 loadAndReload("tdf129568-ui.fodt");
2743 // Same as above, but styles referenced by UI name.
2744 uno::Reference
<style::XStyle
> xStyle(getStyles("CellStyles")->getByName("Default Style.1"), uno::UNO_QUERY
);
2745 CPPUNIT_ASSERT(xStyle
->isInUse());
2746 CPPUNIT_ASSERT_EQUAL(Color(0xffff00), getProperty
<Color
>(xStyle
, "BackColor"));
2749 DECLARE_ODFEXPORT_TEST(testTdf132642_keepWithNextTable
, "tdf132642_keepWithNextTable.odt")
2751 // Since the row is very big, it should split over two pages.
2752 // Since up to this point we haven't tried to make it match MS formats, it should start on page 1.
2753 CPPUNIT_ASSERT_EQUAL_MESSAGE("Row splits over 2 pages", 2, getPages());
2756 CPPUNIT_TEST_FIXTURE(Test
, testImageMimetype
)
2758 loadAndReload("image-mimetype.odt");
2759 CPPUNIT_ASSERT_EQUAL(1, getShapes());
2760 CPPUNIT_ASSERT_EQUAL(1, getPages());
2761 // Test that the loext:mimetype attribute is written for exported images, tdf#109202
2762 xmlDocUniquePtr pXmlDoc
= parseExport("content.xml");
2763 // Original image (svg)
2764 assertXPath(pXmlDoc
, "/office:document-content/office:body/office:text/text:p/draw:frame/draw:image[@draw:mime-type='image/svg+xml']");
2768 CPPUNIT_PLUGIN_IMPLEMENT();
2769 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */