Bug 110986 - Progressbar:setForegroundColor() does not work
Summary: Progressbar:setForegroundColor() does not work
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
Depends on:
Reported: 2017-08-01 12:53 UTC by Thomas Krumbein
Modified: 2020-06-29 10:02 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:
Regression By:

example dialog (23.19 KB, application/vnd.oasis.opendocument.spreadsheet)
2017-08-01 12:53 UTC, Thomas Krumbein
bt with debug symbols (20.46 KB, text/plain)
2017-08-01 22:22 UTC, Julien Nabet

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Krumbein 2017-08-01 12:53:55 UTC
Created attachment 135049 [details]
example dialog

Creating a Progressbar inside of a dialog the service com.sun.star.awt.UnoControlProgressBarModel export the Interface com.sun.star.awt.XProgressBar.

This interface has a public function setForegroundColor() which should define the progressbar foreground color.

But it does not work. 

After setting a foreground color and checking it with XRAY - it is still empty. 

When changing color during Process... no reaction.

You can call and start example Document and start progress-bar. should change color by reaching 80% ...

checked on Windows 10, Lo, 5.3.x and Linux, Lo 5.3.x
Comment 1 Xisco Faulí 2017-08-01 14:34:33 UTC
Thank you for reporting the bug.
Unfortunately without clear steps to reproduce it, we cannot track down the origin of the problem.
Please provide a clearer set of step-by-step instructions on how to reproduce the problem.
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the steps are provided
Comment 2 Thomas Krumbein 2017-08-01 14:47:35 UTC
Hey Fauli,

"Unfortunately without clear steps to reproduce it, we cannot track down the origin of the problem." ???

That ist real stupid. All nessessary steps are declared even with API services.

The attached file do have a working code example inside. So I am sure- if you are really interested to solve the problem or even to understand - you do have all informations.

But for beginners:

- create a dialog inside the Basic IDE (graphice)
- put a dialog-Element "Progessbar" to this dialog
- write the code to start the dialog
- get the object of the progressbar
- change the foreground color i.e. to RGB(200,0,0) (this is red!)
- execute your dialog
- run the code for displaing progress bar -> foreground is green - I guess, this is a predefined value. 

Foregroundcolor do not have any effect. Just for tests: change property setbackgroundcolor() - an you can see the effect - that works;)

this is the code-segment out of the attached file:

sub Fortschrittsbalken
  Dim oCtl as object, i%
  oCtl = oDialog.getControl("ProgressBar1")
  oCtl.setRange(0, 100)

  for i = 1 to 100
    oDialog.getControl("Label9").text = CStr(i)
    oCtl.getModel().ProgressValue = i
    if oCtl.getValue/100 > 0.8 then
	oCtl.setForeGroundColor(RGB(200, 0, 0))
    end if
end sub

this should change progress-bar color to red by reaching 80% - an this works till min. OOo 3.2.1.
Comment 3 Regina Henschel 2017-08-01 19:02:13 UTC
It does not work for me with OpenOffice 3.2.1 OOO320m18(Build:9502) on Windows 7, 32 bit. Do you have a build number for the working version?

It works for me with OOo2.4.3, but that has a different kind of progress bar.
Comment 4 Julien Nabet 2017-08-01 22:22:54 UTC
Created attachment 135059 [details]
bt with debug symbols

On pc Debian x86-64 with master sources updated today, I could reproduce this.

Quite naively, I thought that by finding where setBackground is called I could find the missing mechanism for setForeground.
Here's the bt, I don't see anything obvious but I'm not expert.
Comment 5 Thomas Krumbein 2017-08-02 05:54:33 UTC
@ Regina: No, sorry, I do nit have such an old version;)

Example was part of mey book "OpenOffice.org 3 Macros" which I momentary rework. 

Methode is still part of the com.sun.star.awt.XProgressBar Interfache - so, if it doesn´t work and nobody care´s about - methode should be removed.

Otherwise... then there is no possibility to change color of progressbar.
Comment 6 Julien Nabet 2017-08-02 07:08:39 UTC
About your Xisco's response, have in mind that:
- there are hundreds of bugs in LO so the first goal is to be able to reproduce the problem quickly. It means in this case: just a snippet showing the bug and minimum steps to reproduce (just click a button would have been great) since it seems you know well Basic, I think it would have been quick and easy
- not anyone knows how to use Basic + know German so providing an example in English is a good idea

About your last response:
as a dev, I suppose you know that you can't change a public interface

Now if you want to get involved in LO (Dev, QA, doc or other), you can start here:
https://www.libreoffice.org/community/get-involved/, we're pleased to receive some patches.
But please stop being condenscending.
Comment 7 Regina Henschel 2017-08-04 18:39:32 UTC
The problem came in, when OpenOffice.org has switched to native controls. Setting the environment variable SAL_NO_NWF=true, you can disable the native widget look. Then you get the self-painted controls and for them, setting the foreground color works.
Comment 8 Thomas Krumbein 2017-08-06 11:59:50 UTC
Thanks Regina for this Information.

It is part of my "Macro Book" and because I will not compile LO and even "normal" user will not do this, I will remove this part of information out of the book and just put in a short message, that hthis will not work in standard LO versions. 

by the way... it does not work with AOO too.

So, task can be closed.
Comment 9 Regina Henschel 2017-08-06 14:44:53 UTC
There exists some questions in the Windows forums, but in all answers I have read, only two options are mentioned: (1) Disable Visual Styles (which would make controls look like in Windows98) or (2) paint your own control. Conclusion: Windows has no method to change the color for a single progressbar, but the color is bound to the Windows UI theme.

I suggest not to close this bug. I have changed the component to "sdk". Request: Add a remark to the description of setForeGroundColor(), that it has no effect on Windows OS.

I don't know, whether other OS are affected too. This needs to be checked. If other OS have the same problem, then this method should be marked as "deprecated".
Comment 10 Thomas Krumbein 2017-08-06 15:15:28 UTC
Linux Mint 18:  same behaviour - setForeGroundColor() has no effect
Comment 11 QA Administrators 2018-08-07 02:32:53 UTC Comment hidden (obsolete)
Comment 12 Julien Nabet 2020-06-29 10:02:04 UTC
I'm trying to give it a new try but I don't remember how to do this.

Indeed, after having created a dialog and a progressbar and copy pasted the code, I got:
BASIC runtime error.
Object variable not set.

I suppose I miss something easy but if someone could attach a minimum example file in English, it could help.