https://bugs.documentfoundation.org/show_bug.cgi?id=172333
Bug ID: 172333
Summary: Conditional formatting created via UNO isn’t
immediately visible
Product: LibreOffice
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: sdk
Assignee: [email protected]
Reporter: [email protected]
Description:
If you create conditional formatting such as data bars using
XConditionalFormats then the results aren’t immediately visible in the
document. It only appears after you save and reload the document or manually
edit the conditional formatting with the dialog box.
Steps to Reproduce:
1. Create a text file called DataBars.py and save it in your Python scripting
directory. On Linux this will be ~/.config/libreoffice/4/user/Scripts/python
2. Put the following script in the file:
from com.sun.star.beans import PropertyValue
from com.sun.star.sheet.ConditionEntryType import DATABAR
from com.sun.star.sheet import DataBarEntryType
def reproduce_bug():
ctx = XSCRIPTCONTEXT.getComponentContext()
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
# Create a new spreadsheet
doc = desktop.loadComponentFromURL("private:factory/scalc", "_blank", 0,
())
sheet = doc.getSheets().getByIndex(0)
# Set the numbers 1 to 10 an A1:A10
for i in range(10):
sheet.getCellByPosition(0, i).setValue(i + 1)
# Define range
cells = sheet.getCellRangeByName("A1:A10")
xRange = doc.createInstance("com.sun.star.sheet.SheetCellRanges")
xRange.addRangeAddress(cells.getRangeAddress(), False)
# Create data bar conditional format for the range
cfs = sheet.ConditionalFormats
cfs.createByRange(xRange)
cf = cfs.getConditionalFormats()[0]
cf.createEntry(DATABAR, 0)
entries = cf[0].DataBarEntries
# Set the minimum and maximum to 1->10
entries[0].setType(DataBarEntryType.DATABAR_VALUE)
entries[0].setFormula("1")
entries[1].setType(DataBarEntryType.DATABAR_VALUE)
entries[1].setFormula("10")
3. Run the macro with Tools->Macros->Run Macro… and then My Macros->DataBars
and click Run.
4. This should create a new spreadsheet with the numbers 1 to 10. Notice that
there are no databars.
5. Save the spreadsheet and close it.
6. Reopen the spreadsheet.
7. Notice that there are now data bars.
Actual Results:
The data bars are only visible after saving and reloading the document.
Expected Results:
The data bars should be visible immediately after running the script.
Reproducible: Always
User Profile Reset: No
Additional Info:
It looks like the databars are created in the document but there is a step
missing to attach the conditional formatting to the cells as the
ATTR_CONDITIONAL property.
This bug was found while investigating tdf#171950
Version: 26.8.0.0.alpha1+ (X86_64)
Build ID: 531fa71b488cd4abfcb0f5a0ddfc312fba3a3490
CPU threads: 8; OS: Linux 7.0; UI render: default; VCL: gtk3
Locale: fr-FR (fr_FR.UTF-8); UI: en-US
Calc: threaded
--
You are receiving this mail because:
You are the assignee for the bug.