Bug 150648 - EAN13 function works in spreadsheet with LibreOffice 7.3 not 7.4
Summary: EAN13 function works in spreadsheet with LibreOffice 7.3 not 7.4
Status: RESOLVED INSUFFICIENTDATA
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.4.0.3 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Calc-Function Calc-large-spreadsheets
  Show dependency treegraph
 
Reported: 2022-08-28 17:17 UTC by robert.bassimon@free.fr
Modified: 2023-06-02 05:45 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
program with defective Function (13.78 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-09-27 17:01 UTC, robert.bassimon@free.fr
Details
LO 7.5 (29.40 KB, image/png)
2022-10-04 20:11 UTC, raal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description robert.bassimon@free.fr 2022-08-28 17:17:15 UTC
Description:
I am using EAN13 function since a lot of years without problems. On Ubuntu and Windows, I got Error 509, not the code with EAN13, after LibreOffice 7.4 upgrade.

Steps to Reproduce:
1.use EAN13 function with 7.4
2.
3.

Actual Results:
Error 509

Expected Results:
The ean code (13)


Reproducible: Always


User Profile Reset: No



Additional Info:
EAN13 is a function 
REM  *****  BASIC  *****

Function ean13$(chaine$)
  'Cette fonction est régie par la Licence Générale Publique Amoindrie GNU (GNU LGPL)
  'This function is governed by the GNU Lesser General Public License (GNU LGPL)
  'V 1.1.1
  'Paramètres : une chaine de 12 chiffres
  'Parameters : a 12 digits length string
  'Retour : * une chaine qui, affichée avec la police EAN13.TTF, donne le code barre
  '         * une chaine vide si paramètre fourni incorrect
  'Return : * a string which give the bar code when it is dispayed with EAN13.TTF font
  '         * an empty string if the supplied parameter is no good
  Dim i%, checksum%, first%, CodeBarre$, tableA As Boolean
  ean13$ = ""
  'Vérifier qu'il y a 12 caractères
  'Check for 12 characters
  If Len(chaine$) = 12 Then
    'Et que ce sont bien des chiffres
    'And they are really digits
    For i% = 1 To 12
      If Asc(Mid$(chaine$, i%, 1)) < 48 Or Asc(Mid$(chaine$, i%, 1)) > 57 Then
        i% = 0
        Exit For
      End If
    Next
    If i% = 13 Then
      'Calcul de la clé de contrôle
      'Calculation of the checksum
      For i% = 12 To 1 Step -2
        checksum% = checksum% + Val(Mid$(chaine$, i%, 1))
      Next
      checksum% = checksum% * 3
      For i% = 11 To 1 Step -2
        checksum% = checksum% + Val(Mid$(chaine$, i%, 1))
      Next
      chaine$ = chaine$ & (10 - checksum% Mod 10) Mod 10
      'Le premier chiffre est pris tel quel, le deuxième vient de la table A
      'The first digit is taken just as it is, the second one come from table A
      CodeBarre$ = Left$(chaine$, 1) & Chr$(65 + Val(Mid$(chaine$, 2, 1)))
      first% = Val(Left$(chaine$, 1))
      For i% = 3 To 7
        tableA = False
         Select Case i%
         Case 3
           Select Case first%
           Case 0 To 3
             tableA = True
           End Select
         Case 4
           Select Case first%
           Case 0, 4, 7, 8
             tableA = True
           End Select
         Case 5
           Select Case first%
           Case 0, 1, 4, 5, 9
             tableA = True
           End Select
         Case 6
           Select Case first%
           Case 0, 2, 5, 6, 7
             tableA = True
           End Select
         Case 7
           Select Case first%
           Case 0, 3, 6, 8, 9
             tableA = True
           End Select
         End Select
       If tableA Then
         CodeBarre$ = CodeBarre$ & Chr$(65 + Val(Mid$(chaine$, i%, 1)))
       Else
         CodeBarre$ = CodeBarre$ & Chr$(75 + Val(Mid$(chaine$, i%, 1)))
       End If
     Next
      CodeBarre$ = CodeBarre$ & "*"   'Ajout séparateur central / Add middle separator
      For i% = 8 To 13
        CodeBarre$ = CodeBarre$ & Chr$(97 + Val(Mid$(chaine$, i%, 1)))
      Next
      CodeBarre$ = CodeBarre$ & "+"   'Ajout de la marque de fin / Add end mark
      ean13$ = CodeBarre$
    End If
  End If
End Function
Comment 1 raal 2022-08-28 19:32:12 UTC
Please attach test file. Thank you.
Comment 2 robert.bassimon@free.fr 2022-09-27 17:01:54 UTC
Created attachment 182699 [details]
program with defective Function
Comment 3 QA Administrators 2022-09-28 03:33:03 UTC Comment hidden (obsolete)
Comment 4 raal 2022-10-04 20:11:12 UTC
Created attachment 182836 [details]
LO 7.5

Looks correct with Version: 7.5.0.0.alpha0+ / LibreOffice Community
Build ID: a0bc0cc81b597aa81189355a8125753d6b873cce
CPU threads: 4; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: cs-CZ (cs_CZ.UTF-8); UI: en-US
Calc: threaded
Comment 5 Roman Kuznetsov 2022-11-01 19:32:13 UTC
Robert , please update your LibreOffice to 7.4.2 and try retest your problem
Comment 6 QA Administrators 2023-05-01 03:19:03 UTC Comment hidden (obsolete)
Comment 7 QA Administrators 2023-06-01 03:19:15 UTC Comment hidden (obsolete)
Comment 8 nutka 2023-06-01 22:48:25 UTC
OP pointed out the problem occured after LibreOffice 7.4 upgrade.
As of 7.4 the maximum number of columns is 16384 (from A to XFD).

The name of the function seems to conflict with the cell coordinates EAN13

See the topic on the AskLibreOffice
"Err.509 calc when running a macro with single cell input"
https://ask.libreoffice.org/t/err-509-calc-when-running-a-macro-with-single-cell-input/84687