There is example of formatted text in Spelling Dialog → red text and normal text
But how to format Text in Text Field in Dialog? There is method setAttributes, but without success :-(.
Sub Start
on local error goto chyba
dim oDoc as object, oDlg as object, oDlgModel as object,oWindow as object, oToolkit as object
oDoc=StarDesktop.LoadComponentFromUrl("private:factory/swriter", "_blank", 0, array()) 'new Writer window
oDlg=CreateUnoService("com.sun.star.awt.UnoControlDialog") 'Main Dialog
oDlgModel=CreateUnoService("com.sun.star.awt.UnoControlDialogModel")
with oDlgModel
.Width=100
.Height=100
.PositionX=50
.PositionY=50
end with
oDlg.setModel(oDlgModel)
oWindow=CreateUnoService("com.sun.star.awt.Toolkit")
oToolkit=oDoc.CurrentController.Frame.ContainerWindow
oDlg.createPeer(oWindow, oToolkit)
oDlg.addTopWindowListener(CreateUnoListener("Ldlg_", "com.sun.star.awt.XTopWindowListener")) 'listener for closing cross
dim oEdit as object, sName$, o as object, oAccess as object 'Text Field
oEdit=oDlg.Model.createInstance("com.sun.star.awt.UnoControlEditModel")
sName="TextField1"
with oEdit
.Name=sName
.Width=80
.Height=80
.PositionX=10
.PositionY=10
.Text="hello world"
end with
oDlg.Model.insertByName(sName, oEdit)
o=oDlg.getControl(sName)
o.Editable=true 'enable the methods from "com.sun.star.accessibility.XAccessibleEditableText"
oAccess=o.AccessibleContext
dim bb(12) as new com.sun.star.beans.PropertyValue
'xray oo.getCharacterAttributes(1, array()) 'get array of properties
bb(0).Name="CharBackColor" : bb(0).Value=RGB(0,0,255)
bb(1).Name="CharColor" : bb(1).Value=RGB(255,0,0)
bb(2).Name="CharFontCharSet" : bb(2).Value=0
bb(3).Name="CharFontFamily" : bb(3).Value=0
bb(4).Name="CharFontName" : bb(4).Value=""
bb(5).Name="CharFontPitch" : bb(5).Value=0
bb(6).Name="CharFontStyleName" : bb(6).Value=""
bb(7).Name="CharHeight" : bb(7).Value=0
bb(8).Name="CharPosture" : bb(8).Value=0
bb(9).Name="CharScaleWidth" : bb(9).Value=0
bb(10).Name="CharStrikeout" : bb(10).Value=0
bb(11).Name="CharUnderline" : bb(11).Value=0
bb(12).Name="CharWeight" : bb(12).Value=150
msgbox oAccess.setAttributes(1, 2, bb) 'WHY NOT FUNCTIONAL?
oAccess.replaceText(3, 4, "12") 'but other method from "com.sun.star.accessibility.XAccessibleEditableText" is functional
exit sub
chyba:
bug(Err,Erl,Error,"Start")
End Sub
Sub bug(sErr$, sErl$, sError$, s$)
msgbox("Error: " & sErr & chr(13) & sError & chr(13) & "Řádek: " & sErl & chr(13), 16, s)
stop
End Sub
Sub Ldlg_windowClosing(optional oEvt as object)
on local error goto bug
oEvt.Source.dispose()
exit sub
bug:
bug(Err, Erl, Error, "Ldlg_windowClosing")
End Sub
Sub Ldlg_disposing
End Sub
Sub Ldlg_windowOpened
End Sub
Sub Ldlg_windowClosed
End Sub
Sub Ldlg_windowMinimized
End Sub
Sub Ldlg_windowNormalized
End Sub
Sub Ldlg_windowActivated
End Sub
Sub Ldlg_windowDeactivated
End Sub