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