Difference between revisions of "Talk:Documentation/BASIC Guide/More Than Text"
From Apache OpenOffice Wiki
(add the comments to the scripts) |
|||
| Line 7: | Line 7: | ||
def inset_img(): | def inset_img(): | ||
| + | # abstract the objects in varialbes, doc, text and img, note we used the XSCRIPTCONTEXT | ||
doc = XSCRIPTCONTEXT.getDocument() | doc = XSCRIPTCONTEXT.getDocument() | ||
text = doc.getText() | text = doc.getText() | ||
img = doc.createInstance(u'com.sun.star.text.TextGraphicObject') | img = doc.createInstance(u'com.sun.star.text.TextGraphicObject') | ||
| − | + | ||
| + | # load the image from the TextGraphicObject | ||
img.GraphicURL = "file:///C:/usr/1.png" | img.GraphicURL = "file:///C:/usr/1.png" | ||
| + | # specify the dimension of the image | ||
aSize = Size() | aSize = Size() | ||
aSize.Width = 1000 | aSize.Width = 1000 | ||
aSize.Height = 1000 | aSize.Height = 1000 | ||
img.Size = aSize | img.Size = aSize | ||
| − | + | ||
| + | #inser the image in the text area location | ||
text.insertTextContent(text.getEnd(), img, False)</source> | text.insertTextContent(text.getEnd(), img, False)</source> | ||
Latest revision as of 19:29, 11 July 2008
Python samples and Images
Can we get some translation of these scripts for the Python language and also include samples on inlcuding the handle of objects such as Images. Python quote could be:
from com.sun.star.awt import Size
def inset_img():
# abstract the objects in varialbes, doc, text and img, note we used the XSCRIPTCONTEXT
doc = XSCRIPTCONTEXT.getDocument()
text = doc.getText()
img = doc.createInstance(u'com.sun.star.text.TextGraphicObject')
# load the image from the TextGraphicObject
img.GraphicURL = "file:///C:/usr/1.png"
# specify the dimension of the image
aSize = Size()
aSize.Width = 1000
aSize.Height = 1000
img.Size = aSize
#inser the image in the text area location
text.insertTextContent(text.getEnd(), img, False)