xref: /trunk/test/odf-validate/fixtures/normal-values/make.py (revision 0e16a31d78a652c56c5c0fc79c752f48b9048df9)
1# usage: runpy.sh fixtures/normal-values/make.py <port> <out.odt>
2import sys, uno
3from unohelp import connect, desktop, pv
4from com.sun.star.text.TextContentAnchorType import AT_PAGE, AT_PARAGRAPH
5from com.sun.star.style.BreakType import PAGE_BEFORE
6
7port, out = int(sys.argv[1]), sys.argv[2]
8d = desktop(connect(port))
9doc = d.loadComponentFromURL("private:factory/swriter", "_blank", 0, (pv("Hidden", True),))
10text = doc.Text
11
12tbl = doc.createInstance("com.sun.star.text.TextTable")
13tbl.initialize(2, 3)
14text.insertTextContent(text.End, tbl, False)
15c = tbl.createCursorByCellName("A1")
16c.goRight(1, True)
17c.mergeRange()
18
19cur = text.createTextCursor(); cur.gotoEnd(False)
20text.insertString(cur, "\nbody\n", False)
21cur.gotoEnd(False)
22cur.BreakType = PAGE_BEFORE
23text.insertString(cur, "page two\n", False)
24
25fn = doc.createInstance("com.sun.star.text.Footnote")
26fn.Label = ""
27cur.gotoEnd(False)
28text.insertTextContent(cur, fn, False)
29fn.String = "note text"
30text.insertString(cur, " ", False)
31for part in (0, 3, 2):
32    f = doc.createInstance("com.sun.star.text.TextField.GetReference")
33    f.ReferenceFieldSource = 3
34    f.SourceName = ""
35    f.SequenceNumber = fn.ReferenceId
36    f.ReferenceFieldPart = part
37    text.insertTextContent(cur, f, False)
38    text.insertString(cur, " ", False)
39
40for name, page in (("frame_p2", 2), ("frame_nopage", 0)):
41    fr = doc.createInstance("com.sun.star.text.TextFrame")
42    fr.AnchorType = AT_PAGE
43    if page:
44        fr.AnchorPageNo = page
45    fr.Width = 3000; fr.Height = 1000
46    text.insertTextContent(cur, fr, False)
47    fr.setName(name)
48    fr.Text.String = name
49
50doc.storeToURL(uno.systemPathToFileUrl(out), (pv("FilterName", "writer8"),))
51doc.close(True)
52