Bug 119590 - Wrong color scale conditional formatting structure with BASIC
Summary: Wrong color scale conditional formatting structure with BASIC
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.1.0.3 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-UNOAPI
  Show dependency treegraph
 
Reported: 2018-08-29 15:22 UTC by Fab
Modified: 2021-11-21 03:58 UTC (History)
2 users (show)

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


Attachments
conditionalformat (94.78 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-08-30 14:19 UTC, Oliver Brinzing
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fab 2018-08-29 15:22:01 UTC
Description:
When creating a new color scale conditional formatting, the *ColorScaleEntries* array is empty and I was not able to find any way to create any new *com.sun.star.sheet.XColorScaleEntry* entry in it (2 or 3, depending of which color scale).
Furthermore, when editing this newly created color scale conditional formatting with the Conditional Formatting graphic tool in Calc, Calc crashes !

(I used Xray to see the structure.)


***************************

Sub addColorScaleCF

    Dim oDoc                 As Object
    Dim oRanges              As Object  'Method "createByRange" needs a range collection

    Dim oSheet               As Object
    Dim oRange               As Object

    Dim EveryCF              As Object
    Dim NewCF                As Object


    oDoc = ThisComponent
    oRanges = oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")

    oSheet = oDoc.Sheets.getByIndex(0)
    oRange = oSheet.getCellRangeByName("A1:A4")

    'Add oRange to the range collection
    oRanges.insertByName("", oRange)

    'Get Every CF in sheet
    EveryCF = oSheet.ConditionalFormats

    'Add a new CF
    EveryCF.createByRange(oRanges)

    'Get the newly created CF
    NewCF= EveryCF.ConditionalFormats(EveryCF.Length - 1)

    'Add a new entry (color scale) in the CF
    NewCF.createEntry(com.sun.star.sheet.ConditionEntryType.COLORSCALE, 0)

    'Explore the new entry
    'Xray NewCF.getByIndex(0)

End Sub


***************************

Xray RESULTS
=============
ColorScaleEntries    []com.sun.star.sheet.XColorScaleEntry  <empty>   
ImplementationId     []byte                                 <empty>  (get), read-only 
PropertySetInfo      com.sun.star.beans.XPropertySetInfo             (get), read-only 
Type                 long                                         1  (get), read-only 
Types                []type                                          (get), read-only 


***************************


(Maybe it is not a bug and I missed something about filling the *ColorScaleEntries* array...)


Steps to Reproduce:
1. Open any Calc document.
2. Execute the macro
3. Edit the newly created conditional formatting

Actual Results:
Depends on the action :
If editing the new CF, crash ! But, basically, I think the problem is the emptyness of the *ColorScaleEntries* array.

Expected Results:
*ColorScaleEntries* array filled with editable entries.


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Oliver Brinzing 2018-08-30 14:19:05 UTC
Created attachment 144560 [details]
conditionalformat

it is possible to read the "ColorScaleEntries" from a manually 
created conditional format, see attached file.

so i think, you have to fill the "ColorScaleEntries" to make it work.
the question is how can this be done?

I found a service "ColorScale" but don't know how to instantiate:
https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1sheet_1_1ColorScale.html
Comment 2 Fab 2018-08-30 16:50:22 UTC
Reading the "ColorScaleEntries" property from a manually created format was the way I used to see the structure with 2 or 3 items depending on the color scale I created.

I spent a lot of time trying to manipulate the service you mentionned, as well as trying to create a "ColorScaleEntry" object directly in order to add it to the sequence "ColorScaleEntries", even if I couldn't be able to find a way to add anything to it...

It seems methods or constructors are missing...
Or it is me who is missing something...
Comment 3 Julien Nabet 2018-09-02 05:45:47 UTC
How to install XRay?

I gave a try by downloading file from http://berma.pagesperso-orange.fr/index.html when click "Install" button present in the doc.
I noticed these logs on console:
warn:basic:9094:9094:basic/source/uno/namecont.cxx:916: couldn't open sub storage for library "Standard". Exception: (com.sun.star.io.IOException) { { Message = "/home/julien/lo/libreoffice/package/source/xstor/xstorage.cxx:2381: ", Context = (com.sun.star.uno.XInterface) @0 } }
warn:stoc:9094:9094:stoc/source/inspect/introspection.cxx:1636: object of type "com.sun.star.beans.XIntrospectionAccess" lacks XTypeProvider

Nevertheless, I gave a try to your macro and had this message in LO:
"BASIC runtime error.
Sub-procedure or function procedure not defined."
Comment 4 Oliver Brinzing 2018-09-02 06:42:51 UTC
i use mri instead of xray, https://github.com/hanya/MRI/releases
Comment 5 Julien Nabet 2018-09-02 06:51:36 UTC
(In reply to Oliver Brinzing from comment #4)
> i use mri instead of xray, https://github.com/hanya/MRI/releases

I installed mri, it hangs at the end so had to kill LO.
Nevertheless after restarting LO, the module displayed.
Then I copy paste the macro and replace the Xray line by
Mri NewCF.getByIndex(0)
Again:
"BASIC runtime error.
Sub-procedure or function procedure not defined."
Comment 6 Fab 2018-09-02 09:15:14 UTC
I don't know why you have problems with Xray, MRI or this macro.
Maybe try to start with a fresh install of LibreOffice (I mean an empty profile).
Comment 7 Julien Nabet 2018-09-02 09:33:33 UTC
(In reply to Fab from comment #6)
> I don't know why you have problems with Xray, MRI or this macro.
> Maybe try to start with a fresh install of LibreOffice (I mean an empty
> profile).
The macro works (or at least, I don't have any error message) until I uncomment Xray (or mri) line.
I build LO from master sources and profile was clean.
But certainly someone may help you anyway.
Comment 8 Fab 2018-09-16 07:53:07 UTC
This problem remains with LibreOffice 6.1.1.2...
Comment 9 Julien Nabet 2018-09-16 08:02:24 UTC
Version must correspond to the oldest one.
Comment 10 Fab 2018-09-16 08:13:27 UTC
(In reply to Julien Nabet from comment #9)
> Version must correspond to the oldest one.

Oh, tanks ! I missed that. :)
Comment 11 Buovjaga 2018-10-09 15:47:19 UTC
If this is to be treated as a documentation issue, maybe try https://ask.libreoffice.org/ and if that does not help, the developer mailing list.
Comment 12 Oliver Brinzing 2018-10-10 16:17:45 UTC
(In reply to Buovjaga from comment #11)
> If this is to be treated as a documentation issue, maybe try
> https://ask.libreoffice.org/ and if that does not help, the developer
> mailing list.

no, as mentioned above, i think the problem is, that it seems not 
to be possible to instantiate the "com.sun.star.sheet.ColorScale" service.
Comment 13 Buovjaga 2018-10-10 16:48:13 UTC
Well, then this should go to NEW
Comment 14 Fab 2018-10-10 18:08:59 UTC
Indeed, it really seems that the possibility of instantiating the "com.sun.star.sheet.ColorScale" service or the possibility of instantiating the "com.sun.star.sheet.XColorScaleEntry" object would solve this problem.

Or maybe the "createEntry" method, when used with com.sun.star.sheet.ConditionEntryType.COLORSCALE (=1) as first argument, should accept one more argument (optional) that would be the type of the colorscale conditional format (2 or 3 colors).
Comment 15 QA Administrators 2021-11-21 03:58:14 UTC
Dear Fab,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug