Line data Source code
1 : /*
2 : * This file is part of the LibreOffice project.
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : */
8 :
9 : #include "config_test.h"
10 :
11 : #include <swmodeltestbase.hxx>
12 :
13 : #if !defined(WNT)
14 :
15 : #include <com/sun/star/awt/XBitmap.hpp>
16 : #include <com/sun/star/awt/FontUnderline.hpp>
17 : #include <com/sun/star/awt/FontWeight.hpp>
18 : #include <com/sun/star/beans/XPropertySet.hpp>
19 : #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
20 : #include <com/sun/star/drawing/XControlShape.hpp>
21 : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
22 : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
23 : #include <com/sun/star/lang/XServiceInfo.hpp>
24 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
25 : #include <com/sun/star/text/HoriOrientation.hpp>
26 : #include <com/sun/star/text/RelOrientation.hpp>
27 : #include <com/sun/star/text/SetVariableType.hpp>
28 : #include <com/sun/star/text/TableColumnSeparator.hpp>
29 : #include <com/sun/star/text/TextContentAnchorType.hpp>
30 : #include <com/sun/star/text/VertOrientation.hpp>
31 : #include <com/sun/star/text/WrapTextMode.hpp>
32 : #include <com/sun/star/text/WritingMode2.hpp>
33 : #include <com/sun/star/text/XDependentTextField.hpp>
34 : #include <com/sun/star/text/XFormField.hpp>
35 : #include <com/sun/star/text/XPageCursor.hpp>
36 : #include <com/sun/star/text/XTextColumns.hpp>
37 : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
38 : #include <com/sun/star/text/XTextFrame.hpp>
39 : #include <com/sun/star/text/XTextFramesSupplier.hpp>
40 : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
41 : #include <com/sun/star/style/BreakType.hpp>
42 : #include <com/sun/star/style/ParagraphAdjust.hpp>
43 : #include <com/sun/star/style/LineSpacing.hpp>
44 : #include <com/sun/star/style/LineSpacingMode.hpp>
45 : #include <com/sun/star/table/ShadowFormat.hpp>
46 : #include <com/sun/star/view/XSelectionSupplier.hpp>
47 : #include <com/sun/star/view/XFormLayerAccess.hpp>
48 : #include <com/sun/star/table/BorderLine2.hpp>
49 : #include <com/sun/star/table/TableBorder2.hpp>
50 : #include <com/sun/star/text/SizeType.hpp>
51 : #include <com/sun/star/xml/dom/XDocument.hpp>
52 : #include <com/sun/star/text/XDocumentIndex.hpp>
53 : #include <com/sun/star/style/CaseMap.hpp>
54 : #include <com/sun/star/style/ParagraphAdjust.hpp>
55 : #include <vcl/svapp.hxx>
56 : #include <unotools/fltrcfg.hxx>
57 : #include <comphelper/sequenceashashmap.hxx>
58 : #include <com/sun/star/text/GraphicCrop.hpp>
59 : #include <swtypes.hxx>
60 :
61 : #include <bordertest.hxx>
62 :
63 136 : class Test : public SwModelTestBase
64 : {
65 : public:
66 136 : Test() : SwModelTestBase("/sw/qa/extras/ooxmlimport/data/", "Office Open XML Text")
67 : {
68 136 : }
69 :
70 136 : virtual void preTest(const char* filename) SAL_OVERRIDE
71 : {
72 136 : if (OString(filename) == "smartart.docx" || OString(filename) == "strict-smartart.docx")
73 2 : SvtFilterOptions::Get().SetSmartArt2Shape(true);
74 136 : }
75 :
76 136 : virtual void postTest(const char* filename) SAL_OVERRIDE
77 : {
78 136 : if (OString(filename) == "smartart.docx" || OString(filename) == "strict-smartart.docx")
79 2 : SvtFilterOptions::Get().SetSmartArt2Shape(false);
80 136 : }
81 : };
82 :
83 : #define DECLARE_OOXMLIMPORT_TEST(TestName, filename) DECLARE_SW_IMPORT_TEST(TestName, filename, Test)
84 :
85 9 : DECLARE_OOXMLIMPORT_TEST(testN751054, "n751054.docx")
86 : {
87 1 : text::TextContentAnchorType eValue = getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType");
88 1 : CPPUNIT_ASSERT(eValue != text::TextContentAnchorType_AS_CHARACTER);
89 1 : }
90 :
91 9 : DECLARE_OOXMLIMPORT_TEST(testN751117, "n751117.docx")
92 : {
93 : // First shape: the end should be an arrow, should be rotated and should be flipped.
94 1 : uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
95 2 : OUString aValue;
96 1 : xPropertySet->getPropertyValue("LineEndName") >>= aValue;
97 1 : CPPUNIT_ASSERT(aValue.indexOf("Arrow") != -1);
98 :
99 : // Rotating & Flipping will cause the angle to change from 90 degrees to 270 degrees
100 1 : sal_Int32 nValue = 0;
101 1 : xPropertySet->getPropertyValue("RotateAngle") >>= nValue;
102 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(270 * 100), nValue);
103 :
104 2 : uno::Reference<drawing::XShape> xShape(xPropertySet, uno::UNO_QUERY);
105 1 : awt::Size aActualSize(xShape->getSize());
106 1 : CPPUNIT_ASSERT(aActualSize.Width > 0);
107 :
108 : // The second shape should be a line
109 2 : uno::Reference<lang::XServiceInfo> xServiceInfo(getShape(2), uno::UNO_QUERY);
110 2 : CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.drawing.LineShape"));
111 1 : }
112 :
113 9 : DECLARE_OOXMLIMPORT_TEST(testN751017, "n751017.docx")
114 : {
115 1 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
116 2 : uno::Reference<container::XNameAccess> xMasters(xTextFieldsSupplier->getTextFieldMasters());
117 : // Make sure we have a variable named foo.
118 1 : CPPUNIT_ASSERT(xMasters->hasByName("com.sun.star.text.FieldMaster.SetExpression.foo"));
119 :
120 2 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
121 2 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
122 1 : bool bFoundSet(false), bFoundGet(false);
123 4 : while (xFields->hasMoreElements())
124 : {
125 2 : uno::Reference<lang::XServiceInfo> xServiceInfo(xFields->nextElement(), uno::UNO_QUERY);
126 4 : uno::Reference<beans::XPropertySet> xPropertySet(xServiceInfo, uno::UNO_QUERY);
127 2 : sal_Int16 nValue = 0;
128 4 : OUString aValue;
129 2 : if (xServiceInfo->supportsService("com.sun.star.text.TextField.SetExpression"))
130 : {
131 1 : bFoundSet = true;
132 1 : uno::Reference<text::XDependentTextField> xDependentTextField(xServiceInfo, uno::UNO_QUERY);
133 2 : uno::Reference<beans::XPropertySet> xMasterProps(xDependentTextField->getTextFieldMaster());
134 :
135 : // First step: did we set foo to "bar"?
136 1 : xMasterProps->getPropertyValue("Name") >>= aValue;
137 1 : CPPUNIT_ASSERT_EQUAL(OUString("foo"), aValue);
138 1 : xPropertySet->getPropertyValue("SubType") >>= nValue;
139 1 : CPPUNIT_ASSERT_EQUAL(text::SetVariableType::STRING, nValue);
140 1 : xPropertySet->getPropertyValue("Content") >>= aValue;
141 2 : CPPUNIT_ASSERT_EQUAL(OUString("bar"), aValue);
142 : }
143 1 : else if (xServiceInfo->supportsService("com.sun.star.text.TextField.GetExpression"))
144 : {
145 : // Second step: check the value of foo.
146 1 : bFoundGet = true;
147 1 : xPropertySet->getPropertyValue("Content") >>= aValue;
148 1 : CPPUNIT_ASSERT_EQUAL(OUString("foo"), aValue);
149 1 : xPropertySet->getPropertyValue("SubType") >>= nValue;
150 1 : CPPUNIT_ASSERT_EQUAL(text::SetVariableType::STRING, nValue);
151 1 : xPropertySet->getPropertyValue("CurrentPresentation") >>= aValue;
152 1 : CPPUNIT_ASSERT_EQUAL(OUString("bar"), aValue);
153 : }
154 2 : }
155 1 : CPPUNIT_ASSERT(bFoundSet);
156 2 : CPPUNIT_ASSERT(bFoundGet);
157 1 : }
158 :
159 9 : DECLARE_OOXMLIMPORT_TEST(testN750935, "n750935.docx")
160 : {
161 1 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
162 2 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
163 2 : uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
164 1 : xCursor->jumpToLastPage();
165 : // Some page break types were ignores, resulting in less pages.
166 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(5), xCursor->getPage());
167 :
168 : /*
169 : * The problem was that the header and footer was not shared.
170 : *
171 : * xray ThisComponent.StyleFamilies.PageStyles.Default.FooterIsShared
172 : */
173 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
174 1 : sal_Bool bValue = false;
175 1 : xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue;
176 1 : CPPUNIT_ASSERT_EQUAL(sal_Bool(true), bValue);
177 1 : xPropertySet->getPropertyValue("FooterIsShared") >>= bValue;
178 2 : CPPUNIT_ASSERT_EQUAL(sal_Bool(true), bValue);
179 1 : }
180 :
181 9 : DECLARE_OOXMLIMPORT_TEST(testN757890, "n757890.docx")
182 : {
183 : // The w:pStyle token affected the text outside the textbox.
184 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
185 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
186 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
187 2 : uno::Reference<beans::XPropertySet> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
188 2 : OUString aValue;
189 1 : xPara->getPropertyValue("ParaStyleName") >>= aValue;
190 1 : CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), aValue);
191 :
192 : // This wan't centered
193 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
194 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
195 2 : uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
196 : sal_Int16 nValue;
197 1 : xFrame->getPropertyValue("HoriOrient") >>= nValue;
198 2 : CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, nValue);
199 1 : }
200 :
201 9 : DECLARE_OOXMLIMPORT_TEST(testRhbz988516, "rhbz988516.docx")
202 : {
203 : // The problem was that the list properties of the footer leaked into body
204 2 : CPPUNIT_ASSERT_EQUAL(OUString(),
205 1 : getProperty<OUString>(getParagraph(1), "NumberingStyleName"));
206 1 : CPPUNIT_ASSERT_EQUAL(OUString("Enclosure 3"), getParagraph(2)->getString());
207 2 : CPPUNIT_ASSERT_EQUAL(OUString(),
208 1 : getProperty<OUString>(getParagraph(2), "NumberingStyleName"));
209 2 : CPPUNIT_ASSERT_EQUAL(OUString(),
210 1 : getProperty<OUString>(getParagraph(3), "NumberingStyleName"));
211 1 : }
212 :
213 9 : DECLARE_OOXMLIMPORT_TEST(testFdo49940, "fdo49940.docx")
214 : {
215 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
216 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
217 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
218 2 : uno::Reference<beans::XPropertySet> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
219 2 : OUString aValue;
220 1 : xPara->getPropertyValue("PageStyleName") >>= aValue;
221 2 : CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aValue);
222 1 : }
223 :
224 9 : DECLARE_OOXMLIMPORT_TEST(testN751077, "n751077.docx")
225 : {
226 : /*
227 : xray ThisComponent.DrawPage(1).getByIndex(0).String
228 : xray ThisComponent.DrawPage(1).getByIndex(0).Anchor.PageStyleName
229 : */
230 1 : uno::Reference<drawing::XShapes> xShapes(getShape(2), uno::UNO_QUERY);
231 2 : uno::Reference<text::XTextRange> xShape(xShapes->getByIndex(0), uno::UNO_QUERY);
232 1 : CPPUNIT_ASSERT_EQUAL(OUString("TEXT1\n"), xShape->getString());
233 : // we want to test the textbox is on the first page (it was put onto another page without the fix),
234 : // use a small trick and instead of checking the page layout, check the page style
235 2 : uno::Reference<text::XTextContent> xTextContent(xShape, uno::UNO_QUERY);
236 2 : CPPUNIT_ASSERT_EQUAL(OUString("First Page"), getProperty<OUString>(xTextContent->getAnchor(), "PageStyleName"));
237 1 : }
238 :
239 9 : DECLARE_OOXMLIMPORT_TEST(testN705956_1, "n705956-1.docx")
240 : {
241 : /*
242 : Get the first image in the document and check it's the one image in the document.
243 : It should be also anchored inline (as character) and be inside a groupshape.
244 : image = ThisComponent.DrawPage.getByIndex(0)
245 : graphic = image(0).Graphic
246 : xray graphic.Size
247 : xray image.AnchorType
248 : */
249 1 : uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
250 2 : uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
251 2 : uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage();
252 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 1 ), drawPage->getCount());
253 2 : uno::Reference<drawing::XShapes> shapes(getShape(1), uno::UNO_QUERY);
254 2 : uno::Reference<drawing::XShape> image;
255 1 : shapes->getByIndex(0) >>= image;
256 2 : uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
257 2 : uno::Reference<graphic::XGraphic> graphic;
258 1 : imageProperties->getPropertyValue( "Graphic" ) >>= graphic;
259 2 : uno::Reference<awt::XBitmap> bitmap(graphic, uno::UNO_QUERY);
260 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(120), bitmap->getSize().Width );
261 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(106), bitmap->getSize().Height );
262 : text::TextContentAnchorType anchorType;
263 1 : imageProperties->getPropertyValue( "AnchorType" ) >>= anchorType;
264 2 : CPPUNIT_ASSERT_EQUAL( text::TextContentAnchorType_AS_CHARACTER, anchorType );
265 1 : }
266 :
267 9 : DECLARE_OOXMLIMPORT_TEST(testN705956_2, "n705956-2.docx")
268 : {
269 : /*
270 : <v:shapetype> must be global, reachable even from <v:shape> inside another <w:pict>
271 : image = ThisComponent.DrawPage.getByIndex(0)
272 : xray image.FillColor
273 : */
274 1 : uno::Reference<drawing::XShape> image = getShape(1);
275 2 : uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
276 : sal_Int32 fillColor;
277 1 : imageProperties->getPropertyValue( "FillColor" ) >>= fillColor;
278 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 0xc0504d ), fillColor );
279 1 : }
280 :
281 9 : DECLARE_OOXMLIMPORT_TEST(testN747461, "n747461.docx")
282 : {
283 : /*
284 : The document contains 3 images (Red, Black, Green, in this order), with explicit
285 : w:relativeHeight (300, 0, 225763766). Check that they are in the right ZOrder
286 : after they are loaded.
287 : */
288 2 : uno::Reference<drawing::XShape> image1 = getShape(1), image2 = getShape(2), image3 = getShape(3);
289 : sal_Int32 zOrder1, zOrder2, zOrder3;
290 2 : OUString descr1, descr2, descr3;
291 2 : uno::Reference<beans::XPropertySet> imageProperties1(image1, uno::UNO_QUERY);
292 1 : imageProperties1->getPropertyValue( "ZOrder" ) >>= zOrder1;
293 1 : imageProperties1->getPropertyValue( "Description" ) >>= descr1;
294 2 : uno::Reference<beans::XPropertySet> imageProperties2(image2, uno::UNO_QUERY);
295 1 : imageProperties2->getPropertyValue( "ZOrder" ) >>= zOrder2;
296 1 : imageProperties2->getPropertyValue( "Description" ) >>= descr2;
297 2 : uno::Reference<beans::XPropertySet> imageProperties3(image3, uno::UNO_QUERY);
298 1 : imageProperties3->getPropertyValue( "ZOrder" ) >>= zOrder3;
299 1 : imageProperties3->getPropertyValue( "Description" ) >>= descr3;
300 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), zOrder1 );
301 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 1 ), zOrder2 );
302 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 2 ), zOrder3 );
303 1 : CPPUNIT_ASSERT_EQUAL( OUString( "Black" ), descr1 );
304 1 : CPPUNIT_ASSERT_EQUAL( OUString( "Red" ), descr2 );
305 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Green" ), descr3 );
306 1 : }
307 :
308 9 : DECLARE_OOXMLIMPORT_TEST(testN750255, "n750255.docx")
309 : {
310 :
311 : /*
312 : Column break without columns on the page is a page break, so check those paragraphs
313 : are on page 2 (page style 'Converted1') and page 3 (page style 'Converted2')
314 : enum = ThisComponent.Text.createEnumeration
315 : enum.nextElement
316 : para1 = enum.nextElement
317 : xray para1.String
318 : xray para1.PageStyleName
319 : para2 = enum.nextElement
320 : xray para2.String
321 : xray para2.PageStyleName
322 : */
323 : // get the 2nd and 3rd paragraph
324 1 : uno::Reference<uno::XInterface> paragraph1(getParagraph( 2, "one" ));
325 2 : uno::Reference<uno::XInterface> paragraph2(getParagraph( 3, "two" ));
326 2 : OUString pageStyle1 = getProperty< OUString >( paragraph1, "PageStyleName" );
327 2 : OUString pageStyle2 = getProperty< OUString >( paragraph2, "PageStyleName" );
328 1 : CPPUNIT_ASSERT_EQUAL( OUString( "Converted1" ), pageStyle1 );
329 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Converted2" ), pageStyle2 );
330 :
331 1 : }
332 :
333 9 : DECLARE_OOXMLIMPORT_TEST(testN652364, "n652364.docx")
334 : {
335 : /*
336 : Related to 750255 above, column break with columns on the page however should be a column break.
337 : enum = ThisComponent.Text.createEnumeration
338 : enum.nextElement
339 : para1 = enum.nextElement
340 : xray para1.String
341 : xray para1.PageStyleName
342 : enum.nextElement
343 : para2 = enum.nextElement
344 : xray para2.String
345 : xray para2.PageStyleName
346 : */
347 : // get the 2nd and 4th paragraph
348 1 : uno::Reference<uno::XInterface> paragraph1(getParagraph( 2, "text1" ));
349 2 : uno::Reference<uno::XInterface> paragraph2(getParagraph( 4, "text2" ));
350 2 : OUString pageStyle1 = getProperty< OUString >( paragraph1, "PageStyleName" );
351 2 : OUString pageStyle2 = getProperty< OUString >( paragraph2, "PageStyleName" );
352 : // "Standard" is the style for the first page (2nd is "Converted1").
353 1 : CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle1 );
354 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle2 );
355 1 : }
356 :
357 9 : DECLARE_OOXMLIMPORT_TEST(testN760764, "n760764.docx")
358 : {
359 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
360 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
361 2 : uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
362 2 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
363 2 : uno::Reference<container::XEnumeration> xRunEnum(xRunEnumAccess->createEnumeration());
364 :
365 : // Access the second run, which is a textfield
366 1 : xRunEnum->nextElement();
367 2 : uno::Reference<beans::XPropertySet> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
368 : float fValue;
369 1 : xRun->getPropertyValue("CharHeight") >>= fValue;
370 : // This used to be 11, as character properties were ignored.
371 2 : CPPUNIT_ASSERT_EQUAL(8.f, fValue);
372 1 : }
373 :
374 9 : DECLARE_OOXMLIMPORT_TEST(testN764005, "n764005.docx")
375 : {
376 1 : uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
377 :
378 : // The picture in the header wasn't absolutely positioned and wasn't in the background.
379 : text::TextContentAnchorType eValue;
380 1 : xPropertySet->getPropertyValue("AnchorType") >>= eValue;
381 1 : CPPUNIT_ASSERT(eValue != text::TextContentAnchorType_AS_CHARACTER);
382 1 : sal_Bool bValue = sal_True;
383 1 : xPropertySet->getPropertyValue("Opaque") >>= bValue;
384 1 : CPPUNIT_ASSERT_EQUAL(false, bool(bValue));
385 1 : }
386 :
387 9 : DECLARE_OOXMLIMPORT_TEST(testN764745, "n764745-alignment.docx")
388 : {
389 : /*
390 : shape = ThisComponent.DrawPage.getByIndex(0)
391 : xray shape.AnchorType
392 : xray shape.AnchorPosition.X
393 : xray ThisComponent.StyleFamilies.PageStyles.Default.Width
394 : */
395 1 : uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
396 : // The paragraph is right-aligned and the picture does not explicitly specify position,
397 : // so check it's anchored as character and in the right side of the document.
398 : text::TextContentAnchorType anchorType;
399 1 : xPropertySet->getPropertyValue("AnchorType") >>= anchorType;
400 1 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, anchorType);
401 1 : awt::Point pos;
402 1 : xPropertySet->getPropertyValue("AnchorPosition") >>= pos;
403 2 : uno::Reference<style::XStyleFamiliesSupplier> styleFamiliesSupplier(mxComponent, uno::UNO_QUERY);
404 2 : uno::Reference<container::XNameAccess> styleFamilies = styleFamiliesSupplier->getStyleFamilies();
405 2 : uno::Reference<container::XNameAccess> pageStyles;
406 1 : styleFamilies->getByName("PageStyles") >>= pageStyles;
407 2 : uno::Reference<uno::XInterface> defaultStyle;
408 1 : pageStyles->getByName(DEFAULT_STYLE) >>= defaultStyle;
409 2 : uno::Reference<beans::XPropertySet> styleProperties( defaultStyle, uno::UNO_QUERY );
410 1 : sal_Int32 width = 0;
411 1 : styleProperties->getPropertyValue( "Width" ) >>= width;
412 2 : CPPUNIT_ASSERT( pos.X > width / 2 );
413 1 : }
414 :
415 9 : DECLARE_OOXMLIMPORT_TEST(testN766477, "n766477.docx")
416 : {
417 : /*
418 : * The problem was that the checkbox was not checked.
419 : *
420 : * oParas = ThisComponent.Text.createEnumeration
421 : * oPara = oParas.nextElement
422 : * oRuns = oPara.createEnumeration
423 : * oRun = oRuns.nextElement
424 : * xray oRun.Bookmark.Parameters.ElementNames(0) 'Checkbox_Checked
425 : */
426 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
427 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
428 2 : uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
429 2 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
430 2 : uno::Reference<container::XEnumeration> xRunEnum(xRunEnumAccess->createEnumeration());
431 2 : uno::Reference<beans::XPropertySet> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
432 2 : uno::Reference<text::XFormField> xFormField(xRun->getPropertyValue("Bookmark"), uno::UNO_QUERY);
433 2 : uno::Reference<container::XNameContainer> xParameters(xFormField->getParameters());
434 2 : uno::Sequence<OUString> aElementNames(xParameters->getElementNames());
435 2 : CPPUNIT_ASSERT_EQUAL(OUString("Checkbox_Checked"), aElementNames[0]);
436 1 : }
437 :
438 9 : DECLARE_OOXMLIMPORT_TEST(testN758883, "n758883.docx")
439 : {
440 : /*
441 : * The problem was that direct formatting of the paragraph was not applied
442 : * to the numbering. This is easier to test using a layout dump.
443 : */
444 1 : OUString aHeight = parseDump("/root/page/body/txt/Special", "nHeight");
445 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(220), aHeight.toInt32()); // It was 280
446 :
447 : /*
448 : * Next problem was that the page margin contained the width of the page border as well.
449 : *
450 : * xray ThisComponent.StyleFamilies.PageStyles.Default.LeftMargin
451 : */
452 2 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
453 1 : sal_Int32 nValue = 0;
454 1 : xPropertySet->getPropertyValue("LeftMargin") >>= nValue;
455 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(794), nValue);
456 :
457 : // No assert for the 3rd problem: see the comment in the test doc.
458 :
459 : /*
460 : * 4th problem: Wrap type of the textwrape was not 'through'.
461 : *
462 : * xray ThisComponent.DrawPage(0).Surround ' was 2, should be 1
463 : */
464 1 : xPropertySet.set(getShape(1), uno::UNO_QUERY);
465 : text::WrapTextMode eValue;
466 1 : xPropertySet->getPropertyValue("Surround") >>= eValue;
467 1 : CPPUNIT_ASSERT_EQUAL(eValue, text::WrapTextMode_THROUGHT);
468 :
469 : /*
470 : * 5th problem: anchor type of the second textbox was wrong.
471 : *
472 : * xray ThisComponent.DrawPage(1).AnchorType ' was 1, should be 4
473 : */
474 1 : xPropertySet.set(getShape(2), uno::UNO_QUERY);
475 : text::TextContentAnchorType eAnchorType;
476 1 : xPropertySet->getPropertyValue("AnchorType") >>= eAnchorType;
477 1 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eAnchorType);
478 :
479 : // 6th problem: xray ThisComponent.DrawPage(2).AnchorType ' was 2, should be 4
480 1 : xPropertySet.set(getShape(3), uno::UNO_QUERY);
481 1 : xPropertySet->getPropertyValue("AnchorType") >>= eAnchorType;
482 2 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eAnchorType);
483 1 : }
484 :
485 9 : DECLARE_OOXMLIMPORT_TEST(testN766481, "n766481.docx")
486 : {
487 : /*
488 : * The problem was that we had an additional paragraph before the pagebreak.
489 : *
490 : * oParas = ThisComponent.Text.createEnumeration
491 : * oPara = oParas.nextElement
492 : * oPara = oParas.nextElement
493 : * xray oParas.hasMoreElements ' should be false
494 : */
495 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
496 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
497 2 : uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
498 3 : for (int i = 0; i < 2; ++i)
499 2 : xParaEnum->nextElement();
500 2 : CPPUNIT_ASSERT_EQUAL(sal_False, xParaEnum->hasMoreElements());
501 1 : }
502 :
503 9 : DECLARE_OOXMLIMPORT_TEST(testN766487, "n766487.docx")
504 : {
505 : /*
506 : * The problem was that 1) the font size of the first para was too large 2) numbering had no first-line-indent.
507 : *
508 : * oParas = ThisComponent.Text.createEnumeration
509 : * oPara = oParas.nextElement
510 : * oRuns = oPara.createEnumeration
511 : * oRun = oRuns.nextElement
512 : * xray oRun.CharHeight ' 12, was larger
513 : * oPara = oParas.nextElement
514 : * xray oPara.ParaFirstLineIndent ' -635, was 0
515 : */
516 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
517 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
518 2 : uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
519 :
520 2 : uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
521 2 : uno::Reference<container::XEnumeration> xRunEnum(xRunEnumAccess->createEnumeration());
522 2 : uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
523 1 : float fValue = 0;
524 1 : xPropertySet->getPropertyValue("CharHeight") >>= fValue;
525 1 : CPPUNIT_ASSERT_EQUAL(12.f, fValue);
526 :
527 1 : xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY);
528 1 : sal_Int32 nValue = 0;
529 1 : xPropertySet->getPropertyValue("ParaFirstLineIndent") >>= nValue;
530 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(-360)), nValue);
531 1 : }
532 :
533 9 : DECLARE_OOXMLIMPORT_TEST(testN693238, "n693238.docx")
534 : {
535 : /*
536 : * The problem was that a continuous section break at the end of the doc caused the margins to be ignored.
537 : *
538 : * xray ThisComponent.StyleFamilies.PageStyles.Default.LeftMargin ' was 2000, should be 635
539 : */
540 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
541 1 : sal_Int32 nValue = 0;
542 1 : xPropertySet->getPropertyValue("LeftMargin") >>= nValue;
543 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(635), nValue);
544 1 : }
545 :
546 9 : DECLARE_OOXMLIMPORT_TEST(testNumbering1, "numbering1.docx")
547 : {
548 : /* <w:numPr> in the paragraph itself was overridden by <w:numpr> introduced by the paragraph's <w:pStyle>
549 : enum = ThisComponent.Text.createEnumeration
550 : para = enum.NextElement
551 : xray para.NumberingStyleName
552 : numberingstyle = ThisComponent.NumberingRules.getByIndex(6)
553 : xray numberingstyle.name - should match name above
554 : numbering = numberingstyle.getByIndex(0)
555 : xray numbering(11) - should be 4, arabic
556 : note that the indexes may get off as the implementation evolves, C++ code seaches in loops
557 : */
558 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
559 2 : uno::Reference< text::XTextRange > paragraph(getParagraph( 1, "Text1." ));
560 2 : OUString numberingStyleName = getProperty< OUString >( paragraph, "NumberingStyleName" );
561 2 : uno::Reference<text::XNumberingRulesSupplier> xNumberingRulesSupplier(mxComponent, uno::UNO_QUERY);
562 2 : uno::Reference<container::XIndexAccess> numberingRules(xNumberingRulesSupplier->getNumberingRules(), uno::UNO_QUERY);
563 2 : uno::Reference<container::XIndexAccess> numberingRule;
564 16 : for( int i = 0;
565 8 : i < numberingRules->getCount();
566 : ++i )
567 : {
568 8 : OUString name = getProperty< OUString >( numberingRules->getByIndex( i ), "Name" );
569 8 : if( name == numberingStyleName )
570 : {
571 1 : numberingRule.set( numberingRules->getByIndex( i ), uno::UNO_QUERY );
572 1 : break;
573 : }
574 7 : }
575 1 : CPPUNIT_ASSERT( numberingRule.is());
576 2 : uno::Sequence< beans::PropertyValue > numbering;
577 1 : numberingRule->getByIndex( 0 ) >>= numbering;
578 1 : sal_Int16 numberingType = style::NumberingType::NUMBER_NONE;
579 24 : for( int i = 0;
580 12 : i < numbering.getLength();
581 : ++i )
582 : {
583 12 : if( numbering[ i ].Name == "NumberingType" )
584 : {
585 1 : numbering[ i ].Value >>= numberingType;
586 1 : break;
587 : }
588 : }
589 2 : CPPUNIT_ASSERT_EQUAL( style::NumberingType::ARABIC, numberingType );
590 1 : }
591 :
592 9 : DECLARE_OOXMLIMPORT_TEST(testBnc773061, "bnc773061.docx")
593 : {
594 1 : uno::Reference< text::XTextRange > paragraph = getParagraph( 1 );
595 2 : uno::Reference< text::XTextRange > normal = getRun( paragraph, 1, "Normal " );
596 2 : uno::Reference< text::XTextRange > raised = getRun( paragraph, 2, "Raised" );
597 2 : uno::Reference< text::XTextRange > lowered = getRun( paragraph, 4, "Lowered" );
598 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), getProperty< sal_Int32 >( normal, "CharEscapement" ));
599 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 50 ), getProperty< sal_Int32 >( raised, "CharEscapement" ));
600 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32( -25 ), getProperty< sal_Int32 >( lowered, "CharEscapement" ));
601 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 100 ), getProperty< sal_Int32 >( normal, "CharEscapementHeight" ));
602 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 100 ), getProperty< sal_Int32 >( raised, "CharEscapementHeight" ));
603 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32( 100 ), getProperty< sal_Int32 >( lowered, "CharEscapementHeight" ));
604 1 : }
605 :
606 9 : DECLARE_OOXMLIMPORT_TEST(testAllGapsWord, "all_gaps_word.docx")
607 : {
608 1 : BorderTest borderTest;
609 1 : borderTest.testTheBorders(mxComponent);
610 1 : }
611 :
612 9 : DECLARE_OOXMLIMPORT_TEST(testN775906, "n775906.docx")
613 : {
614 : /*
615 : * The problem was that right margin (via direct formatting) erased the left/first margin (inherited from numbering style).
616 : *
617 : * oParas = ThisComponent.Text.createEnumeration
618 : * oPara = oParas.nextElement
619 : * xray oPara.ParaFirstLineIndent ' was 0
620 : * xray oPara.ParaLeftMargin ' was 0
621 : */
622 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-635), getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent"));
623 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1905), getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
624 1 : }
625 :
626 9 : DECLARE_OOXMLIMPORT_TEST(testN775899, "n775899.docx")
627 : {
628 : /*
629 : * The problem was that a floating table wasn't imported as a frame, then it contained fake paragraphs.
630 : *
631 : * ThisComponent.TextFrames.Count ' was 0
632 : * oParas = ThisComponent.TextFrames(0).Text.createEnumeration
633 : * oPara = oParas.nextElement
634 : * oPara.supportsService("com.sun.star.text.TextTable") 'was a fake paragraph
635 : * oParas.hasMoreElements 'was true
636 : */
637 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
638 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
639 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
640 :
641 2 : uno::Reference<text::XTextFrame> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
642 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xFrame->getText(), uno::UNO_QUERY);
643 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
644 2 : uno::Reference<lang::XServiceInfo> xServiceInfo(xParaEnum->nextElement(), uno::UNO_QUERY);
645 1 : CPPUNIT_ASSERT_EQUAL(sal_True, xServiceInfo->supportsService("com.sun.star.text.TextTable"));
646 :
647 2 : CPPUNIT_ASSERT_EQUAL(sal_False, xParaEnum->hasMoreElements());
648 1 : }
649 :
650 9 : DECLARE_OOXMLIMPORT_TEST(testN777345, "n777345.docx")
651 : {
652 : #if !defined(MACOSX)
653 : // The problem was that v:imagedata inside v:rect was ignored.
654 1 : uno::Reference<document::XEmbeddedObjectSupplier2> xSupplier(getShape(1), uno::UNO_QUERY);
655 2 : uno::Reference<graphic::XGraphic> xGraphic = xSupplier->getReplacementGraphic();
656 2 : Graphic aGraphic(xGraphic);
657 : // If this changes later, feel free to update it, but make sure it's not
658 : // the checksum of a white/transparent placeholder rectangle.
659 2 : CPPUNIT_ASSERT_EQUAL(sal_uLong(2529763117U), aGraphic.GetChecksum());
660 : #endif
661 1 : }
662 :
663 9 : DECLARE_OOXMLIMPORT_TEST(testN777337, "n777337.docx")
664 : {
665 : /*
666 : * The problem was that the top and bottom margin on the first page was only 0.1cm instead of 1.7cm.
667 : *
668 : * oFirst = ThisComponent.StyleFamilies.PageStyles.getByName("First Page")
669 : * xray oFirst.TopMargin
670 : * xray oFirst.BottomMargin
671 : */
672 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("First Page"), uno::UNO_QUERY);
673 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1702), getProperty<sal_Int32>(xPropertySet, "TopMargin"));
674 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1702), getProperty<sal_Int32>(xPropertySet, "BottomMargin"));
675 1 : }
676 :
677 9 : DECLARE_OOXMLIMPORT_TEST(testN778836, "n778836.docx")
678 : {
679 : /*
680 : * The problem was that the paragraph inherited margins from the numbering
681 : * and parent paragraph styles and the result was incorrect.
682 : */
683 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1270), getProperty<sal_Int32>(getParagraph(0), "ParaRightMargin"));
684 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3810), getProperty<sal_Int32>(getParagraph(0), "ParaLeftMargin"));
685 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-635), getProperty<sal_Int32>(getParagraph(0), "ParaFirstLineIndent"));
686 1 : }
687 :
688 9 : DECLARE_OOXMLIMPORT_TEST(testN778140, "n778140.docx")
689 : {
690 : /*
691 : * The problem was that the paragraph top/bottom margins were incorrect due
692 : * to unhandled w:doNotUseHTMLParagraphAutoSpacing.
693 : */
694 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(176), getProperty<sal_Int32>(getParagraph(0), "ParaTopMargin"));
695 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(176), getProperty<sal_Int32>(getParagraph(0), "ParaBottomMargin"));
696 1 : }
697 :
698 9 : DECLARE_OOXMLIMPORT_TEST(testN778828, "n778828.docx")
699 : {
700 : /*
701 : * The problem was that a page break after a continuous section break caused
702 : * double page break on title page.
703 : */
704 1 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
705 2 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
706 2 : uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
707 1 : xCursor->jumpToLastPage();
708 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
709 1 : }
710 :
711 9 : DECLARE_OOXMLIMPORT_TEST(testInk, "ink.docx")
712 : {
713 : /*
714 : * The problem was that ~nothing was imported, except an empty CustomShape.
715 : *
716 : * xray ThisComponent.DrawPage(0).supportsService("com.sun.star.drawing.OpenBezierShape")
717 : */
718 1 : uno::Reference<lang::XServiceInfo> xServiceInfo(getShape(1), uno::UNO_QUERY);
719 1 : CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.drawing.OpenBezierShape"));
720 1 : }
721 :
722 9 : DECLARE_OOXMLIMPORT_TEST(testN779834, "n779834.docx")
723 : {
724 : // This document simply crashed the importer.
725 1 : }
726 :
727 9 : DECLARE_OOXMLIMPORT_TEST(testN779627, "n779627.docx")
728 : {
729 : /*
730 : * The problem was that the table left position was based on the tableCellMar left value
731 : * even for nested tables, while it shouldn't.
732 : */
733 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
734 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
735 2 : uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY);
736 2 : uno::Any aValue = xTableProperties->getPropertyValue("LeftMargin");
737 : sal_Int32 nLeftMargin;
738 1 : aValue >>= nLeftMargin;
739 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE( "Left margin shouldn't take tableCellMar into account in nested tables",
740 1 : sal_Int32(0), nLeftMargin);
741 :
742 : /*
743 : * Another problem tested with this document is that the roundrect is
744 : * centered vertically and horizontally.
745 : */
746 2 : uno::Reference<beans::XPropertySet> xShapeProperties( getShape(4), uno::UNO_QUERY );
747 2 : uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xShapeProperties, uno::UNO_QUERY);
748 : // If this goes wrong, probably the index of the shape is changed and the test should be adjusted.
749 1 : CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.RectangleShape"), xShapeDescriptor->getShapeType());
750 : sal_Int16 nValue;
751 1 : xShapeProperties->getPropertyValue("HoriOrient") >>= nValue;
752 1 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally", text::HoriOrientation::CENTER, nValue);
753 1 : xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
754 1 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally relatively to page", text::RelOrientation::PAGE_FRAME, nValue);
755 1 : xShapeProperties->getPropertyValue("VertOrient") >>= nValue;
756 1 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered vertically", text::VertOrientation::CENTER, nValue);
757 1 : xShapeProperties->getPropertyValue("VertOrientRelation") >>= nValue;
758 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered vertically relatively to page", text::RelOrientation::PAGE_FRAME, nValue);
759 1 : }
760 :
761 9 : DECLARE_OOXMLIMPORT_TEST(testFdo74357, "fdo74357.docx")
762 : {
763 : // Floating table wasn't converted to a textframe.
764 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
765 2 : uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
766 : // This was 0.
767 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
768 :
769 : // Bottom margin of the first paragraph was too large, causing a layout problem.
770 : // This was 494.
771 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(86), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
772 1 : }
773 :
774 9 : DECLARE_OOXMLIMPORT_TEST(testFdo55187, "fdo55187.docx")
775 : {
776 : // 0x010d was imported as a newline.
777 1 : getParagraph(1, OUString("lup\xc4\x8dka", 7, RTL_TEXTENCODING_UTF8));
778 1 : }
779 :
780 9 : DECLARE_OOXMLIMPORT_TEST(testN780563, "n780563.docx")
781 : {
782 : /*
783 : * Make sure we have the table in the fly frame created
784 : */
785 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
786 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
787 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount( ));
788 1 : }
789 :
790 9 : DECLARE_OOXMLIMPORT_TEST(testN780853, "n780853.docx")
791 : {
792 : /*
793 : * The problem was that the table was not imported.
794 : *
795 : * xray ThisComponent.TextTables.Count 'was 0
796 : */
797 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
798 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
799 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
800 1 : }
801 :
802 9 : DECLARE_OOXMLIMPORT_TEST(testN780843, "n780843.docx")
803 : {
804 : /*
805 : * The problem was that wrong footer was picked.
806 : *
807 : * oParas = ThisComponent.Text.createEnumeration
808 : * oPara = oParas.nextElement
809 : * oPara = oParas.nextElement
810 : * oPara = oParas.nextElement
811 : * sStyle = oPara.PageStyleName
812 : * oStyle = ThisComponent.StyleFamilies.PageStyles.getByName(sStyle)
813 : * xray oStyle.FooterText.String ' was "hidden footer"
814 : */
815 1 : uno::Reference< text::XTextRange > xPara = getParagraph(3);
816 2 : OUString aStyleName = getProperty<OUString>(xPara, "PageStyleName");
817 2 : uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(aStyleName), uno::UNO_QUERY);
818 2 : uno::Reference<text::XTextRange> xFooter = getProperty< uno::Reference<text::XTextRange> >(xPageStyle, "FooterText");
819 2 : CPPUNIT_ASSERT_EQUAL(OUString("shown footer"), xFooter->getString());
820 1 : }
821 :
822 9 : DECLARE_OOXMLIMPORT_TEST(testShadow, "imgshadow.docx")
823 : {
824 : /*
825 : * The problem was that drop shadows on inline images were not being
826 : * imported and applied.
827 : */
828 1 : uno::Reference<beans::XPropertySet> xPropertySet(getShape(2), uno::UNO_QUERY);
829 :
830 1 : table::ShadowFormat aShadow;
831 1 : xPropertySet->getPropertyValue("ShadowFormat") >>= aShadow;
832 1 : CPPUNIT_ASSERT(sal_Int32(aShadow.ShadowWidth) > 0);
833 1 : }
834 :
835 9 : DECLARE_OOXMLIMPORT_TEST(testN782061, "n782061.docx")
836 : {
837 : /*
838 : * The problem was that the character escapement in the second run was -58.
839 : */
840 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-9), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapement"));
841 1 : }
842 :
843 9 : DECLARE_OOXMLIMPORT_TEST(testN782345, "n782345.docx")
844 : {
845 : /*
846 : * The problem was that the page break was inserted before the 3rd para, instead of before the 2nd para.
847 : */
848 1 : CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
849 1 : }
850 :
851 9 : DECLARE_OOXMLIMPORT_TEST(testN779941, "n779941.docx")
852 : {
853 : /*
854 : * Make sure top/bottom margins of tables are set to 0 (problem was: bottom margin set to 0.35cm)
855 : */
856 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
857 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
858 2 : uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY);
859 : {
860 1 : uno::Any aValue = xTableProperties->getPropertyValue("TopMargin");
861 : sal_Int32 nTopMargin;
862 1 : aValue >>= nTopMargin;
863 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nTopMargin);
864 : }
865 : {
866 1 : uno::Any aValue = xTableProperties->getPropertyValue("BottomMargin");
867 : sal_Int32 nBottomMargin;
868 1 : aValue >>= nBottomMargin;
869 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nBottomMargin);
870 1 : }
871 1 : }
872 :
873 9 : DECLARE_OOXMLIMPORT_TEST(testN783638, "n783638.docx")
874 : {
875 : // The problem was that the margins of inline images were not zero.
876 1 : uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
877 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "LeftMargin"));
878 1 : }
879 :
880 9 : DECLARE_OOXMLIMPORT_TEST(testFdo52208, "fdo52208.docx")
881 : {
882 : // The problem was that the document had 2 pages instead of 1.
883 1 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
884 2 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
885 2 : uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
886 1 : xCursor->jumpToLastPage();
887 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage());
888 1 : }
889 :
890 9 : DECLARE_OOXMLIMPORT_TEST(testN785767, "n785767.docx")
891 : {
892 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
893 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
894 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
895 2 : uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
896 : // 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).
897 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);
898 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);
899 1 : }
900 :
901 9 : DECLARE_OOXMLIMPORT_TEST(testN773061, "n773061.docx")
902 : {
903 : // xray ThisComponent.TextFrames(0).LeftBorderDistance
904 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
905 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
906 2 : uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
907 1 : CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "LeftBorderDistance" ), sal_Int32( 0 ));
908 1 : CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "TopBorderDistance" ), sal_Int32( 0 ));
909 1 : CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "RightBorderDistance" ), sal_Int32( 0 ));
910 2 : CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "BottomBorderDistance" ), sal_Int32( 0 ));
911 1 : }
912 :
913 9 : DECLARE_OOXMLIMPORT_TEST(testN780645, "n780645.docx")
914 : {
915 : // The problem was that when the number of cells didn't match the grid, we
916 : // didn't take care of direct cell widths.
917 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
918 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
919 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
920 2 : uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
921 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(2135), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position); // was 1999
922 1 : }
923 :
924 9 : DECLARE_OOXMLIMPORT_TEST(testFineTableDash, "tableborder-finedash.docx")
925 : {
926 : // The problem was that finely dashed borders on tables were unsupported
927 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
928 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
929 2 : uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY);
930 1 : table::TableBorder2 aBorder;
931 1 : xTableProperties->getPropertyValue("TableBorder2") >>= aBorder;
932 2 : CPPUNIT_ASSERT_EQUAL(aBorder.RightLine.LineStyle, table::BorderLineStyle::FINE_DASHED);
933 1 : }
934 :
935 9 : DECLARE_OOXMLIMPORT_TEST(testN792778, "n792778.docx")
936 : {
937 : /*
938 : * The problem was that the importer didn't handle complex groupshapes with groupshapes, textboxes and graphics inside.
939 : *
940 : * xray ThisComponent.DrawPage.Count ' 1 groupshape
941 : * xray ThisComponent.DrawPage(0).Count ' 2 sub-groupshapes
942 : * xray ThisComponent.DrawPage(0).getByIndex(0).Count ' first sub-groupshape: 1 pic
943 : * xray ThisComponent.DrawPage(0).getByIndex(1).Count ' second sub-groupshape: 1 pic
944 : * xray ThisComponent.DrawPage(0).getByIndex(0).getByIndex(0).Position.Y ' 11684, the vertical position of the shapes were also wrong
945 : * xray ThisComponent.DrawPage(0).getByIndex(1).getByIndex(0).Position.Y ' 11684
946 : */
947 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
948 2 : uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
949 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
950 :
951 2 : uno::Reference<drawing::XShapes> xGroupShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
952 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupShape->getCount());
953 :
954 2 : uno::Reference<drawing::XShapes> xInnerGroupShape(xGroupShape->getByIndex(0), uno::UNO_QUERY);
955 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xInnerGroupShape->getCount());
956 :
957 2 : uno::Reference<drawing::XShape> xInnerShape(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY);
958 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(11684), xInnerShape->getPosition().Y);
959 :
960 1 : xInnerGroupShape.set(xGroupShape->getByIndex(1), uno::UNO_QUERY);
961 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xInnerGroupShape->getCount());
962 :
963 1 : xInnerShape.set(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY);
964 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(11684), xInnerShape->getPosition().Y);
965 1 : }
966 :
967 9 : DECLARE_OOXMLIMPORT_TEST(testGroupshapeLine, "groupshape-line.docx")
968 : {
969 : /*
970 : * Another fallout from n#792778, this time first the lines inside a
971 : * groupshape wasn't imported, then the fix broke the size/position of
972 : * non-groupshape lines. Test both here.
973 : *
974 : * xray ThisComponent.DrawPage.Count ' 2 shapes
975 : * xray ThisComponent.DrawPage(0).Position 'x: 2656, y: 339
976 : * xray ThisComponent.DrawPage(0).Size ' width: 3270, height: 1392
977 : * xray ThisComponent.DrawPage(1).getByIndex(0).Position 'x: 1272, y: 2286
978 : * xray ThisComponent.DrawPage(1).getByIndex(0).Size 'width: 10160, height: 0
979 : */
980 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
981 2 : uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
982 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDrawPage->getCount());
983 :
984 2 : uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
985 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2656), xShape->getPosition().X);
986 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(339), xShape->getPosition().Y);
987 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3270), xShape->getSize().Width);
988 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1392), xShape->getSize().Height);
989 :
990 2 : uno::Reference<drawing::XShapes> xGroupShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
991 1 : xShape.set(xGroupShape->getByIndex(0), uno::UNO_QUERY);
992 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1272), xShape->getPosition().X);
993 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2286), xShape->getPosition().Y);
994 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(10160), xShape->getSize().Width);
995 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape->getSize().Height);
996 1 : }
997 :
998 9 : DECLARE_OOXMLIMPORT_TEST(testGroupshapeChildRotation, "groupshape-child-rotation.docx")
999 : {
1000 : // The problem was that (due to incorrect handling of rotation inside
1001 : // groupshapes), the first child wasn't in the top left corner of an inline
1002 : // groupshape.
1003 1 : uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY);
1004 2 : uno::Reference<drawing::XShape> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY);
1005 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape->getPosition().X);
1006 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape->getPosition().Y);
1007 :
1008 : #if ! TEST_FONTS_MISSING
1009 1 : xShape.set(xGroupShape->getByIndex(4), uno::UNO_QUERY);
1010 : // This was 887, i.e. border distances were included in the height.
1011 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(686), xShape->getSize().Height);
1012 : #endif
1013 :
1014 2 : uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroupShape->getByIndex(5), uno::UNO_QUERY);
1015 : // This was com.sun.star.drawing.RectangleShape, all shape text in a single line.
1016 2 : CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.TextShape"), xShapeDescriptor->getShapeType());
1017 1 : }
1018 :
1019 9 : DECLARE_OOXMLIMPORT_TEST(testGroupshapeSmarttag, "groupshape-smarttag.docx")
1020 : {
1021 1 : uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY);
1022 2 : uno::Reference<text::XTextRange> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY);
1023 : // First run of shape text was missing due to the w:smartTag wrapper around it.
1024 1 : CPPUNIT_ASSERT_EQUAL(OUString("Box 2"), xShape->getString());
1025 :
1026 : // Font size of the shape text was 10.
1027 2 : CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(xShape->getText(), "CharHeight"));
1028 1 : }
1029 :
1030 9 : DECLARE_OOXMLIMPORT_TEST(testN793262, "n793262.docx")
1031 : {
1032 1 : uno::Reference<container::XEnumerationAccess> xHeaderText = getProperty< uno::Reference<container::XEnumerationAccess> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText");
1033 2 : uno::Reference<container::XEnumeration> xHeaderParagraphs(xHeaderText->createEnumeration());
1034 1 : xHeaderParagraphs->nextElement();
1035 : // Font size of the last empty paragraph in the header was ignored, this was 11.
1036 1 : CPPUNIT_ASSERT_EQUAL(16.f, getProperty<float>(xHeaderParagraphs->nextElement(), "CharHeight"));
1037 :
1038 2 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1039 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1040 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1041 : // Cell margins as direct formatting were ignored, this was 0.
1042 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(76), getProperty<sal_Int32>(xTable->getCellByName("A1"), "TopBorderDistance"));
1043 1 : }
1044 :
1045 9 : DECLARE_OOXMLIMPORT_TEST(testN793998, "n793998.docx")
1046 : {
1047 1 : sal_Int32 nTextPortion = parseDump("/root/page/body/txt/Text[1]", "nWidth").toInt32(); // Width of the first (text) portion
1048 1 : sal_Int32 nTabPortion = parseDump("/root/page/body/txt/Text[2]", "nWidth").toInt32(); // Width of the second (tab) portion
1049 1 : sal_Int32 nParagraph = parseDump("/root/page/body/txt/infos/bounds", "width").toInt32(); // Width of the paragraph
1050 1 : sal_Int32 nRightMargin = 3000;
1051 : // The problem was that the tab portion didn't ignore the right margin, so text + tab width wasn't larger than body (paragraph - right margin) width.
1052 1 : CPPUNIT_ASSERT(nTextPortion + nTabPortion > nParagraph - nRightMargin);
1053 1 : }
1054 :
1055 9 : DECLARE_OOXMLIMPORT_TEST(testN779642, "n779642.docx")
1056 : {
1057 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1058 :
1059 : // First problem: check that we have 2 tables, nesting caused the
1060 : // creation of outer one to fail
1061 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1062 1 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong number of imported tables", sal_Int32(2), xTables->getCount());
1063 :
1064 : // Second problem: check that the outer table is in a frame, at the bottom of the page
1065 2 : uno::Reference<text::XTextTable> xTextTable(xTextTablesSupplier->getTextTables()->getByName("Table2"), uno::UNO_QUERY);
1066 2 : uno::Reference<beans::XPropertySet> xAnchor(xTextTable->getAnchor(), uno::UNO_QUERY);
1067 2 : uno::Any aFrame = xAnchor->getPropertyValue("TextFrame");
1068 2 : uno::Reference<beans::XPropertySet> xFrame;
1069 1 : aFrame >>= xFrame;
1070 : sal_Int16 nValue;
1071 1 : xFrame->getPropertyValue("VertOrient") >>= nValue;
1072 1 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong vertical orientation", nValue, text::VertOrientation::BOTTOM);
1073 1 : xFrame->getPropertyValue("VertOrientRelation") >>= nValue;
1074 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong vertical orientation relation", nValue, text::RelOrientation::PAGE_PRINT_AREA);
1075 1 : }
1076 :
1077 9 : DECLARE_OOXMLIMPORT_TEST(testTbLrHeight, "tblr-height.docx")
1078 : {
1079 1 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1080 2 : uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1081 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1082 2 : uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
1083 : // btLr text direction was imported as MIN, it should be FIX to avoid incorrectly large height in case of too much content.
1084 2 : CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX, getProperty<sal_Int16>(xTableRows->getByIndex(0), "SizeType"));
1085 1 : }
1086 :
1087 9 : DECLARE_OOXMLIMPORT_TEST(testBnc865381, "bnc865381.docx")
1088 : {
1089 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1090 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1091 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1092 2 : uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
1093 : // Second row has a vertically merged cell, make sure size type is not FIX in that case (otherwise B2 is not readable).
1094 1 : CPPUNIT_ASSERT(text::SizeType::FIX != getProperty<sal_Int16>(xTableRows->getByIndex(1), "SizeType"));
1095 : // Explicit size of 41 mm100 was set, so the vertical text in A2 was not readable.
1096 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTableRows->getByIndex(1), "Height"));
1097 1 : }
1098 :
1099 9 : DECLARE_OOXMLIMPORT_TEST(testFdo53985, "fdo53985.docx")
1100 : {
1101 : // Unhandled excetion prevented import of the rest of the document.
1102 :
1103 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1104 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1105 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xTables->getCount()); // Only 4 tables were imported.
1106 1 : }
1107 :
1108 9 : DECLARE_OOXMLIMPORT_TEST(testFdo59638, "fdo59638.docx")
1109 : {
1110 : // The problem was that w:lvlOverride inside w:num was ignores by dmapper.
1111 :
1112 1 : uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
1113 1 : uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
1114 1 : uno::Sequence<beans::PropertyValue> aProps;
1115 1 : xLevels->getByIndex(0) >>= aProps; // 1st level
1116 :
1117 14 : for (int i = 0; i < aProps.getLength(); ++i)
1118 : {
1119 14 : const beans::PropertyValue& rProp = aProps[i];
1120 :
1121 14 : if (rProp.Name == "BulletChar")
1122 : {
1123 : // Was '*', should be 'o'.
1124 1 : CPPUNIT_ASSERT_EQUAL(OUString("\xEF\x82\xB7", 3, RTL_TEXTENCODING_UTF8), rProp.Value.get<OUString>());
1125 2 : return;
1126 : }
1127 : }
1128 0 : CPPUNIT_FAIL("no BulletChar property");
1129 : }
1130 :
1131 9 : DECLARE_OOXMLIMPORT_TEST(testFdo61343, "fdo61343.docx")
1132 : {
1133 : // The problem was that there were a groupshape in the doc, followed by an
1134 : // OLE object, and this lead to a crash.
1135 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1136 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1137 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
1138 1 : }
1139 :
1140 9 : DECLARE_OOXMLIMPORT_TEST(testToolsLineNumbering, "tools-line-numbering.docx")
1141 : {
1142 : /*
1143 : * Test the line numbering feature import (Tools->Line Numbering ...)
1144 : *
1145 : * xray ThisComponent.getLineNumberingProperties().IsOn == True
1146 : * xray ThisComponent.getLineNumberingProperties().CountEmptyLines == True
1147 : * xray ThisComponent.getLineNumberingProperties().NumberPosition == 0
1148 : * xray ThisComponent.getLineNumberingProperties().NumberingType == 4
1149 : * xray ThisComponent.getLineNumberingProperties().SeparatorInterval == 3
1150 : */
1151 :
1152 1 : sal_Bool bValue = sal_False;
1153 1 : sal_Int32 nValue = -1;
1154 :
1155 1 : uno::Reference< text::XTextDocument > xtextDocument(mxComponent, uno::UNO_QUERY);
1156 2 : uno::Reference< text::XLineNumberingProperties > xLineProperties( xtextDocument, uno::UNO_QUERY_THROW );
1157 2 : uno::Reference< beans::XPropertySet > xPropertySet = xLineProperties->getLineNumberingProperties();
1158 :
1159 1 : xPropertySet->getPropertyValue("IsOn") >>= bValue;
1160 1 : CPPUNIT_ASSERT_EQUAL(sal_True, bValue);
1161 :
1162 1 : xPropertySet->getPropertyValue("CountEmptyLines") >>= bValue;
1163 1 : CPPUNIT_ASSERT_EQUAL(sal_True, bValue);
1164 :
1165 1 : xPropertySet->getPropertyValue("NumberPosition") >>= nValue;
1166 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nValue);
1167 :
1168 1 : xPropertySet->getPropertyValue("NumberingType") >>= nValue;
1169 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(4), nValue);
1170 :
1171 1 : xPropertySet->getPropertyValue("SeparatorInterval") >>= nValue;
1172 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nValue);
1173 1 : }
1174 :
1175 9 : DECLARE_OOXMLIMPORT_TEST(testFdo60922, "fdo60922.docx")
1176 : {
1177 : // This was 0, not 100, due to wrong import of w:position w:val="0"
1178 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharEscapementHeight"));
1179 1 : }
1180 :
1181 9 : DECLARE_OOXMLIMPORT_TEST(testFdo59273, "fdo59273.docx")
1182 : {
1183 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1184 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1185 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1186 : // Was 115596 (i.e. 10 times wider than necessary), as w:tblW was missing and the importer didn't set it.
1187 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(12961), getProperty<sal_Int32>(xTextTable, "Width"));
1188 :
1189 2 : uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
1190 : // Was 9997, so the 4th column had ~zero width
1191 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(7498), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[2].Position);
1192 1 : }
1193 :
1194 9 : DECLARE_OOXMLIMPORT_TEST(testTableWidth, "table_width.docx")
1195 : {
1196 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1197 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1198 : // Relative width wasn't recognized during import.
1199 1 : CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xTables->getByIndex(0), "IsWidthRelative")));
1200 :
1201 2 : uno::Reference<text::XTextFramesSupplier> xFramesSupplier(mxComponent, uno::UNO_QUERY);
1202 2 : uno::Reference<container::XIndexAccess> xFrames(xFramesSupplier->getTextFrames(), uno::UNO_QUERY);
1203 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xFrames->getByIndex(0), "FrameWidthPercent"));
1204 1 : }
1205 :
1206 9 : DECLARE_OOXMLIMPORT_TEST(testConditionalstylesTbllook, "conditionalstyles-tbllook.docx")
1207 : {
1208 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1209 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1210 2 : uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1211 : // Background was -1.
1212 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x7F7F7F), getProperty<sal_Int32>(xTable->getCellByName("A1"), "BackColor"));
1213 1 : }
1214 :
1215 9 : DECLARE_OOXMLIMPORT_TEST(testFdo63685, "fdo63685.docx")
1216 : {
1217 : // Was 85697, i.e. original 114120 was converted to mm100 from twips, not from EMUs.
1218 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(getShape(1), "TopMargin"));
1219 1 : }
1220 :
1221 9 : DECLARE_OOXMLIMPORT_TEST(testN592908_Frame, "n592908-frame.docx")
1222 : {
1223 1 : uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
1224 : text::WrapTextMode eValue;
1225 1 : xPropertySet->getPropertyValue("Surround") >>= eValue;
1226 1 : CPPUNIT_ASSERT_EQUAL(eValue, text::WrapTextMode_PARALLEL);
1227 1 : }
1228 :
1229 9 : DECLARE_OOXMLIMPORT_TEST(testN592908_Picture, "n592908-picture.docx")
1230 : {
1231 1 : uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
1232 : text::WrapTextMode eValue;
1233 1 : xPropertySet->getPropertyValue("Surround") >>= eValue;
1234 1 : CPPUNIT_ASSERT_EQUAL(eValue, text::WrapTextMode_PARALLEL);
1235 1 : }
1236 :
1237 9 : DECLARE_OOXMLIMPORT_TEST(testN779630, "n779630.docx")
1238 : {
1239 : // First shape: date picker
1240 1 : uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
1241 2 : uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
1242 2 : uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
1243 1 : CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.DateField")));
1244 1 : CPPUNIT_ASSERT_EQUAL(OUString("date default text"), getProperty<OUString>(xPropertySet, "HelpText"));
1245 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(8), getProperty<sal_Int16>(xPropertySet, "DateFormat"));
1246 1 : CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xPropertySet, "Dropdown")));
1247 :
1248 : // Second shape: combo box
1249 1 : xControlShape.set(getShape(2), uno::UNO_QUERY);
1250 1 : xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
1251 1 : xServiceInfo.set(xPropertySet, uno::UNO_QUERY);
1252 1 : CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.ComboBox")));
1253 1 : CPPUNIT_ASSERT_EQUAL(OUString("dropdown default text"), getProperty<OUString>(xPropertySet, "DefaultText"));
1254 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty< uno::Sequence<OUString> >(xPropertySet, "StringItemList").getLength());
1255 2 : CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xPropertySet, "Dropdown")));
1256 1 : }
1257 :
1258 9 : DECLARE_OOXMLIMPORT_TEST(testIndentation, "indentation.docx")
1259 : {
1260 1 : uno::Reference<uno::XInterface> xParaLTRTitle(getParagraph( 1, "Title aligned"));
1261 2 : uno::Reference<uno::XInterface> xParaLTRNormal(getParagraph( 2, ""));
1262 :
1263 : // this will test the text direction for paragraphs
1264 1 : CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>( xParaLTRTitle, "WritingMode" ));
1265 2 : CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>( xParaLTRNormal, "WritingMode" ));
1266 1 : }
1267 :
1268 9 : DECLARE_OOXMLIMPORT_TEST(testPageBorderShadow, "page-border-shadow.docx")
1269 : {
1270 : // The problem was that in w:pgBorders, child elements had a w:shadow attribute, but that was ignored.
1271 1 : table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "ShadowFormat");
1272 1 : CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
1273 1 : CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
1274 : // w:sz="48" is in eights of a point, 1 pt is 20 twips.
1275 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(TWIP_TO_MM100(48/8*20)), aShadow.ShadowWidth);
1276 1 : }
1277 :
1278 9 : DECLARE_OOXMLIMPORT_TEST(testN816593, "n816593.docx")
1279 : {
1280 : // Two consecutive <w:tbl> without any paragraph in between, but with different tblpPr. In this
1281 : // case we need to have 2 different tables instead of 1
1282 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1283 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1284 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
1285 1 : }
1286 :
1287 9 : DECLARE_OOXMLIMPORT_TEST(testN820509, "n820509.docx")
1288 : {
1289 : // Design mode was enabled.
1290 1 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
1291 2 : uno::Reference<view::XFormLayerAccess> xFormLayerAccess(xModel->getCurrentController(), uno::UNO_QUERY);
1292 1 : CPPUNIT_ASSERT_EQUAL(false, bool(xFormLayerAccess->isFormDesignMode()));
1293 :
1294 : // M.d.yyyy date format was unhandled.
1295 2 : uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
1296 2 : uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
1297 2 : uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
1298 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(8), getProperty<sal_Int16>(xPropertySet, "DateFormat"));
1299 1 : }
1300 :
1301 9 : DECLARE_OOXMLIMPORT_TEST(testN820788, "n820788.docx")
1302 : {
1303 : // The problem was that AutoSize was not enabled for the text frame.
1304 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
1305 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
1306 2 : uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
1307 : // This was text::SizeType::FIX.
1308 2 : CPPUNIT_ASSERT_EQUAL(text::SizeType::MIN, getProperty<sal_Int16>(xFrame, "SizeType"));
1309 1 : }
1310 :
1311 9 : DECLARE_OOXMLIMPORT_TEST(testN820504, "n820504.docx")
1312 : {
1313 1 : uno::Reference<style::XStyleFamiliesSupplier> xFamiliesSupplier(mxComponent, uno::UNO_QUERY);
1314 2 : uno::Reference<container::XNameAccess> xFamiliesAccess(xFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
1315 2 : uno::Reference<container::XNameAccess> xStylesAccess(xFamiliesAccess->getByName("ParagraphStyles"), uno::UNO_QUERY);
1316 2 : uno::Reference<beans::XPropertySet> xStyle(xStylesAccess->getByName("Default Style"), uno::UNO_QUERY);
1317 : // The problem was that the CharColor was set to AUTO (-1) even if we have some default char color set
1318 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(4040635), getProperty<sal_Int32>(xStyle, "CharColor"));
1319 :
1320 : // Also, the groupshape was anchored at-page instead of at-character
1321 : // (that's incorrect as Word only supports at-character and as-character).
1322 2 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
1323 1 : }
1324 :
1325 9 : DECLARE_OOXMLIMPORT_TEST(testN830205, "n830205.docx")
1326 : {
1327 : // Previously import just crashed (due to infinite recursion).
1328 1 : getParagraph(1, "XXX");
1329 1 : }
1330 :
1331 9 : DECLARE_OOXMLIMPORT_TEST(testFdo43641, "fdo43641.docx")
1332 : {
1333 1 : uno::Reference<container::XIndexAccess> xGroupShape(getShape(1), uno::UNO_QUERY);
1334 2 : uno::Reference<drawing::XShape> xLine(xGroupShape->getByIndex(1), uno::UNO_QUERY);
1335 : // This was 2200, not 2579 in mm100, i.e. the size of the line shape was incorrect.
1336 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(EMU_TO_MM100(928694)), xLine->getSize().Width);
1337 1 : }
1338 :
1339 9 : DECLARE_OOXMLIMPORT_TEST(testTableAutoColumnFixedSize, "table-auto-column-fixed-size.docx")
1340 : {
1341 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1342 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1343 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1344 :
1345 : // Width was not recognized during import when table size was 'auto'
1346 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(3996)), getProperty<sal_Int32>(xTextTable, "Width"));
1347 1 : }
1348 :
1349 9 : DECLARE_OOXMLIMPORT_TEST(testFdo46361, "fdo46361.docx")
1350 : {
1351 1 : uno::Reference<container::XIndexAccess> xGroupShape(getShape(1), uno::UNO_QUERY);
1352 2 : uno::Reference<drawing::XShape> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY);
1353 : // This was CENTER.
1354 1 : CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xShape, "TextVerticalAdjust"));
1355 2 : uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
1356 2 : uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText);
1357 : // This was LEFT.
1358 1 : CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust")));
1359 : // This was black, not green.
1360 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x008000), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor"));
1361 : // \n char was missing due to unhandled w:br.
1362 1 : CPPUNIT_ASSERT_EQUAL(OUString("text\ntext"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY)->getString());
1363 : // \n chars were missing, due to unhandled multiple w:p tags.
1364 2 : CPPUNIT_ASSERT_EQUAL(OUString("text\ntext\n"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(2), uno::UNO_QUERY)->getString());
1365 1 : }
1366 :
1367 9 : DECLARE_OOXMLIMPORT_TEST(testFdo65632, "fdo65632.docx")
1368 : {
1369 : // The problem was that the footnote text had fake redline: only the body
1370 : // text has redline in fact.
1371 1 : uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
1372 2 : uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
1373 2 : uno::Reference<text::XText> xText(xFootnotes->getByIndex(0), uno::UNO_QUERY);
1374 : //uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText);
1375 2 : CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "TextPortionType"));
1376 1 : }
1377 :
1378 9 : DECLARE_OOXMLIMPORT_TEST(testFdo66474, "fdo66474.docx")
1379 : {
1380 : // The table width was too small, so the text in the second cell was unreadable: this was 1397.
1381 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1382 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1383 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(10492), getProperty<sal_Int32>(xTables->getByIndex(0), "Width"));
1384 1 : }
1385 :
1386 9 : DECLARE_OOXMLIMPORT_TEST(testGroupshapeRotation, "groupshape-rotation.docx")
1387 : {
1388 : // Rotation on groupshapes wasn't handled at all by the VML importer.
1389 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(315 * 100), getProperty<sal_Int32>(getShape(1), "RotateAngle"));
1390 1 : }
1391 :
1392 9 : DECLARE_OOXMLIMPORT_TEST(testBnc780044Spacing, "bnc780044_spacing.docx")
1393 : {
1394 : // The document has global w:spacing in styles.xml , and local w:spacing in w:pPr, which however
1395 : // only applied to text runs, not to as-character pictures. So the picture made the line higher.
1396 1 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
1397 2 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
1398 2 : uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
1399 1 : xCursor->jumpToLastPage();
1400 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage());
1401 1 : }
1402 :
1403 9 : DECLARE_OOXMLIMPORT_TEST(testTableAutoNested, "table-auto-nested.docx")
1404 : {
1405 : // This was 176, when compat option is not enabled, the auto paragraph bottom margin value was incorrect.
1406 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(494), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
1407 :
1408 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1409 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1410 : // This was 115596, i.e. the width of the outer table was too large.
1411 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(23051), getProperty<sal_Int32>(xTables->getByIndex(1), "Width"));
1412 1 : }
1413 :
1414 9 : DECLARE_OOXMLIMPORT_TEST(testTableStyleParprop, "table-style-parprop.docx")
1415 : {
1416 : // The problem was that w:spacing's w:after=0 (a paragraph property) wasn't imported from table style.
1417 1 : uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
1418 2 : uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1419 : // This was 353, the document default, i.e. paragraph property from table style had no effect.
1420 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
1421 1 : }
1422 :
1423 9 : DECLARE_OOXMLIMPORT_TEST(testTablePagebreak, "table-pagebreak.docx")
1424 : {
1425 : // Page break inside table: should be ignored (was style::BreakType_PAGE_BEFORE before).
1426 1 : CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, getProperty<style::BreakType>(getParagraphOrTable(2), "BreakType"));
1427 :
1428 : // This one is outside the table: should not be ignored.
1429 1 : CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, getProperty<style::BreakType>(getParagraph(3), "BreakType"));
1430 1 : }
1431 :
1432 9 : DECLARE_OOXMLIMPORT_TEST(testFdo68607, "fdo68607.docx")
1433 : {
1434 : // Bugdoc was 8 pages in Word, 1 in Writer due to pointlessly wrapping the
1435 : // table in a frame. Exact layout may depend on fonts available, etc. --
1436 : // but at least make sure that our table spans over multiple pages now.
1437 1 : CPPUNIT_ASSERT(getPages() > 1);
1438 1 : }
1439 :
1440 9 : DECLARE_OOXMLIMPORT_TEST(testVmlTextVerticalAdjust, "vml-text-vertical-adjust.docx")
1441 : {
1442 1 : uno::Reference<drawing::XShapes> xOuterGroupShape(getShape(1), uno::UNO_QUERY);
1443 2 : uno::Reference<drawing::XShapes> xInnerGroupShape(xOuterGroupShape->getByIndex(0), uno::UNO_QUERY);
1444 2 : uno::Reference<drawing::XShape> xShape(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY);
1445 : // Was CENTER.
1446 2 : CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xShape, "TextVerticalAdjust"));
1447 1 : }
1448 :
1449 9 : DECLARE_OOXMLIMPORT_TEST(testGroupshapeSdt, "groupshape-sdt.docx")
1450 : {
1451 : // All problems here are due to the groupshape: we have a drawinglayer rectangle, not a writer textframe.
1452 1 : uno::Reference<drawing::XShapes> xOuterGroupShape(getShape(1), uno::UNO_QUERY);
1453 2 : uno::Reference<drawing::XShapes> xInnerGroupShape(xOuterGroupShape->getByIndex(0), uno::UNO_QUERY);
1454 2 : uno::Reference<text::XTextRange> xShape(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY);
1455 : // Border distances were not implemented, this was 0.
1456 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1905), getProperty<sal_Int32>(xShape, "TextUpperDistance"));
1457 : // Sdt field result wasn't imported, this was "".
1458 1 : CPPUNIT_ASSERT_EQUAL(OUString("placeholder text"), xShape->getString());
1459 : // w:spacing was ignored in oox, this was 0.
1460 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(20), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xShape->getText()), 1), "CharKerning"));
1461 1 : }
1462 :
1463 9 : DECLARE_OOXMLIMPORT_TEST(testDefaultSectBreakCols, "default-sect-break-cols.docx")
1464 : {
1465 : // First problem: the first two paragraphs did not have their own text section, so the whole document had two columns.
1466 1 : uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First."), "TextSection");
1467 1 : CPPUNIT_ASSERT(xTextSection.is());
1468 2 : uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
1469 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
1470 :
1471 : // Second problem: the page style had two columns, while it shouldn't have any.
1472 2 : uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
1473 1 : xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xPageStyle, "TextColumns");
1474 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
1475 : // Check for the Column Separator value.It should be FALSE as the document does not contain separator line.
1476 1 : bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn");
1477 2 : CPPUNIT_ASSERT(!bValue) ;
1478 1 : }
1479 :
1480 9 : DECLARE_OOXMLIMPORT_TEST(testFdo69636, "fdo69636.docx")
1481 : {
1482 : // The problem was that the mso-layout-flow-alt:bottom-to-top VML shape property wasn't handled for sw text frames.
1483 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
1484 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
1485 2 : uno::Reference<text::XTextRange> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
1486 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(900), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xFrame->getText()), 1), "CharRotation"));
1487 1 : }
1488 :
1489 9 : DECLARE_OOXMLIMPORT_TEST(testChartProp, "chart-prop.docx")
1490 : {
1491 : // The problem was that chart was not getting parsed in writer module.
1492 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1493 2 : uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1494 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
1495 :
1496 2 : uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
1497 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(15240), getProperty<sal_Int32>(xPropertySet, "Width"));
1498 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(8890), getProperty<sal_Int32>(xPropertySet, "Height"));
1499 1 : }
1500 :
1501 2 : void lcl_countTextFrames(com::sun::star::uno::Reference< lang::XComponent >& xComponent,
1502 : sal_Int32 nExpected )
1503 : {
1504 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(xComponent, uno::UNO_QUERY);
1505 4 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
1506 4 : CPPUNIT_ASSERT_EQUAL( nExpected, xIndexAccess->getCount());
1507 2 : }
1508 :
1509 9 : DECLARE_OOXMLIMPORT_TEST(testBnc779620, "bnc779620.docx")
1510 : {
1511 : // The problem was that the floating table was imported as a non-floating one.
1512 1 : lcl_countTextFrames( mxComponent, 1 );
1513 1 : }
1514 :
1515 9 : DECLARE_OOXMLIMPORT_TEST(testfdo76583, "fdo76583.docx")
1516 : {
1517 : // The problem was that the floating table was imported as a non-floating one.
1518 : // floating tables are imported as text frames, therefore the document should
1519 : // exactly 1 text frame.
1520 1 : lcl_countTextFrames( mxComponent, 1 );
1521 1 : }
1522 :
1523 9 : DECLARE_OOXMLIMPORT_TEST(testFdo43093, "fdo43093.docx")
1524 : {
1525 : // The problem was that the direction and alignment are not correct for RTL paragraphs.
1526 1 : uno::Reference<uno::XInterface> xParaRtlRight(getParagraph( 1, "Right and RTL in M$"));
1527 1 : sal_Int32 nRtlRight = getProperty< sal_Int32 >( xParaRtlRight, "ParaAdjust" );
1528 1 : sal_Int16 nRRDir = getProperty< sal_Int32 >( xParaRtlRight, "WritingMode" );
1529 :
1530 2 : uno::Reference<uno::XInterface> xParaRtlLeft(getParagraph( 2, "Left and RTL in M$"));
1531 1 : sal_Int32 nRtlLeft = getProperty< sal_Int32 >( xParaRtlLeft, "ParaAdjust" );
1532 1 : sal_Int16 nRLDir = getProperty< sal_Int32 >( xParaRtlLeft, "WritingMode" );
1533 :
1534 2 : uno::Reference<uno::XInterface> xParaLtrRight(getParagraph( 3, "Right and LTR in M$"));
1535 1 : sal_Int32 nLtrRight = getProperty< sal_Int32 >( xParaLtrRight, "ParaAdjust" );
1536 1 : sal_Int16 nLRDir = getProperty< sal_Int32 >( xParaLtrRight, "WritingMode" );
1537 :
1538 2 : uno::Reference<uno::XInterface> xParaLtrLeft(getParagraph( 4, "Left and LTR in M$"));
1539 1 : sal_Int32 nLtrLeft = getProperty< sal_Int32 >( xParaLtrLeft, "ParaAdjust" );
1540 1 : sal_Int16 nLLDir = getProperty< sal_Int32 >( xParaLtrLeft, "WritingMode" );
1541 :
1542 : // this will test the both the text direction and alignment for each paragraph
1543 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nRtlRight);
1544 1 : CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRRDir);
1545 :
1546 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nRtlLeft);
1547 1 : CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRLDir);
1548 :
1549 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nLtrRight);
1550 1 : CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir);
1551 :
1552 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLtrLeft);
1553 2 : CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir);
1554 1 : }
1555 :
1556 9 : DECLARE_OOXMLIMPORT_TEST(testSmartart, "smartart.docx")
1557 : {
1558 1 : uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
1559 2 : uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
1560 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1561 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1562 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc
1563 :
1564 2 : uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
1565 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xGroup->getCount()); // 3 rectangles and an arrow in the group
1566 :
1567 2 : uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(1), uno::UNO_QUERY);
1568 1 : sal_Int32 nValue(0);
1569 1 : xPropertySet->getPropertyValue("FillColor") >>= nValue;
1570 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), nValue); // If fill color is right, theme import is OK
1571 :
1572 2 : uno::Reference<text::XTextRange> xTextRange(xGroup->getByIndex(1), uno::UNO_QUERY);
1573 1 : CPPUNIT_ASSERT_EQUAL(OUString("Sample"), xTextRange->getString()); // Shape has text
1574 :
1575 2 : uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextRange->getText(), uno::UNO_QUERY);
1576 2 : uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
1577 1 : xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY);
1578 1 : xPropertySet->getPropertyValue("ParaAdjust") >>= nValue;
1579 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_CENTER), nValue); // Paragraph properties are imported
1580 1 : }
1581 :
1582 9 : DECLARE_OOXMLIMPORT_TEST(testMultiColumnSeparator, "multi-column-separator-with-line.docx")
1583 : {
1584 1 : uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First data."), "TextSection");
1585 1 : CPPUNIT_ASSERT(xTextSection.is());
1586 2 : uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
1587 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
1588 : // Check for the Column Separator value.It should be TRUE as the document contains separator line.
1589 1 : bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn");
1590 2 : CPPUNIT_ASSERT(bValue);
1591 1 : }
1592 :
1593 9 : DECLARE_OOXMLIMPORT_TEST(testFdo69548, "fdo69548.docx")
1594 : {
1595 : // The problem was that the last space in target URL was removed
1596 1 : CPPUNIT_ASSERT_EQUAL(OUString("#this is a bookmark"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL"));
1597 1 : }
1598 :
1599 9 : DECLARE_OOXMLIMPORT_TEST(testWpsOnly, "wps-only.docx")
1600 : {
1601 : // Document has wp:anchor, not wp:inline, so handle it accordingly.
1602 1 : uno::Reference<drawing::XShape> xShape = getShape(1);
1603 1 : text::TextContentAnchorType eValue = getProperty<text::TextContentAnchorType>(xShape, "AnchorType");
1604 1 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_PARAGRAPH, eValue);
1605 :
1606 : // Check position, it was 0. This is a shape, so use getPosition(), not a property.
1607 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(EMU_TO_MM100(671830)), xShape->getPosition().X);
1608 :
1609 : // Left margin was 0, instead of 114300 EMU's.
1610 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xShape, "LeftMargin"));
1611 : // Wrap type was PARALLEL.
1612 1 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(xShape, "Surround"));
1613 :
1614 : // This should be in front of text.
1615 1 : CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xShape, "Opaque")));
1616 : // And this should be behind the document.
1617 1 : CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(getShape(2), "Opaque")));
1618 1 : }
1619 :
1620 9 : DECLARE_OOXMLIMPORT_TEST(lineWpsOnly, "line-wps-only.docx")
1621 : {
1622 1 : uno::Reference<drawing::XShape> xShape = getShape(1);
1623 : // Check position, it was -7223 as it was set after the CustomShapeGeometry property.
1624 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(208), xShape->getPosition().X);
1625 1 : }
1626 :
1627 9 : DECLARE_OOXMLIMPORT_TEST(lineRotation, "line-rotation.docx")
1628 : {
1629 1 : uno::Reference<drawing::XShape> xShape = getShape(3);
1630 : // This was 5096: the line was shifted towards the bottom, so the end of
1631 : // the 3 different lines wasn't at the same point.
1632 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(4808), xShape->getPosition().Y);
1633 1 : }
1634 :
1635 9 : DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, "textbox-wps-only.docx")
1636 : {
1637 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
1638 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
1639 2 : uno::Reference<text::XTextRange> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
1640 1 : CPPUNIT_ASSERT_EQUAL(OUString("Hello world!"), xFrame->getString());
1641 : // Position wasn't horizontally centered.
1642 1 : CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(xFrame, "HoriOrient"));
1643 :
1644 : // Position was the default (hori center, vert top) for the textbox.
1645 1 : xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
1646 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2173), getProperty<sal_Int32>(xFrame, "HoriOrientPosition"));
1647 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2805), getProperty<sal_Int32>(xFrame, "VertOrientPosition"));
1648 1 : }
1649 :
1650 9 : DECLARE_OOXMLIMPORT_TEST(testWpgOnly, "wpg-only.docx")
1651 : {
1652 1 : uno::Reference<drawing::XShape> xShape = getShape(1);
1653 : // Check position, it was nearly 0. This is a shape, so use getPosition(), not a property.
1654 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(EMU_TO_MM100(548005)), xShape->getPosition().X);
1655 1 : }
1656 :
1657 9 : DECLARE_OOXMLIMPORT_TEST(testWpgNested, "wpg-nested.docx")
1658 : {
1659 1 : uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
1660 2 : uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(0), uno::UNO_QUERY);
1661 : // This was a com.sun.star.drawing.CustomShape, due to lack of handling of groupshapes inside groupshapes.
1662 1 : CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), xShapeDescriptor->getShapeType());
1663 : // This was text::RelOrientation::PAGE_FRAME, effectively placing the group shape on the left side of the page instead of the right one.
1664 2 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_RIGHT, getProperty<sal_Int16>(xGroup, "HoriOrientRelation"));
1665 1 : }
1666 :
1667 9 : DECLARE_OOXMLIMPORT_TEST(textboxWpgOnly, "textbox-wpg-only.docx")
1668 : {
1669 1 : uno::Reference<drawing::XShape> xShape = getShape(1);
1670 : // The relativeFrom attribute was ignored for groupshapes, i.e. these were text::RelOrientation::FRAME.
1671 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "HoriOrientRelation"));
1672 1 : CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "VertOrientRelation"));
1673 : // Make sure the shape is not in the background, as we have behindDoc="0" in the doc.
1674 1 : CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xShape, "Opaque")));
1675 :
1676 : // The 3 paragraphs on the rectangles inside the groupshape ended up in the
1677 : // body text, make sure we don't have multiple paragraphs there anymore.
1678 1 : CPPUNIT_ASSERT_EQUAL(1, getParagraphs()); // was 4
1679 :
1680 : // Character escapement was enabled by default, this was 58.
1681 2 : uno::Reference<container::XIndexAccess> xGroup(xShape, uno::UNO_QUERY);
1682 2 : uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY)->getText();
1683 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xText), 1), "CharEscapementHeight"));
1684 1 : }
1685 :
1686 9 : DECLARE_OOXMLIMPORT_TEST(testMceWpg, "mce-wpg.docx")
1687 : {
1688 : // Make sure that we read the primary branch, if wpg is requested as a feature.
1689 1 : uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
1690 2 : uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY)->getText();
1691 : // This was VML1.
1692 2 : getParagraphOfText(1, xText, "DML1");
1693 1 : }
1694 :
1695 9 : DECLARE_OOXMLIMPORT_TEST(testMceNested, "mce-nested.docx")
1696 : {
1697 : // Vertical position of the textbox was incorrect due to incorrect nested mce handling.
1698 1 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
1699 2 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
1700 2 : uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
1701 : // positionV's posOffset from the bugdoc, was 0.
1702 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(EMU_TO_MM100(2514600)), getProperty<sal_Int32>(xFrame, "VertOrientPosition"));
1703 : // This was -1 (default), make sure the background color is set.
1704 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), getProperty<sal_Int32>(xFrame, "BackColor"));
1705 :
1706 2 : uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(getShape(2), uno::UNO_QUERY);
1707 : // This was a com.sun.star.drawing.CustomShape, due to incorrect handling of wpg elements after a wps textbox.
1708 1 : CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), xShapeDescriptor->getShapeType());
1709 :
1710 : // Now check the top right textbox.
1711 2 : uno::Reference<container::XIndexAccess> xGroup(getShape(2), uno::UNO_QUERY);
1712 2 : uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
1713 2 : uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText, "[Year]");
1714 1 : CPPUNIT_ASSERT_EQUAL(48.f, getProperty<float>(getRun(xParagraph, 1), "CharHeight"));
1715 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor"));
1716 1 : CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xParagraph, 1), "CharWeight"));
1717 2 : CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM, getProperty<drawing::TextVerticalAdjust>(xGroup->getByIndex(1), "TextVerticalAdjust"));
1718 1 : }
1719 :
1720 9 : DECLARE_OOXMLIMPORT_TEST(testMissingPath, "missing-path.docx")
1721 : {
1722 1 : comphelper::SequenceAsHashMap aCustomShapeGeometry(getProperty<beans::PropertyValues>(getShape(1), "CustomShapeGeometry"));
1723 2 : comphelper::SequenceAsHashMap aPath(aCustomShapeGeometry["Path"].get<beans::PropertyValues>());
1724 2 : uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aCoordinates = aPath["Coordinates"].get< uno::Sequence<drawing::EnhancedCustomShapeParameterPair> >();
1725 : // This was 0, the coordinate list was empty.
1726 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(19), aCoordinates.getLength());
1727 1 : }
1728 :
1729 9 : DECLARE_OOXMLIMPORT_TEST(testFdo70457, "fdo70457.docx")
1730 : {
1731 : // The document contains a rotated bitmap
1732 : // It must be imported as a XShape object with the proper rotation value
1733 :
1734 : // Check: there is one shape in the doc
1735 1 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
1736 2 : uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
1737 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
1738 :
1739 : // Check: the angle of the shape is 45ยบ
1740 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(4500), getProperty<sal_Int32>(getShape(1), "RotateAngle"));
1741 1 : }
1742 :
1743 9 : DECLARE_OOXMLIMPORT_TEST(testLOCrash,"file_crash.docx")
1744 : {
1745 : //The problem was libreoffice crash while opening the file.
1746 1 : getParagraph(1,"Contents");
1747 1 : }
1748 :
1749 9 : DECLARE_OOXMLIMPORT_TEST(testFdo72560, "fdo72560.docx")
1750 : {
1751 : // The problem was libreoffice confuse when there RTL default style for paragraph
1752 1 : uno::Reference<uno::XInterface> xParaLeftRTL(getParagraph( 1, "RTL LEFT"));
1753 2 : uno::Reference<uno::XInterface> xParaRightLTR(getParagraph( 2, "LTR RIGHT"));
1754 :
1755 : // this will test the text direction and alignment for paragraphs
1756 1 : CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>( xParaLeftRTL, "WritingMode" ));
1757 1 : CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), getProperty< sal_Int32 >( xParaLeftRTL, "ParaAdjust" ));
1758 :
1759 1 : CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>( xParaRightLTR, "WritingMode" ));
1760 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), getProperty< sal_Int32 >( xParaRightLTR, "ParaAdjust" ));
1761 1 : }
1762 :
1763 9 : DECLARE_OOXMLIMPORT_TEST(testRPrChangeClosed, "rprchange_closed.docx")
1764 : {
1765 : // Redline defined by rPrChanged wasn't removed.
1766 : // First paragraph has an rPrChange element, make sure it doesn't appear in the second paragraph.
1767 1 : CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(getParagraph(2), 1), "RedlineType"));
1768 1 : }
1769 :
1770 9 : DECLARE_OOXMLIMPORT_TEST(testFdo65090, "fdo65090.docx")
1771 : {
1772 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1773 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1774 2 : uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
1775 2 : uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
1776 : // The first row had two cells, instead of a single horizontally merged one.
1777 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength());
1778 1 : }
1779 :
1780 9 : DECLARE_OOXMLIMPORT_TEST(testFdo69649, "fdo69649.docx")
1781 : {
1782 : // The DOCX containing the Table of Contents was not imported with correct page nos
1783 1 : uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
1784 2 : uno::Reference<container::XIndexAccess> xIndexes(xIndexSupplier->getDocumentIndexes( ), uno::UNO_QUERY);
1785 2 : uno::Reference<text::XDocumentIndex> xTOCIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
1786 2 : uno::Reference<text::XTextRange> xTextRange(xTOCIndex->getAnchor(), uno::UNO_QUERY);
1787 2 : uno::Reference<text::XText> xText(xTextRange->getText( ), uno::UNO_QUERY);
1788 2 : uno::Reference<text::XTextCursor> xTextCursor(xText->createTextCursor( ), uno::UNO_QUERY);
1789 1 : xTextCursor->gotoRange(xTextRange->getStart(),false);
1790 1 : xTextCursor->gotoRange(xTextRange->getEnd(),true);
1791 2 : OUString xTocString(xTextCursor->getString());
1792 1 : xTocString = xTocString.copy(256);
1793 2 : CPPUNIT_ASSERT(xTocString.startsWithIgnoreAsciiCase( "Heading 15.1:\t15" ) );
1794 1 : }
1795 :
1796 9 : DECLARE_OOXMLIMPORT_TEST(testFdo73389,"fdo73389.docx")
1797 : {
1798 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1799 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1800 : // This was 9340, i.e. the width of the inner table was too large.
1801 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2842), getProperty<sal_Int32>(xTables->getByIndex(0), "Width"));
1802 1 : }
1803 :
1804 9 : DECLARE_OOXMLIMPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx")
1805 : {
1806 1 : uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY);
1807 : // The text in the groupshape was missing due to the w:sdt and w:sdtContent wrapper around it.
1808 1 : CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY)->getString());
1809 1 : }
1810 :
1811 9 : DECLARE_OOXMLIMPORT_TEST(testDmlCharheightDefault, "dml-charheight-default.docx")
1812 : {
1813 1 : uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
1814 2 : uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY);
1815 : // This was 16: the first run of the second para incorrectly inherited the char height of the first para.
1816 2 : CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(getRun(getParagraphOfText(2, xShape->getText()), 1), "CharHeight"));
1817 1 : }
1818 :
1819 9 : DECLARE_OOXMLIMPORT_TEST(testGroupshapeRelsize, "groupshape-relsize.docx")
1820 : {
1821 : // This was 43760, i.e. the height of the groupshape was larger than the page height, which is obviously incorrect.
1822 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(EMU_TO_MM100(9142730)), getShape(1)->getSize().Height);
1823 1 : }
1824 :
1825 9 : DECLARE_OOXMLIMPORT_TEST(testOleAnchor, "ole-anchor.docx")
1826 : {
1827 : // This was AS_CHARACTER, even if the VML style explicitly contains "position:absolute".
1828 1 : CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
1829 : // This was DYNAMIC, even if the default is THROUGHT and there is no w10:wrap element in the bugdoc.
1830 1 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(getShape(1), "Surround"));
1831 1 : }
1832 :
1833 9 : DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeCapitalization, "dml-groupshape-capitalization.docx")
1834 : {
1835 : // Capitalization inside a group shape was not imported
1836 1 : uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
1837 2 : uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
1838 : // 2nd line is written with uppercase letters
1839 1 : CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE, getProperty<sal_Int16>(getRun(getParagraphOfText(2, xText), 1), "CharCaseMap"));
1840 : // 3rd line has no capitalization
1841 1 : CPPUNIT_ASSERT_EQUAL(style::CaseMap::NONE, getProperty<sal_Int16>(getRun(getParagraphOfText(3, xText), 1), "CharCaseMap"));
1842 : // 4th line has written with small capitals
1843 1 : CPPUNIT_ASSERT_EQUAL(style::CaseMap::SMALLCAPS, getProperty<sal_Int16>(getRun(getParagraphOfText(4, xText), 1), "CharCaseMap"));
1844 : // 5th line has no capitalization
1845 2 : CPPUNIT_ASSERT_EQUAL(style::CaseMap::NONE, getProperty<sal_Int16>(getRun(getParagraphOfText(5, xText), 1), "CharCaseMap"));
1846 1 : }
1847 :
1848 9 : DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeParaAdjust, "dml-groupshape-paraadjust.docx")
1849 : {
1850 : // Paragraph adjustment inside a group shape was not imported
1851 1 : uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
1852 2 : uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
1853 : // 2nd line is adjusted to the right
1854 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getRun(getParagraphOfText(2, xText), 1), "ParaAdjust"));
1855 : // 3rd line has no adjustment
1856 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(3, xText), 1), "ParaAdjust"));
1857 : // 4th line is adjusted to center
1858 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), getProperty<sal_Int16>(getRun(getParagraphOfText(4, xText), 1), "ParaAdjust"));
1859 : // 5th line has no adjustment
1860 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(5, xText), 1), "ParaAdjust"));
1861 : // 6th line is justified
1862 1 : CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_BLOCK), getProperty<sal_Int16>(getRun(getParagraphOfText(6, xText), 1), "ParaAdjust"));
1863 : // 7th line has no adjustment
1864 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(7, xText), 1), "ParaAdjust"));
1865 1 : }
1866 :
1867 9 : DECLARE_OOXMLIMPORT_TEST(testPictureWithSchemeColor, "picture-with-schemecolor.docx")
1868 : {
1869 : // At the start of the document, a picture which has a color specified with a color scheme, lost
1870 : // it's color during import.
1871 1 : uno::Reference<beans::XPropertySet> xImage(getShape(1), uno::UNO_QUERY);
1872 2 : uno::Reference<graphic::XGraphic> xGraphic = getProperty<uno::Reference<graphic::XGraphic> >(xImage, "Graphic");
1873 2 : uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
1874 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(341), xBitmap->getSize().Width );
1875 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(181), xBitmap->getSize().Height );
1876 :
1877 : // Check some bits of the bitmap which change when color is imported.
1878 2 : const uno::Sequence< sal_Int8 > aDIB = xBitmap->getDIB();
1879 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int8>(-91), aDIB[54] );
1880 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int8>(110), aDIB[55] );
1881 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int8>(49), aDIB[56] );
1882 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int8>(-36), aDIB[96] );
1883 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int8>(-57), aDIB[97] );
1884 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int8>(-80), aDIB[98] );
1885 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int8>(-91), aDIB[135] );
1886 1 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int8>(110), aDIB[136] );
1887 2 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int8>(49), aDIB[137] );
1888 1 : }
1889 :
1890 9 : DECLARE_OOXMLIMPORT_TEST(testFdo69656, "Table_cell_auto_width_fdo69656.docx")
1891 : {
1892 1 : uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1893 2 : uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
1894 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(8154), getProperty<sal_Int32>(xTables->getByIndex(0), "Width"));
1895 1 : }
1896 :
1897 9 : DECLARE_OOXMLIMPORT_TEST(testFloatingTablesAnchor, "floating-tables-anchor.docx")
1898 : {
1899 : // Problem was one of the two text frames was anchored to the other text frame
1900 : // Both frames should be anchored to the paragraph with the text "Anchor point"
1901 1 : uno::Reference<text::XTextContent> xTextContent(getShape(1), uno::UNO_QUERY);
1902 2 : uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
1903 2 : uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY);
1904 1 : CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
1905 :
1906 1 : xTextContent.set(getShape(2), uno::UNO_QUERY);
1907 1 : xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY);
1908 1 : xText.set(xRange->getText(), uno::UNO_QUERY);
1909 2 : CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
1910 1 : }
1911 :
1912 9 : DECLARE_OOXMLIMPORT_TEST(testAnnotationFormatting, "annotation-formatting.docx")
1913 : {
1914 1 : uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(2), 2), "TextField");
1915 2 : uno::Reference<text::XText> xText = getProperty< uno::Reference<text::XText> >(xTextField, "TextRange");
1916 : // Make sure we test the right annotation.
1917 2 : uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText, "days");
1918 : // Formatting was lost: the second text portion was NONE, not SINGLE.
1919 2 : CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<sal_Int16>(getRun(xParagraph, 1), "CharUnderline"));
1920 1 : }
1921 :
1922 9 : DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeRunFonts, "dml-groupshape-runfonts.docx")
1923 : {
1924 : // Fonts defined by w:rFonts was not imported and so the font specified by a:fontRef was used.
1925 1 : uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
1926 2 : uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
1927 2 : uno::Reference<text::XTextRange> xRun = getRun(getParagraphOfText(1, xText),1);
1928 1 : CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun, "CharFontName"));
1929 1 : CPPUNIT_ASSERT_EQUAL(OUString("Arial Unicode MS"), getProperty<OUString>(xRun, "CharFontNameComplex"));
1930 2 : CPPUNIT_ASSERT_EQUAL(OUString("MS Mincho"), getProperty<OUString>(xRun, "CharFontNameAsian"));
1931 1 : }
1932 :
1933 9 : DECLARE_OOXMLIMPORT_TEST(testStrict, "strict.docx")
1934 : {
1935 1 : uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
1936 : // This was only 127, pt suffix was ignored, so this got parsed as twips instead of points.
1937 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(72 * 20)), getProperty<sal_Int32>(xPageStyle, "BottomMargin"));
1938 : // This was only 1397, same issue
1939 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(792 * 20)), getProperty<sal_Int32>(xPageStyle, "Height"));
1940 : // Text was missing, due to not handling the strict namespaces.
1941 1 : getParagraph(1, "Hello world!");
1942 :
1943 : // Header in the document caused a crash on import.
1944 2 : uno::Reference<text::XText> xHeaderText(xPageStyle->getPropertyValue("HeaderText"), uno::UNO_QUERY);
1945 1 : getParagraphOfText(1, xHeaderText, "This is a header.");
1946 :
1947 : // Picture was missing.
1948 2 : uno::Reference<lang::XServiceInfo> xServiceInfo(getShape(1), uno::UNO_QUERY);
1949 1 : CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextGraphicObject"));
1950 :
1951 : // SmartArt was missing.
1952 1 : xServiceInfo.set(getShape(2), uno::UNO_QUERY);
1953 1 : CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"));
1954 :
1955 : // Chart was missing.
1956 1 : xServiceInfo.set(getShape(3), uno::UNO_QUERY);
1957 1 : CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextEmbeddedObject"));
1958 :
1959 : // Math was missing.
1960 1 : xServiceInfo.set(getShape(4), uno::UNO_QUERY);
1961 2 : CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextEmbeddedObject"));
1962 1 : }
1963 :
1964 9 : DECLARE_OOXMLIMPORT_TEST(testStrictLockedcanvas, "strict-lockedcanvas.docx")
1965 : {
1966 : // locked canvas shape was missing.
1967 1 : getShape(1);
1968 1 : }
1969 :
1970 9 : DECLARE_OOXMLIMPORT_TEST(testSmartartStrict, "strict-smartart.docx")
1971 : {
1972 1 : uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
1973 : // This was 0, SmartArt was visually missing.
1974 1 : CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xGroup->getCount()); // 3 ellipses + 3 arrows
1975 1 : }
1976 :
1977 9 : DECLARE_OOXMLIMPORT_TEST(testLibreOfficeHang, "frame-wrap-auto.docx")
1978 : {
1979 : // fdo#72775
1980 : // This was text::WrapTextMode_NONE.
1981 1 : CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_DYNAMIC, getProperty<text::WrapTextMode>(getShape(1), "Surround"));
1982 1 : }
1983 :
1984 9 : DECLARE_OOXMLIMPORT_TEST(testI124106, "i124106.docx")
1985 : {
1986 : // This was 2.
1987 1 : CPPUNIT_ASSERT_EQUAL(1, getPages());
1988 1 : }
1989 :
1990 9 : DECLARE_OOXMLIMPORT_TEST(testLargeTwips, "large-twips.docx" )
1991 : {
1992 : // cp#1000043: MSO seems to ignore large twips values, we didn't, which resulted in different
1993 : // layout of broken documents (text not visible in this specific document).
1994 1 : OUString width = parseDump( "/root/page/body/tab/row[1]/cell[1]/txt/infos/bounds", "width" );
1995 1 : CPPUNIT_ASSERT( width.toInt32() > 0 );
1996 1 : }
1997 :
1998 9 : DECLARE_OOXMLIMPORT_TEST(testNegativeCellMarginTwips, "negative-cell-margin-twips.docx" )
1999 : {
2000 : // Sligtly related to cp#1000043, the twips value was negative, which wrapped around somewhere,
2001 : // while MSO seems to ignore that as well.
2002 1 : OUString width = parseDump( "/root/page/body/tab/row[1]/cell[1]/txt/infos/bounds", "width" );
2003 1 : CPPUNIT_ASSERT( width.toInt32() > 0 );
2004 1 : }
2005 :
2006 9 : DECLARE_OOXMLIMPORT_TEST(testFdo38414, "fdo38414.docx" )
2007 : {
2008 : // The cells in the last (4th) column were merged properly and so the result didn't have the same height.
2009 1 : OUString height3 = parseDump("/root/page/body/tab/row[1]/cell[3]/infos/bounds", "height" );
2010 2 : OUString height4 = parseDump("/root/page/body/tab/row[1]/cell[4]/infos/bounds", "height" );
2011 2 : CPPUNIT_ASSERT_EQUAL( height3, height4 );
2012 1 : }
2013 :
2014 9 : DECLARE_OOXMLIMPORT_TEST(testFdo74401, "fdo74401.docx")
2015 : {
2016 1 : uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY);
2017 2 : uno::Reference<drawing::XShapeDescriptor> xShape(xGroupShape->getByIndex(1), uno::UNO_QUERY);
2018 : // The triangle (second child) was a TextShape before, so it was shown as a rectangle.
2019 2 : CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), xShape->getShapeType());
2020 1 : }
2021 :
2022 : #endif
2023 :
2024 4 : CPPUNIT_PLUGIN_IMPLEMENT();
2025 :
2026 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|