wizards/source/sfdocuments/SF_Calc.xba | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
New commits: commit 6caa4dad840542ba58570fa2bced35f63833aa8a Author: Jean-Pierre Ledure <j...@ledure.be> AuthorDate: Mon Aug 22 11:21:02 2022 +0200 Commit: Jean-Pierre Ledure <j...@ledure.be> CommitDate: Mon Aug 22 16:51:11 2022 +0200 ScriptForge - (SF_Calc) support of 16384 columns in a sheet Alignment with Calc support of 2^14 columns as from LO 7.4 instead of 2^10. Review of comments accordingly. Minor optimization of internal method _GetColumnName() More accurate control of boundaries in internal method _Offset() Change-Id: I590ae9a4fab0b90a6e9cc9bbacf6c1b582f9c6e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138666 Tested-by: Jean-Pierre Ledure <j...@ledure.be> Reviewed-by: Jean-Pierre Ledure <j...@ledure.be> Tested-by: Jenkins diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba index 3530544bc038..e32dab652166 100644 --- a/wizards/source/sfdocuments/SF_Calc.xba +++ b/wizards/source/sfdocuments/SF_Calc.xba @@ -134,7 +134,7 @@ REM ============================================================ MODULE CONSTANT Private Const cstSHEET = 1 Private Const cstRANGE = 2 -Private Const MAXCOLS = 2^10 ' Max number of columns in a sheet +Private Const MAXCOLS = 2^14 ' Max number of columns in a sheet Private Const MAXROWS = 2^20 ' Max number of rows in a sheet Private Const CALCREFERENCE = "SF_CalcReference" ' Object type of _Address @@ -4056,11 +4056,11 @@ End Function ' SFDocuments.SF_Calc._FileIdent REM ----------------------------------------------------------------------------- Function _GetColumnName(ByVal plColumnNumber As Long) As String -''' Convert a column number (range 1, 2,..1024) into its letter counterpart (range 'A', 'B',..'AMJ'). +''' Convert a column number (range 1, 2,..16384) into its letter counterpart (range 'A', 'B',..'XFD'). ''' Args: -''' ColumnNumber: the column number, must be in the interval 1 ... 1024 +''' ColumnNumber: the column number, must be in the interval 1 ... 16384 ''' Returns: -''' a string representation of the column name, in range 'A'..'AMJ' +''' a string representation of the column name, in range 'A'..'XFD' ''' Adapted from a Python function by sundar nataraj ''' http://stackoverflow.com/questions/23861680/convert-spreadsheet-number-to-column-letter @@ -4069,11 +4069,12 @@ Dim lDiv As Long ' Intermediate result Dim lMod As Long ' Result of modulo 26 operation Try: + sCol = "" lDiv = plColumnNumber Do While lDiv > 0 lMod = (lDiv - 1) Mod 26 - sCol = Chr(65 + lMod) + sCol - lDiv = Int((lDiv - lMod)/26) + sCol = Chr(65 + lMod) & sCol + lDiv = (lDiv - lMod) \ 26 Loop Finally: @@ -4172,8 +4173,8 @@ Try: lRight = lLeft + Iif(plWidth = 0, .EndColumn - .StartColumn, plWidth - 1) lBottom = lTop + Iif(plHeight = 0, .EndRow - .StartRow, plHeight - 1) If lLeft < 0 Or lRight < 0 Or lTop < 0 Or lBottom < 0 _ - Or lLeft > MAXCOLS Or lRight > MAXCOLS _ - Or lTop > MAXROWS Or lBottom > MAXROWS _ + Or lLeft >= MAXCOLS Or lRight >= MAXCOLS _ + Or lTop >= MAXROWS Or lBottom >= MAXROWS _ Then GoTo CatchAddress Set oNewRange = oSheet.getCellRangeByPosition(lLeft, lTop, lRight, lBottom) End With