Before LibreOffice 6.1 one could use BackGraphicURL to set the background image.
Now BackGraphic should be used, but it doesn't work.
FillBitmap works instead.
oPageStyle = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Default Style")
oPageStyle.FillColor = RGB(255,255,255)
oPageStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.LEFT_TOP
oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
Dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = "URL"
args(0).Value = imgurl
oPageStyle.BackGraphic = oProvider.queryGraphic(args())
Testing in the end:
MsgBox isNull(oProvider.queryGraphic(args())) 'False
MsgBox isNull(oPageStyle.BackGraphic) 'True
No image displayed
Image should be displayed.
User Profile Reset: No
If I try and run this macro in LO188.8.131.52, I get the following error (in French) :
BASIC runtime error.
Property or method not found : BackGraphic.
So the method wasn't available then, or it was called something slightly different.
I also had to correct your use of "Default Style" to "Style par défaut" in order to avoid an error on this line :
oPageStyle = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Style par défaut")
In 6.1, when I run the macro with the tests at the end I get TRUE in the MsgBox. No image is inserted.
I'm not a Basic expert, so can't say what is wrong with your macro when testing in my French language version of LO.
You get True in both MsgBox-es? That's even worse result than what I got, since both terms are null. Have you checked if your image's URL is correct?
Yes, I checked the image URL was correct, but I still get True for both MsgBoxes in LO6252, for example.
Inevitably linked to Tomaz' changes, so adding him to CC.
@Tomaz : any advice here ?