Bug 127310 - Base/BASIC: RectangleShape object does not display an image by setting its FillBitmap
Summary: Base/BASIC: RectangleShape object does not display an image by setting its Fi...
Status: NEEDINFO
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.2.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisectRequest, regression
Depends on:
Blocks: Regressions-imageHandling
  Show dependency treegraph
 
Reported: 2019-09-03 12:37 UTC by Balint Fodor
Modified: 2024-08-11 18:27 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Testimage.zip You need to change the URL of the picture in the code. (52.33 KB, application/x-zip-compressed)
2019-09-03 12:42 UTC, Balint Fodor
Details
Image inserted (68.46 KB, image/png)
2020-06-06 17:58 UTC, Buovjaga
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Balint Fodor 2019-09-03 12:37:42 UTC
Description:
You can add a picture to a form using com.sun.star.drawing.GraphicObjectShape, but the picture will fill the whole area, and I want to be able to display square images centered in a 16:9 rectangle.
com.sun.star.drawing.RectangleShape seems to be able to do it, but when I set its FillBitmap property, no image is shown. Here is the full code:

Steps to Reproduce:
oGraphicsShape=ThisComponent.createInstance("com.sun.star.drawing.RectangleShape")
aSize=CreateUnoStruct("com.sun.star.awt.Size")
ratio=50706/1917
aSize.Width=222*ratio
aSize.Height=125*ratio
oGraphicsShape.setSize(aSize)

aPoint=CreateUnoStruct("com.sun.star.awt.Point")
aPoint.X=0
aPoint.Y=0
oGraphicsShape.setPosition(aPoint)

oGraphicsShape.FillStyle=com.sun.star.drawing.FillStyle.BITMAP

oGraphicsShape.FillBitmapLogicalSize=true
oGraphicsShape.FillBitmapSizeX=100
oGraphicsShape.FillBitmapSizeY=100

url="file:///C:/Users/fodor/OneDrive/Documents/LibreOffice Bugs/testimage222x125.jpg"

oProvider=createUnoService("com.sun.star.graphic.GraphicProvider")
Dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = "URL"
args(0).Value = url
oGraphicsShape.FillBitmap = oProvider.queryGraphic(args())

oGraphicsShape.AnchorType=com.sun.star.text.TextContentAnchorType.AT_PAGE
ThisComponent.DrawPage.add(oGraphicsShape)

'-------------------------------

oGraphicsShape=ThisComponent.createInstance("com.sun.star.drawing.GraphicObjectShape")  

oGraphicsShape.setSize(aSize)
aPoint.Y=125 * ratio
oGraphicsShape.setPosition(aPoint)  

oGraphicsShape.Graphic = oProvider.queryGraphic(args())

oGraphicsShape.AnchorType=com.sun.star.text.TextContentAnchorType.AT_PAGE
ThisComponent.DrawPage.add(oGraphicsShape)


Actual Results:
On the top left corner of the page a blue rectangle is displayed, while below the actual picture.

Expected Results:
Two picture being displayed.


Reproducible: Always


User Profile Reset: Yes



Additional Info:
Comment 1 Balint Fodor 2019-09-03 12:42:30 UTC
Created attachment 153837 [details]
Testimage.zip
You need to change the URL of the picture in the code.
Comment 3 Balint Fodor 2019-09-03 13:39:28 UTC
Most certainly. Just like the other bug I reported, 127025.
Comment 4 Alex Thurgood 2019-09-03 14:08:21 UTC
@Tomaž : comments ? if the old way is deprecated, how is this kind of thing supposed to be done now ?
Comment 5 Alex Thurgood 2019-09-03 14:16:09 UTC
FWIW, I get a crash of LO6304 (with proposed recovery of crashed document) after running this macro in a blank Writer document.

However, I can confirm that the blue shape appears in the top left hand corner of the page. The actual picture I tried to insert isn't displayed however, merely, an image placeholder beneath that blue shape. Then I get the crash.
Comment 6 Alex Thurgood 2019-09-03 14:18:22 UTC
For me, the error message before the crash is :

Erreur d'exécution BASIC.
Une exception s'est produite : 
Type: com.sun.star.lang.IllegalArgumentException
Message: .
Comment 7 Balint Fodor 2019-09-03 14:23:06 UTC
I get that error and the crash, if the URL of the picture is incorrect.
Comment 8 Alex Thurgood 2019-09-03 14:25:58 UTC
Indeed, I suspect the crash is due to a space in my path to the image file, which for some reason causes LO to baulk, even though it is surrounded by double quotation marks. Probably, a separate issue.
Comment 9 Alex Thurgood 2019-09-03 14:26:57 UTC
Changing component to Writer, as you only need a Writer document with the provided macro code to be able to reproduce the problem.
Comment 10 Alex Thurgood 2019-09-03 14:28:17 UTC
Marking as regression, but awaiting Tomaž' input.
Comment 11 Xisco Faulí 2019-09-04 14:01:08 UTC
It doesn't crash for me in

Version: 6.4.0.0.alpha0+
Build ID: e8b3df5b9b0eb0a93c25b6dc2e445ae44a7e3f78
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
Calc: threaded

nor in

Versión: 6.3.0.3 (x86)
Id. de compilación: c75130c129d9c5e43b76e4f26881b3db8bdb5c91
Subprocs. CPU: 1; SO: Windows 6.1; Repres. IU: predet.; VCL: win; 
Configuración regional: es-ES (es_ES); Idioma de IU: es-ES
Calc: threaded

@Alex Thurgood, Does it crash with a clean profile ?
Comment 12 Alex Thurgood 2019-09-04 15:16:31 UTC
(In reply to Xisco Faulí from comment #11)

> 
> @Alex Thurgood, Does it crash with a clean profile ?

@Xisco : the crash is a red herring, I think, with regard to this bug report, due to the space in the path to my image ("Macintosh HD" on Mac). I intend to report that as a separate bug.

The issue is, as Balint points out :

"com.sun.star.drawing.RectangleShape seems to be able to do it, but when I set its FillBitmap property, no image is shown"
Comment 13 Xisco Faulí 2019-09-04 15:21:22 UTC
(In reply to Alex Thurgood from comment #12)
> (In reply to Xisco Faulí from comment #11)
> 
> > 
> > @Alex Thurgood, Does it crash with a clean profile ?
> 
> @Xisco : the crash is a red herring, I think, with regard to this bug
> report, due to the space in the path to my image ("Macintosh HD" on Mac). I
> intend to report that as a separate bug.
> 
> The issue is, as Balint points out :
> 
> "com.sun.star.drawing.RectangleShape seems to be able to do it, but when I
> set its FillBitmap property, no image is shown"

I seee, then please fill the crash in a separate issue.
Regarding the RectangleShape issue, if I remember well, the code must be adapted, I remember a similar issue about it. @Raal, do you remember?
Lowering severity anyway...
Comment 14 Alex Thurgood 2019-09-05 07:12:47 UTC
I can also repeat the initially reported behaviour with :

Version: 6.0.7.3
Build ID: 1:6.0.7-0ubuntu0.18.04.9
Threads CPU : 4; OS : Linux 4.4; UI Render : par défaut; VCL: gtk3; 
Locale : fr-FR (fr_FR.UTF-8); Calc: group

Blue background rectangle displayed in top left hand corner.
Image displayed underneath blue rectangle.
Comment 15 Alex Thurgood 2019-09-05 07:23:17 UTC
And also reproduced with :

Version: 6.3.0.4
Build ID: libreoffice-6.3.0.4-snap1
Threads CPU : 4; OS : Linux 4.4; UI Render : par défaut; VCL: gtk3; 
Locale : fr-FR (fr_FR.UTF-8); Langue IHM : fr-FR
Calc: threaded
Comment 16 Alex Thurgood 2019-09-06 07:46:14 UTC Comment hidden (off-topic)
Comment 17 Alex Thurgood 2019-09-06 07:47:05 UTC Comment hidden (off-topic)
Comment 18 Buovjaga 2020-06-06 17:58:37 UTC
Created attachment 161694 [details]
Image inserted

Inserting the image works for me. Not sure, if the result is as the reporter intended, so attaching this screenshot

Steps:
1. Unzip attachment 153837 [details] and open .odb
2. Modify the included macro to correct the path of the image
3. Double-click Form1 to open it
4. Click the button

Please everyone re-test.

Arch Linux 64-bit
Version: 7.1.0.0.alpha0+
Build ID: 2bccbd2ba6c90d5e02285629c2b079c35260c08b
CPU threads: 8; OS: Linux 5.6; UI render: default; VCL: kf5
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 3 June 2020
Comment 19 Buovjaga 2020-06-06 17:59:03 UTC
(In reply to Buovjaga from comment #18)
> Arch Linux 64-bit
> Version: 7.1.0.0.alpha0+
> Build ID: 2bccbd2ba6c90d5e02285629c2b079c35260c08b
> CPU threads: 8; OS: Linux 5.6; UI render: default; VCL: kf5
> Locale: fi-FI (fi_FI.UTF-8); UI: en-US
> Calc: threaded
> Built on 3 June 2020

Sorry, this was actually with stable

Arch Linux 64-bit
Version: 6.4.4.2
Build ID: 6.4.4-1
CPU threads: 8; OS: Linux 5.6; UI render: default; VCL: kf5; 
Locale: fi-FI (fi_FI.UTF-8); UI-Language: en-US
Calc: threaded
Comment 20 QA Administrators 2022-06-07 03:27:02 UTC Comment hidden (obsolete)
Comment 21 QA Administrators 2024-06-07 03:16:16 UTC Comment hidden (obsolete)
Comment 22 Buovjaga 2024-08-11 18:27:31 UTC
Re-test requested in 2020, no reaction, so let's set this to needinfo.