Exactly, that's what I had in mind, a kind of helper function for a more
permanent solution. In the meantime I'm beginning to look over the source
code to familiarize myself, to see if I can contribute such a solution.
We'll see how far I get...
Il 23/set/2015 03:32, "Carl Marcum" <cmar...@apache.org> ha scritto:

> On 09/22/2015 01:25 PM, John D'Orazio wrote:
>
>> Damjan thank you for the interest, xPropertySet is coming from the current
>> ViewCursor:
>>
>> //In the initialize method of the main class we get the XFrame of our
>> current application
>>              m_xFrame =
>> (com.sun.star.frame.XFrame)UnoRuntime.queryInterface(
>>                  com.sun.star.frame.XFrame.class, object[0]);
>>              m_xController = m_xFrame.getController();
>>              m_xModel = (XModel) xController.getModel();
>>              m_xTextDocument = (XTextDocument)
>> UnoRuntime.queryInterface(XTextDocument.class,m_xModel);
>>
>> //Then at some point we get the text range that corresponds with current
>> cursor position in document, and the XPropertySet of that XTextRange
>>              XTextViewCursorSupplier xViewCursorSupplier =
>> (XTextViewCursorSupplier)
>> UnoRuntime.queryInterface(XTextViewCursorSupplier.class,m_xController);
>>              m_xViewCursor = xViewCursorSupplier.getViewCursor();
>>              XTextRange xTextRange =
>> m_xViewCursor.getText().createTextCursorByRange(m_xViewCursor);
>>              XPropertySet xPropertySet =
>>              (XPropertySet)UnoRuntime.queryInterface(
>>                  XPropertySet.class, xTextRange);
>>
>> //Then we want to set the text color and the text background color
>> starting
>> from the current cursor position to a value chosen by the user of our
>> plugin
>>                  Color userChosenTextColor = Color.BLUE; //let's just use
>> blue for this example, in my actual plugin I am using JColorChooser
>>                  Color userChosenBackgroundColor = Color.YELLOW; //again
>> we'll just use yellow, in the actual plugin I am again using JColorChooser
>>
>>
>> xPropertySet.setPropertyValue("CharColor", userChosenTextColor.getRGB());
>>                  xPropertySet.setPropertyValue("CharBackColor",
>> userChosenBackgroundColor.getRGB());
>>
>> //Then we insert text into the document starting from the current cursor
>> position, the properties of which should reflect the properties set on the
>> XTextRange through the XPropertySet for that range
>>                  m_xText.insertString(xTextRange, "This is a test with
>> BLUE
>> text and YELLOW background", false);
>>
>> The results of the above code is a Blue colored text with no background
>> color (it should have a Yellow background). However this workaround in the
>> above code will work to give a Yellow background:
>>
>>                  xPropertySet.setPropertyValue("CharBackColor",
>> userChosenBackgroundColor.getRGB() & ~0xFF000000);
>>
>> I hope this helps.
>>
> Hi John,
>
> I've been trying to look into this.
> I don't think the problem is on the java uno side as it as they are
> generated from IDL files.
> Every java uno example I've found sets the color either as RBG in hex or
> decimal without the alpha high bits or with zero alpha bits.
> Background transparency is a separate boolean.
> I have found none that use the java Color.BLUE type method.  I suspect
> this has something to do with the IDL color property not handling the alpha
> bits in Java Color.  If you want to use the Java Colors you could use a
> utility method to strip the alpha bits as you have already found.
>
> It may be possible to add a utility method to one of the Java uno helper
> classes or add a new class for a more permanent solution.
>
> Best regards,
> Carl
>
> On Tue, Sep 22, 2015 at 4:51 PM, Damjan Jovanovic <dam...@apache.org>
>> wrote:
>>
>> Hi John
>>>
>>> Yes, you can see what the different directories are for on
>>> https://wiki.openoffice.org/wiki/Source_code_directories
>>>
>>> I understand about the colors. But I can't tell where your
>>> xPropertySet comes from. It is critical to know that. Is it obtained
>>> from the text cursor like the Basic example on that thread? Or
>>> something else?
>>>
>>> Damjan
>>>
>>>
>>> On Tue, Sep 22, 2015 at 4:24 PM, John D'Orazio
>>> <john.dora...@cappellaniauniroma3.org> wrote:
>>>
>>>> Ok I'll take a look at that area of the wiki, in the meantime I have
>>>>
>>> found
>>>
>>>> that the Writer code is under the main/sw folder (in fact I corrected a
>>>> page of the wiki that said it was under main/sd, which is instead the
>>>>
>>> Draw
>>>
>>>> application...)
>>>>
>>>> I posted some code samples in the forum thread that I opened and that I
>>>> posted in the first message of this thread.
>>>>
>>>> Let me try to explain again. Basically, if you try setting the
>>>> "CharBackColor" property from Java using an RGB integer value from a
>>>> Java
>>>> Color object, it simply doesn't work. I can "manually" set a value that
>>>> works by passing an RGB integer value with an "empty" alpha bit, for
>>>> example *xPropertySet.setProperty("CharBackColor", 0x00FF0000)* will
>>>> successfully set the text background color to Red.
>>>>
>>>> However, when working with the Java Color object, the alpha bit is
>>>> automatically set by the Java Color object to 0xFF (which corresponds to
>>>> full opacity, whereas 0x00 actually corresponds with full transparency).
>>>>
>>>> In my understanding, OpenOffice doesn't support alpha transparency for
>>>> background color and therefore assumes a value of 0x00 for the alpha
>>>> bit,
>>>> and if any other value than 0x00 is set in the alpha bit OpenOffice just
>>>> doesn't like it and winds up not displaying the background color at all.
>>>>
>>>> This normally isn't a problem with Basic, because with Basic the color
>>>> operations don't automatically set the alpha bit. You can create an RGB
>>>> integer with Basic that has no alpha bit. You cannot however with the
>>>>
>>> Java
>>>
>>>> Color object: *Color.YELLOW.getRGB()* in Java will give you an integer
>>>>
>>> that
>>>
>>>> has the alpha bit set to 0xFF (= full opacity) by default. And
>>>> OpenOffice
>>>> isn't liking it.
>>>>
>>>> So when working in Java, I have found it necessary to clear the alpha
>>>> bit
>>>> before passing in the integer value: *Color.YELLOW.getRGB() &
>>>>
>>> ~0xFF000000* does
>>>
>>>> the trick here.
>>>>
>>>> It took me a while to figure out what was going on here and to figure
>>>> out
>>>> the necessary workaround with this bitwise operation. I don't think that
>>>> this is intended behaviour, it shouldn't be necessary to explicitly
>>>> clear
>>>> the alpha bit with a bitwise operation in order to set the Character
>>>> Background Color. I'm figuring maybe in earlier versions of Java the
>>>>
>>> alpha
>>>
>>>> bit was not set by default but now it is, or maybe this has been simply
>>>> overlooked.
>>>>
>>>> I hope I have explained better now? I'm looking over the source code to
>>>>
>>> see
>>>
>>>> where exactly OpenOffice is taking the integer value set in the
>>>> "CharBackColor" property and actually applying it to the text in the
>>>> document. That's probably where it's assuming an alpha bit of 0x00 but
>>>> it
>>>> shouldn't be. If background transparency is not supported per design,
>>>>
>>> then
>>>
>>>> OpenOffice not assume an empty alpha bit but should check for the alpha
>>>>
>>> bit
>>>
>>>> value and simply clear it or set it to 0xFF (= full opacity).
>>>>
>>>>
>>>>
>>>> On Tue, Sep 22, 2015 at 10:25 AM, Damjan Jovanovic <dam...@apache.org>
>>>> wrote:
>>>>
>>>> Hi John
>>>>>
>>>>> Have you looked at the development documentation for Writer
>>>>> (https://wiki.openoffice.org/wiki/Writer)?
>>>>>
>>>>> It would also help if you posted a code sample so we can see what you
>>>>> are trying to set the color on.
>>>>>
>>>>> Damjan
>>>>>
>>>>> On Mon, Sep 21, 2015 at 9:17 PM, John D'Orazio
>>>>> <john.dora...@cappellaniauniroma3.org> wrote:
>>>>>
>>>>>> Does anyone know if the Writer application uses some kind of canvas
>>>>>> interface for formatting and displaying text? I'm picking up on
>>>>>>
>>>>> "canvas"
>>>
>>>> here and there but I'm not sure if it's only for the Drawing
>>>>>>
>>>>> application,
>>>
>>>> or if all Applications use a form of canvas.
>>>>>> I'm guessing the problem with the Java values having the alpha bit and
>>>>>>
>>>>> the
>>>>>
>>>>>> Uno/Basic values not having the alpha bit for Character Background
>>>>>>
>>>>> Color
>>>
>>>> would need to be addressed somewhere around where the values are
>>>>>>
>>>>> passed
>>>
>>>> between the two, or where the value is actually set to the Writer
>>>>>> interface. I'm still trying to get an idea of how the source code is
>>>>>> organized...
>>>>>>
>>>>>> On Mon, Sep 21, 2015 at 8:45 PM, John D'Orazio <
>>>>>> john.dora...@cappellaniauniroma3.org> wrote:
>>>>>>
>>>>>> Thanks for the tip on OpenGrok! it rocks :D did a search in 887
>>>>>>> milliseconds, not bad at all. I guess it has the source code already
>>>>>>> indexed so it's a lot faster. That's a big help!
>>>>>>>
>>>>>>> On Mon, Sep 21, 2015 at 8:20 PM, Damjan Jovanovic <dam...@apache.org
>>>>>>> wrote:
>>>>>>>
>>>>>>> I use Eclipse but I first build OpenOffice and then only open 1
>>>>>>>>
>>>>>>> module
>>>
>>>> at a time. If you plan to open the entire project, you'll need a lot
>>>>>>>> of RAM and to increase Eclipse/Java memory limits.
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> Damjan
>>>>>>>>
>>>>>>>> On Mon, Sep 21, 2015 at 7:47 PM, John D'Orazio
>>>>>>>> <john.dora...@cappellaniauniroma3.org> wrote:
>>>>>>>>
>>>>>>>>> Ok I'm trying to get the sources on my local computer to take a
>>>>>>>>>
>>>>>>>> better
>>>>>
>>>>>> look
>>>>>>>>
>>>>>>>>> at them, it'll be easier to search them locally and start to get
>>>>>>>>>
>>>>>>>> to
>>>
>>>> know
>>>>>
>>>>>> them. Does anyone use Eclipse to work with the source code? I'm
>>>>>>>>>
>>>>>>>> giving
>>>>>
>>>>>> it a
>>>>>>>>
>>>>>>>>> try to see if it is feasible... I saw this page
>>>>>>>>> <https://wiki.openoffice.org/wiki/OpenOffice_and_Eclipse> that
>>>>>>>>>
>>>>>>>> says
>>>
>>>> it
>>>>>
>>>>>> should be doable.
>>>>>>>>>
>>>>>>>>> On Sat, Sep 19, 2015 at 7:18 PM, John D'Orazio <
>>>>>>>>> john.dora...@cappellaniauniroma3.org> wrote:
>>>>>>>>>
>>>>>>>>> Yes I tried setting the CharBackTransparent boolean also, it had
>>>>>>>>>>
>>>>>>>>> no
>>>
>>>> effect. From my latest "research" I believe that it's not the
>>>>>>>>>>
>>>>>>>>> case
>>>
>>>> that
>>>>>
>>>>>> transparent and opaque values are being exchange, it's simply
>>>>>>>>>>
>>>>>>>>> that
>>>
>>>> OpenOffice doesn't support transparency for background colors and
>>>>>>>>>>
>>>>>>>>> because
>>>>>>>>
>>>>>>>>> of this seems to use "0x00" for the alpha bit (which would
>>>>>>>>>>
>>>>>>>>> normally
>>>
>>>> mean
>>>>>>>>
>>>>>>>>> transparent rather than opaque!).
>>>>>>>>>> The problem is that the Java Color Object and any other kind of
>>>>>>>>>>
>>>>>>>>> Color
>>>>>
>>>>>> handling such as with JColorChooser, always set the alpha bit. So
>>>>>>>>>>
>>>>>>>>> I'm
>>>>>
>>>>>> having to explicitly unset the alpha bit / set it to 0x00 before
>>>>>>>>>>
>>>>>>>>> trying to
>>>>>>>>
>>>>>>>>> set the background color.
>>>>>>>>>> I believe this is something that can / should be handled behind
>>>>>>>>>>
>>>>>>>>> the
>>>
>>>> scenes, by the OpenOffice API. If it doesn't support
>>>>>>>>>>
>>>>>>>>> transparency it
>>>
>>>> should
>>>>>>>>
>>>>>>>>> however check for the alpha bit and set it to whatever it likes
>>>>>>>>>>
>>>>>>>>> it
>>>
>>>> to
>>>>>
>>>>>> be.
>>>>>>>>
>>>>>>>>> So anyone trying to set transparency will simply get opaque,
>>>>>>>>>>
>>>>>>>>> rather
>>>
>>>> than
>>>>>>>>
>>>>>>>>> get nothing.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Sat, Sep 19, 2015 at 4:31 PM, Carl Marcum <cmar...@apache.org
>>>>>>>>>>
>>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> On 09/17/2015 07:24 PM, John D'Orazio wrote:
>>>>>>>>>>>
>>>>>>>>>>> I believe I have found what can be considered a bug, or at
>>>>>>>>>>>>
>>>>>>>>>>> least
>>>
>>>> not
>>>>>
>>>>>> intended behaviour, in the way the OpenOffice API takes values
>>>>>>>>>>>>
>>>>>>>>>>> from
>>>>>
>>>>>> Java
>>>>>>>>
>>>>>>>>> when setting certain text properties (in this case
>>>>>>>>>>>>
>>>>>>>>>>> "CharBackColor")
>>>>>
>>>>>> using
>>>>>>>>
>>>>>>>>> the XPropertySet interface. I have been discussing this on a
>>>>>>>>>>>>
>>>>>>>>>>> forum
>>>
>>>> thread (
>>>>>>>>>>>>
>>>>>>>>>>>>
>>> https://forum.openoffice.org/en/forum/viewtopic.php?f=44&t=79294&p=364347
>>>
>>>> )
>>>>>>>>>>>> and have opened an issue for it on the bugzilla tracker (
>>>>>>>>>>>> https://bz.apache.org/ooo/show_bug.cgi?id=126531).
>>>>>>>>>>>>
>>>>>>>>>>>> I would be willing to look into it and work on a patch for
>>>>>>>>>>>>
>>>>>>>>>>> this,
>>>
>>>> if
>>>>>
>>>>>> anyone
>>>>>>>>>>>> can point me in the right direction of where exactly to look in
>>>>>>>>>>>>
>>>>>>>>>>> the
>>>>>
>>>>>> Open
>>>>>>>>
>>>>>>>>> Office source code... I have been skimming over it in the svn
>>>>>>>>>>>>
>>>>>>>>>>> repo (
>>>>>
>>>>>> https://svn.apache.org/repos/asf/openoffice/trunk/), but for a
>>>>>>>>>>>>
>>>>>>>>>>> newcomer
>>>>>>>>
>>>>>>>>> it's hard to know where to look (I'm guessing it might have to
>>>>>>>>>>>>
>>>>>>>>>>> do
>>>
>>>> with
>>>>>>>>
>>>>>>>>> the
>>>>>>>>>>>> XPropertySet interface, or wherever the Text Properties
>>>>>>>>>>>>
>>>>>>>>>>> supported
>>>
>>>> by
>>>>>
>>>>>> the
>>>>>>>>
>>>>>>>>> interface are defined). If anyone can point me in the right
>>>>>>>>>>>>
>>>>>>>>>>> direction I
>>>>>>>>
>>>>>>>>> can
>>>>>>>>>>>> try to look into it...
>>>>>>>>>>>>
>>>>>>>>>>>> Hi John,
>>>>>>>>>>>>
>>>>>>>>>>> I'm actually just beginning to look into how the java jars are
>>>>>>>>>>>
>>>>>>>>>> built
>>>>>
>>>>>> so I
>>>>>>>>
>>>>>>>>> may need corrected by someone.
>>>>>>>>>>>
>>>>>>>>>>> I think the java files are "Built" from IDL files and packaged
>>>>>>>>>>>
>>>>>>>>>> into
>>>
>>>> the
>>>>>>>>
>>>>>>>>> jar files during a build process.
>>>>>>>>>>>
>>>>>>>>>>> I have only svn checked out the AOO code last night and begun
>>>>>>>>>>>
>>>>>>>>>> looking.
>>>>>
>>>>>> For instance if you search the codebase for XPropertySet the
>>>>>>>>>>>
>>>>>>>>>> only
>>>
>>>> java
>>>>>
>>>>>> files I have found are in QA type directories.
>>>>>>>>>>>
>>>>>>>>>>> Have you tried to additionally set the CharBackTransparent
>>>>>>>>>>>
>>>>>>>>>> boolean
>>>
>>>> property as well [1].
>>>>>>>>>>>
>>>>>>>>>>> [1]
>>>>>>>>>>>
>>>>>>>>>>>
>>> https://www.openoffice.org/api/docs/common/ref/com/sun/star/style/CharacterProperties.html#CharBackColor
>>>
>>>> Thanks,
>>>>>>>>>>> Carl
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>>> To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
>>>>>>>>>>> For additional commands, e-mail: dev-h...@openoffice.apache.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> John R. D'Orazio
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>> ---------------------------------------------------------------------
>>>
>>>> To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
>>>>>>>> For additional commands, e-mail: dev-h...@openoffice.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> --
>>>>>>> John R. D'Orazio
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> John R. D'Orazio
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
>>>>> For additional commands, e-mail: dev-h...@openoffice.apache.org
>>>>>
>>>>>
>>>>>
>>>> --
>>>> don John R. D'Orazio
>>>> Cappellano Coordinatore
>>>> ________________________________________
>>>>
>>>> Servizio di Cappellania - Università degli Studi Roma Tre
>>>> Piazzale San Paolo 1/d - 00120 Città del Vaticano
>>>> tel. +39 06-69880809 - cell. +39 333/2545447
>>>> E-Mail: *cappellania.uniro...@gmail.com* <
>>>> cappellania.uniro...@gmail.com>
>>>>
>>> |
>>>
>>>> *cappella...@uniroma3.it* <cappella...@uniroma3.it>
>>>> ----
>>>> Sito Web: http://www.cappellaniauniroma3.org
>>>> Twitter: https://twitter.com/CappellaniaR3
>>>> Flickr: http://www.flickr.com/people/cappellaniauniroma3/
>>>> Pagina Facebook: https://www.facebook.com/cappellania.uniroma3
>>>> Gruppo Facebook: https://www.facebook.com/groups/cappellania.uniroma3
>>>> Pagina Google+: https://plus.google.com/+CappellaniaUniRoma3org
>>>> Community Google+: http://gplus.to/CappellaniaUniRoma3
>>>> LinkedIn:
>>>>
>>>>
>>> http://www.linkedin.com/company/cappellania-universit-degli-studi-roma-tre
>>>
>>>> ----
>>>> Per iscriversi al Calendario Pubblico della Cappellania (con account
>>>> gmail): [image: Iscriviti con Google Calendar]
>>>> <
>>>>
>>>
>>> https://www.google.com/calendar/render?cid=8jugejikjtlks094p62hled6vs%40group.calendar.google.com
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
>>> For additional commands, e-mail: dev-h...@openoffice.apache.org
>>>
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
> For additional commands, e-mail: dev-h...@openoffice.apache.org
>
>

Reply via email to