android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / qa / extras / layout / layout.cxx
blobebb63e07eef953c4c1df47f36c5912b8e1367130
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>
11 #include <comphelper/propertysequence.hxx>
12 #include <vcl/scheduler.hxx>
13 #include <svx/svddef.hxx>
15 #include <fmtanchr.hxx>
16 #include <fmtfsize.hxx>
17 #include <fmtcntnt.hxx>
18 #include <wrtsh.hxx>
19 #include <unotxdoc.hxx>
20 #include <rootfrm.hxx>
21 #include <IDocumentLayoutAccess.hxx>
22 #include <IDocumentRedlineAccess.hxx>
23 #include <unoframe.hxx>
25 /// Test to assert layout / rendering result of Writer.
26 class SwLayoutWriter : public SwModelTestBase
28 public:
29 SwLayoutWriter()
30 : SwModelTestBase("/sw/qa/extras/layout/data/")
34 protected:
35 void CheckRedlineFootnotesHidden();
36 void CheckRedlineSectionsHidden();
39 // this is a member because our test classes have protected members :(
40 void SwLayoutWriter::CheckRedlineFootnotesHidden()
42 discardDumpedLayout();
43 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
44 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "24");
45 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
46 "type", "PortionType::Footnote");
47 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
48 "expand", "1");
49 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
50 "type", "PortionType::Text");
51 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
52 "portion", "foaz");
53 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
54 "type", "PortionType::Footnote");
55 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
56 "expand", "2");
57 assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex", "13");
58 assertXPath(pXmlDoc,
59 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
60 "type", "PortionType::FootnoteNum");
61 assertXPath(pXmlDoc,
62 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
63 "expand", "1");
64 assertXPath(pXmlDoc,
65 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
66 "type", "PortionType::Text");
67 assertXPath(pXmlDoc,
68 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
69 "portion", "ac");
70 assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/merged", "paraPropsNodeIndex", "16");
71 assertXPath(pXmlDoc,
72 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
73 "type", "PortionType::FootnoteNum");
74 assertXPath(pXmlDoc,
75 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
76 "expand", "2");
77 assertXPath(pXmlDoc,
78 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
79 "type", "PortionType::Text");
80 assertXPath(pXmlDoc,
81 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
82 "portion", "mo");
85 void SwLayoutWriter::CheckRedlineSectionsHidden()
87 discardDumpedLayout();
88 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
89 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "12");
90 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
91 "type", "PortionType::Para");
92 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
93 "portion", "folah");
94 assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[1]/merged", "paraPropsNodeIndex", "20");
95 assertXPath(pXmlDoc,
96 "/root/page[1]/body/section[1]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
97 "type", "PortionType::Para");
98 assertXPath(pXmlDoc,
99 "/root/page[1]/body/section[1]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
100 "portion", "folah");
103 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf156077)
105 createSwDoc("s4_min2.fodt");
107 CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of pages does not match!", 3, getPages());
108 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
109 assertXPath(pXmlDoc, "/root/page[1]/anchored/fly", 3);
110 assertXPath(pXmlDoc, "/root/page[2]/anchored/fly", 1);
111 // this was 0, the at-page anchored flys were not displayed
112 assertXPath(pXmlDoc, "/root/page[3]/anchored/fly", 3);
115 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFootnotes)
117 createSwDoc("redline_footnotes.odt");
118 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
119 CPPUNIT_ASSERT(pTextDoc);
120 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
121 SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
122 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
124 // verify after load
125 CheckRedlineFootnotesHidden();
127 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
128 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
129 discardDumpedLayout();
130 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
132 // show: nothing is merged
133 assertXPath(pXmlDoc, "//merged", 0);
135 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
136 "type", "PortionType::Footnote");
137 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
138 "expand", "1");
139 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
140 "type", "PortionType::Text");
141 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
142 "portion", "fo");
143 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
144 "type", "PortionType::Text");
145 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
146 "portion", "o");
147 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
148 "type", "PortionType::Footnote");
149 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
150 "expand", "2");
152 assertXPath(pXmlDoc,
153 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
154 "type", "PortionType::FootnoteNum");
155 assertXPath(pXmlDoc,
156 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
157 "expand", "1");
158 assertXPath(pXmlDoc,
159 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
160 "type", "PortionType::Text");
161 assertXPath(pXmlDoc,
162 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
163 "portion", "a");
164 assertXPath(pXmlDoc,
165 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
166 "type", "PortionType::Text");
167 assertXPath(pXmlDoc,
168 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
169 "portion", "b");
170 assertXPath(pXmlDoc,
171 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[3]",
172 "type", "PortionType::Text");
173 assertXPath(pXmlDoc,
174 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[3]",
175 "portion", "c");
176 assertXPath(pXmlDoc,
177 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
178 "type", "PortionType::FootnoteNum");
179 assertXPath(pXmlDoc,
180 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
181 "expand", "2");
182 assertXPath(pXmlDoc,
183 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
184 "type", "PortionType::Text");
185 assertXPath(pXmlDoc,
186 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
187 "portion", "def");
188 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
189 "type", "PortionType::Text");
190 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
191 "portion", "b");
192 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
193 "type", "PortionType::Footnote");
194 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
195 "expand", "3");
196 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
197 "type", "PortionType::Text");
198 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
199 "portion", "ar");
200 assertXPath(pXmlDoc,
201 "/root/page[1]/ftncont/ftn[3]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
202 "type", "PortionType::FootnoteNum");
203 assertXPath(pXmlDoc,
204 "/root/page[1]/ftncont/ftn[3]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
205 "expand", "3");
206 assertXPath(pXmlDoc,
207 "/root/page[1]/ftncont/ftn[3]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
208 "type", "PortionType::Text");
209 assertXPath(pXmlDoc,
210 "/root/page[1]/ftncont/ftn[3]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
211 "portion", "ghi");
212 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
213 "type", "PortionType::Footnote");
214 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
215 "expand", "4");
216 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
217 "type", "PortionType::Text");
218 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
219 "portion", "b");
220 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
221 "type", "PortionType::Text");
222 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
223 "portion", "az");
224 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
225 "type", "PortionType::Footnote");
226 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
227 "expand", "5");
229 assertXPath(pXmlDoc,
230 "/root/page[1]/ftncont/ftn[4]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
231 "type", "PortionType::FootnoteNum");
232 assertXPath(pXmlDoc,
233 "/root/page[1]/ftncont/ftn[4]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
234 "expand", "4");
235 assertXPath(pXmlDoc,
236 "/root/page[1]/ftncont/ftn[4]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
237 "type", "PortionType::Text");
238 assertXPath(pXmlDoc,
239 "/root/page[1]/ftncont/ftn[4]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
240 "portion", "jkl");
241 assertXPath(pXmlDoc,
242 "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
243 "type", "PortionType::FootnoteNum");
244 assertXPath(pXmlDoc,
245 "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
246 "expand", "5");
247 assertXPath(pXmlDoc,
248 "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
249 "type", "PortionType::Text");
250 assertXPath(pXmlDoc,
251 "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
252 "portion", "m");
253 assertXPath(pXmlDoc,
254 "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
255 "type", "PortionType::Text");
256 assertXPath(pXmlDoc,
257 "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
258 "portion", "n");
259 assertXPath(pXmlDoc,
260 "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[3]",
261 "type", "PortionType::Text");
262 assertXPath(pXmlDoc,
263 "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[3]",
264 "portion", "o");
266 // verify after hide
267 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
268 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
269 discardDumpedLayout();
270 CheckRedlineFootnotesHidden();
273 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf136588)
275 createSwDoc("tdf136588.docx");
276 auto pXMLLayoutDump = parseLayoutDump();
277 CPPUNIT_ASSERT(pXMLLayoutDump);
279 //there was a bad line break before, the correct break layout is this:
280 assertXPath(pXMLLayoutDump, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[2]", "portion",
281 "effectively by modern-day small to ");
284 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody)
286 createSwDoc();
287 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
288 CPPUNIT_ASSERT(pTextDoc);
289 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
290 SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
291 SwRootFrame* pLayout(pWrtShell->GetLayout());
292 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
293 pWrtShell->Insert("foo");
294 pWrtShell->SplitNode(false);
295 pWrtShell->Insert("bar");
296 pWrtShell->SplitNode(false);
297 pWrtShell->Insert("baz");
298 SfxItemSet flySet(pDoc->GetAttrPool(),
299 svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>);
300 SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR);
301 pWrtShell->StartOfSection(false);
302 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
303 anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint());
304 flySet.Put(anchor);
305 SwFormatFrameSize size(SwFrameSize::Minimum, 1000, 1000);
306 flySet.Put(size); // set a size, else we get 1 char per line...
307 SwFrameFormat const* pFly = pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true);
308 CPPUNIT_ASSERT(pFly != nullptr);
309 // move inside fly
310 pWrtShell->GotoFly(pFly->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
311 pWrtShell->Insert("abc");
312 pWrtShell->SplitNode(false);
313 pWrtShell->Insert("def");
314 pWrtShell->SplitNode(false);
315 pWrtShell->Insert("ghi");
317 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
318 // delete redline inside fly
319 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
320 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 8, /*bBasicCall=*/false);
321 pWrtShell->Delete();
323 pWrtShell->SttEndDoc(true); // note: SttDoc actually moves to start of fly?
324 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
325 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false);
326 pWrtShell->Delete();
328 for (int i = 0; i < 2; ++i)
330 if (i == 1) // secondly, try with different anchor type
332 anchor.SetType(RndStdIds::FLY_AT_PARA);
333 SwPosition pos(*anchor.GetAnchorNode());
334 pos.nContent.Assign(nullptr, 0);
335 anchor.SetAnchor(&pos);
336 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
339 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
340 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
341 discardDumpedLayout();
342 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
343 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "14");
344 assertXPath(pXmlDoc,
345 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
346 "PortionType::Para");
347 assertXPath(pXmlDoc,
348 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
349 "portion", "foaz");
350 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/merged",
351 "paraPropsNodeIndex", "6");
352 assertXPath(pXmlDoc,
353 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
354 "SwParaPortion[1]",
355 "type", "PortionType::Para");
356 assertXPath(pXmlDoc,
357 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
358 "SwParaPortion[1]",
359 "portion", "ahi");
361 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
362 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
363 discardDumpedLayout();
364 pXmlDoc = parseLayoutDump();
366 // show: nothing is merged
367 assertXPath(pXmlDoc, "//merged", 0);
369 assertXPath(pXmlDoc,
370 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
371 "PortionType::Text");
372 assertXPath(pXmlDoc,
373 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
374 "portion", "fo");
375 assertXPath(pXmlDoc,
376 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
377 "PortionType::Text");
378 assertXPath(pXmlDoc,
379 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
380 "portion", "o");
381 assertXPath(pXmlDoc,
382 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
383 "SwLinePortion[1]",
384 "type", "PortionType::Text");
385 assertXPath(pXmlDoc,
386 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
387 "SwLinePortion[1]",
388 "portion", "a");
389 assertXPath(pXmlDoc,
390 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
391 "SwLinePortion[2]",
392 "type", "PortionType::Text");
393 assertXPath(pXmlDoc,
394 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
395 "SwLinePortion[2]",
396 "portion", "bc");
397 assertXPath(pXmlDoc,
398 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
399 "SwParaPortion[1]",
400 "type", "PortionType::Para");
401 assertXPath(pXmlDoc,
402 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
403 "SwParaPortion[1]",
404 "portion", "def");
405 assertXPath(pXmlDoc,
406 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
407 "SwLinePortion[1]",
408 "type", "PortionType::Text");
409 assertXPath(pXmlDoc,
410 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
411 "SwLinePortion[1]",
412 "portion", "g");
413 assertXPath(pXmlDoc,
414 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
415 "SwLinePortion[2]",
416 "type", "PortionType::Text");
417 assertXPath(pXmlDoc,
418 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
419 "SwLinePortion[2]",
420 "portion", "hi");
421 assertXPath(pXmlDoc,
422 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
423 "PortionType::Para");
424 assertXPath(pXmlDoc,
425 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
426 "portion", "bar");
427 assertXPath(pXmlDoc,
428 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
429 "PortionType::Text");
430 assertXPath(pXmlDoc,
431 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
432 "portion", "b");
433 assertXPath(pXmlDoc,
434 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
435 "PortionType::Text");
436 assertXPath(pXmlDoc,
437 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
438 "portion", "az");
441 // anchor to 2nd (deleted) paragraph
442 pWrtShell->StartOfSection();
443 pWrtShell->Down(false, 1);
444 anchor.SetType(RndStdIds::FLY_AT_CHAR);
445 anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint());
446 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
448 for (int i = 0; i < 2; ++i)
450 if (i == 1) // secondly, try with different anchor type
452 anchor.SetType(RndStdIds::FLY_AT_PARA);
453 SwPosition pos(*anchor.GetAnchorNode());
454 pos.nContent.Assign(nullptr, 0);
455 anchor.SetAnchor(&pos);
456 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
459 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
460 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
461 discardDumpedLayout();
462 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
463 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "14");
464 assertXPath(pXmlDoc,
465 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
466 "PortionType::Para");
467 assertXPath(pXmlDoc,
468 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
469 "portion", "foaz");
471 // hide: no anchored object shown
472 assertXPath(pXmlDoc, "//anchored", 0);
474 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
475 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
476 discardDumpedLayout();
477 pXmlDoc = parseLayoutDump();
479 // show: nothing is merged
480 assertXPath(pXmlDoc, "//merged", 0);
482 assertXPath(pXmlDoc,
483 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
484 "PortionType::Text");
485 assertXPath(pXmlDoc,
486 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
487 "portion", "fo");
488 assertXPath(pXmlDoc,
489 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
490 "PortionType::Text");
491 assertXPath(pXmlDoc,
492 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
493 "portion", "o");
494 assertXPath(pXmlDoc,
495 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
496 "PortionType::Para");
497 assertXPath(pXmlDoc,
498 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
499 "portion", "bar");
500 assertXPath(pXmlDoc,
501 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
502 "SwLinePortion[1]",
503 "type", "PortionType::Text");
504 assertXPath(pXmlDoc,
505 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
506 "SwLinePortion[1]",
507 "portion", "a");
508 assertXPath(pXmlDoc,
509 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
510 "SwLinePortion[2]",
511 "type", "PortionType::Text");
512 assertXPath(pXmlDoc,
513 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
514 "SwLinePortion[2]",
515 "portion", "bc");
516 assertXPath(pXmlDoc,
517 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
518 "SwParaPortion[1]",
519 "type", "PortionType::Para");
520 assertXPath(pXmlDoc,
521 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
522 "SwParaPortion[1]",
523 "portion", "def");
524 assertXPath(pXmlDoc,
525 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
526 "SwLinePortion[1]",
527 "type", "PortionType::Text");
528 assertXPath(pXmlDoc,
529 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
530 "SwLinePortion[1]",
531 "portion", "g");
532 assertXPath(pXmlDoc,
533 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
534 "SwLinePortion[2]",
535 "type", "PortionType::Text");
536 assertXPath(pXmlDoc,
537 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
538 "SwLinePortion[2]",
539 "portion", "hi");
540 assertXPath(pXmlDoc,
541 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
542 "PortionType::Text");
543 assertXPath(pXmlDoc,
544 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
545 "portion", "b");
546 assertXPath(pXmlDoc,
547 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
548 "PortionType::Text");
549 assertXPath(pXmlDoc,
550 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
551 "portion", "az");
554 // anchor to 3rd paragraph
555 pWrtShell->EndOfSection();
556 anchor.SetType(RndStdIds::FLY_AT_CHAR);
557 anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint());
558 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
560 for (int i = 0; i < 2; ++i)
562 if (i == 1) // secondly, try with different anchor type
564 anchor.SetType(RndStdIds::FLY_AT_PARA);
565 SwPosition pos(*anchor.GetAnchorNode());
566 pos.nContent.Assign(nullptr, 0);
567 anchor.SetAnchor(&pos);
568 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
571 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
572 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
573 discardDumpedLayout();
574 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
575 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "14");
576 assertXPath(pXmlDoc,
577 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
578 "PortionType::Para");
579 assertXPath(pXmlDoc,
580 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
581 "portion", "foaz");
582 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/merged",
583 "paraPropsNodeIndex", "6");
584 assertXPath(pXmlDoc,
585 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
586 "SwParaPortion[1]",
587 "type", "PortionType::Para");
588 assertXPath(pXmlDoc,
589 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
590 "SwParaPortion[1]",
591 "portion", "ahi");
593 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
594 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
595 discardDumpedLayout();
596 pXmlDoc = parseLayoutDump();
598 // show: nothing is merged
599 assertXPath(pXmlDoc, "//merged", 0);
601 assertXPath(pXmlDoc,
602 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
603 "PortionType::Text");
604 assertXPath(pXmlDoc,
605 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
606 "portion", "fo");
607 assertXPath(pXmlDoc,
608 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
609 "PortionType::Text");
610 assertXPath(pXmlDoc,
611 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
612 "portion", "o");
613 assertXPath(pXmlDoc,
614 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
615 "PortionType::Para");
616 assertXPath(pXmlDoc,
617 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
618 "portion", "bar");
619 assertXPath(pXmlDoc,
620 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
621 "PortionType::Text");
622 assertXPath(pXmlDoc,
623 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
624 "portion", "b");
625 assertXPath(pXmlDoc,
626 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
627 "PortionType::Text");
628 assertXPath(pXmlDoc,
629 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
630 "portion", "az");
631 assertXPath(pXmlDoc,
632 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
633 "SwLinePortion[1]",
634 "type", "PortionType::Text");
635 assertXPath(pXmlDoc,
636 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
637 "SwLinePortion[1]",
638 "portion", "a");
639 assertXPath(pXmlDoc,
640 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
641 "SwLinePortion[2]",
642 "type", "PortionType::Text");
643 assertXPath(pXmlDoc,
644 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
645 "SwLinePortion[2]",
646 "portion", "bc");
647 assertXPath(pXmlDoc,
648 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
649 "SwParaPortion[1]",
650 "type", "PortionType::Para");
651 assertXPath(pXmlDoc,
652 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
653 "SwParaPortion[1]",
654 "portion", "def");
655 assertXPath(pXmlDoc,
656 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
657 "SwLinePortion[1]",
658 "type", "PortionType::Text");
659 assertXPath(pXmlDoc,
660 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
661 "SwLinePortion[1]",
662 "portion", "g");
663 assertXPath(pXmlDoc,
664 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
665 "SwLinePortion[2]",
666 "type", "PortionType::Text");
667 assertXPath(pXmlDoc,
668 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
669 "SwLinePortion[2]",
670 "portion", "hi");
674 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf134272)
676 createSwDoc("tdf134472.odt");
677 SwDoc* pDoc = getSwDoc();
678 CPPUNIT_ASSERT(pDoc);
679 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
680 assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/infos/bounds", "height", "843");
681 assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/infos/bounds", "bottom", "2819");
684 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestNestedTableMoveFwd)
686 createSwDoc("tabellen_test_windows_1.odt");
687 SwDoc* pDoc = getSwDoc();
688 CPPUNIT_ASSERT(pDoc);
689 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
690 // the row with the nested table should not be split but be the first row on page 2
691 assertXPathContent(pXmlDoc, "/root/page[1]/body/tab[1]/row[last()]/cell[1]/txt[1]",
692 "Tabelle 1");
693 assertXPathContent(
694 pXmlDoc, "/root/page[2]/body/tab[1]/row[1]/cell[1]/tab[1]/row[1]/cell[1]/txt", "Tabelle 2");
697 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf136613)
699 createSwDoc("tdf136613.docx");
700 SwDoc* pDoc = getSwDoc();
701 CPPUNIT_ASSERT(pDoc);
703 //get the flys and the root frame
704 const auto vFlyFormats = pDoc->GetFlyFrameFormats(FLYCNTTYPE_ALL, true);
705 const auto vFrames = pDoc->GetAllLayouts();
707 CPPUNIT_ASSERT(!vFrames.empty());
708 CPPUNIT_ASSERT(!vFlyFormats.empty());
710 //get the page frame from the root
711 SwFrame* pPageFrame = vFrames[0]->Lower();
712 CPPUNIT_ASSERT(pPageFrame);
714 //get the rectangle of the page
715 const SwRect& rPageRect = pPageFrame->getFrameArea();
717 //check the flys and...
718 for (auto pFlyFormat : vFlyFormats)
720 //...the rectangle of the fly location...
721 const SwRect& rRect = pFlyFormat->FindLayoutRect();
722 CPPUNIT_ASSERT(!rRect.IsEmpty());
724 //...if it is on the page. This will fail if not.
725 CPPUNIT_ASSERT_MESSAGE("The pictures are outside the page!", rPageRect.Contains(rRect));
729 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf88496)
731 createSwDoc("tdf88496.docx");
732 SwDoc* pDoc = getSwDoc();
733 CPPUNIT_ASSERT(pDoc);
734 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
735 // This was 4, table fallback "switch off repeating header" started on a new page
736 assertXPath(pXmlDoc, "/root/page", 3);
739 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader)
741 createSwDoc();
742 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
743 CPPUNIT_ASSERT(pTextDoc);
744 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
745 SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
746 SwRootFrame* pLayout(pWrtShell->GetLayout());
747 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
748 pWrtShell->ChangeHeaderOrFooter(u"Default Page Style", /*bHeader*/ true, /*bOn*/ true, false);
749 CPPUNIT_ASSERT(
750 pWrtShell
751 ->IsInHeaderFooter()); // assume this is supposed to put cursor in the new header...
752 pWrtShell->Insert("foo");
753 pWrtShell->SplitNode(false);
754 pWrtShell->Insert("bar");
755 pWrtShell->SplitNode(false);
756 pWrtShell->Insert("baz");
757 SfxItemSet flySet(pDoc->GetAttrPool(),
758 svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>);
759 SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR);
760 pWrtShell->StartOfSection(false);
761 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
762 anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint());
763 flySet.Put(anchor);
764 SwFormatFrameSize size(SwFrameSize::Minimum, 1000, 1000);
765 flySet.Put(size); // set a size, else we get 1 char per line...
766 SwFrameFormat const* pFly = pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true);
767 CPPUNIT_ASSERT(pFly != nullptr);
768 // move inside fly
769 pWrtShell->GotoFly(pFly->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
770 pWrtShell->Insert("abc");
771 pWrtShell->SplitNode(false);
772 pWrtShell->Insert("def");
773 pWrtShell->SplitNode(false);
774 pWrtShell->Insert("ghi");
776 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
777 // delete redline inside fly
778 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
779 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 8, /*bBasicCall=*/false);
780 pWrtShell->Delete();
782 pWrtShell->GotoHeaderText();
783 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
784 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false);
785 pWrtShell->Delete();
787 for (int i = 0; i < 2; ++i)
789 if (i == 1) // secondly, try with different anchor type
791 anchor.SetType(RndStdIds::FLY_AT_PARA);
792 SwPosition pos(*anchor.GetAnchorNode());
793 pos.nContent.Assign(nullptr, 0);
794 anchor.SetAnchor(&pos);
795 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
798 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
799 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
800 discardDumpedLayout();
801 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
802 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout", "type",
803 "PortionType::Para");
804 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "length",
805 "0");
806 assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/merged", "paraPropsNodeIndex", "6");
807 assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout[1]", "type",
808 "PortionType::Para");
809 assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout[1]", "portion",
810 "foaz");
811 assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/merged",
812 "paraPropsNodeIndex", "11");
813 assertXPath(
814 pXmlDoc,
815 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout[1]",
816 "type", "PortionType::Para");
817 assertXPath(
818 pXmlDoc,
819 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout[1]",
820 "portion", "ahi");
822 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
823 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
824 discardDumpedLayout();
825 pXmlDoc = parseLayoutDump();
827 // show: nothing is merged
828 assertXPath(pXmlDoc, "//merged", 0);
830 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "type",
831 "PortionType::Para");
832 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "length",
833 "0");
834 assertXPath(pXmlDoc,
835 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
836 "type", "PortionType::Text");
837 assertXPath(pXmlDoc,
838 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
839 "portion", "fo");
840 assertXPath(pXmlDoc,
841 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
842 "type", "PortionType::Text");
843 assertXPath(pXmlDoc,
844 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
845 "portion", "o");
846 assertXPath(pXmlDoc,
847 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
848 "SwLinePortion[1]",
849 "type", "PortionType::Text");
850 assertXPath(pXmlDoc,
851 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
852 "SwLinePortion[1]",
853 "portion", "a");
854 assertXPath(pXmlDoc,
855 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
856 "SwLinePortion[2]",
857 "type", "PortionType::Text");
858 assertXPath(pXmlDoc,
859 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
860 "SwLinePortion[2]",
861 "portion", "bc");
862 assertXPath(pXmlDoc,
863 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
864 "SwParaPortion[1]",
865 "type", "PortionType::Para");
866 assertXPath(pXmlDoc,
867 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
868 "SwParaPortion[1]",
869 "portion", "def");
870 assertXPath(pXmlDoc,
871 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
872 "SwLinePortion[1]",
873 "type", "PortionType::Text");
874 assertXPath(pXmlDoc,
875 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
876 "SwLinePortion[1]",
877 "portion", "g");
878 assertXPath(pXmlDoc,
879 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
880 "SwLinePortion[2]",
881 "type", "PortionType::Text");
882 assertXPath(pXmlDoc,
883 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
884 "SwLinePortion[2]",
885 "portion", "hi");
886 assertXPath(pXmlDoc,
887 "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
888 "type", "PortionType::Para");
889 assertXPath(pXmlDoc,
890 "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
891 "portion", "bar");
892 assertXPath(pXmlDoc,
893 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
894 "type", "PortionType::Text");
895 assertXPath(pXmlDoc,
896 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
897 "portion", "b");
898 assertXPath(pXmlDoc,
899 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
900 "type", "PortionType::Text");
901 assertXPath(pXmlDoc,
902 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
903 "portion", "az");
906 // anchor to 2nd (deleted) paragraph
907 pWrtShell->StartOfSection();
908 pWrtShell->Down(false, 1);
909 anchor.SetType(RndStdIds::FLY_AT_CHAR);
910 anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint());
911 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
913 for (int i = 0; i < 2; ++i)
915 if (i == 1) // secondly, try with different anchor type
917 anchor.SetType(RndStdIds::FLY_AT_PARA);
918 SwPosition pos(*anchor.GetAnchorNode());
919 pos.nContent.Assign(nullptr, 0);
920 anchor.SetAnchor(&pos);
921 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
924 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
925 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
926 discardDumpedLayout();
927 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
928 // now the frame has no Text portion? not sure why it's a 0-length one first and now none?
929 // assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", "PortionType::Para");
930 // assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "length", "0");
931 assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/merged", "paraPropsNodeIndex", "6");
932 assertXPath(pXmlDoc,
933 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
934 "type", "PortionType::Para");
935 assertXPath(pXmlDoc,
936 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
937 "portion", "foaz");
939 // hide: no anchored object shown
940 assertXPath(pXmlDoc, "//anchored", 0);
942 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
943 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
944 discardDumpedLayout();
945 pXmlDoc = parseLayoutDump();
947 // show: nothing is merged
948 assertXPath(pXmlDoc, "//merged", 0);
950 assertXPath(pXmlDoc,
951 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
952 "PortionType::Para");
953 assertXPath(pXmlDoc,
954 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
955 "length", "0");
956 assertXPath(pXmlDoc,
957 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
958 "type", "PortionType::Text");
959 assertXPath(pXmlDoc,
960 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
961 "portion", "fo");
962 assertXPath(pXmlDoc,
963 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
964 "type", "PortionType::Text");
965 assertXPath(pXmlDoc,
966 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
967 "portion", "o");
968 assertXPath(pXmlDoc,
969 "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
970 "type", "PortionType::Para");
971 assertXPath(pXmlDoc,
972 "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
973 "portion", "bar");
974 assertXPath(pXmlDoc,
975 "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
976 "SwLinePortion[1]",
977 "type", "PortionType::Text");
978 assertXPath(pXmlDoc,
979 "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
980 "SwLinePortion[1]",
981 "portion", "a");
982 assertXPath(pXmlDoc,
983 "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
984 "SwLinePortion[2]",
985 "type", "PortionType::Text");
986 assertXPath(pXmlDoc,
987 "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
988 "SwLinePortion[2]",
989 "portion", "bc");
990 assertXPath(pXmlDoc,
991 "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
992 "SwParaPortion[1]",
993 "type", "PortionType::Para");
994 assertXPath(pXmlDoc,
995 "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
996 "SwParaPortion[1]",
997 "portion", "def");
998 assertXPath(pXmlDoc,
999 "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
1000 "SwLinePortion[1]",
1001 "type", "PortionType::Text");
1002 assertXPath(pXmlDoc,
1003 "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
1004 "SwLinePortion[1]",
1005 "portion", "g");
1006 assertXPath(pXmlDoc,
1007 "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
1008 "SwLinePortion[2]",
1009 "type", "PortionType::Text");
1010 assertXPath(pXmlDoc,
1011 "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
1012 "SwLinePortion[2]",
1013 "portion", "hi");
1014 assertXPath(pXmlDoc,
1015 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1016 "type", "PortionType::Text");
1017 assertXPath(pXmlDoc,
1018 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1019 "portion", "b");
1020 assertXPath(pXmlDoc,
1021 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1022 "type", "PortionType::Text");
1023 assertXPath(pXmlDoc,
1024 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1025 "portion", "az");
1028 // anchor to 3rd paragraph
1029 pWrtShell->EndOfSection();
1030 anchor.SetType(RndStdIds::FLY_AT_CHAR);
1031 anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint());
1032 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
1034 for (int i = 0; i < 2; ++i)
1036 if (i == 1) // secondly, try with different anchor type
1038 anchor.SetType(RndStdIds::FLY_AT_PARA);
1039 SwPosition pos(*anchor.GetAnchorNode());
1040 pos.nContent.Assign(nullptr, 0);
1041 anchor.SetAnchor(&pos);
1042 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
1045 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
1046 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
1047 discardDumpedLayout();
1048 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1049 assertXPath(pXmlDoc,
1050 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
1051 "PortionType::Para");
1052 assertXPath(pXmlDoc,
1053 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1054 "length", "0");
1055 assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/merged", "paraPropsNodeIndex", "6");
1056 assertXPath(pXmlDoc,
1057 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1058 "type", "PortionType::Para");
1059 assertXPath(pXmlDoc,
1060 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1061 "portion", "foaz");
1062 assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/merged",
1063 "paraPropsNodeIndex", "11");
1064 assertXPath(pXmlDoc,
1065 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
1066 "SwParaPortion[1]",
1067 "type", "PortionType::Para");
1068 assertXPath(pXmlDoc,
1069 "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
1070 "SwParaPortion[1]",
1071 "portion", "ahi");
1073 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
1074 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
1075 discardDumpedLayout();
1076 pXmlDoc = parseLayoutDump();
1078 // show: nothing is merged
1079 assertXPath(pXmlDoc, "//merged", 0);
1081 assertXPath(pXmlDoc,
1082 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
1083 "PortionType::Para");
1084 assertXPath(pXmlDoc,
1085 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1086 "length", "0");
1087 assertXPath(pXmlDoc,
1088 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1089 "type", "PortionType::Text");
1090 assertXPath(pXmlDoc,
1091 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1092 "portion", "fo");
1093 assertXPath(pXmlDoc,
1094 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1095 "type", "PortionType::Text");
1096 assertXPath(pXmlDoc,
1097 "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1098 "portion", "o");
1099 assertXPath(pXmlDoc,
1100 "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1101 "type", "PortionType::Para");
1102 assertXPath(pXmlDoc,
1103 "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1104 "portion", "bar");
1105 assertXPath(pXmlDoc,
1106 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1107 "type", "PortionType::Text");
1108 assertXPath(pXmlDoc,
1109 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1110 "portion", "b");
1111 assertXPath(pXmlDoc,
1112 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1113 "type", "PortionType::Text");
1114 assertXPath(pXmlDoc,
1115 "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1116 "portion", "az");
1117 assertXPath(pXmlDoc,
1118 "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
1119 "SwLinePortion[1]",
1120 "type", "PortionType::Text");
1121 assertXPath(pXmlDoc,
1122 "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
1123 "SwLinePortion[1]",
1124 "portion", "a");
1125 assertXPath(pXmlDoc,
1126 "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
1127 "SwLinePortion[2]",
1128 "type", "PortionType::Text");
1129 assertXPath(pXmlDoc,
1130 "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
1131 "SwLinePortion[2]",
1132 "portion", "bc");
1133 assertXPath(pXmlDoc,
1134 "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
1135 "SwParaPortion[1]",
1136 "type", "PortionType::Para");
1137 assertXPath(pXmlDoc,
1138 "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
1139 "SwParaPortion[1]",
1140 "portion", "def");
1141 assertXPath(pXmlDoc,
1142 "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
1143 "SwLinePortion[1]",
1144 "type", "PortionType::Text");
1145 assertXPath(pXmlDoc,
1146 "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
1147 "SwLinePortion[1]",
1148 "portion", "g");
1149 assertXPath(pXmlDoc,
1150 "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
1151 "SwLinePortion[2]",
1152 "type", "PortionType::Text");
1153 assertXPath(pXmlDoc,
1154 "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
1155 "SwLinePortion[2]",
1156 "portion", "hi");
1160 #if !defined(MACOSX)
1161 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf150606)
1163 createSwDoc("tdf150606-1-min.odt");
1165 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
1166 CPPUNIT_ASSERT(pTextDoc);
1167 SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
1169 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1171 assertXPath(pXmlDoc, "/root/page[1]/body/section/column[1]/body/tab", 1);
1172 assertXPath(pXmlDoc, "/root/page[1]/body/section/column[2]/body/tab", 1);
1173 assertXPath(pXmlDoc, "/root/page[1]/body/section/column", 2);
1174 assertXPath(pXmlDoc, "/root/page[2]/body/section/column[1]/body/tab", 1);
1175 assertXPath(pXmlDoc, "/root/page[2]/body/section/column[2]/body/tab", 1);
1176 assertXPath(pXmlDoc, "/root/page[2]/body/section/column", 2);
1177 assertXPath(pXmlDoc, "/root/page[3]/body/section/column[1]/body/tab", 1);
1178 assertXPath(pXmlDoc, "/root/page[3]/body/section/column[2]/body/tab", 1);
1179 assertXPath(pXmlDoc, "/root/page[3]/body/section/column", 2);
1180 assertXPath(pXmlDoc, "/root/page[4]/body/section/column[1]/body/tab", 1);
1181 assertXPath(pXmlDoc, "/root/page[4]/body/section/column[2]/body/tab", 1);
1182 assertXPath(pXmlDoc, "/root/page[4]/body/section/column", 2);
1183 // on page 5 the table is split across balanced columns
1184 assertXPath(pXmlDoc, "/root/page[5]/body/section/column[1]/body/tab", 1);
1185 assertXPath(pXmlDoc, "/root/page[5]/body/section/column[2]/body/tab", 1);
1186 assertXPath(pXmlDoc, "/root/page[5]/body/section/column", 2);
1187 assertXPath(pXmlDoc, "/root/page", 5);
1189 pWrtShell->Down(false, 1);
1190 dispatchCommand(mxComponent, ".uno:DeleteTable", {});
1192 discardDumpedLayout();
1193 pXmlDoc = parseLayoutDump();
1195 assertXPath(pXmlDoc, "/root/page[1]/body/section/column/body/tab", 0);
1196 assertXPath(pXmlDoc, "/root/page", 1);
1198 pWrtShell->Undo();
1199 Scheduler::ProcessEventsToIdle();
1201 discardDumpedLayout();
1202 pXmlDoc = parseLayoutDump();
1204 assertXPath(pXmlDoc, "/root/page[1]/body/section/column[1]/body/tab", 1);
1205 assertXPath(pXmlDoc, "/root/page[1]/body/section/column[2]/body/tab", 1);
1206 assertXPath(pXmlDoc, "/root/page[1]/body/section/column", 2);
1207 assertXPath(pXmlDoc, "/root/page[2]/body/section/column[1]/body/tab", 1);
1208 assertXPath(pXmlDoc, "/root/page[2]/body/section/column[2]/body/tab", 1);
1209 assertXPath(pXmlDoc, "/root/page[2]/body/section/column", 2);
1210 assertXPath(pXmlDoc, "/root/page[3]/body/section/column[1]/body/tab", 1);
1211 assertXPath(pXmlDoc, "/root/page[3]/body/section/column[2]/body/tab", 1);
1212 assertXPath(pXmlDoc, "/root/page[3]/body/section/column", 2);
1213 assertXPath(pXmlDoc, "/root/page[4]/body/section/column[1]/body/tab", 1);
1214 assertXPath(pXmlDoc, "/root/page[4]/body/section/column[2]/body/tab", 1);
1215 assertXPath(pXmlDoc, "/root/page[4]/body/section/column", 2);
1216 // on page 5 the table is split across balanced columns
1217 // (problem was that there were empty pages and table was on page 10)
1218 assertXPath(pXmlDoc, "/root/page[5]/body/section/column[1]/body/tab", 1);
1219 assertXPath(pXmlDoc, "/root/page[5]/body/section/column[2]/body/tab", 1);
1220 assertXPath(pXmlDoc, "/root/page[5]/body/section/column", 2);
1221 assertXPath(pXmlDoc, "/root/page", 5);
1223 #endif
1225 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf152983)
1227 //just care it doesn't crash/assert
1228 createSwDoc("tdf152983-1-min.docx");
1231 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025)
1233 // Check the padding of the textbox
1234 createSwDoc("tdf137025.docx");
1235 SwDoc* pDoc = getSwDoc();
1236 CPPUNIT_ASSERT(pDoc);
1237 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1238 CPPUNIT_ASSERT(pXmlDoc);
1240 // Check the layout xml
1241 // SDRATTR_TEXT_LEFTDIST
1242 assertXPath(pXmlDoc,
1243 "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
1244 "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item"
1245 "[@whichId='"
1246 + OString::number(SDRATTR_TEXT_LEFTDIST) + "']",
1247 "value", "567");
1248 // SDRATTR_TEXT_RIGHTDIST
1249 assertXPath(pXmlDoc,
1250 "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
1251 "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item"
1252 "[@whichId='"
1253 + OString::number(SDRATTR_TEXT_RIGHTDIST) + "']",
1254 "value", "1134");
1255 // SDRATTR_TEXT_UPPERDIST
1256 assertXPath(pXmlDoc,
1257 "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
1258 "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item"
1259 "[@whichId='"
1260 + OString::number(SDRATTR_TEXT_UPPERDIST) + "']",
1261 "value", "1701");
1262 // SDRATTR_TEXT_LOWERDIST
1263 assertXPath(pXmlDoc,
1264 "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
1265 "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item"
1266 "[@whichId='"
1267 + OString::number(SDRATTR_TEXT_LOWERDIST) + "']",
1268 "value", "2268");
1270 // Check the textbox-shape import too
1271 auto xShp = getShape(1);
1272 CPPUNIT_ASSERT(xShp);
1274 uno::Reference<beans::XPropertySet> xShapeProps(xShp, uno::UNO_QUERY);
1276 SwFrameFormat* pFrameFormat = SwTextBoxHelper::getOtherTextBoxFormat(xShp);
1277 CPPUNIT_ASSERT(pFrameFormat);
1279 // The shape has these values to copy to the associated text frame after modification::
1280 const tools::Long nLPaddng
1281 = xShapeProps->getPropertyValue("TextLeftDistance").get<tools::Long>();
1282 const tools::Long nRPaddng
1283 = xShapeProps->getPropertyValue("TextRightDistance").get<tools::Long>();
1284 const tools::Long nTPaddng
1285 = xShapeProps->getPropertyValue("TextUpperDistance").get<tools::Long>();
1286 const tools::Long nBPaddng
1287 = xShapeProps->getPropertyValue("TextLowerDistance").get<tools::Long>();
1289 CPPUNIT_ASSERT_EQUAL(tools::Long(1000), nLPaddng);
1290 CPPUNIT_ASSERT_EQUAL(tools::Long(2000), nRPaddng);
1291 CPPUNIT_ASSERT_EQUAL(tools::Long(3000), nTPaddng);
1292 CPPUNIT_ASSERT_EQUAL(tools::Long(4001), nBPaddng);
1294 // TODO: modify shape distance via UNO with text frame synchronization
1295 // Check the textbox as well:
1296 auto xTxFrm = SwXTextFrame::CreateXTextFrame(*pFrameFormat->GetDoc(), pFrameFormat);
1297 CPPUNIT_ASSERT(xTxFrm);
1299 const tools::Long nFrameLeftPaddng
1300 = xTxFrm->getPropertyValue("LeftBorderDistance").get<tools::Long>();
1301 const tools::Long nFrameRightPaddng
1302 = xTxFrm->getPropertyValue("RightBorderDistance").get<tools::Long>();
1303 const tools::Long nFrameTopPaddng
1304 = xTxFrm->getPropertyValue("TopBorderDistance").get<tools::Long>();
1305 const tools::Long nFrameBottomPaddng
1306 = xTxFrm->getPropertyValue("BottomBorderDistance").get<tools::Long>();
1308 // Check if the shape and frame have different setting
1309 CPPUNIT_ASSERT_EQUAL(nLPaddng, nFrameLeftPaddng);
1310 CPPUNIT_ASSERT_EQUAL(nRPaddng, nFrameRightPaddng);
1311 CPPUNIT_ASSERT_EQUAL(nTPaddng, nFrameTopPaddng);
1312 CPPUNIT_ASSERT_EQUAL(nBPaddng, nFrameBottomPaddng);
1315 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote)
1317 createSwDoc();
1318 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
1319 CPPUNIT_ASSERT(pTextDoc);
1320 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
1321 SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
1322 SwRootFrame* pLayout(pWrtShell->GetLayout());
1323 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
1324 pWrtShell->InsertFootnote("");
1325 CPPUNIT_ASSERT(pWrtShell->IsCursorInFootnote());
1327 SfxItemSet flySet(pDoc->GetAttrPool(),
1328 svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>);
1329 SwFormatFrameSize size(SwFrameSize::Minimum, 1000, 1000);
1330 flySet.Put(size); // set a size, else we get 1 char per line...
1331 SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR);
1332 anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint());
1333 flySet.Put(anchor);
1334 // first fly is in first footnote that will be deleted
1335 /* SwFrameFormat const* pFly1 =*/pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true);
1336 pWrtShell->Insert("quux");
1338 pWrtShell->SttEndDoc(false);
1340 pWrtShell->InsertFootnote("");
1341 CPPUNIT_ASSERT(pWrtShell->IsCursorInFootnote());
1342 pWrtShell->Insert("foo");
1343 pWrtShell->SplitNode(false);
1344 pWrtShell->Insert("bar");
1345 pWrtShell->SplitNode(false);
1346 pWrtShell->Insert("baz");
1348 pWrtShell->StartOfSection(false);
1349 CPPUNIT_ASSERT(pWrtShell->IsCursorInFootnote());
1350 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
1351 anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint());
1352 flySet.Put(anchor);
1353 // second fly is in second footnote that is not deleted
1354 SwFrameFormat const* pFly = pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true);
1355 CPPUNIT_ASSERT(pFly != nullptr);
1356 // move inside fly
1357 pWrtShell->GotoFly(pFly->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
1358 pWrtShell->Insert("abc");
1359 pWrtShell->SplitNode(false);
1360 pWrtShell->Insert("def");
1361 pWrtShell->SplitNode(false);
1362 pWrtShell->Insert("ghi");
1364 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
1365 // delete redline inside fly
1366 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
1367 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 8, /*bBasicCall=*/false);
1368 pWrtShell->Delete();
1370 // pWrtShell->GotoFlyAnchor(); // sigh... why, now we're in the body...
1371 pWrtShell->SttEndDoc(false);
1372 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
1373 pWrtShell->GotoFootnoteText();
1374 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
1375 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false);
1376 pWrtShell->Delete();
1377 pWrtShell->EndSelect(); // ?
1378 // delete first footnote
1379 pWrtShell->SttEndDoc(true);
1380 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false);
1381 pWrtShell->Delete();
1383 for (int i = 0; i < 2; ++i)
1385 if (i == 1) // secondly, try with different anchor type
1387 anchor.SetType(RndStdIds::FLY_AT_PARA);
1388 SwPosition pos(*anchor.GetAnchorNode());
1389 pos.nContent.Assign(nullptr, 0);
1390 anchor.SetAnchor(&pos);
1391 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
1394 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
1395 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
1396 discardDumpedLayout();
1397 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1398 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "25");
1399 assertXPath(pXmlDoc,
1400 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/"
1401 "child::*[@type='PortionType::Footnote']",
1402 "type", "PortionType::Footnote");
1403 assertXPath(pXmlDoc,
1404 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/"
1405 "child::*[@type='PortionType::Footnote']",
1406 "expand", "1");
1407 assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex",
1408 "7");
1409 assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/merged",
1410 "paraPropsNodeIndex", "17");
1411 assertXPath(pXmlDoc,
1412 "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1413 "SwLineLayout/SwParaPortion[1]",
1414 "type", "PortionType::Para");
1415 assertXPath(pXmlDoc,
1416 "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1417 "SwLineLayout/SwParaPortion[1]",
1418 "portion", "ahi");
1419 assertXPath(
1420 pXmlDoc,
1421 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1422 "type", "PortionType::FootnoteNum");
1423 assertXPath(
1424 pXmlDoc,
1425 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1426 "expand", "1");
1428 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
1429 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
1430 discardDumpedLayout();
1431 pXmlDoc = parseLayoutDump();
1433 // show: nothing is merged
1434 assertXPath(pXmlDoc, "//merged", 0);
1436 assertXPath(pXmlDoc,
1437 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1438 "type", "PortionType::Footnote");
1439 assertXPath(pXmlDoc,
1440 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1441 "expand", "1");
1442 assertXPath(pXmlDoc,
1443 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
1444 "type", "PortionType::Footnote");
1445 assertXPath(pXmlDoc,
1446 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
1447 "expand", "2");
1448 assertXPath(pXmlDoc,
1449 "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1450 "SwLineLayout/SwParaPortion[1]",
1451 "type", "PortionType::Para");
1452 assertXPath(pXmlDoc,
1453 "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1454 "SwLineLayout/SwParaPortion[1]",
1455 "portion", "quux");
1456 assertXPath(
1457 pXmlDoc,
1458 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1459 "type", "PortionType::FootnoteNum");
1460 assertXPath(
1461 pXmlDoc,
1462 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1463 "expand", "1");
1464 assertXPath(pXmlDoc,
1465 "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1466 "SwLineLayout/SwLinePortion[1]",
1467 "type", "PortionType::Text");
1468 assertXPath(pXmlDoc,
1469 "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1470 "SwLineLayout/SwLinePortion[1]",
1471 "portion", "a");
1472 assertXPath(pXmlDoc,
1473 "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1474 "SwLineLayout/SwLinePortion[2]",
1475 "type", "PortionType::Text");
1476 assertXPath(pXmlDoc,
1477 "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1478 "SwLineLayout/SwLinePortion[2]",
1479 "portion", "bc");
1480 assertXPath(pXmlDoc,
1481 "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/"
1482 "SwLineLayout/SwParaPortion[1]",
1483 "type", "PortionType::Para");
1484 assertXPath(pXmlDoc,
1485 "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/"
1486 "SwLineLayout/SwParaPortion[1]",
1487 "portion", "def");
1488 assertXPath(pXmlDoc,
1489 "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/"
1490 "SwLineLayout/SwLinePortion[1]",
1491 "type", "PortionType::Text");
1492 assertXPath(pXmlDoc,
1493 "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/"
1494 "SwLineLayout/SwLinePortion[1]",
1495 "portion", "g");
1496 assertXPath(pXmlDoc,
1497 "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/"
1498 "SwLineLayout/SwLinePortion[2]",
1499 "type", "PortionType::Text");
1500 assertXPath(pXmlDoc,
1501 "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/"
1502 "SwLineLayout/SwLinePortion[2]",
1503 "portion", "hi");
1504 assertXPath(
1505 pXmlDoc,
1506 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1507 "type", "PortionType::FootnoteNum");
1508 assertXPath(
1509 pXmlDoc,
1510 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1511 "expand", "2");
1512 assertXPath(
1513 pXmlDoc,
1514 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1515 "type", "PortionType::Text");
1516 assertXPath(
1517 pXmlDoc,
1518 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1519 "portion", "fo");
1520 assertXPath(
1521 pXmlDoc,
1522 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1523 "type", "PortionType::Text");
1524 assertXPath(
1525 pXmlDoc,
1526 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1527 "portion", "o");
1528 assertXPath(
1529 pXmlDoc,
1530 "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1531 "type", "PortionType::Para");
1532 assertXPath(
1533 pXmlDoc,
1534 "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1535 "portion", "bar");
1536 assertXPath(
1537 pXmlDoc,
1538 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1539 "type", "PortionType::Text");
1540 assertXPath(
1541 pXmlDoc,
1542 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1543 "portion", "b");
1544 assertXPath(
1545 pXmlDoc,
1546 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1547 "type", "PortionType::Text");
1548 assertXPath(
1549 pXmlDoc,
1550 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1551 "portion", "az");
1554 // anchor to 2nd (deleted) paragraph
1555 pWrtShell->SttEndDoc(false);
1556 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
1557 pWrtShell->GotoFootnoteText();
1558 pWrtShell->Down(false, 1);
1559 anchor.SetType(RndStdIds::FLY_AT_CHAR);
1560 anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint());
1561 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
1563 for (int i = 0; i < 2; ++i)
1565 if (i == 1) // secondly, try with different anchor type
1567 anchor.SetType(RndStdIds::FLY_AT_PARA);
1568 SwPosition pos(*anchor.GetAnchorNode());
1569 pos.nContent.Assign(nullptr, 0);
1570 anchor.SetAnchor(&pos);
1571 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
1574 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
1575 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
1576 discardDumpedLayout();
1577 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1579 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "25");
1580 assertXPath(pXmlDoc,
1581 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1582 "type", "PortionType::Footnote");
1583 assertXPath(pXmlDoc,
1584 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1585 "expand", "1");
1586 assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex",
1587 "7");
1588 assertXPath(
1589 pXmlDoc,
1590 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1591 "type", "PortionType::FootnoteNum");
1592 assertXPath(
1593 pXmlDoc,
1594 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1595 "expand", "1");
1597 // hide: no anchored object shown
1598 assertXPath(pXmlDoc, "//anchored", 0);
1600 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
1601 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
1602 discardDumpedLayout();
1603 pXmlDoc = parseLayoutDump();
1605 // show: nothing is merged
1606 assertXPath(pXmlDoc, "//merged", 0);
1608 assertXPath(pXmlDoc,
1609 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1610 "type", "PortionType::Footnote");
1611 assertXPath(pXmlDoc,
1612 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1613 "expand", "1");
1614 assertXPath(pXmlDoc,
1615 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
1616 "type", "PortionType::Footnote");
1617 assertXPath(pXmlDoc,
1618 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
1619 "expand", "2");
1620 assertXPath(pXmlDoc,
1621 "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1622 "SwLineLayout/SwParaPortion[1]",
1623 "type", "PortionType::Para");
1624 assertXPath(pXmlDoc,
1625 "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1626 "SwLineLayout/SwParaPortion[1]",
1627 "portion", "quux");
1628 assertXPath(
1629 pXmlDoc,
1630 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1631 "type", "PortionType::FootnoteNum");
1632 assertXPath(
1633 pXmlDoc,
1634 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1635 "expand", "1");
1636 assertXPath(
1637 pXmlDoc,
1638 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1639 "type", "PortionType::FootnoteNum");
1640 assertXPath(
1641 pXmlDoc,
1642 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1643 "expand", "2");
1644 assertXPath(
1645 pXmlDoc,
1646 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1647 "type", "PortionType::Text");
1648 assertXPath(
1649 pXmlDoc,
1650 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1651 "portion", "fo");
1652 assertXPath(
1653 pXmlDoc,
1654 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1655 "type", "PortionType::Text");
1656 assertXPath(
1657 pXmlDoc,
1658 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1659 "portion", "o");
1660 assertXPath(pXmlDoc,
1661 "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/"
1662 "SwLineLayout/SwLinePortion[1]",
1663 "type", "PortionType::Text");
1664 assertXPath(pXmlDoc,
1665 "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/"
1666 "SwLineLayout/SwLinePortion[1]",
1667 "portion", "a");
1668 assertXPath(pXmlDoc,
1669 "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/"
1670 "SwLineLayout/SwLinePortion[2]",
1671 "type", "PortionType::Text");
1672 assertXPath(pXmlDoc,
1673 "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/"
1674 "SwLineLayout/SwLinePortion[2]",
1675 "portion", "bc");
1676 assertXPath(pXmlDoc,
1677 "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/"
1678 "SwLineLayout/SwParaPortion[1]",
1679 "type", "PortionType::Para");
1680 assertXPath(pXmlDoc,
1681 "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/"
1682 "SwLineLayout/SwParaPortion[1]",
1683 "portion", "def");
1684 assertXPath(pXmlDoc,
1685 "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/"
1686 "SwLineLayout/SwLinePortion[1]",
1687 "type", "PortionType::Text");
1688 assertXPath(pXmlDoc,
1689 "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/"
1690 "SwLineLayout/SwLinePortion[1]",
1691 "portion", "g");
1692 assertXPath(pXmlDoc,
1693 "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/"
1694 "SwLineLayout/SwLinePortion[2]",
1695 "type", "PortionType::Text");
1696 assertXPath(pXmlDoc,
1697 "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/"
1698 "SwLineLayout/SwLinePortion[2]",
1699 "portion", "hi");
1700 assertXPath(
1701 pXmlDoc,
1702 "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1703 "type", "PortionType::Para");
1704 assertXPath(
1705 pXmlDoc,
1706 "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1707 "portion", "bar");
1708 assertXPath(
1709 pXmlDoc,
1710 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1711 "type", "PortionType::Text");
1712 assertXPath(
1713 pXmlDoc,
1714 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1715 "portion", "b");
1716 assertXPath(
1717 pXmlDoc,
1718 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1719 "type", "PortionType::Text");
1720 assertXPath(
1721 pXmlDoc,
1722 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1723 "portion", "az");
1726 // anchor to 3rd paragraph
1727 pWrtShell->EndOfSection();
1728 pWrtShell->SttEndDoc(false);
1729 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
1730 pWrtShell->GotoFootnoteText();
1731 pWrtShell->EndOfSection();
1732 anchor.SetType(RndStdIds::FLY_AT_CHAR);
1733 anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint());
1734 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
1736 for (int i = 0; i < 2; ++i)
1738 if (i == 1) // secondly, try with different anchor type
1740 anchor.SetType(RndStdIds::FLY_AT_PARA);
1741 SwPosition pos(*anchor.GetAnchorNode());
1742 pos.nContent.Assign(nullptr, 0);
1743 anchor.SetAnchor(&pos);
1744 pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly));
1747 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
1748 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
1749 discardDumpedLayout();
1750 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1751 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "25");
1752 assertXPath(pXmlDoc,
1753 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1754 "type", "PortionType::Footnote");
1755 assertXPath(pXmlDoc,
1756 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1757 "expand", "1");
1758 assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex",
1759 "7");
1760 assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/merged",
1761 "paraPropsNodeIndex", "17");
1762 assertXPath(pXmlDoc,
1763 "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1764 "SwLineLayout/SwParaPortion[1]",
1765 "type", "PortionType::Para");
1766 assertXPath(pXmlDoc,
1767 "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1768 "SwLineLayout/SwParaPortion[1]",
1769 "portion", "ahi");
1770 assertXPath(
1771 pXmlDoc,
1772 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1773 "type", "PortionType::FootnoteNum");
1774 assertXPath(
1775 pXmlDoc,
1776 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1777 "expand", "1");
1779 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
1780 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
1781 discardDumpedLayout();
1782 pXmlDoc = parseLayoutDump();
1784 // show: nothing is merged
1785 assertXPath(pXmlDoc, "//merged", 0);
1787 assertXPath(pXmlDoc,
1788 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/"
1789 "child::*[@type='PortionType::Footnote'][1]",
1790 "type", "PortionType::Footnote");
1791 assertXPath(pXmlDoc,
1792 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/"
1793 "child::*[@type='PortionType::Footnote'][1]",
1794 "expand", "1");
1795 assertXPath(pXmlDoc,
1796 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/"
1797 "child::*[@type='PortionType::Footnote'][2]",
1798 "type", "PortionType::Footnote");
1799 assertXPath(pXmlDoc,
1800 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/"
1801 "child::*[@type='PortionType::Footnote'][2]",
1802 "expand", "2");
1803 assertXPath(pXmlDoc,
1804 "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1805 "SwLineLayout/SwParaPortion[1]",
1806 "type", "PortionType::Para");
1807 assertXPath(pXmlDoc,
1808 "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
1809 "SwLineLayout/SwParaPortion[1]",
1810 "portion", "quux");
1811 assertXPath(
1812 pXmlDoc,
1813 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1814 "type", "PortionType::FootnoteNum");
1815 assertXPath(
1816 pXmlDoc,
1817 "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1818 "expand", "1");
1819 assertXPath(
1820 pXmlDoc,
1821 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1822 "type", "PortionType::FootnoteNum");
1823 assertXPath(
1824 pXmlDoc,
1825 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
1826 "expand", "2");
1827 assertXPath(
1828 pXmlDoc,
1829 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1830 "type", "PortionType::Text");
1831 assertXPath(
1832 pXmlDoc,
1833 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1834 "portion", "fo");
1835 assertXPath(
1836 pXmlDoc,
1837 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1838 "type", "PortionType::Text");
1839 assertXPath(
1840 pXmlDoc,
1841 "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1842 "portion", "o");
1843 assertXPath(
1844 pXmlDoc,
1845 "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1846 "type", "PortionType::Para");
1847 assertXPath(
1848 pXmlDoc,
1849 "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
1850 "portion", "bar");
1851 assertXPath(pXmlDoc,
1852 "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/"
1853 "SwLineLayout/SwLinePortion[1]",
1854 "type", "PortionType::Text");
1855 assertXPath(pXmlDoc,
1856 "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/"
1857 "SwLineLayout/SwLinePortion[1]",
1858 "portion", "a");
1859 assertXPath(pXmlDoc,
1860 "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/"
1861 "SwLineLayout/SwLinePortion[2]",
1862 "type", "PortionType::Text");
1863 assertXPath(pXmlDoc,
1864 "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/"
1865 "SwLineLayout/SwLinePortion[2]",
1866 "portion", "bc");
1867 assertXPath(pXmlDoc,
1868 "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/"
1869 "SwLineLayout/SwParaPortion[1]",
1870 "type", "PortionType::Para");
1871 assertXPath(pXmlDoc,
1872 "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/"
1873 "SwLineLayout/SwParaPortion[1]",
1874 "portion", "def");
1875 assertXPath(pXmlDoc,
1876 "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/"
1877 "SwLineLayout/SwLinePortion[1]",
1878 "type", "PortionType::Text");
1879 assertXPath(pXmlDoc,
1880 "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/"
1881 "SwLineLayout/SwLinePortion[1]",
1882 "portion", "g");
1883 assertXPath(pXmlDoc,
1884 "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/"
1885 "SwLineLayout/SwLinePortion[2]",
1886 "type", "PortionType::Text");
1887 assertXPath(pXmlDoc,
1888 "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/"
1889 "SwLineLayout/SwLinePortion[2]",
1890 "portion", "hi");
1891 assertXPath(
1892 pXmlDoc,
1893 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1894 "type", "PortionType::Text");
1895 assertXPath(
1896 pXmlDoc,
1897 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
1898 "portion", "b");
1899 assertXPath(
1900 pXmlDoc,
1901 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1902 "type", "PortionType::Text");
1903 assertXPath(
1904 pXmlDoc,
1905 "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
1906 "portion", "az");
1910 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf143239)
1912 createSwDoc("tdf143239-1-min.odt");
1913 SwDoc* pDoc = getSwDoc();
1914 SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
1916 // These are unstable on macOS and Win64 builds,
1917 // so only test that they restore original values for now
1918 OUString p2txt1Left, p2txt2Left, p3txt1Left;
1921 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1922 assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly", 1);
1923 assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly[1]/infos/bounds", "top",
1924 "18540");
1925 p2txt1Left
1926 = getXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly[1]/infos/bounds", "left");
1927 assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly", 1);
1928 assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly[1]/infos/bounds", "top",
1929 "23894");
1930 p2txt2Left
1931 = getXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly[1]/infos/bounds", "left");
1932 assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly", 1);
1933 assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly[1]/infos/bounds", "top",
1934 "35662");
1935 p3txt1Left
1936 = getXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly[1]/infos/bounds", "left");
1937 assertXPath(pXmlDoc, "/root/page", 3);
1938 discardDumpedLayout();
1941 pWrtShell->SelAll();
1942 pWrtShell->Delete();
1943 pWrtShell->Undo();
1944 Scheduler::ProcessEventsToIdle();
1947 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1948 // now the 1st fly was on page 1, and the fly on page 2 was the 2nd one
1949 assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly", 1);
1950 assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly[1]/infos/bounds", "top",
1951 "18540");
1952 assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly[1]/infos/bounds", "left",
1953 p2txt1Left);
1954 assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly", 1);
1955 assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly[1]/infos/bounds", "top",
1956 "23894");
1957 assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly[1]/infos/bounds", "left",
1958 p2txt2Left);
1959 assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly", 1);
1960 assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly[1]/infos/bounds", "top",
1961 "35662");
1962 assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly[1]/infos/bounds", "left",
1963 p3txt1Left);
1964 assertXPath(pXmlDoc, "/root/page", 3);
1965 discardDumpedLayout();
1969 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTableOverlapFooterFly)
1971 // Load a document that has a fly anchored in the footer.
1972 // It also has a table which initially overlaps with the fly, but then moves to the next page.
1973 createSwDoc("footer-fly-table.fodt");
1974 xmlDocUniquePtr pLayout = parseLayoutDump();
1975 // no fly portions, was: 8
1976 assertXPath(pLayout,
1977 "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/SwParaPortion/SwLineLayout/"
1978 "SwFixPortion[@type='PortionType::Fly'][@type='PortionType::Fly']",
1980 // one line break, was: 5
1981 assertXPath(pLayout,
1982 "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/SwParaPortion/SwLineLayout", 1);
1983 // one text portion, was: 1
1984 assertXPath(
1985 pLayout,
1986 "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
1988 assertXPath(
1989 pLayout,
1990 "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion",
1991 "portion", "Abc def ghi jkl mno pqr stu vwx yz.");
1992 // height was: 1517
1993 // tdf#134782 height was: 379
1994 assertXPath(pLayout, "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/infos/bounds", "height",
1995 "253");
1998 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf134277)
2000 createSwDoc("tdf134277.docx");
2001 SwDoc* pDoc = getSwDoc();
2002 CPPUNIT_ASSERT(pDoc);
2003 SwDocShell* pShell = pDoc->GetDocShell();
2005 std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
2006 MetafileXmlDump dumper;
2008 xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
2009 CPPUNIT_ASSERT(pXmlDoc);
2011 assertXPath(pXmlDoc, "/metafile/push/push/push/layoutmode[2]", 0);
2014 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116486)
2016 createSwDoc("tdf116486.docx");
2017 SwDoc* pDoc = getSwDoc();
2018 CPPUNIT_ASSERT(pDoc);
2019 OUString aTop = parseDump(
2020 "/root/page/body/txt/SwParaPortion/SwLineLayout[1]/child::*[@type='PortionType::Fly']",
2021 "height");
2022 CPPUNIT_ASSERT_EQUAL(OUString("4006"), aTop);
2025 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf142080)
2027 // this caused an infinite loop
2028 createSwDoc("fdo43573-2-min.docx");
2030 xmlDocUniquePtr pLayout = parseLayoutDump();
2031 // check the first paragraph on page 9 with its fly; the column was empty too
2032 assertXPath(pLayout,
2033 "/root/page[9]/body/section[1]/column[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/"
2034 "SwLinePortion",
2035 "portion",
2036 "De kleur u (rood) in het rechtervlak (R), de kleur r (wit) beneden (D),");
2037 SwTwips nPage9Top = getXPath(pLayout, "/root/page[9]/infos/bounds", "top").toInt32();
2038 assertXPath(
2039 pLayout,
2040 "/root/page[9]/body/section[1]/column[1]/body/txt[1]/anchored/fly[1]/notxt/infos/bounds",
2041 "top", OUString::number(nPage9Top + 1460));
2044 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf152106)
2046 // this caused an infinite loop
2047 createSwDoc("tdf152106.odt");
2049 xmlDocUniquePtr pLayout = parseLayoutDump();
2051 // frame on page 3
2052 assertXPath(pLayout, "/root/page[3]/sorted_objs/fly", 1);
2055 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128198)
2057 createSwDoc("tdf128198-1.docx");
2058 SwDoc* pDoc = getSwDoc();
2059 CPPUNIT_ASSERT(pDoc);
2060 xmlDocUniquePtr pLayout = parseLayoutDump();
2061 // the problem was that line 5 was truncated at "this "
2062 // due to the fly anchored in previous paragraph
2063 assertXPath(pLayout, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[5]", "portion",
2064 "to access any service, any time, anywhere. From this perspective, satellite "
2065 "boasts some ");
2066 assertXPath(pLayout, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[6]", "portion",
2067 "significant advantages. ");
2070 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testNoLineBreakAtSlash)
2072 createSwDoc("no-line-break-at-slash.fodt");
2073 xmlDocUniquePtr pLayout = parseLayoutDump();
2075 // the line break was between "Foostrasse 13/c/" and "2"
2076 assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout", 2);
2077 assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]/child::*", "type",
2078 "PortionType::Para");
2079 assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/child::*[1]",
2080 "type", "PortionType::Text");
2081 assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/child::*[2]",
2082 "type", "PortionType::Blank");
2083 assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/child::*[3]",
2084 "type", "PortionType::Text");
2086 assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion",
2087 "Blah blah bla bla bla ");
2088 assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/SwLinePortion[1]",
2089 "portion", "Foostrasse");
2090 assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/SwLinePortion[2]",
2091 "portion", "13/c/2, etc.");
2094 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf106153)
2096 createSwDoc("tdf106153.docx");
2097 xmlDocUniquePtr pDump = parseLayoutDump();
2099 const sal_Int64 nPageValLeft = getXPath(pDump, "/root/page/infos/bounds", "left").toInt64();
2100 const sal_Int64 nPageValTop = getXPath(pDump, "/root/page/infos/bounds", "top").toInt64();
2101 const sal_Int64 nPageValRight = getXPath(pDump, "/root/page/infos/bounds", "right").toInt64();
2102 const sal_Int64 nPageValBottom = getXPath(pDump, "/root/page/infos/bounds", "bottom").toInt64();
2104 const sal_Int64 nShape1ValTop
2105 = getXPath(pDump, "/root/page/body/txt/anchored/fly[1]/infos/bounds", "top").toInt64();
2106 const sal_Int64 nShape2ValLeft
2107 = getXPath(pDump, "/root/page/body/txt/anchored/fly[2]/infos/bounds", "left").toInt64();
2108 const sal_Int64 nShape3ValRight
2109 = getXPath(pDump, "/root/page/body/txt/anchored/fly[3]/infos/bounds", "right").toInt64();
2110 const sal_Int64 nShape4ValBottom
2111 = getXPath(pDump, "/root/page/body/txt/anchored/fly[4]/infos/bounds", "bottom").toInt64();
2113 CPPUNIT_ASSERT_MESSAGE("The whole top textbox is inside the page!",
2114 nPageValTop > nShape1ValTop);
2115 CPPUNIT_ASSERT_MESSAGE("The whole left textbox is inside the page!",
2116 nPageValLeft > nShape2ValLeft);
2117 CPPUNIT_ASSERT_MESSAGE("The whole right textbox is inside the page!",
2118 nPageValRight < nShape3ValRight);
2119 CPPUNIT_ASSERT_MESSAGE("The whole bottom textbox is inside the page!",
2120 nPageValBottom < nShape4ValBottom);
2123 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys)
2125 createSwDoc();
2126 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
2127 CPPUNIT_ASSERT(pTextDoc);
2128 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
2129 SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
2130 SwRootFrame* pLayout(pWrtShell->GetLayout());
2131 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
2132 pWrtShell->Insert("foo");
2133 pWrtShell->SplitNode(false);
2134 pWrtShell->Insert("bar");
2135 pWrtShell->SplitNode(false);
2136 pWrtShell->Insert("baz");
2137 SfxItemSet flySet(pDoc->GetAttrPool(),
2138 svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>);
2139 SwFormatFrameSize size(SwFrameSize::Minimum, 1000, 1000);
2140 flySet.Put(size); // set a size, else we get 1 char per line...
2141 pWrtShell->StartOfSection(false);
2142 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
2143 SwFormatAnchor anchor1(RndStdIds::FLY_AT_CHAR);
2144 anchor1.SetAnchor(pWrtShell->GetCursor()->GetPoint());
2145 flySet.Put(anchor1);
2146 SwFrameFormat const* pFly1 = pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true);
2147 CPPUNIT_ASSERT(pFly1 != nullptr);
2148 // move inside fly1
2149 pWrtShell->GotoFly(pFly1->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
2150 pWrtShell->Insert("abc");
2151 pWrtShell->SplitNode(false);
2152 pWrtShell->Insert("def");
2153 pWrtShell->SplitNode(false);
2154 pWrtShell->Insert("ghi");
2156 SwFormatAnchor anchor2(RndStdIds::FLY_AT_CHAR);
2157 pWrtShell->StartOfSection(false); // start of fly...
2158 anchor2.SetAnchor(pWrtShell->GetCursor()->GetPoint());
2159 flySet.Put(anchor2);
2160 SwFrameFormat const* pFly2 = pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true);
2161 CPPUNIT_ASSERT(pFly2 != nullptr);
2162 // move inside fly2
2163 pWrtShell->GotoFly(pFly2->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
2164 pWrtShell->Insert("jkl");
2165 pWrtShell->SplitNode(false);
2166 pWrtShell->Insert("mno");
2167 pWrtShell->SplitNode(false);
2168 pWrtShell->Insert("pqr");
2170 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
2171 // delete redline inside fly2
2172 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
2173 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 8, /*bBasicCall=*/false);
2174 pWrtShell->Delete();
2176 // delete redline inside fly1
2177 pWrtShell->GotoFly(pFly1->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
2178 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
2179 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false);
2180 pWrtShell->Delete();
2182 pWrtShell->ClearMark(); // otherwise it refuses to leave the fly...
2183 pWrtShell->SttEndDoc(true); // note: SttDoc actually moves to start of fly?
2184 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
2185 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false);
2186 pWrtShell->Delete();
2188 for (int i = 0; i < 2; ++i)
2190 if (i == 1) // secondly, try with different anchor type
2192 anchor1.SetType(RndStdIds::FLY_AT_PARA);
2193 SwPosition pos(*anchor1.GetAnchorNode());
2194 pos.nContent.Assign(nullptr, 0);
2195 anchor1.SetAnchor(&pos);
2196 pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1));
2197 anchor2.SetType(RndStdIds::FLY_AT_PARA);
2198 pos.nNode = *anchor2.GetAnchorNode();
2199 anchor2.SetAnchor(&pos);
2200 pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2));
2203 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
2204 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
2205 discardDumpedLayout();
2206 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
2207 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "19");
2208 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/merged",
2209 "paraPropsNodeIndex", "6");
2210 assertXPath(
2211 pXmlDoc,
2212 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/merged",
2213 "paraPropsNodeIndex", "11");
2214 assertXPath(pXmlDoc,
2215 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/"
2216 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
2217 "type", "PortionType::Para");
2218 assertXPath(pXmlDoc,
2219 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/"
2220 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
2221 "portion", "jqr");
2222 assertXPath(pXmlDoc,
2223 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2224 "SwFixPortion[1]",
2225 "type",
2226 "PortionType::Fly"); // remove???
2227 assertXPath(pXmlDoc,
2228 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2229 "SwLineLayout[1]",
2230 "type", "PortionType::Lay");
2231 assertXPath(pXmlDoc,
2232 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2233 "SwLineLayout[1]",
2234 "portion", "abhi");
2235 assertXPath(pXmlDoc,
2236 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
2237 "PortionType::Para");
2238 assertXPath(pXmlDoc,
2239 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2240 "portion", "foaz");
2242 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
2243 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
2244 discardDumpedLayout();
2245 pXmlDoc = parseLayoutDump();
2247 // show: nothing is merged
2248 assertXPath(pXmlDoc, "//merged", 0);
2250 assertXPath(pXmlDoc,
2251 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/"
2252 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2253 "type", "PortionType::Text");
2254 assertXPath(pXmlDoc,
2255 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/"
2256 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2257 "portion", "j");
2258 assertXPath(pXmlDoc,
2259 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/"
2260 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2261 "type", "PortionType::Text");
2262 assertXPath(pXmlDoc,
2263 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/"
2264 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2265 "portion", "kl");
2266 assertXPath(pXmlDoc,
2267 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[2]/"
2268 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
2269 "type", "PortionType::Para");
2270 assertXPath(pXmlDoc,
2271 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[2]/"
2272 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
2273 "portion", "mno");
2274 assertXPath(pXmlDoc,
2275 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/"
2276 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2277 "type", "PortionType::Text");
2278 assertXPath(pXmlDoc,
2279 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/"
2280 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2281 "portion", "p");
2282 assertXPath(pXmlDoc,
2283 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/"
2284 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2285 "type", "PortionType::Text");
2286 assertXPath(pXmlDoc,
2287 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/"
2288 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2289 "portion", "qr");
2290 assertXPath(pXmlDoc,
2291 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2292 "SwFixPortion[1]",
2293 "type",
2294 "PortionType::Fly"); // remove???
2295 assertXPath(pXmlDoc,
2296 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2297 "SwLinePortion[1]",
2298 "type", "PortionType::Text");
2299 assertXPath(pXmlDoc,
2300 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2301 "SwLinePortion[1]",
2302 "portion", "ab");
2303 assertXPath(pXmlDoc,
2304 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2305 "SwLinePortion[2]",
2306 "type", "PortionType::Text");
2307 assertXPath(pXmlDoc,
2308 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2309 "SwLinePortion[2]",
2310 "portion", "c");
2311 assertXPath(pXmlDoc,
2312 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
2313 "SwParaPortion[1]",
2314 "type", "PortionType::Para");
2315 assertXPath(pXmlDoc,
2316 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
2317 "SwParaPortion[1]",
2318 "portion", "def");
2319 assertXPath(pXmlDoc,
2320 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2321 "SwLinePortion[1]",
2322 "type", "PortionType::Text");
2323 assertXPath(pXmlDoc,
2324 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2325 "SwLinePortion[1]",
2326 "portion", "g");
2327 assertXPath(pXmlDoc,
2328 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2329 "SwLinePortion[2]",
2330 "type", "PortionType::Text");
2331 assertXPath(pXmlDoc,
2332 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2333 "SwLinePortion[2]",
2334 "portion", "hi");
2335 assertXPath(pXmlDoc,
2336 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
2337 "PortionType::Text");
2338 assertXPath(pXmlDoc,
2339 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2340 "portion", "fo");
2341 assertXPath(pXmlDoc,
2342 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
2343 "PortionType::Text");
2344 assertXPath(pXmlDoc,
2345 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2346 "portion", "o");
2347 assertXPath(pXmlDoc,
2348 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
2349 "PortionType::Para");
2350 assertXPath(pXmlDoc,
2351 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2352 "portion", "bar");
2353 assertXPath(pXmlDoc,
2354 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
2355 "PortionType::Text");
2356 assertXPath(pXmlDoc,
2357 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2358 "portion", "b");
2359 assertXPath(pXmlDoc,
2360 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
2361 "PortionType::Text");
2362 assertXPath(pXmlDoc,
2363 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2364 "portion", "az");
2367 // anchor to 2nd (deleted) paragraph
2368 // also, switch the in-fly anchoring to the other fly, for additional fun!
2369 pWrtShell->StartOfSection();
2370 pWrtShell->Down(false, 1);
2371 anchor2.SetType(RndStdIds::FLY_AT_CHAR);
2372 anchor2.SetAnchor(pWrtShell->GetCursor()->GetPoint());
2373 pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2));
2374 pWrtShell->GotoFly(pFly2->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
2375 pWrtShell->Down(false, 1);
2376 anchor1.SetType(RndStdIds::FLY_AT_CHAR);
2377 anchor1.SetAnchor(pWrtShell->GetCursor()->GetPoint());
2378 pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1));
2380 for (int i = 0; i < 2; ++i)
2382 if (i == 1) // secondly, try with different anchor type
2384 anchor1.SetType(RndStdIds::FLY_AT_PARA);
2385 SwPosition pos(*anchor1.GetAnchorNode());
2386 pos.nContent.Assign(nullptr, 0);
2387 anchor1.SetAnchor(&pos);
2388 pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1));
2389 anchor2.SetType(RndStdIds::FLY_AT_PARA);
2390 pos.nNode = *anchor2.GetAnchorNode();
2391 anchor2.SetAnchor(&pos);
2392 pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2));
2395 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
2396 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
2397 discardDumpedLayout();
2398 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
2399 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "19");
2400 assertXPath(pXmlDoc,
2401 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
2402 "PortionType::Para");
2403 assertXPath(pXmlDoc,
2404 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2405 "portion", "foaz");
2407 // hide: no anchored object shown
2408 assertXPath(pXmlDoc, "//anchored", 0);
2410 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
2411 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
2412 discardDumpedLayout();
2413 pXmlDoc = parseLayoutDump();
2415 // show: nothing is merged
2416 assertXPath(pXmlDoc, "//merged", 0);
2418 assertXPath(pXmlDoc,
2419 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
2420 "PortionType::Text");
2421 assertXPath(pXmlDoc,
2422 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2423 "portion", "fo");
2424 assertXPath(pXmlDoc,
2425 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
2426 "PortionType::Text");
2427 assertXPath(pXmlDoc,
2428 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2429 "portion", "o");
2430 assertXPath(pXmlDoc,
2431 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2432 "SwLinePortion[1]",
2433 "type", "PortionType::Text");
2434 assertXPath(pXmlDoc,
2435 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2436 "SwLinePortion[1]",
2437 "portion", "j");
2438 assertXPath(pXmlDoc,
2439 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2440 "SwLinePortion[2]",
2441 "type", "PortionType::Text");
2442 assertXPath(pXmlDoc,
2443 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2444 "SwLinePortion[2]",
2445 "portion", "kl");
2446 assertXPath(pXmlDoc,
2447 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/"
2448 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2449 "type", "PortionType::Text");
2450 assertXPath(pXmlDoc,
2451 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/"
2452 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2453 "portion", "ab");
2454 assertXPath(pXmlDoc,
2455 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/"
2456 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2457 "type", "PortionType::Text");
2458 assertXPath(pXmlDoc,
2459 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/"
2460 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2461 "portion", "c");
2462 assertXPath(pXmlDoc,
2463 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[2]/"
2464 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
2465 "type", "PortionType::Para");
2466 assertXPath(pXmlDoc,
2467 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[2]/"
2468 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
2469 "portion", "def");
2470 assertXPath(pXmlDoc,
2471 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/"
2472 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2473 "type", "PortionType::Text");
2474 assertXPath(pXmlDoc,
2475 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/"
2476 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2477 "portion", "g");
2478 assertXPath(pXmlDoc,
2479 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/"
2480 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2481 "type", "PortionType::Text");
2482 assertXPath(pXmlDoc,
2483 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/"
2484 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2485 "portion", "hi");
2486 assertXPath(pXmlDoc,
2487 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
2488 "SwFixPortion[1]",
2489 "type",
2490 "PortionType::Fly"); // remove???
2491 assertXPath(pXmlDoc,
2492 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
2493 "SwLineLayout[1]",
2494 "type", "PortionType::Lay");
2495 assertXPath(pXmlDoc,
2496 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
2497 "SwLineLayout[1]",
2498 "portion", "mno");
2499 assertXPath(pXmlDoc,
2500 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2501 "SwLinePortion[1]",
2502 "type", "PortionType::Text");
2503 assertXPath(pXmlDoc,
2504 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2505 "SwLinePortion[1]",
2506 "portion", "p");
2507 assertXPath(pXmlDoc,
2508 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2509 "SwLinePortion[2]",
2510 "type", "PortionType::Text");
2511 assertXPath(pXmlDoc,
2512 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2513 "SwLinePortion[2]",
2514 "portion", "qr");
2515 assertXPath(pXmlDoc,
2516 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
2517 "PortionType::Para");
2518 assertXPath(pXmlDoc,
2519 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2520 "portion", "bar");
2521 assertXPath(pXmlDoc,
2522 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
2523 "PortionType::Text");
2524 assertXPath(pXmlDoc,
2525 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2526 "portion", "b");
2527 assertXPath(pXmlDoc,
2528 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
2529 "PortionType::Text");
2530 assertXPath(pXmlDoc,
2531 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2532 "portion", "az");
2535 // anchor to 3rd paragraph
2536 pWrtShell->SttEndDoc(false);
2537 anchor1.SetType(RndStdIds::FLY_AT_CHAR);
2538 anchor1.SetAnchor(pWrtShell->GetCursor()->GetPoint());
2539 pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1));
2540 pWrtShell->GotoFly(pFly1->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
2541 pWrtShell->EndOfSection();
2542 anchor2.SetType(RndStdIds::FLY_AT_CHAR);
2543 anchor2.SetAnchor(pWrtShell->GetCursor()->GetPoint());
2544 pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2));
2546 for (int i = 0; i < 2; ++i)
2548 if (i == 1) // secondly, try with different anchor type
2550 anchor1.SetType(RndStdIds::FLY_AT_PARA);
2551 SwPosition pos(*anchor1.GetAnchorNode());
2552 pos.nContent.Assign(nullptr, 0);
2553 anchor1.SetAnchor(&pos);
2554 pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1));
2555 anchor2.SetType(RndStdIds::FLY_AT_PARA);
2556 pos.nNode = *anchor2.GetAnchorNode();
2557 anchor2.SetAnchor(&pos);
2558 pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2));
2561 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
2562 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
2563 discardDumpedLayout();
2564 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
2565 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "19");
2566 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/merged",
2567 "paraPropsNodeIndex", "6");
2568 assertXPath(
2569 pXmlDoc,
2570 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/merged",
2571 "paraPropsNodeIndex", "11");
2572 assertXPath(pXmlDoc,
2573 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/"
2574 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
2575 "type", "PortionType::Para");
2576 assertXPath(pXmlDoc,
2577 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/"
2578 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
2579 "portion", "jqr");
2580 assertXPath(pXmlDoc,
2581 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2582 "SwFixPortion[1]",
2583 "type",
2584 "PortionType::Fly"); // remove???
2585 assertXPath(pXmlDoc,
2586 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2587 "SwLineLayout[1]",
2588 "type", "PortionType::Lay");
2589 assertXPath(pXmlDoc,
2590 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2591 "SwLineLayout[1]",
2592 "portion", "abhi");
2593 assertXPath(pXmlDoc,
2594 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
2595 "PortionType::Para");
2596 assertXPath(pXmlDoc,
2597 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2598 "portion", "foaz");
2600 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
2601 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
2602 discardDumpedLayout();
2603 pXmlDoc = parseLayoutDump();
2605 // show: nothing is merged
2606 assertXPath(pXmlDoc, "//merged", 0);
2608 assertXPath(pXmlDoc,
2609 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
2610 "PortionType::Text");
2611 assertXPath(pXmlDoc,
2612 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2613 "portion", "fo");
2614 assertXPath(pXmlDoc,
2615 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
2616 "PortionType::Text");
2617 assertXPath(pXmlDoc,
2618 "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2619 "portion", "o");
2620 assertXPath(pXmlDoc,
2621 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type",
2622 "PortionType::Para");
2623 assertXPath(pXmlDoc,
2624 "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2625 "portion", "bar");
2626 assertXPath(pXmlDoc,
2627 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2628 "SwLinePortion[1]",
2629 "type", "PortionType::Text");
2630 assertXPath(pXmlDoc,
2631 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2632 "SwLinePortion[1]",
2633 "portion", "ab");
2634 assertXPath(pXmlDoc,
2635 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2636 "SwLinePortion[2]",
2637 "type", "PortionType::Text");
2638 assertXPath(pXmlDoc,
2639 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2640 "SwLinePortion[2]",
2641 "portion", "c");
2642 assertXPath(pXmlDoc,
2643 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
2644 "SwParaPortion[1]",
2645 "type", "PortionType::Para");
2646 assertXPath(pXmlDoc,
2647 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
2648 "SwParaPortion[1]",
2649 "portion", "def");
2650 assertXPath(pXmlDoc,
2651 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/"
2652 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2653 "type", "PortionType::Text");
2654 assertXPath(pXmlDoc,
2655 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/"
2656 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2657 "portion", "j");
2658 assertXPath(pXmlDoc,
2659 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/"
2660 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2661 "type", "PortionType::Text");
2662 assertXPath(pXmlDoc,
2663 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/"
2664 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2665 "portion", "kl");
2666 assertXPath(pXmlDoc,
2667 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[2]/"
2668 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
2669 "type", "PortionType::Para");
2670 assertXPath(pXmlDoc,
2671 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[2]/"
2672 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
2673 "portion", "mno");
2674 assertXPath(pXmlDoc,
2675 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/"
2676 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2677 "type", "PortionType::Text");
2678 assertXPath(pXmlDoc,
2679 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/"
2680 "SwParaPortion/SwLineLayout/SwLinePortion[1]",
2681 "portion", "p");
2682 assertXPath(pXmlDoc,
2683 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/"
2684 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2685 "type", "PortionType::Text");
2686 assertXPath(pXmlDoc,
2687 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/"
2688 "SwParaPortion/SwLineLayout/SwLinePortion[2]",
2689 "portion", "qr");
2690 assertXPath(pXmlDoc,
2691 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2692 "SwLinePortion[1]",
2693 "type", "PortionType::Text");
2694 assertXPath(pXmlDoc,
2695 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2696 "SwFixPortion[1]",
2697 "type",
2698 "PortionType::Fly"); // remove???
2699 assertXPath(pXmlDoc,
2700 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2701 "SwLinePortion[1]",
2702 "portion", "g");
2703 assertXPath(pXmlDoc,
2704 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2705 "SwLinePortion[2]",
2706 "type", "PortionType::Text");
2707 assertXPath(pXmlDoc,
2708 "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2709 "SwLinePortion[2]",
2710 "portion", "hi");
2711 assertXPath(pXmlDoc,
2712 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type",
2713 "PortionType::Text");
2714 assertXPath(pXmlDoc,
2715 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2716 "portion", "b");
2717 assertXPath(pXmlDoc,
2718 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
2719 "PortionType::Text");
2720 assertXPath(pXmlDoc,
2721 "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2722 "portion", "az");
2726 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysAtFlys)
2728 createSwDoc();
2729 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
2730 CPPUNIT_ASSERT(pTextDoc);
2731 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
2732 SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
2733 SwRootFrame* pLayout(pWrtShell->GetLayout());
2734 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
2735 pWrtShell->Insert("foo");
2736 pWrtShell->SplitNode(false);
2737 pWrtShell->Insert("bar");
2738 pWrtShell->SplitNode(false);
2739 pWrtShell->Insert("baz");
2740 SfxItemSet flySet(pDoc->GetAttrPool(),
2741 svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>);
2742 SwFormatFrameSize size(SwFrameSize::Minimum, 1000, 1000);
2743 flySet.Put(size); // set a size, else we get 1 char per line...
2744 pWrtShell->StartOfSection(false);
2745 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
2746 SwFormatAnchor anchor1(RndStdIds::FLY_AT_CHAR);
2747 anchor1.SetAnchor(pWrtShell->GetCursor()->GetPoint());
2748 flySet.Put(anchor1);
2749 SwFrameFormat const* pFly1 = pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true);
2750 CPPUNIT_ASSERT(pFly1 != nullptr);
2751 // move inside fly1
2752 pWrtShell->GotoFly(pFly1->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
2753 pWrtShell->Insert("abc");
2754 pWrtShell->SplitNode(false);
2755 pWrtShell->Insert("def");
2756 pWrtShell->SplitNode(false);
2757 pWrtShell->Insert("ghi");
2759 SwFormatAnchor anchor2(RndStdIds::FLY_AT_FLY);
2760 SwPosition pos(*pFly1->GetContent().GetContentIdx());
2761 anchor2.SetAnchor(&pos);
2762 flySet.Put(anchor2);
2763 SwFrameFormat const* pFly2 = pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true);
2764 CPPUNIT_ASSERT(pFly2 != nullptr);
2765 // move inside fly2
2766 pWrtShell->GotoFly(pFly2->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
2767 pWrtShell->Insert("jkl");
2768 pWrtShell->SplitNode(false);
2769 pWrtShell->Insert("mno");
2770 pWrtShell->SplitNode(false);
2771 pWrtShell->Insert("pqr");
2773 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
2774 // delete redline inside fly2
2775 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
2776 pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 8, /*bBasicCall=*/false);
2777 pWrtShell->Delete();
2779 // delete redline inside fly1
2780 pWrtShell->GotoFly(pFly1->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false);
2781 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
2782 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false);
2783 pWrtShell->Delete();
2785 pWrtShell->ClearMark(); // otherwise it refuses to leave the fly...
2786 pWrtShell->SttEndDoc(true); // note: SttDoc actually moves to start of fly?
2787 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false);
2788 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false);
2789 pWrtShell->Delete();
2791 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
2792 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
2793 discardDumpedLayout();
2794 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
2795 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "19");
2796 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/merged",
2797 "paraPropsNodeIndex", "6");
2798 assertXPath(pXmlDoc,
2799 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/merged",
2800 "paraPropsNodeIndex", "11");
2801 assertXPath(pXmlDoc,
2802 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/"
2803 "SwLineLayout/SwParaPortion[1]",
2804 "type", "PortionType::Para");
2805 assertXPath(pXmlDoc,
2806 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/"
2807 "SwLineLayout/SwParaPortion[1]",
2808 "portion", "jqr");
2809 assertXPath(pXmlDoc,
2810 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2811 "SwFixPortion[1]",
2812 "type",
2813 "PortionType::Fly"); // remove???
2814 assertXPath(pXmlDoc,
2815 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2816 "SwLineLayout[1]",
2817 "type", "PortionType::Lay");
2818 assertXPath(pXmlDoc,
2819 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2820 "SwLineLayout[1]",
2821 "portion", "abhi");
2822 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2823 "type", "PortionType::Para");
2824 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2825 "portion", "foaz");
2827 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
2828 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
2829 discardDumpedLayout();
2830 pXmlDoc = parseLayoutDump();
2832 // show: nothing is merged
2833 assertXPath(pXmlDoc, "//merged", 0);
2835 assertXPath(pXmlDoc,
2836 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/"
2837 "SwLineLayout/SwLinePortion[1]",
2838 "type", "PortionType::Text");
2839 assertXPath(pXmlDoc,
2840 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/"
2841 "SwLineLayout/SwLinePortion[1]",
2842 "portion", "j");
2843 assertXPath(pXmlDoc,
2844 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/"
2845 "SwLineLayout/SwLinePortion[2]",
2846 "type", "PortionType::Text");
2847 assertXPath(pXmlDoc,
2848 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/"
2849 "SwLineLayout/SwLinePortion[2]",
2850 "portion", "kl");
2851 assertXPath(pXmlDoc,
2852 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/SwParaPortion/"
2853 "SwLineLayout/SwParaPortion[1]",
2854 "type", "PortionType::Para");
2855 assertXPath(pXmlDoc,
2856 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/SwParaPortion/"
2857 "SwLineLayout/SwParaPortion[1]",
2858 "portion", "mno");
2859 assertXPath(pXmlDoc,
2860 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/"
2861 "SwLineLayout/SwLinePortion[1]",
2862 "type", "PortionType::Text");
2863 assertXPath(pXmlDoc,
2864 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/"
2865 "SwLineLayout/SwLinePortion[1]",
2866 "portion", "p");
2867 assertXPath(pXmlDoc,
2868 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/"
2869 "SwLineLayout/SwLinePortion[2]",
2870 "type", "PortionType::Text");
2871 assertXPath(pXmlDoc,
2872 "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/"
2873 "SwLineLayout/SwLinePortion[2]",
2874 "portion", "qr");
2875 assertXPath(pXmlDoc,
2876 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2877 "SwFixPortion[1]",
2878 "type",
2879 "PortionType::Fly"); // remove???
2880 assertXPath(pXmlDoc,
2881 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2882 "SwLinePortion[1]",
2883 "type", "PortionType::Text");
2884 assertXPath(pXmlDoc,
2885 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2886 "SwLinePortion[1]",
2887 "portion", "ab");
2888 assertXPath(pXmlDoc,
2889 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2890 "SwLinePortion[2]",
2891 "type", "PortionType::Text");
2892 assertXPath(pXmlDoc,
2893 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
2894 "SwLinePortion[2]",
2895 "portion", "c");
2896 assertXPath(pXmlDoc,
2897 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
2898 "SwParaPortion[1]",
2899 "type", "PortionType::Para");
2900 assertXPath(pXmlDoc,
2901 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
2902 "SwParaPortion[1]",
2903 "portion", "def");
2904 assertXPath(pXmlDoc,
2905 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2906 "SwLinePortion[1]",
2907 "type", "PortionType::Text");
2908 assertXPath(pXmlDoc,
2909 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2910 "SwLinePortion[1]",
2911 "portion", "g");
2912 assertXPath(pXmlDoc,
2913 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2914 "SwLinePortion[2]",
2915 "type", "PortionType::Text");
2916 assertXPath(pXmlDoc,
2917 "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
2918 "SwLinePortion[2]",
2919 "portion", "hi");
2920 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2921 "type", "PortionType::Text");
2922 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2923 "portion", "fo");
2924 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2925 "type", "PortionType::Text");
2926 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2927 "portion", "o");
2928 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2929 "type", "PortionType::Para");
2930 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2931 "portion", "bar");
2932 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2933 "type", "PortionType::Text");
2934 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2935 "portion", "b");
2936 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2937 "type", "PortionType::Text");
2938 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2939 "portion", "az");
2941 // anchor to 2nd (deleted) paragraph
2942 pWrtShell->StartOfSection();
2943 pWrtShell->Down(false, 1);
2944 anchor1.SetType(RndStdIds::FLY_AT_CHAR);
2945 anchor1.SetAnchor(pWrtShell->GetCursor()->GetPoint());
2946 pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1));
2948 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
2949 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
2950 discardDumpedLayout();
2951 pXmlDoc = parseLayoutDump();
2952 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "19");
2953 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2954 "type", "PortionType::Para");
2955 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
2956 "portion", "foaz");
2958 // hide: no anchored object shown
2959 assertXPath(pXmlDoc, "//anchored", 0);
2961 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
2962 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
2963 discardDumpedLayout();
2964 pXmlDoc = parseLayoutDump();
2966 // show: nothing is merged
2967 assertXPath(pXmlDoc, "//merged", 0);
2969 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2970 "type", "PortionType::Text");
2971 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
2972 "portion", "fo");
2973 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2974 "type", "PortionType::Text");
2975 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
2976 "portion", "o");
2977 assertXPath(pXmlDoc,
2978 "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/"
2979 "SwLineLayout/SwLinePortion[1]",
2980 "type", "PortionType::Text");
2981 assertXPath(pXmlDoc,
2982 "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/"
2983 "SwLineLayout/SwLinePortion[1]",
2984 "portion", "j");
2985 assertXPath(pXmlDoc,
2986 "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/"
2987 "SwLineLayout/SwLinePortion[2]",
2988 "type", "PortionType::Text");
2989 assertXPath(pXmlDoc,
2990 "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/"
2991 "SwLineLayout/SwLinePortion[2]",
2992 "portion", "kl");
2993 assertXPath(pXmlDoc,
2994 "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/SwParaPortion/"
2995 "SwLineLayout/SwParaPortion[1]",
2996 "type", "PortionType::Para");
2997 assertXPath(pXmlDoc,
2998 "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/SwParaPortion/"
2999 "SwLineLayout/SwParaPortion[1]",
3000 "portion", "mno");
3001 assertXPath(pXmlDoc,
3002 "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/"
3003 "SwLineLayout/SwLinePortion[1]",
3004 "type", "PortionType::Text");
3005 assertXPath(pXmlDoc,
3006 "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/"
3007 "SwLineLayout/SwLinePortion[1]",
3008 "portion", "p");
3009 assertXPath(pXmlDoc,
3010 "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/"
3011 "SwLineLayout/SwLinePortion[2]",
3012 "type", "PortionType::Text");
3013 assertXPath(pXmlDoc,
3014 "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/"
3015 "SwLineLayout/SwLinePortion[2]",
3016 "portion", "qr");
3017 assertXPath(pXmlDoc,
3018 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
3019 "SwLinePortion[1]",
3020 "type", "PortionType::Text");
3021 assertXPath(pXmlDoc,
3022 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
3023 "SwFixPortion[1]",
3024 "type",
3025 "PortionType::Fly"); // remove???
3026 assertXPath(pXmlDoc,
3027 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
3028 "SwLinePortion[1]",
3029 "portion", "ab");
3030 assertXPath(pXmlDoc,
3031 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
3032 "SwLinePortion[2]",
3033 "type", "PortionType::Text");
3034 assertXPath(pXmlDoc,
3035 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/"
3036 "SwLinePortion[2]",
3037 "portion", "c");
3038 assertXPath(pXmlDoc,
3039 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
3040 "SwParaPortion[1]",
3041 "type", "PortionType::Para");
3042 assertXPath(pXmlDoc,
3043 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/"
3044 "SwParaPortion[1]",
3045 "portion", "def");
3046 assertXPath(pXmlDoc,
3047 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
3048 "SwLinePortion[1]",
3049 "type", "PortionType::Text");
3050 assertXPath(pXmlDoc,
3051 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
3052 "SwLinePortion[1]",
3053 "portion", "g");
3054 assertXPath(pXmlDoc,
3055 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
3056 "SwLinePortion[2]",
3057 "type", "PortionType::Text");
3058 assertXPath(pXmlDoc,
3059 "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/"
3060 "SwLinePortion[2]",
3061 "portion", "hi");
3062 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
3063 "type", "PortionType::Para");
3064 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
3065 "portion", "bar");
3066 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
3067 "type", "PortionType::Text");
3068 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
3069 "portion", "b");
3070 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
3071 "type", "PortionType::Text");
3072 assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
3073 "portion", "az");
3076 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineSections)
3078 createSwDoc("redline_sections.fodt");
3079 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
3080 CPPUNIT_ASSERT(pTextDoc);
3081 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
3082 SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
3083 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
3085 // verify after load
3086 CheckRedlineSectionsHidden();
3088 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
3089 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
3090 // why is this needed explicitly?
3091 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3092 discardDumpedLayout();
3093 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
3095 // show: nothing is merged
3096 assertXPath(pXmlDoc, "//merged", 0);
3097 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/child::*[1]", "type",
3098 "PortionType::Text");
3099 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/child::*[1]",
3100 "portion", "fo");
3101 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/child::*[2]", "type",
3102 "PortionType::Text");
3103 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/child::*[2]",
3104 "portion", "o");
3106 assertXPath(pXmlDoc,
3107 "/root/page[1]/body/section[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
3108 "SwLineLayout/child::*[1]",
3109 "type", "PortionType::Para");
3110 assertXPath(pXmlDoc,
3111 "/root/page[1]/body/section[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/"
3112 "SwLineLayout/child::*[1]",
3113 "portion", "FRAME");
3114 assertXPath(pXmlDoc,
3115 "/root/page[1]/body/section[1]/txt[1]/SwParaPortion/SwLineLayout/child::*[1]",
3116 "type", "PortionType::Para");
3117 assertXPath(pXmlDoc,
3118 "/root/page[1]/body/section[1]/txt[1]/SwParaPortion/SwLineLayout/child::*[1]",
3119 "portion", "bar");
3120 assertXPath(pXmlDoc,
3121 "/root/page[1]/body/section[1]/txt[2]/SwParaPortion/SwLineLayout/child::*[1]",
3122 "type", "PortionType::Para");
3123 assertXPath(pXmlDoc,
3124 "/root/page[1]/body/section[1]/txt[2]/SwParaPortion/SwLineLayout/child::*[1]",
3125 "portion", "baz");
3126 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/child::*[1]", "type",
3127 "PortionType::Text");
3128 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/child::*[1]",
3129 "portion", "b");
3130 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/child::*[2]", "type",
3131 "PortionType::Text");
3132 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/child::*[2]",
3133 "portion", "lah");
3134 assertXPath(pXmlDoc,
3135 "/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/child::*[1]",
3136 "type", "PortionType::Text");
3137 assertXPath(pXmlDoc,
3138 "/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/child::*[1]",
3139 "portion", "fo");
3140 assertXPath(pXmlDoc,
3141 "/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/child::*[2]",
3142 "type", "PortionType::Text");
3143 assertXPath(pXmlDoc,
3144 "/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/child::*[2]",
3145 "portion", "o");
3146 assertXPath(pXmlDoc,
3147 "/root/page[1]/body/section[2]/txt[2]/SwParaPortion/SwLineLayout/child::*[1]",
3148 "type", "PortionType::Para");
3149 assertXPath(pXmlDoc,
3150 "/root/page[1]/body/section[2]/txt[2]/SwParaPortion/SwLineLayout/child::*[1]",
3151 "portion", "bar");
3152 assertXPath(pXmlDoc,
3153 "/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/child::*[1]",
3154 "type", "PortionType::Text");
3155 assertXPath(pXmlDoc,
3156 "/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/child::*[1]",
3157 "portion", "b");
3158 assertXPath(pXmlDoc,
3159 "/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/child::*[2]",
3160 "type", "PortionType::Text");
3161 assertXPath(pXmlDoc,
3162 "/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/child::*[2]",
3163 "portion", "lah");
3165 // verify after hide
3166 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
3167 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
3168 // why is this needed explicitly?
3169 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3170 discardDumpedLayout();
3171 CheckRedlineSectionsHidden();
3174 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TDF69647_images)
3176 createSwDoc("tdf69647_images.odt");
3177 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
3178 CPPUNIT_ASSERT(pTextDoc);
3179 CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of pages does not match!", 2, getPages());
3182 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TDF69647_text)
3184 createSwDoc("tdf69647_text.docx");
3185 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
3186 CPPUNIT_ASSERT(pTextDoc);
3187 CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of pages does not match!", 2, getPages());
3190 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineTables)
3192 createSwDoc("redline_table.fodt");
3193 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
3194 CPPUNIT_ASSERT(pTextDoc);
3195 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
3196 SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
3197 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
3199 // verify after load
3200 discardDumpedLayout();
3201 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
3202 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "12");
3203 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
3204 "type", "PortionType::Para");
3205 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
3206 "portion", "foar");
3208 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
3209 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
3210 // why is this needed explicitly?
3211 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3212 discardDumpedLayout();
3213 pXmlDoc = parseLayoutDump();
3215 // show: nothing is merged
3216 assertXPath(pXmlDoc, "//merged", 0);
3217 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
3218 "type", "PortionType::Text");
3219 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
3220 "portion", "fo");
3221 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
3222 "type", "PortionType::Text");
3223 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
3224 "portion", "o");
3226 assertXPath(pXmlDoc,
3227 "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/anchored/fly[1]/txt[1]/"
3228 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
3229 "type", "PortionType::Para");
3230 assertXPath(pXmlDoc,
3231 "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/anchored/fly[1]/txt[1]/"
3232 "SwParaPortion/SwLineLayout/SwParaPortion[1]",
3233 "portion", "FRAME");
3234 assertXPath(pXmlDoc,
3235 "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/SwParaPortion/SwLineLayout/"
3236 "SwParaPortion[1]",
3237 "type", "PortionType::Para");
3238 assertXPath(pXmlDoc,
3239 "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/SwParaPortion/SwLineLayout/"
3240 "SwParaPortion[1]",
3241 "portion", "aaa");
3242 assertXPath(pXmlDoc,
3243 "/root/page[1]/body/tab[1]/row[2]/cell[2]/txt[1]/SwParaPortion/SwLineLayout/"
3244 "SwParaPortion[1]",
3245 "type", "PortionType::Para");
3246 assertXPath(pXmlDoc,
3247 "/root/page[1]/body/tab[1]/row[2]/cell[2]/txt[1]/SwParaPortion/SwLineLayout/"
3248 "SwParaPortion[1]",
3249 "portion", "ddd");
3250 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
3251 "type", "PortionType::Text");
3252 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
3253 "portion", "b");
3254 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
3255 "type", "PortionType::Text");
3256 assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
3257 "portion", "ar");
3259 // verify after hide
3260 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
3261 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
3262 // why is this needed explicitly?
3263 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3264 discardDumpedLayout();
3265 pXmlDoc = parseLayoutDump();
3266 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "12");
3267 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
3268 "type", "PortionType::Para");
3269 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]",
3270 "portion", "foar");
3273 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144057)
3275 createSwDoc("tdf144057.fodt");
3276 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
3277 CPPUNIT_ASSERT(pTextDoc);
3278 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
3279 SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
3280 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
3281 discardDumpedLayout();
3282 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
3283 // show tracked row deletions
3284 assertXPath(pXmlDoc, "/root/page", 4);
3285 assertXPath(pXmlDoc,
3286 "/root/page[1]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion",
3287 "portion", "A6");
3288 assertXPath(pXmlDoc,
3289 "/root/page[2]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion",
3290 "portion", "A12");
3291 assertXPath(pXmlDoc,
3292 "/root/page[3]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion",
3293 "portion", "B6");
3294 assertXPath(pXmlDoc,
3295 "/root/page[4]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion",
3296 "portion", "B12");
3298 // hide tracked table and table row deletions
3299 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
3300 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
3301 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3302 discardDumpedLayout();
3303 pXmlDoc = parseLayoutDump();
3305 // This was 4 (unhidden tracked table and table row deletions)
3306 assertXPath(pXmlDoc, "/root/page", 1);
3307 assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1);
3308 assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 5);
3309 assertXPath(pXmlDoc,
3310 "/root/page[1]/body/tab/row[5]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion",
3311 "portion", "B12");
3313 // show tracked table and table row deletions again
3314 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
3315 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
3316 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3317 discardDumpedLayout();
3318 pXmlDoc = parseLayoutDump();
3319 assertXPath(pXmlDoc, "/root/page", 4);
3320 assertXPath(pXmlDoc,
3321 "/root/page[1]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion",
3322 "portion", "A6");
3323 assertXPath(pXmlDoc,
3324 "/root/page[2]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion",
3325 "portion", "A12");
3326 assertXPath(pXmlDoc,
3327 "/root/page[3]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion",
3328 "portion", "B6");
3329 assertXPath(pXmlDoc,
3330 "/root/page[4]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion",
3331 "portion", "B12");
3334 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144347)
3336 createSwDoc("tdf144057.fodt");
3337 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
3338 CPPUNIT_ASSERT(pTextDoc);
3339 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
3340 SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
3342 // enable redlining
3343 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
3344 CPPUNIT_ASSERT_MESSAGE("redlining should be on",
3345 pDoc->getIDocumentRedlineAccess().IsRedlineOn());
3346 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
3348 // remove first table
3349 SwEditShell* const pEditShell(pDoc->GetEditShell());
3350 for (int i = 0; i < 12; ++i)
3351 pEditShell->AcceptRedline(0);
3353 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3354 discardDumpedLayout();
3355 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
3356 // show tracked row deletions
3357 assertXPath(pXmlDoc, "/root/page", 2);
3358 assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1);
3360 // select all the text, including the texts before and after the table
3361 // Note: this table contains tracked changes, which was a
3362 // problem for the original OOo implementation of track changes,
3363 // resulting empty tables after accepting the deletion of these tables.
3364 dispatchCommand(mxComponent, ".uno:SelectAll", {});
3365 dispatchCommand(mxComponent, ".uno:SelectAll", {});
3366 dispatchCommand(mxComponent, ".uno:Delete", {});
3367 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3368 discardDumpedLayout();
3369 pXmlDoc = parseLayoutDump();
3371 // table is deleted with change tracking: it still exists
3372 assertXPath(pXmlDoc, "/root/page", 2);
3373 assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1);
3375 // accept all deletions, removing the table completely
3376 while (pEditShell->GetRedlineCount() > 0)
3377 pEditShell->AcceptRedline(0);
3379 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3380 discardDumpedLayout();
3381 pXmlDoc = parseLayoutDump();
3383 assertXPath(pXmlDoc, "/root/page", 1);
3384 // This was 1 (bad empty table)
3385 assertXPath(pXmlDoc, "/root/page[1]/body/tab", 0);
3388 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf155345)
3390 createSwDoc("tdf144057.fodt");
3391 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
3392 CPPUNIT_ASSERT(pTextDoc);
3393 SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
3394 SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
3395 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
3397 // reject all deletions
3398 dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
3400 // enable redlining
3401 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
3402 CPPUNIT_ASSERT_MESSAGE("redlining should be on",
3403 pDoc->getIDocumentRedlineAccess().IsRedlineOn());
3405 // delete table column with track changes
3406 dispatchCommand(mxComponent, ".uno:DeleteColumns", {});
3408 discardDumpedLayout();
3409 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
3410 // show tracked column deletions
3411 assertXPath(pXmlDoc, "/root/page", 4);
3413 // hide tracked table column deletions
3414 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
3415 CPPUNIT_ASSERT(pLayout->IsHideRedlines());
3416 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3417 discardDumpedLayout();
3418 pXmlDoc = parseLayoutDump();
3420 // This was 4 (unhidden tracked table column deletions)
3421 assertXPath(pXmlDoc, "/root/page", 2);
3423 // show tracked table column deletions again
3424 dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
3425 CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
3426 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3427 discardDumpedLayout();
3428 pXmlDoc = parseLayoutDump();
3429 assertXPath(pXmlDoc, "/root/page", 4);
3432 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109137)
3434 createSwDoc("tdf109137.docx");
3435 // FIXME: it's not possible to use 'reload' here because the validation fails with
3436 // Error: attribute "text:start-value" has a bad value
3437 uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
3438 uno::Sequence<beans::PropertyValue> aDescriptor(comphelper::InitPropertySequence({
3439 { "FilterName", uno::Any(OUString("writer8")) },
3440 }));
3441 xStorable->storeToURL(maTempFile.GetURL(), aDescriptor);
3442 mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument");
3443 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
3444 // This was 0, the blue rectangle moved from the 1st to the 2nd page.
3445 assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly/notxt",
3446 /*nNumberOfNodes=*/1);
3449 //just care it doesn't crash/assert
3450 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint72) { createSwDoc("forcepoint72-1.rtf"); }
3452 //just care it doesn't crash/assert
3453 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint75) { createSwDoc("forcepoint75-1.rtf"); }
3455 //just care it doesn't crash/assert
3456 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testUXTSOREL) { createSwDoc("LIBREOFFICE-UXTSOREL.rtf"); }
3458 //just care it doesn't crash/assert
3459 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepointFootnoteFrame)
3461 createSwDoc("forcepoint-swfootnoteframe-1.rtf");
3464 //just care it doesn't crash/assert
3465 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint76) { createSwDoc("forcepoint76-1.rtf"); }
3467 //just care it doesn't crash/assert
3468 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testN4LA0OHZ) { createSwDoc("LIBREOFFICE-N4LA0OHZ.rtf"); }
3470 //just care it doesn't crash/assert
3471 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint89) { createSwWebDoc("forcepoint89.html"); }
3473 //just care it doesn't crash/assert
3474 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint90) { createSwDoc("forcepoint90.rtf"); }
3476 //just care it doesn't crash/assert
3477 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint91) { createSwWebDoc("forcepoint91.html"); }
3479 //just care it doesn't crash/assert
3480 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint92) { createSwDoc("forcepoint92.doc"); }
3482 //just care it doesn't crash/assert
3483 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93)
3485 createSwDoc("forcepoint93-1.rtf");
3486 createSwDoc("forcepoint93-2.rtf");
3489 //just care it doesn't crash/assert
3490 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint94) { createSwWebDoc("forcepoint94.html"); }
3492 //just care it doesn't crash/assert
3493 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint98) { createSwWebDoc("forcepoint98.html"); }
3495 //just care it doesn't crash/assert
3496 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint100) { createSwWebDoc("forcepoint100.html"); }
3498 //just care it doesn't crash/assert
3499 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint102) { createSwDoc("forcepoint102.rtf"); }
3501 //just care it doesn't crash/assert
3502 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint103) { createSwWebDoc("forcepoint103.html"); }
3504 //just care it doesn't crash/assert
3505 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf147485Forcepoint)
3507 createSwDoc("tdf147485-forcepoint.docx");
3510 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf118058)
3512 createSwDoc("tdf118058.fodt");
3513 SwDoc* pDoc = getSwDoc();
3514 // This resulted in a layout loop.
3515 pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
3518 //just care it doesn't crash/assert
3519 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint99) { createSwWebDoc("forcepoint99.html"); }
3521 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128611)
3523 createSwDoc("tdf128611.fodt");
3524 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
3525 CPPUNIT_ASSERT(pXmlDoc);
3526 // Without the accompanying fix in place, this test would have failed with:
3527 // - Expected: 1
3528 // - Actual : 14
3529 // i.e. there were multiple portions in the first paragraph of the A1 cell, which means that the
3530 // rotated text was broken into multiple lines without a good reason.
3531 assertXPathContent(pXmlDoc, "//tab/row/cell[1]/txt", "Abcd efghijkl");
3534 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf142694)
3536 createSwDoc("tdf142694-1.odt");
3538 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
3539 CPPUNIT_ASSERT(pXmlDoc);
3541 // the problem with this table is that the 3rd text frame (inside a nested
3542 // table) contains an as-char fly that doesn't fit on a page with the
3543 // repeated header row; currently it's split so that the 3rd text frame is
3544 // on a page of its own and extends outside the table.
3546 assertXPathNoAttribute(pXmlDoc, "/root/page[4]/body/tab[1]", "precede");
3547 CPPUNIT_ASSERT(!getXPath(pXmlDoc, "/root/page[4]/body/tab[1]", "follow").isEmpty());
3548 assertXPath(pXmlDoc, "/root/page[4]/body/tab[1]/row[1]/cell[1]/tab", 1);
3549 assertXPath(pXmlDoc, "/root/page[4]/body/tab[1]/row[2]/cell[1]/txt", 2);
3550 CPPUNIT_ASSERT(!getXPath(pXmlDoc, "/root/page[5]/body/tab[1]", "precede").isEmpty());
3551 assertXPathNoAttribute(pXmlDoc, "/root/page[5]/body/tab[1]", "follow");
3552 assertXPath(pXmlDoc, "/root/page[5]/body/tab[1]/row[1]/cell[1]/tab", 1);
3553 assertXPath(pXmlDoc, "/root/page[5]/body/tab[1]/row[2]/cell[1]/tab", 1);
3554 assertXPathNoAttribute(pXmlDoc, "/root/page[5]/body/tab[1]/row[2]/cell[1]/tab", "follow");
3555 assertXPath(pXmlDoc, "/root/page[5]/body/tab[1]/row[2]/cell[1]/tab/row/cell/txt", 1);
3558 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf152413)
3560 createSwDoc("tdf152413.fodt");
3561 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
3563 // Without the fix in place, this test would have failed with
3564 // - Expected: 1
3565 // - Actual : 2
3566 // - In <>, XPath '/root/page/body/txt/SwParaPortion/SwLineLayout/SwLinePortion' number of nodes is incorrect
3567 assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwLinePortion", "portion",
3568 u"صِرَ ٰطَ");
3571 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf125893)
3573 createSwDoc("tdf125893.docx");
3574 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
3575 // This was 400. The paragraph must have zero top border.
3576 assertXPath(pXmlDoc, "/root/page/body/txt[4]/infos/prtBounds", "top", "0");
3579 CPPUNIT_PLUGIN_IMPLEMENT();
3581 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */