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