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