Bug 127025 - Background image of Writer form cannot be set using the BackGraphic property
Summary: Background image of Writer form cannot be set using the BackGraphic property
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.2.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-19 12:02 UTC by Balint Fodor
Modified: 2023-05-21 20:55 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Balint Fodor 2019-08-19 12:02:14 UTC
Description:
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.

Full code:

    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

Actual Results:
No image displayed

Expected Results:
Image should be displayed.


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Alex Thurgood 2019-09-03 14:48:53 UTC
If I try and run this macro in LO5.4.7.2, 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.
Comment 2 Balint Fodor 2019-09-03 14:57:01 UTC
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?
Comment 3 Alex Thurgood 2019-09-03 15:04:04 UTC
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 ?
Comment 4 QA Administrators 2021-09-05 04:35:47 UTC Comment hidden (obsolete)
Comment 5 Jean-Michel COSTE 2023-05-21 20:55:20 UTC
Still present in version 7.4.7