1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
REM ***** BASIC *****
Option Explicit
Global Const PRODUCT_NAME = "2BurnerSS"
' TODO make presets based on festivals and discounts
Global Const CURRENT_PRESET = "FESTIVE"
Sub UpdateDocumentFromPriceList(oDoc, oDrawPages, oProduct)
Dim i,j as Integer
Dim oPage
Dim oShape
For i = 0 To oDrawPages.getCount() - 1
oPage = oDrawPages.getByIndex(i)
For j = 0 To oPage.getCount() - 1
oShape = oPage.getByIndex(j)
SubstituteContent(oDoc, oShape, oProduct)
Next j
Next i
End Sub
Sub BrochureGenerate
Dim oDrawPages
Dim oDoc: oDoc = ThisComponent
Dim oProduct
' TODO Iterate through StarDesktop, and get both
' DrawingDocument and SpreadsheetDocument
oDoc = GetFirstOpenDocument("com.sun.star.drawing.DrawingDocument")
If IsNull(oDoc) Then
ErrorLocal$ = "The given document should a Draw Document"
Exit Sub
End If
oProduct = ReadProductFromSheet(oDoc, PRODUCT_NAME)
oDrawPages = oDoc.getDrawPages()
UpdateDocumentFromPriceList(oDoc, oDrawPages, oProduct)
GlobalScope.BasicLibraries.LoadLibrary("MRILib")
Dim oText: oText = oProduct.Title
Dim oEnum: oEnum = oText.createEnumeration()
Dim oSection
Dim s, v
Do While oEnum.hasMoreElements()
v = oEnum.nextElement()
Dim oSubSection
Dim oSecEnum
REM Now create an enumeration of the paragraphs.
REM We can enumerate the sections of the paragraph to
REM obtain the text field and other paragraph content.
oSecEnum = v.createEnumeration()
s = "Enumerating section type: " & v.ImplementationName
Do While oSecEnum.hasMoreElements()
oSubSection = oSecEnum.nextElement()
s = s & CHR$(10) & oSubSection.TextPortionType
If oSubSection.TextPortionType = "TextField" Then
s = s & " <== Type " & oSubSection.TextField.ImplementationName
End If
Loop
MsgBox s, 0, "Enumerate Single Paragraph"
Loop
Exit Sub
'Print oSlide.dbg_methods()
MRI oProduct.Title
Exit Sub
End Sub