Bug 97450 - Validation created by a Macro shows Err508 but after opening the Validation dialog and submitting it the cells shows the expected list
Summary: Validation created by a Macro shows Err508 but after opening the Validation d...
Status: RESOLVED INVALID
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.2.8.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-30 14:50 UTC by feketeszeder
Modified: 2016-04-28 09:43 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
ods, cells shows err508 and the expected list (19.13 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-01-30 14:56 UTC, feketeszeder
Details

Note You need to log in before you can comment on or make changes to this bug.
Description feketeszeder 2016-01-30 14:50:52 UTC
"Cell range" type Validation was created for cellsE2-E11 by a Macro and these cells shows an "Err:508" instead of the expected value list.
But if the Validity panel is opened in any of cellsE2-E11 (Menu/Data/Validity...) and clicked OK, then the cells shows the expected value list.

Speculation.
There are some errors in the formula or in other properties of Validation filled up by the Macro, and the Validity panel corrects it.

Here is the Macro:

sub validity3
Dim Doc As Object
Dim Sheet As Object
Dim Cell As Object
Dim oRow As Integer
Dim oRow2 As Integer
Dim oFormula as String

Doc = ThisComponent
Sheet1 = Doc.Sheets(0)
for oRow = 1 to 10
    Cell = Sheet1.getCellByPosition(4 ,oRow)
    oProps = Cell.Validation
    oProps.Type = com.sun.star.sheet.ValidationType.LIST
	oProps.IgnoreBlankCells = True
    oProps.ShowErrorMessage = True
    oProps.ErrorMessage = "Must be a value from the list!"
    oProps.ErrorTitle = "ERROR"
    oProps.ShowInputMessage = False
    oProps.ErrorAlertStyle = com.sun.star.sheet.ValidationAlertStyle.WARNING
	oRow2 = oRow +1
       oFormula =  "IF($D$" & oRow2 & "=sub.$A$1 ,sub.$A$2:$A$12, " _
       			 & "IF($D$" & oRow2 & "=sub.$B$1 ,sub.$B$2:$B$11, " _
       			 & "IF($D$" & oRow2 & "=sub.$C$1 ,sub.$C$2:$C$8, " _
       			 & "IF($D$" & oRow2 & "=sub.$D$1 ,sub.$D$2:$D$6, " _
       			 & "IF($D$" & oRow2 & "=sub.$E$1 ,sub.$E$2:$E$4, " _
       			 & "IF($D$" & oRow2 & "=sub.$F$1 ,sub.$F$2:$F$3  " _
       			 & ", sub.$G$1))))))" 
    
    oProps.Formula1 = oFormula
    Cell.Validation = oProps
    
 next

end sub
Comment 1 feketeszeder 2016-01-30 14:56:44 UTC
Created attachment 122286 [details]
ods, cells shows err508 and the expected list
Comment 2 feketeszeder 2016-01-30 18:46:04 UTC
Comparison between error-showing and list-showing cells in content.xml reveals a difference in <table:content-validation>:

In all error-showing cells, table:base-cell-address="Sheet1.A1"
while in list-showing cells, it refers to the actual cell, e.g.
table:base-cell-address="Sheet1.E2">
table:base-cell-address="Sheet1.E3">

So the solution may be to set the "table:base-cell-address" property via Macro.
Comment 3 feketeszeder 2016-01-31 00:40:48 UTC
The "table:base-cell-address" property may be a consequence of the problem rather than part of the solution. In content.xml I overwrote the supposedly wrong "A1" value to "E2" and vice versa but neither the the error-showing nor the list-showing cells changed.
Comment 4 Bernard Marcelly 2016-02-06 17:21:19 UTC
Incorrect :
"IF($D$" & oRow2 & "=sub.$A$1 ,sub.$A$2:$A$12, "
Correct :
"IF($D$" & oRow2 & "=sub.$A$1 ;sub.$A$2:$A$12; "
(etc...)

arguments of the IF( ) are separated by semi-colons, not colons.
Comment 5 Buovjaga 2016-02-11 08:48:10 UTC
Fixed by comment 4?

Set to NEEDINFO.
Change back to UNCONFIRMED, if the problem persists. Change to RESOLVED INVALID, if the problem went away.