This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch odf-devel in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 66e02262a34f496809e96e5472f926e7d2cba565 Author: Jim Jagielski <[email protected]> AuthorDate: Fri Oct 23 06:33:40 2026 -0400 test/odf-validate: add fixtures for the table-span, anchor-page and note-ref fixes --- test/odf-validate/fixtures/anchor-page/checks.json | 18 ++++++ .../fixtures/anchor-page/test-image.docx | Bin 0 -> 24026 bytes .../fixtures/normal-values/checks.json | 65 ++++++++++++++++++++ test/odf-validate/fixtures/normal-values/make.py | 51 ++++++++++++++++ .../fixtures/normal-values/normal-values.odt | Bin 0 -> 9381 bytes .../odf-validate/fixtures/note-ref/checks-seq.json | 68 +++++++++++++++++++++ test/odf-validate/fixtures/note-ref/checks.json | 23 +++++++ test/odf-validate/fixtures/note-ref/fields.doc | Bin 0 -> 34816 bytes test/odf-validate/fixtures/note-ref/make.py | 38 ++++++++++++ .../fixtures/table-colspan/MergedTable_3_3.docx | Bin 0 -> 10431 bytes .../fixtures/table-colspan/checks.json | 28 +++++++++ 11 files changed, 291 insertions(+) diff --git a/test/odf-validate/fixtures/anchor-page/checks.json b/test/odf-validate/fixtures/anchor-page/checks.json new file mode 100644 index 0000000000..e52aedf945 --- /dev/null +++ b/test/odf-validate/fixtures/anchor-page/checks.json @@ -0,0 +1,18 @@ +[ + { + "name": "shapes", + "expr": "[(g.ShapeType, g.AnchorType.value, g.Name) for g in [doc.DrawPage.getByIndex(i) for i in range(doc.DrawPage.Count)]]", + "expect": [ + [ + "com.sun.star.drawing.GraphicObjectShape", + "AT_PAGE", + "statue_by_nicu.png" + ], + [ + "FrameShape", + "AT_CHARACTER", + "1" + ] + ] + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/anchor-page/test-image.docx b/test/odf-validate/fixtures/anchor-page/test-image.docx new file mode 100644 index 0000000000..fff6424514 Binary files /dev/null and b/test/odf-validate/fixtures/anchor-page/test-image.docx differ diff --git a/test/odf-validate/fixtures/normal-values/checks.json b/test/odf-validate/fixtures/normal-values/checks.json new file mode 100644 index 0000000000..4291cdb376 --- /dev/null +++ b/test/odf-validate/fixtures/normal-values/checks.json @@ -0,0 +1,65 @@ +[ + { + "name": "cell_text", + "expr": "[(n, doc.TextTables.getByIndex(0).getCellByName(n).String) for n in doc.TextTables.getByIndex(0).CellNames]", + "expect": [ + [ + "A1", + "" + ], + [ + "B1", + "" + ], + [ + "A2", + "" + ], + [ + "B2", + "" + ], + [ + "C2", + "" + ] + ] + }, + { + "name": "frames", + "expr": "[(n, doc.TextFrames.getByName(n).AnchorType.value, doc.TextFrames.getByName(n).AnchorPageNo) for n in sorted(doc.TextFrames.ElementNames)]", + "expect": [ + [ + "frame_nopage", + "AT_PAGE", + 2 + ], + [ + "frame_p2", + "AT_PAGE", + 2 + ] + ] + }, + { + "name": "note_refs", + "expr": "[(f.ReferenceFieldSource, f.ReferenceFieldPart, f.CurrentPresentation) for f in (lambda e: [e.nextElement() for _ in iter(e.hasMoreElements, False)])(doc.TextFields.createEnumeration()) if f.supportsService('com.sun.star.text.TextField.GetReference')]", + "expect": [ + [ + 3, + 0, + "" + ], + [ + 3, + 2, + "" + ], + [ + 3, + 3, + "" + ] + ] + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/normal-values/make.py b/test/odf-validate/fixtures/normal-values/make.py new file mode 100644 index 0000000000..2c857fd1e3 --- /dev/null +++ b/test/odf-validate/fixtures/normal-values/make.py @@ -0,0 +1,51 @@ +# usage: runpy.sh fixtures/normal-values/make.py <port> <out.odt> +import sys, uno +from unohelp import connect, desktop, pv +from com.sun.star.text.TextContentAnchorType import AT_PAGE, AT_PARAGRAPH +from com.sun.star.style.BreakType import PAGE_BEFORE + +port, out = int(sys.argv[1]), sys.argv[2] +d = desktop(connect(port)) +doc = d.loadComponentFromURL("private:factory/swriter", "_blank", 0, (pv("Hidden", True),)) +text = doc.Text + +tbl = doc.createInstance("com.sun.star.text.TextTable") +tbl.initialize(2, 3) +text.insertTextContent(text.End, tbl, False) +c = tbl.createCursorByCellName("A1") +c.goRight(1, True) +c.mergeRange() + +cur = text.createTextCursor(); cur.gotoEnd(False) +text.insertString(cur, "\nbody\n", False) +cur.gotoEnd(False) +cur.BreakType = PAGE_BEFORE +text.insertString(cur, "page two\n", False) + +fn = doc.createInstance("com.sun.star.text.Footnote") +fn.Label = "" +cur.gotoEnd(False) +text.insertTextContent(cur, fn, False) +fn.String = "note text" +text.insertString(cur, " ", False) +for part in (0, 3, 2): + f = doc.createInstance("com.sun.star.text.TextField.GetReference") + f.ReferenceFieldSource = 3 + f.SourceName = "" + f.SequenceNumber = fn.ReferenceId + f.ReferenceFieldPart = part + text.insertTextContent(cur, f, False) + text.insertString(cur, " ", False) + +for name, page in (("frame_p2", 2), ("frame_nopage", 0)): + fr = doc.createInstance("com.sun.star.text.TextFrame") + fr.AnchorType = AT_PAGE + if page: + fr.AnchorPageNo = page + fr.Width = 3000; fr.Height = 1000 + text.insertTextContent(cur, fr, False) + fr.setName(name) + fr.Text.String = name + +doc.storeToURL(uno.systemPathToFileUrl(out), (pv("FilterName", "writer8"),)) +doc.close(True) diff --git a/test/odf-validate/fixtures/normal-values/normal-values.odt b/test/odf-validate/fixtures/normal-values/normal-values.odt new file mode 100644 index 0000000000..fcc8f8730b Binary files /dev/null and b/test/odf-validate/fixtures/normal-values/normal-values.odt differ diff --git a/test/odf-validate/fixtures/note-ref/checks-seq.json b/test/odf-validate/fixtures/note-ref/checks-seq.json new file mode 100644 index 0000000000..63114babad --- /dev/null +++ b/test/odf-validate/fixtures/note-ref/checks-seq.json @@ -0,0 +1,68 @@ +[ + { + "name": "note_refs", + "expr": "(doc.TextFields.refresh(), [(f.ReferenceFieldSource, f.ReferenceFieldPart, f.CurrentPresentation) for f in (lambda e: [e.nextElement() for _ in iter(e.hasMoreElements, False)])(doc.TextFields.createEnumeration()) if f.supportsService('com.sun.star.text.TextField.GetReference')])[1]", + "expect": [ + [ + 3, + 0, + "" + ], + [ + 4, + 2, + "i" + ], + [ + 4, + 2, + "i" + ], + [ + 4, + 2, + "i" + ], + [ + 4, + 2, + "i" + ], + [ + 4, + 3, + "below" + ], + [ + 4, + 0, + "" + ], + [ + 3, + 2, + "1" + ], + [ + 3, + 2, + "1" + ], + [ + 3, + 2, + "1" + ], + [ + 3, + 2, + "1" + ], + [ + 3, + 3, + "below" + ] + ] + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/note-ref/checks.json b/test/odf-validate/fixtures/note-ref/checks.json new file mode 100644 index 0000000000..7e9808963f --- /dev/null +++ b/test/odf-validate/fixtures/note-ref/checks.json @@ -0,0 +1,23 @@ +[ + { + "name": "note_refs", + "expr": "[(f.ReferenceFieldSource, f.ReferenceFieldPart, f.CurrentPresentation) for f in (lambda e: [e.nextElement() for _ in iter(e.hasMoreElements, False)])(doc.TextFields.createEnumeration()) if f.supportsService('com.sun.star.text.TextField.GetReference')]", + "expect": [ + [ + 2, + 0, + "1" + ], + [ + 2, + 1, + "??" + ], + [ + 3, + 2, + "Error: Reference source not found" + ] + ] + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/note-ref/fields.doc b/test/odf-validate/fixtures/note-ref/fields.doc new file mode 100644 index 0000000000..8ad1a3738c Binary files /dev/null and b/test/odf-validate/fixtures/note-ref/fields.doc differ diff --git a/test/odf-validate/fixtures/note-ref/make.py b/test/odf-validate/fixtures/note-ref/make.py new file mode 100644 index 0000000000..e0473f0686 --- /dev/null +++ b/test/odf-validate/fixtures/note-ref/make.py @@ -0,0 +1,38 @@ +# usage: runpy.sh fixtures/note-ref/make.py <port> <out.odt> <expected.json> +# Saves with the office's configured ODF version, so run it against the strict profile (drive.sh strict). +import sys, json, uno +from unohelp import connect, desktop, pv + +port, out, exp = int(sys.argv[1]), sys.argv[2], sys.argv[3] +d = desktop(connect(port)) +doc = d.loadComponentFromURL("private:factory/swriter", "_blank", 0, (pv("Hidden", True),)) +text = doc.Text +cur = text.createTextCursor() +text.insertString(cur, "body", False) +fn = doc.createInstance("com.sun.star.text.Footnote") +text.insertTextContent(cur, fn, False) +fn.String = "note text" +en = doc.createInstance("com.sun.star.text.Endnote") +text.insertTextContent(cur, en, False) +en.String = "end text" +text.insertString(cur, " ", False) +# (source: 3 footnote, 4 endnote), part: 0 page, 1 chapter, 2 text, 3 direction, 5/6/7 sequence-only +for src, note in ((3, fn), (4, en)): + for part in (0, 3, 2, 5, 6, 7): + f = doc.createInstance("com.sun.star.text.TextField.GetReference") + f.ReferenceFieldSource = src + f.SourceName = "" + f.SequenceNumber = note.ReferenceId + f.ReferenceFieldPart = part + text.insertTextContent(cur, f, False) + text.insertString(cur, " ", False) +doc.TextFields.refresh() +e = doc.TextFields.createEnumeration() +rows = [] +while e.hasMoreElements(): + f = e.nextElement() + if f.supportsService("com.sun.star.text.TextField.GetReference"): + rows.append([f.ReferenceFieldSource, f.ReferenceFieldPart, f.CurrentPresentation]) +json.dump(rows, open(exp, "w")) +doc.storeToURL(uno.systemPathToFileUrl(out), (pv("FilterName", "writer8"),)) +doc.close(True) diff --git a/test/odf-validate/fixtures/table-colspan/MergedTable_3_3.docx b/test/odf-validate/fixtures/table-colspan/MergedTable_3_3.docx new file mode 100644 index 0000000000..6fd7447bd4 Binary files /dev/null and b/test/odf-validate/fixtures/table-colspan/MergedTable_3_3.docx differ diff --git a/test/odf-validate/fixtures/table-colspan/checks.json b/test/odf-validate/fixtures/table-colspan/checks.json new file mode 100644 index 0000000000..25adf535e8 --- /dev/null +++ b/test/odf-validate/fixtures/table-colspan/checks.json @@ -0,0 +1,28 @@ +[ + { + "name": "cell_text", + "expr": "[(n, doc.TextTables.getByIndex(0).getCellByName(n).String) for n in doc.TextTables.getByIndex(0).CellNames]", + "expect": [ + [ + "A1", + "Merged top left two cells" + ], + [ + "A2", + "Bottom left" + ], + [ + "B2", + "Bottom center" + ] + ] + }, + { + "name": "rows_cols", + "expr": "(doc.TextTables.getByIndex(0).Rows.Count, doc.TextTables.getByIndex(0).Columns.Count)", + "expect": [ + 2, + 1 + ] + } +] \ No newline at end of file
