Debian Codegraph @

src/installer/openoffice.txt

raw
1 REM ***** BASIC *****
2
3 Sub Main
4 H2Pdf
5 End Sub
6
7 sub H2Pdf
8 BaseDir = "file:///C:/data/h2database/"
9 REM BaseDir = "file:///Users/tmueller/data/"
10
11 Url = BaseDir & "h2/docs/html/onePage.html"
12 dim FileProperties(1) As New com.sun.star.beans.PropertyValue
13 FileProperties(0).Name = "FilterName"
14 FileProperties(0).Value = "HTML (StarWriter)"
15 FileProperties(1).Name = "UpdateDocMode"
16 FileProperties(1).Value = 3 'full update
17 document = StarDesktop.loadComponentFromURL(Url, "_blank", 0, FileProperties)
18 docs = ThisComponent.CurrentController.Frame
19 dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
20 dispatcher.executeDispatch(docs, ".uno:UpdateAll", "", 0, Array())
21 StyleFamilies = document.StyleFamilies
22
23 ParagraphStyles = StyleFamilies.getByName("ParagraphStyles")
24 BodyStyle = ParagraphStyles.getByName("Text body")
25 BodyStyle.ParaOrphans = 2
26 BodyStyle.ParaWidows = 2
27
28 HeadingStyle = ParagraphStyles.getByName("Heading 1")
29 HeadingStyle.BreakType = 3 ' Insert Page Break Before
30 HeadingStyle.ParaKeepTogether = false
31
32 For i = 1 to 4
33 ParagraphStyles.getByName("Heading " + i).OutlineLevel = i
34 Next
35
36 images = document.GraphicObjects
37 For i = 0 to images.getCount() - 1
38 image = images.getByIndex(i)
39 if image.Size.Width <> image.ActualSize.Width or image.Size.Height <> image.ActualSize.Height then
40 image.Size.Width = image.ActualSize.Width
41 image.Size.Height = image.ActualSize.Height
42 wait 100
43 end if
44 Next
45 dispatcher.executeDispatch(docs, ".uno:UpdateAll", "", 0, Array())
46
47 PageStyles = StyleFamilies.getByName("PageStyles")
48
49 Standard = PageStyles.getByName("HTML")
50 Standard.FooterIsOn = True
51
52 dispatcher.executeDispatch(docs, ".uno:UpdateAll", "", 0, Array())
53
54 oText = Standard.FooterText
55 oText.setString("")
56 PageNumber = document.createInstance("com.sun.star.text.TextField.PageNumber")
57 PageNumber.NumberingType = 4 ' magic constant: 4=Arabic numbers
58 PageNumber.SubType = 1 ' magic constant: use current page number
59
60 PageCount = document.createInstance("com.sun.star.text.TextField.PageCount")
61 PageCount.NumberingType = 4 ' magic constant: 4=Arabic numbers
62
63 FooterCursor = oText.Text.createTextCursor()
64 oText.insertString(FooterCursor, Chr(09)& Chr(09), False)
65 oText.insertTextContent(FooterCursor, PageNumber, False)
66 oText.insertString(FooterCursor, " of ", False)
67 oText.insertTextContent(FooterCursor, PageCount, False)
68
69 Cursor = document.Text.createTextCursor()
70 Cursor.gotoStart(false)
71 Cursor.gotoNextParagraph(false)
72 Cursor.gotoNextParagraph(false)
73
74 dispatcher.executeDispatch(docs, ".uno:UpdateAll", "", 0, Array())
75
76 toc = document.createInstance("com.sun.star.text.ContentIndex")
77 toc.Title= "Table of Contents"
78 toc.CreateFromOutline = True
79 toc.Level = 4
80 toc.IsProtected = false
81 document.Text.insertTextContent(Cursor, toc, false)
82
83 Cursor.gotoStart(false)
84 result = true
85 while result
86 result = Cursor.gotoNextParagraph(false)
87 if Cursor.ParaStyleName = "Heading 1" then
88 Cursor.BreakType = 4 ' Insert Page Break After
89 end if
90 wend
91
92 dim linkStart(0) As New com.sun.star.beans.PropertyValue
93 dim linkEnd(0) As New com.sun.star.beans.PropertyValue
94
95 for i = 1 To 4
96 oLevel = toc.LevelFormat.getByIndex(i)
97 bound = UBound(oLevel)
98 x = DimArray(bound + 2)
99 x(0) = linkStart
100 for j = 0 to bound
101 x(j + 1) = oLevel(j)
102 next
103 x(bound + 2) = linkEnd
104 linkStart(0).Name = "TokenType"
105 linkStart(0).Value = "TokenHyperlinkStart"
106 linkStart(0).Handle = -1
107 linkStart(0).State = com.sun.star.beans.PropertyState.DIRECT_VALUE
108 linkEnd(0).Name = "TokenType"
109 linkEnd(0).Value = "TokenHyperlinkEnd"
110 linkEnd(0).Handle = -1
111 linkEnd(0).State = com.sun.star.beans.PropertyState.DIRECT_VALUE
112 toc.LevelFormat.replaceByIndex(i, x)
113 next
114
115 dispatcher.executeDispatch(docs, ".uno:UpdateAll", "", 0, Array())
116 toc.update()
117 dispatcher.executeDispatch(docs, ".uno:UpdateAll", "", 0, Array())
118 toc.update()
119 dispatcher.executeDispatch(docs, ".uno:UpdateAll", "", 0, Array())
120
121 pdfTemp = BaseDir & "h2web/h2temp.pdf"
122 pdf = BaseDir & "h2web/h2.pdf"
123
124 dim pdfProperties(1) as new com.sun.star.beans.PropertyValue
125 pdfProperties(0).Name = "FilterName"
126 pdfProperties(0).Value = "writer_pdf_Export"
127 document.storeToURL(pdfTemp, pdfProperties())
128
129 fileAccessService = createUnoService("com.sun.star.ucb.SimpleFileAccess")
130 fileAccessService.move(pdfTemp, pdf)
131
132 ThisComponent.close(true)
133 end sub