Bug 103673 - User color value
Summary: User color value
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice Online
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-03 09:19 UTC by Aleksander Machniak
Modified: 2017-05-31 08:55 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksander Machniak 2016-11-03 09:19:01 UTC
I'm not sure it's a bug or not, but...

When I edit a document as single user, the Color in postMessage View_Added is a number 411298. I expect this to be hex value of css color. So, if I add '#' to it and use it on the page it looks violet/blue-ish.

However, in the editor window where users are listed I see a black rectangle near by "You" label: <td class="usercolor" style="background-color: #000;"></td>

So, either the editor displays wrong color or it is not a hex color value.
Comment 1 Aleksander Machniak 2016-11-03 13:07:52 UTC
I guess this is java color specification. I found how to convert it to hex in javascript:

color = ((color)>>>0).toString(16).slice(-6);
color = '#' + ("000000").substring(0, 6 - color.length) + color;

I'm not 100% sure this is correct.

Still, this is javascript API, so maybe you could use color in appropriate format.
Still, the color is different than the td.usercolor (which is black).
Comment 2 Pranav Kant 2016-11-07 11:59:54 UTC
(In reply to Aleksander Machniak from comment #1)
> I guess this is java color specification. I found how to convert it to hex
> in javascript:

These are RGB integer values directly fed to loleaflet by LO core.

> 
> color = ((color)>>>0).toString(16).slice(-6);
> color = '#' + ("000000").substring(0, 6 - color.length) + color;
> 
> I'm not 100% sure this is correct.

Yes, that is the correct way to convert. We convert it similarly in loleaflet too.

> Still, the color is different than the td.usercolor (which is black).

The color is explicitly set to black in case of current user, overwriting the value that you noticed in View_Added message so that it matches with the user's cursor which is black. LO core assigns each author a separate color and the value that you get in View_Added message is this same value. This is used in Change Tracking UI (coming soon ...), and comments. You can notice that the background color of comment box is same as of this value. Don't think would be a good idea to overwrite this value with black for current user as we/you might need it in future, but maybe we can add another postmessage API that let you know the viewid of the current user (?) [or maybe integrate the same in those editor init. message ?]
Comment 3 Aleksander Machniak 2016-11-07 12:09:55 UTC
(In reply to Pranav Kant from comment #2)
> > color = ((color)>>>0).toString(16).slice(-6);
> > color = '#' + ("000000").substring(0, 6 - color.length) + color;
> > 
> > I'm not 100% sure this is correct.
> 
> Yes, that is the correct way to convert. We convert it similarly in
> loleaflet too.

Maybe it would be good to have it already converted so any client-side code don't have to do it?

> > Still, the color is different than the td.usercolor (which is black).
> 
> The color is explicitly set to black in case of current user, overwriting
> the value that you noticed in View_Added message so that it matches with the
> user's cursor which is black. LO core assigns each author a separate color
> and the value that you get in View_Added message is this same value. This is
> used in Change Tracking UI (coming soon ...), and comments. You can notice
> that the background color of comment box is same as of this value. Don't
> think would be a good idea to overwrite this value with black for current
> user as we/you might need it in future, but maybe we can add another
> postmessage API that let you know the viewid of the current user (?) [or
> maybe integrate the same in those editor init. message ?]

Yeah, I found out it's the cursor color value. I think we can leave it as is.
Comment 4 Xisco Faulí 2017-04-13 08:42:01 UTC
Putting back to NEW as there's no assignee to this bug
Comment 5 Commit Notification 2017-05-31 08:51:57 UTC
Pranav Kant committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/online/commit/?id=073b58269b1fd63f946f3b7ba7b8b11754e5092c

tdf#103673 - Use hex color value in API