docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / sw / qa / extras / ooxmlexport / ooxmlexport12.cxx
blob902d2f5f33ebc2895d005b0cbbabec96b1b4c2f3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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
25 public:
26 Test()
27 : SwModelTestBase(u"/sw/qa/extras/ooxmlexport/data/"_ustr, u"Office Open XML Text"_ustr)
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(),
42 uno::UNO_QUERY);
43 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xBookmarksByIdx->getCount());
44 uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
45 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table0_full"_ustr));
46 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table0_label_and_number"_ustr));
47 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table0_caption_only"_ustr));
48 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table0_number_only"_ustr));
50 // Check bookmark text ranges
52 uno::Reference<text::XTextContent> xContent(
53 xBookmarksByName->getByName(u"Ref_Table0_full"_ustr), uno::UNO_QUERY);
54 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
55 CPPUNIT_ASSERT_EQUAL(u"Table 1: Table caption"_ustr, xRange->getString());
58 uno::Reference<text::XTextContent> xContent(
59 xBookmarksByName->getByName(u"Ref_Table0_label_and_number"_ustr), uno::UNO_QUERY);
60 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
61 CPPUNIT_ASSERT_EQUAL(u"Table 1"_ustr, xRange->getString());
64 uno::Reference<text::XTextContent> xContent(
65 xBookmarksByName->getByName(u"Ref_Table0_caption_only"_ustr), uno::UNO_QUERY);
66 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
67 CPPUNIT_ASSERT_EQUAL(u"Table caption"_ustr, xRange->getString());
70 uno::Reference<text::XTextContent> xContent(
71 xBookmarksByName->getByName(u"Ref_Table0_number_only"_ustr), uno::UNO_QUERY);
72 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
73 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, 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);
88 switch (nIndex)
90 // Full reference to table caption
91 case 0:
93 CPPUNIT_ASSERT(xServiceInfo->supportsService(
94 u"com.sun.star.text.TextField.GetReference"_ustr));
95 OUString sValue;
96 sal_Int16 nValue;
97 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
98 CPPUNIT_ASSERT_EQUAL(u"Table 1: Table caption"_ustr, sValue);
99 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
100 CPPUNIT_ASSERT_EQUAL(u"Ref_Table0_full"_ustr, sValue);
101 xPropertySet->getPropertyValue(u"SequenceNumber"_ustr) >>= nValue;
102 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
103 break;
105 // Page style reference / exported as simple page reference
106 case 1:
108 CPPUNIT_ASSERT(xServiceInfo->supportsService(
109 u"com.sun.star.text.TextField.GetReference"_ustr));
110 OUString sValue;
111 sal_Int16 nValue;
112 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
113 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, sValue);
114 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
115 CPPUNIT_ASSERT_EQUAL(u"Ref_Table0_full"_ustr, sValue);
116 xPropertySet->getPropertyValue(u"SequenceNumber"_ustr) >>= nValue;
117 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
118 break;
120 // Reference to table number
121 case 2:
123 CPPUNIT_ASSERT(xServiceInfo->supportsService(
124 u"com.sun.star.text.TextField.GetReference"_ustr));
125 OUString sValue;
126 sal_Int16 nValue;
127 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
128 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, sValue);
129 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
130 CPPUNIT_ASSERT_EQUAL(u"Ref_Table0_number_only"_ustr, sValue);
131 xPropertySet->getPropertyValue(u"SequenceNumber"_ustr) >>= nValue;
132 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
133 break;
135 // Reference to caption only
136 case 3:
138 CPPUNIT_ASSERT(xServiceInfo->supportsService(
139 u"com.sun.star.text.TextField.GetReference"_ustr));
140 OUString sValue;
141 sal_Int16 nValue;
142 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
143 CPPUNIT_ASSERT_EQUAL(u"Table caption"_ustr, sValue);
144 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
145 CPPUNIT_ASSERT_EQUAL(u"Ref_Table0_caption_only"_ustr, sValue);
146 xPropertySet->getPropertyValue(u"SequenceNumber"_ustr) >>= nValue;
147 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
148 break;
150 // Reference to category and number
151 case 4:
153 CPPUNIT_ASSERT(xServiceInfo->supportsService(
154 u"com.sun.star.text.TextField.GetReference"_ustr));
155 OUString sValue;
156 sal_Int16 nValue;
157 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
158 CPPUNIT_ASSERT_EQUAL(u"Table 1"_ustr, sValue);
159 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
160 CPPUNIT_ASSERT_EQUAL(u"Ref_Table0_label_and_number"_ustr, sValue);
161 xPropertySet->getPropertyValue(u"SequenceNumber"_ustr) >>= nValue;
162 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
163 break;
165 // Reference to page of the table
166 case 5:
168 CPPUNIT_ASSERT(xServiceInfo->supportsService(
169 u"com.sun.star.text.TextField.GetReference"_ustr));
170 OUString sValue;
171 sal_Int16 nValue;
172 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
173 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, sValue);
174 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
175 CPPUNIT_ASSERT_EQUAL(u"Ref_Table0_full"_ustr, sValue);
176 xPropertySet->getPropertyValue(u"SequenceNumber"_ustr) >>= nValue;
177 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
178 break;
180 // Above / below reference
181 case 6:
183 CPPUNIT_ASSERT(xServiceInfo->supportsService(
184 u"com.sun.star.text.TextField.GetReference"_ustr));
185 OUString sValue;
186 sal_Int16 nValue;
187 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
188 CPPUNIT_ASSERT_EQUAL(u"above"_ustr, sValue);
189 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
190 CPPUNIT_ASSERT_EQUAL(u"Ref_Table0_full"_ustr, sValue);
191 xPropertySet->getPropertyValue(u"SequenceNumber"_ustr) >>= nValue;
192 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nValue);
193 break;
195 default:
196 break;
198 ++nIndex;
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(),
214 uno::UNO_QUERY);
215 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(16), xBookmarksByIdx->getCount());
216 uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
217 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table0_full"_ustr));
218 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table0_label_and_number"_ustr));
219 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table0_caption_only"_ustr));
220 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table0_number_only"_ustr));
221 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table1_full"_ustr));
222 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table1_label_and_number"_ustr));
223 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table1_caption_only"_ustr));
224 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table1_number_only"_ustr));
225 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table2_full"_ustr));
226 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table2_label_and_number"_ustr));
227 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table2_caption_only"_ustr));
228 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table2_number_only"_ustr));
229 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table3_full"_ustr));
230 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table3_label_and_number"_ustr));
231 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table3_caption_only"_ustr));
232 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Table3_number_only"_ustr));
234 // Check bookmark text ranges
235 // First table's caption
237 uno::Reference<text::XTextContent> xContent(
238 xBookmarksByName->getByName(u"Ref_Table0_full"_ustr), uno::UNO_QUERY);
239 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
240 CPPUNIT_ASSERT_EQUAL(u"1. Table: Table caption"_ustr, xRange->getString());
243 uno::Reference<text::XTextContent> xContent(
244 xBookmarksByName->getByName(u"Ref_Table0_label_and_number"_ustr), uno::UNO_QUERY);
245 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
246 CPPUNIT_ASSERT_EQUAL(u"1. Table"_ustr, xRange->getString());
249 uno::Reference<text::XTextContent> xContent(
250 xBookmarksByName->getByName(u"Ref_Table0_caption_only"_ustr), uno::UNO_QUERY);
251 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
252 CPPUNIT_ASSERT_EQUAL(u"Table caption"_ustr, xRange->getString());
255 uno::Reference<text::XTextContent> xContent(
256 xBookmarksByName->getByName(u"Ref_Table0_number_only"_ustr), uno::UNO_QUERY);
257 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
258 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, xRange->getString());
260 // Second table's caption
262 uno::Reference<text::XTextContent> xContent(
263 xBookmarksByName->getByName(u"Ref_Table1_full"_ustr), uno::UNO_QUERY);
264 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
265 CPPUNIT_ASSERT_EQUAL(u"2. TableTable caption"_ustr, xRange->getString());
268 uno::Reference<text::XTextContent> xContent(
269 xBookmarksByName->getByName(u"Ref_Table1_label_and_number"_ustr), uno::UNO_QUERY);
270 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
271 CPPUNIT_ASSERT_EQUAL(u"2. Table"_ustr, xRange->getString());
274 uno::Reference<text::XTextContent> xContent(
275 xBookmarksByName->getByName(u"Ref_Table1_caption_only"_ustr), uno::UNO_QUERY);
276 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
277 CPPUNIT_ASSERT_EQUAL(u"Table caption"_ustr, xRange->getString());
280 uno::Reference<text::XTextContent> xContent(
281 xBookmarksByName->getByName(u"Ref_Table1_number_only"_ustr), uno::UNO_QUERY);
282 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
283 CPPUNIT_ASSERT_EQUAL(u"2"_ustr, xRange->getString());
285 // Third table's caption
287 uno::Reference<text::XTextContent> xContent(
288 xBookmarksByName->getByName(u"Ref_Table2_full"_ustr), uno::UNO_QUERY);
289 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
290 CPPUNIT_ASSERT_EQUAL(u"3) Table Table caption"_ustr, xRange->getString());
293 uno::Reference<text::XTextContent> xContent(
294 xBookmarksByName->getByName(u"Ref_Table2_label_and_number"_ustr), uno::UNO_QUERY);
295 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
296 CPPUNIT_ASSERT_EQUAL(u"3) Table"_ustr, xRange->getString());
299 uno::Reference<text::XTextContent> xContent(
300 xBookmarksByName->getByName(u"Ref_Table2_caption_only"_ustr), uno::UNO_QUERY);
301 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
302 CPPUNIT_ASSERT_EQUAL(u"Table caption"_ustr, xRange->getString());
305 uno::Reference<text::XTextContent> xContent(
306 xBookmarksByName->getByName(u"Ref_Table2_number_only"_ustr), uno::UNO_QUERY);
307 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
308 CPPUNIT_ASSERT_EQUAL(u"3"_ustr, xRange->getString());
310 // Fourth table's caption
312 uno::Reference<text::XTextContent> xContent(
313 xBookmarksByName->getByName(u"Ref_Table3_full"_ustr), uno::UNO_QUERY);
314 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
315 CPPUNIT_ASSERT_EQUAL(u"Table 4- Table caption"_ustr, xRange->getString());
318 uno::Reference<text::XTextContent> xContent(
319 xBookmarksByName->getByName(u"Ref_Table3_label_and_number"_ustr), uno::UNO_QUERY);
320 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
321 CPPUNIT_ASSERT_EQUAL(u"Table 4"_ustr, xRange->getString());
324 uno::Reference<text::XTextContent> xContent(
325 xBookmarksByName->getByName(u"Ref_Table3_caption_only"_ustr), uno::UNO_QUERY);
326 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
327 CPPUNIT_ASSERT_EQUAL(u"Table caption"_ustr, xRange->getString());
330 uno::Reference<text::XTextContent> xContent(
331 xBookmarksByName->getByName(u"Ref_Table3_number_only"_ustr), uno::UNO_QUERY);
332 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
333 CPPUNIT_ASSERT_EQUAL(u"4"_ustr, 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(),
348 uno::UNO_QUERY);
349 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(15), xBookmarksByIdx->getCount());
350 uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
351 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Drawing0_full"_ustr));
352 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Drawing0_label_and_number"_ustr));
353 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Drawing0_caption_only"_ustr));
354 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Drawing0_number_only"_ustr));
355 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Drawing1_full"_ustr));
357 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Illustration0_full"_ustr));
358 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Illustration0_label_and_number"_ustr));
359 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Illustration0_caption_only"_ustr));
360 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Illustration0_number_only"_ustr));
361 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Illustration1_caption_only"_ustr));
363 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Text0_full"_ustr));
364 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Text0_label_and_number"_ustr));
365 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Text0_caption_only"_ustr));
366 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Text0_number_only"_ustr));
367 CPPUNIT_ASSERT(xBookmarksByName->hasByName(u"Ref_Text1_label_and_number"_ustr));
369 // Check bookmark text ranges
370 // Cross references to shapes
372 uno::Reference<text::XTextContent> xContent(
373 xBookmarksByName->getByName(u"Ref_Drawing0_full"_ustr), uno::UNO_QUERY);
374 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
375 CPPUNIT_ASSERT_EQUAL(u"Drawing 1: A rectangle"_ustr, xRange->getString());
378 uno::Reference<text::XTextContent> xContent(
379 xBookmarksByName->getByName(u"Ref_Drawing0_label_and_number"_ustr), uno::UNO_QUERY);
380 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
381 CPPUNIT_ASSERT_EQUAL(u"Drawing 1"_ustr, xRange->getString());
384 uno::Reference<text::XTextContent> xContent(
385 xBookmarksByName->getByName(u"Ref_Drawing0_caption_only"_ustr), uno::UNO_QUERY);
386 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
387 CPPUNIT_ASSERT_EQUAL(u"A rectangle"_ustr, xRange->getString());
390 uno::Reference<text::XTextContent> xContent(
391 xBookmarksByName->getByName(u"Ref_Drawing0_number_only"_ustr), uno::UNO_QUERY);
392 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
393 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, xRange->getString());
396 uno::Reference<text::XTextContent> xContent(
397 xBookmarksByName->getByName(u"Ref_Drawing1_full"_ustr), uno::UNO_QUERY);
398 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
399 CPPUNIT_ASSERT_EQUAL(u"Drawing 2: a circle"_ustr, xRange->getString());
402 // Cross references to pictures
404 uno::Reference<text::XTextContent> xContent(
405 xBookmarksByName->getByName(u"Ref_Illustration0_full"_ustr), uno::UNO_QUERY);
406 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
407 CPPUNIT_ASSERT_EQUAL(u"Illustration 1: A picture"_ustr, xRange->getString());
410 uno::Reference<text::XTextContent> xContent(
411 xBookmarksByName->getByName(u"Ref_Illustration0_label_and_number"_ustr),
412 uno::UNO_QUERY);
413 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
414 CPPUNIT_ASSERT_EQUAL(u"Illustration 1"_ustr, xRange->getString());
417 uno::Reference<text::XTextContent> xContent(
418 xBookmarksByName->getByName(u"Ref_Illustration0_caption_only"_ustr), uno::UNO_QUERY);
419 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
420 CPPUNIT_ASSERT_EQUAL(u"A picture"_ustr, xRange->getString());
423 uno::Reference<text::XTextContent> xContent(
424 xBookmarksByName->getByName(u"Ref_Illustration0_number_only"_ustr), uno::UNO_QUERY);
425 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
426 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, xRange->getString());
429 uno::Reference<text::XTextContent> xContent(
430 xBookmarksByName->getByName(u"Ref_Illustration1_caption_only"_ustr), uno::UNO_QUERY);
431 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
432 CPPUNIT_ASSERT_EQUAL(u"another image"_ustr, xRange->getString());
435 // Cross references to text frames
437 uno::Reference<text::XTextContent> xContent(
438 xBookmarksByName->getByName(u"Ref_Text0_full"_ustr), uno::UNO_QUERY);
439 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
440 CPPUNIT_ASSERT_EQUAL(u"Text 1: A frame"_ustr, xRange->getString());
443 uno::Reference<text::XTextContent> xContent(
444 xBookmarksByName->getByName(u"Ref_Text0_label_and_number"_ustr), uno::UNO_QUERY);
445 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
446 CPPUNIT_ASSERT_EQUAL(u"Text 1"_ustr, xRange->getString());
449 uno::Reference<text::XTextContent> xContent(
450 xBookmarksByName->getByName(u"Ref_Text0_caption_only"_ustr), uno::UNO_QUERY);
451 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
452 CPPUNIT_ASSERT_EQUAL(u"A frame"_ustr, xRange->getString());
455 uno::Reference<text::XTextContent> xContent(
456 xBookmarksByName->getByName(u"Ref_Text0_number_only"_ustr), uno::UNO_QUERY);
457 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
458 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, xRange->getString());
461 uno::Reference<text::XTextContent> xContent(
462 xBookmarksByName->getByName(u"Ref_Text1_label_and_number"_ustr), uno::UNO_QUERY);
463 uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
464 CPPUNIT_ASSERT_EQUAL(u"Text 2"_ustr, xRange->getString());
467 // Check reference fields
468 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
469 uno::Reference<container::XEnumerationAccess> xFieldsAccess(
470 xTextFieldsSupplier->getTextFields());
471 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
472 CPPUNIT_ASSERT(xFields->hasMoreElements());
474 sal_uInt16 nIndex = 0;
475 while (xFields->hasMoreElements())
477 uno::Reference<lang::XServiceInfo> xServiceInfo(xFields->nextElement(), uno::UNO_QUERY);
478 uno::Reference<beans::XPropertySet> xPropertySet(xServiceInfo, uno::UNO_QUERY);
479 switch (nIndex)
481 // Reference to image number
482 case 0:
484 CPPUNIT_ASSERT(xServiceInfo->supportsService(
485 u"com.sun.star.text.TextField.GetReference"_ustr));
486 OUString sValue;
487 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
488 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, sValue);
489 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
490 CPPUNIT_ASSERT_EQUAL(u"Ref_Illustration0_number_only"_ustr, sValue);
491 break;
493 // Full reference to the circle shape
494 case 1:
496 CPPUNIT_ASSERT(xServiceInfo->supportsService(
497 u"com.sun.star.text.TextField.GetReference"_ustr));
498 OUString sValue;
499 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
500 CPPUNIT_ASSERT_EQUAL(u"Drawing 2: a circle"_ustr, sValue);
501 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
502 CPPUNIT_ASSERT_EQUAL(u"Ref_Drawing1_full"_ustr, sValue);
503 break;
505 // Caption only reference to the second picture
506 case 2:
508 CPPUNIT_ASSERT(xServiceInfo->supportsService(
509 u"com.sun.star.text.TextField.GetReference"_ustr));
510 OUString sValue;
511 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
512 CPPUNIT_ASSERT_EQUAL(u"another image"_ustr, sValue);
513 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
514 CPPUNIT_ASSERT_EQUAL(u"Ref_Illustration1_caption_only"_ustr, sValue);
515 break;
517 // Category and number reference to second text frame
518 case 3:
520 CPPUNIT_ASSERT(xServiceInfo->supportsService(
521 u"com.sun.star.text.TextField.GetReference"_ustr));
522 OUString sValue;
523 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
524 CPPUNIT_ASSERT_EQUAL(u"Text 2"_ustr, sValue);
525 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
526 CPPUNIT_ASSERT_EQUAL(u"Ref_Text1_label_and_number"_ustr, sValue);
527 break;
529 // Full reference to rectangle shape
530 case 4:
532 CPPUNIT_ASSERT(xServiceInfo->supportsService(
533 u"com.sun.star.text.TextField.GetReference"_ustr));
534 OUString sValue;
535 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
536 CPPUNIT_ASSERT_EQUAL(u"Drawing 1: A rectangle"_ustr, sValue);
537 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
538 CPPUNIT_ASSERT_EQUAL(u"Ref_Drawing0_full"_ustr, sValue);
539 break;
541 // Caption only reference to rectangle shape
542 case 5:
544 CPPUNIT_ASSERT(xServiceInfo->supportsService(
545 u"com.sun.star.text.TextField.GetReference"_ustr));
546 OUString sValue;
547 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
548 CPPUNIT_ASSERT_EQUAL(u"A rectangle"_ustr, sValue);
549 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
550 CPPUNIT_ASSERT_EQUAL(u"Ref_Drawing0_caption_only"_ustr, sValue);
551 break;
553 // Category and number reference to rectangle shape
554 case 6:
556 CPPUNIT_ASSERT(xServiceInfo->supportsService(
557 u"com.sun.star.text.TextField.GetReference"_ustr));
558 OUString sValue;
559 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
560 CPPUNIT_ASSERT_EQUAL(u"Drawing 1"_ustr, sValue);
561 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
562 CPPUNIT_ASSERT_EQUAL(u"Ref_Drawing0_label_and_number"_ustr, sValue);
563 break;
565 // Reference to rectangle shape's number
566 case 7:
568 CPPUNIT_ASSERT(xServiceInfo->supportsService(
569 u"com.sun.star.text.TextField.GetReference"_ustr));
570 OUString sValue;
571 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
572 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, sValue);
573 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
574 CPPUNIT_ASSERT_EQUAL(u"Ref_Drawing0_number_only"_ustr, sValue);
575 break;
577 // Full reference to first text frame
578 case 8:
580 CPPUNIT_ASSERT(xServiceInfo->supportsService(
581 u"com.sun.star.text.TextField.GetReference"_ustr));
582 OUString sValue;
583 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
584 CPPUNIT_ASSERT_EQUAL(u"Text 1: A frame"_ustr, sValue);
585 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
586 CPPUNIT_ASSERT_EQUAL(u"Ref_Text0_full"_ustr, sValue);
587 break;
589 // Caption only reference to first text frame
590 case 9:
592 CPPUNIT_ASSERT(xServiceInfo->supportsService(
593 u"com.sun.star.text.TextField.GetReference"_ustr));
594 OUString sValue;
595 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
596 CPPUNIT_ASSERT_EQUAL(u"A frame"_ustr, sValue);
597 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
598 CPPUNIT_ASSERT_EQUAL(u"Ref_Text0_caption_only"_ustr, sValue);
599 break;
601 // Category and number reference to first text frame
602 case 10:
604 CPPUNIT_ASSERT(xServiceInfo->supportsService(
605 u"com.sun.star.text.TextField.GetReference"_ustr));
606 OUString sValue;
607 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
608 CPPUNIT_ASSERT_EQUAL(u"Text 1"_ustr, sValue);
609 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
610 CPPUNIT_ASSERT_EQUAL(u"Ref_Text0_label_and_number"_ustr, sValue);
611 break;
613 // Number only reference to first text frame
614 case 11:
616 CPPUNIT_ASSERT(xServiceInfo->supportsService(
617 u"com.sun.star.text.TextField.GetReference"_ustr));
618 OUString sValue;
619 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
620 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, sValue);
621 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
622 CPPUNIT_ASSERT_EQUAL(u"Ref_Text0_number_only"_ustr, sValue);
623 break;
625 // Full reference to first picture
626 case 12:
628 CPPUNIT_ASSERT(xServiceInfo->supportsService(
629 u"com.sun.star.text.TextField.GetReference"_ustr));
630 OUString sValue;
631 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
632 CPPUNIT_ASSERT_EQUAL(u"Illustration 1: A picture"_ustr,
633 sValue.trim()); // fails on MAC without trim
634 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
635 CPPUNIT_ASSERT_EQUAL(u"Ref_Illustration0_full"_ustr, sValue);
636 break;
638 // Reference to first picture' caption
639 case 13:
641 CPPUNIT_ASSERT(xServiceInfo->supportsService(
642 u"com.sun.star.text.TextField.GetReference"_ustr));
643 OUString sValue;
644 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
645 CPPUNIT_ASSERT_EQUAL(u"A picture"_ustr, sValue);
646 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
647 CPPUNIT_ASSERT_EQUAL(u"Ref_Illustration0_caption_only"_ustr, sValue);
648 break;
650 // Category and number reference to first picture
651 case 14:
653 CPPUNIT_ASSERT(xServiceInfo->supportsService(
654 u"com.sun.star.text.TextField.GetReference"_ustr));
655 OUString sValue;
656 xPropertySet->getPropertyValue(u"CurrentPresentation"_ustr) >>= sValue;
657 CPPUNIT_ASSERT_EQUAL(u"Illustration 1"_ustr, sValue);
658 xPropertySet->getPropertyValue(u"SourceName"_ustr) >>= sValue;
659 CPPUNIT_ASSERT_EQUAL(u"Ref_Illustration0_label_and_number"_ustr, sValue);
660 break;
662 default:
663 break;
665 ++nIndex;
668 CPPUNIT_ASSERT_EQUAL(sal_uInt16(21), nIndex);
671 CPPUNIT_TEST_FIXTURE(Test, testTd112202)
673 auto verify = [this](bool bIsExport = false) {
674 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
676 // page 1 header: 1 paragraph, 2 flys, 1 draw object
677 assertXPath(pXmlDoc, "/root/page[1]/header/txt", 1);
678 assertXPath(pXmlDoc, "/root/page[1]/header/txt/anchored/fly", 2);
679 if (bIsExport) // somehow there's an additional shape on re-import?
680 assertXPath(pXmlDoc, "/root/page[1]/header/txt/anchored/SwAnchoredDrawObject", 2);
681 else
682 assertXPath(pXmlDoc, "/root/page[1]/header/txt/anchored/SwAnchoredDrawObject", 1);
684 // page 2 header: 3 paragraphs, 1 table, 1 fly on last paragraph
685 assertXPath(pXmlDoc, "/root/page[2]/header/txt", 3);
686 assertXPath(pXmlDoc, "/root/page[2]/header/tab", 1);
687 assertXPath(pXmlDoc, "/root/page[2]/header/txt/anchored/fly", 1);
689 // page 3 header: 1 table, 1 paragraph, no text
690 assertXPath(pXmlDoc, "/root/page[3]/header/txt", 1);
691 assertXPath(pXmlDoc, "/root/page[3]/header/tab", 1);
692 assertXPath(pXmlDoc,
693 "/root/page[3]/header/tab/row/cell/txt/SwParaPortion/SwLineLayout/child::*", 0);
694 assertXPath(pXmlDoc, "/root/page[3]/header//anchored", 0);
695 // tdf#149313: ensure 3rd page does not have extra empty paragraph at top
696 assertXPathContent(pXmlDoc, "/root/page[3]/body//txt", u"AUFGABENSTELLUNG");
698 // page 4 header: 1 table, 1 paragraph, with text
699 assertXPath(pXmlDoc, "/root/page[4]/header/txt", 1);
700 assertXPath(pXmlDoc, "/root/page[4]/header/tab", 1);
701 assertXPath(pXmlDoc,
702 "/root/page[4]/header/tab/row[1]/cell[1]/txt[1]/SwParaPortion/SwLineLayout/"
703 "SwParaPortion",
704 "portion", u"Titel der studentischen Arbeit");
705 assertXPath(pXmlDoc, "/root/page[4]/header//anchored", 0);
707 // page 5: same as page 4
708 assertXPath(pXmlDoc, "/root/page[5]/header/txt", 1);
709 assertXPath(pXmlDoc, "/root/page[5]/header/tab", 1);
710 assertXPath(pXmlDoc,
711 "/root/page[5]/header/tab/row[1]/cell[1]/txt[1]/SwParaPortion/SwLineLayout/"
712 "SwParaPortion",
713 "portion", u"Titel der studentischen Arbeit");
714 assertXPath(pXmlDoc, "/root/page[5]/header//anchored", 0);
716 // page 6: same as page 4
717 assertXPath(pXmlDoc, "/root/page[6]/header/txt", 1);
718 assertXPath(pXmlDoc, "/root/page[6]/header/tab", 1);
719 assertXPath(pXmlDoc,
720 "/root/page[6]/header/tab/row[1]/cell[1]/txt[1]/SwParaPortion/SwLineLayout/"
721 "SwParaPortion",
722 "portion", u"Titel der studentischen Arbeit");
723 assertXPath(pXmlDoc, "/root/page[6]/header//anchored", 0);
726 createSwDoc("090716_Studentische_Arbeit_VWS.docx");
727 verify();
728 saveAndReload(mpFilter);
729 verify(/*bIsExport*/ true);
732 CPPUNIT_TEST_FIXTURE(Test, testTdf79435_legacyInputFields)
734 loadAndReload("tdf79435_legacyInputFields.doc");
735 //using .doc input file to verify cross-format compatibility.
736 uno::Reference<text::XFormField> xFormField = getProperty<uno::Reference<text::XFormField>>(
737 getRun(getParagraph(5), 3), u"Bookmark"_ustr);
738 uno::Reference<container::XNameContainer> xParameters(xFormField->getParameters());
740 OUString sTmp;
741 // Doc import problems, so disabling tests
742 //xParameters->getByName("EntryMacro") >>= sTmp;
743 //CPPUNIT_ASSERT_EQUAL(OUString("test"), sTmp);
744 //xParameters->getByName("Help") >>= sTmp;
745 //CPPUNIT_ASSERT_EQUAL(OUString("F1Help"), sTmp);
746 //xParameters->getByName("ExitMacro") >>= sTmp;
747 //CPPUNIT_ASSERT_EQUAL(OUString("test"), sTmp);
748 xParameters->getByName(u"Hint"_ustr) >>= sTmp;
749 CPPUNIT_ASSERT_EQUAL(u"StatusHelp"_ustr, sTmp);
750 //xParameters->getByName("Content") >>= sTmp;
751 //CPPUNIT_ASSERT_EQUAL(OUString("Camelcase"), sTmp);
752 //xParameters->getByName("Format") >>= sTmp;
753 //CPPUNIT_ASSERT_EQUAL(OUString("TITLE CASE"), sTmp);
755 sal_uInt16 nMaxLength = 0;
756 xParameters->getByName(u"MaxLength"_ustr) >>= nMaxLength;
757 CPPUNIT_ASSERT_EQUAL_MESSAGE("Max Length", sal_uInt16(10), nMaxLength);
759 // too bad this is based on character runs - just found try trial and error.
760 xFormField = getProperty<uno::Reference<text::XFormField>>(getRun(getParagraph(6), 2),
761 u"Bookmark"_ustr);
762 xParameters.set(xFormField->getParameters());
763 xParameters->getByName(u"Type"_ustr) >>= sTmp;
764 CPPUNIT_ASSERT_EQUAL(u"calculated"_ustr, sTmp);
766 xFormField = getProperty<uno::Reference<text::XFormField>>(getRun(getParagraph(7), 2),
767 u"Bookmark"_ustr);
768 xParameters.set(xFormField->getParameters());
769 xParameters->getByName(u"Type"_ustr) >>= sTmp;
770 CPPUNIT_ASSERT_EQUAL(u"currentDate"_ustr, sTmp);
772 xFormField = getProperty<uno::Reference<text::XFormField>>(getRun(getParagraph(7), 7),
773 u"Bookmark"_ustr);
774 xParameters.set(xFormField->getParameters());
775 xParameters->getByName(u"Type"_ustr) >>= sTmp;
776 CPPUNIT_ASSERT_EQUAL(u"currentTime"_ustr, sTmp);
778 xFormField = getProperty<uno::Reference<text::XFormField>>(getRun(getParagraph(8), 2),
779 u"Bookmark"_ustr);
780 xParameters.set(xFormField->getParameters());
781 xParameters->getByName(u"Type"_ustr) >>= sTmp;
782 CPPUNIT_ASSERT_EQUAL(u"number"_ustr, sTmp);
784 xFormField = getProperty<uno::Reference<text::XFormField>>(getRun(getParagraph(8), 7),
785 u"Bookmark"_ustr);
786 xParameters.set(xFormField->getParameters());
787 xParameters->getByName(u"Type"_ustr) >>= sTmp;
788 CPPUNIT_ASSERT_EQUAL(u"date"_ustr, sTmp);
790 xmlDocUniquePtr pXmlDoc = parseExport(u"word/settings.xml"_ustr);
791 assertXPath(pXmlDoc, "/w:settings/w:compat/w:compatSetting[1]", "name", u"compatibilityMode");
792 assertXPath(pXmlDoc, "/w:settings/w:compat/w:compatSetting[1]", "uri",
793 u"http://schemas.microsoft.com/office/word");
794 assertXPath(pXmlDoc, "/w:settings/w:compat/w:compatSetting[1]", "val", u"11");
797 DECLARE_OOXMLEXPORT_TEST(testTdf120224_textControlCrossRef, "tdf120224_textControlCrossRef.docx")
799 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
800 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
801 uno::UNO_QUERY);
802 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
803 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(),
804 uno::UNO_QUERY);
805 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
806 xRunEnum->nextElement(); //Text
807 uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
809 CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr,
810 getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr));
812 xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
813 CPPUNIT_ASSERT_EQUAL(u"TextFieldStart"_ustr,
814 getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr));
815 uno::Reference<container::XNamed> xBookmark(
816 getProperty<uno::Reference<beans::XPropertySet>>(xPropertySet, u"Bookmark"_ustr),
817 uno::UNO_QUERY);
819 // Critical test: does TextField's bookmark name match cross-reference?
820 const OUString sTextFieldName(xBookmark->getName());
821 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
822 uno::Reference<container::XEnumerationAccess> xFieldsAccess(
823 xTextFieldsSupplier->getTextFields());
824 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
825 CPPUNIT_ASSERT(xFields->hasMoreElements());
826 xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
827 CPPUNIT_ASSERT_EQUAL(sTextFieldName, getProperty<OUString>(xPropertySet, u"SourceName"_ustr));
829 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
830 uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(),
831 uno::UNO_QUERY);
832 // TextFields should not be turned into real bookmarks.
833 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xBookmarksByIdx->getCount());
835 // The actual name isn't critical, but if it fails, it is worth asking why.
836 CPPUNIT_ASSERT_EQUAL(u"Text1"_ustr, sTextFieldName);
839 DECLARE_OOXMLEXPORT_TEST(testTdf117504_numberingIndent, "tdf117504_numberingIndent.docx")
841 OUString sName = getProperty<OUString>(getParagraph(1), u"NumberingStyleName"_ustr);
842 CPPUNIT_ASSERT_MESSAGE("Paragraph has numbering style", !sName.isEmpty());
844 uno::Reference<beans::XPropertySet> xPropertySet(
845 getStyles(u"ParagraphStyles"_ustr)->getByName(u"Revision"_ustr), uno::UNO_QUERY);
846 CPPUNIT_ASSERT_EQUAL(sal_Int32(353),
847 getProperty<sal_Int32>(xPropertySet, u"ParaBottomMargin"_ustr));
848 xPropertySet.set(getStyles(u"ParagraphStyles"_ustr)->getByName(u"Body Note"_ustr),
849 uno::UNO_QUERY);
850 CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
851 getProperty<sal_Int32>(xPropertySet, u"ParaBottomMargin"_ustr));
854 DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx")
856 uno::Reference<drawing::XShape> xShape = getShape(1);
858 sal_Int32 nHeight = xShape->getSize().Height;
860 // Rounding errors
861 sal_Int32 nDifference = 5150 - nHeight;
862 std::stringstream ss;
863 ss << "Difference: " << nDifference << " TotalHeight: " << nHeight;
864 CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference <= 4);
865 CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference >= -4);
868 DECLARE_OOXMLEXPORT_TEST(testWatermarkTrim, "tdf114308.docx")
870 uno::Reference<drawing::XShape> xShape = getShape(1);
872 // Rounding errors
873 sal_Int32 nHeight = xShape->getSize().Height;
874 sal_Int32 nDifference = 8729 - nHeight;
875 std::stringstream ss;
876 ss << "Difference: " << nDifference << " TotalHeight: " << nHeight;
877 CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference <= 4);
878 CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference >= -4);
881 CPPUNIT_TEST_FIXTURE(Test, testVMLShapetypeId)
883 loadAndSave("controlshape.fodt");
884 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
885 // must be _x0000_t<NR>
886 assertXPath(pXmlDoc,
887 "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[1]/w:r/mc:AlternateContent/"
888 "mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wps:wsp/wps:txbx/"
889 "w:txbxContent/w:p/w:r/w:object/v:shapetype",
890 "id", u"_x0000_t75");
891 assertXPath(pXmlDoc,
892 "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[1]/w:r/mc:AlternateContent/"
893 "mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wps:wsp/wps:txbx/"
894 "w:txbxContent/w:p/w:r/w:object/v:shape",
895 "type", u"#_x0000_t75");
898 CPPUNIT_TEST_FIXTURE(Test, testTdf73547)
900 loadAndSave("tdf73547-dash.docx");
901 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
902 double nD = getXPath(pXmlDoc, "//a:custDash/a:ds[1]", "d").toDouble();
903 CPPUNIT_ASSERT_DOUBLES_EQUAL(105000.0, nD, 5000.0); // was 100000
904 double nSp = getXPath(pXmlDoc, "//a:custDash/a:ds[1]", "sp").toDouble();
905 CPPUNIT_ASSERT_DOUBLES_EQUAL(35000.0, nSp, 5000.0); // was 100000
908 DECLARE_OOXMLEXPORT_TEST(testTdf119143, "tdf119143.docx")
910 // The runs inside <w:dir> were ignored
911 const OUString sParaText = getParagraph(1)->getString();
912 CPPUNIT_ASSERT_EQUAL(
913 u"عندما يريد العالم أن يتكلّم ‬ ، فهو يتحدّث "
914 u"بلغة "
915 u"يونيكود. تسجّل الآن لحضور المؤتمر الدولي العاشر "
916 u"ليونيكود (Unicode Conference)، الذي سيعقد في 10-12 "
917 u"آذار 1997 بمدينة مَايِنْتْس، ألمانيا. و سيجمع المؤتمر "
918 u"بين خبراء من كافة قطاعات الصناعة على الشبكة "
919 u"العالمية انترنيت ويونيكود، حيث ستتم، على الصعيدين "
920 u"الدولي والمحلي على حد سواء مناقشة سبل استخدام "
921 u"يونكود في النظم القائمة وفيما يخص التطبيقات "
922 u"الحاسوبية، الخطوط، تصميم النصوص والحوسبة متعددة "
923 u"اللغات."_ustr,
924 sParaText);
927 CPPUNIT_TEST_FIXTURE(Test, testTdf105444)
929 loadAndSave("tdf105444.docx");
930 xmlDocUniquePtr pXmlComm = parseExport(u"word/comments.xml"_ustr);
931 // there is no extra paragraph on Win32, only a single one.
932 assertXPath(pXmlComm, "/w:comments/w:comment/w:p", 1);
935 DECLARE_OOXMLEXPORT_TEST(testTdf117137, "tdf117137.docx")
937 // Paragraphs were not part of a numbering anymore after roundtrip.
938 uno::Reference<beans::XPropertySet> xPara1(getParagraph(1), uno::UNO_QUERY);
939 CPPUNIT_ASSERT(xPara1.is());
940 CPPUNIT_ASSERT(xPara1->getPropertyValue(u"NumberingRules"_ustr).hasValue());
942 uno::Reference<beans::XPropertySet> xPara2(getParagraph(2), uno::UNO_QUERY);
943 CPPUNIT_ASSERT(xPara2.is());
944 CPPUNIT_ASSERT(xPara2->getPropertyValue(u"NumberingRules"_ustr).hasValue());
946 uno::Reference<beans::XPropertySet> xPara3(getParagraph(3), uno::UNO_QUERY);
947 CPPUNIT_ASSERT(xPara3.is());
948 CPPUNIT_ASSERT(xPara3->getPropertyValue(u"NumberingRules"_ustr).hasValue());
951 CPPUNIT_TEST_FIXTURE(Test, testTdf138780)
953 loadAndReload("tdf138780.odt");
954 CPPUNIT_ASSERT_EQUAL(1, getPages());
955 // Paragraphs were not part of a numbering anymore after roundtrip.
956 uno::Reference<beans::XPropertySet> xPara1(getParagraph(1), uno::UNO_QUERY);
957 CPPUNIT_ASSERT(xPara1.is());
958 CPPUNIT_ASSERT(xPara1->getPropertyValue(u"NumberingRules"_ustr).hasValue());
960 uno::Reference<beans::XPropertySet> xPara2(getParagraph(2), uno::UNO_QUERY);
961 CPPUNIT_ASSERT(xPara2.is());
962 CPPUNIT_ASSERT(xPara2->getPropertyValue(u"NumberingRules"_ustr).hasValue());
964 uno::Reference<beans::XPropertySet> xPara3(getParagraph(3), uno::UNO_QUERY);
965 CPPUNIT_ASSERT(xPara3.is());
966 CPPUNIT_ASSERT(xPara3->getPropertyValue(u"NumberingRules"_ustr).hasValue());
969 CPPUNIT_TEST_FIXTURE(Test, testTdf134618)
971 loadAndSave("tdf134618.doc");
972 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
974 //Without the fix it in place, it would have failed with
975 //- Expected: 1
976 //- Actual : 9
977 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r", 1);
979 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent", 2);
982 CPPUNIT_TEST_FIXTURE(Test, testTdf99631)
984 loadAndSave("tdf99631.docx");
985 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
987 assertXPath(pXmlDoc, "//w:object", 2);
988 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object", 2);
989 // first XSLX OLE object (1:1 scale)
990 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/w:object[1]", "dxaOrig", u"2561");
991 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/w:object[1]", "dyaOrig", u"513");
992 // second XLSX OLE object (same content + 1 row, but zoomed)
993 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:object[1]", "dxaOrig", u"2561");
994 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:object[1]", "dyaOrig", u"769");
997 CPPUNIT_TEST_FIXTURE(Test, testTdf138899)
999 loadAndSave("tdf138899.docx");
1000 xmlDocUniquePtr pXmlDocument = parseExport(u"word/document.xml"_ustr);
1001 // This was 6, not removed empty temporary paragraph at the end of the section
1002 assertXPath(pXmlDocument, "/w:document/w:body/w:p", 5);
1004 //tdf#134385: Paragraph property to "add space between paragraphs of the same style" was lost
1005 assertXPath(pXmlDocument, "//w:p[1]/w:pPr/w:contextualSpacing", "val", u"false");
1008 CPPUNIT_TEST_FIXTURE(Test, testTdf122563)
1010 loadAndSave("tdf122563.docx");
1011 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1013 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object", 1);
1014 // Size of the embedded OLE spreadsheet was the bad "width:28.35pt;height:28.35pt"
1015 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/w:object/v:shape", "style",
1016 u"width:255.75pt;height:63.75pt;mso-wrap-distance-right:0pt");
1019 CPPUNIT_TEST_FIXTURE(Test, testTdf94628)
1021 loadAndReload("tdf94628.docx");
1022 uno::Reference<beans::XPropertySet> xPropertySet(
1023 getStyles(u"NumberingStyles"_ustr)->getByName(u"WWNum1"_ustr), uno::UNO_QUERY);
1024 uno::Reference<container::XIndexAccess> xLevels(
1025 xPropertySet->getPropertyValue(u"NumberingRules"_ustr), uno::UNO_QUERY);
1026 uno::Sequence<beans::PropertyValue> aProps;
1027 xLevels->getByIndex(0) >>= aProps; // 1st level
1029 OUString sBulletChar = std::find_if(std::cbegin(aProps), std::cend(aProps),
1030 [](const beans::PropertyValue& rValue) {
1031 return rValue.Name == "BulletChar";
1033 ->Value.get<OUString>();
1034 // Actually for 'BLACK UPPER RIGHT TRIANGLE' is \u25E5
1035 // But we use Wingdings 3 font here, so code is different
1036 CPPUNIT_ASSERT_EQUAL(u"\uF07B"_ustr, sBulletChar);
1039 DECLARE_OOXMLEXPORT_TEST(testTdf122594, "tdf122594.docx")
1041 // test import/export of ActiveTable (visible sheet) of embedded XLSX OLE objects
1042 uno::Reference<text::XTextEmbeddedObjectsSupplier> xEmbeddedObjectsSupplier(mxComponent,
1043 uno::UNO_QUERY);
1044 uno::Reference<container::XIndexAccess> xObjects(xEmbeddedObjectsSupplier->getEmbeddedObjects(),
1045 uno::UNO_QUERY);
1046 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xObjects->getCount());
1048 uno::Reference<beans::XPropertySet> xSheets;
1049 xObjects->getByIndex(0) >>= xSheets;
1051 uno::Reference<frame::XModel> xModel;
1052 xSheets->getPropertyValue(u"Model"_ustr) >>= xModel;
1053 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(xModel, uno::UNO_QUERY);
1055 uno::Reference<container::XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData());
1056 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xIndexAccess->getCount());
1058 uno::Sequence<beans::PropertyValue> aSeq;
1059 sal_Int32 nCheck = 0;
1060 if (xIndexAccess->getByIndex(0) >>= aSeq)
1062 sal_Int32 nCount(aSeq.getLength());
1063 for (sal_Int32 i = 0; i < nCount; ++i)
1065 OUString sName(aSeq[i].Name);
1066 if (sName == "ActiveTable")
1068 OUString sTabName;
1069 if (aSeq[i].Value >>= sTabName)
1071 // Sheet2, not Sheet1
1072 CPPUNIT_ASSERT_EQUAL(u"Munka2"_ustr, sTabName);
1073 nCheck++;
1076 // tdf#122624 column and row viewarea positions
1077 else if (sName == "PositionLeft")
1079 sal_Int32 nPosLeft;
1080 aSeq[i].Value >>= nPosLeft;
1081 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nPosLeft);
1082 nCheck++;
1084 else if (sName == "PositionTop")
1086 sal_Int32 nPosTop;
1087 aSeq[i].Value >>= nPosTop;
1088 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nPosTop);
1089 nCheck++;
1094 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), nCheck);
1097 CPPUNIT_TEST_FIXTURE(Test, testLanguageInGroupShape)
1099 loadAndSave("tdf131922_LanguageInGroupShape.docx");
1100 // tdf#131922: Check if good language is used in shape group texts
1101 xmlDocUniquePtr pXml = parseExport(u"word/document.xml"_ustr);
1102 assertXPath(pXml,
1103 "/w:document/w:body/w:p[7]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/"
1104 "a:graphic/a:graphicData/wpg:wgp/"
1105 "wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:lang",
1106 "val", u"de-DE");
1109 DECLARE_OOXMLEXPORT_TEST(testTdf116883, "tdf116883.docx")
1112 uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
1113 CPPUNIT_ASSERT_EQUAL(u"1>1>"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1116 uno::Reference<beans::XPropertySet> xPara(getParagraph(2), uno::UNO_QUERY);
1117 CPPUNIT_ASSERT_EQUAL(u"1>2>"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1120 uno::Reference<beans::XPropertySet> xPara(getParagraph(3), uno::UNO_QUERY);
1121 CPPUNIT_ASSERT_EQUAL(u"1>2>1>1>"_ustr,
1122 getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1125 uno::Reference<beans::XPropertySet> xPara(getParagraph(4), uno::UNO_QUERY);
1126 CPPUNIT_ASSERT_EQUAL(u"1>2>2>"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1129 uno::Reference<beans::XPropertySet> xPara(getParagraph(5), uno::UNO_QUERY);
1130 CPPUNIT_ASSERT_EQUAL(u"1>2>3>"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1133 uno::Reference<beans::XPropertySet> xPara(getParagraph(6), uno::UNO_QUERY);
1134 CPPUNIT_ASSERT_EQUAL(u"1>1)"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1137 uno::Reference<beans::XPropertySet> xPara(getParagraph(7), uno::UNO_QUERY);
1138 CPPUNIT_ASSERT_EQUAL(u"1>2)"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1141 uno::Reference<beans::XPropertySet> xPara(getParagraph(8), uno::UNO_QUERY);
1142 CPPUNIT_ASSERT_EQUAL(u"1>2>1<1)"_ustr,
1143 getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1146 uno::Reference<beans::XPropertySet> xPara(getParagraph(9), uno::UNO_QUERY);
1147 CPPUNIT_ASSERT_EQUAL(u"1>2.2)"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1150 uno::Reference<beans::XPropertySet> xPara(getParagraph(10), uno::UNO_QUERY);
1151 CPPUNIT_ASSERT_EQUAL(u"1>2.3)"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr));
1155 CPPUNIT_TEST_FIXTURE(Test, testTdf131420)
1157 loadAndSave("tdf131420.docx");
1158 xmlDocUniquePtr pXmlDocument = parseExport(u"word/document.xml"_ustr);
1159 assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:pPr/w:pBdr/w:top");
1162 CPPUNIT_TEST_FIXTURE(Test, testTdf80526_word_wrap)
1164 // tdf#80526: check whether the "wrap" property has been set
1165 createSwDoc("tdf80526_word_wrap.docx");
1166 // TODO: fix export too
1167 uno::Reference<drawing::XShape> xShape = getShape(1);
1168 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xShape, u"TextWordWrap"_ustr));
1171 DECLARE_OOXMLEXPORT_TEST(testTdf118521_marginsLR, "tdf118521_marginsLR.docx")
1173 // tdf#118521 paragraphs with direct formatting of only some of left, right, or first margins have
1174 // lost the other unset margins coming from paragraph style, getting a bad margin from the default style instead
1176 uno::Reference<beans::XPropertySet> xMyStyle(
1177 getStyles(u"ParagraphStyles"_ustr)->getByName(u"MyStyle"_ustr), uno::UNO_QUERY);
1178 // from paragraph style - this is what direct formatting should equal
1179 sal_Int32 nMargin = getProperty<sal_Int32>(xMyStyle, u"ParaLeftMargin"_ustr);
1180 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nMargin);
1181 // from direct formatting
1182 CPPUNIT_ASSERT_EQUAL(nMargin, getProperty<sal_Int32>(getParagraph(1), u"ParaLeftMargin"_ustr));
1184 nMargin = getProperty<sal_Int32>(xMyStyle, u"ParaRightMargin"_ustr);
1185 CPPUNIT_ASSERT_EQUAL(sal_Int32(1900), nMargin);
1186 CPPUNIT_ASSERT_EQUAL(nMargin, getProperty<sal_Int32>(getParagraph(2), u"ParaRightMargin"_ustr));
1187 CPPUNIT_ASSERT_EQUAL(sal_Int32(882),
1188 getProperty<sal_Int32>(getParagraph(2), u"ParaFirstLineIndent"_ustr));
1191 DECLARE_OOXMLEXPORT_TEST(testTdf104797, "tdf104797.docx")
1193 // check moveFrom and moveTo
1194 CPPUNIT_ASSERT_EQUAL(u"Will this sentence be duplicated?"_ustr, getParagraph(1)->getString());
1195 CPPUNIT_ASSERT_EQUAL(u""_ustr, getRun(getParagraph(1), 1)->getString());
1196 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 3), u"RedlineType"_ustr));
1197 CPPUNIT_ASSERT_EQUAL(u"Delete"_ustr,
1198 getProperty<OUString>(getRun(getParagraph(1), 3), u"RedlineType"_ustr));
1199 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getRun(getParagraph(1), 3), u"IsStart"_ustr));
1200 CPPUNIT_ASSERT_EQUAL(
1201 u"This is a filler sentence. Will this sentence be duplicated ADDED STUFF?"_ustr,
1202 getParagraph(2)->getString());
1203 CPPUNIT_ASSERT_EQUAL(u""_ustr, getRun(getParagraph(2), 1)->getString());
1204 CPPUNIT_ASSERT_EQUAL(u"This is a filler sentence."_ustr,
1205 getRun(getParagraph(2), 2)->getString());
1206 CPPUNIT_ASSERT_EQUAL(u""_ustr, getRun(getParagraph(2), 3)->getString());
1207 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 3), u"RedlineType"_ustr));
1208 CPPUNIT_ASSERT_EQUAL(u"Insert"_ustr,
1209 getProperty<OUString>(getRun(getParagraph(2), 3), u"RedlineType"_ustr));
1210 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getRun(getParagraph(2), 3), u"IsStart"_ustr));
1212 CPPUNIT_ASSERT_EQUAL(u" "_ustr, getRun(getParagraph(2), 4)->getString());
1213 CPPUNIT_ASSERT_EQUAL(u""_ustr, getRun(getParagraph(2), 5)->getString());
1214 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 6), u"RedlineType"_ustr));
1215 CPPUNIT_ASSERT_EQUAL(u"Insert"_ustr,
1216 getProperty<OUString>(getRun(getParagraph(2), 6), u"RedlineType"_ustr));
1217 CPPUNIT_ASSERT_EQUAL(u""_ustr, getRun(getParagraph(2), 7)->getString());
1218 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 7), u"RedlineType"_ustr));
1219 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getRun(getParagraph(2), 7), u"IsStart"_ustr));
1220 CPPUNIT_ASSERT_EQUAL(u"Will this sentence be duplicated"_ustr,
1221 getRun(getParagraph(2), 8)->getString());
1222 CPPUNIT_ASSERT_EQUAL(u" ADDED STUFF"_ustr, getRun(getParagraph(2), 11)->getString());
1223 CPPUNIT_ASSERT_EQUAL(u"?"_ustr, getRun(getParagraph(2), 14)->getString());
1226 CPPUNIT_TEST_FIXTURE(Test, testTdf145720)
1228 // check moveFromRangeStart/End and moveToRangeStart/End (to keep tracked text moving)
1229 loadAndSave("tdf104797.docx");
1230 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1231 // These were 0 (missing move*FromRange* elements)
1232 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", 1);
1233 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:moveFromRangeEnd", 1);
1234 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", 1);
1235 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:moveToRangeEnd", 1);
1237 // paired names
1238 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", "name",
1239 u"move471382752");
1240 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", "name",
1241 u"move471382752");
1243 // mandatory authors and dates
1244 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", "author",
1245 u"Tekijä");
1246 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", "author",
1247 u"Tekijä");
1248 // no date (anonymized change)
1249 // This failed, date was exported as w:date="0-00-00T00:00:00Z", and later "1970-01-01T00:00:00Z"
1250 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart",
1251 "date");
1252 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart",
1253 "date");
1256 CPPUNIT_TEST_FIXTURE(Test, testTdf150166)
1258 // check moveFromRangeStart/End and moveToRangeStart/End (to keep tracked text moving)
1259 loadAndSave("tdf150166.docx");
1260 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1261 assertXPath(pXmlDoc, "//w:moveFromRangeStart", 0);
1262 // This was 2 (missing RangeStart elements, but bad unpaired RangeEnds)
1263 assertXPath(pXmlDoc, "//w:moveFromRangeEnd", 0);
1265 // These were 0 (moveFrom, moveTo and t)
1266 assertXPath(pXmlDoc, "//w:del", 11);
1267 assertXPath(pXmlDoc, "//w:ins", 12);
1268 assertXPath(pXmlDoc, "//w:delText", 7);
1270 // no more moveFrom/moveTo to avoid of problems with ToC
1271 assertXPath(pXmlDoc, "//w:moveFrom", 0);
1272 assertXPath(pXmlDoc, "//w:moveTo", 0);
1275 CPPUNIT_TEST_FIXTURE(Test, testTdf143510)
1277 // check moveFromRangeStart/End and moveToRangeStart/End for tracked table move by drag & drop
1278 loadAndSave("TC-table-DnD-move.docx");
1279 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1280 // This was 0 (missing tracked table row deletion/insertion)
1281 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr/w:trPr/w:del", 2);
1282 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[2]/w:tr/w:trPr/w:ins", 2);
1285 CPPUNIT_TEST_FIXTURE(Test, testTdf143510_table_from_row)
1287 // check moveFromRangeStart/End and moveToRangeStart/End for tracked table move by drag & drop
1288 loadAndSave("TC-table-Separate-Move.docx");
1289 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1290 // This was 0 (missing tracked table row deletion/insertion)
1291 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr/w:trPr/w:del", 1);
1292 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[3]/w:trPr/w:del", 1);
1293 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[2]/w:tr", 1);
1294 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[2]/w:tr/w:trPr/w:ins", 1);
1297 CPPUNIT_TEST_FIXTURE(Test, testTdf143510_within_table)
1299 // check moveFromRangeStart/End and moveToRangeStart/End for tracked table row move by DnD
1300 loadAndSave("TC-table-rowDND.docx");
1301 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1302 // This was 0 (missing tracked table row deletion/insertion)
1303 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:trPr/w:del", 1);
1304 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:trPr/w:ins", 1);
1307 CPPUNIT_TEST_FIXTURE(Test, testTdf143510_within_table2)
1309 // check moveFromRangeStart/End and moveToRangeStart/End for tracked table row move by DnD
1310 loadAndSave("TC-table-rowDND-front.docx");
1311 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1312 // This was 0 (missing tracked table row deletion/insertion)
1313 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:trPr/w:ins", 1);
1314 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:trPr/w:del", 1);
1317 CPPUNIT_TEST_FIXTURE(Test, testTdf150824)
1319 // check tracked table row insertion (stored in a single redline)
1320 loadAndSave("tdf150824.fodt");
1321 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1322 // This was 0 (missing tracked table row deletion/insertion)
1323 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:trPr/w:ins", 1);
1324 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:ins", 1);
1325 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:trPr/w:ins", 1);
1328 CPPUNIT_TEST_FIXTURE(Test, testTdf157011)
1330 // check tracked table column insertions and deletions with empty cells
1331 loadAndSave("tdf157011_ins_del_empty_cols.docx");
1332 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1334 // This was 1 (missing tracked table cell insertions)
1335 assertXPath(pXmlDoc, "//w:ins", 3);
1337 // This was 4 (missing tracked table cell deletions)
1338 assertXPath(pXmlDoc, "//w:del", 6);
1340 // tdf#157187 This was false (dummy w:tc/w:p/w:sdt/w:sdtContent content box)
1341 assertXPath(pXmlDoc, "//w:tc/w:p/w:del", 6);
1342 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(),
1357 getProperty<OUString>(getParagraph(2), u"NumberingStyleName"_ustr));
1360 DECLARE_OOXMLEXPORT_TEST(testTdf119188_list_margin_in_cell, "tdf119188_list_margin_in_cell.docx")
1362 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1363 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
1364 uno::UNO_QUERY);
1365 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1366 uno::Reference<text::XTextRange> xCell(xTable->getCellByName(u"A1"_ustr), uno::UNO_QUERY);
1368 // lists with auto margins in cells: top margin of the first paragraph is zero,
1369 // but not the bottom margin of the last paragraph, also other list items have got
1370 // zero margins.
1372 CPPUNIT_ASSERT_EQUAL(
1373 static_cast<sal_Int32>(0),
1374 getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), u"ParaTopMargin"_ustr));
1375 CPPUNIT_ASSERT_EQUAL(
1376 static_cast<sal_Int32>(0),
1377 getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), u"ParaBottomMargin"_ustr));
1378 CPPUNIT_ASSERT_EQUAL(
1379 static_cast<sal_Int32>(0),
1380 getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), u"ParaTopMargin"_ustr));
1381 CPPUNIT_ASSERT_EQUAL(
1382 static_cast<sal_Int32>(0),
1383 getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), u"ParaBottomMargin"_ustr));
1384 CPPUNIT_ASSERT_EQUAL(
1385 static_cast<sal_Int32>(0),
1386 getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), u"ParaTopMargin"_ustr));
1387 CPPUNIT_ASSERT_EQUAL(
1388 static_cast<sal_Int32>(494),
1389 getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), u"ParaBottomMargin"_ustr));
1392 CPPUNIT_TEST_FIXTURE(Test, testChart_BorderLine_Style)
1394 loadAndSave("Chart_BorderLine_Style.docx");
1395 /* DOCX containing Chart with BorderLine Style as Dash Type should get preserved
1396 * inside an XML tag <a:prstDash> with value "dash", "sysDot, "lgDot", etc.
1398 xmlDocUniquePtr pXmlDoc = parseExport(u"word/charts/chart1.xml"_ustr);
1399 assertXPath(pXmlDoc,
1400 "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:spPr/a:ln/a:prstDash",
1401 "val", u"sysDot");
1402 assertXPath(pXmlDoc,
1403 "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[2]/c:spPr/a:ln/a:prstDash",
1404 "val", u"sysDash");
1405 assertXPath(pXmlDoc,
1406 "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[3]/c:spPr/a:ln/a:prstDash",
1407 "val", u"dash");
1410 CPPUNIT_TEST_FIXTURE(Test, testChart_Plot_BorderLine_Style)
1412 loadAndSave("Chart_Plot_BorderLine_Style.docx");
1413 /* DOCX containing Chart wall (plot area) and Chart Page with BorderLine Style as Dash Type
1414 * should get preserved inside an XML tag <a:prstDash> with value "dash", "sysDot, "lgDot", etc.
1416 xmlDocUniquePtr pXmlDoc = parseExport(u"word/charts/chart1.xml"_ustr);
1417 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:ln/a:prstDash", "val",
1418 u"lgDashDot");
1419 assertXPath(pXmlDoc, "/c:chartSpace/c:spPr/a:ln/a:prstDash", "val", u"sysDash");
1422 CPPUNIT_TEST_FIXTURE(Test, testTrackChangesDeletedEmptyParagraph)
1424 loadAndSave("testTrackChangesDeletedEmptyParagraph.docx");
1425 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1426 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:rPr/w:del");
1429 CPPUNIT_TEST_FIXTURE(Test, testTrackChangesEmptyParagraphsInADeletion)
1431 loadAndSave("testTrackChangesEmptyParagraphsInADeletion.docx");
1432 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1433 for (int i = 1; i < 12; ++i)
1434 assertXPath(pXmlDoc,
1435 "/w:document/w:body/w:p[" + OString::number(i) + "]/w:pPr/w:rPr/w:del");
1438 CPPUNIT_TEST_FIXTURE(Test, testTdf149708)
1440 loadAndSave("tdf149708.docx");
1441 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1442 // keep tracked insertion of a list item
1443 // This was 0 (missing tracked insertion of the paragraph mark)
1444 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:ins");
1447 CPPUNIT_TEST_FIXTURE(Test, testTdf149707)
1449 loadAndSave("tdf149711.docx");
1450 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1451 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:moveFrom");
1452 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:moveTo");
1453 // These were missing
1454 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:moveFrom");
1455 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:rPr/w:moveTo");
1458 CPPUNIT_TEST_FIXTURE(Test, testTdf70234)
1460 loadAndSave("tdf70234.docx");
1461 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1462 // import field with tracked deletion
1463 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:del/w:r[1]/w:fldChar");
1465 // export multiple runs of a field with tracked deletion
1466 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:del/w:r", 6);
1468 // export w:delInstrText
1469 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:del/w:r/w:delInstrText");
1472 CPPUNIT_TEST_FIXTURE(Test, testTdf115212)
1474 loadAndSave("tdf115212.docx");
1475 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1476 // export field with tracked deletion
1477 assertXPath(pXmlDoc, "//w:p[2]/w:del[1]/w:r[1]/w:fldChar");
1480 CPPUNIT_TEST_FIXTURE(Test, testTdf126243)
1482 loadAndSave("tdf120338.docx");
1483 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1484 // export change tracking rejection data for tracked paragraph style change
1485 assertXPath(pXmlDoc, "/w:document/w:body/w:p[11]/w:pPr/w:pPrChange/w:pPr/w:pStyle", "val",
1486 u"Heading3");
1489 CPPUNIT_TEST_FIXTURE(Test, testTdf126245)
1491 loadAndSave("tdf126245.docx");
1492 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1493 // export change tracking rejection data for tracked numbering change
1494 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pPrChange/w:pPr/w:numPr/w:numId", "val",
1495 u"1");
1498 CPPUNIT_TEST_FIXTURE(Test, testTdf124491)
1500 loadAndSave("tdf124491.docx");
1501 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1502 // import format change of empty lines, FIXME: change w:r with w:pPr in export
1503 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/*/w:rPr/w:rPrChange");
1504 // empty line without format change
1505 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/*/w:rPrChange", 0);
1506 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/*/*/w:rPrChange", 0);
1509 CPPUNIT_TEST_FIXTURE(Test, testTdf143911)
1511 loadAndSave("tdf126206.docx");
1512 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1513 // export format change of text portions
1514 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:rPr/w:rPrChange");
1515 // This was without tracked bold formatting
1516 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:rPr/w:rPrChange/w:rPr/w:b");
1519 CPPUNIT_TEST_FIXTURE(Test, testTdf105485)
1521 loadAndSave("tdf105485.docx");
1522 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1523 // import change tracking of deleted comments
1524 assertXPath(pXmlDoc, "//w:del/w:r/w:commentReference");
1527 CPPUNIT_TEST_FIXTURE(Test, testTdf125894)
1529 loadAndSave("tdf125894.docx");
1530 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1531 // import change tracking in frames
1532 assertXPath(pXmlDoc, "//w:del", 2);
1533 assertXPath(pXmlDoc, "//w:ins");
1536 CPPUNIT_TEST_FIXTURE(Test, testTdf149388)
1538 // see also testTdf132371
1539 loadAndSave("tdf132271.docx");
1540 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1541 // import change tracking in floating tables
1542 // (don't recognize tracked text moving during the import,
1543 // because the text is too short and it's only a single word)
1544 assertXPath(pXmlDoc, "//w:del", 2);
1545 assertXPath(pXmlDoc, "//w:ins", 2);
1546 assertXPath(pXmlDoc, "//w:moveFrom", 0);
1547 assertXPath(pXmlDoc, "//w:moveTo", 0);
1550 CPPUNIT_TEST_FIXTURE(Test, testTdf132271)
1552 // see also testTdf149388
1553 loadAndSave("tdf149388.docx");
1554 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1555 // import change tracking in floating tables
1556 assertXPath(pXmlDoc, "//w:del", 1);
1557 assertXPath(pXmlDoc, "//w:ins", 1);
1558 // tracked text moving recognized during the import
1559 assertXPath(pXmlDoc, "//w:moveFrom", 1);
1560 assertXPath(pXmlDoc, "//w:moveTo", 1);
1563 CPPUNIT_TEST_FIXTURE(Test, testTdf149388_fly)
1565 // see also testTdf136667
1566 loadAndSave("tdf136667.docx");
1567 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1568 // import change tracking in floating tables
1569 assertXPath(pXmlDoc, "//w:del", 2);
1570 assertXPath(pXmlDoc, "//w:ins", 4);
1571 assertXPath(pXmlDoc, "//w:moveFrom", 0);
1572 assertXPath(pXmlDoc, "//w:moveTo", 0);
1575 CPPUNIT_TEST_FIXTURE(Test, testTdf136667)
1577 // see also testTdf149388_fly
1578 loadAndSave("tdf149388_fly.docx");
1579 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1580 // import change tracking in floating tables
1581 assertXPath(pXmlDoc, "//w:del", 1);
1582 assertXPath(pXmlDoc, "//w:ins", 3);
1583 // tracked text moving recognized during the import
1584 assertXPath(pXmlDoc, "//w:moveFrom", 1);
1585 assertXPath(pXmlDoc, "//w:moveTo", 1);
1588 CPPUNIT_TEST_FIXTURE(Test, testTdf136850)
1590 loadAndSave("tdf136850.docx");
1591 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1592 // import change tracking in floating tables
1593 assertXPath(pXmlDoc, "//w:del");
1596 CPPUNIT_TEST_FIXTURE(Test, testTdf128156)
1598 loadAndSave("tdf128156.docx");
1599 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1600 // keep tracked insertion of a paragraph
1601 // This was 0 before 350972a8bffc1a74b531e0336954bf54b1356025,
1602 // and 1 later (missing tracked insertion of the paragraph mark)
1603 assertXPath(pXmlDoc, "//w:ins", 2);
1606 CPPUNIT_TEST_FIXTURE(Test, testTdf125546)
1608 loadAndSave("tdf125546.docx");
1609 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1610 // compress redlines (it was 15)
1611 assertXPath(pXmlDoc, "//w:rPrChange", 2);
1614 CPPUNIT_TEST_FIXTURE(Test, testLabelWidthAndPosition_Left_FirstLineIndent)
1616 loadAndSave("Hau_min_list2.fodt");
1617 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1618 // list is LABEL_WIDTH_AND_POSITION with SvxAdjust::Left
1619 // I) LTR
1620 // a) all LTR cases with no number text look good in Word
1621 // 1) negative first line indent on paragraph:
1622 // no list width/indent: this one was 0 previously; this looks good
1623 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "start", u"0");
1624 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "hanging", u"399");
1625 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "end", u"0");
1626 // list width:
1627 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:ind", "start", u"567");
1628 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:ind", "hanging", u"966");
1629 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:ind", "end", u"0");
1630 // list indent:
1631 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:ind", "start", u"567");
1632 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:ind", "hanging", u"399");
1633 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:ind", "end", u"0");
1634 // list width + list indent:
1635 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:ind", "start", u"1134");
1636 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:ind", "hanging", u"966");
1637 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:ind", "end", u"0");
1638 // 2) positive first line indent on paragraph:
1639 // no list width/indent:
1640 assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:ind", "start", u"0");
1641 assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:ind", "firstLine", u"420");
1642 assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:ind", "end", u"0");
1643 // list width:
1644 assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:pPr/w:ind", "start", u"567");
1645 assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:pPr/w:ind", "hanging", u"147");
1646 assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:pPr/w:ind", "end", u"0");
1647 // list indent:
1648 assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "start", u"567");
1649 assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "firstLine", u"420");
1650 assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "end", u"0");
1651 // list width + list indent:
1652 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:pPr/w:ind", "start", u"1134");
1653 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:pPr/w:ind", "hanging", u"147");
1654 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:pPr/w:ind", "end", u"0");
1655 // b) all LTR cases with number text: the indent looks good but some tabs are wrong
1656 // 1) negative first line indent on paragraph:
1657 // no list width/indent: this one was 0 previously; this looks good
1658 assertXPath(pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:ind", "start", u"0");
1659 assertXPath(pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:ind", "hanging", u"399");
1660 assertXPath(pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:ind", "end", u"0");
1661 // list width:
1662 assertXPath(pXmlDoc, "/w:document/w:body/w:p[10]/w:pPr/w:ind", "start", u"567");
1663 assertXPath(pXmlDoc, "/w:document/w:body/w:p[10]/w:pPr/w:ind", "hanging", u"966");
1664 assertXPath(pXmlDoc, "/w:document/w:body/w:p[10]/w:pPr/w:ind", "end", u"0");
1665 // list indent:
1666 assertXPath(pXmlDoc, "/w:document/w:body/w:p[11]/w:pPr/w:ind", "start", u"567");
1667 assertXPath(pXmlDoc, "/w:document/w:body/w:p[11]/w:pPr/w:ind", "hanging", u"399");
1668 assertXPath(pXmlDoc, "/w:document/w:body/w:p[11]/w:pPr/w:ind", "end", u"0");
1669 // list width + list indent:
1670 assertXPath(pXmlDoc, "/w:document/w:body/w:p[12]/w:pPr/w:ind", "start", u"1134");
1671 assertXPath(pXmlDoc, "/w:document/w:body/w:p[12]/w:pPr/w:ind", "hanging", u"966");
1672 assertXPath(pXmlDoc, "/w:document/w:body/w:p[12]/w:pPr/w:ind", "end", u"0");
1673 // 2) positive first line indent on paragraph:
1674 // no list width/indent:
1675 assertXPath(pXmlDoc, "/w:document/w:body/w:p[13]/w:pPr/w:ind", "start", u"0");
1676 assertXPath(pXmlDoc, "/w:document/w:body/w:p[13]/w:pPr/w:ind", "firstLine", u"420");
1677 assertXPath(pXmlDoc, "/w:document/w:body/w:p[13]/w:pPr/w:ind", "end", u"0");
1678 // list width:
1679 assertXPath(pXmlDoc, "/w:document/w:body/w:p[14]/w:pPr/w:ind", "start", u"567");
1680 assertXPath(pXmlDoc, "/w:document/w:body/w:p[14]/w:pPr/w:ind", "hanging", u"147");
1681 assertXPath(pXmlDoc, "/w:document/w:body/w:p[14]/w:pPr/w:ind", "end", u"0");
1682 // list indent:
1683 assertXPath(pXmlDoc, "/w:document/w:body/w:p[15]/w:pPr/w:ind", "start", u"567");
1684 assertXPath(pXmlDoc, "/w:document/w:body/w:p[15]/w:pPr/w:ind", "firstLine", u"420");
1685 assertXPath(pXmlDoc, "/w:document/w:body/w:p[15]/w:pPr/w:ind", "end", u"0");
1686 // list width + list indent:
1687 assertXPath(pXmlDoc, "/w:document/w:body/w:p[16]/w:pPr/w:ind", "start", u"1134");
1688 assertXPath(pXmlDoc, "/w:document/w:body/w:p[16]/w:pPr/w:ind", "hanging", u"147");
1689 assertXPath(pXmlDoc, "/w:document/w:body/w:p[16]/w:pPr/w:ind", "end", u"0");
1690 // (w:p[17] is empty)
1691 // I) RTL
1692 // a) only RTL cases with no number text and no width/indent look good in Word
1693 // 1) negative first line indent on paragraph:
1694 // no list width/indent
1695 assertXPath(pXmlDoc, "/w:document/w:body/w:p[18]/w:pPr/w:ind", "start", u"0");
1696 assertXPath(pXmlDoc, "/w:document/w:body/w:p[18]/w:pPr/w:ind", "hanging", u"399");
1697 assertXPath(pXmlDoc, "/w:document/w:body/w:p[18]/w:pPr/w:ind", "end", u"0");
1698 // 2) positive first line indent on paragraph:
1699 // no list width/indent:
1700 assertXPath(pXmlDoc, "/w:document/w:body/w:p[22]/w:pPr/w:ind", "start", u"0");
1701 assertXPath(pXmlDoc, "/w:document/w:body/w:p[22]/w:pPr/w:ind", "firstLine", u"420");
1702 assertXPath(pXmlDoc, "/w:document/w:body/w:p[22]/w:pPr/w:ind", "end", u"0");
1703 // b) RTL cases with number text: the indent looks good but some tabs are wrong
1704 // 1) negative first line indent on paragraph:
1705 // no list width/indent
1706 assertXPath(pXmlDoc, "/w:document/w:body/w:p[26]/w:pPr/w:ind", "start", u"0");
1707 assertXPath(pXmlDoc, "/w:document/w:body/w:p[26]/w:pPr/w:ind", "hanging", u"399");
1708 assertXPath(pXmlDoc, "/w:document/w:body/w:p[26]/w:pPr/w:ind", "end", u"0");
1709 // 2) positive first line indent on paragraph:
1710 // no list width/indent:
1711 assertXPath(pXmlDoc, "/w:document/w:body/w:p[30]/w:pPr/w:ind", "start", u"0");
1712 assertXPath(pXmlDoc, "/w:document/w:body/w:p[30]/w:pPr/w:ind", "firstLine", u"420");
1713 assertXPath(pXmlDoc, "/w:document/w:body/w:p[30]/w:pPr/w:ind", "end", u"0");
1714 // TODO: other cases
1717 CPPUNIT_TEST_FIXTURE(Test, testTdf124604)
1719 loadAndSave("tdf124604.docx");
1720 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1721 // If the numbering comes from a base style, indentation of the base style has also priority.
1722 assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "start", u"0");
1725 CPPUNIT_TEST_FIXTURE(Test, testTdf95374)
1727 loadAndSave("tdf95374.docx");
1728 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1729 // Numbering disabled by non-existent numId=0, disabling also inheritance of indentation of parent styles
1730 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "hanging", u"0");
1731 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "start", u"1136");
1734 DECLARE_OOXMLEXPORT_TEST(testTdf108493, "tdf108493.docx")
1736 uno::Reference<beans::XPropertySet> xPara7(getParagraph(7), uno::UNO_QUERY);
1737 // set in the paragraph (709 twips)
1738 CPPUNIT_ASSERT_EQUAL(sal_Int32(1251), getProperty<sal_Int32>(xPara7, u"ParaLeftMargin"_ustr));
1739 // set in the numbering style (this was 0)
1740 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1251),
1741 getProperty<sal_Int32>(xPara7, u"ParaFirstLineIndent"_ustr));
1744 DECLARE_OOXMLEXPORT_TEST(testTdf118691, "tdf118691.docx")
1746 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1747 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
1748 uno::UNO_QUERY);
1749 // Text "Before" stays in the first cell, not removed before the table because of
1750 // bad handling of <w:cr>
1751 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1752 uno::Reference<text::XTextRange> xCell(xTable->getCellByName(u"A1"_ustr), uno::UNO_QUERY);
1753 CPPUNIT_ASSERT_EQUAL(u"Before\nAfter"_ustr, xCell->getString());
1756 DECLARE_OOXMLEXPORT_TEST(testTdf64264, "tdf64264.docx")
1758 // DOCX table rows with tblHeader setting mustn't modify the count of the
1759 // repeated table header rows, when there is rows before them without tblHeader settings.
1760 xmlDocUniquePtr pDump = parseLayoutDump();
1761 CPPUNIT_ASSERT_EQUAL(2, getPages());
1763 // table starts on page 1 and finished on page 2
1764 // and it has got only a single repeating header line
1765 assertXPath(pDump, "/root/page[2]/body/tab", 1);
1766 assertXPath(pDump, "/root/page[2]/body/tab/row", 47);
1767 assertXPathContent(pDump, "/root/page[2]/body/tab/row[1]/cell[1]/txt/text()",
1768 u"Repeating Table Header");
1769 assertXPathContent(pDump, "/root/page[2]/body/tab/row[2]/cell[1]/txt/text()", u"Text");
1772 DECLARE_OOXMLEXPORT_TEST(testTdf58944RepeatingTableHeader, "tdf58944-repeating-table-header.docx")
1774 // DOCX tables with more than 10 repeating header lines imported without repeating header lines
1775 // as a workaround for MSO's limitation of header line repetition
1776 xmlDocUniquePtr pDump = parseLayoutDump();
1777 CPPUNIT_ASSERT_EQUAL(2, getPages());
1779 // table starts on page 1 and finished on page 2
1780 // instead of showing only a part of it on page 2
1781 assertXPath(pDump, "/root/page[1]/body/tab", 1);
1782 assertXPath(pDump, "/root/page[1]/body/tab/row", 11);
1783 assertXPathContent(pDump, "/root/page[2]/body/tab/row[1]/cell[1]/txt/text()", u"Test1");
1784 assertXPathContent(pDump, "/root/page[2]/body/tab/row[2]/cell[1]/txt/text()", u"Test2");
1787 CPPUNIT_TEST_FIXTURE(Test, testTdf81100)
1789 auto verify = [this](bool bIsExport = false) {
1790 xmlDocUniquePtr pDump = parseLayoutDump();
1791 CPPUNIT_ASSERT_EQUAL(3, getPages());
1793 // table starts on page 1 and finished on page 2
1794 // and it has got only a single repeating header line
1795 assertXPath(pDump, "/root/page[2]/body/tab[1]", 1);
1796 assertXPath(pDump, "/root/page[2]/body/tab[1]/row", 2);
1797 assertXPath(pDump, "/root/page[3]/body/tab", 1);
1798 if (!bIsExport) // TODO export tblHeader=false
1799 assertXPath(pDump, "/root/page[3]/body/tab/row", 1);
1801 createSwDoc("tdf81100.docx");
1802 verify();
1803 saveAndReload(mpFilter);
1804 verify(/*bIsExport*/ true);
1806 xmlDocUniquePtr pXmlDoc = parseExport(u"word/styles.xml"_ustr);
1807 CPPUNIT_ASSERT(pXmlDoc);
1808 // keep "repeat table header" setting of table styles
1809 assertXPath(pXmlDoc, "/w:styles/w:style/w:tblStylePr/w:trPr/w:tblHeader", 4);
1812 CPPUNIT_TEST_FIXTURE(Test, testTdf88496)
1814 loadAndReload("tdf88496.docx");
1815 // Switch off repeating header, there is no place for it.
1816 // Now there are only 3 pages with complete table content
1817 // instead of a 51-page long table only with header.
1818 CPPUNIT_ASSERT_EQUAL(3, getPages());
1819 // (this appears to have the correct result now?)
1820 // FIXME: this actually has 3 pages but SwWrtShell::SttPg() puts the cursor
1821 // into the single SwTextFrame in the follow-flow-row at the top of the
1822 // table but that SwTextFrame 1105 should not exist and the cursor ends up
1823 // at the end of its master frame 848 instead; the problem is somewhere in
1824 // SwTextFrame::FormatAdjust() which first determines nNew = 1 but then
1825 // grows this frame anyway so that the follow is empty, but nothing
1826 // invalidates 1105 again.
1829 CPPUNIT_TEST_FIXTURE(Test, testTdf77417)
1831 loadAndReload("tdf77417.docx");
1832 // MSO 2010 compatibility mode: terminating white spaces are ignored in tables.
1833 // This was 3 pages with the first invisible blank page.
1834 CPPUNIT_ASSERT_EQUAL(2, getPages());
1837 CPPUNIT_TEST_FIXTURE(Test, testTdf130494)
1839 loadAndSave("tdf130494.docx");
1840 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1841 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:pPr/w:rPr/w:highlight", "val",
1842 u"yellow");
1843 // keep direct formatting of table cell paragraph with removed highlighting
1844 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:r/w:rPr/w:highlight", 0);
1847 CPPUNIT_TEST_FIXTURE(Test, testTdf130690)
1849 loadAndSave("tdf130690.docx");
1850 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1851 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:pPr/w:rPr/w:highlight", "val",
1852 u"yellow");
1853 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:r[1]/w:rPr/w:highlight", 1);
1854 // keep direct formatting of table cell paragraph with removed highlighting
1855 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:r[2]/w:rPr/w:highlight", 0);
1858 CPPUNIT_TEST_FIXTURE(Test, testTdf105215)
1860 loadAndSave("tdf105215.docx");
1861 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1862 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:pPr/w:rPr/w:rFonts", "ascii",
1863 u"Linux Libertine G");
1865 // These were "Linux Libertine G"
1866 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r/w:rPr", 5);
1867 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[1]/w:rPr/w:rFonts", "ascii",
1868 u"Lohit Devanagari");
1869 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[2]/w:rPr/w:rFonts", "ascii",
1870 u"Lohit Devanagari");
1871 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[3]/w:rPr/w:rFonts", "ascii",
1872 u"Lohit Devanagari");
1873 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[4]/w:rPr/w:rFonts", "ascii",
1874 u"Lohit Devanagari");
1875 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[5]/w:rPr/w:rFonts", "ascii",
1876 u"Lohit Devanagari");
1879 CPPUNIT_TEST_FIXTURE(Test, testTdf135187)
1881 loadAndSave("tdf135187.docx");
1882 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1883 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p/w:pPr/w:rPr/w:b", 0);
1884 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:p/w:pPr/w:rPr/w:b", 1);
1885 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[1]/w:p/w:pPr/w:rPr/w:b", 1);
1887 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b", 1);
1888 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b",
1889 "val");
1890 // This was 0
1891 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b", 1);
1892 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b",
1893 "val");
1894 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b", 1);
1895 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[1]/w:p/w:r[1]/w:rPr/w:b", "val",
1896 u"false");
1899 CPPUNIT_TEST_FIXTURE(Test, testTdf136617)
1901 loadAndSave("tdf136617.docx");
1903 // This was 2
1904 CPPUNIT_ASSERT_EQUAL(1, getPages());
1906 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1907 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:p[2]/w:pPr/w:rPr/w:sz", "val",
1908 u"16");
1911 CPPUNIT_TEST_FIXTURE(Test, testTdf121597TrackedDeletionOfMultipleParagraphs)
1913 loadAndSave("tdf121597.odt");
1914 CPPUNIT_ASSERT_EQUAL(1, getPages());
1915 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1917 // check paragraphs with removed paragraph mark
1918 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:del");
1919 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:del");
1920 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:rPr/w:del");
1921 assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:rPr/w:del");
1922 assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:pPr/w:rPr/w:del");
1923 assertXPath(pXmlDoc, "/w:document/w:body/w:p[10]/w:pPr/w:rPr/w:del");
1926 CPPUNIT_TEST_FIXTURE(Test, testTdf141660)
1928 loadAndSave("tdf141660.docx");
1929 CPPUNIT_ASSERT_EQUAL(1, getPages());
1930 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1932 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:footnoteReference", "id", u"2");
1933 // w:del is imported correctly with its footnote
1934 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:del[2]/w:r/w:footnoteReference", "id", u"3");
1935 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/w:footnoteReference", "id", u"4");
1938 CPPUNIT_TEST_FIXTURE(Test, testTdf133643)
1940 loadAndSave("tdf133643.doc");
1941 CPPUNIT_ASSERT_EQUAL(1, getPages());
1942 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1944 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[1]/w:fldChar", "fldCharType",
1945 u"begin");
1946 assertXPath(
1947 pXmlDoc,
1948 "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[1]/w:fldChar/w:ffData/w:ddList/w:listEntry[1]",
1949 "val", u"Bourgoin-Jallieu, ");
1950 assertXPath(
1951 pXmlDoc,
1952 "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[1]/w:fldChar/w:ffData/w:ddList/w:listEntry[2]",
1953 "val", u"Fontaine, ");
1955 assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[2]/w:instrText",
1956 u" FORMDROPDOWN ");
1958 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[3]/w:fldChar", "fldCharType",
1959 u"separate");
1960 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[5]/w:fldChar", "fldCharType",
1961 u"end");
1963 // Without the fix in place, this w:r wouldn't exist
1964 assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r[6]/w:t",
1965 u"le 22 fevrier 2013");
1968 DECLARE_OOXMLEXPORT_TEST(testTdf123189_tableBackground, "table-black_fill.docx")
1970 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1971 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
1972 uno::UNO_QUERY);
1973 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1975 uno::Reference<table::XCell> xCell = xTable->getCellByName(u"A1"_ustr);
1976 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty<Color>(xCell, u"BackColor"_ustr));
1979 DECLARE_OOXMLEXPORT_TEST(testTdf116084, "tdf116084.docx")
1981 // tracked line is not a single text portion: w:del is recognized within w:ins
1982 CPPUNIT_ASSERT_EQUAL(u""_ustr, getRun(getParagraph(1), 1)->getString());
1983 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 1), u"RedlineType"_ustr));
1984 CPPUNIT_ASSERT_EQUAL(u"There "_ustr, getRun(getParagraph(1), 2)->getString());
1985 CPPUNIT_ASSERT_EQUAL(u""_ustr, getRun(getParagraph(1), 4)->getString());
1986 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 4), u"RedlineType"_ustr));
1987 CPPUNIT_ASSERT_EQUAL(u"must"_ustr, getRun(getParagraph(1), 5)->getString());
1990 CPPUNIT_TEST_FIXTURE(Test, testTdf116084_anonymized)
1992 loadAndSave("tdf116084.docx");
1993 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
1994 // w:del in w:ins is exported correctly
1995 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del/w:r/w:delText", u"must");
1997 // no date (anonymized changes)
1998 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins[@date]", 0);
1999 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del[@w:date]", 0);
2001 // w:ins and w:del have w:author attributes, and the same
2002 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del[@w:author]", 1);
2003 OUString sAuthor = getXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins[2]", "author");
2004 OUString sAuthor2 = getXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del", "author");
2005 CPPUNIT_ASSERT_EQUAL(sAuthor, sAuthor2);
2008 DECLARE_OOXMLEXPORT_TEST(testTdf121176, "tdf121176.docx")
2010 // w:del is imported correctly when it is in a same size w:ins
2011 CPPUNIT_ASSERT_EQUAL(u""_ustr, getRun(getParagraph(1), 1)->getString());
2012 CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 1), u"RedlineType"_ustr));
2013 CPPUNIT_ASSERT_EQUAL(u"must"_ustr, getRun(getParagraph(1), 2)->getString());
2016 CPPUNIT_TEST_FIXTURE(Test, testTdf121176_anonymized)
2018 loadAndSave("tdf121176.docx");
2019 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
2020 // w:del in w:ins is exported correctly
2021 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del/w:r/w:delText", u"must");
2023 // no date (anonymized changes)
2024 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:p/w:ins", "date");
2025 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del[@w:date]", 0);
2027 // w:ins and w:del have w:author attributes, and the same
2028 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del[@w:author]", 1);
2029 OUString sAuthor = getXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins", "author");
2030 OUString sAuthor2 = getXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del", "author");
2031 CPPUNIT_ASSERT_EQUAL(sAuthor, sAuthor2);
2034 CPPUNIT_TEST_FIXTURE(Test, testTdf128913)
2036 loadAndSave("tdf128913.docx");
2037 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
2038 // w:ins and w:del are imported correctly, if they contain only inline images
2039 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:r/w:drawing/wp:inline/a:graphic");
2040 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:del/w:r/w:drawing/wp:inline/a:graphic");
2043 CPPUNIT_TEST_FIXTURE(Test, testTdf142700)
2045 loadAndSave("tdf142700.docx");
2046 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
2047 // w:ins and w:del are imported correctly, if they contain only images anchored to character
2048 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:r/w:drawing/wp:anchor/a:graphic");
2049 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:del/w:r/w:drawing/wp:anchor/a:graphic");
2052 CPPUNIT_TEST_FIXTURE(Test, testTdf142387)
2054 loadAndSave("tdf142387.docx");
2055 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
2056 // w:del in w:ins is exported correctly (only w:del was exported)
2057 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:del/w:r/w:delText", u"inserts ");
2060 CPPUNIT_TEST_FIXTURE(Test, testTdf147892)
2062 loadAndSave("tdf147892.fodt");
2063 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
2064 // w:del in w:ins is exported correctly
2065 // (both w:del and w:ins were exported for para marker)
2066 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:del", 1);
2067 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:ins", 0);
2070 DECLARE_OOXMLEXPORT_TEST(testTdf123054, "tdf123054.docx")
2072 CPPUNIT_ASSERT_EQUAL(u"No Spacing"_ustr,
2073 getProperty<OUString>(getParagraph(20), u"ParaStyleName"_ustr));
2076 DECLARE_OOXMLEXPORT_TEST(testTdf67207_MERGEFIELD_DATABASE, "tdf67207.docx")
2078 // database fields use the database "database" and its table "Sheet1"
2079 uno::Reference<beans::XPropertySet> xTextField
2080 = getProperty<uno::Reference<beans::XPropertySet>>(getRun(getParagraph(2), 2),
2081 u"TextField"_ustr);
2082 CPPUNIT_ASSERT(xTextField.is());
2083 uno::Reference<lang::XServiceInfo> xServiceInfo(xTextField, uno::UNO_QUERY_THROW);
2084 uno::Reference<text::XDependentTextField> xDependent(xTextField, uno::UNO_QUERY_THROW);
2086 CPPUNIT_ASSERT(xServiceInfo->supportsService(u"com.sun.star.text.TextField.Database"_ustr));
2087 OUString sValue;
2088 xTextField->getPropertyValue(u"Content"_ustr) >>= sValue;
2089 CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8("<c1>"), sValue);
2091 uno::Reference<beans::XPropertySet> xFiledMaster = xDependent->getTextFieldMaster();
2092 uno::Reference<lang::XServiceInfo> xFiledMasterServiceInfo(xFiledMaster, uno::UNO_QUERY_THROW);
2094 CPPUNIT_ASSERT(
2095 xFiledMasterServiceInfo->supportsService(u"com.sun.star.text.fieldmaster.Database"_ustr));
2097 // Defined properties: DataBaseName, Name, DataTableName, DataColumnName, DependentTextFields, DataCommandType, InstanceName, DataBaseURL
2098 CPPUNIT_ASSERT(xFiledMaster->getPropertyValue(u"DataBaseName"_ustr) >>= sValue);
2099 CPPUNIT_ASSERT_EQUAL(u"database"_ustr, sValue);
2100 sal_Int32 nCommandType;
2101 CPPUNIT_ASSERT(xFiledMaster->getPropertyValue(u"DataCommandType"_ustr) >>= nCommandType);
2102 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nCommandType); // css::sdb::CommandType::TABLE
2103 CPPUNIT_ASSERT(xFiledMaster->getPropertyValue(u"DataTableName"_ustr) >>= sValue);
2104 CPPUNIT_ASSERT_EQUAL(u"Sheet1"_ustr, sValue);
2105 CPPUNIT_ASSERT(xFiledMaster->getPropertyValue(u"DataColumnName"_ustr) >>= sValue);
2106 CPPUNIT_ASSERT_EQUAL(u"c1"_ustr, sValue);
2107 CPPUNIT_ASSERT(xFiledMaster->getPropertyValue(u"InstanceName"_ustr) >>= sValue);
2108 CPPUNIT_ASSERT_EQUAL(u"com.sun.star.text.fieldmaster.DataBase.database.Sheet1.c1"_ustr, sValue);
2111 CPPUNIT_TEST_FIXTURE(Test, testTdf101122_noFillForCustomShape)
2113 loadAndSave("tdf101122_noFillForCustomShape.odt");
2114 CPPUNIT_ASSERT_EQUAL(2, getShapes());
2115 CPPUNIT_ASSERT_EQUAL(1, getPages());
2116 // tdf#101122 check whether the "F" (noFill) option has been exported to docx
2117 xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
2119 assertXPath(pXmlDoc,
2120 "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/"
2121 "a:graphic/a:graphicData/wps:wsp/wps:spPr/a:custGeom/a:pathLst/a:path",
2122 "fill", u"none");
2123 assertXPathNoAttribute(
2124 pXmlDoc,
2125 "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
2126 "a:graphicData/wps:wsp/wps:spPr/a:custGeom/a:pathLst/a:path",
2127 "fill");
2129 // The (tdf124678_no_leading_paragraph.odt, tdf124678_with_leading_paragraph.odt) documents are the same,
2130 // except:
2131 // - tdf124678_no_leading_paragraph.odt doesn't contain leading empty paragraph
2132 // before the first section
2134 CPPUNIT_TEST_FIXTURE(Test, testTdf124678_case1)
2136 loadAndReload("tdf124678_no_leading_paragraph.odt");
2137 CPPUNIT_ASSERT_EQUAL(2, getPages());
2138 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
2139 CPPUNIT_ASSERT_EQUAL_MESSAGE("First page header text", u""_ustr,
2140 getXPathContent(pXmlDoc, "/root/page[1]/header/txt"));
2141 CPPUNIT_ASSERT_EQUAL_MESSAGE("Second page header text", u"HEADER"_ustr,
2142 getXPathContent(pXmlDoc, "/root/page[2]/header/txt"));
2145 // The (tdf124678_no_leading_paragraph.odt, tdf124678_with_leading_paragraph.odt) documents are the same,
2146 // except:
2147 // - tdf124678_no_leading_paragraph.odt doesn't contain leading empty paragraph
2148 // before the first section
2150 CPPUNIT_TEST_FIXTURE(Test, testTdf124678_case2)
2152 loadAndReload("tdf124678_with_leading_paragraph.odt");
2153 CPPUNIT_ASSERT_EQUAL(2, getPages());
2154 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
2155 CPPUNIT_ASSERT_EQUAL_MESSAGE("First page header text", u""_ustr,
2156 getXPathContent(pXmlDoc, "/root/page[1]/header/txt"));
2157 CPPUNIT_ASSERT_EQUAL_MESSAGE("Second page header text", u"HEADER"_ustr,
2158 getXPathContent(pXmlDoc, "/root/page[2]/header/txt"));
2161 static bool lcl_nearEqual(const sal_Int32 nNumber1, const sal_Int32 nNumber2,
2162 sal_Int32 nMaxDiff = 5)
2164 return std::abs(nNumber1 - nNumber2) < nMaxDiff;
2167 CPPUNIT_TEST_FIXTURE(Test, testTdf119952_negativeMargins)
2169 auto verify = [this](bool bIsExport = false) {
2170 // With negative margins (in MS Word) one can set up header (or footer) that overlaps with the body.
2171 // LibreOffice unable to display that, so when importing negative margins,
2172 // the header (or footer) converted to a flyframe, anchored to the header..
2173 // that can overlap with the body, and will appear like in Word.
2174 // This conversion modifies the document [i.e. replacing header text with a textbox...]
2175 // but its DOCX export looks the same, as the original document in Word, too.
2176 xmlDocUniquePtr pDump = parseLayoutDump();
2178 //Check layout positions / sizes
2179 sal_Int32 nLeftHead = getXPath(pDump, "//page[1]/header/infos/bounds", "left").toInt32();
2180 sal_Int32 nLeftBody = getXPath(pDump, "//page[1]/body/infos/bounds", "left").toInt32();
2181 sal_Int32 nLeftFoot = getXPath(pDump, "//page[1]/footer/infos/bounds", "left").toInt32();
2182 sal_Int32 nLeftHFly
2183 = getXPath(pDump, "//page[1]/header/txt/anchored/fly/infos/bounds", "left").toInt32();
2184 sal_Int32 nLeftFFly
2185 = getXPath(pDump, "//page[1]/footer/txt/anchored/fly/infos/bounds", "left").toInt32();
2187 sal_Int32 nTopHead = getXPath(pDump, "//page[1]/header/infos/bounds", "top").toInt32();
2188 sal_Int32 nTopBody = getXPath(pDump, "//page[1]/body/infos/bounds", "top").toInt32();
2189 sal_Int32 nTopFoot = getXPath(pDump, "//page[1]/footer/infos/bounds", "top").toInt32();
2190 sal_Int32 nTopHFly
2191 = getXPath(pDump, "//page[1]/header/txt/anchored/fly/infos/bounds", "top").toInt32();
2192 sal_Int32 nTopFFly
2193 = getXPath(pDump, "//page[1]/footer/txt/anchored/fly/infos/bounds", "top").toInt32();
2195 sal_Int32 nHeightHead
2196 = getXPath(pDump, "//page[1]/header/infos/bounds", "height").toInt32();
2197 sal_Int32 nHeightBody = getXPath(pDump, "//page[1]/body/infos/bounds", "height").toInt32();
2198 sal_Int32 nHeightFoot
2199 = getXPath(pDump, "//page[1]/footer/infos/bounds", "height").toInt32();
2200 sal_Int32 nHeightHFly
2201 = getXPath(pDump, "//page[1]/header/txt/anchored/fly/infos/bounds", "height").toInt32();
2202 sal_Int32 nHeightFFly
2203 = getXPath(pDump, "//page[1]/footer/txt/anchored/fly/infos/bounds", "height").toInt32();
2204 sal_Int32 nHeightHFlyBound
2205 = getXPath(pDump, "//page[1]/header/infos/prtBounds", "height").toInt32();
2206 sal_Int32 nHeightFFlyBound
2207 = getXPath(pDump, "//page[1]/footer/infos/prtBounds", "height").toInt32();
2209 CPPUNIT_ASSERT(lcl_nearEqual(nLeftHead, nLeftBody));
2210 CPPUNIT_ASSERT(lcl_nearEqual(nLeftHead, nLeftFoot));
2211 CPPUNIT_ASSERT(lcl_nearEqual(nLeftHead, nLeftHFly));
2212 CPPUNIT_ASSERT(lcl_nearEqual(nLeftHead, nLeftFFly));
2214 CPPUNIT_ASSERT(lcl_nearEqual(nTopHead, 851));
2215 CPPUNIT_ASSERT(lcl_nearEqual(nTopBody, 1418));
2216 CPPUNIT_ASSERT(lcl_nearEqual(nTopFoot, 15875));
2217 CPPUNIT_ASSERT(lcl_nearEqual(nTopHFly, 851));
2219 // this seems to be an import bug
2220 if (!bIsExport)
2221 CPPUNIT_ASSERT(lcl_nearEqual(nTopFFly, 14403));
2223 CPPUNIT_ASSERT(lcl_nearEqual(nHeightHead, 567));
2224 CPPUNIT_ASSERT(lcl_nearEqual(nHeightBody, 14457));
2225 CPPUNIT_ASSERT(lcl_nearEqual(nHeightFoot, 680));
2226 CPPUNIT_ASSERT(lcl_nearEqual(nHeightHFly, 2152));
2227 CPPUNIT_ASSERT(lcl_nearEqual(nHeightFFly, 2152));
2229 // after export these heights increase to like 567.
2230 // not sure if it is another import, or export bug... or just the result of the modified document
2231 if (!bIsExport)
2233 CPPUNIT_ASSERT(lcl_nearEqual(nHeightHFlyBound, 57));
2234 CPPUNIT_ASSERT(lcl_nearEqual(nHeightFFlyBound, 57));
2237 //Check text of header/ footer
2238 assertXPath(
2239 pDump,
2240 "//page[1]/header/txt/anchored/fly/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
2241 "portion", u"f1");
2242 assertXPath(
2243 pDump,
2244 "//page[1]/header/txt/anchored/fly/txt[8]/SwParaPortion/SwLineLayout/SwParaPortion",
2245 "portion", u" f8");
2246 assertXPath(
2247 pDump,
2248 "//page[1]/footer/txt/anchored/fly/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
2249 "portion", u" f8");
2250 assertXPath(
2251 pDump,
2252 "//page[1]/footer/txt/anchored/fly/txt[8]/SwParaPortion/SwLineLayout/SwParaPortion",
2253 "portion", u"f1");
2255 assertXPath(
2256 pDump,
2257 "//page[2]/header/txt/anchored/fly/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
2258 "portion", u"p1");
2259 assertXPath(
2260 pDump,
2261 "//page[2]/footer/txt/anchored/fly/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
2262 "portion", u"p1");
2264 assertXPath(
2265 pDump,
2266 "//page[3]/header/txt/anchored/fly/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
2267 "portion", u" aaaa");
2268 assertXPath(
2269 pDump,
2270 "//page[3]/header/txt/anchored/fly/txt[5]/SwParaPortion/SwLineLayout/SwParaPortion",
2271 "portion", u" eeee");
2273 assertXPathContent(pDump, "/root/page[1]/header/txt/anchored/fly",
2274 u"f1 f2 f3 f4 f5 f6 "
2275 " f7 f8");
2276 assertXPathContent(pDump, "/root/page[1]/footer/txt/anchored/fly",
2277 u" f8 f7 f6 f5 "
2278 " f4 f3 f2f1");
2279 assertXPathContent(pDump, "/root/page[2]/header/txt/anchored/fly", u"p1");
2280 assertXPathContent(pDump, "/root/page[2]/footer/txt/anchored/fly", u"p1");
2281 assertXPathContent(pDump, "/root/page[3]/header/txt/anchored/fly",
2282 u" aaaa bbbb cccc dddd eeee");
2285 createSwDoc("tdf119952_negativeMargins.docx");
2286 verify();
2287 saveAndReload(mpFilter);
2288 verify(/*bIsExport*/ true);
2291 DECLARE_OOXMLEXPORT_TEST(testTdf143384_tableInFoot_negativeMargins,
2292 "tdf143384_tableInFoot_negativeMargins.docx")
2294 // There should be no crash during loading of the document
2295 // so, let's check just how much pages we have
2296 // Ideally this would be 1, matching Word.
2297 CPPUNIT_ASSERT_EQUAL(2, getPages());
2300 CPPUNIT_PLUGIN_IMPLEMENT();
2302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */