From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- sw/qa/core/layout/data/birt_min.odt | Bin 0 -> 20194 bytes sw/qa/core/layout/data/border-collapse-compat.docx | Bin 0 -> 12669 bytes sw/qa/core/layout/data/btlr-nested-cell.odt | Bin 0 -> 9936 bytes sw/qa/core/layout/data/btlr-table-row-span.odt | Bin 0 -> 11958 bytes sw/qa/core/layout/data/bullet.png | Bin 0 -> 351 bytes .../data/continuous-endnotes-move-backwards.doc | Bin 0 -> 24576 bytes .../core/layout/data/double-border-horizontal.docx | Bin 0 -> 12250 bytes sw/qa/core/layout/data/double-border-vertical.docx | Bin 0 -> 12253 bytes sw/qa/core/layout/data/double-page-border.docx | Bin 0 -> 12053 bytes sw/qa/core/layout/data/floattable-2cols.docx | Bin 0 -> 31941 bytes sw/qa/core/layout/data/floattable-3pages.docx | Bin 0 -> 13014 bytes .../data/floattable-anchor-keep-with-next.docx | Bin 0 -> 12225 bytes .../core/layout/data/floattable-compat14-body.docx | Bin 0 -> 27894 bytes .../layout/data/floattable-compat14-nosplit.docx | Bin 0 -> 26165 bytes sw/qa/core/layout/data/floattable-compat14.docx | Bin 0 -> 28497 bytes sw/qa/core/layout/data/floattable-del-empty.docx | Bin 0 -> 36317 bytes .../layout/data/floattable-deleted-anchor.docx | Bin 0 -> 41531 bytes .../core/layout/data/floattable-footer-2rows.docx | Bin 0 -> 31993 bytes sw/qa/core/layout/data/floattable-footer.docx | Bin 0 -> 31661 bytes sw/qa/core/layout/data/floattable-from-bottom.docx | Bin 0 -> 59718 bytes sw/qa/core/layout/data/floattable-hori-pos.docx | Bin 0 -> 12432 bytes .../layout/data/floattable-in-inlinetable.docx | Bin 0 -> 18597 bytes .../layout/data/floattable-in-inltbl-in-sect.docx | Bin 0 -> 18625 bytes sw/qa/core/layout/data/floattable-in-section.docx | Bin 0 -> 14024 bytes .../layout/data/floattable-in-text-section.docx | Bin 0 -> 12452 bytes ...e-model-position-for-view-point-correction.docx | Bin 0 -> 12696 bytes sw/qa/core/layout/data/floattable-move-master.docx | Bin 0 -> 13635 bytes sw/qa/core/layout/data/floattable-multi-col.docx | Bin 0 -> 12525 bytes .../layout/data/floattable-negative-height.docx | Bin 0 -> 39432 bytes .../core/layout/data/floattable-nested-overlap.odt | Bin 0 -> 11681 bytes .../layout/data/floattable-nested-rowspan.docx | Bin 0 -> 25940 bytes sw/qa/core/layout/data/floattable-nested.odt | Bin 0 -> 11635 bytes .../data/floattable-next-leaf-in-section.docx | Bin 0 -> 24632 bytes .../data/floattable-next-row-invalidate-pos.docx | Bin 0 -> 9281 bytes .../layout/data/floattable-no-footer-overlap.doc | Bin 0 -> 48640 bytes sw/qa/core/layout/data/floattable-nomargins.docx | Bin 0 -> 12737 bytes .../layout/data/floattable-object-formatter.docx | Bin 0 -> 21480 bytes sw/qa/core/layout/data/floattable-rowsplit.docx | Bin 0 -> 13220 bytes .../layout/data/floattable-tab-join-legacy.docx | Bin 0 -> 21410 bytes sw/qa/core/layout/data/floattable-tab-join.docx | Bin 0 -> 21571 bytes sw/qa/core/layout/data/floattable-table-join.docx | Bin 0 -> 16869 bytes .../layout/data/floattable-table-row-keep.docx | Bin 0 -> 41801 bytes sw/qa/core/layout/data/floattable-then-table.doc | Bin 0 -> 50688 bytes sw/qa/core/layout/data/floattable-then-table.docx | Bin 0 -> 28857 bytes sw/qa/core/layout/data/floattable-vertoffset.docx | Bin 0 -> 12960 bytes sw/qa/core/layout/data/floattable-widow.docx | Bin 0 -> 31279 bytes .../layout/data/floattable-wrap-on-all-pages.docx | Bin 0 -> 13099 bytes .../layout/data/floattable-wrapped-by-table.docx | Bin 0 -> 12728 bytes sw/qa/core/layout/data/floattable.docx | Bin 0 -> 12966 bytes sw/qa/core/layout/data/header-textbox.docx | Bin 0 -> 5778 bytes sw/qa/core/layout/data/inner-border.docx | Bin 0 -> 12391 bytes .../core/layout/data/keepwithnext-fullheight.fodt | 42 + sw/qa/core/layout/data/linked-bullet.odt | Bin 0 -> 8779 bytes .../core/layout/data/page-remove-fly-no-table.fodt | 460 +++++++ sw/qa/core/layout/data/page-remove-fly-table.odt | Bin 0 -> 13943 bytes .../core/layout/data/para-border-in-cell-clip.docx | Bin 0 -> 12524 bytes sw/qa/core/layout/data/rtl-table.docx | Bin 0 -> 5487 bytes sw/qa/core/layout/data/shape-textbox.odt | Bin 0 -> 15441 bytes sw/qa/core/layout/data/sorted-objs-insert.docx | Bin 0 -> 27084 bytes sw/qa/core/layout/data/split-table-border.odt | Bin 0 -> 13057 bytes .../core/layout/data/split-table-merged-border.odt | Bin 0 -> 12318 bytes .../layout/data/table-fly-overlap-spacing.docx | Bin 0 -> 24594 bytes sw/qa/core/layout/data/table-fly-overlap.docx | Bin 0 -> 17718 bytes sw/qa/core/layout/data/table-in-footnote.docx | Bin 0 -> 15684 bytes sw/qa/core/layout/data/table-missing-join.docx | Bin 0 -> 18441 bytes sw/qa/core/layout/data/table-print-area-left.docx | Bin 0 -> 11807 bytes sw/qa/core/layout/data/tables-move-backwards.odt | Bin 0 -> 9578 bytes sw/qa/core/layout/data/tdf122894-4.doc | Bin 0 -> 214528 bytes sw/qa/core/layout/data/tdf128195.docx | Bin 0 -> 14883 bytes ...f134783_testAnchorPositionBasedOnParagraph.fodt | 284 +++++ sw/qa/core/layout/data/tdf157096.docx | Bin 0 -> 18904 bytes sw/qa/core/layout/data/tdf45908_invoice.odt | Bin 0 -> 4780 bytes .../layout/data/textbox-autogrow-vertical.docx | Bin 0 -> 13722 bytes sw/qa/core/layout/data/textbox-modification.docx | Bin 0 -> 12284 bytes sw/qa/core/layout/data/textbox-phantom-change.docx | Bin 0 -> 5092 bytes sw/qa/core/layout/data/vmerge-cell-border.docx | Bin 0 -> 13610 bytes sw/qa/core/layout/fly.cxx | 91 ++ sw/qa/core/layout/flycnt.cxx | 1275 ++++++++++++++++++++ sw/qa/core/layout/frmtool.cxx | 40 + sw/qa/core/layout/ftnfrm.cxx | 66 + sw/qa/core/layout/layact.cxx | 91 ++ sw/qa/core/layout/layout.cxx | 1052 ++++++++++++++++ sw/qa/core/layout/paintfrm.cxx | 163 +++ sw/qa/core/layout/sortedobjs.cxx | 35 + sw/qa/core/layout/tabfrm.cxx | 204 ++++ sw/qa/core/layout/trvlfrm.cxx | 56 + 86 files changed, 3859 insertions(+) create mode 100644 sw/qa/core/layout/data/birt_min.odt create mode 100644 sw/qa/core/layout/data/border-collapse-compat.docx create mode 100644 sw/qa/core/layout/data/btlr-nested-cell.odt create mode 100644 sw/qa/core/layout/data/btlr-table-row-span.odt create mode 100644 sw/qa/core/layout/data/bullet.png create mode 100644 sw/qa/core/layout/data/continuous-endnotes-move-backwards.doc create mode 100644 sw/qa/core/layout/data/double-border-horizontal.docx create mode 100644 sw/qa/core/layout/data/double-border-vertical.docx create mode 100644 sw/qa/core/layout/data/double-page-border.docx create mode 100644 sw/qa/core/layout/data/floattable-2cols.docx create mode 100644 sw/qa/core/layout/data/floattable-3pages.docx create mode 100644 sw/qa/core/layout/data/floattable-anchor-keep-with-next.docx create mode 100644 sw/qa/core/layout/data/floattable-compat14-body.docx create mode 100644 sw/qa/core/layout/data/floattable-compat14-nosplit.docx create mode 100644 sw/qa/core/layout/data/floattable-compat14.docx create mode 100644 sw/qa/core/layout/data/floattable-del-empty.docx create mode 100644 sw/qa/core/layout/data/floattable-deleted-anchor.docx create mode 100644 sw/qa/core/layout/data/floattable-footer-2rows.docx create mode 100644 sw/qa/core/layout/data/floattable-footer.docx create mode 100644 sw/qa/core/layout/data/floattable-from-bottom.docx create mode 100644 sw/qa/core/layout/data/floattable-hori-pos.docx create mode 100644 sw/qa/core/layout/data/floattable-in-inlinetable.docx create mode 100644 sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx create mode 100644 sw/qa/core/layout/data/floattable-in-section.docx create mode 100644 sw/qa/core/layout/data/floattable-in-text-section.docx create mode 100644 sw/qa/core/layout/data/floattable-model-position-for-view-point-correction.docx create mode 100644 sw/qa/core/layout/data/floattable-move-master.docx create mode 100644 sw/qa/core/layout/data/floattable-multi-col.docx create mode 100644 sw/qa/core/layout/data/floattable-negative-height.docx create mode 100644 sw/qa/core/layout/data/floattable-nested-overlap.odt create mode 100644 sw/qa/core/layout/data/floattable-nested-rowspan.docx create mode 100644 sw/qa/core/layout/data/floattable-nested.odt create mode 100644 sw/qa/core/layout/data/floattable-next-leaf-in-section.docx create mode 100644 sw/qa/core/layout/data/floattable-next-row-invalidate-pos.docx create mode 100644 sw/qa/core/layout/data/floattable-no-footer-overlap.doc create mode 100644 sw/qa/core/layout/data/floattable-nomargins.docx create mode 100644 sw/qa/core/layout/data/floattable-object-formatter.docx create mode 100644 sw/qa/core/layout/data/floattable-rowsplit.docx create mode 100644 sw/qa/core/layout/data/floattable-tab-join-legacy.docx create mode 100644 sw/qa/core/layout/data/floattable-tab-join.docx create mode 100644 sw/qa/core/layout/data/floattable-table-join.docx create mode 100644 sw/qa/core/layout/data/floattable-table-row-keep.docx create mode 100644 sw/qa/core/layout/data/floattable-then-table.doc create mode 100644 sw/qa/core/layout/data/floattable-then-table.docx create mode 100644 sw/qa/core/layout/data/floattable-vertoffset.docx create mode 100644 sw/qa/core/layout/data/floattable-widow.docx create mode 100644 sw/qa/core/layout/data/floattable-wrap-on-all-pages.docx create mode 100644 sw/qa/core/layout/data/floattable-wrapped-by-table.docx create mode 100644 sw/qa/core/layout/data/floattable.docx create mode 100644 sw/qa/core/layout/data/header-textbox.docx create mode 100644 sw/qa/core/layout/data/inner-border.docx create mode 100644 sw/qa/core/layout/data/keepwithnext-fullheight.fodt create mode 100644 sw/qa/core/layout/data/linked-bullet.odt create mode 100644 sw/qa/core/layout/data/page-remove-fly-no-table.fodt create mode 100644 sw/qa/core/layout/data/page-remove-fly-table.odt create mode 100644 sw/qa/core/layout/data/para-border-in-cell-clip.docx create mode 100644 sw/qa/core/layout/data/rtl-table.docx create mode 100644 sw/qa/core/layout/data/shape-textbox.odt create mode 100644 sw/qa/core/layout/data/sorted-objs-insert.docx create mode 100644 sw/qa/core/layout/data/split-table-border.odt create mode 100644 sw/qa/core/layout/data/split-table-merged-border.odt create mode 100644 sw/qa/core/layout/data/table-fly-overlap-spacing.docx create mode 100644 sw/qa/core/layout/data/table-fly-overlap.docx create mode 100644 sw/qa/core/layout/data/table-in-footnote.docx create mode 100644 sw/qa/core/layout/data/table-missing-join.docx create mode 100644 sw/qa/core/layout/data/table-print-area-left.docx create mode 100644 sw/qa/core/layout/data/tables-move-backwards.odt create mode 100644 sw/qa/core/layout/data/tdf122894-4.doc create mode 100644 sw/qa/core/layout/data/tdf128195.docx create mode 100644 sw/qa/core/layout/data/tdf134783_testAnchorPositionBasedOnParagraph.fodt create mode 100644 sw/qa/core/layout/data/tdf157096.docx create mode 100644 sw/qa/core/layout/data/tdf45908_invoice.odt create mode 100644 sw/qa/core/layout/data/textbox-autogrow-vertical.docx create mode 100644 sw/qa/core/layout/data/textbox-modification.docx create mode 100644 sw/qa/core/layout/data/textbox-phantom-change.docx create mode 100644 sw/qa/core/layout/data/vmerge-cell-border.docx create mode 100644 sw/qa/core/layout/fly.cxx create mode 100644 sw/qa/core/layout/flycnt.cxx create mode 100644 sw/qa/core/layout/frmtool.cxx create mode 100644 sw/qa/core/layout/ftnfrm.cxx create mode 100644 sw/qa/core/layout/layact.cxx create mode 100644 sw/qa/core/layout/layout.cxx create mode 100644 sw/qa/core/layout/paintfrm.cxx create mode 100644 sw/qa/core/layout/sortedobjs.cxx create mode 100644 sw/qa/core/layout/tabfrm.cxx create mode 100644 sw/qa/core/layout/trvlfrm.cxx (limited to 'sw/qa/core/layout') diff --git a/sw/qa/core/layout/data/birt_min.odt b/sw/qa/core/layout/data/birt_min.odt new file mode 100644 index 0000000000..91193644c2 Binary files /dev/null and b/sw/qa/core/layout/data/birt_min.odt differ diff --git a/sw/qa/core/layout/data/border-collapse-compat.docx b/sw/qa/core/layout/data/border-collapse-compat.docx new file mode 100644 index 0000000000..a3f29cbe8d Binary files /dev/null and b/sw/qa/core/layout/data/border-collapse-compat.docx differ diff --git a/sw/qa/core/layout/data/btlr-nested-cell.odt b/sw/qa/core/layout/data/btlr-nested-cell.odt new file mode 100644 index 0000000000..ca7a4798db Binary files /dev/null and b/sw/qa/core/layout/data/btlr-nested-cell.odt differ diff --git a/sw/qa/core/layout/data/btlr-table-row-span.odt b/sw/qa/core/layout/data/btlr-table-row-span.odt new file mode 100644 index 0000000000..ca4b6872fb Binary files /dev/null and b/sw/qa/core/layout/data/btlr-table-row-span.odt differ diff --git a/sw/qa/core/layout/data/bullet.png b/sw/qa/core/layout/data/bullet.png new file mode 100644 index 0000000000..4e2dcf4149 Binary files /dev/null and b/sw/qa/core/layout/data/bullet.png differ diff --git a/sw/qa/core/layout/data/continuous-endnotes-move-backwards.doc b/sw/qa/core/layout/data/continuous-endnotes-move-backwards.doc new file mode 100644 index 0000000000..3ee6c56aa3 Binary files /dev/null and b/sw/qa/core/layout/data/continuous-endnotes-move-backwards.doc differ diff --git a/sw/qa/core/layout/data/double-border-horizontal.docx b/sw/qa/core/layout/data/double-border-horizontal.docx new file mode 100644 index 0000000000..624c7aa1aa Binary files /dev/null and b/sw/qa/core/layout/data/double-border-horizontal.docx differ diff --git a/sw/qa/core/layout/data/double-border-vertical.docx b/sw/qa/core/layout/data/double-border-vertical.docx new file mode 100644 index 0000000000..a4731ebec6 Binary files /dev/null and b/sw/qa/core/layout/data/double-border-vertical.docx differ diff --git a/sw/qa/core/layout/data/double-page-border.docx b/sw/qa/core/layout/data/double-page-border.docx new file mode 100644 index 0000000000..a706b327cd Binary files /dev/null and b/sw/qa/core/layout/data/double-page-border.docx differ diff --git a/sw/qa/core/layout/data/floattable-2cols.docx b/sw/qa/core/layout/data/floattable-2cols.docx new file mode 100644 index 0000000000..b55bc8dd49 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-2cols.docx differ diff --git a/sw/qa/core/layout/data/floattable-3pages.docx b/sw/qa/core/layout/data/floattable-3pages.docx new file mode 100644 index 0000000000..d6cbdafc19 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-3pages.docx differ diff --git a/sw/qa/core/layout/data/floattable-anchor-keep-with-next.docx b/sw/qa/core/layout/data/floattable-anchor-keep-with-next.docx new file mode 100644 index 0000000000..a0930900d8 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-anchor-keep-with-next.docx differ diff --git a/sw/qa/core/layout/data/floattable-compat14-body.docx b/sw/qa/core/layout/data/floattable-compat14-body.docx new file mode 100644 index 0000000000..fc25b867af Binary files /dev/null and b/sw/qa/core/layout/data/floattable-compat14-body.docx differ diff --git a/sw/qa/core/layout/data/floattable-compat14-nosplit.docx b/sw/qa/core/layout/data/floattable-compat14-nosplit.docx new file mode 100644 index 0000000000..bd3f09c69e Binary files /dev/null and b/sw/qa/core/layout/data/floattable-compat14-nosplit.docx differ diff --git a/sw/qa/core/layout/data/floattable-compat14.docx b/sw/qa/core/layout/data/floattable-compat14.docx new file mode 100644 index 0000000000..19221609dd Binary files /dev/null and b/sw/qa/core/layout/data/floattable-compat14.docx differ diff --git a/sw/qa/core/layout/data/floattable-del-empty.docx b/sw/qa/core/layout/data/floattable-del-empty.docx new file mode 100644 index 0000000000..340d06b622 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-del-empty.docx differ diff --git a/sw/qa/core/layout/data/floattable-deleted-anchor.docx b/sw/qa/core/layout/data/floattable-deleted-anchor.docx new file mode 100644 index 0000000000..cab5b68ff9 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-deleted-anchor.docx differ diff --git a/sw/qa/core/layout/data/floattable-footer-2rows.docx b/sw/qa/core/layout/data/floattable-footer-2rows.docx new file mode 100644 index 0000000000..0d3db047c1 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-footer-2rows.docx differ diff --git a/sw/qa/core/layout/data/floattable-footer.docx b/sw/qa/core/layout/data/floattable-footer.docx new file mode 100644 index 0000000000..731e4fdb23 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-footer.docx differ diff --git a/sw/qa/core/layout/data/floattable-from-bottom.docx b/sw/qa/core/layout/data/floattable-from-bottom.docx new file mode 100644 index 0000000000..86374a68ba Binary files /dev/null and b/sw/qa/core/layout/data/floattable-from-bottom.docx differ diff --git a/sw/qa/core/layout/data/floattable-hori-pos.docx b/sw/qa/core/layout/data/floattable-hori-pos.docx new file mode 100644 index 0000000000..7a5e033a49 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-hori-pos.docx differ diff --git a/sw/qa/core/layout/data/floattable-in-inlinetable.docx b/sw/qa/core/layout/data/floattable-in-inlinetable.docx new file mode 100644 index 0000000000..56505316cd Binary files /dev/null and b/sw/qa/core/layout/data/floattable-in-inlinetable.docx differ diff --git a/sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx b/sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx new file mode 100644 index 0000000000..ff329ecb5a Binary files /dev/null and b/sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx differ diff --git a/sw/qa/core/layout/data/floattable-in-section.docx b/sw/qa/core/layout/data/floattable-in-section.docx new file mode 100644 index 0000000000..a0e9090bcc Binary files /dev/null and b/sw/qa/core/layout/data/floattable-in-section.docx differ diff --git a/sw/qa/core/layout/data/floattable-in-text-section.docx b/sw/qa/core/layout/data/floattable-in-text-section.docx new file mode 100644 index 0000000000..5b377dd037 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-in-text-section.docx differ diff --git a/sw/qa/core/layout/data/floattable-model-position-for-view-point-correction.docx b/sw/qa/core/layout/data/floattable-model-position-for-view-point-correction.docx new file mode 100644 index 0000000000..1de36c6e0c Binary files /dev/null and b/sw/qa/core/layout/data/floattable-model-position-for-view-point-correction.docx differ diff --git a/sw/qa/core/layout/data/floattable-move-master.docx b/sw/qa/core/layout/data/floattable-move-master.docx new file mode 100644 index 0000000000..03087eb358 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-move-master.docx differ diff --git a/sw/qa/core/layout/data/floattable-multi-col.docx b/sw/qa/core/layout/data/floattable-multi-col.docx new file mode 100644 index 0000000000..10e63bad39 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-multi-col.docx differ diff --git a/sw/qa/core/layout/data/floattable-negative-height.docx b/sw/qa/core/layout/data/floattable-negative-height.docx new file mode 100644 index 0000000000..e5b6cd5103 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-negative-height.docx differ diff --git a/sw/qa/core/layout/data/floattable-nested-overlap.odt b/sw/qa/core/layout/data/floattable-nested-overlap.odt new file mode 100644 index 0000000000..b90ae9a7b0 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-nested-overlap.odt differ diff --git a/sw/qa/core/layout/data/floattable-nested-rowspan.docx b/sw/qa/core/layout/data/floattable-nested-rowspan.docx new file mode 100644 index 0000000000..48cbdbfe59 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-nested-rowspan.docx differ diff --git a/sw/qa/core/layout/data/floattable-nested.odt b/sw/qa/core/layout/data/floattable-nested.odt new file mode 100644 index 0000000000..3d21314f58 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-nested.odt differ diff --git a/sw/qa/core/layout/data/floattable-next-leaf-in-section.docx b/sw/qa/core/layout/data/floattable-next-leaf-in-section.docx new file mode 100644 index 0000000000..3a315d51c9 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-next-leaf-in-section.docx differ diff --git a/sw/qa/core/layout/data/floattable-next-row-invalidate-pos.docx b/sw/qa/core/layout/data/floattable-next-row-invalidate-pos.docx new file mode 100644 index 0000000000..bbc7114b8e Binary files /dev/null and b/sw/qa/core/layout/data/floattable-next-row-invalidate-pos.docx differ diff --git a/sw/qa/core/layout/data/floattable-no-footer-overlap.doc b/sw/qa/core/layout/data/floattable-no-footer-overlap.doc new file mode 100644 index 0000000000..87e301189d Binary files /dev/null and b/sw/qa/core/layout/data/floattable-no-footer-overlap.doc differ diff --git a/sw/qa/core/layout/data/floattable-nomargins.docx b/sw/qa/core/layout/data/floattable-nomargins.docx new file mode 100644 index 0000000000..642010e0f3 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-nomargins.docx differ diff --git a/sw/qa/core/layout/data/floattable-object-formatter.docx b/sw/qa/core/layout/data/floattable-object-formatter.docx new file mode 100644 index 0000000000..2582af0eb8 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-object-formatter.docx differ diff --git a/sw/qa/core/layout/data/floattable-rowsplit.docx b/sw/qa/core/layout/data/floattable-rowsplit.docx new file mode 100644 index 0000000000..8e1e9fb301 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-rowsplit.docx differ diff --git a/sw/qa/core/layout/data/floattable-tab-join-legacy.docx b/sw/qa/core/layout/data/floattable-tab-join-legacy.docx new file mode 100644 index 0000000000..f4056bf21f Binary files /dev/null and b/sw/qa/core/layout/data/floattable-tab-join-legacy.docx differ diff --git a/sw/qa/core/layout/data/floattable-tab-join.docx b/sw/qa/core/layout/data/floattable-tab-join.docx new file mode 100644 index 0000000000..cb1990c2a8 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-tab-join.docx differ diff --git a/sw/qa/core/layout/data/floattable-table-join.docx b/sw/qa/core/layout/data/floattable-table-join.docx new file mode 100644 index 0000000000..807b4cfa8c Binary files /dev/null and b/sw/qa/core/layout/data/floattable-table-join.docx differ diff --git a/sw/qa/core/layout/data/floattable-table-row-keep.docx b/sw/qa/core/layout/data/floattable-table-row-keep.docx new file mode 100644 index 0000000000..c7edcc0334 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-table-row-keep.docx differ diff --git a/sw/qa/core/layout/data/floattable-then-table.doc b/sw/qa/core/layout/data/floattable-then-table.doc new file mode 100644 index 0000000000..8c9684e595 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-then-table.doc differ diff --git a/sw/qa/core/layout/data/floattable-then-table.docx b/sw/qa/core/layout/data/floattable-then-table.docx new file mode 100644 index 0000000000..eb06507bd8 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-then-table.docx differ diff --git a/sw/qa/core/layout/data/floattable-vertoffset.docx b/sw/qa/core/layout/data/floattable-vertoffset.docx new file mode 100644 index 0000000000..d71a587f9c Binary files /dev/null and b/sw/qa/core/layout/data/floattable-vertoffset.docx differ diff --git a/sw/qa/core/layout/data/floattable-widow.docx b/sw/qa/core/layout/data/floattable-widow.docx new file mode 100644 index 0000000000..c3f17e6cd9 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-widow.docx differ diff --git a/sw/qa/core/layout/data/floattable-wrap-on-all-pages.docx b/sw/qa/core/layout/data/floattable-wrap-on-all-pages.docx new file mode 100644 index 0000000000..39642002bb Binary files /dev/null and b/sw/qa/core/layout/data/floattable-wrap-on-all-pages.docx differ diff --git a/sw/qa/core/layout/data/floattable-wrapped-by-table.docx b/sw/qa/core/layout/data/floattable-wrapped-by-table.docx new file mode 100644 index 0000000000..a53f652183 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-wrapped-by-table.docx differ diff --git a/sw/qa/core/layout/data/floattable.docx b/sw/qa/core/layout/data/floattable.docx new file mode 100644 index 0000000000..ee1b029882 Binary files /dev/null and b/sw/qa/core/layout/data/floattable.docx differ diff --git a/sw/qa/core/layout/data/header-textbox.docx b/sw/qa/core/layout/data/header-textbox.docx new file mode 100644 index 0000000000..4df72cccd3 Binary files /dev/null and b/sw/qa/core/layout/data/header-textbox.docx differ diff --git a/sw/qa/core/layout/data/inner-border.docx b/sw/qa/core/layout/data/inner-border.docx new file mode 100644 index 0000000000..1d8adc9fe8 Binary files /dev/null and b/sw/qa/core/layout/data/inner-border.docx differ diff --git a/sw/qa/core/layout/data/keepwithnext-fullheight.fodt b/sw/qa/core/layout/data/keepwithnext-fullheight.fodt new file mode 100644 index 0000000000..b33dd80e71 --- /dev/null +++ b/sw/qa/core/layout/data/keepwithnext-fullheight.fodt @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + Landscape page + Heading + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz + UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA + AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 + AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ + BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 + cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn + /878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF + QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo + YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo + 2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A + cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA + AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A + hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 + 5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA + AABJRU5ErkJggg== + + + + diff --git a/sw/qa/core/layout/data/linked-bullet.odt b/sw/qa/core/layout/data/linked-bullet.odt new file mode 100644 index 0000000000..ae165531ab Binary files /dev/null and b/sw/qa/core/layout/data/linked-bullet.odt differ diff --git a/sw/qa/core/layout/data/page-remove-fly-no-table.fodt b/sw/qa/core/layout/data/page-remove-fly-no-table.fodt new file mode 100644 index 0000000000..035688b85b --- /dev/null +++ b/sw/qa/core/layout/data/page-remove-fly-no-table.fodt @@ -0,0 +1,460 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2022-04-24_Quirks in the focusing property of the Navigator + This example file shows several bugs. It was written as an example to #148755. But I also recorded all other surprising things in order to report them on separate bug reports. Don’t mind if they appear here, it is just just to catch some of them in order to report them. + This report was written with + Version: 7.4.0.0.alpha0+ / LibreOffice CommunityBuild ID: f775b625b497b4fa6731bddd433916dde52fbb2eCPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3Locale: de-DE (de_DE.UTF-8); UI: en-USCalc: threaded + but I have seen some of these glitches also in other versions of LO Writer! + + + Table of Contents + + + + + + + + + + + + Table of Contents + + + + + + + + + + + + + + + + + + + + + + Original Post #148755 + Preceding events + + + New findings + + + + Sometimes I use tables because they make the location of inserted images more predictable than if I insert them into the text (e.g. anchored to paragraphs). If - as e.g. often in user manuals - many short text passages and corresponding illustrations follow one after another, it may even make sense to place headings in tables as well. If you do this, however, you lose the nice feature of the navigator that you can continuously see how a text is positioned in the hierarchy of associated headings: The navigator suddenly shows the position in the hierarchy of tables (or sections, if the text passage is in a section). + Expected behavior: + I expect the navigator to always show the location of the bookmark in the editing window with respect to the category selected in the navigator's drop-down list of categories at the top left (really useful there are headings, tables, maybe sections. For hyperlinks, I can only imagine that it might make sense to highlight the next hyperlink before the position of the bookmark in the editing window). + + An example + In order to demonstrate the to be shown behavior, I add some headlines such that navigator really has some structure to show. Then I also add the original post, but this time arranged in a table: + Original Post #148755 in a table + + + + + Preceding events in a table + + + + + End of June 2021 I first observed that the Navigator adjusts itself to the proper headline associated to the current editing position. The item belonging to the edit position in the Edit window gets highlighted. That's something which has long been missing and which is very useful. + + + + + New findings in a table + + + + + Now I found something inconsistent with that: If the edit position in the edit window is in a table, the highlight moves to the relevant entry in the Tables category, if it is in a section, the highlight jumps to the proper entry in the Sections category. + + + + + + When writing a larger document, the main hierarchy of things is by headline order. Being able to associate some place in the document to the surrounding headlines hierarchy is the main concern. Only in very special cases one might want to locate an image in the list of all images or a table in the list of all tables and so on. + + + + + Locating something in another category than the one highlighted (Headings/Images/Sections/Table, ..., topmost drop-down setting of Navigator) is not meaningful, especially jumping to sections instead of headlines is bizarre. + + + + + Sometimes I use tables because they make the location of inserted images more predictable than if I insert them into the text (e.g. anchored to paragraphs). If - as e.g. often in user manuals - many short text passages and corresponding illustrations follow one after another, it may even make sense to place headings in tables as well. If you do this, however, you lose the nice feature of the navigator that you can continuously see how a text is positioned in the hierarchy of associated headings: The navigator suddenly shows the position in the hierarchy of tables (or sections, if the text passage is in a section). + + + + + Expected behavior in a table: + + + + + I expect the navigator to always show the location of the bookmark in the editing window with respect to the category selected in the navigator's drop-down list of categories at the top left (really useful there are headings, tables, maybe sections. For hyperlinks, I can only imagine that it might make sense to highlight the next hyperlink before the position of the bookmark in the editing window). + + + + Some screenshots demonstrating what goes wrong + + + + + What goes right + Before I’ll show what goes wrong, I’ll precede my examples with one showing that Navigator’s reflection of edit places goes right, as long as one navigates in text which is not part of a table (or a section, which we will encounter soon): I go some lines up, add the word HERE to some place and make a screenshot: + + + + + + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz +UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA +AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 +AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ +BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 +cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn +/878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF +QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo +YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo +2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A +cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA +AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A +hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 +5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA +AABJRU5ErkJggg==The highlighted word HERE is in the paragraph with headline “An example“: the right paragraph is highlighted in the Navigator. That’s really helpful. In order to show that this is not just an accidental result, I’ll remove the highlighted word and transplant it to some other paragraph: + + + + + + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz +UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA +AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 +AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ +BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 +cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn +/878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF +QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo +YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo +2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A +cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA +AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A +hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 +5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA +AABJRU5ErkJggg==Again the highlighted portion in the Navigator shows the position in the edit window. Now I’ll test it with yet another place. + + + + + But this one will go wrong: + + + + + + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz +UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA +AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 +AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ +BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 +cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn +/878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF +QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo +YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo +2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A +cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA +AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A +hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 +5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA +AABJRU5ErkJggg==1. Expected result + This time, the highlight is in section c0! This is really surprising! I have not created any section c0 active at all. Even when LO Writer created one for internal organizational reasons: my text is under the heading “New findings”! + + + + + Continued examples + In order to avoid any difficulty of pasted screenshots appearing on arbitrary places (another bug, but not the issue of this error report, I place all my text and screenshots to just another table: In the next picture, you see the navigator when the focus in the text field is HERE + + + + + + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz +UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA +AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 +AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ +BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 +cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn +/878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF +QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo +YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo +2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A +cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA +AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A +hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 +5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA +AABJRU5ErkJggg==As you see, Table2 under Tables is highlighted. You might argue, ok, the focus is really in Table2, just go to Headings in Navigator. I’ll do that now: + + + + + + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz +UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA +AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 +AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ +BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 +cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn +/878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF +QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo +YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo +2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A +cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA +AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A +hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 +5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA +AABJRU5ErkJggg==but as soon as I continue writing in the text area, Table2 is highlighted again! + + + + + 2. Expected behavior + If the focus in Navigator is on Headings, it should not jump to tables when I continue to edit text which is in a table. + + + + + Now I create a section + + + + + To make it appear differently, I make it a two column one. Right now, the focus in the editing window is HERE, but although “H Headings” is selected in the upper left corner of Navigator, the highlight jumps down to section 2! (Btw: when I tried to paste the screenshot below this text, it went to a completely different page, which is yet another bug in LO Writer, which is not subject of this bug report, but I keep note of it to report it in another bug report soon). In order to paste my picture where I want it to appear, I rearranged my text into a table and pasted the picture to a cell below. Strangely, this picture goes to the next page in this section!) + + + + + + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz +UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA +AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 +AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ +BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 +cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn +/878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF +QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo +YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo +2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A +cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA +AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A +hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 +5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA +AABJRU5ErkJggg== + + + + + 3. Expected Behavior + 1. Since “H Headings” is highlighted, I would expect this one highlighted: + + + + + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz +UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA +AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 +AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ +BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 +cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn +/878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF +QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo +YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo +2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A +cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA +AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A +hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 +5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA +AABJRU5ErkJggg==However, whatever I do, as soon as I continue editing, Table3 is highlighted again in the editor window. + + + + + 2. I would have expected the column to continue on the last page (which again is another quirk which I’ll report in another bug report). + + + + + 3. When editing this part, LibreOffice Writer started flickering (a phenomemon which I also observed earlier but for which I was missing reproducible examples – and of course, this bug is not subject of this report, but I note it in order to use this file for a demonstration. + + + + + + + + diff --git a/sw/qa/core/layout/data/page-remove-fly-table.odt b/sw/qa/core/layout/data/page-remove-fly-table.odt new file mode 100644 index 0000000000..6aaf230966 Binary files /dev/null and b/sw/qa/core/layout/data/page-remove-fly-table.odt differ diff --git a/sw/qa/core/layout/data/para-border-in-cell-clip.docx b/sw/qa/core/layout/data/para-border-in-cell-clip.docx new file mode 100644 index 0000000000..7c51685364 Binary files /dev/null and b/sw/qa/core/layout/data/para-border-in-cell-clip.docx differ diff --git a/sw/qa/core/layout/data/rtl-table.docx b/sw/qa/core/layout/data/rtl-table.docx new file mode 100644 index 0000000000..a329229699 Binary files /dev/null and b/sw/qa/core/layout/data/rtl-table.docx differ diff --git a/sw/qa/core/layout/data/shape-textbox.odt b/sw/qa/core/layout/data/shape-textbox.odt new file mode 100644 index 0000000000..15b0aa48df Binary files /dev/null and b/sw/qa/core/layout/data/shape-textbox.odt differ diff --git a/sw/qa/core/layout/data/sorted-objs-insert.docx b/sw/qa/core/layout/data/sorted-objs-insert.docx new file mode 100644 index 0000000000..4041ab9868 Binary files /dev/null and b/sw/qa/core/layout/data/sorted-objs-insert.docx differ diff --git a/sw/qa/core/layout/data/split-table-border.odt b/sw/qa/core/layout/data/split-table-border.odt new file mode 100644 index 0000000000..743d54bd38 Binary files /dev/null and b/sw/qa/core/layout/data/split-table-border.odt differ diff --git a/sw/qa/core/layout/data/split-table-merged-border.odt b/sw/qa/core/layout/data/split-table-merged-border.odt new file mode 100644 index 0000000000..122bfd473c Binary files /dev/null and b/sw/qa/core/layout/data/split-table-merged-border.odt differ diff --git a/sw/qa/core/layout/data/table-fly-overlap-spacing.docx b/sw/qa/core/layout/data/table-fly-overlap-spacing.docx new file mode 100644 index 0000000000..1791bbee6d Binary files /dev/null and b/sw/qa/core/layout/data/table-fly-overlap-spacing.docx differ diff --git a/sw/qa/core/layout/data/table-fly-overlap.docx b/sw/qa/core/layout/data/table-fly-overlap.docx new file mode 100644 index 0000000000..a819e855b2 Binary files /dev/null and b/sw/qa/core/layout/data/table-fly-overlap.docx differ diff --git a/sw/qa/core/layout/data/table-in-footnote.docx b/sw/qa/core/layout/data/table-in-footnote.docx new file mode 100644 index 0000000000..10e20ffbf4 Binary files /dev/null and b/sw/qa/core/layout/data/table-in-footnote.docx differ diff --git a/sw/qa/core/layout/data/table-missing-join.docx b/sw/qa/core/layout/data/table-missing-join.docx new file mode 100644 index 0000000000..1fabb9e5b2 Binary files /dev/null and b/sw/qa/core/layout/data/table-missing-join.docx differ diff --git a/sw/qa/core/layout/data/table-print-area-left.docx b/sw/qa/core/layout/data/table-print-area-left.docx new file mode 100644 index 0000000000..e326bed82f Binary files /dev/null and b/sw/qa/core/layout/data/table-print-area-left.docx differ diff --git a/sw/qa/core/layout/data/tables-move-backwards.odt b/sw/qa/core/layout/data/tables-move-backwards.odt new file mode 100644 index 0000000000..861dc4f4ad Binary files /dev/null and b/sw/qa/core/layout/data/tables-move-backwards.odt differ diff --git a/sw/qa/core/layout/data/tdf122894-4.doc b/sw/qa/core/layout/data/tdf122894-4.doc new file mode 100644 index 0000000000..2fe41c9ad1 Binary files /dev/null and b/sw/qa/core/layout/data/tdf122894-4.doc differ diff --git a/sw/qa/core/layout/data/tdf128195.docx b/sw/qa/core/layout/data/tdf128195.docx new file mode 100644 index 0000000000..16180654ce Binary files /dev/null and b/sw/qa/core/layout/data/tdf128195.docx differ diff --git a/sw/qa/core/layout/data/tdf134783_testAnchorPositionBasedOnParagraph.fodt b/sw/qa/core/layout/data/tdf134783_testAnchorPositionBasedOnParagraph.fodt new file mode 100644 index 0000000000..aa5cc77126 --- /dev/null +++ b/sw/qa/core/layout/data/tdf134783_testAnchorPositionBasedOnParagraph.fodt @@ -0,0 +1,284 @@ + + + + 2020-07-14T15:50:45.951000000PT1M19S1LibreOfficeDev/7.1.0.0.alpha0$Windows_X86_64 LibreOffice_project/e8ffd954ee590d1f382685ceae12a51387919fb8 + + + 0 + 0 + 37837 + 23232 + true + false + + + view2 + 10911 + 6713 + 0 + 0 + 37835 + 23230 + 0 + 1 + false + 100 + false + false + + + + + false + + + + 1 + true + false + false + true + false + false + true + true + + + true + false + false + 0 + true + false + true + false + false + 0 + false + true + false + false + false + false + high-resolution + false + false + true + false + false + false + false + false + true + false + true + false + + false + false + false + true + false + 2065661 + false + false + false + false + false + 2065661 + false + true + false + true + true + false + false + false + true + true + false + true + false + false + false + false + true + false + false + false + false + false + false + 0 + true + false + true + true + true + false + true + false + false + true + false + false + true + + false + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A1 + + + A2 + + + A3 + + + B1 + + + diff --git a/sw/qa/core/layout/data/tdf157096.docx b/sw/qa/core/layout/data/tdf157096.docx new file mode 100644 index 0000000000..bca591e8ad Binary files /dev/null and b/sw/qa/core/layout/data/tdf157096.docx differ diff --git a/sw/qa/core/layout/data/tdf45908_invoice.odt b/sw/qa/core/layout/data/tdf45908_invoice.odt new file mode 100644 index 0000000000..41ff78d34d Binary files /dev/null and b/sw/qa/core/layout/data/tdf45908_invoice.odt differ diff --git a/sw/qa/core/layout/data/textbox-autogrow-vertical.docx b/sw/qa/core/layout/data/textbox-autogrow-vertical.docx new file mode 100644 index 0000000000..0cc45a781c Binary files /dev/null and b/sw/qa/core/layout/data/textbox-autogrow-vertical.docx differ diff --git a/sw/qa/core/layout/data/textbox-modification.docx b/sw/qa/core/layout/data/textbox-modification.docx new file mode 100644 index 0000000000..6adf1a950e Binary files /dev/null and b/sw/qa/core/layout/data/textbox-modification.docx differ diff --git a/sw/qa/core/layout/data/textbox-phantom-change.docx b/sw/qa/core/layout/data/textbox-phantom-change.docx new file mode 100644 index 0000000000..75ac039561 Binary files /dev/null and b/sw/qa/core/layout/data/textbox-phantom-change.docx differ diff --git a/sw/qa/core/layout/data/vmerge-cell-border.docx b/sw/qa/core/layout/data/vmerge-cell-border.docx new file mode 100644 index 0000000000..11d7a76d22 Binary files /dev/null and b/sw/qa/core/layout/data/vmerge-cell-border.docx differ diff --git a/sw/qa/core/layout/fly.cxx b/sw/qa/core/layout/fly.cxx new file mode 100644 index 0000000000..47cfb40fa6 --- /dev/null +++ b/sw/qa/core/layout/fly.cxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +/// Covers sw/source/core/layout/fly.cxx fixes, i.e. mostly SwFlyFrame. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNegativeHeight) +{ + // Given a document with complex enough content that a split fly frame temporarily moves below + // the bottom of the body frame on a page: + // When laying out the document, SwEditShell::CalcLayout() never returned: + createSwDoc("floattable-negative-height.docx"); + + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->Reformat(); + + // Make sure that all the pages have the expected content: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + for (SwFrame* pFrame = pLayout->Lower(); pFrame; pFrame = pFrame->GetNext()) + { + auto pPage = pFrame->DynCastPageFrame(); + if (!pPage->GetPrev()) + { + // First page: start of the split fly chain: + CPPUNIT_ASSERT(pPage->GetSortedObjs()); + SwSortedObjs& rPageObjs = *pPage->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size()); + auto pFly = rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pFly); + CPPUNIT_ASSERT(!pFly->GetPrecede()); + CPPUNIT_ASSERT(pFly->GetFollow()); + } + else if (pPage->GetPrev() && pPage->GetNext() && pPage->GetNext()->GetNext()) + { + // Middle pages: have a previous and a next fly: + CPPUNIT_ASSERT(pPage->GetSortedObjs()); + SwSortedObjs& rPageObjs = *pPage->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size()); + auto pFly = rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pFly); + CPPUNIT_ASSERT(pFly->GetPrecede()); + CPPUNIT_ASSERT(pFly->GetFollow()); + } + else if (pPage->GetPrev() && pPage->GetNext() && !pPage->GetNext()->GetNext()) + { + // Page last but one: end of the fly chain: + CPPUNIT_ASSERT(pPage->GetSortedObjs()); + SwSortedObjs& rPageObjs = *pPage->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size()); + auto pFly = rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pFly); + CPPUNIT_ASSERT(pFly->GetPrecede()); + CPPUNIT_ASSERT(!pFly->GetFollow()); + } + else if (pPage->GetPrev() && !pPage->GetNext()) + { + // Last page: no flys. + CPPUNIT_ASSERT(!pPage->GetSortedObjs()); + } + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx new file mode 100644 index 0000000000..455012ea49 --- /dev/null +++ b/sw/qa/core/layout/flycnt.cxx @@ -0,0 +1,1275 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +/// Covers sw/source/core/layout/flycnt.cxx fixes, i.e. mostly SwFlyAtContentFrame. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } + + /// Creates a document with a multi-page floating table: 1 columns and 2 rows. + void Create1x2SplitFly(); +}; + +void Test::Create1x2SplitFly() +{ + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + SwPageDesc aStandard(pDoc->GetPageDesc(0)); + SwFormatFrameSize aPageSize(aStandard.GetMaster().GetFrameSize()); + // 10 cm for the page height, 2cm are the top and bottom margins, so 6cm remains for the body + // frame: + aPageSize.SetHeight(5669); + aStandard.GetMaster().SetFormatAttr(aPageSize); + pDoc->ChgPageDesc(0, aStandard); + // Insert a table: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0); + pWrtShell->InsertTable(aTableOptions, /*nRows=*/2, /*nCols=*/1); + pWrtShell->MoveTable(GotoPrevTable, fnTableStart); + pWrtShell->GoPrevCell(); + pWrtShell->Insert("A1"); + SwFormatFrameSize aRowSize(SwFrameSize::Minimum); + // 4 cm, so 2 rows don't fit 1 page. + aRowSize.SetHeight(2267); + pWrtShell->SetRowHeight(aRowSize); + pWrtShell->GoNextCell(); + pWrtShell->Insert("A2"); + pWrtShell->SetRowHeight(aRowSize); + // Select cell: + pWrtShell->SelAll(); + // Select table: + pWrtShell->SelAll(); + // Wrap the table in a text frame: + SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr); + pWrtShell->StartAllAction(); + aMgr.InsertFlyFrame(RndStdIds::FLY_AT_PARA, aMgr.GetPos(), aMgr.GetSize()); + pWrtShell->EndAllAction(); + // Allow the text frame to split: + pWrtShell->StartAllAction(); + auto& rFlys = *pDoc->GetSpzFrameFormats(); + auto pFly = rFlys[0]; + SwAttrSet aSet(pFly->GetAttrSet()); + aSet.Put(SwFormatFlySplit(true)); + pDoc->SetAttr(aSet, *pFly); + pWrtShell->EndAllAction(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + // We have 2 pages: + CPPUNIT_ASSERT(pPage1->GetNext()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWithTable) +{ + // Given a document with a multi-page floating table: + createSwDoc("floattable.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the first row goes to page 1 and the second row goes to page 2, while the + // table is floating: + SwDoc* pDoc = getSwDoc(); + // Without the accompanying fix in place, this test would have failed with a stack overflow + // because the follow frame of the anchor was moved into the follow frame of the fly, so the fly + // was anchored in itself. + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + // Page 1 has a master fly, which contains a master table: + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + CPPUNIT_ASSERT(!pPage1Fly->GetPrecede()); + CPPUNIT_ASSERT(pPage1Fly->GetFollow()); + auto pPage1Table = dynamic_cast(pPage1Fly->GetLower()); + CPPUNIT_ASSERT(pPage1Table); + CPPUNIT_ASSERT(!pPage1Table->GetPrecede()); + CPPUNIT_ASSERT(pPage1Table->GetFollow()); + // Page 2 has a follow fly, which contains a follow table: + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + CPPUNIT_ASSERT(pPage2Fly->GetPrecede()); + CPPUNIT_ASSERT(!pPage2Fly->GetFollow()); + auto pPage2Table = dynamic_cast(pPage2Fly->GetLower()); + CPPUNIT_ASSERT(pPage2Table); + CPPUNIT_ASSERT(pPage2Table->GetPrecede()); + CPPUNIT_ASSERT(!pPage2Table->GetFollow()); + // Page 1 anchor has no text: + auto pPage1Anchor = dynamic_cast(pPage1->FindLastBodyContent()); + CPPUNIT_ASSERT(pPage1Anchor); + // This failed, page 1 anchor had unexpected, leftover text. + CPPUNIT_ASSERT(!pPage1Anchor->HasPara()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyVertOffset) +{ + // Given a document with a floattable, split on 2 pages and a positive vertical offset: + createSwDoc("floattable-vertoffset.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the vert offset has an effect on the master fly, but not on follow flys: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + auto pPage1Anchor = dynamic_cast(pPage1->FindLastBodyContent()); + CPPUNIT_ASSERT(pPage1Anchor); + SwTwips nPage1AnchorTop = pPage1Anchor->getFrameArea().Top(); + SwTwips nPage1FlyTop = pPage1Fly->getFrameArea().Top(); + // First page, the vert offset should be there. This comes from word/document.xml: + // + CPPUNIT_ASSERT_EQUAL(static_cast(1135), nPage1FlyTop - nPage1AnchorTop); + + // Also verify that the 2nd page has no such offset: + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + auto pPage2Anchor = dynamic_cast(pPage2->FindLastBodyContent()); + CPPUNIT_ASSERT(pPage2Anchor); + SwTwips nPage2AnchorTop = pPage2Anchor->getFrameArea().Top(); + SwTwips nPage2FlyTop = pPage2Fly->getFrameArea().Top(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 1135 + // i.e. the fly frame on the 2nd page was also shifted down in Writer, but not in Word. + CPPUNIT_ASSERT_EQUAL(static_cast(0), nPage2FlyTop - nPage2AnchorTop); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFly3Pages) +{ + // Given a document with a floattable, split on 3 pages: + createSwDoc("floattable-3pages.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that row 1, 2 & 3 go to page 1, 2 & 3, while the table is floating: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + auto pPage1Anchor = dynamic_cast(pPage1->FindLastBodyContent()); + CPPUNIT_ASSERT(pPage1Anchor); + SwTwips nPage1AnchorTop = pPage1Anchor->getFrameArea().Top(); + SwTwips nPage1FlyTop = pPage1Fly->getFrameArea().Top(); + // The vert offset should be there on the first page: + CPPUNIT_ASSERT_EQUAL(static_cast(1135), nPage1FlyTop - nPage1AnchorTop); + // Second page: + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 2 + // i.e. both the 2nd and 3rd fly was anchored on page 2. + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + auto pPage2Anchor = dynamic_cast(pPage2->FindLastBodyContent()); + CPPUNIT_ASSERT(pPage2Anchor); + SwTwips nPage2AnchorTop = pPage2Anchor->getFrameArea().Top(); + SwTwips nPage2FlyTop = pPage2Fly->getFrameArea().Top(); + // No vert offset on the second page: + CPPUNIT_ASSERT_EQUAL(static_cast(0), nPage2FlyTop - nPage2AnchorTop); + // 3rd page: + auto pPage3 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage3); + const SwSortedObjs& rPage3Objs = *pPage3->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage3Objs.size()); + auto pPage3Fly = dynamic_cast(rPage3Objs[0]); + CPPUNIT_ASSERT(pPage3Fly); + auto pPage3Anchor = dynamic_cast(pPage3->FindLastBodyContent()); + CPPUNIT_ASSERT(pPage3Anchor); + SwTwips nPage3AnchorTop = pPage3Anchor->getFrameArea().Top(); + SwTwips nPage3FlyTop = pPage3Fly->getFrameArea().Top(); + // No vert offset on the 3rd page: + CPPUNIT_ASSERT_EQUAL(static_cast(0), nPage3FlyTop - nPage3AnchorTop); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyRow) +{ + // Given a document with a floattable, single row split on 2 pages: + createSwDoc("floattable-rowsplit.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the single row is split to 2 pages, and the fly frames have the correct + // coordinates: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + auto pPage1Anchor = dynamic_cast(pPage1->FindLastBodyContent()); + CPPUNIT_ASSERT(pPage1Anchor); + // ~No offset between the fly and its anchor: + SwTwips nPage1AnchorTop = pPage1Anchor->getFrameArea().Top(); + SwTwips nPage1FlyTop = pPage1Fly->getFrameArea().Top(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), nPage1FlyTop - nPage1AnchorTop); + // Second page: + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + auto pPage2Anchor = dynamic_cast(pPage2->FindLastBodyContent()); + CPPUNIT_ASSERT(pPage2Anchor); + // No offset between the fly and its anchor: + SwTwips nPage2AnchorTop = pPage2Anchor->getFrameArea().Top(); + SwTwips nPage2FlyTop = pPage2Fly->getFrameArea().Top(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : -1440 + // i.e. the 2nd page's fly had a wrong position. + CPPUNIT_ASSERT_EQUAL(static_cast(0), nPage2FlyTop - nPage2AnchorTop); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyEnable) +{ + // Given a document with a table in a textframe: + Create1x2SplitFly(); + + // Then make sure that the layout is updated and we have 2 pages: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + // Without the accompanying fix in place, this test would have failed, there was no 2nd page. + CPPUNIT_ASSERT(pPage2); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyDisable) +{ + // Given a document with a floating table, table split on 2 pages: + Create1x2SplitFly(); + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(pPage1->GetNext()); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + CPPUNIT_ASSERT(pPage1Fly->GetFollow()); + + // When turning the "split fly" checkbox off: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->StartAllAction(); + auto& rFlys = *pDoc->GetSpzFrameFormats(); + auto pFly = rFlys[0]; + SwAttrSet aSet(pFly->GetAttrSet()); + // Note how the UI puts a SwFormatFrameSize into this item set with a slightly different size + // (e.g. 3823 twips width -> 3821). This means that by accident the UI works even without the + // explicit RES_FLY_SPLIT handling in SwFlyFrame::UpdateAttr_(), but this test will fail when + // that is missing. + aSet.Put(SwFormatFlySplit(false)); + pDoc->SetAttr(aSet, *pFly); + pWrtShell->EndAllAction(); + + // Then make sure the extra page and follow fly frame is joined: + CPPUNIT_ASSERT(!pPage1->GetNext()); + // Without the accompanying fix in place, this test would have failed, the follow fly frame was + // moved to page 1, but it wasn't deleted. + CPPUNIT_ASSERT(!pPage1Fly->GetFollow()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyFooter) +{ + // Given a document with a floattable, table split on 2 pages with headers/footers: + createSwDoc("floattable-footer.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the table is split to 2 pages: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + SwTwips nPage1Top = pPage1->getFrameArea().Top(); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + SwTwips nPage1FlyTop = pPage1Fly->getFrameArea().Top(); + // from the bugdoc. + CPPUNIT_ASSERT_EQUAL(static_cast(3286), nPage1FlyTop - nPage1Top); + // Second page: + auto pPage2 = dynamic_cast(pPage1->GetNext()); + // Without the accompanying fix in place, this test would have failed, there was no 2nd page. + CPPUNIT_ASSERT(pPage2); + SwTwips nPage2Top = pPage2->getFrameArea().Top(); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + SwTwips nPage2FlyTop = pPage2Fly->getFrameArea().Top(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1440 + // - Actual : 0 + // i.e. from the bugdoc was lost, the follow fly had no vertical offset. + CPPUNIT_ASSERT_EQUAL(static_cast(1440), nPage2FlyTop - nPage2Top); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyFooter2Rows) +{ + // Given a document with a 2nd page that contains the second half of a split row + a last row: + createSwDoc("floattable-footer-2rows.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the table is split to 2 pages: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + // Without the accompanying fix in place, this test would have failed. The 2nd page only had the + // 2nd half of the split row and the last row went to a 3rd page. + CPPUNIT_ASSERT(!pPage2->GetNext()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFly2Cols) +{ + // Given a document with a 2nd page that contains the second half of a split row and 2 columns: + createSwDoc("floattable-2cols.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the table is split to 2 pages: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + // Without the accompanying fix in place, this test would have failed. The 2nd page only had the + // 2nd half of the split row and the very last row went to a 3rd page. + CPPUNIT_ASSERT(!pPage2->GetNext()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWidow) +{ + // Given a document with a 2nd page that contains 2 lines, due to widow control: + createSwDoc("floattable-widow.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that widow control works: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + SwFrame* pTab1 = pPage1Fly->GetLower(); + SwFrame* pRow1 = pTab1->GetLower(); + SwFrame* pCell1 = pRow1->GetLower(); + auto pText1 = dynamic_cast(pCell1->GetLower()); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 6 + // - Actual : 7 + // i.e. widow control was disabled, layout didn't match Word. + CPPUNIT_ASSERT_EQUAL(static_cast(6), pText1->GetThisLines()); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + SwFrame* pTab2 = pPage2Fly->GetLower(); + SwFrame* pRow2 = pTab2->GetLower(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1014 + // - Actual : 553 + // i.e. from the file was ignored. + CPPUNIT_ASSERT_EQUAL(static_cast(1014), pRow2->getFrameArea().Height()); + SwFrame* pCell2 = pRow2->GetLower(); + auto pText2 = dynamic_cast(pCell2->GetLower()); + // And then similarly this was 1, not 2. + CPPUNIT_ASSERT_EQUAL(static_cast(2), pText2->GetThisLines()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyCompat14) +{ + // Given a Word 2010 document with 2 pages, one table row each: + createSwDoc("floattable-compat14.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the first row is entirely on page 1: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + SwFrame* pTab1 = pPage1Fly->GetLower(); + SwFrame* pRow1 = pTab1->GetLower(); + auto pCell1 = dynamic_cast(pRow1->GetLower()); + // Without the accompanying fix in place, this test would have failed, the first row was split, + // but not in Word. + CPPUNIT_ASSERT(!pCell1->GetFollowCell()); + // Also make sure that the second row is entirely on page 2: + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + SwFrame* pTab2 = pPage2Fly->GetLower(); + SwFrame* pRow2 = pTab2->GetLower(); + auto pCell2 = dynamic_cast(pRow2->GetLower()); + // Without the accompanying fix in place, this test would have failed, the second row was split, + // but not in Word. + CPPUNIT_ASSERT(!pCell2->GetPreviousCell()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyCompat14Nosplit) +{ + // Given a Word 2010 document with 2 pages, 2 rows on page 1, 1 row on page 2: + createSwDoc("floattable-compat14-nosplit.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the last row is on a separate page: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + SwFrame* pTab1 = pPage1Fly->GetLower(); + SwFrame* pRow1 = pTab1->GetLower(); + CPPUNIT_ASSERT(pRow1->GetNext()); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + // Without the accompanying fix in place, this test would have failed, all rows were on page 1. + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + SwFrame* pTab2 = pPage2Fly->GetLower(); + SwFrame* pRow2 = pTab2->GetLower(); + CPPUNIT_ASSERT(!pRow2->GetNext()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyCompat14Body) +{ + // Given a Word 2010 document with 2 pages, 1 row on page 1, 1 row on page 2: + createSwDoc("floattable-compat14-body.docx"); + + // When laying out that document: + // (This is legacy mode, but still Word doesn't split row 2 because 1) row 2 has a minimal + // height, so even the first part of row 2 would not fit the body frame and 2) Word allows using + // the bottom margin area in legacy mode, but only in case the fly height <= body height.) + calcLayout(); + + // Then make sure that the second row is on a page 2: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + SwFrame* pTab1 = pPage1Fly->GetLower(); + SwFrame* pRow1 = pTab1->GetLower(); + // Without the accompanying fix in place, this test would have failed, part of row 2 was on page + // 1. + CPPUNIT_ASSERT(!pRow1->GetNext()); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + SwFrame* pTab2 = pPage2Fly->GetLower(); + SwFrame* pRow2 = pTab2->GetLower(); + CPPUNIT_ASSERT(!pRow2->GetNext()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyFollowHorizontalPosition) +{ + // Given a document with 2 pages, master fly on page 1, follow fly on page 2: + createSwDoc("floattable-hori-pos.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the follow fly doesn't have a different horizontal position: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + tools::Long nPage1FlyLeft = pPage1Fly->getFrameArea().Left(); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + tools::Long nPage2FlyLeft = pPage2Fly->getFrameArea().Left(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 5528 + // - Actual : 284 + // i.e. the follow fly was pushed towards the left, instead of having the same position as the + // master fly. + CPPUNIT_ASSERT_EQUAL(nPage1FlyLeft, nPage2FlyLeft); +} + +CPPUNIT_TEST_FIXTURE(Test, testCursorTraversal) +{ + // Given a document with a multi-page floating table: + Create1x2SplitFly(); + + // When going from A1 to A2: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->GotoTable("Table1"); + SwTextNode* pTextNode = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); + CPPUNIT_ASSERT_EQUAL(OUString("A1"), pTextNode->GetText()); + pWrtShell->Down(/*bSelect=*/false); + + // Then make sure we get to A2 and don't stay in A1: + pTextNode = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: A2 + // - Actual : A1 + // i.e. the cursor didn't get from A1 to A2. + CPPUNIT_ASSERT_EQUAL(OUString("A2"), pTextNode->GetText()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyRowDelete) +{ + // Given a document with a multi-page floating table: + Create1x2SplitFly(); + + // When deleting the row of A2: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->GotoTable("Table1"); + pWrtShell->Down(/*bSelect=*/false); + SwTextNode* pTextNode = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); + // We delete the right row: + CPPUNIT_ASSERT_EQUAL(OUString("A2"), pTextNode->GetText()); + pWrtShell->DeleteRow(); + + // Then make sure we only have 1 page: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(!pPage1->GetNext()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFly1stRowDelete) +{ + // Given a document with a multi-page floating table: + Create1x2SplitFly(); + + // When deleting the row of A1: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->GotoTable("Table1"); + SwTextNode* pTextNode = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); + // We delete the right row: + CPPUNIT_ASSERT_EQUAL(OUString("A1"), pTextNode->GetText()); + pWrtShell->DeleteRow(); + + // Then make sure we only have 1 page: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + // Without the accompanying fix in place, this test would have failed, the follow fly was still + // on page 2. + CPPUNIT_ASSERT(!pPage1->GetNext()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFly3rdRowDelete) +{ + // Given a document with a floattable, split on 3 pages: + createSwDoc("floattable-3pages.docx"); + + // When deleting the row of A3: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->GotoTable("Table1"); + pWrtShell->Down(/*bSelect=*/false); + pWrtShell->Down(/*bSelect=*/false); + SwTextNode* pTextNode = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); + // We delete the right row: + CPPUNIT_ASSERT_EQUAL(OUString("A3"), pTextNode->GetText()); + pWrtShell->DeleteRow(); + + // Then make sure we only have 2 pages: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + // Without the accompanying fix in place, this test would have failed, page 3 was not deleted. + CPPUNIT_ASSERT(!pPage2->GetNext()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFly2ndRowSelect) +{ + // Given a document with a multi-page floating table: + createSwDoc("floattable.docx"); + + // When selecting the second row: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + auto pPage2Fly = dynamic_cast(rPage2Objs[0]); + const SwRect& aFollowArea = pPage2Fly->getFrameArea(); + Point aTopCenter((aFollowArea.Left() + aFollowArea.Right()) / 2, aFollowArea.Top()); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->SelectObj(aTopCenter); + + // Then make sure the first row is selected: + const SdrMarkList& rMarkList = pWrtShell->GetDrawView()->GetMarkedObjectList(); + SdrObject* pSelectedObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + auto pSelectedVirtObj = dynamic_cast(pSelectedObj); + auto pSelected = static_cast(pSelectedVirtObj->GetFlyFrame()); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 5 + // - Actual : 17 + // i.e. a follow fly was possible to select (instead of its master) + CPPUNIT_ASSERT_EQUAL(pPage2Fly->GetPrecede()->GetFrameId(), pSelected->GetFrameId()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInSection) +{ + // This crashed, the layout assumed that the floating table is directly under the body frame. + createSwDoc("floattable-in-section.docx"); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyThenTable) +{ + // Given a document with a 2 page floating table, followed by an other table: + // Intentionally load the document as hidden to avoid layout during load (see TestTdf150616): + uno::Sequence aFilterOptions = { + comphelper::makePropertyValue("Hidden", true), + }; + mxComponent = loadFromDesktop(m_directories.getURLFromSrc(u"/sw/qa/core/layout/data/") + + "floattable-then-table.docx", + "com.sun.star.text.TextDocument", aFilterOptions); + + // When layout is calculated during PDF export: + // Then make sure that finishes without errors: + // This crashed, due to a stack overflow in layout code. + save("writer_pdf_Export"); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInTextSection) +{ + // The document contains a DOCX cont sect break, which is mapped to a TextSection. + // This crashed, the anchor was split directly, so the follow anchor was moved outside the + // section frame, which is broken. + createSwDoc("floattable-in-text-section.docx"); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyTableRowKeep) +{ + // Given a document with a floating table, 2.5 rows on the first page: + createSwDoc("floattable-table-row-keep.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the expected amount of rows is on the first page: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + SwFrame* pTab1 = pPage1Fly->GetLower(); + SwFrame* pRow1 = pTab1->GetLower(); + CPPUNIT_ASSERT(pRow1); + SwFrame* pRow2 = pRow1->GetNext(); + // Without the accompanying fix in place, this test would have failed, the table on the first + // page only had 1 row, due to TableRowKeep kicking in for floating tables, which is incorrect. + CPPUNIT_ASSERT(pRow2); + SwFrame* pRow3 = pRow2->GetNext(); + CPPUNIT_ASSERT(pRow3); + auto pCell3 = dynamic_cast(pRow3->GetLower()); + CPPUNIT_ASSERT(pCell3->GetFollowCell()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyDeletedAnchor) +{ + // Given a document with a floating table that spans over 3 pages: + createSwDoc("floattable-deleted-anchor.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that there are 3 anchors for the 3 pages: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + SwFrame* pBody1 = pPage1->GetLower(); + CPPUNIT_ASSERT(pBody1); + auto pAnchor1 = dynamic_cast(pBody1->GetLower()->GetNext()); + CPPUNIT_ASSERT(pAnchor1); + SwTextFrame* pAnchor2 = pAnchor1->GetFollow(); + CPPUNIT_ASSERT(pAnchor2); + SwTextFrame* pAnchor3 = pAnchor2->GetFollow(); + // Without the accompanying fix in place, this test would have failed, the fly frame on the 3rd + // page was anchored to a text frame on the 2nd page, leading to a negative frame height. + CPPUNIT_ASSERT(pAnchor3); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyMultiCol) +{ + // Given a document with a floating table that is in a multi-col section: + createSwDoc("floattable-multi-col.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the fly frame is not split, matching Word: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + // Without the accompanying fix in place, this test would have failed, we tried to split and + // then hit an assertion failure. + CPPUNIT_ASSERT(!pPage1Fly->GetFollow()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyTabJoin) +{ + // Given a document with 3 pages and 2 tables: table on first and second page, 3rd page has no + // table: + createSwDoc("floattable-tab-join.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that all pages have the expected amount of fly frames: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 2 + // i.e. the 2nd page had 2 fly frames, hosting a split table, instead of joining that table and + // having 1 fly frame. + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage3 = dynamic_cast(pPage2->GetNext()); + CPPUNIT_ASSERT(pPage3); + CPPUNIT_ASSERT(!pPage3->GetSortedObjs()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyTabJoinLegacy) +{ + // Given a document with 3 pages and 2 tables: table on first and second page, 3rd page has no + // table (Word 2010 mode): + createSwDoc("floattable-tab-join-legacy.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that all pages have the expected amount of fly frames: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 2 + // i.e. the 2nd page had 2 fly frames, hosting a split table, instead of joining that table and + // having 1 fly frame (even after the non-legacy case was fixed already). + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage3 = dynamic_cast(pPage2->GetNext()); + CPPUNIT_ASSERT(pPage3); + CPPUNIT_ASSERT(!pPage3->GetSortedObjs()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyObjectFormatter) +{ + // Given a document with 3 pages and 2 tables: table on first and second page, 3rd page has no + // table: + createSwDoc("floattable-object-formatter.docx"); + + // When calculating the layout: + calcLayout(); + + // Then make sure we don't crash and also that all pages have the expected amount of fly frames: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage3 = dynamic_cast(pPage2->GetNext()); + CPPUNIT_ASSERT(pPage3); + CPPUNIT_ASSERT(!pPage3->GetSortedObjs()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNextLeafInSection) +{ + // Given a document with 4 pages: page 1 had a floating table, page 2 & 3 had a second floating + // table and finally page 4 is empty: + createSwDoc("floattable-next-leaf-in-section.docx"); + + // When calculating the layout: + // Then this never returned, the loop in SwFrame::GetNextFlyLeaf() never finished. + calcLayout(); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyAnchorKeepWithNext) +{ + // Given a document with 2 pages, a split floating table on both pages: + createSwDoc("floattable-anchor-keep-with-next.docx"); + + // When calculating the layout: + calcLayout(); + + // Then make sure the pages have the expected amount of anchored objects: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + // Without the accompanying fix in place, this test would have failed, page 1 had no floating + // table, it was entirely on page 2. + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + CPPUNIT_ASSERT(pPage2->GetSortedObjs()); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNoFooterOverlap) +{ + // Given a document with 2 pages, a floating table on both pages: + createSwDoc("floattable-no-footer-overlap.doc"); + + // When calculating the layout: + calcLayout(); + + // Then make sure the second page has a floating table: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 2 + // i.e. part of the second table was on page 1. + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage2 = dynamic_cast(pPage1->GetNext()); + // Without the accompanying fix in place, this test would have failed, there was no page 2, both + // floating tables were on page 1. + CPPUNIT_ASSERT(pPage2); + CPPUNIT_ASSERT(pPage2->GetSortedObjs()); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyGrowFromBottom) +{ + // Given a document with a floating table that grows from the bottom: + createSwDoc("floattable-from-bottom.docx"); + + // When calculating the layout: + calcLayout(); + + // Then make sure that such a floating table is not split, matching Word: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + const auto pFly = dynamic_cast(rPage1Objs[0]); + // Without the accompanying fix in place, this test would have failed, we tried to split the fly + // frame on page 1 even when it would fit, and this lead to a crash on export later. + CPPUNIT_ASSERT(!pFly->GetFollow()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyIntoTable) +{ + // Given a document with a floating table, then an inline table on the next page: + createSwDoc("floattable-then-table.doc"); + + // When inserting a page break: + // Then make sure the layout doesn't crash: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->InsertPageBreak(); + // Without the accompanying fix in place, this test would have crashed, we tried to insert the + // second part of a floating table into a table on the next page, not before that table. + calcLayout(); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyFromAsCharAnchor) +{ + // Given a document with a footnote that has a table (imported in an as-char anchored frame in + // Writer): + createSwDoc("table-in-footnote.docx"); + + // When changing the anchor type of that frame to to-para: + // Then make sure we don't crash: + selectShape(1); + // Without the accompanying fix in place, this test would have crashed, we tried to split a + // frame+table inside a footnote. + dispatchCommand(mxComponent, ".uno:SetAnchorToPara", {}); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNested) +{ + // Given a document with a nested, multi-page floating table: + // When calculating the layout: + createSwDoc("floattable-nested.odt"); + calcLayout(); + + // Then make sure we don't crash: + // Without the accompanying fix in place, this test would have crashed. + // Check that we have exactly 4 fly frames, all of them on the expected pages: master outer, + // follow outer, master inner and follow inner. + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage1Objs.size()); + auto pPage1Fly1 = rPage1Objs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pPage1Fly1); + CPPUNIT_ASSERT(pPage1Fly1->GetAnchorFrameContainingAnchPos()->IsInFly()); + CPPUNIT_ASSERT(pPage1Fly1->GetFollow()); + auto pPage1Fly2 = rPage1Objs[1]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pPage1Fly2); + CPPUNIT_ASSERT(!pPage1Fly2->GetAnchorFrameContainingAnchPos()->IsInFly()); + CPPUNIT_ASSERT(pPage1Fly2->GetFollow()); + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + CPPUNIT_ASSERT(pPage2->GetSortedObjs()); + SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage2Objs.size()); + auto pPage2Fly1 = rPage2Objs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pPage2Fly1); + CPPUNIT_ASSERT(pPage2Fly1->GetAnchorFrameContainingAnchPos()->IsInFly()); + CPPUNIT_ASSERT(pPage2Fly1->GetPrecede()); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected greater than: 6204 + // - Actual : 1725 + // i.e. the inner follow fly had a bad position, it was outside the page rectangle, it was not + // rendered and this way the inner anchor had no fly portion, either. + CPPUNIT_ASSERT_GREATER(pPage2->getFrameArea().Top(), pPage2Fly1->getFrameArea().Top()); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected less than: 12523 + // - Actual : 15312 + // i.e. the inner follow fly was not "moved back" to its place to have the wanted 4400 position, + // which makes the "Inner A2" text visible. + CPPUNIT_ASSERT_LESS(pPage2->getFrameArea().Right(), pPage2Fly1->getFrameArea().Right()); + + auto pPage2Fly2 = rPage2Objs[1]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pPage2Fly2); + CPPUNIT_ASSERT(!pPage2Fly2->GetAnchorFrameContainingAnchPos()->IsInFly()); + CPPUNIT_ASSERT(pPage2Fly2->GetPrecede()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNestedOverlap) +{ + // Given a document with a nested, multi-page floating table, enabling the "don't overlap" logic: + // When calculating the layout: + createSwDoc("floattable-nested-overlap.odt"); + calcLayout(); + + // Then make sure we get 2 pages (2 flys on each page): + // Without the accompanying fix in place, this test would have failed with a layout loop. + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage1Objs.size()); + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + CPPUNIT_ASSERT(pPage2->GetSortedObjs()); + SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage2Objs.size()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyMoveMaster) +{ + // Given a document with a multi-page floating table on pages 1 -> 2 -> 3: + createSwDoc("floattable-move-master.docx"); + + // When adding an empty para at the start of the anchor text of the table: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->SttEndDoc(/*bStt=*/true); + pWrtShell->Down(/*bSelect=*/false, /*nCount=*/4); + pWrtShell->SplitNode(); + + // Then make sure page the fly chain is pages 1 -> 2 -> 3, still: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + // Without the accompanying fix in place, this test would have failed, the fly chain was pages 1 + // -> 4 -> 2. + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage1Fly = rPage1Objs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pPage1Fly); + CPPUNIT_ASSERT(!pPage1Fly->GetPrecede()); + CPPUNIT_ASSERT(pPage1Fly->HasFollow()); + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + CPPUNIT_ASSERT(pPage2->GetSortedObjs()); + SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage2Fly = rPage2Objs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pPage2Fly); + CPPUNIT_ASSERT(pPage2Fly->GetPrecede()); + CPPUNIT_ASSERT(pPage2Fly->HasFollow()); + auto pPage3 = pPage2->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage3); + CPPUNIT_ASSERT(pPage3->GetSortedObjs()); + SwSortedObjs& rPage3Objs = *pPage3->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage3Objs.size()); + auto pPage3Fly = rPage3Objs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pPage3Fly); + CPPUNIT_ASSERT(pPage3Fly->GetPrecede()); + CPPUNIT_ASSERT(!pPage3Fly->GetFollow()); + auto pPage4 = pPage3->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage4); + CPPUNIT_ASSERT(!pPage4->GetSortedObjs()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyDelEmpty) +{ + // Given a document with multiple floating tables and 7 pages: + // When loading that document: + // Without the accompanying fix in place, this test would have crashed due to a + // heap-use-after-free problem (visible with e.g. MALLOC_PERTURB_=153). + createSwDoc("floattable-del-empty.docx"); + + // Then make sure that the page count matches Word: + CPPUNIT_ASSERT_EQUAL(7, getPages()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInTableInSection) +{ + // Given a document where page 2 and page 3 has a floating table inside an inline table, inside + // a section: + // Without the accompanying fix in place, this test would have crashed, we created a follow + // anchor which was marked as "in table", but had no table parent. + createSwDoc("floattable-in-inltbl-in-sect.docx"); + + // Then make sure that the floating table is on page 2 and page 3: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(!pPage1->GetSortedObjs()); + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + CPPUNIT_ASSERT(pPage2->GetSortedObjs()); + SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); + auto pPage3 = pPage2->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage3); + CPPUNIT_ASSERT(pPage3->GetSortedObjs()); + SwSortedObjs& rPage3Objs = *pPage3->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage3Objs.size()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWrapOnAllPages) +{ + // Given a document where we want to wrap on all pages, around a split floating table: + createSwDoc("floattable-wrap-on-all-pages.docx"); + SwDoc* pDoc = getSwDoc(); + pDoc->getIDocumentSettingAccess().set(DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK, + true); + + // When formatting that document: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->Reformat(); + + // Then make sure that the anchor text is also split between page 1 and page 2: + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + auto pPage1Anchor = pPage1->FindLastBodyContent()->DynCastTextFrame(); + CPPUNIT_ASSERT(pPage1Anchor); + OUString aAnchor1Text(pPage1Anchor->GetText().subView( + static_cast(pPage1Anchor->GetOffset()), + static_cast(pPage1Anchor->GetFollow()->GetOffset() + - pPage1Anchor->GetOffset()))); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: He heard quiet steps behind him. That + // - Actual : + // i.e. the first page had no anchor text, only the second. + CPPUNIT_ASSERT_EQUAL(OUString("He heard quiet steps behind him. That "), aAnchor1Text); + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + auto pPage2Anchor = pPage2->FindLastBodyContent()->DynCastTextFrame(); + CPPUNIT_ASSERT(pPage2Anchor); + OUString aAnchor2Text( + pPage2Anchor->GetText().subView(static_cast(pPage2Anchor->GetOffset()))); + CPPUNIT_ASSERT(!pPage2Anchor->GetFollow()); + CPPUNIT_ASSERT_EQUAL(OUString("didn't bode well."), aAnchor2Text); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyPerFrameWrapOnAllPages) +{ + // Given a document where we want to wrap on all pages, around a split floating table: + createSwDoc("floattable-wrap-on-all-pages.docx"); + SwDoc* pDoc = getSwDoc(); + sw::SpzFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormat* pFly = rFlys[0]; + SfxItemSet aSet(pFly->GetAttrSet()); + SwFormatWrapTextAtFlyStart aItem(true); + aSet.Put(aItem); + pDoc->SetFlyFrameAttr(*pFly, aSet); + + // When formatting that document: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->Reformat(); + + // Then make sure that the anchor text is also split between page 1 and page 2: + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + auto pPage1Anchor = pPage1->FindLastBodyContent()->DynCastTextFrame(); + CPPUNIT_ASSERT(pPage1Anchor); + OUString aAnchor1Text(pPage1Anchor->GetText().subView( + static_cast(pPage1Anchor->GetOffset()), + static_cast(pPage1Anchor->GetFollow()->GetOffset() + - pPage1Anchor->GetOffset()))); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: He heard quiet steps behind him. That + // - Actual : + // i.e. the first page had no anchor text, only the second. + CPPUNIT_ASSERT_EQUAL(OUString("He heard quiet steps behind him. That "), aAnchor1Text); + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + auto pPage2Anchor = pPage2->FindLastBodyContent()->DynCastTextFrame(); + CPPUNIT_ASSERT(pPage2Anchor); + OUString aAnchor2Text( + pPage2Anchor->GetText().subView(static_cast(pPage2Anchor->GetOffset()))); + CPPUNIT_ASSERT(!pPage2Anchor->GetFollow()); + CPPUNIT_ASSERT_EQUAL(OUString("didn't bode well."), aAnchor2Text); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/frmtool.cxx b/sw/qa/core/layout/frmtool.cxx new file mode 100644 index 0000000000..2ee4c3a07d --- /dev/null +++ b/sw/qa/core/layout/frmtool.cxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include + +namespace +{ +/// Covers sw/source/core/layout/frmtool.cxx fixes. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testFloattableNoMargins) +{ + createSwDoc("floattable-nomargins.docx"); + + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(!pPage1->GetNext()); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/ftnfrm.cxx b/sw/qa/core/layout/ftnfrm.cxx new file mode 100644 index 0000000000..4c874202da --- /dev/null +++ b/sw/qa/core/layout/ftnfrm.cxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +/// Covers sw/source/core/layout/ftnfrm.cxx fixes. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testFlySplitFootnoteLayout) +{ + // Given a document with a split fly (to host a table): + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr); + RndStdIds eAnchor = RndStdIds::FLY_AT_PARA; + pWrtShell->StartAllAction(); + aMgr.InsertFlyFrame(eAnchor, aMgr.GetPos(), aMgr.GetSize()); + pWrtShell->EndAllAction(); + pWrtShell->StartAllAction(); + sw::FrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormat* pFly = rFlys[0]; + SwAttrSet aSet(pFly->GetAttrSet()); + aSet.Put(SwFormatFlySplit(true)); + pDoc->SetAttr(aSet, *pFly); + pWrtShell->EndAllAction(); + pWrtShell->UnSelectFrame(); + pWrtShell->LeaveSelFrameMode(); + pWrtShell->GetView().AttrChangedNotify(nullptr); + pWrtShell->MoveSection(GoCurrSection, fnSectionEnd); + + // When inserting a footnote: + pWrtShell->InsertFootnote(OUString()); + + // Then make sure the footnote frame and its container is created: + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage = dynamic_cast(pLayout->Lower()); + CPPUNIT_ASSERT(pPage); + // Without the accompanying fix in place, this test would have failed, the footnote frame was + // not created, the footnote reference was empty. + CPPUNIT_ASSERT(pPage->FindFootnoteCont()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/layact.cxx b/sw/qa/core/layout/layact.cxx new file mode 100644 index 0000000000..d432ae52b7 --- /dev/null +++ b/sw/qa/core/layout/layact.cxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +/// Covers sw/source/core/layout/layact.cxx fixes. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNextRowInvalidatePos) +{ + // Given a multi-page floating table, row1 is split, i.e. is both on page 1 and page 2: + createSwDoc("floattable-next-row-invalidate-pos.docx"); + // Make sure the follow anchor's IsCompletePaint() reaches its false state, as it happens in the + // interactive case. + Scheduler::ProcessEventsToIdle(); + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + CPPUNIT_ASSERT(pPage2->GetSortedObjs()); + SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + auto pFly2 = rPage2Objs[0]->DynCastFlyFrame(); + auto pTable2 = pFly2->GetLower()->DynCastTabFrame(); + auto pRow2 = pTable2->GetLastLower()->DynCastRowFrame(); + SwTwips nOldRow2Top = pRow2->getFrameArea().Top(); + + // When adding a new paragraph at the end of B1: + // Go to the table: A1 cell. + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->GotoTable("Table1"); + // Go to the column: B1 cell. + pWrtShell->GoNextCell(); + // Go to the end of the B1 cell, on page 2. + pWrtShell->EndOfSection(); + // Add a new paragraph at the cell end. + pWrtShell->SplitNode(); + + // Then make sure row 2 is shifted down: + SwTwips nNewRow2Top = pRow2->getFrameArea().Top(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected greater than: 7121 + // - Actual : 7121 + // i.e. row 2 has to be shifted down to 7390, but this didn't happen. + CPPUNIT_ASSERT_GREATER(nOldRow2Top, nNewRow2Top); +} + +CPPUNIT_TEST_FIXTURE(Test, testTdf157096) +{ + createSwDoc("tdf157096.docx"); + + CPPUNIT_ASSERT_EQUAL(2, getPages()); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + + // Without the fix in place, it would have crashed here + dispatchCommand(mxComponent, ".uno:Delete", {}); + + CPPUNIT_ASSERT_EQUAL(1, getPages()); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx new file mode 100644 index 0000000000..5971e87030 --- /dev/null +++ b/sw/qa/core/layout/layout.cxx @@ -0,0 +1,1052 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/// Covers sw/source/core/layout/ fixes. +class SwCoreLayoutTest : public SwModelTestBase +{ +public: + SwCoreLayoutTest() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTableFlyOverlap) +{ + // Load a document that has an image anchored in the header. + // It also has a table which has the wrap around the image. + createSwDoc("table-fly-overlap.docx"); + SwTwips nFlyTop + = parseDump("//header/txt/anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); + SwTwips nFlyHeight + = parseDump("//header/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32(); + SwTwips nFlyBottom = nFlyTop + nFlyHeight; + SwTwips nTableFrameTop = parseDump("//tab/infos/bounds"_ostr, "top"_ostr).toInt32(); + SwTwips nTablePrintTop = parseDump("//tab/infos/prtBounds"_ostr, "top"_ostr).toInt32(); + SwTwips nTableTop = nTableFrameTop + nTablePrintTop; + // Without the accompanying fix in place, this test would have failed with: + // - Expected greater or equal than: 3579 + // - Actual : 2210 + // i.e. the table's top border overlapped with the image, even if the image's wrap mode was set + // to parallel. + CPPUNIT_ASSERT_GREATEREQUAL(nFlyBottom, nTableTop); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTdf128195) +{ + // Load a document that has two paragraphs in the header. + // The second paragraph should have its bottom spacing applied. + createSwDoc("tdf128195.docx"); + sal_Int32 nTxtHeight = parseDump("//header/txt[2]/infos/bounds"_ostr, "height"_ostr).toInt32(); + sal_Int32 nTxtBottom = parseDump("//header/txt[2]/infos/bounds"_ostr, "bottom"_ostr).toInt32(); + CPPUNIT_ASSERT_EQUAL(static_cast(2269), nTxtHeight); + CPPUNIT_ASSERT_EQUAL(static_cast(3529), nTxtBottom); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBIRT) +{ + // this looped + createSwDoc("birt_min.odt"); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBorderCollapseCompat) +{ + // Load a document with a border conflict: top cell has a dotted bottom border, bottom cell has + // a solid upper border. + createSwDoc("border-collapse-compat.docx"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDocShell* pShell = pTextDoc->GetDocShell(); + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump aDumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); + + // Make sure the solid border has priority. + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 48 + // i.e. there was no single cell border with width=20, rather there were 48 border parts + // (forming a dotted border), all with width=40. + assertXPath(pXmlDoc, "//polyline[@style='solid']"_ostr, "width"_ostr, "20"); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBtlrTableRowSpan) +{ + // Load a document which has a table. The A1 cell has btlr text direction, and the A1..A3 cells + // are merged. + createSwDoc("btlr-table-row-span.odt"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDocShell* pShell = pTextDoc->GetDocShell(); + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump aDumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: USA + // - Actual : West + // i.e. the "USA" text completely disappeared. + assertXPathContent(pXmlDoc, "//textarray[1]/text"_ostr, "USA"); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTableFlyOverlapSpacing) +{ + // Load a document that has an image on the right of a table. The table wraps around the image. + createSwDoc("table-fly-overlap-spacing.docx"); + SwTwips nFlyTop = parseDump("//body/txt/anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); + SwTwips nFlyHeight + = parseDump("//body/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32(); + SwTwips nFlyBottom = nFlyTop + nFlyHeight; + SwTwips nTableFrameTop = parseDump("//tab/infos/bounds"_ostr, "top"_ostr).toInt32(); + SwTwips nTablePrintTop = parseDump("//tab/infos/prtBounds"_ostr, "top"_ostr).toInt32(); + SwTwips nTableTop = nTableFrameTop + nTablePrintTop; + // Without the accompanying fix in place, this test would have failed with: + // - Expected greater or equal than: 3993 + // - Actual : 3993 + // i.e. the table was below the image, not on the left of the image. + CPPUNIT_ASSERT_LESS(nFlyBottom, nTableTop); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTablesMoveBackwards) +{ + // Load a document with 1 pages: empty content on first page, then 21 tables on the second page. + createSwDoc("tables-move-backwards.odt"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDocShell* pDocShell = pTextDoc->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + + // Delete the content on the first page. + pWrtShell->SttEndDoc(/*bStart=*/true); + pWrtShell->EndPg(/*bSelect=*/true); + pWrtShell->DelLeft(); + + // Calc the layout and check the number of pages. + pWrtShell->CalcLayout(); + xmlDocUniquePtr pLayout = parseLayoutDump(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 2 + // i.e. there was an unexpected 2nd page, as only 20 out of 21 tables were moved to the first + // page. + assertXPath(pLayout, "//page"_ostr, 1); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testContinuousEndnotesMoveBackwards) +{ + // Load a document with the ContinuousEndnotes flag turned on. + createSwDoc("continuous-endnotes-move-backwards.doc"); + xmlDocUniquePtr pLayout = parseLayoutDump(); + // We have 2 pages. + assertXPath(pLayout, "/root/page"_ostr, 2); + // No endnote container on page 1. + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 1 + // i.e. there were unexpected endnotes on page 1. + assertXPath(pLayout, "/root/page[1]/ftncont"_ostr, 0); + // All endnotes are in a container on page 2. + assertXPath(pLayout, "/root/page[2]/ftncont"_ostr, 1); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testAnchorPositionBasedOnParagraph) +{ + // tdf#134783 check whether position of shape is good if it is anchored to paragraph and + // the "Don't add space between paragraphs of the same style" option is set + createSwDoc("tdf134783_testAnchorPositionBasedOnParagraph.fodt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "(//anchored/SwAnchoredDrawObject)[1]/bounds"_ostr, "top"_ostr, "1671"); + assertXPath(pXmlDoc, "(//anchored/SwAnchoredDrawObject)[1]/bounds"_ostr, "bottom"_ostr, "1732"); + assertXPath(pXmlDoc, "(//anchored/SwAnchoredDrawObject)[2]/bounds"_ostr, "top"_ostr, "1947"); + assertXPath(pXmlDoc, "(//anchored/SwAnchoredDrawObject)[2]/bounds"_ostr, "bottom"_ostr, "2008"); + assertXPath(pXmlDoc, "(//anchored/SwAnchoredDrawObject)[3]/bounds"_ostr, "top"_ostr, "3783"); + assertXPath(pXmlDoc, "(//anchored/SwAnchoredDrawObject)[3]/bounds"_ostr, "bottom"_ostr, "3844"); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxStaysInsideShape) +{ + // tdf#135198: check whether text box stays inside shape after moving it upwards + createSwDoc("shape-textbox.odt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + + // Without the fix in place, this test would have failed with + // - Expected: 1932 + // - Actual : 7476 + assertXPath(pXmlDoc, "//anchored/fly/infos/bounds"_ostr, "top"_ostr, "1932"); + assertXPath(pXmlDoc, "//anchored/fly/infos/bounds"_ostr, "bottom"_ostr, "7184"); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxNotModifiedOnOpen) +{ + // tdf#138050: a freshly opened document containing a shape with a text box + // should not appear to be modified + createSwDoc("textbox-phantom-change.docx"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + + // Without the fix in place this test would have shown that the document + // was modified due to a fix to tdf#135198 + CPPUNIT_ASSERT(!pDoc->getIDocumentState().IsModified()); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxAutoGrowVertical) +{ + createSwDoc("textbox-autogrow-vertical.docx"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pShape = pPage->GetObj(0); + tools::Rectangle aShapeRect = pShape->GetCurrentBoundRect(); + + discardDumpedLayout(); + xmlDocUniquePtr pLayout = parseLayoutDump(); + CPPUNIT_ASSERT(pLayout); + sal_Int32 nFlyLeft + = getXPath(pLayout, "//anchored/fly/infos/bounds"_ostr, "left"_ostr).toInt32(); + sal_Int32 nFlyTop = getXPath(pLayout, "//anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); + sal_Int32 nFlyRight + = getXPath(pLayout, "//anchored/fly/infos/bounds"_ostr, "right"_ostr).toInt32(); + sal_Int32 nFlyBottom + = getXPath(pLayout, "//anchored/fly/infos/bounds"_ostr, "bottom"_ostr).toInt32(); + tools::Rectangle aFlyRect(nFlyLeft, nFlyTop, nFlyRight, nFlyBottom); + // Without the accompanying fix in place, this test would have failed, as aFlyRect was too wide, + // so it was not inside aShapeRect anymore. + CPPUNIT_ASSERT(aShapeRect.Contains(aFlyRect)); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextboxModification) +{ + // Load a document with a textbox in it: the layout will have to position the shape part. + createSwDoc("textbox-modification.docx"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDocShell* pDocShell = pTextDoc->GetDocShell(); + + // Without the accompanying fix in place, this test would have failed, as the document was + // marked as modified right after the import. + CPPUNIT_ASSERT(!pDocShell->IsModified()); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxInHeaderIsPositioned) +{ + // Load a document with a floating text box in the header + createSwDoc("header-textbox.docx"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + + // Without the fix in place, this test would have failed with + // - Expected: 8051 + // - Actual : 1418 + // Comparison with 7000 chosen due to variability between devices + CPPUNIT_ASSERT_GREATEREQUAL( + double(7000), + getXPath(pXmlDoc, "//anchored/fly/infos/bounds"_ostr, "left"_ostr).toDouble()); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBtlrNestedCell) +{ + // Load a document with a nested table, the inner A1 cell has a btlr text direction. + createSwDoc("btlr-nested-cell.odt"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + SwFrame* pPage = pLayout->GetLower(); + SwFrame* pBody = pPage->GetLower(); + SwFrame* pOuterTable = pBody->GetLower()->GetNext(); + SwFrame* pInnerTable = pOuterTable->GetLower()->GetLower()->GetLower(); + + // Check the paint area of the only text frame in the cell. + SwFrame* pTextFrame = pInnerTable->GetLower()->GetLower()->GetLower(); + tools::Long nFrameBottom = pTextFrame->getFrameArea().Bottom(); + SwRect aPaintArea = pTextFrame->GetPaintArea(); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected greater or equal than: 2829 + // - Actual : 2080 + // i.e. part of the text frame area was not painted, hiding the actual text. + CPPUNIT_ASSERT_GREATEREQUAL(nFrameBottom, aPaintArea.Bottom()); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testKeepwithnextFullheight) +{ + // The document has a heading (keep with next) and a full-page image in the next paragraph, i.e. + // conflicting requirements. + // Without the accompanying fix in place, this test would have failed with a layout loop in + // SwEditShell::CalcLayout(). + createSwDoc("keepwithnext-fullheight.fodt"); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + // Make sure the document has 2 pages. + assertXPath(pXmlDoc, "//page"_ostr, 2); + // Heading stays on page 1 to avoid a layout loop. + assertXPathContent(pXmlDoc, "//page[1]/body/txt[2]"_ostr, "Heading"); + // Image stays on page 2. + assertXPath(pXmlDoc, "//page[2]/body/txt/anchored/fly"_ostr, 1); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testGutterMargin) +{ + // Create a document, remember the old left edge of the page print area (the rectangle that is + // inside margins). + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + uno::Reference xStandard(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + SwFrame* pPage = pLayout->GetLower(); + tools::Long nOldLeft = pPage->getFramePrintArea().Left(); + + // Set the gutter margin to 2cm. + sal_Int32 nGutterMm100 = 2000; + xStandard->setPropertyValue("GutterMargin", uno::Any(nGutterMm100)); + + // Verify that the new left edge is larger. + tools::Long nNewLeft = pPage->getFramePrintArea().Left(); + tools::Long nGutterTwips = o3tl::toTwips(nGutterMm100, o3tl::Length::mm100); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1134 + // - Actual : 0 + // i.e. the gutter was not added to the left margin. + CPPUNIT_ASSERT_EQUAL(nGutterTwips, nNewLeft - nOldLeft); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testGutterTopMargin) +{ + // Create a document, remember the old top edge of the page print area (the rectangle that is + // inside margins). + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + uno::Reference xFactory(mxComponent, uno::UNO_QUERY); + uno::Reference xSettings( + xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + xSettings->setPropertyValue("GutterAtTop", uno::Any(true)); + uno::Reference xStandard(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + SwFrame* pPage = pLayout->GetLower(); + tools::Long nOldTop = pPage->getFramePrintArea().Top(); + + // Set the gutter margin to 2cm. + sal_Int32 nGutterMm100 = 2000; + xStandard->setPropertyValue("GutterMargin", uno::Any(nGutterMm100)); + + // Verify that the new top edge is larger. + tools::Long nNewTop = pPage->getFramePrintArea().Top(); + tools::Long nGutterTwips = o3tl::toTwips(nGutterMm100, o3tl::Length::mm100); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1134 + // - Actual : 0 + // i.e. the gutter was not added to the left margin. + CPPUNIT_ASSERT_EQUAL(nGutterTwips, nNewTop - nOldTop); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testGutterMirrorMargin) +{ + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + SwDocShell* pDocShell = pDoc->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + pWrtShell->InsertPageBreak(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + SwFrame* pPage = pLayout->GetLower(); + tools::Long nOldLeft = pPage->getFramePrintArea().Left(); + SwFrame* pPage2 = pPage->GetNext(); + tools::Long nOldRight = pPage2->getFramePrintArea().Right(); + + uno::Reference xStandard(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + xStandard->setPropertyValue("PageStyleLayout", uno::Any(style::PageStyleLayout_MIRRORED)); + sal_Int32 nGutterMm100 = 2000; + xStandard->setPropertyValue("GutterMargin", uno::Any(nGutterMm100)); + + tools::Long nNewLeft = pPage->getFramePrintArea().Left(); + tools::Long nGutterTwips = o3tl::toTwips(nGutterMm100, o3tl::Length::mm100); + CPPUNIT_ASSERT_EQUAL(nGutterTwips, nNewLeft - nOldLeft); + tools::Long nNewRight = pPage2->getFramePrintArea().Right(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1134 + // - Actual : 0 + // i.e. the gutter was missing on the second, mirrored page. + CPPUNIT_ASSERT_EQUAL(nGutterTwips, nOldRight - nNewRight); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testRtlGutterMargin) +{ + // Given a document with a right margin: + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + uno::Reference xStandard(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + SwFrame* pPage = pLayout->GetLower(); + tools::Long nOldRight = pPage->getFramePrintArea().Right(); + + // When setting enable RTL gutter mode and setting a gutter margin: + xStandard->setPropertyValue("RtlGutter", uno::Any(true)); + sal_Int32 nGutterMm100 = 2000; + xStandard->setPropertyValue("GutterMargin", uno::Any(nGutterMm100)); + + // Then make sure the new right edge of the print area is decreased: + tools::Long nNewRight = pPage->getFramePrintArea().Right(); + tools::Long nGutterTwips = o3tl::toTwips(nGutterMm100, o3tl::Length::mm100); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1134 + // - Actual : 0 + // i.e. the gutter was missing on the right side. + CPPUNIT_ASSERT_EQUAL(nGutterTwips, nOldRight - nNewRight); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testGutterMarginPageBorder) +{ +// FIXME this is 3369 on macOS -- calculate this number dynamically? +// FIXME this is random on Windows at the moment (in two subsequent tests without any scaling, +// the actual values were 6346, 10066) - something broke metafile generation on Windows? +#if !defined(MACOSX) && !defined(_WIN32) + // Given a document with a non-0 gutter margin. + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + uno::Reference xStandard(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + sal_Int32 nGutterMm100 = 2000; + xStandard->setPropertyValue("GutterMargin", uno::Any(nGutterMm100)); + + // When setting a left border. + table::BorderLine2 aBorder; + aBorder.LineWidth = 2; + aBorder.OuterLineWidth = 2; + xStandard->setPropertyValue("LeftBorder", uno::Any(aBorder)); + + // Then make sure border is at the left edge of the text area. + SwDocShell* pShell = pDoc->GetDocShell(); + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2565 + // - Actual : 1425 + // Where 2565 is close to the left edge of the text area (2553). + assertXPath(pXmlDoc, "//polyline[@style='solid']/point[1]"_ostr, "x"_ostr, "2565"); +#endif +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTdf45908_invoice) +{ + // without the fix, this was hanging (and slowly consuming memory) on fileopen. + createSwDoc("tdf45908_invoice.odt"); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testVerticallyMergedCellBorder) +{ + // Given a document with a table: 2 columns, 5 rows. B2 -> B5 is merged: + createSwDoc("vmerge-cell-border.docx"); + SwDoc* pDoc = getSwDoc(); + SwDocShell* pShell = pDoc->GetDocShell(); + + // When rendering the table: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Make sure that B4->B5 has no borders. + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + // Collect vertical positions of all border points. + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"_ostr); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + std::vector aBorderPositions; + for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); ++i) + { + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[i]; + xmlChar* pValue = xmlGetProp(pXmlNode, BAD_CAST("y")); + sal_Int32 nValue = o3tl::toInt32(reinterpret_cast(pValue)); + aBorderPositions.push_back(nValue); + } + xmlXPathFreeObject(pXmlObj); + // Collect top and bottom of the B1->B3 rows. + xmlDocUniquePtr pLayout = parseLayoutDump(); + pXmlObj = getXPathNode(pLayout, "//tab/row/infos/bounds"_ostr); + pXmlNodes = pXmlObj->nodesetval; + std::vector aLayoutPositions; + for (int i = 0; i < 3; ++i) + { + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[i]; + if (i == 0) + { + xmlChar* pValue = xmlGetProp(pXmlNode, BAD_CAST("top")); + sal_Int32 nValue = o3tl::toInt32(reinterpret_cast(pValue)); + aLayoutPositions.push_back(nValue); + } + xmlChar* pValue = xmlGetProp(pXmlNode, BAD_CAST("bottom")); + sal_Int32 nValue = o3tl::toInt32(reinterpret_cast(pValue)); + aLayoutPositions.push_back(nValue); + } + xmlXPathFreeObject(pXmlObj); + // Check if any border is outside the B1->B3 range. + for (const auto nBorderPosition : aBorderPositions) + { + bool bFound = false; + for (const auto nLayoutPosition : aLayoutPositions) + { + if (std::abs(nBorderPosition - nLayoutPosition) <= 30) + { + bFound = true; + break; + } + } + std::stringstream ss; + ss << "Bad vertical position for border point: " << nBorderPosition; + ss << " Expected positions: "; + for (size_t i = 0; i < aLayoutPositions.size(); ++i) + { + if (i > 0) + { + ss << ", "; + } + ss << aLayoutPositions[i]; + } + + // Without the accompanying fix in place, this test would have failed with: + // - Bad vertical position for border point: 5624 Expected positions: 3022, 3540, 4059, 4578 + // i.e. the middle vertical border end was the bottom of B5, not bottom of B3. + CPPUNIT_ASSERT_MESSAGE(ss.str(), bFound); + } +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testCrashRemoveFromLayout) +{ + createSwDoc("tdf122894-4.doc"); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testLinkedBullet) +{ + // Given a document with a graphic bullet, where the image is a linked one: + createSwDoc("linked-bullet.odt"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDocShell* pShell = pTextDoc->GetDocShell(); + + // When rendering that document: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure the render result contains exactly one bitmap: + MetafileXmlDump aDumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // i.e. the bullet's bitmap was lost. + assertXPath(pXmlDoc, "//bmpexscale"_ostr, 1); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testInnerCellBorderIntersect) +{ + // Given a table with both outer and inner borders: + createSwDoc("inner-border.docx"); + SwDoc* pDoc = getSwDoc(); + SwDocShell* pShell = pDoc->GetDocShell(); + + // When rendering table borders: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure that inner and outer borders don't overlap in Word compatibility mode, + // and inner borders are reduced to prevent an overlap: + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + // Collect start/end (vertical) positions of horizontal borders. + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"_ostr); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + std::vector> aBorderStartEnds; + for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2) + { + xmlNodePtr pStart = pXmlNodes->nodeTab[i]; + xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; + xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); + xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); + sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY)); + sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY)); + if (nStartY != nEndY) + { + // Vertical border. + continue; + } + xmlChar* pStartX = xmlGetProp(pStart, BAD_CAST("x")); + xmlChar* pEndX = xmlGetProp(pEnd, BAD_CAST("x")); + sal_Int32 nStartX = o3tl::toInt32(reinterpret_cast(pStartX)); + sal_Int32 nEndX = o3tl::toInt32(reinterpret_cast(pEndX)); + aBorderStartEnds.emplace_back(nStartX, nEndX); + } + xmlXPathFreeObject(pXmlObj); + // We have 3 lines: top, middle and bottom. The top and the bottom one is a full line, since + // it's an outer border. The middle one has increased start and decreased end to avoid an + // overlap. + CPPUNIT_ASSERT_EQUAL(static_cast(3), aBorderStartEnds.size()); + CPPUNIT_ASSERT_EQUAL(aBorderStartEnds[0].first, aBorderStartEnds[2].first); + // Without the accompanying fix in place, this test would have failed with: + // - Expected greater than: 1724 + // - Actual : 1724 + // i.e. the middle line's start was the same as the top line start, while what we want is a + // larger X position, so the start of the middle line doesn't overlap with the thick vertical + // outer border on the left of the table. + CPPUNIT_ASSERT_GREATER(aBorderStartEnds[0].first, aBorderStartEnds[1].first); + CPPUNIT_ASSERT_EQUAL(aBorderStartEnds[0].second, aBorderStartEnds[2].second); + CPPUNIT_ASSERT_LESS(aBorderStartEnds[0].second, aBorderStartEnds[1].second); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testInnerCellBorderNocompatIntersect) +{ + // Given a table with both outer and inner borders: + createSwDoc(); + SwDocShell* pShell = getSwDocShell(); + SwDoc* pDoc = pShell->GetDoc(); + // Set the default page style's writing direction to vertical: + SwPageDesc aStandard(pDoc->GetPageDesc(0)); + SvxFrameDirectionItem aDirection(SvxFrameDirection::Vertical_RL_TB, RES_FRAMEDIR); + aStandard.GetMaster().SetFormatAttr(aDirection); + pDoc->ChgPageDesc(0, aStandard); + // Insert a 4x4 table: + SwWrtShell* pWrtShell = pShell->GetWrtShell(); + SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0); + pWrtShell->InsertTable(aTableOptions, 4, 4); + + // When rendering table borders: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure that all horizontal lines have the same length: + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + // Collect start/end (vertical) positions of horizontal borders. + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"_ostr); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + std::vector> aBorderStartEnds; + for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2) + { + xmlNodePtr pStart = pXmlNodes->nodeTab[i]; + xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; + xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); + xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); + sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY)); + sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY)); + if (nStartY != nEndY) + { + // Vertical border. + continue; + } + xmlChar* pStartX = xmlGetProp(pStart, BAD_CAST("x")); + xmlChar* pEndX = xmlGetProp(pEnd, BAD_CAST("x")); + sal_Int32 nStartX = o3tl::toInt32(reinterpret_cast(pStartX)); + sal_Int32 nEndX = o3tl::toInt32(reinterpret_cast(pEndX)); + aBorderStartEnds.emplace_back(nStartX, nEndX); + } + xmlXPathFreeObject(pXmlObj); + // We have 5 lines: top of 4 cells + bottom. + CPPUNIT_ASSERT_EQUAL(static_cast(5), aBorderStartEnds.size()); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 9719 + // - Actual : 10064 + // i.e. the 2nd line started later than the first one, which is incorrect. + CPPUNIT_ASSERT_EQUAL(aBorderStartEnds[0].first, aBorderStartEnds[1].first); + CPPUNIT_ASSERT_EQUAL(aBorderStartEnds[0].first, aBorderStartEnds[2].first); + CPPUNIT_ASSERT_EQUAL(aBorderStartEnds[0].first, aBorderStartEnds[3].first); + CPPUNIT_ASSERT_EQUAL(aBorderStartEnds[0].first, aBorderStartEnds[4].first); + CPPUNIT_ASSERT_EQUAL(aBorderStartEnds[0].second, aBorderStartEnds[1].second); + CPPUNIT_ASSERT_EQUAL(aBorderStartEnds[0].second, aBorderStartEnds[2].second); + CPPUNIT_ASSERT_EQUAL(aBorderStartEnds[0].second, aBorderStartEnds[3].second); + CPPUNIT_ASSERT_EQUAL(aBorderStartEnds[0].second, aBorderStartEnds[4].second); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testDoubleBorderVertical) +{ + // Given a table with a left and right double border, outer is thick, inner is thin: + createSwDoc("double-border-vertical.docx"); + SwDoc* pDoc = getSwDoc(); + SwDocShell* pShell = pDoc->GetDocShell(); + + // When rendering that document: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure the left border is thick+thin and the right border is thin+thick (from left to + // right): + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + // Collect widths of vertical lines. + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"_ostr); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + // Horizontal position -> width. + std::map aBorderWidths; + for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2) + { + xmlNodePtr pStart = pXmlNodes->nodeTab[i]; + xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; + xmlChar* pStartX = xmlGetProp(pStart, BAD_CAST("x")); + xmlChar* pEndX = xmlGetProp(pEnd, BAD_CAST("x")); + sal_Int32 nStartX = o3tl::toInt32(reinterpret_cast(pStartX)); + sal_Int32 nEndX = o3tl::toInt32(reinterpret_cast(pEndX)); + if (nStartX != nEndX) + { + // Horizontal border. + continue; + } + xmlChar* pWidth = xmlGetProp(pStart->parent, BAD_CAST("width")); + sal_Int32 nWidth = o3tl::toInt32(reinterpret_cast(pWidth)); + aBorderWidths[nStartX] = nWidth; + } + xmlXPathFreeObject(pXmlObj); + std::vector aBorderWidthVec; + std::transform(aBorderWidths.begin(), aBorderWidths.end(), std::back_inserter(aBorderWidthVec), + [](const std::pair& rPair) { return rPair.second; }); + CPPUNIT_ASSERT_EQUAL(static_cast(4), aBorderWidthVec.size()); + // Without the accompanying fix in place, this test would have failed with: + // - Expected greater than: 120 + // - Actual : 60 + // i.e. the left border was thin+thick, not thick+thin. + CPPUNIT_ASSERT_GREATER(aBorderWidthVec[1], aBorderWidthVec[0]); + CPPUNIT_ASSERT_GREATER(aBorderWidthVec[2], aBorderWidthVec[3]); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testDoubleBorderHorizontal) +{ + // Given a table with a top and bottom double border, outer is thin, inner is thick: + createSwDoc("double-border-horizontal.docx"); + SwDoc* pDoc = getSwDoc(); + SwDocShell* pShell = pDoc->GetDocShell(); + + // When rendering table borders: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure the top border is thin+thick and the bottom border is thick+thin (from top to + // bottom): + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + // Collect widths of horizontal lines. + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"_ostr); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + // Vertical position -> width. + std::map aBorderWidths; + for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2) + { + xmlNodePtr pStart = pXmlNodes->nodeTab[i]; + xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; + xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); + xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); + sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY)); + sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY)); + if (nStartY != nEndY) + { + // Vertical border. + continue; + } + xmlChar* pWidth = xmlGetProp(pStart->parent, BAD_CAST("width")); + sal_Int32 nWidth = o3tl::toInt32(reinterpret_cast(pWidth)); + aBorderWidths[nStartY] = nWidth; + } + xmlXPathFreeObject(pXmlObj); + std::vector aBorderWidthVec; + std::transform(aBorderWidths.begin(), aBorderWidths.end(), std::back_inserter(aBorderWidthVec), + [](const std::pair& rPair) { return rPair.second; }); + CPPUNIT_ASSERT_EQUAL(static_cast(4), aBorderWidthVec.size()); + CPPUNIT_ASSERT_GREATER(aBorderWidthVec[0], aBorderWidthVec[1]); + // Without the accompanying fix in place, this test would have failed with: + // - Expected greater than: 120 + // - Actual : 60 + // i.e. the bottom border was thin+thick, not thick+thin. + CPPUNIT_ASSERT_GREATER(aBorderWidthVec[3], aBorderWidthVec[2]); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testParaBorderInCellClip) +{ + // Given a document which has outside-cell borders defined, which should not be visible: + createSwDoc("para-border-in-cell-clip.docx"); + SwDoc* pDoc = getSwDoc(); + SwDocShell* pShell = pDoc->GetDocShell(); + + // When rendering those borders: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure that we have clipping setup for both paragraphs inside the table cell: + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 0 + // - XPath '//clipregion/polygon' number of nodes is incorrect + // i.e. there was no clipping applied, leading to unexpected left/right borders. + assertXPath(pXmlDoc, "//clipregion/polygon"_ostr, 2); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testDoublePageBorder) +{ + // Given a page with a top and bottom double border, outer is thick, inner is thin: + createSwDoc("double-page-border.docx"); + SwDoc* pDoc = getSwDoc(); + SwDocShell* pShell = pDoc->GetDocShell(); + + // When rendering that document: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure the top border is thick+thing and the bottom border is thin+thick (from top to + // bottom): + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + // Collect widths of horizontal lines. + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"_ostr); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + // Vertical position -> width. + std::map aBorderWidths; + for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2) + { + xmlNodePtr pStart = pXmlNodes->nodeTab[i]; + xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; + xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); + xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); + sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY)); + sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY)); + if (nStartY != nEndY) + { + // Vertical border. + continue; + } + xmlChar* pWidth = xmlGetProp(pStart->parent, BAD_CAST("width")); + sal_Int32 nWidth = o3tl::toInt32(reinterpret_cast(pWidth)); + aBorderWidths[nStartY] = nWidth; + } + xmlXPathFreeObject(pXmlObj); + std::vector aBorderWidthVec; + std::transform(aBorderWidths.begin(), aBorderWidths.end(), std::back_inserter(aBorderWidthVec), + [](const std::pair& rPair) { return rPair.second; }); + CPPUNIT_ASSERT_EQUAL(static_cast(4), aBorderWidthVec.size()); + CPPUNIT_ASSERT_GREATER(aBorderWidthVec[1], aBorderWidthVec[0]); + // Without the accompanying fix in place, this test would have failed with: + // - Expected greater than: 60 + // - Actual : 15 + // i.e. the bottom border was thick+thin, not thin+thick. + CPPUNIT_ASSERT_GREATER(aBorderWidthVec[2], aBorderWidthVec[3]); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testNegativePageBorder) +{ + // FIXME: the DPI check should be removed when either (1) the test is fixed to work with + // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin. + if (!IsDefaultDPI()) + return; + + // Given a document with a top margin and a negative border distance: + createSwDoc(); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDocShell* pDocShell = pTextDoc->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + pWrtShell->Insert("test"); + uno::Reference xPageStyle(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + xPageStyle->setPropertyValue("TopMargin", uno::Any(static_cast(501))); // 284 twips + table::BorderLine2 aBorder; + aBorder.LineWidth = 159; // 90 twips + aBorder.OuterLineWidth = 159; + xPageStyle->setPropertyValue("TopBorder", uno::Any(aBorder)); + sal_Int32 nTopBorderDistance = -646; // -366 twips + xPageStyle->setPropertyValue("TopBorderDistance", uno::Any(nTopBorderDistance)); + nTopBorderDistance = 0; + xPageStyle->getPropertyValue("TopBorderDistance") >>= nTopBorderDistance; + CPPUNIT_ASSERT_EQUAL(static_cast(-646), nTopBorderDistance); + + // When rendering that border: + std::shared_ptr xMetaFile = pDocShell->GetPreviewMetaFile(); + + // Then make sure that the negative distance pushes the horizontal borderline down: + MetafileXmlDump aDumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 899 + // - Actual : 524 + // i.e. the negative border distance was rounded up to 0 in lcl_CalcBorderRect(). + // Ideally this would be 284 (top of first page) + 284 (top margin) + 366 (border distance) = + // 934. + assertXPath(pXmlDoc, "//polyline[@style='solid']/point[1]"_ostr, "y"_ostr, "899"); + assertXPath(pXmlDoc, "//polyline[@style='solid']/point[2]"_ostr, "y"_ostr, "899"); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testNegativePageBorderNoMargin) +{ + // FIXME: the DPI check should be removed when either (1) the test is fixed to work with + // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin. + if (!IsDefaultDPI()) + return; + + // Given a document with no top margin and a negative border distance: + createSwDoc(); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDocShell* pDocShell = pTextDoc->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + pWrtShell->Insert("test"); + uno::Reference xPageStyle(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + xPageStyle->setPropertyValue("TopMargin", uno::Any(static_cast(0))); // 0 twips + table::BorderLine2 aBorder; + aBorder.LineWidth = 159; // 90 twips + aBorder.OuterLineWidth = 159; + xPageStyle->setPropertyValue("TopBorder", uno::Any(aBorder)); + sal_Int32 nTopBorderDistance = -1147; // -650 twips + xPageStyle->setPropertyValue("TopBorderDistance", uno::Any(nTopBorderDistance)); + + // When rendering that border: + std::shared_ptr xMetaFile = pDocShell->GetPreviewMetaFile(); + + // Then make sure that the negative distance pushes the horizontal borderline down: + MetafileXmlDump aDumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 899 + // - Actual : 329 + // i.e. this failed differently: the lack of top margin caused a second problem. + // Ideally this would be 284 (top of first page) + 650 (border distance) = + // 934. + assertXPath(pXmlDoc, "//polyline[@style='solid']/point[1]"_ostr, "y"_ostr, "899"); + assertXPath(pXmlDoc, "//polyline[@style='solid']/point[2]"_ostr, "y"_ostr, "899"); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testFollowTextFlowWrapInBackground) +{ + // Given a document with a table, and a graphic inside that table -- anchored, wrap set to + // through and follow-text-flow set to true: + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + pDoc->getIDocumentSettingAccess().set(DocumentSettingId::USE_FORMER_TEXT_WRAPPING, true); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0); + pWrtShell->InsertTable(aTableOptions, 1, 1); + pWrtShell->MoveTable(GotoPrevTable, fnTableStart); + SfxItemSet aFrameSet(pDoc->GetAttrPool(), svl::Items); + SwFormatAnchor aAnchor(RndStdIds::FLY_AT_CHAR); + aFrameSet.Put(aAnchor); + SwFormatSurround aSurround(text::WrapTextMode_THROUGH); + aFrameSet.Put(aSurround); + SwFormatFrameSize aSize(SwFrameSize::Fixed, 1000, 1000); + aFrameSet.Put(aSize); + SwFormatFollowTextFlow aFlow(true); + aFrameSet.Put(aFlow); + Graphic aGrf; + + // When inserting that image: + pWrtShell->SwFEShell::Insert(OUString(), OUString(), &aGrf, &aFrameSet); + + // Then make sure that the cell height grows to have space for the graphic, given that + // background=true is not specified. + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nCellHeight + = getXPath(pXmlDoc, "//cell[1]/infos/bounds"_ostr, "height"_ostr).toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected greater than: 1000 + // - Actual : 396 + // i.e. the image was larger than the containing cell. + CPPUNIT_ASSERT_GREATER(static_cast(1000), nCellHeight); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testPageRemoveFlyTable) +{ + // Given a document with a ToC and several tables, one table marked with a bookmark: + createSwDoc("page-remove-fly-table.odt"); + SwDoc* pDoc = getSwDoc(); + + // When updating the ToC and incrementally formatting the document: + SwView* pView = pDoc->GetDocShell()->GetView(); + SfxDispatcher& rDispatcher = *pView->GetViewFrame().GetDispatcher(); + rDispatcher.Execute(FN_UPDATE_TOX); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->Reformat(); + + // Then make sure that the 2nd table below the bookmark has no unwanted top margin: + pWrtShell->GotoMark("test"); + pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1, /*bBasicCall=*/false); + pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1, /*bBasicCall=*/false); + SwCursor* pCursor = pWrtShell->GetCursor(); + SwTextNode* pTextNode = pCursor->GetPoint()->GetNode().GetTextNode(); + SwFrame* pTextFrame = pTextNode->getLayoutFrame(nullptr); + SwTabFrame* pInnerTable = pTextFrame->FindTabFrame(); + SwTabFrame* pOuterTable = pInnerTable->GetUpper()->FindTabFrame(); + tools::Long nActual = pOuterTable->getFramePrintArea().Top(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 5879 + // i.e. the problematic table had a large, unwanted/leftover top margin. + CPPUNIT_ASSERT_EQUAL(static_cast(0), nActual); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testPageRemoveFlyNoTable) +{ + createSwDoc("page-remove-fly-no-table.fodt"); + // This never returned. + calcLayout(); +} + +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testNewFollowTextFlowWrapInBackground) +{ + // Given a document with a table, and a graphic inside that table -- anchored, wrap set to + // through and follow-text-flow set to true, legacy USE_FORMER_TEXT_WRAPPING is not set: + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0); + pWrtShell->InsertTable(aTableOptions, 1, 1); + pWrtShell->MoveTable(GotoPrevTable, fnTableStart); + SfxItemSet aFrameSet(pDoc->GetAttrPool(), svl::Items); + SwFormatAnchor aAnchor(RndStdIds::FLY_AT_CHAR); + aFrameSet.Put(aAnchor); + SwFormatSurround aSurround(text::WrapTextMode_THROUGH); + aFrameSet.Put(aSurround); + SwFormatFrameSize aSize(SwFrameSize::Fixed, 1000, 1000); + aFrameSet.Put(aSize); + SwFormatFollowTextFlow aFlow(true); + aFrameSet.Put(aFlow); + Graphic aGrf; + + // When inserting that image: + pWrtShell->SwFEShell::Insert(OUString(), OUString(), &aGrf, &aFrameSet); + + // Then make sure that the cell height grows to have space for the graphic, given that + // background=true is not specified. + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nCellHeight + = getXPath(pXmlDoc, "//cell[1]/infos/bounds"_ostr, "height"_ostr).toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected less than: 1000 + // - Actual : 1120 + // i.e. the cell height was too large, the image influenced it, which is not expected. + CPPUNIT_ASSERT_LESS(static_cast(1000), nCellHeight); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/paintfrm.cxx b/sw/qa/core/layout/paintfrm.cxx new file mode 100644 index 0000000000..b5990648b2 --- /dev/null +++ b/sw/qa/core/layout/paintfrm.cxx @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include + +#include +#include + +namespace +{ +/// Covers sw/source/core/layout/paintfrm.cxx fixes. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testSplitTableBorder) +{ + // Given a document with a split table, table borders are defined, but cell borders are not: + createSwDoc("split-table-border.odt"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDocShell* pShell = pTextDoc->GetDocShell(); + + // When rendering that document: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure that the master table has a bottom border and the follow table has a top + // border: + MetafileXmlDump aDumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"_ostr); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + int nHorizontalBorders = 0; + // Count the horizontal borders: + for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2) + { + xmlNodePtr pStart = pXmlNodes->nodeTab[i]; + xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; + xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); + xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); + sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY)); + sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY)); + if (nStartY != nEndY) + { + // Vertical border. + continue; + } + + ++nHorizontalBorders; + } + xmlXPathFreeObject(pXmlObj); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 4 + // - Actual : 2 + // i.e. the bottom border in the master table and the top border in the follow table were + // missing. + CPPUNIT_ASSERT_EQUAL(4, nHorizontalBorders); +} + +CPPUNIT_TEST_FIXTURE(Test, testRTLBorderMerge) +{ + // Given a document with an RTL table: + createSwDoc("rtl-table.docx"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDocShell* pShell = pTextDoc->GetDocShell(); + + // When rendering that document: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure the 5 columns all have left and right vertical borders: + MetafileXmlDump aDumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"_ostr); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + int nVerticalBorders = 0; + // Count the vertical borders: + for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2) + { + xmlNodePtr pStart = pXmlNodes->nodeTab[i]; + xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; + xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); + xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); + sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY)); + sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY)); + if (nStartY == nEndY) + { + // Horizontal border. + continue; + } + + ++nVerticalBorders; + } + xmlXPathFreeObject(pXmlObj); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 6 + // - Actual : 4 + // i.e. the 2nd and 5th vertical border was missing. + CPPUNIT_ASSERT_EQUAL(6, nVerticalBorders); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitTableMergedBorder) +{ + // Given a document with a split table, first row in frame 1 has merged cells: + createSwDoc("split-table-merged-border.odt"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + SwDocShell* pShell = pTextDoc->GetDocShell(); + + // When rendering that document: + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure that the master table has a bottom border with the correct widths: + MetafileXmlDump aDumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"_ostr); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + std::set aHorizontalBorderStarts; + std::set aHorizontalBorderEnds; + // Collect the horizontal borders: + for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2) + { + xmlNodePtr pStart = pXmlNodes->nodeTab[i]; + xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; + xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); + xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); + sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY)); + sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY)); + if (nStartY != nEndY) + { + // Vertical border. + continue; + } + + xmlChar* pStartX = xmlGetProp(pStart, BAD_CAST("x")); + xmlChar* pEndX = xmlGetProp(pEnd, BAD_CAST("x")); + sal_Int32 nStartX = o3tl::toInt32(reinterpret_cast(pStartX)); + sal_Int32 nEndX = o3tl::toInt32(reinterpret_cast(pEndX)); + aHorizontalBorderStarts.insert(nStartX); + aHorizontalBorderEnds.insert(nEndX); + } + xmlXPathFreeObject(pXmlObj); + CPPUNIT_ASSERT_EQUAL(static_cast(2), aHorizontalBorderStarts.size()); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 3 + // i.e. the frame 1 bottom border ended sooner than expected, resulting in a buggy, partial + // bottom border. + CPPUNIT_ASSERT_EQUAL(static_cast(2), aHorizontalBorderEnds.size()); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/sortedobjs.cxx b/sw/qa/core/layout/sortedobjs.cxx new file mode 100644 index 0000000000..471dd48a8b --- /dev/null +++ b/sw/qa/core/layout/sortedobjs.cxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +namespace +{ +/// Covers sw/source/core/layout/sortedobjs.cxx fixes. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testSortedObjsInsert) +{ + // Given a document with two anchored objects, one is a fly frame in the header and the other is + // a group shape where one inner shape has an associated fly frame: + // When importing that document: + // Then make sure that we don't try to do binary search on an unsorted container that leads to a + // crash in debug builds: + createSwDoc("sorted-objs-insert.docx"); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx new file mode 100644 index 0000000000..9357fc2df1 --- /dev/null +++ b/sw/qa/core/layout/tabfrm.cxx @@ -0,0 +1,204 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +/// Covers sw/source/core/layout/tabfrm.cxx fixes. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testTablePrintAreaLeft) +{ + // Given a document with a header containing an image, and also with an overlapping table: + createSwDoc("table-print-area-left.docx"); + + // When laying out that document & parsing the left margin of the table: + SwTwips nTablePrintLeft = parseDump("//tab/infos/prtBounds"_ostr, "left"_ostr).toInt32(); + + // Then make sure it has ~no left margin: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 5 + // - Actual : 10646 + // i.e. the table was shifted outside the page, was invisible. + CPPUNIT_ASSERT_EQUAL(static_cast(5), nTablePrintLeft); +} + +CPPUNIT_TEST_FIXTURE(Test, testTableMissingJoin) +{ + // Given a document with a table on page 2: + // When laying out that document: + createSwDoc("table-missing-join.docx"); + + // Then make sure that the table fits page 2: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + SwFrame* pBody = pPage2->FindBodyCont(); + auto pTab = pBody->GetLower()->DynCastTabFrame(); + // Without the accompanying fix in place, this test would have failed, the table continued on + // page 3. + CPPUNIT_ASSERT(!pTab->HasFollow()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInInlineTable) +{ + // Outer inline table on pages 1 -> 2 -> 3, inner floating table on pages 2 -> 3: + // When laying out that document: + createSwDoc("floattable-in-inlinetable.docx"); + + // Then make sure that the outer table is not missing on page 3: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + { + SwFrame* pBody = pPage1->FindBodyCont(); + auto pTab = pBody->GetLower()->DynCastTabFrame(); + CPPUNIT_ASSERT(!pTab->GetPrecede()); + CPPUNIT_ASSERT(pTab->GetFollow()); + } + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + { + SwFrame* pBody = pPage2->FindBodyCont(); + auto pTab = pBody->GetLower()->DynCastTabFrame(); + CPPUNIT_ASSERT(pTab->GetPrecede()); + // Without the accompanying fix in place, this test would have failed, the outer table was + // missing on page 3. + CPPUNIT_ASSERT(pTab->GetFollow()); + } + auto pPage3 = pPage2->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage3); + { + SwFrame* pBody = pPage3->FindBodyCont(); + auto pTab = pBody->GetLower()->DynCastTabFrame(); + CPPUNIT_ASSERT(pTab->GetPrecede()); + CPPUNIT_ASSERT(!pTab->GetFollow()); + } +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNestedRowSpan) +{ + // Given a document with nested floating tables and a row with rowspan cells at page boundary: + // When loading that document: + // Without the accompanying fix in place, this test would have resulted in a layout loop. + createSwDoc("floattable-nested-rowspan.docx"); + + // Then make sure the resulting page count matches Word: + CPPUNIT_ASSERT_EQUAL(6, getPages()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyTableJoin) +{ + // Given a document with a multi-page floating table: + // When loading this document: + createSwDoc("floattable-table-join.docx"); + + // Then make sure this document doesn't crash the layout and has a floating table split on 4 + // pages: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + { + SwSortedObjs& rPageObjs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size()); + auto pFly = rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pFly); + // Start of the chain. + CPPUNIT_ASSERT(!pFly->GetPrecede()); + CPPUNIT_ASSERT(pFly->HasFollow()); + } + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + CPPUNIT_ASSERT(pPage2->GetSortedObjs()); + { + SwSortedObjs& rPageObjs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size()); + auto pFly = rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pFly); + CPPUNIT_ASSERT(pFly->GetPrecede()); + CPPUNIT_ASSERT(pFly->HasFollow()); + } + auto pPage3 = pPage2->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage3); + CPPUNIT_ASSERT(pPage3->GetSortedObjs()); + { + SwSortedObjs& rPageObjs = *pPage3->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size()); + auto pFly = rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pFly); + CPPUNIT_ASSERT(pFly->GetPrecede()); + CPPUNIT_ASSERT(pFly->HasFollow()); + } + auto pPage4 = pPage3->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage4); + CPPUNIT_ASSERT(pPage4->GetSortedObjs()); + SwSortedObjs& rPageObjs = *pPage4->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size()); + auto pFly = rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pFly); + // End of the chain. + CPPUNIT_ASSERT(pFly->GetPrecede()); + CPPUNIT_ASSERT(!pFly->HasFollow()); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWrappedByTable) +{ + // Given a document with a floating table, wrapped by an inline table: + // When laying out the document: + createSwDoc("floattable-wrapped-by-table.docx"); + + // Then make sure the inline table wraps around the floating table: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage); + // Get the top of the inline table, ignoring margins: + CPPUNIT_ASSERT(pPage->GetSortedObjs()); + SwSortedObjs& rPageObjs = *pPage->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size()); + auto pFly = rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame(); + CPPUNIT_ASSERT(pFly); + // Get the bottom of the floating table, ignoring margins: + SwTwips nFloatingBottom = pFly->getFrameArea().Top() + pFly->getFramePrintArea().Height(); + SwFrame* pBody = pPage->FindBodyCont(); + auto pTab = pBody->GetLower()->GetNext()->DynCastTabFrame(); + SwTwips nInlineTop = pTab->getFrameArea().Top() + pTab->getFramePrintArea().Top(); + // Make sure the inline table is on the right of the floating one, not below it: + // Without the accompanying fix in place, this test would have failed with: + // - Expected less than: 7287 + // - Actual : 7287 + // i.e. the inline table was under the floating one, not on the right of it. + CPPUNIT_ASSERT_LESS(nFloatingBottom, nInlineTop); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/trvlfrm.cxx b/sw/qa/core/layout/trvlfrm.cxx new file mode 100644 index 0000000000..dc8ba54f4f --- /dev/null +++ b/sw/qa/core/layout/trvlfrm.cxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include +#include +#include + +namespace +{ +/// Covers sw/source/core/layout/trvlfrm.cxx fixes. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyModelPositionForViewPointCorrection) +{ + // Given a 2 page floating table, 40% width, positioned on the left of the page: + createSwDoc("floattable-model-position-for-view-point-correction.docx"); + + // When clicking on the right side of the table: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwDoc* pDoc = getSwDocShell()->GetDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + SwFrame* pPage = pLayout->GetLower(); + SwFrame* pBody = pPage->GetLower(); + const SwRect& rBodyRect = pBody->getFrameArea(); + // 1 line below the top center of the body frame. + Point aDocPos(rBodyRect.Left() + rBodyRect.Width() / 2, rBodyRect.Top() + 220); + bool bOnlyText = false; + pWrtShell->CallSetCursor(&aDocPos, bOnlyText); + + // Then make sure the cursor gets inside the table, and doesn't go to the anchor on page 2: + SwCursor& rCursor = pWrtShell->GetCurrentShellCursor(); + SwTableNode* pTableNode = rCursor.GetPointNode().FindTableNode(); + // Without the accompanying fix in place, this test would have failed, the cursor was in the + // anchor text node, not inside the split fly. + CPPUNIT_ASSERT(pTableNode); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3