I want to introduce a Textfield with corresponding text inside a spreadsheet.
For this I wrote the code below.
oDoc is the document, oSheet the corresponding sheet.
The code runs through, but:
In the corresponding sheet "oSheet" no output can be seen. Clicking on the area, where I expect the textfield, I can see an empty frame without border line.
and the print outputs deliver:
print oTextf.Position.X ---> 100 as set in the macro
print oTextf.CharFontName ---> Times New Roman ??? why, I set this to Courier?
print oTextf.String ---> this is expected to be xxx, but nothing is output, so that explains, why the textfield is empty, but why isn't the input accepted?
What did I miss? I get the TextShape instantiated and I add it to the sheet's drawpage.
Something with visibility or layer?
Could you give me some example code for spreadsheets (I found some for text documents, perhaps there is some difference?).
I'm not very acquainted to this style of programming with services and find it somewhat hard to use the documentation without some examples.
Furthermore I'd like to center the reference point of the textfield. Seems I could do it with GluePoints.
I got one defined, see the second code snippet.
How would I use this exactly?
There is some "EnhancedCustomShapeParameterPair" with its property GluePoints, but the code below (oTextf.GluePoints = mGluePoint2) gives me an error that the property is write-protected. What to do?
Thanks
Andreas
Code: Select all
oDrawPage = oSheet.DrawPage
oTextf = oDoc.createInstance("com.sun.star.drawing.TextShape")
oTextf.FillStyle = SOLID
mPoint.X = 100
mPoint.Y = 0
mSize.Width = 9000
mSize.Height = 5000
oTextf.FillColor = RGB(200,200,200)
oTextf.LineStyle = SOLID
oTextf.LineCOLOR = RGB(100,100,100)
otextf.Position = mPoint
oTextf.Size = mSize
oTextf.CharFontName = "Courier"
oTextf.CharHeight = 9
oDrawPage.add(oTextf)
oTextf.String("xxx")
print oTextf.Position.X
print oTextf.CharFontName
print oTextf.String
Code: Select all
mPointGlue.X = 4500
mPointGlue.Y = 2500
mGluePoint2.Position = mPointGlue
mGluePoint2.IsRelative = False
mGluePoint2.PositionAlignment = CENTER
mGluePoint2.Escape = HORIZONTAL
mGluePoint2.IsUserDefined = True
oTextf.GluePoints = mGluePoint2