Ask Your Question
0

Setting background image in Base form

asked 2019-08-16 13:59:20 +0200

fodorbalint gravatar image

updated 2019-08-17 11:09:09 +0200

It used to be so easy by using this line:

oPageStyle.BackGraphicURL=imgurl

but it became deprecated with LibreOffice 6.1.

Now I am trying this code, and it runs without error but does not set the background image:

imgurl="file:///C:/Users/fodor/OneDrive/Documents/Recipe%20organizer/Developing-own/Big%20Images/20180319_114502.jpg"

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
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-08-17 15:02:29 +0200

No idea why, but using FillBitmap instead of BackGraphic seems to do the trick.

edit flag offensive delete link more

Comments

Possibly worth filing a bug report...

Mike Kaganski gravatar imageMike Kaganski ( 2019-08-17 15:03:05 +0200 )edit

Thanks, this works now! Will report it.

fodorbalint gravatar imagefodorbalint ( 2019-08-17 18:01:33 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-08-16 13:59:20 +0200

Seen: 101 times

Last updated: Aug 17 '19