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: NEW
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: imageHandling-regressions
  Show dependency treegraph
 
Reported: 2019-09-03 12:37 UTC by Balint Fodor
Modified: 2019-09-06 07:47 UTC (History)
6 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

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
The problem seems to be linked to anchoring of the object :

Process 10694 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001842dfa4b libswlo.dylib`SwFEShell::ShouldObjectBeSelected(this=0x00000001803f9f40, rPt=0x00007ffeefbfe8b8) at feshview.cxx:1361:83
   1358	            {
   1359	                if ( pObj->GetLayer() == rIDDMA.GetHellId() )
   1360	                {
-> 1361	                    const SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
   1362	                    const SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat();
   1363	                    const SwFormatSurround& rSurround = rFormat.GetSurround();
   1364	                    if ( rSurround.GetSurround() == css::text::WrapTextMode_THROUGH )
Target 0: (soffice) stopped.
Comment 17 Alex Thurgood 2019-09-06 07:47:05 UTC
(In reply to Alex Thurgood from comment #16)

Sorry, wrong bug, apols.