Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : */
9 :
10 : #include <swmodeltestbase.hxx>
11 :
12 : #if !defined(MACOSX)
13 : #include <com/sun/star/awt/Gradient.hpp>
14 : #include <com/sun/star/container/XIndexReplace.hpp>
15 : #include <com/sun/star/drawing/FillStyle.hpp>
16 : #include <com/sun/star/table/ShadowFormat.hpp>
17 : #include <com/sun/star/text/RelOrientation.hpp>
18 : #include <com/sun/star/text/XDocumentIndex.hpp>
19 : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
20 :
21 56 : class Test : public SwModelTestBase
22 : {
23 : public:
24 56 : Test() : SwModelTestBase("/sw/qa/extras/odfexport/data/", "writer8") {}
25 :
26 : /**
27 : * Blacklist handling
28 : */
29 28 : bool mustTestImportOf(const char* filename) const SAL_OVERRIDE {
30 : // Only test import of .odt document
31 28 : return OString(filename).endsWith(".odt");
32 : }
33 : };
34 :
35 : #define DECLARE_ODFEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, Test)
36 :
37 28 : DECLARE_ODFEXPORT_TEST(testFdo38244, "fdo38244.odt")
38 : {
39 : // See ooxmlexport's testFdo38244().
40 :
41 : // Test comment range feature.
42 4 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
43 8 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
44 8 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
45 8 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
46 8 : uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
47 4 : xRunEnum->nextElement();
48 8 : uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
49 4 : CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(xPropertySet, "TextPortionType"));
50 4 : xRunEnum->nextElement();
51 4 : xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
52 4 : CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
53 :
54 : // Test properties
55 8 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
56 8 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
57 8 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
58 4 : xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
59 4 : CPPUNIT_ASSERT_EQUAL(OUString("__Fieldmark__4_1833023242"), getProperty<OUString>(xPropertySet, "Name"));
60 8 : CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
61 4 : }
62 :
63 28 : DECLARE_ODFEXPORT_TEST(testFdo79358, "fdo79358.odt")
64 : {
65 : // the boolean properties of the index were not exported properly
66 4 : uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
67 8 : uno::Reference<container::XIndexAccess> xIndexes(xIndexSupplier->getDocumentIndexes(), uno::UNO_QUERY);
68 8 : uno::Reference<text::XDocumentIndex> xTOCIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
69 8 : uno::Reference<beans::XPropertySet> xTOCProps(xTOCIndex, uno::UNO_QUERY);
70 4 : CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTOCProps, "CreateFromOutline"));
71 4 : CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTOCProps, "CreateFromMarks"));
72 4 : CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTOCProps, "CreateFromLevelParagraphStyles"));
73 : // check that the source styles are preserved too while at it
74 : uno::Reference<container::XIndexReplace> xLevels(
75 : getProperty< uno::Reference<container::XIndexReplace> >(xTOCProps,
76 8 : "LevelParagraphStyles"));
77 8 : uno::Sequence<OUString> seq(1);
78 4 : seq[0] = "Heading";
79 4 : CPPUNIT_ASSERT_EQUAL(uno::makeAny(seq), xLevels->getByIndex(1));
80 8 : CPPUNIT_ASSERT_EQUAL(uno::makeAny(uno::Sequence<OUString>()), xLevels->getByIndex(2));
81 4 : }
82 :
83 28 : DECLARE_ODFEXPORT_TEST(testFirstHeaderFooter, "first-header-footer.odt")
84 : {
85 : // Test import and export of the header-first token.
86 :
87 : // The document has 6 pages, two page styles for the first and second half of pages.
88 4 : CPPUNIT_ASSERT_EQUAL(OUString("First header"), parseDump("/root/page[1]/header/txt/text()"));
89 4 : CPPUNIT_ASSERT_EQUAL(OUString("First footer"), parseDump("/root/page[1]/footer/txt/text()"));
90 4 : CPPUNIT_ASSERT_EQUAL(OUString("Left header"), parseDump("/root/page[2]/header/txt/text()"));
91 4 : CPPUNIT_ASSERT_EQUAL(OUString("Left footer"), parseDump("/root/page[2]/footer/txt/text()"));
92 4 : CPPUNIT_ASSERT_EQUAL(OUString("Right header"), parseDump("/root/page[3]/header/txt/text()"));
93 4 : CPPUNIT_ASSERT_EQUAL(OUString("Right footer"), parseDump("/root/page[3]/footer/txt/text()"));
94 4 : CPPUNIT_ASSERT_EQUAL(OUString("First header2"), parseDump("/root/page[4]/header/txt/text()"));
95 4 : CPPUNIT_ASSERT_EQUAL(OUString("First footer2"), parseDump("/root/page[4]/footer/txt/text()"));
96 4 : CPPUNIT_ASSERT_EQUAL(OUString("Right header2"), parseDump("/root/page[5]/header/txt/text()"));
97 4 : CPPUNIT_ASSERT_EQUAL(OUString("Right footer2"), parseDump("/root/page[5]/footer/txt/text()"));
98 4 : CPPUNIT_ASSERT_EQUAL(OUString("Left header2"), parseDump("/root/page[6]/header/txt/text()"));
99 4 : CPPUNIT_ASSERT_EQUAL(OUString("Left footer2"), parseDump("/root/page[6]/footer/txt/text()"));
100 4 : }
101 :
102 28 : DECLARE_ODFEXPORT_TEST(testTextframeGradient, "textframe-gradient.odt")
103 : {
104 4 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
105 8 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
106 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
107 :
108 8 : uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
109 4 : CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
110 4 : awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
111 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor);
112 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor);
113 4 : CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
114 :
115 4 : xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
116 4 : CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
117 4 : aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
118 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor);
119 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor);
120 8 : CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
121 4 : }
122 :
123 28 : DECLARE_ODFEXPORT_TEST(testFdo60769, "fdo60769.odt")
124 : {
125 : // Test multi-paragraph comment range feature.
126 4 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
127 8 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
128 8 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
129 8 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
130 8 : uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
131 32 : while (xRunEnum->hasMoreElements())
132 : {
133 24 : uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
134 48 : OUString aType = getProperty<OUString>(xPropertySet, "TextPortionType");
135 : // First paragraph: no field end, no anchor
136 24 : CPPUNIT_ASSERT(aType == "Text" || aType == "Annotation");
137 24 : }
138 :
139 4 : xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
140 8 : while (xRunEnum->hasMoreElements())
141 : {
142 0 : uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
143 0 : OUString aType = getProperty<OUString>(xPropertySet, "TextPortionType");
144 : // Second paragraph: no field start
145 0 : CPPUNIT_ASSERT(aType == "Text" || aType == "AnnotationEnd");
146 4 : }
147 4 : }
148 :
149 26 : DECLARE_ODFEXPORT_TEST(testFdo58949, "fdo58949.docx")
150 : {
151 : /*
152 : * The problem was that the exporter didn't insert "Obj102" to the
153 : * resulting zip file. No idea how to check for "broken" (missing OLE data
154 : * and replacement image) OLE objects using UNO, so we'll check the zip file directly.
155 : */
156 :
157 2 : utl::TempFile aTempFile;
158 2 : save("writer8", aTempFile);
159 :
160 4 : uno::Sequence<uno::Any> aArgs(1);
161 2 : aArgs[0] <<= OUString(aTempFile.GetURL());
162 4 : uno::Reference<container::XNameAccess> xNameAccess(m_xSFactory->createInstanceWithArguments("com.sun.star.packages.zip.ZipFileAccess", aArgs), uno::UNO_QUERY);
163 4 : CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("Obj102")));
164 2 : }
165 :
166 28 : DECLARE_ODFEXPORT_TEST(testCharacterBorder, "charborder.odt")
167 : {
168 : // Make sure paragraph and character attributes don't interfere
169 : // First paragraph has a paragraph border and a character border included by the paragraph style
170 :
171 : // Paragraph border of first paragraph
172 : {
173 4 : const table::BorderLine2 aFirstParTopBorder(0x6666FF,0,26,26,7,53);
174 4 : const sal_Int32 aFirstParTopPadding(150);
175 4 : uno::Reference<beans::XPropertySet> xSet(getParagraph(1), uno::UNO_QUERY);
176 :
177 : // Top border
178 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder, getProperty<table::BorderLine2>(xSet,"TopBorder"));
179 4 : CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding, getProperty<sal_Int32>(xSet,"TopBorderDistance"));
180 :
181 : // Bottom border (same as top border)
182 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder, getProperty<table::BorderLine2>(xSet,"BottomBorder"));
183 4 : CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding, getProperty<sal_Int32>(xSet,"BottomBorderDistance"));
184 :
185 : // Left border (same as top border)
186 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder, getProperty<table::BorderLine2>(xSet,"LeftBorder"));
187 4 : CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding, getProperty<sal_Int32>(xSet,"LeftBorderDistance"));
188 :
189 : // Right border (same as top border)
190 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParTopBorder, getProperty<table::BorderLine2>(xSet,"RightBorder"));
191 4 : CPPUNIT_ASSERT_EQUAL(aFirstParTopPadding, getProperty<sal_Int32>(xSet,"RightBorderDistance"));
192 :
193 : // Shadow
194 4 : const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xSet,"ParaShadowFormat");
195 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aShadow.Color);
196 4 : CPPUNIT_ASSERT_EQUAL(false, (bool)aShadow.IsTransparent);
197 4 : CPPUNIT_ASSERT_EQUAL(table::ShadowLocation(0), aShadow.Location);
198 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aShadow.ShadowWidth);
199 : }
200 :
201 : // Character border for first paragraph
202 : {
203 4 : const table::BorderLine2 aFirstParCharTopBorder(0xFF3333,0,37,0,2,37);
204 4 : const sal_Int32 aFirstParCharTopPadding(450);
205 4 : uno::Reference<beans::XPropertySet> xSet(getParagraph(1), uno::UNO_QUERY);
206 :
207 : // Top border
208 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,"CharTopBorder"));
209 4 : CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,"CharTopBorderDistance"));
210 :
211 : // Bottom border (same as top border)
212 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,"CharBottomBorder"));
213 4 : CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,"CharBottomBorderDistance"));
214 :
215 : // Left border (same as top border)
216 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,"CharLeftBorder"));
217 4 : CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,"CharLeftBorderDistance"));
218 :
219 : // Right border (same as top border)
220 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,"CharRightBorder"));
221 4 : CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,"CharRightBorderDistance"));
222 :
223 : // Shadow
224 4 : const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xSet,"CharShadowFormat");
225 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF3333), aShadow.Color);
226 4 : CPPUNIT_ASSERT_EQUAL(false, (bool)aShadow.IsTransparent);
227 4 : CPPUNIT_ASSERT_EQUAL(table::ShadowLocation(2), aShadow.Location);
228 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(280), aShadow.ShadowWidth);
229 :
230 : // Check autostyle
231 : {
232 4 : uno::Reference< style::XAutoStyleFamily > xAutoStyleFamily(getAutoStyles("ParagraphStyles"));
233 8 : uno::Reference < container::XEnumeration > xAutoStylesEnum( xAutoStyleFamily->createEnumeration() );
234 4 : CPPUNIT_ASSERT_EQUAL(true, (bool)xAutoStylesEnum->hasMoreElements());
235 :
236 : // First paragraph autostyle
237 8 : uno::Reference < beans::XPropertySet > xPSet( xAutoStylesEnum->nextElement(), uno::UNO_QUERY );
238 :
239 : // Top border
240 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,"CharTopBorder"));
241 4 : CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,"CharTopBorderDistance"));
242 :
243 : // Bottom border
244 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,"CharBottomBorder"));
245 4 : CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,"CharBottomBorderDistance"));
246 :
247 : // Left border
248 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,"CharLeftBorder"));
249 4 : CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,"CharLeftBorderDistance"));
250 :
251 : // Right border
252 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aFirstParCharTopBorder, getProperty<table::BorderLine2>(xSet,"CharRightBorder"));
253 8 : CPPUNIT_ASSERT_EQUAL(aFirstParCharTopPadding, getProperty<sal_Int32>(xSet,"CharRightBorderDistance"));
254 4 : }
255 : }
256 :
257 : // Second paragraph's second text portion has a character style named CharDiffBor
258 : // This style includes border with different sides
259 : {
260 :
261 : table::BorderLine2 aBorderArray[4] =
262 : {
263 : table::BorderLine2(0xFF3333,0,37,0,14,37), // Top (fine dashed line)
264 : table::BorderLine2(0x99FF66,26,26,53,11,106), // Bottom
265 : table::BorderLine2(0x6666FF,9,26,9,12,71), // Left
266 : table::BorderLine2(0,0,0,0,0,0) // Right
267 4 : };
268 :
269 4 : sal_Int32 aDistances[4] = { 400 /*Top*/, 300 /*Bottom*/, 250 /*Left*/, 0 /*Right*/ };
270 :
271 : // Get second text portion of second paragraph
272 4 : uno::Reference < beans::XPropertySet > xSet( getRun(getParagraph(2),2), uno::UNO_QUERY );
273 :
274 : // Top border
275 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[0], getProperty<table::BorderLine2>(xSet,"CharTopBorder"));
276 4 : CPPUNIT_ASSERT_EQUAL(aDistances[0], getProperty<sal_Int32>(xSet,"CharTopBorderDistance"));
277 :
278 : // Bottom border
279 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[1], getProperty<table::BorderLine2>(xSet,"CharBottomBorder"));
280 4 : CPPUNIT_ASSERT_EQUAL(aDistances[1], getProperty<sal_Int32>(xSet,"CharBottomBorderDistance"));
281 :
282 : // Left border
283 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[2], getProperty<table::BorderLine2>(xSet,"CharLeftBorder"));
284 4 : CPPUNIT_ASSERT_EQUAL(aDistances[2], getProperty<sal_Int32>(xSet,"CharLeftBorderDistance"));
285 :
286 : // Right border
287 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[3], getProperty<table::BorderLine2>(xSet,"CharRightBorder"));
288 4 : CPPUNIT_ASSERT_EQUAL(aDistances[3], getProperty<sal_Int32>(xSet,"CharRightBorderDistance"));
289 :
290 : // Shadow
291 4 : const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xSet,"CharShadowFormat");
292 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aShadow.Color);
293 4 : CPPUNIT_ASSERT_EQUAL(false, (bool)aShadow.IsTransparent);
294 4 : CPPUNIT_ASSERT_EQUAL(table::ShadowLocation(3), aShadow.Location);
295 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(79), aShadow.ShadowWidth);
296 :
297 : // Check character style
298 : {
299 4 : uno::Reference< container::XNameAccess > xStyleFamily(getStyles("CharacterStyles"), uno::UNO_QUERY);
300 8 : uno::Reference < beans::XPropertySet > xStyleSet(xStyleFamily->getByName("CharDiffBor"), uno::UNO_QUERY);
301 :
302 : // Top border
303 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[0], getProperty<table::BorderLine2>(xSet,"CharTopBorder"));
304 4 : CPPUNIT_ASSERT_EQUAL(aDistances[0], getProperty<sal_Int32>(xSet,"CharTopBorderDistance"));
305 :
306 : // Bottom border
307 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[1], getProperty<table::BorderLine2>(xSet,"CharBottomBorder"));
308 4 : CPPUNIT_ASSERT_EQUAL(aDistances[1], getProperty<sal_Int32>(xSet,"CharBottomBorderDistance"));
309 :
310 : // Left border
311 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[2], getProperty<table::BorderLine2>(xSet,"CharLeftBorder"));
312 4 : CPPUNIT_ASSERT_EQUAL(aDistances[2], getProperty<sal_Int32>(xSet,"CharLeftBorderDistance"));
313 :
314 : // Right border
315 4 : CPPUNIT_ASSERT_BORDER_EQUAL(aBorderArray[3], getProperty<table::BorderLine2>(xSet,"CharRightBorder"));
316 8 : CPPUNIT_ASSERT_EQUAL(aDistances[3], getProperty<sal_Int32>(xSet,"CharRightBorderDistance"));
317 4 : }
318 : }
319 4 : }
320 :
321 28 : DECLARE_ODFEXPORT_TEST(testFdo43807, "fdo43807.odt")
322 : {
323 4 : uno::Reference<beans::XPropertySet> xSet(getParagraph(1), uno::UNO_QUERY);
324 4 : CPPUNIT_ASSERT_EQUAL(OUString("Drop Caps"),getProperty<OUString>(xSet,"DropCapCharStyleName"));
325 :
326 4 : xSet = uno::Reference<beans::XPropertySet>(getParagraph(2), uno::UNO_QUERY);
327 4 : CPPUNIT_ASSERT_EQUAL(OUString("User Defined Drop Caps"),getProperty<OUString>(xSet,"DropCapCharStyleName"));
328 4 : }
329 :
330 28 : DECLARE_ODFEXPORT_TEST(testTextframeTransparentShadow, "textframe-transparent-shadow.odt")
331 : {
332 4 : uno::Reference<drawing::XShape> xPicture = getShape(1);
333 : // ODF stores opacity of 75%, that means 25% transparency.
334 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty<sal_Int32>(xPicture, "ShadowTransparence"));
335 4 : }
336 :
337 28 : DECLARE_ODFEXPORT_TEST(testRelhPage, "relh-page.odt")
338 : {
339 4 : uno::Reference<drawing::XShape> xTextFrame = getShape(1);
340 : // This was text::RelOrientation::FRAME (the default), RelativeHeightRelation was not handled in xmloff.
341 4 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation"));
342 : // Make sure rel-height-rel doesn't affect width.
343 4 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation"));
344 :
345 : // This was 2601, 20% height was relative from margin, not page.
346 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3168), parseDump("/root/page/body/txt/anchored/fly/infos/bounds", "height").toInt32());
347 4 : }
348 :
349 28 : DECLARE_ODFEXPORT_TEST(testRelwPage, "relw-page.odt")
350 : {
351 4 : uno::Reference<drawing::XShape> xTextFrame = getShape(1);
352 : // This was text::RelOrientation::FRAME (the default), RelativeWidthRelation was not handled in xmloff.
353 4 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation"));
354 : // Make sure rel-width-rel doesn't affect height.
355 4 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation"));
356 :
357 : // This was 3762, 40% width was relative from margin, not page.
358 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(4896), parseDump("/root/page/body/txt/anchored/fly/infos/bounds", "width").toInt32());
359 4 : }
360 :
361 28 : DECLARE_ODFEXPORT_TEST(testTextFrameVertAdjust, "textframe-vertadjust.odt")
362 : {
363 : // Test import/export of new frame attribute called TextVerticalAdjust
364 :
365 : // 1st frame's context is adjusted to the top
366 4 : uno::Reference<beans::XPropertySet> xFrame(getTextFrameByName("Rectangle 1"), uno::UNO_QUERY);
367 4 : CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust"));
368 : // 2nd frame's context is adjusted to the center
369 4 : xFrame.set(getTextFrameByName("Rectangle 2"), uno::UNO_QUERY);
370 4 : CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_CENTER, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust"));
371 : // 3rd frame's context is adjusted to the bottom
372 4 : xFrame.set(getTextFrameByName("Rectangle 3"), uno::UNO_QUERY);
373 4 : CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust"));
374 4 : }
375 :
376 28 : DECLARE_ODFEXPORT_TEST(testShapeRelsize, "shape-relsize.odt")
377 : {
378 4 : uno::Reference<drawing::XShape> xShape = getShape(1);
379 : // These were all 0, as style:rel-width/height was ignored on import for shapes.
380 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(xShape, "RelativeWidth"));
381 4 : CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(xShape, "RelativeHeight"));
382 :
383 : // Relation was "page" for both width and height, should be "paragraph" for width.
384 4 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation"));
385 : // And make sure that height stays "page".
386 4 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation"));
387 4 : }
388 :
389 28 : DECLARE_ODFEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.odt")
390 : {
391 4 : uno::Reference<drawing::XShape> xShape = getShape(1);
392 8 : comphelper::SequenceAsHashMap aCustomShapeGeometry = comphelper::SequenceAsHashMap(getProperty< uno::Sequence<beans::PropertyValue> >(xShape, "CustomShapeGeometry"));
393 :
394 : // Test that the shape is a rounded rectangle.
395 4 : CPPUNIT_ASSERT_EQUAL(OUString("round-rectangle"), aCustomShapeGeometry["Type"].get<OUString>());
396 :
397 : // The shape text should start with a table, with "a" in its A1 cell.
398 8 : uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
399 8 : uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY);
400 8 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
401 8 : CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell->getString());
402 4 : }
403 :
404 : #endif
405 :
406 8 : CPPUNIT_PLUGIN_IMPLEMENT();
407 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|