1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include <swmodeltestbase.hxx>
14 #include <com/sun/star/awt/FontWeight.hpp>
15 #include <com/sun/star/drawing/FillStyle.hpp>
16 #include <com/sun/star/drawing/BitmapMode.hpp>
17 #include <com/sun/star/style/PageStyleLayout.hpp>
18 #include <com/sun/star/table/XCell.hpp>
19 #include <com/sun/star/table/BorderLine.hpp>
20 #include <com/sun/star/text/XTextSection.hpp>
21 #include <com/sun/star/text/XTextTable.hpp>
25 #include <swdtflvr.hxx>
31 typedef std::map
<OUString
, com::sun::star::uno::Sequence
< com::sun::star::table::BorderLine
> > AllBordersMap
;
32 typedef std::pair
<OUString
, com::sun::star::uno::Sequence
< com::sun::star::table::BorderLine
> > StringSequencePair
;
34 class Test
: public SwModelTestBase
37 Test() : SwModelTestBase("/sw/qa/extras/odfimport/data/", "writer8") {}
40 DECLARE_ODFIMPORT_TEST(testEmptySvgFamilyName
, "empty-svg-family-name.odt")
42 // .odt import did crash on the empty font list (which I think is valid according SVG spec)
45 DECLARE_ODFIMPORT_TEST(testHideAllSections
, "fdo53210.odt")
47 // This document has a section that is conditionally hidden, but has no empty paragraph after it.
48 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
49 uno::Reference
<container::XNameAccess
> xMasters
= xTextFieldsSupplier
->getTextFieldMasters();
50 // Set _CS_Allgemein to 0
51 uno::Reference
<beans::XPropertySet
> xMaster(xMasters
->getByName("com.sun.star.text.fieldmaster.User._CS_Allgemein"), uno::UNO_QUERY
);
52 xMaster
->setPropertyValue("Content", uno::makeAny(OUString("0")));
54 uno::Reference
<util::XRefreshable
>(xTextFieldsSupplier
->getTextFields(), uno::UNO_QUERY
)->refresh();
57 DECLARE_ODFIMPORT_TEST(testOdtBorders
, "borders_ooo33.odt")
60 uno::Sequence
< table::BorderLine
> tempSequence(4);
62 tempSequence
[0] = table::BorderLine(0, 2, 2, 35); // left
63 tempSequence
[1] = table::BorderLine(0, 2, 2, 35); // right
64 tempSequence
[2] = table::BorderLine(0, 2, 2, 35); // top
65 tempSequence
[3] = table::BorderLine(0, 2, 2, 35); // bottom
66 map
.insert(StringSequencePair(OUString("B2"), tempSequence
));
67 tempSequence
[0] = table::BorderLine(0, 0, 2, 0);
68 tempSequence
[1] = table::BorderLine(0, 0, 2, 0);
69 tempSequence
[2] = table::BorderLine(0, 0, 2, 0);
70 tempSequence
[3] = table::BorderLine(0, 0, 2, 0);
71 map
.insert(StringSequencePair(OUString("D2"), tempSequence
));
72 tempSequence
[0] = table::BorderLine(0, 2, 2, 88);
73 tempSequence
[1] = table::BorderLine(0, 2, 2, 88);
74 tempSequence
[2] = table::BorderLine(0, 2, 2, 88);
75 tempSequence
[3] = table::BorderLine(0, 2, 2, 88);
76 map
.insert(StringSequencePair(OUString("B4"), tempSequence
));
77 tempSequence
[0] = table::BorderLine(0, 0, 18, 0);
78 tempSequence
[1] = table::BorderLine(0, 0, 18, 0);
79 tempSequence
[2] = table::BorderLine(0, 0, 18, 0);
80 tempSequence
[3] = table::BorderLine(0, 0, 18, 0);
81 map
.insert(StringSequencePair(OUString("D4"), tempSequence
));
82 tempSequence
[0] = table::BorderLine(0, 35, 35, 35);
83 tempSequence
[1] = table::BorderLine(0, 35, 35, 35);
84 tempSequence
[2] = table::BorderLine(0, 35, 35, 35);
85 tempSequence
[3] = table::BorderLine(0, 35, 35, 35);
86 map
.insert(StringSequencePair(OUString("B6"), tempSequence
));
87 tempSequence
[0] = table::BorderLine(0, 0, 35, 0);
88 tempSequence
[1] = table::BorderLine(0, 0, 35, 0);
89 tempSequence
[2] = table::BorderLine(0, 0, 35, 0);
90 tempSequence
[3] = table::BorderLine(0, 0, 35, 0);
91 map
.insert(StringSequencePair(OUString("D6"), tempSequence
));
92 tempSequence
[0] = table::BorderLine(0, 88, 88, 88);
93 tempSequence
[1] = table::BorderLine(0, 88, 88, 88);
94 tempSequence
[2] = table::BorderLine(0, 88, 88, 88);
95 tempSequence
[3] = table::BorderLine(0, 88, 88, 88);
96 map
.insert(StringSequencePair(OUString("B8"), tempSequence
));
97 tempSequence
[0] = table::BorderLine(0, 0, 88, 0);
98 tempSequence
[1] = table::BorderLine(0, 0, 88, 0);
99 tempSequence
[2] = table::BorderLine(0, 0, 88, 0);
100 tempSequence
[3] = table::BorderLine(0, 0, 88, 0);
101 map
.insert(StringSequencePair(OUString("D8"), tempSequence
));
102 tempSequence
[0] = table::BorderLine(0, 2, 35, 88);
103 tempSequence
[1] = table::BorderLine(0, 2, 35, 88);
104 tempSequence
[2] = table::BorderLine(0, 2, 35, 88);
105 tempSequence
[3] = table::BorderLine(0, 2, 35, 88);
106 map
.insert(StringSequencePair(OUString("B10"), tempSequence
));
107 tempSequence
[0] = table::BorderLine(0, 0, 141, 0);
108 tempSequence
[1] = table::BorderLine(0, 0, 141, 0);
109 tempSequence
[2] = table::BorderLine(0, 0, 141, 0);
110 tempSequence
[3] = table::BorderLine(0, 0, 141, 0);
111 map
.insert(StringSequencePair(OUString("D10"), tempSequence
));
112 tempSequence
[0] = table::BorderLine(0, 2, 88, 88);
113 tempSequence
[1] = table::BorderLine(0, 2, 88, 88);
114 tempSequence
[2] = table::BorderLine(0, 2, 88, 88);
115 tempSequence
[3] = table::BorderLine(0, 2, 88, 88);
116 map
.insert(StringSequencePair(OUString("B12"), tempSequence
));
117 tempSequence
[0] = table::BorderLine(0, 0, 176, 0);
118 tempSequence
[1] = table::BorderLine(0, 0, 176, 0);
119 tempSequence
[2] = table::BorderLine(0, 0, 176, 0);
120 tempSequence
[3] = table::BorderLine(0, 0, 176, 0);
121 map
.insert(StringSequencePair(OUString("D12"), tempSequence
));
122 tempSequence
[0] = table::BorderLine(0, 2, 141, 88);
123 tempSequence
[1] = table::BorderLine(0, 2, 141, 88);
124 tempSequence
[2] = table::BorderLine(0, 2, 141, 88);
125 tempSequence
[3] = table::BorderLine(0, 2, 141, 88);
126 map
.insert(StringSequencePair(OUString("B14"), tempSequence
));
127 tempSequence
[0] = table::BorderLine(0, 35, 88, 88);
128 tempSequence
[1] = table::BorderLine(0, 35, 88, 88);
129 tempSequence
[2] = table::BorderLine(0, 35, 88, 88);
130 tempSequence
[3] = table::BorderLine(0, 35, 88, 88);
131 map
.insert(StringSequencePair(OUString("B16"), tempSequence
));
132 tempSequence
[0] = table::BorderLine(0, 88, 35, 35);
133 tempSequence
[1] = table::BorderLine(0, 88, 35, 35);
134 tempSequence
[2] = table::BorderLine(0, 88, 35, 35);
135 tempSequence
[3] = table::BorderLine(0, 88, 35, 35);
136 map
.insert(StringSequencePair(OUString("B18"), tempSequence
));
137 tempSequence
[0] = table::BorderLine(0, 88, 141, 88);
138 tempSequence
[1] = table::BorderLine(0, 88, 141, 88);
139 tempSequence
[2] = table::BorderLine(0, 88, 141, 88);
140 tempSequence
[3] = table::BorderLine(0, 88, 141, 88);
141 map
.insert(StringSequencePair(OUString("B20"), tempSequence
));
142 tempSequence
[0] = table::BorderLine(0, 141, 88, 88);
143 tempSequence
[1] = table::BorderLine(0, 141, 88, 88);
144 tempSequence
[2] = table::BorderLine(0, 141, 88, 88);
145 tempSequence
[3] = table::BorderLine(0, 141, 88, 88);
146 map
.insert(StringSequencePair(OUString("B22"), tempSequence
));
148 uno::Reference
<text::XTextDocument
> textDocument(mxComponent
, uno::UNO_QUERY
);
149 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(textDocument
->getText(), uno::UNO_QUERY
);
150 // list of paragraphs
151 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
154 uno::Reference
<lang::XServiceInfo
> xServiceInfo
;
155 if (xParaEnum
->nextElement() >>= xServiceInfo
)
157 if (xServiceInfo
->supportsService("com.sun.star.text.TextTable"))
159 uno::Reference
<text::XTextTable
> const xTextTable(xServiceInfo
, uno::UNO_QUERY_THROW
);
160 uno::Sequence
<OUString
> const cells
= xTextTable
->getCellNames();
161 sal_Int32 nLength
= cells
.getLength();
163 AllBordersMap::iterator it
;
166 for (sal_Int32 i
= 0; i
< nLength
; ++i
)
168 if(i
%10==6 || (i
%10==8 && i
<60)) // only B and D cells have borders, every 2 rows
170 uno::Reference
<table::XCell
> xCell
= xTextTable
->getCellByName(cells
[i
]);
171 uno::Reference
< beans::XPropertySet
> xPropSet(xCell
, uno::UNO_QUERY_THROW
);
172 it
= map
.find(cells
[i
]);
174 uno::Any aLeftBorder
= xPropSet
->getPropertyValue("LeftBorder");
175 table::BorderLine aLeftBorderLine
;
176 if (aLeftBorder
>>= aLeftBorderLine
)
178 sal_Int32 innerLineWidth
= aLeftBorderLine
.InnerLineWidth
;
179 sal_Int32 outerLineWidth
= aLeftBorderLine
.OuterLineWidth
;
180 sal_Int32 lineDistance
= aLeftBorderLine
.LineDistance
;
182 sal_Int32 perfectInner
= it
->second
[0].InnerLineWidth
;
183 sal_Int32 perfectOuter
= it
->second
[0].OuterLineWidth
;
184 sal_Int32 perfectDistance
= it
->second
[0].LineDistance
;
185 CPPUNIT_ASSERT_EQUAL(perfectInner
, innerLineWidth
);
186 CPPUNIT_ASSERT_EQUAL(perfectOuter
, outerLineWidth
);
187 CPPUNIT_ASSERT_EQUAL(perfectDistance
, lineDistance
);
190 uno::Any aRightBorder
= xPropSet
->getPropertyValue("RightBorder");
191 table::BorderLine aRightBorderLine
;
192 if (aRightBorder
>>= aRightBorderLine
)
194 sal_Int32 innerLineWidth
= aRightBorderLine
.InnerLineWidth
;
195 sal_Int32 outerLineWidth
= aRightBorderLine
.OuterLineWidth
;
196 sal_Int32 lineDistance
= aRightBorderLine
.LineDistance
;
198 sal_Int32 perfectInner
= it
->second
[1].InnerLineWidth
;
199 sal_Int32 perfectOuter
= it
->second
[1].OuterLineWidth
;
200 sal_Int32 perfectDistance
= it
->second
[1].LineDistance
;
201 CPPUNIT_ASSERT_EQUAL(perfectInner
, innerLineWidth
);
202 CPPUNIT_ASSERT_EQUAL(perfectOuter
, outerLineWidth
);
203 CPPUNIT_ASSERT_EQUAL(perfectDistance
, lineDistance
);
206 uno::Any aTopBorder
= xPropSet
->getPropertyValue("TopBorder");
207 table::BorderLine aTopBorderLine
;
208 if (aTopBorder
>>= aTopBorderLine
)
210 sal_Int32 innerLineWidth
= aTopBorderLine
.InnerLineWidth
;
211 sal_Int32 outerLineWidth
= aTopBorderLine
.OuterLineWidth
;
212 sal_Int32 lineDistance
= aTopBorderLine
.LineDistance
;
214 sal_Int32 perfectInner
= it
->second
[2].InnerLineWidth
;
215 sal_Int32 perfectOuter
= it
->second
[2].OuterLineWidth
;
216 sal_Int32 perfectDistance
= it
->second
[2].LineDistance
;
217 CPPUNIT_ASSERT_EQUAL(perfectInner
, innerLineWidth
);
218 CPPUNIT_ASSERT_EQUAL(perfectOuter
, outerLineWidth
);
219 CPPUNIT_ASSERT_EQUAL(perfectDistance
, lineDistance
);
222 uno::Any aBottomBorder
= xPropSet
->getPropertyValue("BottomBorder");
223 table::BorderLine aBottomBorderLine
;
224 if (aBottomBorder
>>= aBottomBorderLine
)
226 sal_Int32 innerLineWidth
= aBottomBorderLine
.InnerLineWidth
;
227 sal_Int32 outerLineWidth
= aBottomBorderLine
.OuterLineWidth
;
228 sal_Int32 lineDistance
= aBottomBorderLine
.LineDistance
;
230 sal_Int32 perfectInner
= it
->second
[3].InnerLineWidth
;
231 sal_Int32 perfectOuter
= it
->second
[3].OuterLineWidth
;
232 sal_Int32 perfectDistance
= it
->second
[3].LineDistance
;
233 CPPUNIT_ASSERT_EQUAL(perfectInner
, innerLineWidth
);
234 CPPUNIT_ASSERT_EQUAL(perfectOuter
, outerLineWidth
);
235 CPPUNIT_ASSERT_EQUAL(perfectDistance
, lineDistance
);
238 } //end of the 'for' loop
241 } while(xParaEnum
->hasMoreElements());
244 DECLARE_ODFIMPORT_TEST(testPageStyleLayoutDefault
, "hello.odt")
246 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("PageStyles")->getByName("Default Style"), uno::UNO_QUERY
);
247 // This was style::PageStyleLayout_MIRRORED.
248 CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_ALL
, getProperty
<style::PageStyleLayout
>(xPropertySet
, "PageStyleLayout"));
251 DECLARE_ODFIMPORT_TEST(testPageStyleLayoutRight
, "hello.odt")
253 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("PageStyles")->getByName("Default Style"), uno::UNO_QUERY
);
254 // This caused a crash.
255 xPropertySet
->setPropertyValue("PageStyleLayout", uno::makeAny(style::PageStyleLayout_RIGHT
));
258 DECLARE_ODFIMPORT_TEST(testFdo61952
, "hello.odt")
260 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(0), uno::UNO_QUERY
);
261 xPara
->setPropertyValue("PageDescName", uno::makeAny(OUString("Left Page")));
262 xPara
->setPropertyValue("PageDescName", uno::makeAny(OUString("Right Page")));
263 xPara
->setPropertyValue("PageDescName", uno::makeAny(OUString("Left Page")));
264 xPara
->setPropertyValue("PageDescName", uno::makeAny(OUString("Right Page")));
267 DECLARE_ODFIMPORT_TEST(testFdo60842
, "fdo60842.odt")
269 uno::Reference
<text::XTextContent
> const xTable(getParagraphOrTable(0));
270 getCell(xTable
, "A1", "");
271 getCell(xTable
, "B1", "18/02/2012");
272 getCell(xTable
, "C1", "USD"); // this is the cell with office:string-value
273 getCell(xTable
, "D1", "");
274 getCell(xTable
, "E1", "01/04/2012");
277 DECLARE_ODFIMPORT_TEST(testFdo79269
, "fdo79269.odt")
279 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
280 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
281 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(), uno::UNO_QUERY
);
282 xCursor
->jumpToLastPage();
283 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor
->getPage());
285 // The problem was that the first-footer was shared.
286 uno::Reference
<beans::XPropertySet
> xPropSet(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
287 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xPropSet
, "FirstIsShared"));
289 uno::Reference
<text::XTextRange
> xFooter1
= getProperty
< uno::Reference
<text::XTextRange
> >(xPropSet
, "FooterTextFirst");
290 CPPUNIT_ASSERT_EQUAL(OUString("forst"), xFooter1
->getString());
291 uno::Reference
<text::XTextRange
> xFooter
= getProperty
< uno::Reference
<text::XTextRange
> >(xPropSet
, "FooterText");
292 CPPUNIT_ASSERT_EQUAL(OUString("second"), xFooter
->getString());
295 DECLARE_ODFIMPORT_TEST(testFdo79269_header
, "fdo79269_header.odt")
297 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
298 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
299 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(), uno::UNO_QUERY
);
300 xCursor
->jumpToLastPage();
301 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor
->getPage());
303 uno::Reference
<beans::XPropertySet
> xPropSet(getStyles("PageStyles")->getByName(DEFAULT_STYLE
), uno::UNO_QUERY
);
304 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xPropSet
, "FirstIsShared"));
306 uno::Reference
<text::XTextRange
> xFooter1
= getProperty
< uno::Reference
<text::XTextRange
> >(xPropSet
, "HeaderTextFirst");
307 CPPUNIT_ASSERT_EQUAL(OUString("forst"), xFooter1
->getString());
308 uno::Reference
<text::XTextRange
> xFooter
= getProperty
< uno::Reference
<text::XTextRange
> >(xPropSet
, "HeaderText");
309 CPPUNIT_ASSERT_EQUAL(OUString("second"), xFooter
->getString());
312 DECLARE_ODFIMPORT_TEST(testPageBackground
, "PageBackground.odt")
314 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("PageStyles")->getByName("Default Style"), uno::UNO_QUERY
);
315 // The background image was lost
316 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, getProperty
<drawing::FillStyle
>(xPropertySet
, "FillStyle"));
317 CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty
<OUString
>(xPropertySet
, "FillBitmapName"));
318 CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_REPEAT
, getProperty
<drawing::BitmapMode
>(xPropertySet
, "FillBitmapMode"));
320 uno::Reference
<beans::XPropertySet
> xPropertySetOld(getStyles("PageStyles")->getByName("OldStandard"), uno::UNO_QUERY
);
321 // The background image was overridden by color
322 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, getProperty
<drawing::FillStyle
>(xPropertySetOld
, "FillStyle"));
323 CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty
<OUString
>(xPropertySetOld
, "FillBitmapName"));
324 CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_REPEAT
, getProperty
<drawing::BitmapMode
>(xPropertySetOld
, "FillBitmapMode"));
327 DECLARE_ODFIMPORT_TEST(testFdo56272
, "fdo56272.odt")
329 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
330 // Vertical position was incorrect.
331 CPPUNIT_ASSERT_EQUAL(sal_Int32(422), xShape
->getPosition().Y
); // Was -2371
334 DECLARE_ODFIMPORT_TEST(testCalcFootnoteContent
, "ooo32780-1.odt")
336 //this was a CalcFootnoteContent crash
339 DECLARE_ODFIMPORT_TEST(testMoveSubTree
, "ooo77837-1.odt")
341 //this was a MoveSubTree crash
344 DECLARE_ODFIMPORT_TEST(testFdo75872_ooo33
, "fdo75872_ooo33.odt")
346 // graphics default style: line color and fill color changed
347 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
348 CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_BLACK
),
349 getProperty
<sal_Int32
>(xShape
, "LineColor"));
350 CPPUNIT_ASSERT_EQUAL(sal_Int32(RGB_COLORDATA(153, 204, 255)),
351 getProperty
<sal_Int32
>(xShape
, "FillColor"));
354 DECLARE_ODFIMPORT_TEST(testFdo75872_aoo40
, "fdo75872_aoo40.odt")
356 // graphics default style: line color and fill color changed
357 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
358 CPPUNIT_ASSERT_EQUAL(sal_Int32(RGB_COLORDATA(128, 128, 128)),
359 getProperty
<sal_Int32
>(xShape
, "LineColor"));
360 CPPUNIT_ASSERT_EQUAL(sal_Int32(RGB_COLORDATA(0xCF, 0xE7, 0xF5)),
361 getProperty
<sal_Int32
>(xShape
, "FillColor"));
364 DECLARE_ODFIMPORT_TEST(testFdo55814
, "fdo55814.odt")
366 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
367 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
368 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
369 uno::Reference
<beans::XPropertySet
> xField(xFields
->nextElement(), uno::UNO_QUERY
);
370 xField
->setPropertyValue("Content", uno::makeAny(OUString("Yes")));
371 uno::Reference
<util::XRefreshable
>(xTextFieldsSupplier
->getTextFields(), uno::UNO_QUERY
)->refresh();
372 uno::Reference
<text::XTextSectionsSupplier
> xTextSectionsSupplier(mxComponent
, uno::UNO_QUERY
);
373 uno::Reference
<container::XIndexAccess
> xSections(xTextSectionsSupplier
->getTextSections(), uno::UNO_QUERY
);
375 CPPUNIT_ASSERT_EQUAL(OUString("Hide==\"Yes\""), getProperty
<OUString
>(xSections
->getByIndex(0), "Condition"));
379 uno::Reference
<drawing::XShape
> const& xShape
, OUString
const& rExpected
)
381 uno::Reference
<container::XNamed
> const xNamed(xShape
, uno::UNO_QUERY
);
382 CPPUNIT_ASSERT(xNamed
.is());
383 CPPUNIT_ASSERT_EQUAL(rExpected
, xNamed
->getName());
386 DECLARE_ODFIMPORT_TEST(testFdo68839
, "fdo68839.odt")
389 lcl_CheckShape(getShape(1), "FrameXXX");
390 lcl_CheckShape(getShape(2), "ObjectXXX");
391 lcl_CheckShape(getShape(3), "FrameY");
392 lcl_CheckShape(getShape(4), "graphicsXXX");
394 uno::Reference
<drawing::XShape
> xShape
= getShape(5);
395 CPPUNIT_FAIL("IndexOutOfBoundsException expected");
396 } catch (lang::IndexOutOfBoundsException
const&) { }
397 // check prev/next chain
398 uno::Reference
<beans::XPropertySet
> xFrame1(getShape(1), uno::UNO_QUERY
);
399 uno::Reference
<beans::XPropertySet
> xFrame2(getShape(3), uno::UNO_QUERY
);
400 CPPUNIT_ASSERT_EQUAL(OUString(),
401 getProperty
<OUString
>(xFrame1
, "ChainPrevName"));
402 CPPUNIT_ASSERT_EQUAL(OUString("FrameY"),
403 getProperty
<OUString
>(xFrame1
, "ChainNextName"));
404 CPPUNIT_ASSERT_EQUAL(OUString("FrameXXX"),
405 getProperty
<OUString
>(xFrame2
, "ChainPrevName"));
406 CPPUNIT_ASSERT_EQUAL(OUString(),
407 getProperty
<OUString
>(xFrame2
, "ChainNextName"));
410 DECLARE_ODFIMPORT_TEST(testFdo82165
, "fdo82165.odt")
412 // there was a duplicate shape in the left header
413 lcl_CheckShape(getShape(1), "Picture 9");
415 uno::Reference
<drawing::XShape
> xShape
= getShape(2);
416 CPPUNIT_FAIL("IndexOutOfBoundsException expected");
417 } catch (lang::IndexOutOfBoundsException
const&) { }
420 DECLARE_ODFIMPORT_TEST(testTdf89802
, "tdf89802.fodt")
422 // the text frame was dropped during import
423 uno::Reference
<text::XTextFramesSupplier
> const xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
424 uno::Reference
<container::XIndexAccess
> const xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
425 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess
->getCount());
426 uno::Reference
<beans::XPropertySet
> const xFrame(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
428 xFrame
->getPropertyValue("BackColor") >>= nValue
;
429 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x3f004586), nValue
);
432 DECLARE_ODFIMPORT_TEST(testFdo37606
, "fdo37606.odt")
434 SwXTextDocument
* pTextDoc
= dynamic_cast<SwXTextDocument
*>(mxComponent
.get());
435 CPPUNIT_ASSERT(pTextDoc
);
436 SwWrtShell
* pWrtShell
= pTextDoc
->GetDocShell()->GetWrtShell();
437 SwShellCrsr
* pShellCrsr
= pWrtShell
->getShellCrsr(false);
440 pWrtShell
->SelAll(); // Selects A1.
441 SwTextNode
& rCellEnd
= dynamic_cast<SwTextNode
&>(pShellCrsr
->End()->nNode
.GetNode());
442 // fdo#72486 This was "Hello.", i.e. a single select-all selected the whole document, not just the cell only.
443 CPPUNIT_ASSERT_EQUAL(OUString("A1"), rCellEnd
.GetText());
445 pWrtShell
->SelAll(); // Selects the whole table.
446 pWrtShell
->SelAll(); // Selects the whole document.
447 SwTextNode
& rStart
= dynamic_cast<SwTextNode
&>(pShellCrsr
->Start()->nNode
.GetNode());
448 CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart
.GetText());
450 SwTextNode
& rEnd
= dynamic_cast<SwTextNode
&>(pShellCrsr
->End()->nNode
.GetNode());
451 // This was "A1", i.e. Ctrl-A only selected the A1 cell of the table, not the whole document.
452 CPPUNIT_ASSERT_EQUAL(OUString("Hello."), rEnd
.GetText());
456 pWrtShell
->SttEndDoc(false); // Go to the end of the doc.
457 pWrtShell
->SelAll(); // And now that we're outside of the table, try Ctrl-A again.
458 SwTextNode
& rStart
= dynamic_cast<SwTextNode
&>(pShellCrsr
->Start()->nNode
.GetNode());
459 // This was "Hello", i.e. Ctrl-A did not select the starting table.
460 CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart
.GetText());
462 SwTextNode
& rEnd
= dynamic_cast<SwTextNode
&>(pShellCrsr
->End()->nNode
.GetNode());
463 CPPUNIT_ASSERT_EQUAL(OUString("Hello."), rEnd
.GetText());
467 pWrtShell
->Delete(); // Delete the selection
468 // And make sure the table got deleted as well.
469 SwNodes
& rNodes
= pWrtShell
->GetDoc()->GetNodes();
470 SwNodeIndex
nNode(rNodes
.GetEndOfExtras());
471 SwContentNode
* pContentNode
= rNodes
.GoNext(&nNode
);
472 // First content node was in a table -> table wasn't deleted.
473 CPPUNIT_ASSERT(!pContentNode
->FindTableNode());
477 DECLARE_ODFIMPORT_TEST(testFdo37606Copy
, "fdo37606.odt")
479 SwXTextDocument
* pTextDoc
= dynamic_cast<SwXTextDocument
*>(mxComponent
.get());
480 CPPUNIT_ASSERT(pTextDoc
);
481 SwWrtShell
* pWrtShell
= pTextDoc
->GetDocShell()->GetWrtShell();
483 pWrtShell
->SelAll(); // Selects A1.
484 pWrtShell
->SelAll(); // Selects the whole table.
485 pWrtShell
->SelAll(); // Selects the whole document.
488 SwTransferable
* pTransferable
= new SwTransferable(*pWrtShell
);
489 uno::Reference
<datatransfer::XTransferable
> xTransferable(pTransferable
);
490 pTransferable
->Copy();
492 pWrtShell
->SttEndDoc(false); // Go to the end of the doc.
495 TransferableDataHelper
aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(&pWrtShell
->GetView().GetEditWin()));
496 SwTransferable::Paste( *pWrtShell
, aDataHelper
);
498 // Previously copy&paste failed to copy the table in case it was the document-starting one.
499 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
500 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
501 #if !defined(MACOSX) && !defined(LIBO_HEADLESS) // FIXME
502 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables
->getCount());
506 DECLARE_ODFIMPORT_TEST(testFdo69862
, "fdo69862.odt")
508 // The test doc is special in that it starts with a table and it also has a footnote.
509 SwXTextDocument
* pTextDoc
= dynamic_cast<SwXTextDocument
*>(mxComponent
.get());
510 CPPUNIT_ASSERT(pTextDoc
);
511 SwWrtShell
* pWrtShell
= pTextDoc
->GetDocShell()->GetWrtShell();
512 SwShellCrsr
* pShellCrsr
= pWrtShell
->getShellCrsr(false);
514 pWrtShell
->SelAll(); // Selects A1.
515 pWrtShell
->SelAll(); // Selects the whole table.
516 pWrtShell
->SelAll(); // Selects the whole document.
517 SwTextNode
& rStart
= dynamic_cast<SwTextNode
&>(pShellCrsr
->Start()->nNode
.GetNode());
518 // This was "Footnote.", as Ctrl-A also selected footnotes, but it should not.
519 CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart
.GetText());
521 SwTextNode
& rEnd
= dynamic_cast<SwTextNode
&>(pShellCrsr
->End()->nNode
.GetNode());
522 CPPUNIT_ASSERT_EQUAL(OUString("H" "\x01" "ello."), rEnd
.GetText());
525 DECLARE_ODFIMPORT_TEST(testFdo69979
, "fdo69979.odt")
527 // The test doc is special in that it starts with a table and it also has a header.
528 SwXTextDocument
* pTextDoc
= dynamic_cast<SwXTextDocument
*>(mxComponent
.get());
529 CPPUNIT_ASSERT(pTextDoc
);
530 SwWrtShell
* pWrtShell
= pTextDoc
->GetDocShell()->GetWrtShell();
531 SwShellCrsr
* pShellCrsr
= pWrtShell
->getShellCrsr(false);
533 pWrtShell
->SelAll(); // Selects A1.
534 pWrtShell
->SelAll(); // Selects the whole table.
535 pWrtShell
->SelAll(); // Selects the whole document.
536 SwTextNode
& rStart
= dynamic_cast<SwTextNode
&>(pShellCrsr
->Start()->nNode
.GetNode());
537 // This was "", as Ctrl-A also selected headers, but it should not.
538 CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart
.GetText());
540 SwTextNode
& rEnd
= dynamic_cast<SwTextNode
&>(pShellCrsr
->End()->nNode
.GetNode());
541 CPPUNIT_ASSERT_EQUAL(OUString("Hello."), rEnd
.GetText());
544 DECLARE_ODFIMPORT_TEST(testSpellmenuRedline
, "spellmenu-redline.odt")
546 SwXTextDocument
* pTextDoc
= dynamic_cast<SwXTextDocument
*>(mxComponent
.get());
547 CPPUNIT_ASSERT(pTextDoc
);
548 SwWrtShell
* pWrtShell
= pTextDoc
->GetDocShell()->GetWrtShell();
550 uno::Reference
<linguistic2::XSpellAlternatives
> xAlt
;
551 SwSpellPopup
aPopup(pWrtShell
, xAlt
, aParaText
);
552 // Make sure that if we show the spellcheck popup menu (for the current
553 // document, which contains redlines), then the last two entries will be
554 // always 'go to next/previous change'.
555 CPPUNIT_ASSERT_EQUAL(sal_uInt16(FN_REDLINE_NEXT_CHANGE
), aPopup
.GetItemId(aPopup
.GetItemCount() - 2));
556 CPPUNIT_ASSERT_EQUAL(sal_uInt16(FN_REDLINE_PREV_CHANGE
), aPopup
.GetItemId(aPopup
.GetItemCount() - 1));
559 DECLARE_ODFIMPORT_TEST(testAnnotationFormatting
, "annotation-formatting.odt")
561 uno::Reference
<beans::XPropertySet
> xTextField
= getProperty
< uno::Reference
<beans::XPropertySet
> >(getRun(getParagraph(1), 1), "TextField");
562 uno::Reference
<text::XText
> xText
= getProperty
< uno::Reference
<text::XText
> >(xTextField
, "TextRange");
563 // Make sure we test the right annotation.
564 uno::Reference
<text::XTextRange
> xParagraph
= getParagraphOfText(1, xText
, "Looses: bold");
565 // Formatting was lost: the second text portion was NORMAL, not BOLD.
566 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD
, getProperty
<float>(getRun(xParagraph
, 2), "CharWeight"));
569 DECLARE_ODFIMPORT_TEST(fdo81223
, "fdo81223.odt")
571 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
572 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
573 uno::Reference
<beans::XPropertySet
> xFrame(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
575 xFrame
->getPropertyValue("BackColor") >>= nValue
;
576 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffffff), nValue
);
579 DECLARE_ODFIMPORT_TEST(fdo90130_1
, "fdo90130-1.odt")
581 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
582 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
583 uno::Reference
<beans::XPropertySet
> xFrame(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
585 xFrame
->getPropertyValue("BackColor") >>= nValue
;
586 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00ff3333), nValue
);
589 DECLARE_ODFIMPORT_TEST(fdo90130_2
, "fdo90130-2.odt")
591 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
592 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
593 uno::Reference
<beans::XPropertySet
> xFrame(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
595 xFrame
->getPropertyValue("BackColorTransparency") >>= nValue
;
596 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), nValue
);
599 DECLARE_ODFIMPORT_TEST(testBnc800714
, "bnc800714.fodt")
601 // Document's second paragraph wants to be together with the third one, but:
602 // - it's in a section with multiple columns
603 // - contains a single as-char anchored frame
604 // This was a layout loop.
605 CPPUNIT_ASSERT(getProperty
< uno::Reference
<text::XTextSection
> >(getParagraph(2), "TextSection").is());
606 CPPUNIT_ASSERT(getProperty
<bool>(getParagraph(2), "ParaKeepTogether"));
609 DECLARE_ODFIMPORT_TEST(testTdf92586
, "tdf92586.odt")
611 uno::Reference
<beans::XPropertySet
> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY
);
612 // This was BitmapMode_NO_REPEAT.
613 CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_STRETCH
, getProperty
<drawing::BitmapMode
>(xPageStyle
, "FillBitmapMode"));
618 CPPUNIT_PLUGIN_IMPLEMENT();
619 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */