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>
12 #include <com/sun/star/text/XBookmarksSupplier.hpp>
13 #include <com/sun/star/text/XDependentTextField.hpp>
14 #include <com/sun/star/text/XFormField.hpp>
15 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
16 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
17 #include <com/sun/star/text/XTextDocument.hpp>
18 #include <com/sun/star/text/XTextTablesSupplier.hpp>
19 #include <com/sun/star/text/XTextTable.hpp>
20 #include <com/sun/star/document/XViewDataSupplier.hpp>
21 #include <o3tl/string_view.hxx>
23 class Test
: public SwModelTestBase
27 : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text")
32 CPPUNIT_TEST_FIXTURE(Test
, testTableCrossReference
)
34 loadAndReload("table_cross_reference.odt");
35 CPPUNIT_ASSERT_EQUAL(1, getPages());
36 // tdf#42346: Cross references to tables were not saved
37 // MSO uses simple bookmarks for referencing table caption, so we do the same by export
39 // Check whether we have all the necessary bookmarks exported and imported back
40 uno::Reference
<text::XBookmarksSupplier
> xBookmarksSupplier(mxComponent
, uno::UNO_QUERY
);
41 uno::Reference
<container::XIndexAccess
> xBookmarksByIdx(xBookmarksSupplier
->getBookmarks(),
43 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xBookmarksByIdx
->getCount());
44 uno::Reference
<container::XNameAccess
> xBookmarksByName
= xBookmarksSupplier
->getBookmarks();
45 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table0_full"));
46 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table0_label_and_number"));
47 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table0_caption_only"));
48 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table0_number_only"));
50 // Check bookmark text ranges
52 uno::Reference
<text::XTextContent
> xContent(xBookmarksByName
->getByName("Ref_Table0_full"),
54 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
55 CPPUNIT_ASSERT_EQUAL(OUString("Table 1: Table caption"), xRange
->getString());
58 uno::Reference
<text::XTextContent
> xContent(
59 xBookmarksByName
->getByName("Ref_Table0_label_and_number"), uno::UNO_QUERY
);
60 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
61 CPPUNIT_ASSERT_EQUAL(OUString("Table 1"), xRange
->getString());
64 uno::Reference
<text::XTextContent
> xContent(
65 xBookmarksByName
->getByName("Ref_Table0_caption_only"), uno::UNO_QUERY
);
66 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
67 CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange
->getString());
70 uno::Reference
<text::XTextContent
> xContent(
71 xBookmarksByName
->getByName("Ref_Table0_number_only"), uno::UNO_QUERY
);
72 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
73 CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange
->getString());
76 // Check reference fields
77 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
78 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(
79 xTextFieldsSupplier
->getTextFields());
80 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
81 CPPUNIT_ASSERT(xFields
->hasMoreElements());
83 sal_uInt16 nIndex
= 0;
84 while (xFields
->hasMoreElements())
86 uno::Reference
<lang::XServiceInfo
> xServiceInfo(xFields
->nextElement(), uno::UNO_QUERY
);
87 uno::Reference
<beans::XPropertySet
> xPropertySet(xServiceInfo
, uno::UNO_QUERY
);
90 // Full reference to table caption
94 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
97 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
98 CPPUNIT_ASSERT_EQUAL(OUString("Table 1: Table caption"), sValue
);
99 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
100 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue
);
101 xPropertySet
->getPropertyValue("SequenceNumber") >>= nValue
;
102 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue
);
105 // Page style reference / exported as simple page reference
109 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
112 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
113 CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue
);
114 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
115 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue
);
116 xPropertySet
->getPropertyValue("SequenceNumber") >>= nValue
;
117 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue
);
120 // Reference to table number
124 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
127 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
128 CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue
);
129 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
130 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_number_only"), sValue
);
131 xPropertySet
->getPropertyValue("SequenceNumber") >>= nValue
;
132 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue
);
135 // Reference to caption only
139 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
142 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
143 CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), sValue
);
144 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
145 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_caption_only"), sValue
);
146 xPropertySet
->getPropertyValue("SequenceNumber") >>= nValue
;
147 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue
);
150 // Reference to category and number
154 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
157 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
158 CPPUNIT_ASSERT_EQUAL(OUString("Table 1"), sValue
);
159 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
160 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_label_and_number"), sValue
);
161 xPropertySet
->getPropertyValue("SequenceNumber") >>= nValue
;
162 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue
);
165 // Reference to page of the table
169 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
172 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
173 CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue
);
174 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
175 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue
);
176 xPropertySet
->getPropertyValue("SequenceNumber") >>= nValue
;
177 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue
);
180 // Above / below reference
184 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
187 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
188 CPPUNIT_ASSERT_EQUAL(OUString("above"), sValue
);
189 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
190 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Table0_full"), sValue
);
191 xPropertySet
->getPropertyValue("SequenceNumber") >>= nValue
;
192 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue
);
201 CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), nIndex
);
204 CPPUNIT_TEST_FIXTURE(Test
, testTableCrossReferenceCustomFormat
)
206 loadAndReload("table_cross_reference_custom_format.odt");
207 CPPUNIT_ASSERT_EQUAL(1, getPages());
208 // tdf#42346: Cross references to tables were not saved
209 // Check also captions with custom formatting
211 // Check whether we have all the necessary bookmarks exported and imported back
212 uno::Reference
<text::XBookmarksSupplier
> xBookmarksSupplier(mxComponent
, uno::UNO_QUERY
);
213 uno::Reference
<container::XIndexAccess
> xBookmarksByIdx(xBookmarksSupplier
->getBookmarks(),
215 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(16), xBookmarksByIdx
->getCount());
216 uno::Reference
<container::XNameAccess
> xBookmarksByName
= xBookmarksSupplier
->getBookmarks();
217 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table0_full"));
218 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table0_label_and_number"));
219 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table0_caption_only"));
220 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table0_number_only"));
221 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table1_full"));
222 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table1_label_and_number"));
223 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table1_caption_only"));
224 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table1_number_only"));
225 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table2_full"));
226 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table2_label_and_number"));
227 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table2_caption_only"));
228 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table2_number_only"));
229 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table3_full"));
230 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table3_label_and_number"));
231 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table3_caption_only"));
232 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Table3_number_only"));
234 // Check bookmark text ranges
235 // First table's caption
237 uno::Reference
<text::XTextContent
> xContent(xBookmarksByName
->getByName("Ref_Table0_full"),
239 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
240 CPPUNIT_ASSERT_EQUAL(OUString("1. Table: Table caption"), xRange
->getString());
243 uno::Reference
<text::XTextContent
> xContent(
244 xBookmarksByName
->getByName("Ref_Table0_label_and_number"), uno::UNO_QUERY
);
245 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
246 CPPUNIT_ASSERT_EQUAL(OUString("1. Table"), xRange
->getString());
249 uno::Reference
<text::XTextContent
> xContent(
250 xBookmarksByName
->getByName("Ref_Table0_caption_only"), uno::UNO_QUERY
);
251 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
252 CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange
->getString());
255 uno::Reference
<text::XTextContent
> xContent(
256 xBookmarksByName
->getByName("Ref_Table0_number_only"), uno::UNO_QUERY
);
257 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
258 CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange
->getString());
260 // Second table's caption
262 uno::Reference
<text::XTextContent
> xContent(xBookmarksByName
->getByName("Ref_Table1_full"),
264 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
265 CPPUNIT_ASSERT_EQUAL(OUString("2. TableTable caption"), xRange
->getString());
268 uno::Reference
<text::XTextContent
> xContent(
269 xBookmarksByName
->getByName("Ref_Table1_label_and_number"), uno::UNO_QUERY
);
270 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
271 CPPUNIT_ASSERT_EQUAL(OUString("2. Table"), xRange
->getString());
274 uno::Reference
<text::XTextContent
> xContent(
275 xBookmarksByName
->getByName("Ref_Table1_caption_only"), uno::UNO_QUERY
);
276 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
277 CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange
->getString());
280 uno::Reference
<text::XTextContent
> xContent(
281 xBookmarksByName
->getByName("Ref_Table1_number_only"), uno::UNO_QUERY
);
282 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
283 CPPUNIT_ASSERT_EQUAL(OUString("2"), xRange
->getString());
285 // Third table's caption
287 uno::Reference
<text::XTextContent
> xContent(xBookmarksByName
->getByName("Ref_Table2_full"),
289 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
290 CPPUNIT_ASSERT_EQUAL(OUString("3) Table Table caption"), xRange
->getString());
293 uno::Reference
<text::XTextContent
> xContent(
294 xBookmarksByName
->getByName("Ref_Table2_label_and_number"), uno::UNO_QUERY
);
295 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
296 CPPUNIT_ASSERT_EQUAL(OUString("3) Table"), xRange
->getString());
299 uno::Reference
<text::XTextContent
> xContent(
300 xBookmarksByName
->getByName("Ref_Table2_caption_only"), uno::UNO_QUERY
);
301 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
302 CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange
->getString());
305 uno::Reference
<text::XTextContent
> xContent(
306 xBookmarksByName
->getByName("Ref_Table2_number_only"), uno::UNO_QUERY
);
307 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
308 CPPUNIT_ASSERT_EQUAL(OUString("3"), xRange
->getString());
310 // Fourth table's caption
312 uno::Reference
<text::XTextContent
> xContent(xBookmarksByName
->getByName("Ref_Table3_full"),
314 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
315 CPPUNIT_ASSERT_EQUAL(OUString("Table 4- Table caption"), xRange
->getString());
318 uno::Reference
<text::XTextContent
> xContent(
319 xBookmarksByName
->getByName("Ref_Table3_label_and_number"), uno::UNO_QUERY
);
320 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
321 CPPUNIT_ASSERT_EQUAL(OUString("Table 4"), xRange
->getString());
324 uno::Reference
<text::XTextContent
> xContent(
325 xBookmarksByName
->getByName("Ref_Table3_caption_only"), uno::UNO_QUERY
);
326 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
327 CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange
->getString());
330 uno::Reference
<text::XTextContent
> xContent(
331 xBookmarksByName
->getByName("Ref_Table3_number_only"), uno::UNO_QUERY
);
332 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
333 CPPUNIT_ASSERT_EQUAL(OUString("4"), xRange
->getString());
337 CPPUNIT_TEST_FIXTURE(Test
, testObjectCrossReference
)
339 loadAndReload("object_cross_reference.odt");
340 CPPUNIT_ASSERT_EQUAL(10, getShapes());
341 CPPUNIT_ASSERT_EQUAL(2, getPages());
342 // tdf#42346: Cross references to objects were not saved
343 // MSO uses simple bookmarks for referencing table caption, so we do the same by export
345 // Check whether we have all the necessary bookmarks exported and imported back
346 uno::Reference
<text::XBookmarksSupplier
> xBookmarksSupplier(mxComponent
, uno::UNO_QUERY
);
347 uno::Reference
<container::XIndexAccess
> xBookmarksByIdx(xBookmarksSupplier
->getBookmarks(),
349 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(15), xBookmarksByIdx
->getCount());
350 uno::Reference
<container::XNameAccess
> xBookmarksByName
= xBookmarksSupplier
->getBookmarks();
351 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Drawing0_full"));
352 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Drawing0_label_and_number"));
353 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Drawing0_caption_only"));
354 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Drawing0_number_only"));
355 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Drawing1_full"));
357 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Illustration0_full"));
358 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Illustration0_label_and_number"));
359 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Illustration0_caption_only"));
360 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Illustration0_number_only"));
361 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Illustration1_caption_only"));
363 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Text0_full"));
364 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Text0_label_and_number"));
365 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Text0_caption_only"));
366 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Text0_number_only"));
367 CPPUNIT_ASSERT(xBookmarksByName
->hasByName("Ref_Text1_label_and_number"));
369 // Check bookmark text ranges
370 // Cross references to shapes
372 uno::Reference
<text::XTextContent
> xContent(
373 xBookmarksByName
->getByName("Ref_Drawing0_full"), uno::UNO_QUERY
);
374 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
375 CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1: A rectangle"), xRange
->getString());
378 uno::Reference
<text::XTextContent
> xContent(
379 xBookmarksByName
->getByName("Ref_Drawing0_label_and_number"), uno::UNO_QUERY
);
380 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
381 CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1"), xRange
->getString());
384 uno::Reference
<text::XTextContent
> xContent(
385 xBookmarksByName
->getByName("Ref_Drawing0_caption_only"), uno::UNO_QUERY
);
386 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
387 CPPUNIT_ASSERT_EQUAL(OUString("A rectangle"), xRange
->getString());
390 uno::Reference
<text::XTextContent
> xContent(
391 xBookmarksByName
->getByName("Ref_Drawing0_number_only"), uno::UNO_QUERY
);
392 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
393 CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange
->getString());
396 uno::Reference
<text::XTextContent
> xContent(
397 xBookmarksByName
->getByName("Ref_Drawing1_full"), uno::UNO_QUERY
);
398 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
399 CPPUNIT_ASSERT_EQUAL(OUString("Drawing 2: a circle"), xRange
->getString());
402 // Cross references to pictures
404 uno::Reference
<text::XTextContent
> xContent(
405 xBookmarksByName
->getByName("Ref_Illustration0_full"), uno::UNO_QUERY
);
406 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
407 CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1: A picture"), xRange
->getString());
410 uno::Reference
<text::XTextContent
> xContent(
411 xBookmarksByName
->getByName("Ref_Illustration0_label_and_number"), uno::UNO_QUERY
);
412 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
413 CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1"), xRange
->getString());
416 uno::Reference
<text::XTextContent
> xContent(
417 xBookmarksByName
->getByName("Ref_Illustration0_caption_only"), uno::UNO_QUERY
);
418 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
419 CPPUNIT_ASSERT_EQUAL(OUString("A picture"), xRange
->getString());
422 uno::Reference
<text::XTextContent
> xContent(
423 xBookmarksByName
->getByName("Ref_Illustration0_number_only"), uno::UNO_QUERY
);
424 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
425 CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange
->getString());
428 uno::Reference
<text::XTextContent
> xContent(
429 xBookmarksByName
->getByName("Ref_Illustration1_caption_only"), uno::UNO_QUERY
);
430 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
431 CPPUNIT_ASSERT_EQUAL(OUString("another image"), xRange
->getString());
434 // Cross references to text frames
436 uno::Reference
<text::XTextContent
> xContent(xBookmarksByName
->getByName("Ref_Text0_full"),
438 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
439 CPPUNIT_ASSERT_EQUAL(OUString("Text 1: A frame"), xRange
->getString());
442 uno::Reference
<text::XTextContent
> xContent(
443 xBookmarksByName
->getByName("Ref_Text0_label_and_number"), uno::UNO_QUERY
);
444 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
445 CPPUNIT_ASSERT_EQUAL(OUString("Text 1"), xRange
->getString());
448 uno::Reference
<text::XTextContent
> xContent(
449 xBookmarksByName
->getByName("Ref_Text0_caption_only"), uno::UNO_QUERY
);
450 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
451 CPPUNIT_ASSERT_EQUAL(OUString("A frame"), xRange
->getString());
454 uno::Reference
<text::XTextContent
> xContent(
455 xBookmarksByName
->getByName("Ref_Text0_number_only"), uno::UNO_QUERY
);
456 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
457 CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange
->getString());
460 uno::Reference
<text::XTextContent
> xContent(
461 xBookmarksByName
->getByName("Ref_Text1_label_and_number"), uno::UNO_QUERY
);
462 uno::Reference
<text::XTextRange
> xRange
= xContent
->getAnchor();
463 CPPUNIT_ASSERT_EQUAL(OUString("Text 2"), xRange
->getString());
466 // Check reference fields
467 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
468 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(
469 xTextFieldsSupplier
->getTextFields());
470 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
471 CPPUNIT_ASSERT(xFields
->hasMoreElements());
473 sal_uInt16 nIndex
= 0;
474 while (xFields
->hasMoreElements())
476 uno::Reference
<lang::XServiceInfo
> xServiceInfo(xFields
->nextElement(), uno::UNO_QUERY
);
477 uno::Reference
<beans::XPropertySet
> xPropertySet(xServiceInfo
, uno::UNO_QUERY
);
480 // Reference to image number
484 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
486 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
487 CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue
);
488 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
489 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_number_only"), sValue
);
492 // Full reference to the circle shape
496 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
498 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
499 CPPUNIT_ASSERT_EQUAL(OUString("Drawing 2: a circle"), sValue
);
500 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
501 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing1_full"), sValue
);
504 // Caption only reference to the second picture
508 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
510 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
511 CPPUNIT_ASSERT_EQUAL(OUString("another image"), sValue
);
512 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
513 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration1_caption_only"), sValue
);
516 // Category and number reference to second text frame
520 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
522 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
523 CPPUNIT_ASSERT_EQUAL(OUString("Text 2"), sValue
);
524 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
525 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text1_label_and_number"), sValue
);
528 // Full reference to rectangle shape
532 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
534 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
535 CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1: A rectangle"), sValue
);
536 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
537 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_full"), sValue
);
540 // Caption only reference to rectangle shape
544 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
546 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
547 CPPUNIT_ASSERT_EQUAL(OUString("A rectangle"), sValue
);
548 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
549 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_caption_only"), sValue
);
552 // Category and number reference to rectangle shape
556 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
558 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
559 CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1"), sValue
);
560 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
561 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_label_and_number"), sValue
);
564 // Reference to rectangle shape's number
568 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
570 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
571 CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue
);
572 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
573 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Drawing0_number_only"), sValue
);
576 // Full reference to first text frame
580 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
582 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
583 CPPUNIT_ASSERT_EQUAL(OUString("Text 1: A frame"), sValue
);
584 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
585 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_full"), sValue
);
588 // Caption only reference to first text frame
592 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
594 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
595 CPPUNIT_ASSERT_EQUAL(OUString("A frame"), sValue
);
596 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
597 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_caption_only"), sValue
);
600 // Category and number reference to first text frame
604 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
606 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
607 CPPUNIT_ASSERT_EQUAL(OUString("Text 1"), sValue
);
608 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
609 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_label_and_number"), sValue
);
612 // Number only reference to first text frame
616 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
618 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
619 CPPUNIT_ASSERT_EQUAL(OUString("1"), sValue
);
620 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
621 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Text0_number_only"), sValue
);
624 // Full reference to first picture
628 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
630 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
631 CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1: A picture"),
632 sValue
.trim()); // fails on MAC without trim
633 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
634 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_full"), sValue
);
637 // Reference to first picture' caption
641 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
643 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
644 CPPUNIT_ASSERT_EQUAL(OUString("A picture"), sValue
);
645 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
646 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_caption_only"), sValue
);
649 // Category and number reference to first picture
653 xServiceInfo
->supportsService("com.sun.star.text.TextField.GetReference"));
655 xPropertySet
->getPropertyValue("CurrentPresentation") >>= sValue
;
656 CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1"), sValue
);
657 xPropertySet
->getPropertyValue("SourceName") >>= sValue
;
658 CPPUNIT_ASSERT_EQUAL(OUString("Ref_Illustration0_label_and_number"), sValue
);
667 CPPUNIT_ASSERT_EQUAL(sal_uInt16(21), nIndex
);
670 DECLARE_OOXMLEXPORT_TEST(testTdf112202
, "090716_Studentische_Arbeit_VWS.docx")
672 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
674 // page 1 header: 1 paragraph, 2 flys, 1 draw object
675 assertXPath(pXmlDoc
, "/root/page[1]/header/txt", 1);
676 assertXPath(pXmlDoc
, "/root/page[1]/header/txt/anchored/fly", 2);
677 if (isExported()) // somehow there's an additional shape on re-import?
678 assertXPath(pXmlDoc
, "/root/page[1]/header/txt/anchored/SwAnchoredDrawObject", 2);
680 assertXPath(pXmlDoc
, "/root/page[1]/header/txt/anchored/SwAnchoredDrawObject", 1);
682 // page 2 header: 3 paragraphs, 1 table, 1 fly on last paragraph
683 assertXPath(pXmlDoc
, "/root/page[2]/header/txt", 3);
684 assertXPath(pXmlDoc
, "/root/page[2]/header/tab", 1);
685 assertXPath(pXmlDoc
, "/root/page[2]/header/txt/anchored/fly", 1);
687 // page 3 header: 1 table, 1 paragraph, no text
688 assertXPath(pXmlDoc
, "/root/page[3]/header/txt", 1);
689 assertXPath(pXmlDoc
, "/root/page[3]/header/tab", 1);
691 "/root/page[3]/header/tab/row/cell/txt/SwParaPortion/SwLineLayout/child::*", 0);
692 assertXPath(pXmlDoc
, "/root/page[3]/header//anchored", 0);
693 // tdf#149313: ensure 3rd page does not have extra empty paragraph at top
694 assertXPathContent(pXmlDoc
, "/root/page[3]/body//txt", "AUFGABENSTELLUNG");
696 // page 4 header: 1 table, 1 paragraph, with text
697 assertXPath(pXmlDoc
, "/root/page[4]/header/txt", 1);
698 assertXPath(pXmlDoc
, "/root/page[4]/header/tab", 1);
701 "/root/page[4]/header/tab/row[1]/cell[1]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
702 "portion", "Titel der studentischen Arbeit");
703 assertXPath(pXmlDoc
, "/root/page[4]/header//anchored", 0);
705 // page 5: same as page 4
706 assertXPath(pXmlDoc
, "/root/page[5]/header/txt", 1);
707 assertXPath(pXmlDoc
, "/root/page[5]/header/tab", 1);
710 "/root/page[5]/header/tab/row[1]/cell[1]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
711 "portion", "Titel der studentischen Arbeit");
712 assertXPath(pXmlDoc
, "/root/page[5]/header//anchored", 0);
714 // page 6: same as page 4
715 assertXPath(pXmlDoc
, "/root/page[6]/header/txt", 1);
716 assertXPath(pXmlDoc
, "/root/page[6]/header/tab", 1);
719 "/root/page[6]/header/tab/row[1]/cell[1]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
720 "portion", "Titel der studentischen Arbeit");
721 assertXPath(pXmlDoc
, "/root/page[6]/header//anchored", 0);
724 CPPUNIT_TEST_FIXTURE(Test
, testTdf79435_legacyInputFields
)
726 loadAndReload("tdf79435_legacyInputFields.doc");
727 //using .doc input file to verify cross-format compatibility.
728 uno::Reference
<text::XFormField
> xFormField
729 = getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(5), 3), "Bookmark");
730 uno::Reference
<container::XNameContainer
> xParameters(xFormField
->getParameters());
733 // Doc import problems, so disabling tests
734 //xParameters->getByName("EntryMacro") >>= sTmp;
735 //CPPUNIT_ASSERT_EQUAL(OUString("test"), sTmp);
736 //xParameters->getByName("Help") >>= sTmp;
737 //CPPUNIT_ASSERT_EQUAL(OUString("F1Help"), sTmp);
738 //xParameters->getByName("ExitMacro") >>= sTmp;
739 //CPPUNIT_ASSERT_EQUAL(OUString("test"), sTmp);
740 xParameters
->getByName("Hint") >>= sTmp
;
741 CPPUNIT_ASSERT_EQUAL(OUString("StatusHelp"), sTmp
);
742 //xParameters->getByName("Content") >>= sTmp;
743 //CPPUNIT_ASSERT_EQUAL(OUString("Camelcase"), sTmp);
744 //xParameters->getByName("Format") >>= sTmp;
745 //CPPUNIT_ASSERT_EQUAL(OUString("TITLE CASE"), sTmp);
747 sal_uInt16 nMaxLength
= 0;
748 xParameters
->getByName("MaxLength") >>= nMaxLength
;
749 CPPUNIT_ASSERT_EQUAL_MESSAGE("Max Length", sal_uInt16(10), nMaxLength
);
751 // too bad this is based on character runs - just found try trial and error.
753 = getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(6), 2), "Bookmark");
754 xParameters
.set(xFormField
->getParameters());
755 xParameters
->getByName("Type") >>= sTmp
;
756 CPPUNIT_ASSERT_EQUAL(OUString("calculated"), sTmp
);
759 = getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(7), 2), "Bookmark");
760 xParameters
.set(xFormField
->getParameters());
761 xParameters
->getByName("Type") >>= sTmp
;
762 CPPUNIT_ASSERT_EQUAL(OUString("currentDate"), sTmp
);
765 = getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(7), 7), "Bookmark");
766 xParameters
.set(xFormField
->getParameters());
767 xParameters
->getByName("Type") >>= sTmp
;
768 CPPUNIT_ASSERT_EQUAL(OUString("currentTime"), sTmp
);
771 = getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(8), 2), "Bookmark");
772 xParameters
.set(xFormField
->getParameters());
773 xParameters
->getByName("Type") >>= sTmp
;
774 CPPUNIT_ASSERT_EQUAL(OUString("number"), sTmp
);
777 = getProperty
<uno::Reference
<text::XFormField
>>(getRun(getParagraph(8), 7), "Bookmark");
778 xParameters
.set(xFormField
->getParameters());
779 xParameters
->getByName("Type") >>= sTmp
;
780 CPPUNIT_ASSERT_EQUAL(OUString("date"), sTmp
);
782 xmlDocUniquePtr pXmlDoc
= parseExport("word/settings.xml");
783 assertXPath(pXmlDoc
, "/w:settings/w:compat/w:compatSetting[1]", "name", "compatibilityMode");
784 assertXPath(pXmlDoc
, "/w:settings/w:compat/w:compatSetting[1]", "uri",
785 "http://schemas.microsoft.com/office/word");
786 assertXPath(pXmlDoc
, "/w:settings/w:compat/w:compatSetting[1]", "val", "11");
789 DECLARE_OOXMLEXPORT_TEST(testTdf120224_textControlCrossRef
, "tdf120224_textControlCrossRef.docx")
791 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
792 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(),
794 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
795 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xParaEnum
->nextElement(),
797 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
798 xRunEnum
->nextElement(); //Text
799 uno::Reference
<beans::XPropertySet
> xPropertySet(xRunEnum
->nextElement(), uno::UNO_QUERY
);
801 CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"),
802 getProperty
<OUString
>(xPropertySet
, "TextPortionType"));
803 uno::Reference
<container::XNamed
> xBookmark(
804 getProperty
<uno::Reference
<beans::XPropertySet
>>(xPropertySet
, "Bookmark"), uno::UNO_QUERY
);
806 // Critical test: does TextField's bookmark name match cross-reference?
807 const OUString
& sTextFieldName(xBookmark
->getName());
808 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
809 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(
810 xTextFieldsSupplier
->getTextFields());
811 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
812 CPPUNIT_ASSERT(xFields
->hasMoreElements());
813 xPropertySet
.set(xFields
->nextElement(), uno::UNO_QUERY
);
814 CPPUNIT_ASSERT_EQUAL(sTextFieldName
, getProperty
<OUString
>(xPropertySet
, "SourceName"));
816 uno::Reference
<text::XBookmarksSupplier
> xBookmarksSupplier(mxComponent
, uno::UNO_QUERY
);
817 uno::Reference
<container::XIndexAccess
> xBookmarksByIdx(xBookmarksSupplier
->getBookmarks(),
819 // TextFields should not be turned into real bookmarks.
820 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), xBookmarksByIdx
->getCount());
822 // The actual name isn't critical, but if it fails, it is worth asking why.
823 CPPUNIT_ASSERT_EQUAL(OUString("Text1"), sTextFieldName
);
826 DECLARE_OOXMLEXPORT_TEST(testTdf117504_numberingIndent
, "tdf117504_numberingIndent.docx")
828 OUString sName
= getProperty
<OUString
>(getParagraph(1), "NumberingStyleName");
829 CPPUNIT_ASSERT_MESSAGE("Paragraph has numbering style", !sName
.isEmpty());
831 uno::Reference
<beans::XPropertySet
> xPropertySet(
832 getStyles("ParagraphStyles")->getByName("Revision"), uno::UNO_QUERY
);
833 CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty
<sal_Int32
>(xPropertySet
, "ParaBottomMargin"));
834 xPropertySet
.set(getStyles("ParagraphStyles")->getByName("Body Note"), uno::UNO_QUERY
);
835 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xPropertySet
, "ParaBottomMargin"));
838 DECLARE_OOXMLEXPORT_TEST(testWatermark
, "watermark.docx")
840 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
842 sal_Int32 nHeight
= xShape
->getSize().Height
;
845 sal_Int32 nDifference
= 5150 - nHeight
;
846 std::stringstream ss
;
847 ss
<< "Difference: " << nDifference
<< " TotalHeight: " << nHeight
;
848 CPPUNIT_ASSERT_MESSAGE(ss
.str(), nDifference
<= 4);
849 CPPUNIT_ASSERT_MESSAGE(ss
.str(), nDifference
>= -4);
852 DECLARE_OOXMLEXPORT_TEST(testWatermarkTrim
, "tdf114308.docx")
854 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
857 sal_Int32 nHeight
= xShape
->getSize().Height
;
858 sal_Int32 nDifference
= 8729 - nHeight
;
859 std::stringstream ss
;
860 ss
<< "Difference: " << nDifference
<< " TotalHeight: " << nHeight
;
861 CPPUNIT_ASSERT_MESSAGE(ss
.str(), nDifference
<= 4);
862 CPPUNIT_ASSERT_MESSAGE(ss
.str(), nDifference
>= -4);
865 CPPUNIT_TEST_FIXTURE(Test
, testVMLShapetypeId
)
867 loadAndSave("controlshape.fodt");
868 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
869 // must be _x0000_t<NR>
871 "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[1]/w:r/mc:AlternateContent/"
872 "mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wps:wsp/wps:txbx/"
873 "w:txbxContent/w:p/w:r/w:object/v:shapetype",
876 "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[1]/w:r/mc:AlternateContent/"
877 "mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wps:wsp/wps:txbx/"
878 "w:txbxContent/w:p/w:r/w:object/v:shape",
879 "type", "#_x0000_t75");
882 CPPUNIT_TEST_FIXTURE(Test
, testTdf73547
)
884 loadAndSave("tdf73547-dash.docx");
885 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
886 double nD
= getXPath(pXmlDoc
, "//a:custDash/a:ds[1]", "d").toDouble();
887 CPPUNIT_ASSERT_DOUBLES_EQUAL(105000.0, nD
, 5000.0); // was 100000
888 double nSp
= getXPath(pXmlDoc
, "//a:custDash/a:ds[1]", "sp").toDouble();
889 CPPUNIT_ASSERT_DOUBLES_EQUAL(35000.0, nSp
, 5000.0); // was 100000
892 DECLARE_OOXMLEXPORT_TEST(testTdf119143
, "tdf119143.docx")
894 // The runs inside <w:dir> were ignored
895 const OUString sParaText
= getParagraph(1)->getString();
896 CPPUNIT_ASSERT_EQUAL(
897 OUString(u
"عندما يريد العالم أن يتكلّم ، فهو يتحدّث "
899 u
"يونيكود. تسجّل الآن لحضور المؤتمر الدولي العاشر "
900 u
"ليونيكود (Unicode Conference)، الذي سيعقد في 10-12 "
901 u
"آذار 1997 بمدينة مَايِنْتْس، ألمانيا. و سيجمع المؤتمر "
902 u
"بين خبراء من كافة قطاعات الصناعة على الشبكة "
903 u
"العالمية انترنيت ويونيكود، حيث ستتم، على الصعيدين "
904 u
"الدولي والمحلي على حد سواء مناقشة سبل استخدام "
905 u
"يونكود في النظم القائمة وفيما يخص التطبيقات "
906 u
"الحاسوبية، الخطوط، تصميم النصوص والحوسبة متعددة "
911 CPPUNIT_TEST_FIXTURE(Test
, testTdf105444
)
913 loadAndSave("tdf105444.docx");
914 xmlDocUniquePtr pXmlComm
= parseExport("word/comments.xml");
915 // there is no extra paragraph on Win32, only a single one.
916 assertXPath(pXmlComm
, "/w:comments/w:comment/w:p", 1);
919 DECLARE_OOXMLEXPORT_TEST(testTdf117137
, "tdf117137.docx")
921 // Paragraphs were not part of a numbering anymore after roundtrip.
922 uno::Reference
<beans::XPropertySet
> xPara1(getParagraph(1), uno::UNO_QUERY
);
923 CPPUNIT_ASSERT(xPara1
.is());
924 CPPUNIT_ASSERT(xPara1
->getPropertyValue("NumberingRules").hasValue());
926 uno::Reference
<beans::XPropertySet
> xPara2(getParagraph(2), uno::UNO_QUERY
);
927 CPPUNIT_ASSERT(xPara2
.is());
928 CPPUNIT_ASSERT(xPara2
->getPropertyValue("NumberingRules").hasValue());
930 uno::Reference
<beans::XPropertySet
> xPara3(getParagraph(3), uno::UNO_QUERY
);
931 CPPUNIT_ASSERT(xPara3
.is());
932 CPPUNIT_ASSERT(xPara3
->getPropertyValue("NumberingRules").hasValue());
935 CPPUNIT_TEST_FIXTURE(Test
, testTdf138780
)
937 loadAndReload("tdf138780.odt");
938 CPPUNIT_ASSERT_EQUAL(1, getPages());
939 // Paragraphs were not part of a numbering anymore after roundtrip.
940 uno::Reference
<beans::XPropertySet
> xPara1(getParagraph(1), uno::UNO_QUERY
);
941 CPPUNIT_ASSERT(xPara1
.is());
942 CPPUNIT_ASSERT(xPara1
->getPropertyValue("NumberingRules").hasValue());
944 uno::Reference
<beans::XPropertySet
> xPara2(getParagraph(2), uno::UNO_QUERY
);
945 CPPUNIT_ASSERT(xPara2
.is());
946 CPPUNIT_ASSERT(xPara2
->getPropertyValue("NumberingRules").hasValue());
948 uno::Reference
<beans::XPropertySet
> xPara3(getParagraph(3), uno::UNO_QUERY
);
949 CPPUNIT_ASSERT(xPara3
.is());
950 CPPUNIT_ASSERT(xPara3
->getPropertyValue("NumberingRules").hasValue());
953 CPPUNIT_TEST_FIXTURE(Test
, testTdf134618
)
955 loadAndSave("tdf134618.doc");
956 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
958 //Without the fix it in place, it would have failed with
961 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r", 1);
963 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent", 2);
966 CPPUNIT_TEST_FIXTURE(Test
, testTdf99631
)
968 loadAndSave("tdf99631.docx");
969 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
971 assertXPath(pXmlDoc
, "//w:object", 2);
972 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r/w:object", 2);
973 // first XSLX OLE object (1:1 scale)
974 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r[1]/w:object[1]", "dxaOrig", "2561");
975 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r[1]/w:object[1]", "dyaOrig", "513");
976 // second XLSX OLE object (same content + 1 row, but zoomed)
977 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r[2]/w:object[1]", "dxaOrig", "2561");
978 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r[2]/w:object[1]", "dyaOrig", "769");
981 CPPUNIT_TEST_FIXTURE(Test
, testTdf138899
)
983 loadAndSave("tdf138899.docx");
984 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
985 // This was 6, not removed empty temporary paragraph at the end of the section
986 assertXPath(pXmlDocument
, "/w:document/w:body/w:p", 5);
988 //tdf#134385: Paragraph property to "add space between paragraphs of the same style" was lost
989 assertXPath(pXmlDocument
, "//w:p[1]/w:pPr/w:contextualSpacing", "val", "false");
992 CPPUNIT_TEST_FIXTURE(Test
, testTdf122563
)
994 loadAndSave("tdf122563.docx");
995 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
997 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r/w:object", 1);
998 // Size of the embedded OLE spreadsheet was the bad "width:28.35pt;height:28.35pt"
999 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:r[1]/w:object/v:shape", "style",
1000 "width:255.75pt;height:63.75pt;mso-wrap-distance-right:0pt");
1003 CPPUNIT_TEST_FIXTURE(Test
, testTdf94628
)
1005 loadAndReload("tdf94628.docx");
1006 uno::Reference
<beans::XPropertySet
> xPropertySet(
1007 getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
1008 uno::Reference
<container::XIndexAccess
> xLevels(
1009 xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
1010 uno::Sequence
<beans::PropertyValue
> aProps
;
1011 xLevels
->getByIndex(0) >>= aProps
; // 1st level
1013 OUString sBulletChar
= std::find_if(std::cbegin(aProps
), std::cend(aProps
),
1014 [](const beans::PropertyValue
& rValue
) {
1015 return rValue
.Name
== "BulletChar";
1017 ->Value
.get
<OUString
>();
1018 // Actually for 'BLACK UPPER RIGHT TRIANGLE' is \u25E5
1019 // But we use Wingdings 3 font here, so code is different
1020 CPPUNIT_ASSERT_EQUAL(OUString(u
"\uF07B"), sBulletChar
);
1023 DECLARE_OOXMLEXPORT_TEST(testTdf122594
, "tdf122594.docx")
1025 // test import/export of ActiveTable (visible sheet) of embedded XLSX OLE objects
1026 uno::Reference
<text::XTextEmbeddedObjectsSupplier
> xEmbeddedObjectsSupplier(mxComponent
,
1028 uno::Reference
<container::XIndexAccess
> xObjects(xEmbeddedObjectsSupplier
->getEmbeddedObjects(),
1030 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), xObjects
->getCount());
1032 uno::Reference
<beans::XPropertySet
> xSheets
;
1033 xObjects
->getByIndex(0) >>= xSheets
;
1035 uno::Reference
<frame::XModel
> xModel
;
1036 xSheets
->getPropertyValue("Model") >>= xModel
;
1037 uno::Reference
<document::XViewDataSupplier
> xViewDataSupplier(xModel
, uno::UNO_QUERY
);
1039 uno::Reference
<container::XIndexAccess
> xIndexAccess(xViewDataSupplier
->getViewData());
1040 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), xIndexAccess
->getCount());
1042 uno::Sequence
<beans::PropertyValue
> aSeq
;
1043 sal_Int32 nCheck
= 0;
1044 if (xIndexAccess
->getByIndex(0) >>= aSeq
)
1046 sal_Int32
nCount(aSeq
.getLength());
1047 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
1049 OUString
sName(aSeq
[i
].Name
);
1050 if (sName
== "ActiveTable")
1053 if (aSeq
[i
].Value
>>= sTabName
)
1055 // Sheet2, not Sheet1
1056 CPPUNIT_ASSERT_EQUAL(OUString("Munka2"), sTabName
);
1060 // tdf#122624 column and row viewarea positions
1061 else if (sName
== "PositionLeft")
1064 aSeq
[i
].Value
>>= nPosLeft
;
1065 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), nPosLeft
);
1068 else if (sName
== "PositionTop")
1071 aSeq
[i
].Value
>>= nPosTop
;
1072 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), nPosTop
);
1078 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), nCheck
);
1081 CPPUNIT_TEST_FIXTURE(Test
, testLanguageInGroupShape
)
1083 loadAndSave("tdf131922_LanguageInGroupShape.docx");
1084 // tdf#131922: Check if good language is used in shape group texts
1085 xmlDocUniquePtr pXml
= parseExport("word/document.xml");
1087 "/w:document/w:body/w:p[7]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/"
1088 "a:graphic/a:graphicData/wpg:wgp/"
1089 "wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:lang",
1093 DECLARE_OOXMLEXPORT_TEST(testTdf116883
, "tdf116883.docx")
1096 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1097 CPPUNIT_ASSERT_EQUAL(OUString("1>1>"), getProperty
<OUString
>(xPara
, "ListLabelString"));
1100 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(2), uno::UNO_QUERY
);
1101 CPPUNIT_ASSERT_EQUAL(OUString("1>2>"), getProperty
<OUString
>(xPara
, "ListLabelString"));
1104 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(3), uno::UNO_QUERY
);
1105 CPPUNIT_ASSERT_EQUAL(OUString("1>2>1>1>"), getProperty
<OUString
>(xPara
, "ListLabelString"));
1108 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(4), uno::UNO_QUERY
);
1109 CPPUNIT_ASSERT_EQUAL(OUString("1>2>2>"), getProperty
<OUString
>(xPara
, "ListLabelString"));
1112 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(5), uno::UNO_QUERY
);
1113 CPPUNIT_ASSERT_EQUAL(OUString("1>2>3>"), getProperty
<OUString
>(xPara
, "ListLabelString"));
1116 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(6), uno::UNO_QUERY
);
1117 CPPUNIT_ASSERT_EQUAL(OUString("1>1)"), getProperty
<OUString
>(xPara
, "ListLabelString"));
1120 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(7), uno::UNO_QUERY
);
1121 CPPUNIT_ASSERT_EQUAL(OUString("1>2)"), getProperty
<OUString
>(xPara
, "ListLabelString"));
1124 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(8), uno::UNO_QUERY
);
1125 CPPUNIT_ASSERT_EQUAL(OUString("1>2>1<1)"), getProperty
<OUString
>(xPara
, "ListLabelString"));
1128 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(9), uno::UNO_QUERY
);
1129 CPPUNIT_ASSERT_EQUAL(OUString("1>2.2)"), getProperty
<OUString
>(xPara
, "ListLabelString"));
1132 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(10), uno::UNO_QUERY
);
1133 CPPUNIT_ASSERT_EQUAL(OUString("1>2.3)"), getProperty
<OUString
>(xPara
, "ListLabelString"));
1137 CPPUNIT_TEST_FIXTURE(Test
, testTdf131420
)
1139 loadAndSave("tdf131420.docx");
1140 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
1141 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:pPr/w:pBdr/w:top");
1144 DECLARE_OOXMLEXPORT_TEST(testTdf80526_word_wrap
, "tdf80526_word_wrap.docx")
1146 // tdf#80526: check whether the "wrap" property has been set
1147 // TODO: fix export too
1150 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1151 CPPUNIT_ASSERT_EQUAL(false, getProperty
<bool>(xShape
, "TextWordWrap"));
1154 DECLARE_OOXMLEXPORT_TEST(testTdf118521_marginsLR
, "tdf118521_marginsLR.docx")
1156 // tdf#118521 paragraphs with direct formatting of only some of left, right, or first margins have
1157 // lost the other unset margins coming from paragraph style, getting a bad margin from the default style instead
1159 uno::Reference
<beans::XPropertySet
> xMyStyle(getStyles("ParagraphStyles")->getByName("MyStyle"),
1161 // from paragraph style - this is what direct formatting should equal
1162 sal_Int32 nMargin
= getProperty
<sal_Int32
>(xMyStyle
, "ParaLeftMargin");
1163 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nMargin
);
1164 // from direct formatting
1165 CPPUNIT_ASSERT_EQUAL(nMargin
, getProperty
<sal_Int32
>(getParagraph(1), "ParaLeftMargin"));
1167 nMargin
= getProperty
<sal_Int32
>(xMyStyle
, "ParaRightMargin");
1168 CPPUNIT_ASSERT_EQUAL(sal_Int32(1900), nMargin
);
1169 CPPUNIT_ASSERT_EQUAL(nMargin
, getProperty
<sal_Int32
>(getParagraph(2), "ParaRightMargin"));
1170 CPPUNIT_ASSERT_EQUAL(sal_Int32(882),
1171 getProperty
<sal_Int32
>(getParagraph(2), "ParaFirstLineIndent"));
1174 DECLARE_OOXMLEXPORT_TEST(testTdf104797
, "tdf104797.docx")
1176 // check moveFrom and moveTo
1177 CPPUNIT_ASSERT_EQUAL(OUString("Will this sentence be duplicated?"),
1178 getParagraph(1)->getString());
1179 CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(1), 1)->getString());
1180 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 3), "RedlineType"));
1181 CPPUNIT_ASSERT_EQUAL(OUString("Delete"),
1182 getProperty
<OUString
>(getRun(getParagraph(1), 3), "RedlineType"));
1183 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getRun(getParagraph(1), 3), "IsStart"));
1184 CPPUNIT_ASSERT_EQUAL(
1185 OUString("This is a filler sentence. Will this sentence be duplicated ADDED STUFF?"),
1186 getParagraph(2)->getString());
1187 CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(2), 1)->getString());
1188 CPPUNIT_ASSERT_EQUAL(OUString("This is a filler sentence."),
1189 getRun(getParagraph(2), 2)->getString());
1190 CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(2), 3)->getString());
1191 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 3), "RedlineType"));
1192 CPPUNIT_ASSERT_EQUAL(OUString("Insert"),
1193 getProperty
<OUString
>(getRun(getParagraph(2), 3), "RedlineType"));
1194 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getRun(getParagraph(2), 3), "IsStart"));
1196 CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(2), 4)->getString());
1197 CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(2), 5)->getString());
1198 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 6), "RedlineType"));
1199 CPPUNIT_ASSERT_EQUAL(OUString("Insert"),
1200 getProperty
<OUString
>(getRun(getParagraph(2), 6), "RedlineType"));
1201 CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(2), 7)->getString());
1202 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 7), "RedlineType"));
1203 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(getRun(getParagraph(2), 7), "IsStart"));
1204 CPPUNIT_ASSERT_EQUAL(OUString("Will this sentence be duplicated"),
1205 getRun(getParagraph(2), 8)->getString());
1206 CPPUNIT_ASSERT_EQUAL(OUString(" ADDED STUFF"), getRun(getParagraph(2), 11)->getString());
1207 CPPUNIT_ASSERT_EQUAL(OUString("?"), getRun(getParagraph(2), 14)->getString());
1210 DECLARE_OOXMLEXPORT_TEST(testTdf145720
, "tdf104797.docx")
1212 // check moveFromRangeStart/End and moveToRangeStart/End (to keep tracked text moving)
1215 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1216 // These were 0 (missing move*FromRange* elements)
1217 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", 1);
1218 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:moveFromRangeEnd", 1);
1219 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", 1);
1220 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:moveToRangeEnd", 1);
1223 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", "name",
1225 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", "name",
1228 // mandatory authors and dates
1229 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", "author",
1231 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", "author",
1233 // no date (anonymized change)
1234 // This failed, date was exported as w:date="0-00-00T00:00:00Z", and later "1970-01-01T00:00:00Z"
1235 assertXPathNoAttribute(pXmlDoc
, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart",
1237 assertXPathNoAttribute(pXmlDoc
, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart",
1242 DECLARE_OOXMLEXPORT_TEST(testTdf150166
, "tdf150166.docx")
1244 // check moveFromRangeStart/End and moveToRangeStart/End (to keep tracked text moving)
1247 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1248 assertXPath(pXmlDoc
, "//w:moveFromRangeStart", 0);
1249 // This was 2 (missing RangeStart elements, but bad unpaired RangeEnds)
1250 assertXPath(pXmlDoc
, "//w:moveFromRangeEnd", 0);
1252 // These were 0 (moveFrom, moveTo and t)
1253 assertXPath(pXmlDoc
, "//w:del", 11);
1254 assertXPath(pXmlDoc
, "//w:ins", 12);
1255 assertXPath(pXmlDoc
, "//w:delText", 7);
1257 // no more moveFrom/moveTo to avoid of problems with ToC
1258 assertXPath(pXmlDoc
, "//w:moveFrom", 0);
1259 assertXPath(pXmlDoc
, "//w:moveTo", 0);
1263 DECLARE_OOXMLEXPORT_TEST(testTdf143510
, "TC-table-DnD-move.docx")
1265 // check moveFromRangeStart/End and moveToRangeStart/End for tracked table move by drag & drop
1268 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1269 // This was 0 (missing tracked table row deletion/insertion)
1270 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr/w:trPr/w:del", 2);
1271 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl[2]/w:tr/w:trPr/w:ins", 2);
1275 DECLARE_OOXMLEXPORT_TEST(testTdf143510_table_from_row
, "TC-table-Separate-Move.docx")
1277 // check moveFromRangeStart/End and moveToRangeStart/End for tracked table move by drag & drop
1280 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1281 // This was 0 (missing tracked table row deletion/insertion)
1282 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr/w:trPr/w:del", 1);
1283 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr[3]/w:trPr/w:del", 1);
1284 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl[2]/w:tr", 1);
1285 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl[2]/w:tr/w:trPr/w:ins", 1);
1289 DECLARE_OOXMLEXPORT_TEST(testTdf143510_within_table
, "TC-table-rowDND.docx")
1291 // check moveFromRangeStart/End and moveToRangeStart/End for tracked table row move by DnD
1294 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1295 // This was 0 (missing tracked table row deletion/insertion)
1296 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:trPr/w:del", 1);
1297 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:trPr/w:ins", 1);
1301 DECLARE_OOXMLEXPORT_TEST(testTdf143510_within_table2
, "TC-table-rowDND-front.docx")
1303 // check moveFromRangeStart/End and moveToRangeStart/End for tracked table row move by DnD
1306 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1307 // This was 0 (missing tracked table row deletion/insertion)
1308 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:trPr/w:ins", 1);
1309 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:trPr/w:del", 1);
1313 DECLARE_OOXMLEXPORT_TEST(testTdf150824
, "tdf150824.fodt")
1315 // check tracked table row insertion (stored in a single redline)
1318 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1319 // This was 0 (missing tracked table row deletion/insertion)
1320 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:trPr/w:ins", 1);
1321 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:ins", 1);
1322 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:trPr/w:ins", 1);
1326 DECLARE_OOXMLEXPORT_TEST(testTdf157011
, "tdf157011_ins_del_empty_cols.docx")
1328 // check tracked table column insertions and deletions with empty cells
1331 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1333 // This was 1 (missing tracked table cell insertions)
1334 assertXPath(pXmlDoc
, "//w:ins", 3);
1336 // This was 4 (missing tracked table cell deletions)
1337 assertXPath(pXmlDoc
, "//w:del", 6);
1339 // tdf#157187 This was false (dummy w:tc/w:p/w:sdt/w:sdtContent content box)
1340 assertXPath(pXmlDoc
, "//w:tc/w:p/w:del", 6);
1341 assertXPath(pXmlDoc
, "//w:tc/w:p/w:ins", 3);
1345 DECLARE_OOXMLEXPORT_TEST(testTdf150824_regression
, "ooo30436-1-minimized.sxw")
1347 // There should be no crash during loading of the document
1348 // so, let's check just how much pages we have
1349 CPPUNIT_ASSERT_EQUAL(2, getPages());
1352 DECLARE_OOXMLEXPORT_TEST(testTdf113608_runAwayNumbering
, "tdf113608_runAwayNumbering.docx")
1354 // check that an incorrect numbering style is not applied
1355 // after removing a w:r-less paragraph
1356 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty
<OUString
>(getParagraph(2), "NumberingStyleName"));
1359 DECLARE_OOXMLEXPORT_TEST(testTdf119188_list_margin_in_cell
, "tdf119188_list_margin_in_cell.docx")
1361 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1362 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(),
1364 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1365 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1367 // lists with auto margins in cells: top margin of the first paragraph is zero,
1368 // but not the bottom margin of the last paragraph, also other list items have got
1371 CPPUNIT_ASSERT_EQUAL(
1372 static_cast<sal_Int32
>(0),
1373 getProperty
<sal_Int32
>(getParagraphOfText(1, xCell
->getText()), "ParaTopMargin"));
1374 CPPUNIT_ASSERT_EQUAL(
1375 static_cast<sal_Int32
>(0),
1376 getProperty
<sal_Int32
>(getParagraphOfText(1, xCell
->getText()), "ParaBottomMargin"));
1377 CPPUNIT_ASSERT_EQUAL(
1378 static_cast<sal_Int32
>(0),
1379 getProperty
<sal_Int32
>(getParagraphOfText(2, xCell
->getText()), "ParaTopMargin"));
1380 CPPUNIT_ASSERT_EQUAL(
1381 static_cast<sal_Int32
>(0),
1382 getProperty
<sal_Int32
>(getParagraphOfText(2, xCell
->getText()), "ParaBottomMargin"));
1383 CPPUNIT_ASSERT_EQUAL(
1384 static_cast<sal_Int32
>(0),
1385 getProperty
<sal_Int32
>(getParagraphOfText(3, xCell
->getText()), "ParaTopMargin"));
1386 CPPUNIT_ASSERT_EQUAL(
1387 static_cast<sal_Int32
>(494),
1388 getProperty
<sal_Int32
>(getParagraphOfText(3, xCell
->getText()), "ParaBottomMargin"));
1391 CPPUNIT_TEST_FIXTURE(Test
, testChart_BorderLine_Style
)
1393 loadAndSave("Chart_BorderLine_Style.docx");
1394 /* DOCX containing Chart with BorderLine Style as Dash Type should get preserved
1395 * inside an XML tag <a:prstDash> with value "dash", "sysDot, "lgDot", etc.
1397 xmlDocUniquePtr pXmlDoc
= parseExport("word/charts/chart1.xml");
1398 assertXPath(pXmlDoc
,
1399 "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:spPr/a:ln/a:prstDash",
1401 assertXPath(pXmlDoc
,
1402 "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[2]/c:spPr/a:ln/a:prstDash",
1404 assertXPath(pXmlDoc
,
1405 "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[3]/c:spPr/a:ln/a:prstDash",
1409 CPPUNIT_TEST_FIXTURE(Test
, testChart_Plot_BorderLine_Style
)
1411 loadAndSave("Chart_Plot_BorderLine_Style.docx");
1412 /* DOCX containing Chart wall (plot area) and Chart Page with BorderLine Style as Dash Type
1413 * should get preserved inside an XML tag <a:prstDash> with value "dash", "sysDot, "lgDot", etc.
1415 xmlDocUniquePtr pXmlDoc
= parseExport("word/charts/chart1.xml");
1416 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:ln/a:prstDash", "val",
1418 assertXPath(pXmlDoc
, "/c:chartSpace/c:spPr/a:ln/a:prstDash", "val", "sysDash");
1421 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesDeletedEmptyParagraph
)
1423 loadAndSave("testTrackChangesDeletedEmptyParagraph.docx");
1424 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1425 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:pPr/w:rPr/w:del");
1428 CPPUNIT_TEST_FIXTURE(Test
, testTrackChangesEmptyParagraphsInADeletion
)
1430 loadAndSave("testTrackChangesEmptyParagraphsInADeletion.docx");
1431 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1432 for (int i
= 1; i
< 12; ++i
)
1433 assertXPath(pXmlDoc
,
1434 "/w:document/w:body/w:p[" + OString::number(i
) + "]/w:pPr/w:rPr/w:del");
1437 CPPUNIT_TEST_FIXTURE(Test
, testTdf149708
)
1439 loadAndSave("tdf149708.docx");
1440 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1441 // keep tracked insertion of a list item
1442 // This was 0 (missing tracked insertion of the paragraph mark)
1443 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:ins");
1446 CPPUNIT_TEST_FIXTURE(Test
, testTdf149707
)
1448 loadAndSave("tdf149711.docx");
1449 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1450 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:moveFrom");
1451 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/w:moveTo");
1452 // These were missing
1453 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:moveFrom");
1454 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/w:pPr/w:rPr/w:moveTo");
1457 CPPUNIT_TEST_FIXTURE(Test
, testTdf70234
)
1459 loadAndSave("tdf70234.docx");
1460 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1461 // import field with tracked deletion
1462 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:del/w:r[1]/w:fldChar");
1464 // export multiple runs of a field with tracked deletion
1465 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:del/w:r", 6);
1467 // export w:delInstrText
1468 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:del/w:r/w:delInstrText");
1471 CPPUNIT_TEST_FIXTURE(Test
, testTdf115212
)
1473 loadAndSave("tdf115212.docx");
1474 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1475 // export field with tracked deletion
1476 assertXPath(pXmlDoc
, "//w:p[2]/w:del[1]/w:r[1]/w:fldChar");
1479 CPPUNIT_TEST_FIXTURE(Test
, testTdf126243
)
1481 loadAndSave("tdf120338.docx");
1482 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1483 // export change tracking rejection data for tracked paragraph style change
1484 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[11]/w:pPr/w:pPrChange/w:pPr/w:pStyle", "val",
1488 CPPUNIT_TEST_FIXTURE(Test
, testTdf126245
)
1490 loadAndSave("tdf126245.docx");
1491 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1492 // export change tracking rejection data for tracked numbering change
1493 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:pPrChange/w:pPr/w:numPr/w:numId", "val",
1497 CPPUNIT_TEST_FIXTURE(Test
, testTdf124491
)
1499 loadAndSave("tdf124491.docx");
1500 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1501 // import format change of empty lines, FIXME: change w:r with w:pPr in export
1502 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/*/w:rPr/w:rPrChange");
1503 // empty line without format change
1504 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/*/w:rPrChange", 0);
1505 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/*/*/w:rPrChange", 0);
1508 CPPUNIT_TEST_FIXTURE(Test
, testTdf143911
)
1510 loadAndSave("tdf126206.docx");
1511 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1512 // export format change of text portions
1513 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r[2]/w:rPr/w:rPrChange");
1514 // This was without tracked bold formatting
1515 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r[2]/w:rPr/w:rPrChange/w:rPr/w:b");
1518 CPPUNIT_TEST_FIXTURE(Test
, testTdf105485
)
1520 loadAndSave("tdf105485.docx");
1521 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1522 // import change tracking of deleted comments
1523 assertXPath(pXmlDoc
, "//w:del/w:r/w:commentReference");
1526 CPPUNIT_TEST_FIXTURE(Test
, testTdf125894
)
1528 loadAndSave("tdf125894.docx");
1529 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1530 // import change tracking in frames
1531 assertXPath(pXmlDoc
, "//w:del", 2);
1532 assertXPath(pXmlDoc
, "//w:ins");
1535 CPPUNIT_TEST_FIXTURE(Test
, testTdf149388
)
1537 // see also testTdf132371
1538 loadAndSave("tdf132271.docx");
1539 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1540 // import change tracking in floating tables
1541 // (don't recognize tracked text moving during the import,
1542 // because the text is too short and it's only a single word)
1543 assertXPath(pXmlDoc
, "//w:del", 2);
1544 assertXPath(pXmlDoc
, "//w:ins", 2);
1545 assertXPath(pXmlDoc
, "//w:moveFrom", 0);
1546 assertXPath(pXmlDoc
, "//w:moveTo", 0);
1549 CPPUNIT_TEST_FIXTURE(Test
, testTdf132271
)
1551 // see also testTdf149388
1552 loadAndSave("tdf149388.docx");
1553 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1554 // import change tracking in floating tables
1557 assertXPath(pXmlDoc
, "//w:del", 2);
1558 assertXPath(pXmlDoc
, "//w:ins", 2);
1559 assertXPath(pXmlDoc
, "//w:moveFrom", 0);
1560 assertXPath(pXmlDoc
, "//w:moveTo", 0);
1564 assertXPath(pXmlDoc
, "//w:del", 1);
1565 assertXPath(pXmlDoc
, "//w:ins", 1);
1566 // tracked text moving recognized during the import
1567 assertXPath(pXmlDoc
, "//w:moveFrom", 1);
1568 assertXPath(pXmlDoc
, "//w:moveTo", 1);
1572 CPPUNIT_TEST_FIXTURE(Test
, testTdf149388_fly
)
1574 // see also testTdf136667
1575 loadAndSave("tdf136667.docx");
1576 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1577 // import change tracking in floating tables
1578 assertXPath(pXmlDoc
, "//w:del", 2);
1579 assertXPath(pXmlDoc
, "//w:ins", 4);
1580 assertXPath(pXmlDoc
, "//w:moveFrom", 0);
1581 assertXPath(pXmlDoc
, "//w:moveTo", 0);
1584 CPPUNIT_TEST_FIXTURE(Test
, testTdf136667
)
1586 // see also testTdf149388_fly
1587 loadAndSave("tdf149388_fly.docx");
1588 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1589 // import change tracking in floating tables
1592 assertXPath(pXmlDoc
, "//w:del", 2);
1593 assertXPath(pXmlDoc
, "//w:ins", 4);
1594 assertXPath(pXmlDoc
, "//w:moveFrom", 0);
1595 assertXPath(pXmlDoc
, "//w:moveTo", 0);
1599 assertXPath(pXmlDoc
, "//w:del", 1);
1600 assertXPath(pXmlDoc
, "//w:ins", 3);
1601 // tracked text moving recognized during the import
1602 assertXPath(pXmlDoc
, "//w:moveFrom", 1);
1603 assertXPath(pXmlDoc
, "//w:moveTo", 1);
1607 CPPUNIT_TEST_FIXTURE(Test
, testTdf136850
)
1609 loadAndSave("tdf136850.docx");
1610 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1611 // import change tracking in floating tables
1612 assertXPath(pXmlDoc
, "//w:del");
1615 CPPUNIT_TEST_FIXTURE(Test
, testTdf128156
)
1617 loadAndSave("tdf128156.docx");
1618 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1619 // keep tracked insertion of a paragraph
1620 // This was 0 before 350972a8bffc1a74b531e0336954bf54b1356025,
1621 // and 1 later (missing tracked insertion of the paragraph mark)
1622 assertXPath(pXmlDoc
, "//w:ins", 2);
1625 CPPUNIT_TEST_FIXTURE(Test
, testTdf125546
)
1627 loadAndSave("tdf125546.docx");
1628 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1629 // compress redlines (it was 15)
1630 assertXPath(pXmlDoc
, "//w:rPrChange", 2);
1633 CPPUNIT_TEST_FIXTURE(Test
, testLabelWidthAndPosition_Left_FirstLineIndent
)
1635 loadAndSave("Hau_min_list2.fodt");
1636 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1637 // list is LABEL_WIDTH_AND_POSITION with SvxAdjust::Left
1639 // a) all LTR cases with no number text look good in Word
1640 // 1) negative first line indent on paragraph:
1641 // no list width/indent: this one was 0 previously; this looks good
1642 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "start", "0");
1643 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "hanging", "399");
1644 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "end", "0");
1646 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:pPr/w:ind", "start", "567");
1647 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:pPr/w:ind", "hanging", "966");
1648 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:pPr/w:ind", "end", "0");
1650 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:pPr/w:ind", "start", "567");
1651 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:pPr/w:ind", "hanging", "399");
1652 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:pPr/w:ind", "end", "0");
1653 // list width + list indent:
1654 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/w:pPr/w:ind", "start", "1134");
1655 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/w:pPr/w:ind", "hanging", "966");
1656 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/w:pPr/w:ind", "end", "0");
1657 // 2) positive first line indent on paragraph:
1658 // no list width/indent:
1659 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[5]/w:pPr/w:ind", "start", "0");
1660 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[5]/w:pPr/w:ind", "firstLine", "420");
1661 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[5]/w:pPr/w:ind", "end", "0");
1663 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[6]/w:pPr/w:ind", "start", "567");
1664 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[6]/w:pPr/w:ind", "hanging", "147");
1665 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[6]/w:pPr/w:ind", "end", "0");
1667 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "start", "567");
1668 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "firstLine", "420");
1669 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "end", "0");
1670 // list width + list indent:
1671 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[8]/w:pPr/w:ind", "start", "1134");
1672 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[8]/w:pPr/w:ind", "hanging", "147");
1673 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[8]/w:pPr/w:ind", "end", "0");
1674 // b) all LTR cases with number text: the indent looks good but some tabs are wrong
1675 // 1) negative first line indent on paragraph:
1676 // no list width/indent: this one was 0 previously; this looks good
1677 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[9]/w:pPr/w:ind", "start", "0");
1678 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[9]/w:pPr/w:ind", "hanging", "399");
1679 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[9]/w:pPr/w:ind", "end", "0");
1681 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[10]/w:pPr/w:ind", "start", "567");
1682 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[10]/w:pPr/w:ind", "hanging", "966");
1683 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[10]/w:pPr/w:ind", "end", "0");
1685 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[11]/w:pPr/w:ind", "start", "567");
1686 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[11]/w:pPr/w:ind", "hanging", "399");
1687 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[11]/w:pPr/w:ind", "end", "0");
1688 // list width + list indent:
1689 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[12]/w:pPr/w:ind", "start", "1134");
1690 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[12]/w:pPr/w:ind", "hanging", "966");
1691 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[12]/w:pPr/w:ind", "end", "0");
1692 // 2) positive first line indent on paragraph:
1693 // no list width/indent:
1694 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[13]/w:pPr/w:ind", "start", "0");
1695 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[13]/w:pPr/w:ind", "firstLine", "420");
1696 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[13]/w:pPr/w:ind", "end", "0");
1698 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[14]/w:pPr/w:ind", "start", "567");
1699 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[14]/w:pPr/w:ind", "hanging", "147");
1700 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[14]/w:pPr/w:ind", "end", "0");
1702 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[15]/w:pPr/w:ind", "start", "567");
1703 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[15]/w:pPr/w:ind", "firstLine", "420");
1704 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[15]/w:pPr/w:ind", "end", "0");
1705 // list width + list indent:
1706 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[16]/w:pPr/w:ind", "start", "1134");
1707 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[16]/w:pPr/w:ind", "hanging", "147");
1708 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[16]/w:pPr/w:ind", "end", "0");
1709 // (w:p[17] is empty)
1711 // a) only RTL cases with no number text and no width/indent look good in Word
1712 // 1) negative first line indent on paragraph:
1713 // no list width/indent
1714 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[18]/w:pPr/w:ind", "start", "0");
1715 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[18]/w:pPr/w:ind", "hanging", "399");
1716 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[18]/w:pPr/w:ind", "end", "0");
1717 // 2) positive first line indent on paragraph:
1718 // no list width/indent:
1719 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[22]/w:pPr/w:ind", "start", "0");
1720 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[22]/w:pPr/w:ind", "firstLine", "420");
1721 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[22]/w:pPr/w:ind", "end", "0");
1722 // b) RTL cases with number text: the indent looks good but some tabs are wrong
1723 // 1) negative first line indent on paragraph:
1724 // no list width/indent
1725 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[26]/w:pPr/w:ind", "start", "0");
1726 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[26]/w:pPr/w:ind", "hanging", "399");
1727 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[26]/w:pPr/w:ind", "end", "0");
1728 // 2) positive first line indent on paragraph:
1729 // no list width/indent:
1730 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[30]/w:pPr/w:ind", "start", "0");
1731 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[30]/w:pPr/w:ind", "firstLine", "420");
1732 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[30]/w:pPr/w:ind", "end", "0");
1733 // TODO: other cases
1736 CPPUNIT_TEST_FIXTURE(Test
, testTdf124604
)
1738 loadAndSave("tdf124604.docx");
1739 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1740 // If the numbering comes from a base style, indentation of the base style has also priority.
1741 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "start", "0");
1744 CPPUNIT_TEST_FIXTURE(Test
, testTdf95374
)
1746 loadAndSave("tdf95374.docx");
1747 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1748 // Numbering disabled by non-existent numId=0, disabling also inheritance of indentation of parent styles
1749 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "hanging", "0");
1750 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "start", "1136");
1753 DECLARE_OOXMLEXPORT_TEST(testTdf108493
, "tdf108493.docx")
1755 uno::Reference
<beans::XPropertySet
> xPara7(getParagraph(7), uno::UNO_QUERY
);
1756 // set in the paragraph (709 twips)
1757 CPPUNIT_ASSERT_EQUAL(sal_Int32(1251), getProperty
<sal_Int32
>(xPara7
, "ParaLeftMargin"));
1758 // set in the numbering style (this was 0)
1759 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1251), getProperty
<sal_Int32
>(xPara7
, "ParaFirstLineIndent"));
1762 DECLARE_OOXMLEXPORT_TEST(testTdf118691
, "tdf118691.docx")
1764 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1765 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(),
1767 // Text "Before" stays in the first cell, not removed before the table because of
1768 // bad handling of <w:cr>
1769 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1770 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
1771 CPPUNIT_ASSERT_EQUAL(OUString("Before\nAfter"), xCell
->getString());
1774 DECLARE_OOXMLEXPORT_TEST(testTdf64264
, "tdf64264.docx")
1776 // DOCX table rows with tblHeader setting mustn't modify the count of the
1777 // repeated table header rows, when there is rows before them without tblHeader settings.
1778 xmlDocUniquePtr pDump
= parseLayoutDump();
1779 CPPUNIT_ASSERT_EQUAL(2, getPages());
1781 // table starts on page 1 and finished on page 2
1782 // and it has got only a single repeating header line
1783 assertXPath(pDump
, "/root/page[2]/body/tab", 1);
1784 assertXPath(pDump
, "/root/page[2]/body/tab/row", 47);
1785 CPPUNIT_ASSERT_EQUAL(OUString("Repeating Table Header"),
1786 parseDump("/root/page[2]/body/tab/row[1]/cell[1]/txt/text()"));
1787 CPPUNIT_ASSERT_EQUAL(OUString("Text"),
1788 parseDump("/root/page[2]/body/tab/row[2]/cell[1]/txt/text()"));
1791 DECLARE_OOXMLEXPORT_TEST(testTdf58944RepeatingTableHeader
, "tdf58944-repeating-table-header.docx")
1793 // DOCX tables with more than 10 repeating header lines imported without repeating header lines
1794 // as a workaround for MSO's limitation of header line repetition
1795 xmlDocUniquePtr pDump
= parseLayoutDump();
1796 CPPUNIT_ASSERT_EQUAL(2, getPages());
1798 // table starts on page 1 and finished on page 2
1799 // instead of showing only a part of it on page 2
1800 assertXPath(pDump
, "/root/page[1]/body/tab", 1);
1801 assertXPath(pDump
, "/root/page[1]/body/tab/row", 11);
1802 CPPUNIT_ASSERT_EQUAL(OUString("Test1"),
1803 parseDump("/root/page[2]/body/tab/row[1]/cell[1]/txt/text()"));
1804 CPPUNIT_ASSERT_EQUAL(OUString("Test2"),
1805 parseDump("/root/page[2]/body/tab/row[2]/cell[1]/txt/text()"));
1808 CPPUNIT_TEST_FIXTURE(Test
, testTdf81100
)
1810 loadAndSave("tdf81100.docx");
1811 xmlDocUniquePtr pXmlDoc
= parseExport("word/styles.xml");
1812 CPPUNIT_ASSERT(pXmlDoc
);
1813 // keep "repeat table header" setting of table styles
1814 assertXPath(pXmlDoc
, "/w:styles/w:style/w:tblStylePr/w:trPr/w:tblHeader", 4);
1816 xmlDocUniquePtr pDump
= parseLayoutDump();
1817 CPPUNIT_ASSERT_EQUAL(3, getPages());
1819 // table starts on page 1 and finished on page 2
1820 // and it has got only a single repeating header line
1821 assertXPath(pDump
, "/root/page[2]/body/tab[1]", 1);
1822 assertXPath(pDump
, "/root/page[2]/body/tab[1]/row", 2);
1823 assertXPath(pDump
, "/root/page[3]/body/tab", 1);
1824 if (!isExported()) // TODO export tblHeader=false
1825 assertXPath(pDump
, "/root/page[3]/body/tab/row", 1);
1828 CPPUNIT_TEST_FIXTURE(Test
, testTdf88496
)
1830 loadAndReload("tdf88496.docx");
1831 // Switch off repeating header, there is no place for it.
1832 // Now there are only 3 pages with complete table content
1833 // instead of a 51-page long table only with header.
1834 CPPUNIT_ASSERT_EQUAL(3, getPages());
1835 // (this appears to have the correct result now?)
1836 // FIXME: this actually has 3 pages but SwWrtShell::SttPg() puts the cursor
1837 // into the single SwTextFrame in the follow-flow-row at the top of the
1838 // table but that SwTextFrame 1105 should not exist and the cursor ends up
1839 // at the end of its master frame 848 instead; the problem is somewhere in
1840 // SwTextFrame::FormatAdjust() which first determines nNew = 1 but then
1841 // grows this frame anyway so that the follow is empty, but nothing
1842 // invalidates 1105 again.
1845 CPPUNIT_TEST_FIXTURE(Test
, testTdf77417
)
1847 loadAndReload("tdf77417.docx");
1848 // MSO 2010 compatibility mode: terminating white spaces are ignored in tables.
1849 // This was 3 pages with the first invisible blank page.
1850 CPPUNIT_ASSERT_EQUAL(2, getPages());
1853 CPPUNIT_TEST_FIXTURE(Test
, testTdf130494
)
1855 loadAndSave("tdf130494.docx");
1856 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1857 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:pPr/w:rPr/w:highlight", "val",
1859 // keep direct formatting of table cell paragraph with removed highlighting
1860 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:r/w:rPr/w:highlight", 0);
1863 CPPUNIT_TEST_FIXTURE(Test
, testTdf130690
)
1865 loadAndSave("tdf130690.docx");
1866 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1867 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:pPr/w:rPr/w:highlight", "val",
1869 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:r[1]/w:rPr/w:highlight", 1);
1870 // keep direct formatting of table cell paragraph with removed highlighting
1871 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:r[2]/w:rPr/w:highlight", 0);
1874 CPPUNIT_TEST_FIXTURE(Test
, testTdf105215
)
1876 loadAndSave("tdf105215.docx");
1877 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1878 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:pPr/w:rPr/w:rFonts", "ascii",
1879 "Linux Libertine G");
1881 // These were "Linux Libertine G"
1882 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r/w:rPr", 5);
1883 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[1]/w:rPr/w:rFonts", "ascii",
1884 "Lohit Devanagari");
1885 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[2]/w:rPr/w:rFonts", "ascii",
1886 "Lohit Devanagari");
1887 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[3]/w:rPr/w:rFonts", "ascii",
1888 "Lohit Devanagari");
1889 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[4]/w:rPr/w:rFonts", "ascii",
1890 "Lohit Devanagari");
1891 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[5]/w:rPr/w:rFonts", "ascii",
1892 "Lohit Devanagari");
1895 CPPUNIT_TEST_FIXTURE(Test
, testTdf135187
)
1897 loadAndSave("tdf135187.docx");
1898 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1899 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p/w:pPr/w:rPr/w:b", 0);
1900 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:p/w:pPr/w:rPr/w:b", 1);
1901 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[1]/w:p/w:pPr/w:rPr/w:b", 1);
1903 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b", 1);
1904 assertXPathNoAttribute(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b",
1907 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b", 1);
1908 assertXPathNoAttribute(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b",
1910 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b", 1);
1911 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b", "val",
1915 CPPUNIT_TEST_FIXTURE(Test
, testTdf136617
)
1917 loadAndSave("tdf136617.docx");
1920 CPPUNIT_ASSERT_EQUAL(1, getPages());
1922 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1923 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:p[2]/w:pPr/w:rPr/w:sz", "val",
1927 CPPUNIT_TEST_FIXTURE(Test
, testTdf121597TrackedDeletionOfMultipleParagraphs
)
1929 loadAndSave("tdf121597.odt");
1930 CPPUNIT_ASSERT_EQUAL(1, getPages());
1931 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1933 // check paragraphs with removed paragraph mark
1934 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:del");
1935 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:del");
1936 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/w:pPr/w:rPr/w:del");
1937 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[5]/w:pPr/w:rPr/w:del");
1938 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[7]/w:pPr/w:rPr/w:del");
1939 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[10]/w:pPr/w:rPr/w:del");
1942 CPPUNIT_TEST_FIXTURE(Test
, testTdf141660
)
1944 loadAndSave("tdf141660.docx");
1945 CPPUNIT_ASSERT_EQUAL(1, getPages());
1946 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1948 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[2]/w:footnoteReference", "id", "2");
1949 // w:del is imported correctly with its footnote
1950 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:del[2]/w:r/w:footnoteReference", "id", "3");
1951 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:r/w:footnoteReference", "id", "4");
1954 CPPUNIT_TEST_FIXTURE(Test
, testTdf133643
)
1956 loadAndSave("tdf133643.doc");
1957 CPPUNIT_ASSERT_EQUAL(1, getPages());
1958 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1960 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[1]/w:fldChar", "fldCharType",
1964 "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[1]/w:fldChar/w:ffData/w:ddList/w:listEntry[1]",
1965 "val", "Bourgoin-Jallieu, ");
1968 "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[1]/w:fldChar/w:ffData/w:ddList/w:listEntry[2]",
1969 "val", "Fontaine, ");
1971 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[2]/w:instrText",
1974 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[3]/w:fldChar", "fldCharType",
1976 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[5]/w:fldChar", "fldCharType",
1979 // Without the fix in place, this w:r wouldn't exist
1980 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[6]/w:t",
1981 "le 22 fevrier 2013");
1984 DECLARE_OOXMLEXPORT_TEST(testTdf123189_tableBackground
, "table-black_fill.docx")
1986 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1987 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(),
1989 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
1991 uno::Reference
<table::XCell
> xCell
= xTable
->getCellByName("A1");
1992 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT
, getProperty
<Color
>(xCell
, "BackColor"));
1995 DECLARE_OOXMLEXPORT_TEST(testTdf116084
, "tdf116084.docx")
1997 // tracked line is not a single text portion: w:del is recognized within w:ins
1998 CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(1), 1)->getString());
1999 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 1), "RedlineType"));
2000 CPPUNIT_ASSERT_EQUAL(OUString("There "), getRun(getParagraph(1), 2)->getString());
2001 CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(1), 4)->getString());
2002 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 4), "RedlineType"));
2003 CPPUNIT_ASSERT_EQUAL(OUString("must"), getRun(getParagraph(1), 5)->getString());
2006 CPPUNIT_TEST_FIXTURE(Test
, testTdf116084_anonymized
)
2008 loadAndSave("tdf116084.docx");
2009 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
2010 // w:del in w:ins is exported correctly
2011 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:del/w:r/w:delText", "must");
2013 // no date (anonymized changes)
2014 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins[@date]", 0);
2015 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:del[@w:date]", 0);
2017 // w:ins and w:del have w:author attributes, and the same
2018 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:del[@w:author]", 1);
2019 OUString sAuthor
= getXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins[2]", "author");
2020 OUString sAuthor2
= getXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:del", "author");
2021 CPPUNIT_ASSERT_EQUAL(sAuthor
, sAuthor2
);
2024 DECLARE_OOXMLEXPORT_TEST(testTdf121176
, "tdf121176.docx")
2026 // w:del is imported correctly when it is in a same size w:ins
2027 CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(1), 1)->getString());
2028 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 1), "RedlineType"));
2029 CPPUNIT_ASSERT_EQUAL(OUString("must"), getRun(getParagraph(1), 2)->getString());
2032 CPPUNIT_TEST_FIXTURE(Test
, testTdf121176_anonymized
)
2034 loadAndSave("tdf121176.docx");
2035 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
2036 // w:del in w:ins is exported correctly
2037 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:del/w:r/w:delText", "must");
2039 // no date (anonymized changes)
2040 assertXPathNoAttribute(pXmlDoc
, "/w:document/w:body/w:p/w:ins", "date");
2041 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:del[@w:date]", 0);
2043 // w:ins and w:del have w:author attributes, and the same
2044 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:del[@w:author]", 1);
2045 OUString sAuthor
= getXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins", "author");
2046 OUString sAuthor2
= getXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:del", "author");
2047 CPPUNIT_ASSERT_EQUAL(sAuthor
, sAuthor2
);
2050 CPPUNIT_TEST_FIXTURE(Test
, testTdf128913
)
2052 loadAndSave("tdf128913.docx");
2053 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
2054 // w:ins and w:del are imported correctly, if they contain only inline images
2055 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:r/w:drawing/wp:inline/a:graphic");
2056 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:del/w:r/w:drawing/wp:inline/a:graphic");
2059 CPPUNIT_TEST_FIXTURE(Test
, testTdf142700
)
2061 loadAndSave("tdf142700.docx");
2062 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
2063 // w:ins and w:del are imported correctly, if they contain only images anchored to character
2064 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:r/w:drawing/wp:anchor/a:graphic");
2065 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:del/w:r/w:drawing/wp:anchor/a:graphic");
2068 CPPUNIT_TEST_FIXTURE(Test
, testTdf142387
)
2070 loadAndSave("tdf142387.docx");
2071 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
2072 // w:del in w:ins is exported correctly (only w:del was exported)
2073 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p/w:ins/w:del/w:r/w:delText", "inserts ");
2076 CPPUNIT_TEST_FIXTURE(Test
, testTdf147892
)
2078 loadAndSave("tdf147892.fodt");
2079 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
2080 // w:del in w:ins is exported correctly
2081 // (both w:del and w:ins were exported for para marker)
2082 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:del", 1);
2083 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:ins", 0);
2086 DECLARE_OOXMLEXPORT_TEST(testTdf123054
, "tdf123054.docx")
2088 CPPUNIT_ASSERT_EQUAL(OUString("No Spacing"),
2089 getProperty
<OUString
>(getParagraph(20), "ParaStyleName"));
2092 DECLARE_OOXMLEXPORT_TEST(testTdf67207_MERGEFIELD_DATABASE
, "tdf67207.docx")
2094 // database fields use the database "database" and its table "Sheet1"
2095 uno::Reference
<beans::XPropertySet
> xTextField
2096 = getProperty
<uno::Reference
<beans::XPropertySet
>>(getRun(getParagraph(2), 2), "TextField");
2097 CPPUNIT_ASSERT(xTextField
.is());
2098 uno::Reference
<lang::XServiceInfo
> xServiceInfo(xTextField
, uno::UNO_QUERY_THROW
);
2099 uno::Reference
<text::XDependentTextField
> xDependent(xTextField
, uno::UNO_QUERY_THROW
);
2101 CPPUNIT_ASSERT(xServiceInfo
->supportsService("com.sun.star.text.TextField.Database"));
2103 xTextField
->getPropertyValue("Content") >>= sValue
;
2104 CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8("<c1>"), sValue
);
2106 uno::Reference
<beans::XPropertySet
> xFiledMaster
= xDependent
->getTextFieldMaster();
2107 uno::Reference
<lang::XServiceInfo
> xFiledMasterServiceInfo(xFiledMaster
, uno::UNO_QUERY_THROW
);
2110 xFiledMasterServiceInfo
->supportsService("com.sun.star.text.fieldmaster.Database"));
2112 // Defined properties: DataBaseName, Name, DataTableName, DataColumnName, DependentTextFields, DataCommandType, InstanceName, DataBaseURL
2113 CPPUNIT_ASSERT(xFiledMaster
->getPropertyValue("DataBaseName") >>= sValue
);
2114 CPPUNIT_ASSERT_EQUAL(OUString("database"), sValue
);
2115 sal_Int32 nCommandType
;
2116 CPPUNIT_ASSERT(xFiledMaster
->getPropertyValue("DataCommandType") >>= nCommandType
);
2117 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nCommandType
); // css::sdb::CommandType::TABLE
2118 CPPUNIT_ASSERT(xFiledMaster
->getPropertyValue("DataTableName") >>= sValue
);
2119 CPPUNIT_ASSERT_EQUAL(OUString("Sheet1"), sValue
);
2120 CPPUNIT_ASSERT(xFiledMaster
->getPropertyValue("DataColumnName") >>= sValue
);
2121 CPPUNIT_ASSERT_EQUAL(OUString("c1"), sValue
);
2122 CPPUNIT_ASSERT(xFiledMaster
->getPropertyValue("InstanceName") >>= sValue
);
2123 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.text.fieldmaster.DataBase.database.Sheet1.c1"),
2127 CPPUNIT_TEST_FIXTURE(Test
, testTdf101122_noFillForCustomShape
)
2129 loadAndSave("tdf101122_noFillForCustomShape.odt");
2130 CPPUNIT_ASSERT_EQUAL(2, getShapes());
2131 CPPUNIT_ASSERT_EQUAL(1, getPages());
2132 // tdf#101122 check whether the "F" (noFill) option has been exported to docx
2133 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
2135 assertXPath(pXmlDoc
,
2136 "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/"
2137 "a:graphic/a:graphicData/wps:wsp/wps:spPr/a:custGeom/a:pathLst/a:path",
2139 assertXPathNoAttribute(
2141 "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
2142 "a:graphicData/wps:wsp/wps:spPr/a:custGeom/a:pathLst/a:path",
2145 // The (tdf124678_no_leading_paragraph.odt, tdf124678_with_leading_paragraph.odt) documents are the same,
2147 // - tdf124678_no_leading_paragraph.odt doesn't contain leading empty paragraph
2148 // before the first section
2150 CPPUNIT_TEST_FIXTURE(Test
, testTdf124678_case1
)
2152 loadAndReload("tdf124678_no_leading_paragraph.odt");
2153 CPPUNIT_ASSERT_EQUAL(2, getPages());
2154 CPPUNIT_ASSERT_EQUAL_MESSAGE("First page header text", OUString(""),
2155 parseDump("/root/page[1]/header/txt"));
2156 CPPUNIT_ASSERT_EQUAL_MESSAGE("Second page header text", OUString("HEADER"),
2157 parseDump("/root/page[2]/header/txt"));
2160 // The (tdf124678_no_leading_paragraph.odt, tdf124678_with_leading_paragraph.odt) documents are the same,
2162 // - tdf124678_no_leading_paragraph.odt doesn't contain leading empty paragraph
2163 // before the first section
2165 CPPUNIT_TEST_FIXTURE(Test
, testTdf124678_case2
)
2167 loadAndReload("tdf124678_with_leading_paragraph.odt");
2168 CPPUNIT_ASSERT_EQUAL(2, getPages());
2169 CPPUNIT_ASSERT_EQUAL_MESSAGE("First page header text", OUString(""),
2170 parseDump("/root/page[1]/header/txt"));
2171 CPPUNIT_ASSERT_EQUAL_MESSAGE("Second page header text", OUString("HEADER"),
2172 parseDump("/root/page[2]/header/txt"));
2175 static bool lcl_nearEqual(const sal_Int32 nNumber1
, const sal_Int32 nNumber2
,
2176 sal_Int32 nMaxDiff
= 5)
2178 return std::abs(nNumber1
- nNumber2
) < nMaxDiff
;
2181 DECLARE_OOXMLEXPORT_TEST(testTdf119952_negativeMargins
, "tdf119952_negativeMargins.docx")
2183 // With negative margins (in MS Word) one can set up header (or footer) that overlaps with the body.
2184 // LibreOffice unable to display that, so when importing negative margins,
2185 // the header (or footer) converted to a flyframe, anchored to the header..
2186 // that can overlap with the body, and will appear like in Word.
2187 // This conversion modifies the document [i.e. replacing header text with a textbox...]
2188 // but its DOCX export looks the same, as the original document in Word, too.
2189 xmlDocUniquePtr pDump
= parseLayoutDump();
2191 //Check layout positions / sizes
2192 sal_Int32 nLeftHead
= getXPath(pDump
, "//page[1]/header/infos/bounds", "left").toInt32();
2193 sal_Int32 nLeftBody
= getXPath(pDump
, "//page[1]/body/infos/bounds", "left").toInt32();
2194 sal_Int32 nLeftFoot
= getXPath(pDump
, "//page[1]/footer/infos/bounds", "left").toInt32();
2196 = getXPath(pDump
, "//page[1]/header/txt/anchored/fly/infos/bounds", "left").toInt32();
2198 = getXPath(pDump
, "//page[1]/footer/txt/anchored/fly/infos/bounds", "left").toInt32();
2200 sal_Int32 nTopHead
= getXPath(pDump
, "//page[1]/header/infos/bounds", "top").toInt32();
2201 sal_Int32 nTopBody
= getXPath(pDump
, "//page[1]/body/infos/bounds", "top").toInt32();
2202 sal_Int32 nTopFoot
= getXPath(pDump
, "//page[1]/footer/infos/bounds", "top").toInt32();
2204 = getXPath(pDump
, "//page[1]/header/txt/anchored/fly/infos/bounds", "top").toInt32();
2206 = getXPath(pDump
, "//page[1]/footer/txt/anchored/fly/infos/bounds", "top").toInt32();
2208 sal_Int32 nHeightHead
= getXPath(pDump
, "//page[1]/header/infos/bounds", "height").toInt32();
2209 sal_Int32 nHeightBody
= getXPath(pDump
, "//page[1]/body/infos/bounds", "height").toInt32();
2210 sal_Int32 nHeightFoot
= getXPath(pDump
, "//page[1]/footer/infos/bounds", "height").toInt32();
2211 sal_Int32 nHeightHFly
2212 = getXPath(pDump
, "//page[1]/header/txt/anchored/fly/infos/bounds", "height").toInt32();
2213 sal_Int32 nHeightFFly
2214 = getXPath(pDump
, "//page[1]/footer/txt/anchored/fly/infos/bounds", "height").toInt32();
2215 sal_Int32 nHeightHFlyBound
2216 = getXPath(pDump
, "//page[1]/header/infos/prtBounds", "height").toInt32();
2217 sal_Int32 nHeightFFlyBound
2218 = getXPath(pDump
, "//page[1]/footer/infos/prtBounds", "height").toInt32();
2220 CPPUNIT_ASSERT(lcl_nearEqual(nLeftHead
, nLeftBody
));
2221 CPPUNIT_ASSERT(lcl_nearEqual(nLeftHead
, nLeftFoot
));
2222 CPPUNIT_ASSERT(lcl_nearEqual(nLeftHead
, nLeftHFly
));
2223 CPPUNIT_ASSERT(lcl_nearEqual(nLeftHead
, nLeftFFly
));
2225 CPPUNIT_ASSERT(lcl_nearEqual(nTopHead
, 851));
2226 CPPUNIT_ASSERT(lcl_nearEqual(nTopBody
, 1418));
2227 CPPUNIT_ASSERT(lcl_nearEqual(nTopFoot
, 15875));
2228 CPPUNIT_ASSERT(lcl_nearEqual(nTopHFly
, 851));
2230 // this seems to be an import bug
2232 CPPUNIT_ASSERT(lcl_nearEqual(nTopFFly
, 14403));
2234 CPPUNIT_ASSERT(lcl_nearEqual(nHeightHead
, 567));
2235 CPPUNIT_ASSERT(lcl_nearEqual(nHeightBody
, 14457));
2236 CPPUNIT_ASSERT(lcl_nearEqual(nHeightFoot
, 680));
2237 CPPUNIT_ASSERT(lcl_nearEqual(nHeightHFly
, 2152));
2238 CPPUNIT_ASSERT(lcl_nearEqual(nHeightFFly
, 2152));
2240 // after export these heights increase to like 567.
2241 // not sure if it is another import, or export bug... or just the result of the modified document
2244 CPPUNIT_ASSERT(lcl_nearEqual(nHeightHFlyBound
, 57));
2245 CPPUNIT_ASSERT(lcl_nearEqual(nHeightFFlyBound
, 57));
2248 //Check text of header/ footer
2249 CPPUNIT_ASSERT_EQUAL(
2253 "//page[1]/header/txt/anchored/fly/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
2255 CPPUNIT_ASSERT_EQUAL(
2259 "//page[1]/header/txt/anchored/fly/txt[8]/SwParaPortion/SwLineLayout/SwParaPortion",
2261 CPPUNIT_ASSERT_EQUAL(
2265 "//page[1]/footer/txt/anchored/fly/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
2267 CPPUNIT_ASSERT_EQUAL(
2271 "//page[1]/footer/txt/anchored/fly/txt[8]/SwParaPortion/SwLineLayout/SwParaPortion",
2274 CPPUNIT_ASSERT_EQUAL(
2278 "//page[2]/header/txt/anchored/fly/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
2280 CPPUNIT_ASSERT_EQUAL(
2284 "//page[2]/footer/txt/anchored/fly/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
2287 CPPUNIT_ASSERT_EQUAL(
2291 "//page[3]/header/txt/anchored/fly/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
2293 CPPUNIT_ASSERT_EQUAL(
2297 "//page[3]/header/txt/anchored/fly/txt[5]/SwParaPortion/SwLineLayout/SwParaPortion",
2300 CPPUNIT_ASSERT_EQUAL(OUString("f1 f2 f3 f4 f5 f6 "
2302 parseDump("/root/page[1]/header/txt/anchored/fly"));
2303 CPPUNIT_ASSERT_EQUAL(OUString(" f8 f7 f6 f5 "
2305 parseDump("/root/page[1]/footer/txt/anchored/fly"));
2306 CPPUNIT_ASSERT_EQUAL(OUString("p1"), parseDump("/root/page[2]/header/txt/anchored/fly"));
2307 CPPUNIT_ASSERT_EQUAL(OUString("p1"), parseDump("/root/page[2]/footer/txt/anchored/fly"));
2308 CPPUNIT_ASSERT_EQUAL(OUString(" aaaa bbbb cccc dddd eeee"),
2309 parseDump("/root/page[3]/header/txt/anchored/fly"));
2312 DECLARE_OOXMLEXPORT_TEST(testTdf143384_tableInFoot_negativeMargins
,
2313 "tdf143384_tableInFoot_negativeMargins.docx")
2315 // There should be no crash during loading of the document
2316 // so, let's check just how much pages we have
2317 CPPUNIT_ASSERT_EQUAL(1, getPages());
2320 CPPUNIT_PLUGIN_IMPLEMENT();
2322 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */