Bug 165282 - Our macro for setting the Document Background Color stopped working with version 25.2.0.3
Summary: Our macro for setting the Document Background Color stopped working with vers...
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
25.2.0.3 release
Hardware: All All
: medium normal
Assignee: Sahil Gautam (allotropia)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: LibreOffice-Themes
  Show dependency treegraph
 
Reported: 2025-02-16 18:50 UTC by Michael
Modified: 2025-02-19 15:21 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Image of the spreadsheet when entering data with a dark active cell background (14.79 KB, image/jpeg)
2025-02-17 01:33 UTC, Michael
Details
ChangeDocBgColor macro fails after version 25.02.03 (3.09 KB, text/plain)
2025-02-19 14:14 UTC, Michael
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael 2025-02-16 18:50:36 UTC
We have been using a macro to change the Document Background Color. This macro stopped working with version 25.02.0.3. The problem is with this line:

keyNodeColor.setPropertyValue("Color", rgb(R,G,B))

where:
keyNode = Tools.Misc.GetRegistryKeyContent("org.openoffice.Office.UI/ColorScheme", False)
curScheme = keyNode.CurrentColorScheme
' Get the scheme node
nodeName = "org.openoffice.Office.UI/ColorScheme/ColorSchemes/" & curScheme & "/DocColor"
' Set the root path for our configuration access
keyNodeColor = Tools.Misc.GetRegistryKeyContent(nodeName, True)


This is the error message:

BASIC runtime error.
An exception occurred
Type: com.sun.star.beans.UnknownPropertyException
Message: Color.

Version: 25.2.0.3 (X86_64) / LibreOffice Community
Build ID: e1cf4a87eb02d755bce1a01209907ea5ddc8f069
CPU threads: 4; OS: Windows 11 X86_64 (10.0 build 22000); UI render: Skia/Raster; VCL: win
Locale: en-CA (en_CA); UI: en-US
Calc: CL threaded

I can supply the entire macro if needed, but I think the line with the error and the definitions should suffice.
Comment 1 V Stuart Foote 2025-02-16 22:12:37 UTC
@Sahil, @Heiko, were there also API changes expected around removal of Application Colors? What would folks need to use now to macro script UI with new Appearance themes. Just a 'customization' name change in the new framework?
Comment 2 V Stuart Foote 2025-02-16 22:16:29 UTC
@Michael

Was purpose of that adjusting the document's style, ie. to change its printed/output page color? Or just its appearance in the UI--responding to os/DE or appearance theme/app colors?
Comment 3 Michael 2025-02-17 01:28:38 UTC
The purpose was to change the background colour of the active cell when entering data. Currently, the colour of the active cell when entering data is set by the Document Background Color. We transcribe historic weather data with the image of the document page as the image background. These images can be quite dark, and it is easier to see our entered text with a yellow font. However, it is hard to see the yellow font when you are entering the data against the white background of the active cell. We get around it by changing the Document Background Color.
Comment 4 Michael 2025-02-17 01:33:14 UTC
Created attachment 199237 [details]
Image of the spreadsheet when entering data with a dark active cell background

This image shows how we use a yellow font when entering data. The font is very visible against the image, and it is easy to see against the non-white background of the cell when we are entering the data. In an ideal world, the cell background, when entering data, would be transparent so we could see the image while we type. We were told, when asking for that enhancement, that it would be too difficult to implement, so changing the Document Background Color is our option.
Comment 5 Heiko Tietze 2025-02-17 07:30:53 UTC
(In reply to Michael from comment #0)
> nodeName = "org.openoffice.Office.UI/ColorScheme/ColorSchemes/" & curScheme
> & "/DocColor"
We distinguish between Light and Dark now (see also bug 164970) and you might need to add what is defined on the OS/DE. Or force the appearance to be one.
Comment 6 Sahil Gautam (allotropia) 2025-02-19 04:37:02 UTC
@Michael does that work for you? can we close the ticket.
Comment 7 Michael 2025-02-19 14:10:28 UTC
That definition of nodename is the exactly the same as what I was using.

These are the pertinent lines:

nodeName = "org.openoffice.Office.UI/ColorScheme/ColorSchemes/" & curScheme & "/DocColor"
' Set the root path for our configuration access
keyNodeColor = Tools.Misc.GetRegistryKeyContent(nodeName, True)

And, farther down, this is the line that fails:
keyNodeColor.setPropertyValue("Color", rgb(R,G,B))

with this message:
BASIC runtime error.
An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: Color.

I will attach the full macro.
Comment 8 Michael 2025-02-19 14:14:00 UTC
Created attachment 199312 [details]
ChangeDocBgColor macro fails after version 25.02.03

This is the macro that fails. I have commented out the On Local Error line.
Comment 9 Sahil Gautam (allotropia) 2025-02-19 15:09:01 UTC
(In reply to Michael from comment #8)
> Created attachment 199312 [details]
> ChangeDocBgColor macro fails after version 25.02.03
> 
> This is the macro that fails. I have commented out the On Local Error line.

for all the lines which set the color property value (like the one below)

keyNodeColor.setPropertyValue("Color",Colour(Value))

please replace them with two of these statements one for "Light", and one for "Dark", something like this.


keyNodeColor.setPropertyValue("Light",Colour(Value))
keyNodeColor.setPropertyValue("Dark",Colour(Value))
Comment 10 Michael 2025-02-19 15:18:49 UTC
That works, thank you. I'm sorry for being so slow to catch on.