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 22f5c9e469ffa3f8f450077c87eeb24dc27733d3 Author: Jim Jagielski <[email protected]> AuthorDate: Fri Oct 23 08:51:38 2026 -0400 test/odf-validate: add fixtures for the ODF 1.2 mode fill, grid-snap and row-split fixes --- test/odf-validate/fixtures/fill-others/calc.json | 14 +++ test/odf-validate/fixtures/fill-others/draw.json | 10 +++ .../odf-validate/fixtures/fill-others/impress.json | 10 +++ test/odf-validate/fixtures/fill-others/make.py | 98 +++++++++++++++++++++ .../fixtures/fill-others/others-calc.ods | Bin 0 -> 9160 bytes .../fixtures/fill-others/others-draw.odg | Bin 0 -> 9758 bytes .../fixtures/fill-others/others-impress.odp | Bin 0 -> 14795 bytes .../fixtures/fill-others/others-writer.odt | Bin 0 -> 9604 bytes test/odf-validate/fixtures/fill-others/writer.json | 18 ++++ test/odf-validate/fixtures/grid-snap/checks.json | 6 ++ test/odf-validate/fixtures/grid-snap/grid-snap.odt | Bin 0 -> 8918 bytes test/odf-validate/fixtures/grid-snap/make.py | 35 ++++++++ test/odf-validate/fixtures/page-fill/bitmap.json | 6 ++ test/odf-validate/fixtures/page-fill/checks.json | 14 +++ test/odf-validate/fixtures/page-fill/make.py | 60 +++++++++++++ test/odf-validate/fixtures/page-fill/page-fill.odt | Bin 0 -> 9916 bytes test/odf-validate/fixtures/para-fill/bitmap.json | 10 +++ test/odf-validate/fixtures/para-fill/checks.json | 14 +++ test/odf-validate/fixtures/para-fill/make.py | 65 ++++++++++++++ test/odf-validate/fixtures/para-fill/para-fill.odt | Bin 0 -> 12883 bytes test/odf-validate/fixtures/row-split/checks.json | 11 +++ test/odf-validate/fixtures/row-split/make.py | 17 ++++ test/odf-validate/fixtures/row-split/row-split.odt | Bin 0 -> 8704 bytes 23 files changed, 388 insertions(+) diff --git a/test/odf-validate/fixtures/fill-others/calc.json b/test/odf-validate/fixtures/fill-others/calc.json new file mode 100644 index 0000000000..add9a3ccd9 --- /dev/null +++ b/test/odf-validate/fixtures/fill-others/calc.json @@ -0,0 +1,14 @@ +[ + { + "name": "cell", + "expr": "[(c.String, c.CellBackColor, c.IsCellBackgroundTransparent) for c in [doc.Sheets.getByIndex(0).getCellByPosition(0,0), doc.Sheets.getByIndex(0).getCellByPosition(2,2)]]" + }, + { + "name": "page_style", + "expr": "[(s.BackColor, s.IsBackgroundTransparent) for s in [doc.StyleFamilies.getByName('PageStyles').getByName('Default')]]" + }, + { + "name": "shapes", + "expr": "[(s.String, s.FillStyle.value, s.FillColor, s.FillGradient.StartColor, s.FillGradient.EndColor, s.FillTransparence) for i in range(doc.Sheets.getByIndex(0).DrawPage.Count) for s in [doc.Sheets.getByIndex(0).DrawPage.getByIndex(i)]]" + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/fill-others/draw.json b/test/odf-validate/fixtures/fill-others/draw.json new file mode 100644 index 0000000000..e27850cfe8 --- /dev/null +++ b/test/odf-validate/fixtures/fill-others/draw.json @@ -0,0 +1,10 @@ +[ + { + "name": "shapes", + "expr": "[(s.String, s.FillStyle.value, s.FillColor, s.FillGradient.StartColor, s.FillGradient.EndColor, s.FillTransparence) for i in range(doc.DrawPages.getByIndex(0).Count) for s in [doc.DrawPages.getByIndex(0).getByIndex(i)]]" + }, + { + "name": "background", + "expr": "[(b.FillStyle.value, b.FillColor, b.FillGradient.StartColor, b.FillGradient.EndColor) for b in [doc.DrawPages.getByIndex(0).Background]] if doc.DrawPages.getByIndex(0).Background is not None else None" + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/fill-others/impress.json b/test/odf-validate/fixtures/fill-others/impress.json new file mode 100644 index 0000000000..e27850cfe8 --- /dev/null +++ b/test/odf-validate/fixtures/fill-others/impress.json @@ -0,0 +1,10 @@ +[ + { + "name": "shapes", + "expr": "[(s.String, s.FillStyle.value, s.FillColor, s.FillGradient.StartColor, s.FillGradient.EndColor, s.FillTransparence) for i in range(doc.DrawPages.getByIndex(0).Count) for s in [doc.DrawPages.getByIndex(0).getByIndex(i)]]" + }, + { + "name": "background", + "expr": "[(b.FillStyle.value, b.FillColor, b.FillGradient.StartColor, b.FillGradient.EndColor) for b in [doc.DrawPages.getByIndex(0).Background]] if doc.DrawPages.getByIndex(0).Background is not None else None" + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/fill-others/make.py b/test/odf-validate/fixtures/fill-others/make.py new file mode 100644 index 0000000000..cd8a6075ac --- /dev/null +++ b/test/odf-validate/fixtures/fill-others/make.py @@ -0,0 +1,98 @@ +# usage: runpy.sh fixtures/fill-others/make.py <port> <outdir> (office saving ODF 1.2 Extended) +# Other consumers of fills: Writer frame/table/section, Calc cell/page/shape, Draw shape/page, Impress shape/slide. +import sys, os, uno +from unohelp import connect, desktop, pv +from com.sun.star.awt import Gradient, Rectangle +from com.sun.star.awt.GradientStyle import LINEAR +from com.sun.star.drawing.FillStyle import SOLID, GRADIENT +from com.sun.star.awt import Size, Point + +port, outdir = int(sys.argv[1]), sys.argv[2] +d = desktop(connect(port)) + +def grad(): + g = Gradient(); g.Style = LINEAR; g.StartColor = 0xFF0000; g.EndColor = 0x0000FF + g.Angle = 0; g.Border = 0; g.XOffset = 50; g.YOffset = 50 + g.StartIntensity = 100; g.EndIntensity = 100; g.StepCount = 0 + return g + +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) + +def shape(doc, page, x, y, kind, text, fillkind): + s = doc.createInstance(kind) + page.add(s) + s.Position = Point(x, y); s.Size = Size(4000, 2000) + s.String = text + if fillkind == "solid": + s.FillStyle = SOLID; s.FillColor = 0x33AA55 + else: + s.FillStyle = GRADIENT; s.FillGradient = grad() + return s + +# Writer: frame, table cell, section, with solid and gradient fills +doc = new("swriter") +text = doc.Text +cur = text.createTextCursor() +for i, fk in enumerate(("solid", "gradient")): + fr = doc.createInstance("com.sun.star.text.TextFrame") + fr.Width = 4000; fr.Height = 1500 + text.insertTextContent(cur, fr, False) + fr.Text.String = "frame " + fk + if fk == "solid": + fr.FillStyle = SOLID; fr.FillColor = 0x33AA55 + else: + fr.FillStyle = GRADIENT; fr.FillGradient = grad() +tbl = doc.createInstance("com.sun.star.text.TextTable") +tbl.initialize(2, 2) +text.insertTextContent(text.End, tbl, False) +tbl.getCellByName("A1").BackColor = 0xFFCC00 +tbl.getCellByName("B1").BackColor = 0xFFAACC +tbl.BackColor = 0xCCFFCC +sec = doc.createInstance("com.sun.star.text.TextSection") +text.insertTextContent(text.End, sec, False) +sec.BackColor = 0xCCCCFF +save(doc, "others-writer.odt", "writer8") + +# Calc: cell back colour, page style back colour, shape with gradient and with text +doc = new("scalc") +sh = doc.Sheets.getByIndex(0) +sh.getCellByPosition(0, 0).String = "cell" +sh.getCellByPosition(0, 0).CellBackColor = 0xFFCC00 +sh.getCellByPosition(1, 0).String = "grad" +pst = doc.StyleFamilies.getByName("PageStyles").getByName("Default") +pst.BackColor = 0xDDEEFF +dp = sh.DrawPage +shape(doc, dp, 1000, 3000, "com.sun.star.drawing.RectangleShape", "calc shape", "gradient") +save(doc, "others-calc.ods", "calc8") + +# Draw: shapes (solid and gradient), page background +doc = new("sdraw") +page = doc.DrawPages.getByIndex(0) +shape(doc, page, 1000, 1000, "com.sun.star.drawing.RectangleShape", "draw solid", "solid") +shape(doc, page, 6000, 1000, "com.sun.star.drawing.EllipseShape", "draw grad", "gradient") +try: + page.Background = None + bg = doc.createInstance("com.sun.star.drawing.Background") + bg.FillStyle = GRADIENT; bg.FillGradient = grad() + page.Background = bg +except Exception as e: + print("draw background:", repr(e)) +save(doc, "others-draw.odg", "draw8") + +# Impress: shapes with text, slide background +doc = new("simpress") +page = doc.DrawPages.getByIndex(0) +shape(doc, page, 1000, 1000, "com.sun.star.drawing.RectangleShape", "impress solid", "solid") +shape(doc, page, 6000, 1000, "com.sun.star.drawing.RectangleShape", "impress grad", "gradient") +try: + bg = doc.createInstance("com.sun.star.drawing.Background") + bg.FillStyle = SOLID; bg.FillColor = 0xCCEEFF + page.Background = bg +except Exception as e: + print("impress background:", repr(e)) +save(doc, "others-impress.odp", "impress8") diff --git a/test/odf-validate/fixtures/fill-others/others-calc.ods b/test/odf-validate/fixtures/fill-others/others-calc.ods new file mode 100644 index 0000000000..b445eb388d Binary files /dev/null and b/test/odf-validate/fixtures/fill-others/others-calc.ods differ diff --git a/test/odf-validate/fixtures/fill-others/others-draw.odg b/test/odf-validate/fixtures/fill-others/others-draw.odg new file mode 100644 index 0000000000..9d4705b967 Binary files /dev/null and b/test/odf-validate/fixtures/fill-others/others-draw.odg differ diff --git a/test/odf-validate/fixtures/fill-others/others-impress.odp b/test/odf-validate/fixtures/fill-others/others-impress.odp new file mode 100644 index 0000000000..468b1e09a7 Binary files /dev/null and b/test/odf-validate/fixtures/fill-others/others-impress.odp differ diff --git a/test/odf-validate/fixtures/fill-others/others-writer.odt b/test/odf-validate/fixtures/fill-others/others-writer.odt new file mode 100644 index 0000000000..d25e0ad310 Binary files /dev/null and b/test/odf-validate/fixtures/fill-others/others-writer.odt differ diff --git a/test/odf-validate/fixtures/fill-others/writer.json b/test/odf-validate/fixtures/fill-others/writer.json new file mode 100644 index 0000000000..b769f610e2 --- /dev/null +++ b/test/odf-validate/fixtures/fill-others/writer.json @@ -0,0 +1,18 @@ +[ + { + "name": "frames", + "expr": "[(f.Text.String, f.FillStyle.value, f.FillColor, f.FillGradient.StartColor, f.FillGradient.EndColor, f.BackColor, f.BackTransparent) for n in doc.TextFrames.ElementNames for f in [doc.TextFrames.getByName(n)]]" + }, + { + "name": "table", + "expr": "[(c, t.getCellByName(c).BackColor, t.getCellByName(c).BackTransparent) for t in [doc.TextTables.getByIndex(0)] for c in ('A1','B1','A2')] + [doc.TextTables.getByIndex(0).BackColor]" + }, + { + "name": "section", + "expr": "[(s.BackColor, s.BackTransparent) for s in [doc.TextSections.getByIndex(0)]]" + }, + { + "name": "paras", + "expr": "[(p.String, p.ParaBackColor, p.ParaBackTransparent) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None) if p.supportsService('com.sun.star.text.Paragraph')]" + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/grid-snap/checks.json b/test/odf-validate/fixtures/grid-snap/checks.json new file mode 100644 index 0000000000..a69da6680b --- /dev/null +++ b/test/odf-validate/fixtures/grid-snap/checks.json @@ -0,0 +1,6 @@ +[ + { + "name": "page_grid", + "expr": "[(n, ps.GridMode, ps.StandardPageMode, ps.GridBaseWidth, ps.GridSnapToChars) for n in ('G_snap_on','G_snap_off','G_lines_off') for ps in [doc.StyleFamilies.getByName('PageStyles').getByName(n)]]" + } +] diff --git a/test/odf-validate/fixtures/grid-snap/grid-snap.odt b/test/odf-validate/fixtures/grid-snap/grid-snap.odt new file mode 100644 index 0000000000..358c1d1924 Binary files /dev/null and b/test/odf-validate/fixtures/grid-snap/grid-snap.odt differ diff --git a/test/odf-validate/fixtures/grid-snap/make.py b/test/odf-validate/fixtures/grid-snap/make.py new file mode 100644 index 0000000000..73f6d339de --- /dev/null +++ b/test/odf-validate/fixtures/grid-snap/make.py @@ -0,0 +1,35 @@ +# usage: runpy.sh fixtures/grid-snap/make.py <port> <out.odt> (office saving ODF 1.2 Extended) +import sys, uno +from unohelp import connect, desktop, pv + +port, out = int(sys.argv[1]), sys.argv[2] +d = desktop(connect(port)) +doc = d.loadComponentFromURL("private:factory/swriter", "_blank", 0, (pv("Hidden", True),)) +ps = doc.StyleFamilies.getByName("PageStyles") +specs = [("G_snap_on", True, 2), ("G_snap_off", False, 2), ("G_lines_off", False, 1)] +for name, snap, mode in specs: + s = doc.createInstance("com.sun.star.style.PageStyle") + ps.insertByName(name, s) + s.GridMode = mode; s.StandardPageMode = True; s.GridSnapToChars = snap +text = doc.Text +cur = text.createTextCursor() +PB = uno.getConstantByName("com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK") +for name, *_ in specs: + text.insertString(cur, "grid " + name, False) + text.insertControlCharacter(cur, PB, False) +en = text.createEnumeration() +for name, *_ in specs: + en.nextElement().PageDescName = name +doc.storeToURL(uno.systemPathToFileUrl(out), (pv("FilterName", "writer8"),)) +doc.close(True) + +# base-width suppresses standard-mode on export and the importer does not infer it, so add it by hand +import zipfile, shutil +tmp = out + ".tmp" +with zipfile.ZipFile(out) as zi, zipfile.ZipFile(tmp, "w") as zo: + for it in zi.infolist(): + data = zi.read(it.filename) + if it.filename == "styles.xml": + data = data.replace(b"style:layout-grid-base-width=", b'style:layout-grid-standard-mode="true" style:layout-grid-base-width=') + zo.writestr(it, data, compress_type=it.compress_type) +shutil.move(tmp, out) diff --git a/test/odf-validate/fixtures/page-fill/bitmap.json b/test/odf-validate/fixtures/page-fill/bitmap.json new file mode 100644 index 0000000000..a7ef3362d8 --- /dev/null +++ b/test/odf-validate/fixtures/page-fill/bitmap.json @@ -0,0 +1,6 @@ +[ + { + "name": "page_bitmap", + "expr": "[(pre or 'page', ('GraphicObject:0000' not in u and 'GraphicObject:' in u), g.getPropertyValue(pre+'FillStyle').value) for g in [doc.StyleFamilies.getByName('PageStyles').getByName('P_bitmap')] for pre in ('', 'Header', 'Footer') for u in [g.getPropertyValue(pre+'BackGraphicURL')]]" + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/page-fill/checks.json b/test/odf-validate/fixtures/page-fill/checks.json new file mode 100644 index 0000000000..f82b9e3c41 --- /dev/null +++ b/test/odf-validate/fixtures/page-fill/checks.json @@ -0,0 +1,14 @@ +[ + { + "name": "page_fill", + "expr": "[(n, s.BackColor, s.BackTransparent, s.FillStyle.value, s.FillColor, s.FillTransparence) for n in ('P_solid','P_transp','P_grad','P_bitmap') for s in [doc.StyleFamilies.getByName('PageStyles').getByName(n)]]" + }, + { + "name": "hf_fill", + "expr": "[(n, s.HeaderBackColor, s.HeaderFillStyle.value, s.HeaderFillColor, s.HeaderFillTransparence, s.FooterBackColor, s.FooterFillStyle.value, s.FooterFillColor, s.FooterFillTransparence) for n in ('P_solid','P_transp','P_grad','P_bitmap') for s in [doc.StyleFamilies.getByName('PageStyles').getByName(n)]]" + }, + { + "name": "page_desc_names", + "expr": "[(p.String, p.PageDescName) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None)]" + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/page-fill/make.py b/test/odf-validate/fixtures/page-fill/make.py new file mode 100644 index 0000000000..97f7607562 --- /dev/null +++ b/test/odf-validate/fixtures/page-fill/make.py @@ -0,0 +1,60 @@ +# usage: runpy.sh fixtures/page-fill/make.py <port> <out.odt> <png> (office saving ODF 1.2 Extended) +import sys, uno +from unohelp import connect, desktop, pv +from com.sun.star.awt import Gradient +from com.sun.star.awt.GradientStyle import LINEAR +from com.sun.star.drawing import Hatch +from com.sun.star.drawing.HatchStyle import SINGLE +from com.sun.star.drawing.FillStyle import SOLID, GRADIENT, HATCH, BITMAP + +port, out, png = int(sys.argv[1]), sys.argv[2], uno.systemPathToFileUrl(sys.argv[3]) +d = desktop(connect(port)) +doc = d.loadComponentFromURL("private:factory/swriter", "_blank", 0, (pv("Hidden", True),)) + +def grad(): + g = Gradient(); g.Style = LINEAR; g.StartColor = 0xFF0000; g.EndColor = 0x0000FF + g.Angle = 0; g.Border = 0; g.XOffset = 50; g.YOffset = 50 + g.StartIntensity = 100; g.EndIntensity = 100; g.StepCount = 0 + return g + +def hatch(): + h = Hatch(); h.Style = SINGLE; h.Color = 0x00AA00; h.Distance = 200; h.Angle = 450 + return h + +def fill(o, pre, kind, color=0xFFCC00): + if kind == "solid": + setattr(o, pre + "FillStyle", SOLID); setattr(o, pre + "FillColor", color) + elif kind == "solid_transp": + setattr(o, pre + "FillStyle", SOLID); setattr(o, pre + "FillColor", color); setattr(o, pre + "FillTransparence", 40) + elif kind == "gradient": + setattr(o, pre + "FillStyle", GRADIENT); setattr(o, pre + "FillGradient", grad()) + elif kind == "hatch": + setattr(o, pre + "FillStyle", HATCH); setattr(o, pre + "FillHatch", hatch()) + setattr(o, pre + "FillColor", 0xFFFFCC); setattr(o, pre + "FillBackground", True) + elif kind == "bitmap": + setattr(o, pre + "FillStyle", BITMAP); setattr(o, pre + "FillBitmapURL", png) + +ps = doc.StyleFamilies.getByName("PageStyles") +specs = [("P_solid", "solid", "solid", "solid"), ("P_transp", "solid_transp", "solid_transp", "solid_transp"), + ("P_grad", "gradient", "gradient", "hatch"), ("P_bitmap", "bitmap", "bitmap", "bitmap")] +for name, pg, hd, ft in specs: + s = doc.createInstance("com.sun.star.style.PageStyle") + ps.insertByName(name, s) + s.HeaderIsOn = True; s.FooterIsOn = True + fill(s, "", pg, 0x66CCFF); fill(s, "Header", hd, 0xCCFF66); fill(s, "Footer", ft, 0xFF66CC) + +text = doc.Text +cur = text.createTextCursor() +PB = uno.getConstantByName("com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK") +paras = [] +for name, *_ in specs: + text.insertString(cur, "page " + name, False) + text.insertControlCharacter(cur, PB, False) + paras.append(name) +en = text.createEnumeration() +for name in paras: + p = en.nextElement() + p.PageDescName = name + +doc.storeToURL(uno.systemPathToFileUrl(out), (pv("FilterName", "writer8"),)) +doc.close(True) diff --git a/test/odf-validate/fixtures/page-fill/page-fill.odt b/test/odf-validate/fixtures/page-fill/page-fill.odt new file mode 100644 index 0000000000..ea02a346e1 Binary files /dev/null and b/test/odf-validate/fixtures/page-fill/page-fill.odt differ diff --git a/test/odf-validate/fixtures/para-fill/bitmap.json b/test/odf-validate/fixtures/para-fill/bitmap.json new file mode 100644 index 0000000000..d3aec5af16 --- /dev/null +++ b/test/odf-validate/fixtures/para-fill/bitmap.json @@ -0,0 +1,10 @@ +[ + { + "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]]" + }, + { + "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]]" + } +] \ 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 new file mode 100644 index 0000000000..ab620fc15c --- /dev/null +++ b/test/odf-validate/fixtures/para-fill/checks.json @@ -0,0 +1,14 @@ +[ + { + "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)]" + }, + { + "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)]]" + }, + { + "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)]" + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/para-fill/make.py b/test/odf-validate/fixtures/para-fill/make.py new file mode 100644 index 0000000000..1215a1e9fa --- /dev/null +++ b/test/odf-validate/fixtures/para-fill/make.py @@ -0,0 +1,65 @@ +# usage: runpy.sh fixtures/para-fill/make.py <port> <out.odt> (run against an office saving ODF 1.2 Extended) +import sys, uno +from unohelp import connect, desktop, pv +from com.sun.star.awt import Gradient +from com.sun.star.awt.GradientStyle import LINEAR +from com.sun.star.drawing import Hatch +from com.sun.star.drawing.HatchStyle import SINGLE +from com.sun.star.drawing.FillStyle import SOLID, GRADIENT, HATCH, BITMAP + +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 +png = uno.systemPathToFileUrl(sys.argv[3]) if len(sys.argv) > 3 else None + +def grad(): + g = Gradient(); g.Style = LINEAR; g.StartColor = 0xFF0000; g.EndColor = 0x0000FF + g.Angle = 0; g.Border = 0; g.XOffset = 50; g.YOffset = 50 + g.StartIntensity = 100; g.EndIntensity = 100; g.StepCount = 0 + return g + +def hatch(): + h = Hatch(); h.Style = SINGLE; h.Color = 0x00AA00; h.Distance = 200; h.Angle = 450 + return h + +def fill(o, kind): + if kind == "solid": + o.ParaBackColor = 0xFFCC00; o.ParaBackTransparent = False + elif kind == "solid_fill": + o.FillStyle = SOLID; o.FillColor = 0x33AA55 + elif kind == "solid_transp": + o.FillStyle = SOLID; o.FillColor = 0x3355AA; o.FillTransparence = 40 + elif kind == "gradient": + o.FillStyle = GRADIENT; o.FillGradient = grad() + elif kind == "hatch": + o.FillStyle = HATCH; o.FillHatch = hatch(); o.FillColor = 0xFFFFCC; o.FillBackground = True + elif kind == "bitmap": + o.FillStyle = BITMAP; o.FillBitmapURL = png + +kinds = ["solid", "solid_fill", "solid_transp", "gradient", "hatch"] + (["bitmap"] if png else []) +styles = doc.StyleFamilies.getByName("ParagraphStyles") +for k in kinds: + s = doc.createInstance("com.sun.star.style.ParagraphStyle") + s.ParentStyle = "Standard" + styles.insertByName("S_" + k, s) + fill(s, k) + +PB = uno.getConstantByName("com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK") +cur = text.createTextCursor() +labels = [] +for k in kinds: + for kind in ("direct", "styled"): + text.insertString(cur, kind + " " + k, False) + text.insertControlCharacter(cur, PB, False) + labels.append((kind, k)) +paras = doc.Text.createEnumeration() +for kind, k in labels: + p = paras.nextElement() + if kind == "direct": + fill(p, k) + else: + p.ParaStyleName = "S_" + k + +doc.storeToURL(uno.systemPathToFileUrl(out), (pv("FilterName", "writer8"),)) +doc.close(True) diff --git a/test/odf-validate/fixtures/para-fill/para-fill.odt b/test/odf-validate/fixtures/para-fill/para-fill.odt new file mode 100644 index 0000000000..26e501dc57 Binary files /dev/null and b/test/odf-validate/fixtures/para-fill/para-fill.odt differ diff --git a/test/odf-validate/fixtures/row-split/checks.json b/test/odf-validate/fixtures/row-split/checks.json new file mode 100644 index 0000000000..d907ae03f3 --- /dev/null +++ b/test/odf-validate/fixtures/row-split/checks.json @@ -0,0 +1,11 @@ +[ + { + "name": "row_split", + "expr": "[doc.TextTables.getByIndex(0).Rows.getByIndex(i).IsSplitAllowed for i in range(doc.TextTables.getByIndex(0).Rows.Count)]", + "expect": [ + true, + false, + true + ] + } +] \ No newline at end of file diff --git a/test/odf-validate/fixtures/row-split/make.py b/test/odf-validate/fixtures/row-split/make.py new file mode 100644 index 0000000000..87d1558b44 --- /dev/null +++ b/test/odf-validate/fixtures/row-split/make.py @@ -0,0 +1,17 @@ +# usage: runpy.sh fixtures/row-split/make.py <port> <out.odt> (office saving ODF 1.2 Extended) +import sys, uno +from unohelp import connect, desktop, pv + +port, out = int(sys.argv[1]), sys.argv[2] +d = desktop(connect(port)) +doc = d.loadComponentFromURL("private:factory/swriter", "_blank", 0, (pv("Hidden", True),)) +tbl = doc.createInstance("com.sun.star.text.TextTable") +tbl.initialize(3, 2) +doc.Text.insertTextContent(doc.Text.End, tbl, False) +rows = tbl.Rows +rows.getByIndex(0).IsSplitAllowed = True +rows.getByIndex(1).IsSplitAllowed = False +rows.getByIndex(2).IsSplitAllowed = True +rows.getByIndex(2).Height = 1000 +doc.storeToURL(uno.systemPathToFileUrl(out), (pv("FilterName", "writer8"),)) +doc.close(True) diff --git a/test/odf-validate/fixtures/row-split/row-split.odt b/test/odf-validate/fixtures/row-split/row-split.odt new file mode 100644 index 0000000000..ea214ccf97 Binary files /dev/null and b/test/odf-validate/fixtures/row-split/row-split.odt differ
