Bug 127025

Summary: Background image of Writer form cannot be set using the BackGraphic property
Product: LibreOffice Reporter: Balint Fodor <fodorbalint>
Component: BASICAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: normal CC: iplaw67, quikee
Priority: medium    
Version: 6.2.5.2 release   
Hardware: All   
OS: All   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=127310
Whiteboard:
Crash report or crash signature: Regression By:

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