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 99fa0a57e1e27b18399c2171973129454080b9b6 Author: Jim Jagielski <[email protected]> AuthorDate: Fri Oct 23 09:34:04 2026 -0400 test/odf-validate: add fixtures for the ODF 1.2 mode gating, alien-attribute and connector viewBox fixes Also fill in the expected values of the para-fill fixture. --- .../fixtures/alien-attrs/alien-calc.ods | Bin 0 -> 7526 bytes .../fixtures/alien-attrs/alien-draw.odg | Bin 0 -> 8880 bytes .../fixtures/alien-attrs/alien-writer.odt | Bin 0 -> 9094 bytes test/odf-validate/fixtures/alien-attrs/make.py | 70 +++++ test/odf-validate/fixtures/alien-attrs/writer.json | 25 ++ .../fixtures/chart-shapes/chart-shapes.ods | Bin 0 -> 15985 bytes .../odf-validate/fixtures/chart-shapes/checks.json | 29 ++ test/odf-validate/fixtures/chart-shapes/make.py | 31 ++ .../fixtures/connector-viewbox/checks.json | 348 +++++++++++++++++++++ .../fixtures/connector-viewbox/conn.odg | Bin 0 -> 8642 bytes .../fixtures/connector-viewbox/conn.odp | Bin 0 -> 13927 bytes .../fixtures/connector-viewbox/make.py | 42 +++ test/odf-validate/fixtures/ole-text/checks.json | 18 ++ test/odf-validate/fixtures/ole-text/make.py | 19 ++ test/odf-validate/fixtures/ole-text/ole-text.odg | Bin 0 -> 11569 bytes test/odf-validate/fixtures/para-fill/bitmap.json | 22 +- test/odf-validate/fixtures/para-fill/checks.json | 216 ++++++++++++- test/odf-validate/fixtures/xforms-list/checks.json | 44 +++ test/odf-validate/fixtures/xforms-list/make.py | 18 ++ .../fixtures/xforms-list/xforms-list.odt | Bin 0 -> 21564 bytes 20 files changed, 877 insertions(+), 5 deletions(-) diff --git a/test/odf-validate/fixtures/alien-attrs/alien-calc.ods b/test/odf-validate/fixtures/alien-attrs/alien-calc.ods new file mode 100644 index 0000000000..47e2b1e51d Binary files /dev/null and b/test/odf-validate/fixtures/alien-attrs/alien-calc.ods differ diff --git a/test/odf-validate/fixtures/alien-attrs/alien-draw.odg b/test/odf-validate/fixtures/alien-attrs/alien-draw.odg new file mode 100644 index 0000000000..67e9eeda05 Binary files /dev/null and b/test/odf-validate/fixtures/alien-attrs/alien-draw.odg differ diff --git a/test/odf-validate/fixtures/alien-attrs/alien-writer.odt b/test/odf-validate/fixtures/alien-attrs/alien-writer.odt new file mode 100644 index 0000000000..e0ec343329 Binary files /dev/null and b/test/odf-validate/fixtures/alien-attrs/alien-writer.odt differ diff --git a/test/odf-validate/fixtures/alien-attrs/make.py b/test/odf-validate/fixtures/alien-attrs/make.py new file mode 100644 index 0000000000..311163a02a --- /dev/null +++ b/test/odf-validate/fixtures/alien-attrs/make.py @@ -0,0 +1,70 @@ +# usage: runpy.sh fixtures/alien-attrs/make.py <port> <outdir> (office saving ODF 1.2 Extended) +# Preserved alien attributes in ODF namespaces and in a foreign namespace on the carriers that keep them: +# Writer paragraph, character, section, table and table cell (item-set export path), Draw shape, Calc cell. +import sys, os, uno +from unohelp import connect, desktop, pv +from com.sun.star.awt import Size, Point + +port, outdir = int(sys.argv[1]), sys.argv[2] +d = desktop(connect(port)) +NS = {"text": "urn:oasis:names:tc:opendocument:xmlns:text:1.0", + "style": "urn:oasis:names:tc:opendocument:xmlns:style:1.0", + "draw": "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0", + "table": "urn:oasis:names:tc:opendocument:xmlns:table:1.0", + "office": "urn:oasis:names:tc:opendocument:xmlns:office:1.0", + "svg": "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0", + "fo": "http://www.w3.org/1999/XSL/Format", + "ex": "urn:example:foreign"} +ATTRS = (("text", "enable-numbering"), ("style", "alien-style"), ("draw", "alien-draw"), ("table", "alien-table"), + ("office", "alien-office"), ("svg", "alien-svg"), ("fo", "alien-fo"), ("ex", "alien-foreign")) + +def put(container): + for p, n in ATTRS: + a = uno.createUnoStruct("com.sun.star.xml.AttributeData") + a.Namespace = NS[p]; a.Type = "CDATA"; a.Value = "v-" + p + container.insertByName(p + ":" + n, a) + +def new(kind): + return d.loadComponentFromURL("private:factory/" + kind, "_blank", 0, (pv("Hidden", True),)) + +def save(doc, name, flt): + doc.storeToURL(uno.systemPathToFileUrl(os.path.join(outdir, name)), (pv("FilterName", flt),)) + doc.close(True) + +doc = new("swriter") +text = doc.Text +cur = text.createTextCursor() +text.insertString(cur, "para text", False) +text.insertControlCharacter(cur, 0, False) +cur.gotoStart(False); cur.goRight(4, True) +cont = cur.ParaUserDefinedAttributes +put(cont); cur.ParaUserDefinedAttributes = cont +cont = cur.TextUserDefinedAttributes +put(cont); cur.TextUserDefinedAttributes = cont +cur.gotoEnd(False) +tbl = doc.createInstance("com.sun.star.text.TextTable") +tbl.initialize(2, 2) +text.insertTextContent(cur, tbl, False) +for tgt in (tbl, tbl.getCellByName("A1")): + cont = tgt.UserDefinedAttributes + put(cont); tgt.UserDefinedAttributes = cont +sec = doc.createInstance("com.sun.star.text.TextSection") +text.insertTextContent(text.End, sec, False) +cont = sec.UserDefinedAttributes +put(cont); sec.UserDefinedAttributes = cont +save(doc, "alien-writer.odt", "writer8") + +doc = new("sdraw") +page = doc.DrawPages.getByIndex(0) +s = doc.createInstance("com.sun.star.drawing.RectangleShape") +page.add(s); s.Position = Point(2000, 2000); s.Size = Size(4000, 2000); s.String = "alien" +cont = s.UserDefinedAttributes +put(cont); s.UserDefinedAttributes = cont +save(doc, "alien-draw.odg", "draw8") + +doc = new("scalc") +c = doc.Sheets.getByIndex(0).getCellByPosition(0, 0) +c.Value = 1 +cont = c.UserDefinedAttributes +put(cont); c.UserDefinedAttributes = cont +save(doc, "alien-calc.ods", "calc8") diff --git a/test/odf-validate/fixtures/alien-attrs/writer.json b/test/odf-validate/fixtures/alien-attrs/writer.json new file mode 100644 index 0000000000..91920487e0 --- /dev/null +++ b/test/odf-validate/fixtures/alien-attrs/writer.json @@ -0,0 +1,25 @@ +[ + { + "name": "writer_aliens", + "expr": "[sorted(doc.Text.createTextCursor().ParaUserDefinedAttributes.ElementNames), sorted(doc.TextTables.getByIndex(0).UserDefinedAttributes.ElementNames), sorted(doc.TextSections.getByIndex(0).UserDefinedAttributes.ElementNames)]", + "expect": [ + [ + "ex:alien-foreign", + "text:enable-numbering" + ], + [ + "draw:alien-draw", + "ex:alien-foreign", + "fo:alien-fo", + "office:alien-office", + "style:alien-style", + "svg:alien-svg", + "table:alien-table", + "text:enable-numbering" + ], + [ + "ex:alien-foreign" + ] + ] + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/chart-shapes/chart-shapes.ods b/test/odf-validate/fixtures/chart-shapes/chart-shapes.ods new file mode 100644 index 0000000000..ad670e09ad Binary files /dev/null and b/test/odf-validate/fixtures/chart-shapes/chart-shapes.ods differ diff --git a/test/odf-validate/fixtures/chart-shapes/checks.json b/test/odf-validate/fixtures/chart-shapes/checks.json new file mode 100644 index 0000000000..ea35f87cfb --- /dev/null +++ b/test/odf-validate/fixtures/chart-shapes/checks.json @@ -0,0 +1,29 @@ +[ + { + "name": "chart_shapes", + "expr": "[[s.ShapeType, getattr(s, 'String', None)] for s in [doc.Sheets.getByIndex(0).Charts.getByIndex(0).EmbeddedObject.DrawPage.getByIndex(i) for i in range(doc.Sheets.getByIndex(0).Charts.getByIndex(0).EmbeddedObject.DrawPage.Count)]]", + "expect": [ + [ + "com.sun.star.drawing.GroupShape", + null + ], + [ + "com.sun.star.drawing.PolyLineShape", + "" + ], + [ + "com.sun.star.drawing.RectangleShape", + "rect" + ], + [ + "com.sun.star.drawing.TextShape", + "note" + ] + ] + }, + { + "name": "chart_type", + "expr": "doc.Sheets.getByIndex(0).Charts.getByIndex(0).EmbeddedObject.getDiagram().getDiagramType()", + "expect": "com.sun.star.chart.BarDiagram" + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/chart-shapes/make.py b/test/odf-validate/fixtures/chart-shapes/make.py new file mode 100644 index 0000000000..bc0213e3a2 --- /dev/null +++ b/test/odf-validate/fixtures/chart-shapes/make.py @@ -0,0 +1,31 @@ +# usage: runpy.sh fixtures/chart-shapes/make.py <port> <out.ods> (office saving ODF 1.2 Extended) +# Calc chart with additional shapes (polyline, rectangle, text) in the chart draw page. +import sys, uno +from unohelp import connect, desktop, pv +from com.sun.star.awt import Size, Point, Rectangle +from com.sun.star.table import CellRangeAddress + +port, out = int(sys.argv[1]), sys.argv[2] +d = desktop(connect(port)) +doc = d.loadComponentFromURL("private:factory/scalc", "_blank", 0, (pv("Hidden", True),)) +sh = doc.Sheets.getByIndex(0) +for r, (a, b) in enumerate(((1, 2), (2, 4), (3, 3))): + sh.getCellByPosition(0, r).Value = a + sh.getCellByPosition(1, r).Value = b +rng = CellRangeAddress(); rng.Sheet = 0; rng.StartColumn = 0; rng.StartRow = 0; rng.EndColumn = 1; rng.EndRow = 2 +r = Rectangle(); r.X = 1000; r.Y = 4000; r.Width = 10000; r.Height = 7000 +sh.Charts.addNewByName("c1", r, (rng,), False, False) +ch = sh.Charts.getByName("c1").EmbeddedObject +page = ch.DrawPage +from com.sun.star.awt import Point as P +def mk(kind, x, y, w, h): + s = ch.createInstance(kind) + page.add(s) + s.Position = Point(x, y); s.Size = Size(w, h) + return s +pl = mk("com.sun.star.drawing.PolyLineShape", 500, 500, 3000, 1500) +pl.PolyPolygon = ((P(0, 1500), P(1000, 500), P(3000, 0)),) +mk("com.sun.star.drawing.RectangleShape", 4000, 500, 2000, 1000).String = "rect" +mk("com.sun.star.drawing.TextShape", 6500, 500, 2000, 800).String = "note" +doc.storeToURL(uno.systemPathToFileUrl(out), (pv("FilterName", "calc8"),)) +doc.close(True) diff --git a/test/odf-validate/fixtures/connector-viewbox/checks.json b/test/odf-validate/fixtures/connector-viewbox/checks.json new file mode 100644 index 0000000000..cf49ec87b2 --- /dev/null +++ b/test/odf-validate/fixtures/connector-viewbox/checks.json @@ -0,0 +1,348 @@ +[ + { + "name": "connectors", + "expr": "[[s.Name, s.StartPosition.X, s.StartPosition.Y, s.EndPosition.X, s.EndPosition.Y, s.EdgeKind.value, [[[p.X, p.Y] for p in seg] for seg in s.PolyPolygonBezier.Coordinates], [[f.value for f in seg] for seg in s.PolyPolygonBezier.Flags], (s.StartShape.Position.X if s.StartShape else None), (s.EndShape.Position.X if s.EndShape else None), s.StartGluePointIndex, s.EndGluePointIndex] for s in [doc.DrawPages.getByIndex(0).getByIndex(i) for i in range(doc.DrawPages.getByIndex(0).Count [...] + "expect": [ + [ + "std_free", + 2000, + 2000, + 8000, + 6000, + "STANDARD", + [ + [ + [ + 2000, + 2000 + ], + [ + 5000, + 2000 + ], + [ + 5000, + 6000 + ], + [ + 8000, + 6000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL", + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "curve_free", + 10000, + 2000, + 16000, + 6000, + "CURVE", + [ + [ + [ + 10000, + 2000 + ], + [ + 14500, + 2000 + ], + [ + 11500, + 6000 + ], + [ + 16000, + 6000 + ] + ] + ], + [ + [ + "NORMAL", + "CONTROL", + "CONTROL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "line_h", + 2000, + 8000, + 8000, + 8000, + "LINE", + [ + [ + [ + 2000, + 8000 + ], + [ + 8000, + 8000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "line_v", + 10000, + 8000, + 10000, + 11000, + "LINE", + [ + [ + [ + 10000, + 8000 + ], + [ + 10000, + 11000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "line_rev", + 18000, + 9000, + 14000, + 5000, + "LINE", + [ + [ + [ + 18000, + 9000 + ], + [ + 14000, + 5000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "std_h", + 2000, + 28000, + 8000, + 28000, + "STANDARD", + [ + [ + [ + 2000, + 28000 + ], + [ + 8000, + 28000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "std_v", + 16000, + 28000, + 16000, + 32000, + "STANDARD", + [ + [ + [ + 16000, + 28000 + ], + [ + 16000, + 32000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "std_conn", + 4000, + 13000, + 12000, + 17000, + "STANDARD", + [ + [ + [ + 4000, + 13000 + ], + [ + 8000, + 13000 + ], + [ + 8000, + 17000 + ], + [ + 12000, + 17000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL", + "NORMAL", + "NORMAL" + ] + ], + 1000, + 12000, + -1, + -1 + ], + [ + "curve_conn", + 4000, + 21000, + 9000, + 25000, + "CURVE", + [ + [ + [ + 4000, + 21000 + ], + [ + 7750, + 21000 + ], + [ + 5250, + 25000 + ], + [ + 9000, + 25000 + ] + ] + ], + [ + [ + "NORMAL", + "CONTROL", + "CONTROL", + "NORMAL" + ] + ], + 1000, + 9000, + -1, + -1 + ], + [ + "lines_free", + 2000, + 34000, + 9000, + 38000, + "LINES", + [ + [ + [ + 2000, + 34000 + ], + [ + 9000, + 38000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ] + ] + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/connector-viewbox/conn.odg b/test/odf-validate/fixtures/connector-viewbox/conn.odg new file mode 100644 index 0000000000..163be71dc6 Binary files /dev/null and b/test/odf-validate/fixtures/connector-viewbox/conn.odg differ diff --git a/test/odf-validate/fixtures/connector-viewbox/conn.odp b/test/odf-validate/fixtures/connector-viewbox/conn.odp new file mode 100644 index 0000000000..755929c3e1 Binary files /dev/null and b/test/odf-validate/fixtures/connector-viewbox/conn.odp differ diff --git a/test/odf-validate/fixtures/connector-viewbox/make.py b/test/odf-validate/fixtures/connector-viewbox/make.py new file mode 100644 index 0000000000..3056b9c0a3 --- /dev/null +++ b/test/odf-validate/fixtures/connector-viewbox/make.py @@ -0,0 +1,42 @@ +# usage: runpy.sh fixtures/connector-viewbox/make.py <port> <outdir> (office saving ODF 1.2 Extended) +# Connectors of every kind, connected and free, axis-aligned and diagonal, in Draw and Impress. +import sys, os, uno +from unohelp import connect, desktop, pv +from com.sun.star.awt import Size, Point +from com.sun.star.drawing.ConnectorType import STANDARD, CURVE, LINE, LINES + +port, outdir = int(sys.argv[1]), sys.argv[2] +d = desktop(connect(port)) + +def build(doc, page): + def rect(x, y, w, h): + s = doc.createInstance("com.sun.star.drawing.RectangleShape") + page.add(s); s.Position = Point(x, y); s.Size = Size(w, h) + return s + def conn(kind, a, b, name): + c = doc.createInstance("com.sun.star.drawing.ConnectorShape") + page.add(c); c.EdgeKind = kind + c.StartPosition = Point(*a); c.EndPosition = Point(*b) + c.Name = name + return c + r1 = rect(1000, 12000, 3000, 2000); r2 = rect(12000, 16000, 3000, 2000) + r3 = rect(1000, 20000, 3000, 2000); r4 = rect(9000, 24000, 3000, 2000) + conn(STANDARD, (2000, 2000), (8000, 6000), "std_free") + conn(CURVE, (10000, 2000), (16000, 6000), "curve_free") + conn(LINE, (2000, 8000), (8000, 8000), "line_h") + conn(LINE, (10000, 8000), (10000, 11000), "line_v") + conn(LINE, (18000, 9000), (14000, 5000), "line_rev") + conn(STANDARD, (2000, 28000), (8000, 28000), "std_h") + conn(STANDARD, (16000, 28000), (16000, 32000), "std_v") + c = conn(STANDARD, (0, 0), (0, 0), "std_conn"); c.StartShape = r1; c.EndShape = r2 + c = conn(CURVE, (0, 0), (0, 0), "curve_conn"); c.StartShape = r3; c.EndShape = r4 + c = conn(LINES, (2000, 34000), (9000, 38000), "lines_free") + +def save(doc, name, flt): + doc.storeToURL(uno.systemPathToFileUrl(os.path.join(outdir, name)), (pv("FilterName", flt),)) + doc.close(True) + +for kind, name, flt in (("sdraw", "conn.odg", "draw8"), ("simpress", "conn.odp", "impress8")): + doc = d.loadComponentFromURL("private:factory/" + kind, "_blank", 0, (pv("Hidden", True),)) + build(doc, doc.DrawPages.getByIndex(0)) + save(doc, name, flt) diff --git a/test/odf-validate/fixtures/ole-text/checks.json b/test/odf-validate/fixtures/ole-text/checks.json new file mode 100644 index 0000000000..b14519c5d8 --- /dev/null +++ b/test/odf-validate/fixtures/ole-text/checks.json @@ -0,0 +1,18 @@ +[ + { + "name": "ole", + "expr": "[[s.ShapeType, s.String, s.CLSID] for s in [doc.DrawPages.getByIndex(0).getByIndex(i) for i in range(doc.DrawPages.getByIndex(0).Count)]]", + "expect": [ + [ + "com.sun.star.drawing.OLE2Shape", + "", + "078B7ABA-54FC-457F-8551-6147e776a997" + ], + [ + "com.sun.star.drawing.OLE2Shape", + "OLE label", + "078B7ABA-54FC-457F-8551-6147e776a997" + ] + ] + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/ole-text/make.py b/test/odf-validate/fixtures/ole-text/make.py new file mode 100644 index 0000000000..9493b316e4 --- /dev/null +++ b/test/odf-validate/fixtures/ole-text/make.py @@ -0,0 +1,19 @@ +# usage: runpy.sh fixtures/ole-text/make.py <port> <out.odg> (office saving ODF 1.2 Extended) +# Draw page with an OLE object without text and one with text. +import sys, uno +from unohelp import connect, desktop, pv +from com.sun.star.awt import Size, Point + +port, out = int(sys.argv[1]), sys.argv[2] +d = desktop(connect(port)) +doc = d.loadComponentFromURL("private:factory/sdraw", "_blank", 0, (pv("Hidden", True),)) +page = doc.DrawPages.getByIndex(0) +for i, text in enumerate(("", "OLE label")): + s = doc.createInstance("com.sun.star.drawing.OLE2Shape") + s.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997" + page.add(s) + s.Position = Point(2000 + i * 8000, 2000); s.Size = Size(5000, 3000) + if text: + s.String = text +doc.storeToURL(uno.systemPathToFileUrl(out), (pv("FilterName", "draw8"),)) +doc.close(True) diff --git a/test/odf-validate/fixtures/ole-text/ole-text.odg b/test/odf-validate/fixtures/ole-text/ole-text.odg new file mode 100644 index 0000000000..d533db4d22 Binary files /dev/null and b/test/odf-validate/fixtures/ole-text/ole-text.odg differ diff --git a/test/odf-validate/fixtures/para-fill/bitmap.json b/test/odf-validate/fixtures/para-fill/bitmap.json index d3aec5af16..d8e76539e7 100644 --- a/test/odf-validate/fixtures/para-fill/bitmap.json +++ b/test/odf-validate/fixtures/para-fill/bitmap.json @@ -1,10 +1,28 @@ [ { "name": "para_bitmap", - "expr": "[(p.String, ('GraphicObject:0000' not in u and 'GraphicObject:' in u), p.FillStyle.value) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None) if p.String.endswith('bitmap') for u in [p.ParaBackGraphicURL]]" + "expr": "[(p.String, ('GraphicObject:0000' not in u and 'GraphicObject:' in u), p.FillStyle.value) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None) if p.String.endswith('bitmap') for u in [p.ParaBackGraphicURL]]", + "expect": [ + [ + "direct bitmap", + false, + "BITMAP" + ], + [ + "styled bitmap", + true, + "BITMAP" + ] + ] }, { "name": "parastyle_bitmap", - "expr": "[(('GraphicObject:0000' not in u and 'GraphicObject:' in u), s.FillStyle.value) for s in [doc.StyleFamilies.getByName('ParagraphStyles').getByName('S_bitmap')] for u in [s.ParaBackGraphicURL]]" + "expr": "[(('GraphicObject:0000' not in u and 'GraphicObject:' in u), s.FillStyle.value) for s in [doc.StyleFamilies.getByName('ParagraphStyles').getByName('S_bitmap')] for u in [s.ParaBackGraphicURL]]", + "expect": [ + [ + true, + "BITMAP" + ] + ] } ] \ No newline at end of file diff --git a/test/odf-validate/fixtures/para-fill/checks.json b/test/odf-validate/fixtures/para-fill/checks.json index ab620fc15c..3e81cba128 100644 --- a/test/odf-validate/fixtures/para-fill/checks.json +++ b/test/odf-validate/fixtures/para-fill/checks.json @@ -1,14 +1,224 @@ [ { "name": "paragraphs", - "expr": "[(p.String, p.ParaBackColor, p.ParaBackTransparent, p.FillStyle.value, p.FillColor, p.FillTransparence) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None)]" + "expr": "[(p.String, p.ParaBackColor, p.ParaBackTransparent, p.FillStyle.value, p.FillColor, p.FillTransparence) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None)]", + "expect": [ + [ + "direct solid", + -3151883, + true, + "NONE", + 13625333, + 0 + ], + [ + "styled solid", + 16763904, + false, + "SOLID", + 16763904, + 0 + ], + [ + "direct solid_fill", + 3385941, + false, + "SOLID", + 3385941, + 0 + ], + [ + "styled solid_fill", + 3385941, + false, + "SOLID", + 3385941, + 0 + ], + [ + "direct solid_transp", + 1697863082, + false, + "SOLID", + 3364266, + 40 + ], + [ + "styled solid_transp", + 1697863082, + false, + "SOLID", + 3364266, + 40 + ], + [ + "direct gradient", + 8421504, + false, + "GRADIENT", + 13625333, + 0 + ], + [ + "styled gradient", + 8388736, + false, + "GRADIENT", + 13625333, + 0 + ], + [ + "direct hatch", + 16777164, + false, + "HATCH", + 16777164, + 0 + ], + [ + "styled hatch", + 16777164, + false, + "HATCH", + 16777164, + 0 + ], + [ + "direct bitmap", + -1, + true, + "BITMAP", + 13625333, + 0 + ], + [ + "styled bitmap", + -1, + true, + "BITMAP", + 13625333, + 0 + ], + [ + "", + -3151883, + true, + "NONE", + 13625333, + 0 + ] + ] }, { "name": "para_styles", - "expr": "[(n, p.ParaBackColor, p.ParaBackTransparent, p.FillStyle.value, p.FillColor, p.FillTransparence) for n in doc.StyleFamilies.getByName('ParagraphStyles').ElementNames if n.startswith('S_') for p in [doc.StyleFamilies.getByName('ParagraphStyles').getByName(n)]]" + "expr": "[(n, p.ParaBackColor, p.ParaBackTransparent, p.FillStyle.value, p.FillColor, p.FillTransparence) for n in doc.StyleFamilies.getByName('ParagraphStyles').ElementNames if n.startswith('S_') for p in [doc.StyleFamilies.getByName('ParagraphStyles').getByName(n)]]", + "expect": [ + [ + "S_solid", + 16763904, + false, + "SOLID", + 16763904, + 0 + ], + [ + "S_solid_fill", + 3385941, + false, + "SOLID", + 3385941, + 0 + ], + [ + "S_solid_transp", + 1697863082, + false, + "SOLID", + 3364266, + 40 + ], + [ + "S_gradient", + 8388736, + false, + "GRADIENT", + 13625333, + 0 + ], + [ + "S_hatch", + 16777164, + false, + "HATCH", + 16777164, + 0 + ], + [ + "S_bitmap", + -1, + true, + "BITMAP", + 13625333, + 0 + ] + ] }, { "name": "styled_para_style_names", - "expr": "[(p.String, p.ParaStyleName) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None)]" + "expr": "[(p.String, p.ParaStyleName) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None)]", + "expect": [ + [ + "direct solid", + "Standard" + ], + [ + "styled solid", + "S_solid" + ], + [ + "direct solid_fill", + "Standard" + ], + [ + "styled solid_fill", + "S_solid_fill" + ], + [ + "direct solid_transp", + "Standard" + ], + [ + "styled solid_transp", + "S_solid_transp" + ], + [ + "direct gradient", + "Standard" + ], + [ + "styled gradient", + "S_gradient" + ], + [ + "direct hatch", + "Standard" + ], + [ + "styled hatch", + "S_hatch" + ], + [ + "direct bitmap", + "Standard" + ], + [ + "styled bitmap", + "S_bitmap" + ], + [ + "", + "Standard" + ] + ] } ] \ No newline at end of file diff --git a/test/odf-validate/fixtures/xforms-list/checks.json b/test/odf-validate/fixtures/xforms-list/checks.json new file mode 100644 index 0000000000..ed11b54737 --- /dev/null +++ b/test/odf-validate/fixtures/xforms-list/checks.json @@ -0,0 +1,44 @@ +[ + { + "name": "controls", + "expr": "[[doc.DrawPage.Forms.getByIndex(f).getByIndex(i).Name, doc.DrawPage.Forms.getByIndex(f).getByIndex(i).ClassId, doc.DrawPage.Forms.getByIndex(f).getByIndex(i).getValueBinding() is not None, doc.DrawPage.Forms.getByIndex(f).getByIndex(i).getListEntrySource() is not None] for f in range(doc.DrawPage.Forms.Count) for i in range(doc.DrawPage.Forms.getByIndex(f).Count) if doc.DrawPage.Forms.getByIndex(f).getByIndex(i).ClassId in (6, 7)]", + "expect": [ + [ + "ComboBox", + 7, + true, + true + ], + [ + "ListBox1", + 6, + true, + true + ], + [ + "ComboBox2", + 7, + true, + false + ], + [ + "ComboBox3", + 7, + true, + false + ], + [ + "ComboBox4", + 7, + true, + false + ], + [ + "ComboBox5", + 7, + true, + false + ] + ] + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/xforms-list/make.py b/test/odf-validate/fixtures/xforms-list/make.py new file mode 100644 index 0000000000..685ead72f2 --- /dev/null +++ b/test/odf-validate/fixtures/xforms-list/make.py @@ -0,0 +1,18 @@ +# usage: python3 -I fixtures/xforms-list/make.py <xforms-ubl.odt> <out.odt> +# Derives a document with a combobox and a listbox that both have form:xforms-list-source. +import re, sys, zipfile + +src, out = sys.argv[1], sys.argv[2] +zin = zipfile.ZipFile(src) +zout = zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) +for info in zin.infolist(): + data = zin.read(info.filename) + if info.filename == "content.xml": + s = data.decode("utf-8") + m = re.search(r'<form:combobox form:name="ComboBox1"[^>]*>.*?</form:combobox>', s, re.S) + assert m, "ComboBox1 not found" + lb = '<form:listbox form:name="ListBox1" form:control-implementation="ooo:com.sun.star.form.component.ListBox" form:id="control50" form:dropdown="true" form:tab-index="29" xforms:bind="Bindung 45" form:xforms-list-source="currencies"/>' + s = s[:m.start()] + lb + s[m.end():] + data = s.encode("utf-8") + zout.writestr(info, data, zipfile.ZIP_STORED if info.filename == "mimetype" else zipfile.ZIP_DEFLATED) +zout.close() diff --git a/test/odf-validate/fixtures/xforms-list/xforms-list.odt b/test/odf-validate/fixtures/xforms-list/xforms-list.odt new file mode 100644 index 0000000000..9734e631e3 Binary files /dev/null and b/test/odf-validate/fixtures/xforms-list/xforms-list.odt differ
