You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openoffice.apache.org by bu...@apache.org on 2015/09/16 02:25:29 UTC

[Issue 126531] New: different behaviour for "CharColor" and "CharBackColor" properties in java

https://bz.apache.org/ooo/show_bug.cgi?id=126531

          Issue ID: 126531
        Issue Type: DEFECT
           Summary: different behaviour for "CharColor" and
                    "CharBackColor" properties in java
           Product: App Dev
           Version: 4.1.1
          Hardware: PC
                OS: Windows 10
            Status: UNCONFIRMED
          Severity: normal
          Priority: P5
         Component: api
          Assignee: issues@openoffice.apache.org
          Reporter: john.dorazio@cappellaniauniroma3.org

==Overview==
When using the com.sun.star.beans.XPropertySet interface in a java extension, I
am seeing different behaviour for the "CharColor" property and the
"CharBackColor" property. The API documentation says that they take a "long"
value; and it then gives as an example the usage of a hex number such as
0x00FFFF00
(https://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Formatting). The
"CharBackColor" property, differently from the "CharColor" property, will not
take an integer value such as the one produced by the Color.getRGB() method.

==Steps to reproduce==
The "CharColor" property will take an integer as produced by the getRGB()
method:

    xPropertySet.setPropertyValue("CharColor", Color.YELLOW.getRGB());

This will correctly set the character color to yellow.
However this will not work for the "CharBackColor" property:

    xPropertySet.setPropertyValue("CharBackColor", Color.YELLOW.getRGB());

This simply will not do anything, it does not give an error but it also does
not set the background to yellow. This will work instead:

    xPropertySet.setPropertyValue("CharBackColor", 0x00FFFF00);

Casting a variable as "long" and passing it in as value for the "CharBackColor"
property results in an error:

long bgColor = 0x00FFFF00; //Long bgColor = (long) 0x00FFFF00
xPropertySet.setPropertyValue("CharBackColor", bgColor);

com.sun.star.lang.IllegalArgumentException: 
    at com.sun.star.bridges.jni_uno.JNI_proxy.dispatch_call(Native Method)
    at com.sun.star.bridges.jni_uno.JNI_proxy.invoke(JNI_proxy.java:171)
    at com.sun.proxy.$Proxy6.setPropertyValue(Unknown Source)

==Actual results==
Passing an integer value as produced by Color.getRGB() into the "CharBackColor"
property will not throw an error but will have no result. Passing a value cast
as "long" or "Long" or "int" will result in an error.

==Expected results==
Passing a Color.getRGB() value into the "CharBackColor" property should be
sufficient to correctly set the color.

-- 
You are receiving this mail because:
You are the assignee for the issue.

[Issue 126531] different behaviour for "CharColor" and "CharBackColor" properties in java

Posted by bu...@apache.org.
https://bz.apache.org/ooo/show_bug.cgi?id=126531

--- Comment #5 from John R. D'Orazio <jo...@cappellaniauniroma3.org> ---
I believe I understand what the "CharBackTransparent" property is doing,
basically it means if you want "no color" as opposed to white background, then
you set "CharBackTransparent" to true so that no matter what the
"CharBackColor" is set to, there will still be no background at all (you would
need this property if the alpha bit is not read from the "CharBackColor"
property in fact).

Therefore it is of no help when you are wanting to see and set a Character
Background Color. "CharBackTransparent" would have to be set to false in order
to see any background color, but it does not modify how the alpha bit in
"CharBackColor" is being dealt with, it's a simple ovverride is what I'm
guessing.

-- 
You are receiving this mail because:
You are the assignee for the issue.

[Issue 126531] different behaviour for "CharColor" and "CharBackColor" properties in java

Posted by bu...@apache.org.
https://bz.apache.org/ooo/show_bug.cgi?id=126531

--- Comment #1 from John R. D'Orazio <jo...@cappellaniauniroma3.org> ---
I have run some further tests, and I see that the CharBackColor property has
swapped the alpha value such that a value of 0 (or 0.0, or 0x00) is treated as
opaque and a value of 255 (or 1.0, or 0xFF) is treated as transparent.

This is not the case for the CharColor property which seems to behave as it
should.

xPropertySet.setPropertyValue("CharBackColor", Color.YELLOW.getRGB()); //-> has
no visible effect because is treated as transparent!

xPropertySet.setPropertyValue("CharBackColor", Color.YELLOW.getRGB() -
0xFF000000); //-> sets an opaque yellow background color! having subtracted the
alpha bits and setting them 0 should give a transparent color, but Open Office
is treating transparent as opaque in this case!

-- 
You are receiving this mail because:
You are the assignee for the issue.

[Issue 126531] different behaviour for "CharColor" and "CharBackColor" properties in java

Posted by bu...@apache.org.
https://bz.apache.org/ooo/show_bug.cgi?id=126531

John R. D'Orazio <jo...@cappellaniauniroma3.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.dorazio@cappellaniauni
                   |                            |roma3.org
           Keywords|                            |usability

-- 
You are receiving this mail because:
You are the assignee for the issue.

[Issue 126531] different behaviour for "CharColor" and "CharBackColor" properties in java

Posted by bu...@apache.org.
https://bz.apache.org/ooo/show_bug.cgi?id=126531

John R. D'Orazio <jo...@cappellaniauniroma3.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|john.dorazio@cappellaniauni |
                   |roma3.org                   |

-- 
You are receiving this mail because:
You are the assignee for the issue.

[Issue 126531] different behaviour for "CharColor" and "CharBackColor" properties in java

Posted by bu...@apache.org.
https://bz.apache.org/ooo/show_bug.cgi?id=126531

--- Comment #4 from John R. D'Orazio <jo...@cappellaniauniroma3.org> ---
I can also add that I have tried to set the "CharBackTransparent" property both
to true and to false before setting the "CharBackColor" property, but it had no
effect. In any case I have to clear the alpha bit.
(So what exactly does the "CharBackTransparent" property do? Is it supposed to
enable transparency for background colors? Doesn't seem to be working if it
is...)

-- 
You are receiving this mail because:
You are the assignee for the issue.

[Issue 126531] different behaviour for "CharColor" and "CharBackColor" properties in java

Posted by bu...@apache.org.
https://bz.apache.org/ooo/show_bug.cgi?id=126531

--- Comment #2 from John R. D'Orazio <jo...@cappellaniauniroma3.org> ---
I think I understand a little better what is happening here.
It seems that OpenOffice perhaps doesn't support the alpha bit for background
colors, and so assumes an empty bit such as 0x00. However 0x00 actually means
100% transparency, compared to 0xFF which means 0% transparency (full opacity).

However, since Java automatically sets the alpha bit with the Color object or
with JColorChooser or any similar handling of colors, the only way to get
OpenOffice to correctly accept the color value is to explicitly unset or clear
the alpha bit before setting the integer value for the "CharBackColor"
property. I am currently doing this with a bitwise operation that clears the
bit. Example:

xPropertySet.setPropertyValue("CharBackColor", Color.YELLOW.getRGB() &
~0xFF000000);

I will do a little more investigation to see if I can gather any more
information on this issue...

-- 
You are receiving this mail because:
You are the assignee for the issue.

[Issue 126531] different behaviour for "CharColor" and "CharBackColor" properties in java

Posted by bu...@apache.org.
https://bz.apache.org/ooo/show_bug.cgi?id=126531

--- Comment #3 from John R. D'Orazio <jo...@cappellaniauniroma3.org> ---
I can also add that "int" is the correct type in Java for the "long" type in
UNO, I found a page about type mapping for Java:
https://wiki.openoffice.org/wiki/Uno/Java/Specifications/Type_Mapping

-- 
You are receiving this mail because:
You are the assignee for the issue.