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 <swmodeltestbase.hxx>
10 :
11 : #include <com/sun/star/awt/XBitmap.hpp>
12 : #include <com/sun/star/graphic/XGraphic.hpp>
13 : #include <com/sun/star/table/BorderLine2.hpp>
14 : #include <com/sun/star/table/TableBorder.hpp>
15 : #include <com/sun/star/table/TableBorder2.hpp>
16 : #include <com/sun/star/text/XDependentTextField.hpp>
17 : #include <com/sun/star/text/XTextFramesSupplier.hpp>
18 : #include <com/sun/star/text/XTextTablesSupplier.hpp>
19 : #include <com/sun/star/table/ShadowFormat.hpp>
20 :
21 : #include <vcl/svapp.hxx>
22 :
23 : #include <bordertest.hxx>
24 :
25 : #define convertTwipToMm100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
26 :
27 56 : class Test : public SwModelTestBase
28 : {
29 : public:
30 56 : Test() : SwModelTestBase("/sw/qa/extras/ww8import/data/", "MS Word 97")
31 : {
32 56 : }
33 : };
34 :
35 : #define DECLARE_WW8IMPORT_TEST(TestName, filename) DECLARE_SW_IMPORT_TEST(TestName, filename, Test)
36 :
37 18 : DECLARE_WW8IMPORT_TEST(testFloatingTableSectionMargins, "floating-table-section-margins.doc")
38 : {
39 2 : sal_Int32 pageLeft = parseDump("/root/page[2]/infos/bounds", "left").toInt32();
40 2 : sal_Int32 pageWidth = parseDump("/root/page[2]/infos/bounds", "width").toInt32();
41 2 : sal_Int32 tableLeft = parseDump("/root/page[2]/body/column/body/section/column/body/txt[2]/anchored/fly/tab/infos/bounds", "left").toInt32();
42 2 : sal_Int32 tableWidth = parseDump("/root/page[2]/body/column/body/section/column/body/txt[2]/anchored/fly/tab/infos/bounds", "width").toInt32();
43 2 : CPPUNIT_ASSERT( pageWidth > 0 );
44 2 : CPPUNIT_ASSERT( tableWidth > 0 );
45 : // The table's resulting position should be roughly centered.
46 2 : CPPUNIT_ASSERT( abs(( pageLeft + pageWidth / 2 ) - ( tableLeft + tableWidth / 2 )) < 20 );
47 2 : }
48 :
49 18 : DECLARE_WW8IMPORT_TEST(testN757910, "n757910.doc")
50 : {
51 : // The internal margin was larger than 0.28cm
52 2 : uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
53 4 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
54 4 : uno::Reference<beans::XPropertySet> xPropertySet(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
55 2 : sal_Int32 nValue = 0;
56 2 : xPropertySet->getPropertyValue("LeftBorderDistance") >>= nValue;
57 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(280), nValue);
58 :
59 : // The border width was zero
60 2 : table::BorderLine2 aBorder;
61 2 : xPropertySet->getPropertyValue("LeftBorder") >>= aBorder;
62 4 : CPPUNIT_ASSERT(aBorder.LineWidth > 0);
63 2 : }
64 :
65 18 : DECLARE_WW8IMPORT_TEST(testN760294, "n760294.doc")
66 : {
67 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
68 4 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
69 4 : uno::Reference<beans::XPropertySet> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
70 2 : table::TableBorder aTableBorder;
71 2 : xTable->getPropertyValue("TableBorder") >>= aTableBorder;
72 2 : CPPUNIT_ASSERT_EQUAL(aTableBorder.TopLine.InnerLineWidth, aTableBorder.TopLine.OuterLineWidth);
73 4 : CPPUNIT_ASSERT_EQUAL(aTableBorder.TopLine.InnerLineWidth, aTableBorder.TopLine.LineDistance);
74 2 : }
75 :
76 18 : DECLARE_WW8IMPORT_TEST(testN750255, "n750255.doc")
77 : {
78 : /*
79 : Column break without columns on the page is a page break, so check those paragraphs
80 : are on page 2 (page style 'Convert 1') and page 3 (page style 'Convert 2')
81 : enum = ThisComponent.Text.createEnumeration
82 : enum.nextElement
83 : para1 = enum.nextElement
84 : xray para1.String
85 : xray para1.PageStyleName
86 : para2 = enum.nextElement
87 : xray para2.String
88 : xray para2.PageStyleName
89 : */
90 2 : uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
91 4 : uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
92 : // list of paragraphs
93 4 : uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
94 : // go to 1st paragraph
95 2 : (void) paraEnum->nextElement();
96 : // get the 2nd and 3rd paragraph
97 4 : uno::Reference<uno::XInterface> paragraph1(paraEnum->nextElement(), uno::UNO_QUERY);
98 4 : uno::Reference<uno::XInterface> paragraph2(paraEnum->nextElement(), uno::UNO_QUERY);
99 4 : uno::Reference<text::XTextRange> text1(paragraph1, uno::UNO_QUERY);
100 4 : uno::Reference<text::XTextRange> text2(paragraph2, uno::UNO_QUERY);
101 2 : CPPUNIT_ASSERT_EQUAL( OUString( "one" ), text1->getString());
102 2 : CPPUNIT_ASSERT_EQUAL( OUString( "two" ), text2->getString());
103 4 : uno::Reference<beans::XPropertySet> paragraphProperties1(paragraph1, uno::UNO_QUERY);
104 4 : uno::Reference<beans::XPropertySet> paragraphProperties2(paragraph2, uno::UNO_QUERY);
105 4 : OUString pageStyle1, pageStyle2;
106 2 : paragraphProperties1->getPropertyValue( "PageStyleName" ) >>= pageStyle1;
107 2 : paragraphProperties2->getPropertyValue( "PageStyleName" ) >>= pageStyle2;
108 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Convert 1" ), pageStyle1 );
109 4 : CPPUNIT_ASSERT_EQUAL( OUString( "Convert 2" ), pageStyle2 );
110 :
111 2 : }
112 :
113 18 : DECLARE_WW8IMPORT_TEST(testN652364, "n652364.doc")
114 : {
115 : /*
116 : Related to 750255 above, column break with columns on the page however should be a column break.
117 : enum = ThisComponent.Text.createEnumeration
118 : enum.nextElement
119 : para1 = enum.nextElement
120 : xray para1.String
121 : xray para1.PageStyleName
122 : enum.nextElement
123 : para2 = enum.nextElement
124 : xray para2.String
125 : xray para2.PageStyleName
126 : */
127 2 : uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
128 4 : uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
129 : // list of paragraphs
130 4 : uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
131 : // get the 2nd and 4th paragraph
132 2 : (void) paraEnum->nextElement();
133 4 : uno::Reference<uno::XInterface> paragraph1(paraEnum->nextElement(), uno::UNO_QUERY);
134 2 : (void) paraEnum->nextElement();
135 4 : uno::Reference<uno::XInterface> paragraph2(paraEnum->nextElement(), uno::UNO_QUERY);
136 4 : uno::Reference<text::XTextRange> text1(paragraph1, uno::UNO_QUERY);
137 4 : uno::Reference<text::XTextRange> text2(paragraph2, uno::UNO_QUERY);
138 2 : CPPUNIT_ASSERT_EQUAL( OUString( "text1" ), text1->getString());
139 2 : CPPUNIT_ASSERT_EQUAL( OUString( "text2" ), text2->getString());
140 4 : uno::Reference<beans::XPropertySet> paragraphProperties1(paragraph1, uno::UNO_QUERY);
141 4 : uno::Reference<beans::XPropertySet> paragraphProperties2(paragraph2, uno::UNO_QUERY);
142 4 : OUString pageStyle1, pageStyle2;
143 2 : paragraphProperties1->getPropertyValue( "PageStyleName" ) >>= pageStyle1;
144 2 : paragraphProperties2->getPropertyValue( "PageStyleName" ) >>= pageStyle2;
145 : // "Standard" is the style for the first page (2nd is "Convert 1").
146 2 : CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle1 );
147 4 : CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle2 );
148 2 : }
149 :
150 18 : DECLARE_WW8IMPORT_TEST(testN757118, "n757118.doc")
151 : {
152 : /*
153 : Two pairs of horizontal rules (one absolute width, one relative width)
154 : have the same width (full page width, half page width).
155 : xray ThisComponent.DrawPage.getByIndex(0).BoundRect
156 : */
157 2 : uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
158 4 : uno::Reference<drawing::XShape> rule1 = getShape(1), rule2 = getShape(2), rule3 = getShape(3), rule4 = getShape(4);
159 4 : uno::Reference<beans::XPropertySet> ruleProperties1(rule1, uno::UNO_QUERY);
160 4 : uno::Reference<beans::XPropertySet> ruleProperties2(rule2, uno::UNO_QUERY);
161 4 : uno::Reference<beans::XPropertySet> ruleProperties3(rule3, uno::UNO_QUERY);
162 4 : uno::Reference<beans::XPropertySet> ruleProperties4(rule4, uno::UNO_QUERY);
163 2 : awt::Rectangle boundRect1, boundRect2, boundRect3, boundRect4;
164 2 : ruleProperties1->getPropertyValue( "BoundRect" ) >>= boundRect1;
165 2 : ruleProperties2->getPropertyValue( "BoundRect" ) >>= boundRect2;
166 2 : ruleProperties3->getPropertyValue( "BoundRect" ) >>= boundRect3;
167 2 : ruleProperties4->getPropertyValue( "BoundRect" ) >>= boundRect4;
168 : // compare, allow for < 5 differences because of rounding errors
169 2 : CPPUNIT_ASSERT( abs( boundRect1.Width - boundRect3.Width ) < 5 );
170 4 : CPPUNIT_ASSERT( abs( boundRect2.Width - boundRect4.Width ) < 5 );
171 2 : }
172 :
173 18 : DECLARE_WW8IMPORT_TEST(testN757905, "n757905.doc")
174 : {
175 : // The problem was that the paragraph had only a single fly
176 : // (as-character-anchored), and the height of that was smallar than the
177 : // paragraph height. When in Word-compat mode, we should take the max of
178 : // the two, not just the height of the fly.
179 :
180 2 : OUString aHeight = parseDump("/root/page/body/txt/infos/bounds", "height");
181 2 : CPPUNIT_ASSERT(sal_Int32(31) < aHeight.toInt32());
182 2 : }
183 :
184 18 : DECLARE_WW8IMPORT_TEST(testAllGapsWord, "all_gaps_word.doc")
185 : {
186 2 : BorderTest borderTest;
187 2 : borderTest.testTheBorders(mxComponent, true);
188 2 : }
189 :
190 18 : DECLARE_WW8IMPORT_TEST(testI120158, "i120158.doc")
191 : {
192 : // See https://issues.apache.org/ooo/show_bug.cgi?id=120158
193 2 : uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
194 4 : uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
195 : // list of paragraphs
196 4 : uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
197 : // get contents of 1st paragraph as text
198 4 : uno::Reference<uno::XInterface> paragraph0(paraEnum->nextElement(), uno::UNO_QUERY);
199 4 : uno::Reference<text::XTextRange> text0(paragraph0, uno::UNO_QUERY);
200 4 : OUString sFieldResult = text0->getString();
201 4 : CPPUNIT_ASSERT(sFieldResult.endsWith("AM") || sFieldResult.endsWith("PM"));
202 2 : }
203 :
204 18 : DECLARE_WW8IMPORT_TEST(testN816603, "n816603.doc")
205 : {
206 : // Bugdoc was 5 pages in Word, 1 in Writer due to pointlessly wrapping the
207 : // table in a frame. Exact layout may depend on fonts available, etc. --
208 : // but at least make sure that our table spans over multiple pages now.
209 2 : CPPUNIT_ASSERT(getPages() > 1);
210 2 : }
211 :
212 18 : DECLARE_WW8IMPORT_TEST(testN816593, "n816593.doc")
213 : {
214 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
215 4 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
216 : // Make sure that even if we import the two tables as non-floating, we
217 : // still consider them different, and not merge them.
218 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
219 2 : }
220 :
221 18 : DECLARE_WW8IMPORT_TEST(testPageBorder, "page-border.doc")
222 : {
223 : // Page border was missing (LineWidth was 0), due to wrong interpretation of pgbApplyTo.
224 2 : table::BorderLine2 aBorder = getProperty<table::BorderLine2>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "TopBorder");
225 2 : CPPUNIT_ASSERT_EQUAL(sal_uInt32(convertTwipToMm100(6 * 20)), aBorder.LineWidth);
226 2 : }
227 :
228 18 : DECLARE_WW8IMPORT_TEST(testN823651, "n823651.doc")
229 : {
230 : // Character height was 10pt instead of 7.5pt in the header.
231 2 : uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
232 4 : uno::Reference<text::XText> xText = getProperty< uno::Reference<text::XTextRange> >(xStyle, "HeaderTextFirst")->getText();
233 4 : CPPUNIT_ASSERT_EQUAL(7.5f, getProperty<float>(getParagraphOfText(1, xText), "CharHeight"));
234 2 : }
235 :
236 18 : DECLARE_WW8IMPORT_TEST(testFdo36868, "fdo36868.doc")
237 : {
238 2 : OUString aText = parseDump("/root/page/body/txt[3]/Special[@nType='POR_NUMBER']", "rText");
239 : // This was 1.1.
240 2 : CPPUNIT_ASSERT_EQUAL(OUString("2.1"), aText);
241 2 : }
242 :
243 18 : DECLARE_WW8IMPORT_TEST(testListNolevel, "list-nolevel.doc")
244 : {
245 : // Similar to fdo#36868, numbering portions had wrong values.
246 2 : OUString aText = parseDump("/root/page/body/txt[1]/Special[@nType='POR_NUMBER']", "rText");
247 : // POR_NUMBER was completely missing.
248 2 : CPPUNIT_ASSERT_EQUAL(OUString("1."), aText);
249 2 : }
250 :
251 18 : DECLARE_WW8IMPORT_TEST(testBnc821208, "bnc821208.doc")
252 : {
253 : // WW8Num1z0 earned a Symbol font, turning numbers into rectangles.
254 2 : uno::Reference<beans::XPropertyState> xPropertyState(getStyles("CharacterStyles")->getByName("WW8Num1z0"), uno::UNO_QUERY);
255 2 : beans::PropertyState ePropertyState = xPropertyState->getPropertyState("CharFontName");
256 : // This was beans::PropertyState_DIRECT_VALUE.
257 2 : CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE, ePropertyState);
258 :
259 : // Background of the numbering itself should have been the default, was yellow (0xffff00).
260 2 : CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xPropertyState, "CharBackColor"));
261 2 : }
262 :
263 18 : DECLARE_WW8IMPORT_TEST(testCp1000044, "cp1000044.doc")
264 : {
265 2 : uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
266 : // It wasn't possible to fill out this form.
267 2 : CPPUNIT_ASSERT_EQUAL(false, bool(xStorable->isReadonly()));
268 2 : }
269 :
270 18 : DECLARE_WW8IMPORT_TEST(testCp1000039, "cp1000039.doc")
271 : {
272 : // This was RTL_TEXTENCODING_SYMBOL, causing "1" rendered as a placeholder rectangle.
273 2 : CPPUNIT_ASSERT_EQUAL(sal_Int16(RTL_TEXTENCODING_DONTKNOW), getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharFontCharSet"));
274 2 : }
275 :
276 18 : DECLARE_WW8IMPORT_TEST(testBorderColours, "bordercolours.doc")
277 : {
278 : // The following 6 colours can only be represented with WW9 (Word 2000)
279 : // BRC (BoRder Control) structures. We can tell that they have been
280 : // exported/imported using a WW8 (Word '97) BRC if they instead come
281 : // through as one of the 16 colours listed at this link:
282 : // http://msdn.microsoft.com/en-us/library/dd773060.aspx
283 2 : table::BorderLine2 expectedTop(0xFA670C, 0, 53, 0, 1, 53);
284 2 : table::BorderLine2 expectedLeft(0xD99594, 0, 79, 0, 0, 79);
285 2 : table::BorderLine2 expectedRight(0xB2A1C7, 53, 53, 53, 3, 159);
286 2 : table::BorderLine2 expectedBottom(0xB6DDE8, 0, 106, 0, 14, 106);
287 2 : table::BorderLine2 expectedDashedRed(0xFA670C, 0, 53, 0, 2, 53);
288 2 : table::BorderLine2 expectedDoubleGreen(0xC2D69B, 26, 106, 26, 4, 159);
289 :
290 : // Paragraph border
291 : uno::Reference<text::XBookmarksSupplier> bookmarksSupplier(mxComponent,
292 2 : uno::UNO_QUERY);
293 : uno::Reference<container::XNameAccess> bookmarks(
294 4 : bookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
295 : uno::Reference<text::XTextContent> bookmark(
296 4 : bookmarks->getByName("ParagraphBorder"), uno::UNO_QUERY);
297 4 : uno::Reference<text::XTextRange> anchor(bookmark->getAnchor());
298 2 : table::BorderLine2 border;
299 2 : border = getProperty<table::BorderLine2>(anchor, "TopBorder");
300 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
301 2 : border = getProperty<table::BorderLine2>(anchor, "LeftBorder");
302 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
303 2 : border = getProperty<table::BorderLine2>(anchor, "RightBorder");
304 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
305 2 : border = getProperty<table::BorderLine2>(anchor, "BottomBorder");
306 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
307 :
308 : // Page border
309 4 : OUString pageStyleName = getProperty<OUString>(anchor, "PageStyleName");
310 : uno::Reference<style::XStyle> pageStyle(
311 4 : getStyles("PageStyles")->getByName(pageStyleName), uno::UNO_QUERY);
312 2 : border = getProperty<table::BorderLine2>(pageStyle, "TopBorder");
313 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
314 2 : border = getProperty<table::BorderLine2>(pageStyle, "LeftBorder");
315 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
316 2 : border = getProperty<table::BorderLine2>(pageStyle, "RightBorder");
317 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
318 2 : border = getProperty<table::BorderLine2>(pageStyle, "BottomBorder");
319 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
320 :
321 : // Character border
322 2 : bookmark.set(bookmarks->getByName("CharBorder"), uno::UNO_QUERY);
323 2 : anchor = bookmark->getAnchor();
324 2 : border = getProperty<table::BorderLine2>(anchor, "CharTopBorder");
325 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
326 2 : border = getProperty<table::BorderLine2>(anchor, "CharLeftBorder");
327 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
328 2 : border = getProperty<table::BorderLine2>(anchor, "CharRightBorder");
329 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
330 2 : border = getProperty<table::BorderLine2>(anchor, "CharBottomBorder");
331 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
332 :
333 : // Table border
334 : uno::Reference<text::XTextTablesSupplier> tablesSupplier(mxComponent,
335 4 : uno::UNO_QUERY);
336 : uno::Reference<container::XNameAccess> tables(
337 4 : tablesSupplier->getTextTables(), uno::UNO_QUERY);
338 : uno::Reference<text::XTextTable> table(
339 4 : tables->getByName("Table1"), uno::UNO_QUERY);
340 : table::TableBorder2 tableBorder = getProperty<table::TableBorder2>(
341 2 : table, "TableBorder2");
342 2 : CPPUNIT_ASSERT_EQUAL(expectedTop.Color, tableBorder.TopLine.Color);
343 2 : CPPUNIT_ASSERT_EQUAL(expectedLeft.Color, tableBorder.LeftLine.Color);
344 2 : CPPUNIT_ASSERT_EQUAL(expectedRight.Color, tableBorder.RightLine.Color);
345 2 : CPPUNIT_ASSERT_EQUAL(expectedBottom.Color, tableBorder.BottomLine.Color);
346 :
347 : // Table cells
348 : uno::Reference<table::XCell> cell(
349 4 : table->getCellByName("A2"), uno::UNO_QUERY);
350 2 : border = getProperty<table::BorderLine2>(cell, "TopBorder");
351 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
352 2 : border = getProperty<table::BorderLine2>(cell, "LeftBorder");
353 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
354 2 : border = getProperty<table::BorderLine2>(cell, "BottomBorder");
355 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
356 :
357 2 : cell.set(table->getCellByName("B2"), uno::UNO_QUERY);
358 2 : border = getProperty<table::BorderLine2>(cell, "TopBorder");
359 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
360 2 : border = getProperty<table::BorderLine2>(cell, "LeftBorder");
361 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
362 2 : border = getProperty<table::BorderLine2>(cell, "BottomBorder");
363 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
364 :
365 2 : cell.set(table->getCellByName("C2"), uno::UNO_QUERY);
366 2 : border = getProperty<table::BorderLine2>(cell, "TopBorder");
367 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
368 2 : border = getProperty<table::BorderLine2>(cell, "LeftBorder");
369 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedDashedRed, border);
370 2 : border = getProperty<table::BorderLine2>(cell, "RightBorder");
371 2 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
372 2 : border = getProperty<table::BorderLine2>(cell, "BottomBorder");
373 4 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
374 :
375 : // Picture border
376 : // (#if'd out as they are not yet imported with correct colours)
377 : #if 0
378 : bookmark.set(bookmarks->getByName("PictureBorder"),uno::UNO_QUERY);
379 : anchor = bookmark->getAnchor();
380 : border = getProperty<table::BorderLine2>(anchor, "TopBorder");
381 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
382 : border = getProperty<table::BorderLine2>(anchor, "LeftBorder");
383 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
384 : border = getProperty<table::BorderLine2>(anchor, "RightBorder");
385 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
386 : border = getProperty<table::BorderLine2>(anchor, "BottomBorder");
387 : CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
388 : #endif
389 2 : }
390 :
391 18 : DECLARE_WW8IMPORT_TEST(testMsoBrightnessContrast, "msobrightnesscontrast.doc")
392 : {
393 2 : uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
394 4 : uno::Reference<drawing::XShape> image(getShape(1), uno::UNO_QUERY);
395 4 : uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
396 4 : uno::Reference<graphic::XGraphic> graphic;
397 2 : imageProperties->getPropertyValue( "Graphic" ) >>= graphic;
398 4 : uno::Reference<awt::XBitmap> bitmap(graphic, uno::UNO_QUERY);
399 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32(58), bitmap->getSize().Width );
400 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32(320), bitmap->getSize().Height );
401 4 : const uno::Sequence< sal_Int8 > data = bitmap->getDIB(); // as .bmp data
402 2 : CPPUNIT_ASSERT_EQUAL( sal_Int32(20278), data.getLength());
403 2 : CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b0])); // -50 = 206 pixel value
404 2 : CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b1]));
405 2 : CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b2]));
406 2 : CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b3]));
407 4 : CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b4]));
408 2 : }
409 :
410 18 : DECLARE_WW8IMPORT_TEST(testBnc863018, "bnc863018.doc")
411 : {
412 : // The problem was that there should be some whitespace above the table,
413 : // but there wasn't.
414 2 : uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
415 4 : uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
416 4 : uno::Reference<beans::XPropertySet> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
417 : // This was 0.
418 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(5002), getProperty<sal_Int32>(xTable, "TopMargin"));
419 2 : }
420 :
421 18 : DECLARE_WW8IMPORT_TEST(testBnc875715, "bnc875715.doc")
422 : {
423 2 : uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
424 4 : uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
425 : // Was incorrectly set as -1270.
426 4 : CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xSections->getByIndex(0), "SectionLeftMargin"));
427 2 : }
428 :
429 18 : DECLARE_WW8IMPORT_TEST(testFdo77844, "fdo77844.doc")
430 : {
431 2 : uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles");
432 :
433 : // get a page cursor
434 4 : uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
435 : uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
436 4 : xModel->getCurrentController(), uno::UNO_QUERY);
437 : uno::Reference<text::XPageCursor> xCursor(
438 4 : xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
439 :
440 : // check that the first page has no header
441 2 : xCursor->jumpToFirstPage();
442 4 : OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
443 : uno::Reference<style::XStyle> pageStyle(
444 4 : pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
445 2 : bool headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
446 2 : CPPUNIT_ASSERT(!headerIsOn);
447 :
448 : // check that the second page has a header
449 2 : xCursor->jumpToPage(2);
450 2 : pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
451 : pageStyle.set(
452 2 : pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
453 2 : headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
454 2 : CPPUNIT_ASSERT(headerIsOn);
455 :
456 : // check that the third page has a header
457 2 : xCursor->jumpToPage(3);
458 2 : pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
459 : pageStyle.set(
460 2 : pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
461 2 : headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
462 4 : CPPUNIT_ASSERT(headerIsOn);
463 :
464 : // check that the fourth page has no header
465 : // (#if'd out as this is not yet imported correctly)
466 : #if 0
467 : xCursor->jumpToPage(4);
468 : pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
469 : pageStyle.set(
470 : pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
471 : headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
472 : CPPUNIT_ASSERT(!headerIsOn);
473 : #endif
474 2 : }
475 :
476 18 : DECLARE_WW8IMPORT_TEST(testFdp80333, "fdo80333.doc")
477 : {
478 : // Despite there is no character border, border shadow was imported
479 2 : uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
480 2 : const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
481 2 : CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
482 2 : }
483 :
484 18 : DECLARE_WW8IMPORT_TEST(testFdo81102, "fdo81102.doc")
485 : {
486 : // get page style at beginning of document
487 : uno::Reference<text::XTextDocument> textDocument(
488 2 : mxComponent, uno::UNO_QUERY);
489 : uno::Reference<text::XTextRange> start(
490 4 : textDocument->getText()->getStart(), uno::UNO_QUERY);
491 4 : OUString pageStyleName = getProperty<OUString>(start, "PageStyleName");
492 : uno::Reference<style::XStyle> pageStyle(
493 4 : getStyles("PageStyles")->getByName(pageStyleName), uno::UNO_QUERY);
494 :
495 : // check that left and right pages do not share the same header
496 2 : bool headerIsShared = getProperty<bool>(pageStyle, "HeaderIsShared");
497 4 : CPPUNIT_ASSERT(!headerIsShared);
498 2 : }
499 :
500 18 : DECLARE_WW8IMPORT_TEST(testFloatingTableSectionColumns, "floating-table-section-columns.doc")
501 : {
502 2 : OUString tableWidth = parseDump("/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds", "width");
503 : // table width was restricted by a column
504 2 : CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 );
505 2 : }
506 :
507 18 : DECLARE_WW8IMPORT_TEST(testBnc787942, "bnc787942.doc")
508 : {
509 : // The frame ended up on the second page instead of first.
510 2 : parseDump("/root/page[1]/body/txt[4]/anchored");
511 2 : }
512 :
513 18 : DECLARE_WW8IMPORT_TEST(testLayoutHanging, "fdo68967.doc")
514 : {
515 : // This must not hang in layout
516 2 : }
517 :
518 8 : CPPUNIT_PLUGIN_IMPLEMENT();
519 :
520 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|