Thanks for your suggestion. I worked on it some more and ended up with this:
Code: Select all
sub addSigImage
'insert the image of a signature
dim oDoc as object, oDocFrame as object
dim oDrawPage as object, oDrawPageObj as object
dim dispatcher as object
oDoc = ThisComponent
oDocFrame = oDoc.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(3) as new com.sun.star.beans.PropertyValue
args1(0).Name = "FileName"
args1(0).Value = "file://tesla/images/674.png"
args1(1).Name = "FilterName"
args1(1).Value = "<All formats>"
args1(2).Name = "AsLink"
args1(2).Value = false
args1(3).Name = "Style"
args1(3).Value = "TMsigFrame"
dispatcher.executeDispatch(oDocFrame, ".uno:InsertGraphic", "", 0, args1())
'operate on the last image inserted
oDrawPage = oDoc.DrawPage
oDrawPageObj = oDrawPage.getByIndex(oDrawPage.Count - 1)
oDrawPageObj.AnchorType = 0 'zero is paragraph anchor
oDrawPageObj.Opaque = False 'In Background
oDrawPageObj.Surround = 1 'this and next seem to give Wrap Through
oDrawPageObj.TextWrap = 1
end sub
It turns out that if you specify a "Style" that does not exist, it will be created. Then the properties of the DrawPage object can be set and they will override the properties of the frame style. This means that you don't have to create the frame style ahead of time and give it the correct properties. However, it is important that you do not modify the properties of the frame style manually after inserting the image. If you do, the image will inherit all of the frame properties and the image will jump to a new location!
It may also be possible to insert the image, then set some properties of the frame style, then set some properties of the image. I may try that too.
Thanks again for your help.