Line data Source code
1 : /*
2 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
3 : *
4 : * The contents of this file are subject to the Mozilla Public License Version
5 : * 1.1 (the "License"); you may not use this file except in compliance with
6 : * the License. You may obtain a copy of the License at
7 : * http://www.mozilla.org/MPL/
8 : *
9 : * Software distributed under the License is distributed on an "AS IS" basis,
10 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 : * for the specific language governing rights and limitations under the
12 : * License.
13 : *
14 : * The Initial Developer of the Original Code is
15 : * Miklos Vajna <vmiklos@suse.cz> (SUSE, Inc.)
16 : * Portions created by the Initial Developer are Copyright (C) 2012 the
17 : * Initial Developer. All Rights Reserved.
18 : *
19 : * Contributor(s):
20 : *
21 : * Alternatively, the contents of this file may be used under the terms of
22 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
23 : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
24 : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
25 : * instead of those above.
26 : */
27 :
28 : #include <com/sun/star/awt/XBitmap.hpp>
29 : #include <com/sun/star/beans/XPropertySet.hpp>
30 : #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
31 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
32 : #include <com/sun/star/lang/XServiceInfo.hpp>
33 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
34 : #include <com/sun/star/text/HoriOrientation.hpp>
35 : #include <com/sun/star/text/RelOrientation.hpp>
36 : #include <com/sun/star/text/SetVariableType.hpp>
37 : #include <com/sun/star/text/TableColumnSeparator.hpp>
38 : #include <com/sun/star/text/TextContentAnchorType.hpp>
39 : #include <com/sun/star/text/VertOrientation.hpp>
40 : #include <com/sun/star/text/WrapTextMode.hpp>
41 : #include <com/sun/star/text/XDependentTextField.hpp>
42 : #include <com/sun/star/text/XFormField.hpp>
43 : #include <com/sun/star/text/XPageCursor.hpp>
44 : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
45 : #include <com/sun/star/text/XTextFrame.hpp>
46 : #include <com/sun/star/text/XTextFramesSupplier.hpp>
47 : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
48 : #include <com/sun/star/style/BreakType.hpp>
49 : #include <com/sun/star/style/ParagraphAdjust.hpp>
50 : #include <com/sun/star/table/ShadowFormat.hpp>
51 : #include <com/sun/star/view/XSelectionSupplier.hpp>
52 : #include <com/sun/star/table/BorderLine2.hpp>
53 : #include <com/sun/star/table/TableBorder2.hpp>
54 :
55 : #include <vcl/svapp.hxx>
56 :
57 : #include <swmodeltestbase.hxx>
58 : #include <bordertest.hxx>
59 :
60 : #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
61 :
62 6 : class Test : public SwModelTestBase
63 : {
64 : public:
65 : void testN751054();
66 : void testN751117();
67 : void testN751017();
68 : void testN750935();
69 : void testN757890();
70 : void testFdo49940();
71 : void testN751077();
72 : void testN705956_1();
73 : void testN705956_2();
74 : void testN747461();
75 : void testN750255();
76 : void testN652364();
77 : void testN760764();
78 : void testN764005();
79 : void testSmartart();
80 : void testN764745();
81 : void testN766477();
82 : void testN758883();
83 : void testN766481();
84 : void testN766487();
85 : void testN693238();
86 : void testNumbering1();
87 : void testBnc773061();
88 : void testAllGapsWord();
89 : void testN775906();
90 : void testN775899();
91 : void testN777345();
92 : void testN777337();
93 : void testN778836();
94 : void testN778140();
95 : void testN778828();
96 : void testInk();
97 : void testN779834();
98 : void testN779627();
99 : void testN779941();
100 : void testFdo55187();
101 : void testN780563();
102 : void testN780853();
103 : void testN780843();
104 : void testShadow();
105 : void testN782061();
106 : void testN782345();
107 : void testN783638();
108 : void testFdo52208();
109 : void testN785767();
110 : void testN773061();
111 : void testN780645();
112 : void testFineTableDash();
113 :
114 4 : CPPUNIT_TEST_SUITE(Test);
115 : #if !defined(MACOSX) && !defined(WNT)
116 2 : CPPUNIT_TEST(run);
117 : #endif
118 4 : CPPUNIT_TEST_SUITE_END();
119 :
120 : private:
121 : void run();
122 : };
123 :
124 2 : void Test::run()
125 : {
126 : MethodEntry<Test> aMethods[] = {
127 : {"n751054.docx", &Test::testN751054},
128 : {"n751117.docx", &Test::testN751117},
129 : {"n751017.docx", &Test::testN751017},
130 : {"n750935.docx", &Test::testN750935},
131 : {"n757890.docx", &Test::testN757890},
132 : {"fdo49940.docx", &Test::testFdo49940},
133 : {"n751077.docx", &Test::testN751077},
134 : {"n705956-1.docx", &Test::testN705956_1},
135 : {"n705956-2.docx", &Test::testN705956_2},
136 : {"n747461.docx", &Test::testN747461},
137 : {"n750255.docx", &Test::testN750255},
138 : {"n652364.docx", &Test::testN652364},
139 : {"n760764.docx", &Test::testN760764},
140 : {"n764005.docx", &Test::testN764005},
141 : {"smartart.docx", &Test::testSmartart},
142 : {"n764745-alignment.docx", &Test::testN764745},
143 : {"n766477.docx", &Test::testN766477},
144 : {"n758883.docx", &Test::testN758883},
145 : {"n766481.docx", &Test::testN766481},
146 : {"n766487.docx", &Test::testN766487},
147 : {"n693238.docx", &Test::testN693238},
148 : {"numbering1.docx", &Test::testNumbering1},
149 : {"bnc773061.docx", &Test::testBnc773061},
150 : {"all_gaps_word.docx", &Test::testAllGapsWord},
151 : {"n775906.docx", &Test::testN775906},
152 : {"n775899.docx", &Test::testN775899},
153 : {"n777345.docx", &Test::testN777345},
154 : {"n777337.docx", &Test::testN777337},
155 : {"n778836.docx", &Test::testN778836},
156 : {"n778140.docx", &Test::testN778140},
157 : {"n778828.docx", &Test::testN778828},
158 : {"ink.docx", &Test::testInk},
159 : {"n779834.docx", &Test::testN779834},
160 : {"n779627.docx", &Test::testN779627},
161 : {"n779941.docx", &Test::testN779941},
162 : {"fdo55187.docx", &Test::testFdo55187},
163 : {"n780563.docx", &Test::testN780563},
164 : {"n780853.docx", &Test::testN780853},
165 : {"n780843.docx", &Test::testN780843},
166 : {"imgshadow.docx", &Test::testShadow},
167 : {"n782061.docx", &Test::testN782061},
168 : {"n782345.docx", &Test::testN782345},
169 : {"n783638.docx", &Test::testN783638},
170 : {"fdo52208.docx", &Test::testFdo52208},
171 : {"n785767.docx", &Test::testN785767},
172 : {"n773061.docx", &Test::testN773061},
173 : {"n780645.docx", &Test::testN780645},
174 : {"tableborder-finedash.docx", &Test::testFineTableDash}
175 2 : };
176 98 : for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
177 : {
178 96 : MethodEntry<Test>& rEntry = aMethods[i];
179 96 : mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/ooxmlimport/data/") + OUString::createFromAscii(rEntry.pName));
180 96 : (this->*rEntry.pMethod)();
181 : }
182 2 : }
183 :
184 2 : void Test::testN751054()
185 : {
186 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
187 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
188 2 : uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
189 : text::TextContentAnchorType eValue;
190 2 : xPropertySet->getPropertyValue("AnchorType") >>= eValue;
191 2 : CPPUNIT_ASSERT(eValue != text::TextContentAnchorType_AS_CHARACTER);
192 2 : }
193 :
194 2 : void Test::testN751117()
195 : {
196 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
197 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
198 :
199 : // First shape: the end should be an arrow, should be rotated and should be flipped.
200 2 : uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
201 2 : OUString aValue;
202 2 : xPropertySet->getPropertyValue("LineEndName") >>= aValue;
203 2 : CPPUNIT_ASSERT(aValue.indexOf("Arrow") != -1);
204 :
205 2 : sal_Int32 nValue = 0;
206 2 : xPropertySet->getPropertyValue("RotateAngle") >>= nValue;
207 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(90 * 100), nValue);
208 :
209 2 : uno::Reference<drawing::XShape> xShape(xPropertySet, uno::UNO_QUERY);
210 2 : awt::Size aActualSize(xShape->getSize());
211 2 : CPPUNIT_ASSERT(aActualSize.Width < 0);
212 :
213 : // The second shape should be a line
214 2 : uno::Reference<lang::XServiceInfo> xServiceInfo(xDraws->getByIndex(1), uno::UNO_QUERY);
215 2 : CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.drawing.LineShape"));
216 2 : }
217 :
218 2 : void Test::testN751017()
219 : {
220 2 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
221 2 : uno::Reference<container::XNameAccess> xMasters(xTextFieldsSupplier->getTextFieldMasters());
222 : // Make sure we have a variable named foo.
223 2 : CPPUNIT_ASSERT(xMasters->hasByName("com.sun.star.text.FieldMaster.SetExpression.foo"));
224 :
225 2 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
226 2 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
227 2 : bool bFoundSet(false), bFoundGet(false);
228 8 : while (xFields->hasMoreElements())
229 : {
230 4 : uno::Reference<lang::XServiceInfo> xServiceInfo(xFields->nextElement(), uno::UNO_QUERY);
231 4 : uno::Reference<beans::XPropertySet> xPropertySet(xServiceInfo, uno::UNO_QUERY);
232 4 : sal_Int16 nValue = 0;
233 4 : OUString aValue;
234 4 : if (xServiceInfo->supportsService("com.sun.star.text.TextField.SetExpression"))
235 : {
236 2 : bFoundSet = true;
237 2 : uno::Reference<text::XDependentTextField> xDependentTextField(xServiceInfo, uno::UNO_QUERY);
238 2 : uno::Reference<beans::XPropertySet> xMasterProps(xDependentTextField->getTextFieldMaster());
239 :
240 : // First step: did we set foo to "bar"?
241 2 : xMasterProps->getPropertyValue("Name") >>= aValue;
242 2 : CPPUNIT_ASSERT_EQUAL(OUString("foo"), aValue);
243 2 : xPropertySet->getPropertyValue("SubType") >>= nValue;
244 2 : CPPUNIT_ASSERT_EQUAL(text::SetVariableType::STRING, nValue);
245 2 : xPropertySet->getPropertyValue("Content") >>= aValue;
246 2 : CPPUNIT_ASSERT_EQUAL(OUString("bar"), aValue);
247 : }
248 2 : else if (xServiceInfo->supportsService("com.sun.star.text.TextField.GetExpression"))
249 : {
250 : // Second step: check the value of foo.
251 2 : bFoundGet = true;
252 2 : xPropertySet->getPropertyValue("Content") >>= aValue;
253 2 : CPPUNIT_ASSERT_EQUAL(OUString("foo"), aValue);
254 2 : xPropertySet->getPropertyValue("SubType") >>= nValue;
255 2 : CPPUNIT_ASSERT_EQUAL(text::SetVariableType::STRING, nValue);
256 2 : xPropertySet->getPropertyValue("CurrentPresentation") >>= aValue;
257 2 : CPPUNIT_ASSERT_EQUAL(OUString("bar"), aValue);
258 : }
259 4 : }
260 2 : CPPUNIT_ASSERT(bFoundSet);
261 2 : CPPUNIT_ASSERT(bFoundGet);
262 2 : }
263 :
264 2 : void Test::testN750935()
265 : {
266 2 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
267 2 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
268 2 : uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
269 2 : xCursor->jumpToLastPage();
270 : // Some page break types were ignores, resulting in less pages.
271 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(5), xCursor->getPage());
272 :
273 : /*
274 : * The problem was that the header and footer was not shared.
275 : *
276 : * xray ThisComponent.StyleFamilies.PageStyles.Default.FooterIsShared
277 : */
278 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
279 2 : sal_Bool bValue = false;
280 2 : xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue;
281 2 : CPPUNIT_ASSERT_EQUAL(sal_Bool(true), bValue);
282 2 : xPropertySet->getPropertyValue("FooterIsShared") >>= bValue;
283 2 : CPPUNIT_ASSERT_EQUAL(sal_Bool(true), bValue);
284 2 : }
285 :
286 2 : void Test::testN757890()
287 : {
288 : // The w:pStyle token affected the text outside the textbox.
289 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
290 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
291 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
292 2 : uno::Reference<beans::XPropertySet> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
293 2 : OUString aValue;
294 2 : xPara->getPropertyValue("ParaStyleName") >>= aValue;
295 2 : CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), aValue);
296 :
297 : // This wan't centered
298 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
299 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
300 2 : uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
301 : sal_Int16 nValue;
302 2 : xFrame->getPropertyValue("HoriOrient") >>= nValue;
303 2 : CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, nValue);
304 2 : }
305 :
306 2 : void Test::testFdo49940()
307 : {
308 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
309 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
310 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
311 2 : uno::Reference<beans::XPropertySet> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
312 2 : OUString aValue;
313 2 : xPara->getPropertyValue("PageStyleName") >>= aValue;
314 2 : CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aValue);
315 2 : }
316 :
317 2 : void Test::testN751077()
318 : {
319 : /*
320 : enum = ThisComponent.Text.createEnumeration
321 : enum.NextElement
322 : para = enum.NextElement
323 : xray para.String
324 : xray para.PageStyleName
325 : */
326 2 : uno::Reference<uno::XInterface> paragraph(getParagraph( 2, "TEXT1" ));
327 : // we want to test the paragraph is on the first page (it was put onto another page without the fix),
328 : // use a small trick and instead of checking the page layout, check the page style
329 2 : OUString pageStyle = getProperty< OUString >( paragraph, "PageStyleName" );
330 2 : CPPUNIT_ASSERT_EQUAL( OUString( "First Page" ), pageStyle );
331 2 : }
332 :
333 2 : void Test::testN705956_1()
334 : {
335 : /*
336 : Get the first image in the document and check it's the one image in the document.
337 : It should be also anchored inline (as character).
338 : image = ThisComponent.DrawPage.getByIndex(0)
339 : graphic = image.Graphic
340 : xray graphic.Size
341 : xray image.AnchorType
342 : */
343 2 : uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
344 2 : uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
345 2 : uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage();
346 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 1 ), drawPage->getCount());
347 2 : uno::Reference<drawing::XShape> image;
348 2 : drawPage->getByIndex(0) >>= image;
349 2 : uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
350 2 : uno::Reference<graphic::XGraphic> graphic;
351 2 : imageProperties->getPropertyValue( "Graphic" ) >>= graphic;
352 2 : uno::Reference<awt::XBitmap> bitmap(graphic, uno::UNO_QUERY);
353 2 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(120), bitmap->getSize().Width );
354 2 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(106), bitmap->getSize().Height );
355 : text::TextContentAnchorType anchorType;
356 2 : imageProperties->getPropertyValue( "AnchorType" ) >>= anchorType;
357 2 : CPPUNIT_ASSERT_EQUAL( text::TextContentAnchorType_AS_CHARACTER, anchorType );
358 2 : }
359 :
360 2 : void Test::testN705956_2()
361 : {
362 : /*
363 : <v:shapetype> must be global, reachable even from <v:shape> inside another <w:pict>
364 : image = ThisComponent.DrawPage.getByIndex(0)
365 : xray image.FillColor
366 : */
367 2 : uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
368 2 : uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
369 2 : uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage();
370 2 : uno::Reference<drawing::XShape> image;
371 2 : drawPage->getByIndex(0) >>= image;
372 2 : uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
373 : sal_Int32 fillColor;
374 2 : imageProperties->getPropertyValue( "FillColor" ) >>= fillColor;
375 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 0xc0504d ), fillColor );
376 2 : }
377 :
378 2 : void Test::testN747461()
379 : {
380 : /*
381 : The document contains 3 images (Red, Black, Green, in this order), with explicit
382 : w:relativeHeight (300, 0, 225763766). Check that they are in the right ZOrder
383 : after they are loaded.
384 : */
385 2 : uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
386 2 : uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
387 2 : uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage();
388 2 : uno::Reference<drawing::XShape> image1, image2, image3;
389 2 : drawPage->getByIndex( 0 ) >>= image1;
390 2 : drawPage->getByIndex( 1 ) >>= image2;
391 2 : drawPage->getByIndex( 2 ) >>= image3;
392 : sal_Int32 zOrder1, zOrder2, zOrder3;
393 2 : OUString descr1, descr2, descr3;
394 2 : uno::Reference<beans::XPropertySet> imageProperties1(image1, uno::UNO_QUERY);
395 2 : imageProperties1->getPropertyValue( "ZOrder" ) >>= zOrder1;
396 2 : imageProperties1->getPropertyValue( "Description" ) >>= descr1;
397 2 : uno::Reference<beans::XPropertySet> imageProperties2(image2, uno::UNO_QUERY);
398 2 : imageProperties2->getPropertyValue( "ZOrder" ) >>= zOrder2;
399 2 : imageProperties2->getPropertyValue( "Description" ) >>= descr2;
400 2 : uno::Reference<beans::XPropertySet> imageProperties3(image3, uno::UNO_QUERY);
401 2 : imageProperties3->getPropertyValue( "ZOrder" ) >>= zOrder3;
402 2 : imageProperties3->getPropertyValue( "Description" ) >>= descr3;
403 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), zOrder1 );
404 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 1 ), zOrder2 );
405 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 2 ), zOrder3 );
406 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Black" ), descr1 );
407 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Red" ), descr2 );
408 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Green" ), descr3 );
409 2 : }
410 :
411 2 : void Test::testN750255()
412 : {
413 :
414 : /*
415 : Column break without columns on the page is a page break, so check those paragraphs
416 : are on page 2 (page style 'Converted1') and page 3 (page style 'Converted2')
417 : enum = ThisComponent.Text.createEnumeration
418 : enum.nextElement
419 : para1 = enum.nextElement
420 : xray para1.String
421 : xray para1.PageStyleName
422 : para2 = enum.nextElement
423 : xray para2.String
424 : xray para2.PageStyleName
425 : */
426 : // get the 2nd and 3rd paragraph
427 2 : uno::Reference<uno::XInterface> paragraph1(getParagraph( 2, "one" ));
428 2 : uno::Reference<uno::XInterface> paragraph2(getParagraph( 3, "two" ));
429 2 : OUString pageStyle1 = getProperty< OUString >( paragraph1, "PageStyleName" );
430 2 : OUString pageStyle2 = getProperty< OUString >( paragraph2, "PageStyleName" );
431 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Converted1" ), pageStyle1 );
432 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Converted2" ), pageStyle2 );
433 :
434 2 : }
435 :
436 2 : void Test::testN652364()
437 : {
438 : /*
439 : Related to 750255 above, column break with columns on the page however should be a column break.
440 : enum = ThisComponent.Text.createEnumeration
441 : enum.nextElement
442 : para1 = enum.nextElement
443 : xray para1.String
444 : xray para1.PageStyleName
445 : enum.nextElement
446 : para2 = enum.nextElement
447 : xray para2.String
448 : xray para2.PageStyleName
449 : */
450 : // get the 2nd and 4th paragraph
451 2 : uno::Reference<uno::XInterface> paragraph1(getParagraph( 2, "text1" ));
452 2 : uno::Reference<uno::XInterface> paragraph2(getParagraph( 4, "text2" ));
453 2 : OUString pageStyle1 = getProperty< OUString >( paragraph1, "PageStyleName" );
454 2 : OUString pageStyle2 = getProperty< OUString >( paragraph2, "PageStyleName" );
455 : // "Standard" is the style for the first page (2nd is "Converted1").
456 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle1 );
457 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle2 );
458 2 : }
459 :
460 2 : void Test::testN760764()
461 : {
462 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
463 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
464 2 : uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
465 2 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
466 2 : uno::Reference<container::XEnumeration> xRunEnum(xRunEnumAccess->createEnumeration());
467 :
468 : // Access the second run, which is a textfield
469 2 : xRunEnum->nextElement();
470 2 : uno::Reference<beans::XPropertySet> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
471 : float fValue;
472 2 : xRun->getPropertyValue("CharHeight") >>= fValue;
473 : // This used to be 11, as character properties were ignored.
474 2 : CPPUNIT_ASSERT_EQUAL(8.f, fValue);
475 2 : }
476 :
477 2 : void Test::testN764005()
478 : {
479 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
480 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
481 2 : uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
482 :
483 : // The picture in the header wasn't absolutely positioned and wasn't in the background.
484 : text::TextContentAnchorType eValue;
485 2 : xPropertySet->getPropertyValue("AnchorType") >>= eValue;
486 2 : CPPUNIT_ASSERT(eValue != text::TextContentAnchorType_AS_CHARACTER);
487 2 : sal_Bool bValue = sal_True;
488 2 : xPropertySet->getPropertyValue("Opaque") >>= bValue;
489 2 : CPPUNIT_ASSERT_EQUAL(sal_False, bValue);
490 2 : }
491 :
492 2 : void Test::testSmartart()
493 : {
494 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
495 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
496 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc
497 :
498 2 : uno::Reference<container::XIndexAccess> xGroup(xDraws->getByIndex(0), uno::UNO_QUERY);
499 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xGroup->getCount()); // 3 rectangles and an arrow in the group
500 :
501 2 : uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(1), uno::UNO_QUERY);
502 2 : sal_Int32 nValue(0);
503 2 : xPropertySet->getPropertyValue("FillColor") >>= nValue;
504 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), nValue); // If fill color is right, theme import is OK
505 :
506 2 : uno::Reference<text::XTextRange> xTextRange(xGroup->getByIndex(1), uno::UNO_QUERY);
507 2 : CPPUNIT_ASSERT_EQUAL(OUString("Sample"), xTextRange->getString()); // Shape has text
508 :
509 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextRange->getText(), uno::UNO_QUERY);
510 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
511 2 : xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY);
512 2 : xPropertySet->getPropertyValue("ParaAdjust") >>= nValue;
513 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_CENTER), nValue); // Paragraph properties are imported
514 2 : }
515 :
516 2 : void Test::testN764745()
517 : {
518 : /*
519 : shape = ThisComponent.DrawPage.getByIndex(0)
520 : xray shape.AnchorType
521 : xray shape.AnchorPosition.X
522 : xray ThisComponent.StyleFamilies.PageStyles.Default.Width
523 : */
524 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
525 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
526 2 : uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
527 : // The paragraph is right-aligned and the picture does not explicitly specify position,
528 : // so check it's anchored as character and in the right side of the document.
529 : text::TextContentAnchorType anchorType;
530 2 : xPropertySet->getPropertyValue("AnchorType") >>= anchorType;
531 2 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, anchorType);
532 2 : awt::Point pos;
533 2 : xPropertySet->getPropertyValue("AnchorPosition") >>= pos;
534 2 : uno::Reference<style::XStyleFamiliesSupplier> styleFamiliesSupplier(mxComponent, uno::UNO_QUERY);
535 2 : uno::Reference<container::XNameAccess> styleFamilies = styleFamiliesSupplier->getStyleFamilies();
536 2 : uno::Reference<container::XNameAccess> pageStyles;
537 2 : styleFamilies->getByName("PageStyles") >>= pageStyles;
538 2 : uno::Reference<uno::XInterface> defaultStyle;
539 2 : pageStyles->getByName(DEFAULT_STYLE) >>= defaultStyle;
540 2 : uno::Reference<beans::XPropertySet> styleProperties( defaultStyle, uno::UNO_QUERY );
541 2 : sal_Int32 width = 0;
542 2 : styleProperties->getPropertyValue( "Width" ) >>= width;
543 2 : CPPUNIT_ASSERT( pos.X > width / 2 );
544 2 : }
545 :
546 2 : void Test::testN766477()
547 : {
548 : /*
549 : * The problem was that the checkbox was not checked.
550 : *
551 : * oParas = ThisComponent.Text.createEnumeration
552 : * oPara = oParas.nextElement
553 : * oRuns = oPara.createEnumeration
554 : * oRun = oRuns.nextElement
555 : * xray oRun.Bookmark.Parameters.ElementNames(0) 'Checkbox_Checked
556 : */
557 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
558 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
559 2 : uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
560 2 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
561 2 : uno::Reference<container::XEnumeration> xRunEnum(xRunEnumAccess->createEnumeration());
562 2 : uno::Reference<beans::XPropertySet> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
563 2 : uno::Reference<text::XFormField> xFormField(xRun->getPropertyValue("Bookmark"), uno::UNO_QUERY);
564 2 : uno::Reference<container::XNameContainer> xParameters(xFormField->getParameters());
565 2 : uno::Sequence<OUString> aElementNames(xParameters->getElementNames());
566 2 : CPPUNIT_ASSERT_EQUAL(OUString("Checkbox_Checked"), aElementNames[0]);
567 2 : }
568 :
569 2 : void Test::testN758883()
570 : {
571 : /*
572 : * The problem was that direct formatting of the paragraph was not applied
573 : * to the numbering. This is easier to test using a layout dump.
574 : */
575 2 : OUString aHeight = parseDump("/root/page/body/txt/Special", "nHeight");
576 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(220), aHeight.toInt32()); // It was 280
577 :
578 : /*
579 : * Next problem was that the page margin contained the width of the page border as well.
580 : *
581 : * xray ThisComponent.StyleFamilies.PageStyles.Default.LeftMargin
582 : */
583 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
584 2 : sal_Int32 nValue = 0;
585 2 : xPropertySet->getPropertyValue("LeftMargin") >>= nValue;
586 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(794), nValue);
587 :
588 : // No assert for the 3rd problem: see the comment in the test doc.
589 :
590 : /*
591 : * 4th problem: Wrap type of the textwrape was not 'through'.
592 : *
593 : * xray ThisComponent.DrawPage(0).Surround ' was 2, should be 1
594 : */
595 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
596 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
597 2 : xPropertySet.set(xDraws->getByIndex(0), uno::UNO_QUERY);
598 : text::WrapTextMode eValue;
599 2 : xPropertySet->getPropertyValue("Surround") >>= eValue;
600 2 : CPPUNIT_ASSERT_EQUAL(eValue, text::WrapTextMode_THROUGHT);
601 :
602 : /*
603 : * 5th problem: anchor type of the second textbox was wrong.
604 : *
605 : * xray ThisComponent.DrawPage(1).AnchorType ' was 1, should be 4
606 : */
607 2 : xPropertySet.set(xDraws->getByIndex(1), uno::UNO_QUERY);
608 : text::TextContentAnchorType eAnchorType;
609 2 : xPropertySet->getPropertyValue("AnchorType") >>= eAnchorType;
610 2 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eAnchorType);
611 :
612 : // 6th problem: xray ThisComponent.DrawPage(2).AnchorType ' was 2, should be 4
613 2 : xPropertySet.set(xDraws->getByIndex(2), uno::UNO_QUERY);
614 2 : xPropertySet->getPropertyValue("AnchorType") >>= eAnchorType;
615 2 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eAnchorType);
616 2 : }
617 :
618 2 : void Test::testN766481()
619 : {
620 : /*
621 : * The problem was that we had an additional paragraph before the pagebreak.
622 : *
623 : * oParas = ThisComponent.Text.createEnumeration
624 : * oPara = oParas.nextElement
625 : * oPara = oParas.nextElement
626 : * xray oParas.hasMoreElements ' should be false
627 : */
628 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
629 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
630 2 : uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
631 6 : for (int i = 0; i < 2; ++i)
632 4 : xParaEnum->nextElement();
633 2 : CPPUNIT_ASSERT_EQUAL(sal_False, xParaEnum->hasMoreElements());
634 2 : }
635 :
636 2 : void Test::testN766487()
637 : {
638 : /*
639 : * The problem was that 1) the font size of the first para was too large 2) numbering had no first-line-indent.
640 : *
641 : * oParas = ThisComponent.Text.createEnumeration
642 : * oPara = oParas.nextElement
643 : * oRuns = oPara.createEnumeration
644 : * oRun = oRuns.nextElement
645 : * xray oRun.CharHeight ' 12, was larger
646 : * oPara = oParas.nextElement
647 : * xray oPara.ParaFirstLineIndent ' -635, was 0
648 : */
649 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
650 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
651 2 : uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
652 :
653 2 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
654 2 : uno::Reference<container::XEnumeration> xRunEnum(xRunEnumAccess->createEnumeration());
655 2 : uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
656 2 : float fValue = 0;
657 2 : xPropertySet->getPropertyValue("CharHeight") >>= fValue;
658 2 : CPPUNIT_ASSERT_EQUAL(12.f, fValue);
659 :
660 2 : xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY);
661 2 : sal_Int32 nValue = 0;
662 2 : xPropertySet->getPropertyValue("ParaFirstLineIndent") >>= nValue;
663 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(-360)), nValue);
664 2 : }
665 :
666 2 : void Test::testN693238()
667 : {
668 : /*
669 : * The problem was that a continous section break at the end of the doc caused the margins to be ignored.
670 : *
671 : * xray ThisComponent.StyleFamilies.PageStyles.Default.LeftMargin ' was 2000, should be 635
672 : */
673 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
674 2 : sal_Int32 nValue = 0;
675 2 : xPropertySet->getPropertyValue("LeftMargin") >>= nValue;
676 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(635), nValue);
677 2 : }
678 :
679 2 : void Test::testNumbering1()
680 : {
681 : /* <w:numPr> in the paragraph itself was overriden by <w:numpr> introduced by the paragraph's <w:pStyle>
682 : enum = ThisComponent.Text.createEnumeration
683 : para = enum.NextElement
684 : xray para.NumberingStyleName
685 : numberingstyle = ThisComponent.NumberingRules.getByIndex(6)
686 : xray numberingstyle.name - should match name above
687 : numbering = numberingstyle.getByIndex(0)
688 : xray numbering(11) - should be 4, arabic
689 : note that the indexes may get off as the implementation evolves, C++ code seaches in loops
690 : */
691 2 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
692 2 : uno::Reference< text::XTextRange > paragraph(getParagraph( 1, "Text1." ));
693 2 : OUString numberingStyleName = getProperty< OUString >( paragraph, "NumberingStyleName" );
694 2 : uno::Reference<text::XNumberingRulesSupplier> xNumberingRulesSupplier(mxComponent, uno::UNO_QUERY);
695 2 : uno::Reference<container::XIndexAccess> numberingRules(xNumberingRulesSupplier->getNumberingRules(), uno::UNO_QUERY);
696 2 : uno::Reference<container::XIndexAccess> numberingRule;
697 28 : for( int i = 0;
698 14 : i < numberingRules->getCount();
699 : ++i )
700 : {
701 14 : OUString name = getProperty< OUString >( numberingRules->getByIndex( i ), "Name" );
702 14 : if( name == numberingStyleName )
703 : {
704 2 : numberingRule.set( numberingRules->getByIndex( i ), uno::UNO_QUERY );
705 : break;
706 : }
707 14 : }
708 2 : CPPUNIT_ASSERT( numberingRule.is());
709 2 : uno::Sequence< beans::PropertyValue > numbering;
710 2 : numberingRule->getByIndex( 0 ) >>= numbering;
711 2 : sal_Int16 numberingType = style::NumberingType::NUMBER_NONE;
712 48 : for( int i = 0;
713 24 : i < numbering.getLength();
714 : ++i )
715 : {
716 24 : if( numbering[ i ].Name == "NumberingType" )
717 : {
718 2 : numbering[ i ].Value >>= numberingType;
719 2 : break;
720 : }
721 : }
722 2 : CPPUNIT_ASSERT_EQUAL( style::NumberingType::ARABIC, numberingType );
723 2 : }
724 :
725 2 : void Test::testBnc773061()
726 : {
727 2 : uno::Reference< text::XTextRange > paragraph = getParagraph( 1 );
728 2 : uno::Reference< text::XTextRange > normal = getRun( paragraph, 1, "Normal " );
729 2 : uno::Reference< text::XTextRange > raised = getRun( paragraph, 2, "Raised" );
730 2 : uno::Reference< text::XTextRange > lowered = getRun( paragraph, 4, "Lowered" );
731 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), getProperty< sal_Int32 >( normal, "CharEscapement" ));
732 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 50 ), getProperty< sal_Int32 >( raised, "CharEscapement" ));
733 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( -25 ), getProperty< sal_Int32 >( lowered, "CharEscapement" ));
734 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 100 ), getProperty< sal_Int32 >( normal, "CharEscapementHeight" ));
735 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 100 ), getProperty< sal_Int32 >( raised, "CharEscapementHeight" ));
736 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 100 ), getProperty< sal_Int32 >( lowered, "CharEscapementHeight" ));
737 2 : }
738 :
739 2 : void Test::testAllGapsWord()
740 : {
741 2 : BorderTest borderTest;
742 2 : borderTest.testTheBorders(mxComponent);
743 2 : }
744 :
745 2 : void Test::testN775906()
746 : {
747 : /*
748 : * The problem was that right margin (via direct formatting) erased the left/first margin (inherited from numbering style).
749 : *
750 : * oParas = ThisComponent.Text.createEnumeration
751 : * oPara = oParas.nextElement
752 : * xray oPara.ParaFirstLineIndent ' was 0
753 : * xray oPara.ParaLeftMargin ' was 0
754 : */
755 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-635), getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent"));
756 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1905), getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
757 2 : }
758 :
759 2 : void Test::testN775899()
760 : {
761 : /*
762 : * The problem was that a floating table wasn't imported as a frame, then it contained fake paragraphs.
763 : *
764 : * ThisComponent.TextFrames.Count ' was 0
765 : * oParas = ThisComponent.TextFrames(0).Text.createEnumeration
766 : * oPara = oParas.nextElement
767 : * oPara.supportsService("com.sun.star.text.TextTable") 'was a fake paragraph
768 : * oParas.hasMoreElements 'was true
769 : */
770 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
771 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
772 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
773 :
774 2 : uno::Reference<text::XTextFrame> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
775 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xFrame->getText(), uno::UNO_QUERY);
776 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
777 2 : uno::Reference<lang::XServiceInfo> xServiceInfo(xParaEnum->nextElement(), uno::UNO_QUERY);
778 2 : CPPUNIT_ASSERT_EQUAL(sal_True, xServiceInfo->supportsService("com.sun.star.text.TextTable"));
779 :
780 2 : CPPUNIT_ASSERT_EQUAL(sal_False, xParaEnum->hasMoreElements());
781 2 : }
782 :
783 2 : void Test::testN777345()
784 : {
785 : // The problem was that v:imagedata inside v:rect was ignored.
786 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
787 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
788 2 : uno::Reference<document::XEmbeddedObjectSupplier2> xSupplier(xDraws->getByIndex(0), uno::UNO_QUERY);
789 2 : uno::Reference<graphic::XGraphic> xGraphic = xSupplier->getReplacementGraphic();
790 2 : Graphic aGraphic(xGraphic);
791 : // If this changes later, feel free to update it, but make sure it's not
792 : // the checksum of a white/transparent placeholder rectangle.
793 2 : CPPUNIT_ASSERT_EQUAL(sal_uLong(3816010727U), aGraphic.GetChecksum());
794 2 : }
795 :
796 2 : void Test::testN777337()
797 : {
798 : /*
799 : * The problem was that the top and bottom margin on the first page was only 0.1cm instead of 1.7cm.
800 : *
801 : * oFirst = ThisComponent.StyleFamilies.PageStyles.getByName("First Page")
802 : * xray oFirst.TopMargin
803 : * xray oFirst.BottomMargin
804 : */
805 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("First Page"), uno::UNO_QUERY);
806 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1702), getProperty<sal_Int32>(xPropertySet, "TopMargin"));
807 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1702), getProperty<sal_Int32>(xPropertySet, "BottomMargin"));
808 2 : }
809 :
810 2 : void Test::testN778836()
811 : {
812 : /*
813 : * The problem was that the paragraph inherited margins from the numbering
814 : * and parent paragraph styles and the result was incorrect.
815 : */
816 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1270), getProperty<sal_Int32>(getParagraph(0), "ParaRightMargin"));
817 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3810), getProperty<sal_Int32>(getParagraph(0), "ParaLeftMargin"));
818 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-635), getProperty<sal_Int32>(getParagraph(0), "ParaFirstLineIndent"));
819 2 : }
820 :
821 2 : void Test::testN778140()
822 : {
823 : /*
824 : * The problem was that the paragraph top/bottom margins were incorrect due
825 : * to unhandled w:doNotUseHTMLParagraphAutoSpacing.
826 : */
827 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(176), getProperty<sal_Int32>(getParagraph(0), "ParaTopMargin"));
828 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(176), getProperty<sal_Int32>(getParagraph(0), "ParaBottomMargin"));
829 2 : }
830 :
831 2 : void Test::testN778828()
832 : {
833 : /*
834 : * The problem was that a page break after a continous section break caused
835 : * double page break on title page.
836 : */
837 2 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
838 2 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
839 2 : uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
840 2 : xCursor->jumpToLastPage();
841 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
842 2 : }
843 :
844 2 : void Test::testInk()
845 : {
846 : /*
847 : * The problem was that ~nothing was imported, except an empty CustomShape.
848 : *
849 : * xray ThisComponent.DrawPage(0).supportsService("com.sun.star.drawing.OpenBezierShape")
850 : */
851 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
852 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
853 2 : uno::Reference<lang::XServiceInfo> xServiceInfo(xDraws->getByIndex(0), uno::UNO_QUERY);
854 2 : CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.drawing.OpenBezierShape"));
855 2 : }
856 :
857 2 : void Test::testN779834()
858 : {
859 : // This document simply crashed the importer.
860 2 : }
861 :
862 2 : void Test::testN779627()
863 : {
864 : /*
865 : * The problem was that the table left position was based on the tableCellMar left value
866 : * even for nested tables, while it shouldn't.
867 : */
868 2 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
869 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
870 2 : uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY);
871 2 : uno::Any aValue = xTableProperties->getPropertyValue("LeftMargin");
872 : sal_Int32 nLeftMargin;
873 2 : aValue >>= nLeftMargin;
874 4 : CPPUNIT_ASSERT_EQUAL_MESSAGE( "Left margin shouldn't take tableCellMar into account in nested tables",
875 2 : sal_Int32(0), nLeftMargin);
876 :
877 : /*
878 : * Another problem tested with this document is that the roundrect is
879 : * centered vertically and horizontally.
880 : */
881 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
882 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
883 2 : uno::Reference<beans::XPropertySet> xShapeProperties( xDraws->getByIndex(2), uno::UNO_QUERY );
884 : sal_Int16 nValue;
885 2 : xShapeProperties->getPropertyValue("HoriOrient") >>= nValue;
886 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally", text::HoriOrientation::CENTER, nValue);
887 2 : xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
888 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally relatively to page", text::RelOrientation::PAGE_FRAME, nValue);
889 2 : xShapeProperties->getPropertyValue("VertOrient") >>= nValue;
890 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered vertically", text::VertOrientation::CENTER, nValue);
891 2 : xShapeProperties->getPropertyValue("VertOrientRelation") >>= nValue;
892 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered vertically relatively to page", text::RelOrientation::PAGE_FRAME, nValue);
893 2 : }
894 :
895 2 : void Test::testFdo55187()
896 : {
897 : // 0x010d was imported as a newline.
898 2 : getParagraph(1, OUString("lupĨka", 7, RTL_TEXTENCODING_UTF8));
899 2 : }
900 :
901 2 : void Test::testN780563()
902 : {
903 : /*
904 : * Make sure we have the table in the fly frame created
905 : */
906 2 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
907 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
908 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount( ));
909 2 : }
910 :
911 2 : void Test::testN780853()
912 : {
913 : /*
914 : * The problem was that the table was not imported.
915 : *
916 : * xray ThisComponent.TextTables.Count 'was 0
917 : */
918 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
919 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
920 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
921 2 : }
922 :
923 2 : void Test::testN780843()
924 : {
925 : /*
926 : * The problem was that wrong footer was picked.
927 : *
928 : * oParas = ThisComponent.Text.createEnumeration
929 : * oPara = oParas.nextElement
930 : * oPara = oParas.nextElement
931 : * oPara = oParas.nextElement
932 : * sStyle = oPara.PageStyleName
933 : * oStyle = ThisComponent.StyleFamilies.PageStyles.getByName(sStyle)
934 : * xray oStyle.FooterText.String ' was "hidden footer"
935 : */
936 2 : uno::Reference< text::XTextRange > xPara = getParagraph(3);
937 2 : OUString aStyleName = getProperty<OUString>(xPara, "PageStyleName");
938 2 : uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(aStyleName), uno::UNO_QUERY);
939 2 : uno::Reference<text::XTextRange> xFooter = getProperty< uno::Reference<text::XTextRange> >(xPageStyle, "FooterText");
940 2 : CPPUNIT_ASSERT_EQUAL(OUString("shown footer"), xFooter->getString());
941 2 : }
942 :
943 2 : void Test::testShadow()
944 : {
945 : /*
946 : * The problem was that drop shadows on inline images were not being
947 : * imported and applied.
948 : */
949 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
950 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
951 2 : uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(1), uno::UNO_QUERY);
952 :
953 2 : table::ShadowFormat aShadow;
954 2 : xPropertySet->getPropertyValue("ShadowFormat") >>= aShadow;
955 2 : CPPUNIT_ASSERT(sal_Int32(aShadow.ShadowWidth) > 0);
956 2 : }
957 :
958 2 : void Test::testN782061()
959 : {
960 : /*
961 : * The problem was that the character escapement in the second run was -58.
962 : */
963 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-9), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapement"));
964 2 : }
965 :
966 2 : void Test::testN782345()
967 : {
968 : /*
969 : * The problem was that the page break was inserted before the 3rd para, instead of before the 2nd para.
970 : */
971 2 : CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
972 2 : }
973 :
974 2 : void Test::testN779941()
975 : {
976 : /*
977 : * Make sure top/bottom margins of tables are set to 0 (problem was: bottom margin set to 0.35cm)
978 : */
979 2 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
980 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
981 2 : uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY);
982 : {
983 2 : uno::Any aValue = xTableProperties->getPropertyValue("TopMargin");
984 : sal_Int32 nTopMargin;
985 2 : aValue >>= nTopMargin;
986 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nTopMargin);
987 : }
988 : {
989 2 : uno::Any aValue = xTableProperties->getPropertyValue("BottomMargin");
990 : sal_Int32 nBottomMargin;
991 2 : aValue >>= nBottomMargin;
992 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nBottomMargin);
993 2 : }
994 2 : }
995 :
996 2 : void Test::testN783638()
997 : {
998 : // The problem was that the margins of inline images were not zero.
999 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1000 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1001 2 : uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
1002 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "LeftMargin"));
1003 2 : }
1004 :
1005 2 : void Test::testFdo52208()
1006 : {
1007 : // The problem was that the document had 2 pages instead of 1.
1008 2 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
1009 2 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
1010 2 : uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
1011 2 : xCursor->jumpToLastPage();
1012 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage());
1013 2 : }
1014 :
1015 :
1016 2 : void Test::testN785767()
1017 : {
1018 2 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1019 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1020 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1021 2 : uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
1022 : // Check the A1 and B1 cells, the width of both of them was the default value (10000 / 9, as there were 9 cells in the row).
1023 2 : CPPUNIT_ASSERT_MESSAGE("A1 must not have default width", sal_Int16(10000 / 9) != getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
1024 2 : CPPUNIT_ASSERT_MESSAGE("B1 must not have default width", sal_Int16(10000 / 9) != getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position);
1025 2 : }
1026 :
1027 2 : void Test::testN773061()
1028 : {
1029 : // xray ThisComponent.TextFrames(0).LeftBorderDistance
1030 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
1031 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
1032 2 : uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
1033 2 : CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "LeftBorderDistance" ), sal_Int32( 0 ));
1034 2 : CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "TopBorderDistance" ), sal_Int32( 0 ));
1035 2 : CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "RightBorderDistance" ), sal_Int32( 0 ));
1036 2 : CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "BottomBorderDistance" ), sal_Int32( 0 ));
1037 2 : }
1038 :
1039 2 : void Test::testN780645()
1040 : {
1041 : // The problem was that when the number of cells didn't match the grid, we
1042 : // didn't take care of direct cell widths.
1043 2 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1044 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1045 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1046 2 : uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
1047 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(2135), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position); // was 1999
1048 2 : }
1049 :
1050 2 : void Test::testFineTableDash()
1051 : {
1052 : // The problem was that finely dashed borders on tables were unsupported
1053 2 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1054 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1055 2 : uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY);
1056 2 : table::TableBorder2 aBorder;
1057 2 : xTableProperties->getPropertyValue("TableBorder2") >>= aBorder;
1058 2 : CPPUNIT_ASSERT_EQUAL(aBorder.RightLine.LineStyle, table::BorderLineStyle::FINE_DASHED);
1059 2 : }
1060 :
1061 2 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
1062 :
1063 8 : CPPUNIT_PLUGIN_IMPLEMENT();
1064 :
1065 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|