0
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
69
70
71
72
73
74
| | Sub RichEdit_Test
' create new dialog
oDialog = CreateUnoService( _
"com.sun.star.awt.UnoControlDialog" )
oDialogModel = CreateUnoService( _
"com.sun.star.awt.UnoControlDialogModel" )
' set position and size of the dialog
PS_POSSIZE = com.sun.star.awt.PosSize.POSSIZE
oDialog.setPosSize(100, 100, 300, 200, PS_POSSIZE )
oDialog.setModel(oDialogModel)
' create new rich edit control
oRichEditModel = CreateUnoService( _
"com.sun.star.form.component.RichTextControl" )
oRichEdit = CreateUnoService( _
"com.sun.star.form.control.RichTextControl")
' use rich format
oRichEditModel.setPropertyValue("RichText",True)
oRichEditModel.setPropertyValues( _
Array("Align", "Border", "MultiLine", "ReadOnly"), _
Array(0, 2, True, False) )
'oRichEditModel.setPropertyValue("BackgroundColor",-1)
oRichEdit.setPosSize(5, 5, 290, 100, PS_POSSIZE)
oRichEdit.setModel(oRichEditModel)
' add it to the dialog
oDialog.addControl("rich",oRichEdit)
' set text into the rich edit control
' rich edit control supports paragraph
oText = oRichEditModel.getText()
oCursor = oText.createTextCursor()
' normal
oText.insertString(oCursor,"void ", False)
' set bold
oCursor.CharWeight = 150.0
oText.insertString(oCursor,"start",True)
' insert line break
nCtrlChar = com.sun.star.text.ControlCharacter
oText.insertControlCharacter( _
oText.getEnd(), nCtrlChar.LINE_BREAK, False)
' test fontname and color
oCursor.CharWeight = 100.0
oCursor.CharFontName = "Arial"
oCursor.CharColor = RGB(255,0,0)
oText.insertString(oCursor,"( [in] string nJobName )",True)
Dim aBoldItalicSpan(1) As New com.sun.star.beans.PropertyValue
aBoldItalicSpan(0).Name = "CharWeight"
aBoldItalicSpan(0).Value = 150.0
aBoldItalicSpan(1).Name = "CharPosture"
aBoldItalicSpan(1).Value = com.sun.star.awt.FontSlant.ITALIC
Dim aNormalSpan(0) As New com.sun.star.beans.PropertyValue
aNormalSpan(0).Name = "CharWeight"
aNormalSpan(0).Value = 100.0
oText.appendTextPortion("BOLDITALIC",aBoldItalicSpan)
oText.insertControlCharacter( _
oText.getEnd(), nCtrlChar.LINE_BREAK, False)
oText.appendTextPortion("needs to reset POSTURE ...",aNormalSpan)
oDialog.setVisible(True)
oDialog.execute()
oDialog.dispose()
End Sub
|