https://bugs.documentfoundation.org/show_bug.cgi?id=149714
Bug ID: 149714
Summary: BitsPerPixel property of Graphic has Boolean UNO type
Product: LibreOffice
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Keywords: difficultyBeginner, easyHack, skillCpp
Severity: normal
Priority: medium
Component: BASIC
Assignee: [email protected]
Reporter: [email protected]
Consider the code:
Sub TestGraphicBitsPerPixel
Dim oProps(0) As New com.sun.star.beans.PropertyValue
oProps(0).Name = "URL"
oProps(0).Value =
"https://bug-attachments.documentfoundation.org/attachment.cgi?id=177261"
oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
oGraphic = oProvider.queryGraphic(oProps())
MsgBox oGraphic.BitsPerPixel
End Sub
It uses attachment 177261 (that is simply a small PNG having 24 BPP), and the
expected output would be 24; but the actual result is "True".
The problem is implementation of BitsPerPixel property (documented to have
'byte' UNO type) [1] in vcl/source/graphic/UnoGraphicDescriptor.cxx, where the
UNO type is defined as cppu::UnoType< sal_uInt8 > [2]. But that type maps to
TypeClass::BOOLEAN [3], which makes Basic to convert the non-0 value to True.
The actual type that maps to TypeClass::BYTE is cppu::UnoType< sal_Int8 >.
The problem was since the introduction of the code in commit
7e83653a7fac894bee2c7c35fa2b84daac026642; there also was GraphicType property
using that type initially, but that was fixed in commit
0170d51253bddd1e8ec1c8c887b526f2fc18d019. The code that sets the numeric value
to the property [4] uses the correct sal_Int8 type.
The fix of this easyhack should contain a unit test.
[1]
https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1graphic_1_1GraphicDescriptor.html#ac99c505108bd7f6220e43c3f7a7a9040
[2]
https://opengrok.libreoffice.org/xref/core/vcl/source/graphic/UnoGraphicDescriptor.cxx?r=912b8fa6#241
[3]
https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1uno.html#a00683ed3ec24b47c36ead10a20d6f328a8a583f16e8d237a423c8c1d9087a4c72
[4]
https://opengrok.libreoffice.org/xref/core/vcl/source/graphic/UnoGraphicDescriptor.cxx?r=912b8fa6#381
--
You are receiving this mail because:
You are the assignee for the bug.