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