Apache OpenOffice (AOO) Bugzilla – Issue 25739
ReDim Preserve vItems(iCount) fails
Last modified: 2013-02-24 21:09:18 UTC
vItems() is a variant. In the example that I have seen, iCount is 77 AND UBound(vItems()) is also 77. This does not always fail, it typically fails the second time through. I can provide the complete set of code if required. No errors are generated, but the macro simply stops and that line is highlighted. I have not stared at the code for long, but this line might not be required. I created a working solution by only changing the dimension when it is required. Print "iCount = " & iCount & " ub = " & UBound(vItems()) If iCount <> UBound(vItems()) Then ReDim Preserve vItems(iCount) End If
Okay, when will I be able to assign such things directly to scripting. I thought that I could reassign this to scripting at least after I created it and also assign it to ab! Drat!\ Oh yeah, this was not a problem in 1.1.0.
I was told to mention that this is REGRESSION. This is a new bug with 1.1.1b that does not exist in 1.1.0. When I ran this code, I had an empty document and the macro. Nothing more. If you download my main libraries http://www.pitonyak.org/PitonyakLibs.zip You will need the Pitonyak and PitonyakDialogs library. Use the PitonyakDialogs and then use the module that contains the RunSimpleObjectBrowser() routine and just run the main routine.....
Probably duplicate to internal StarOffice pp2 regression task. I will check this...
Run this macro. I trimmed it down to 109 lines. I could have trimmed it more but.... Option Explicit Sub TheMain Dim iCount%, j%, iPos%, sNew$, oItems(), i% Dim s$, sep$ s$ = ThisComponent.DBG_Properties sep$ = ";" Call BuildItemArray(s$, sep$, oItems()) End Sub '************************************************************************* '** Find the first character starting at location i% that is not whitespace. '** If there are none, then the return value will be greater than the '** length of the string. '************************************************************************* Function FirstNonWhiteSpace(ByVal i%, s$) As Integer If i <= Len(s) Then Do While IsWhiteSpace(Asc(Mid$(s, i, 1))) i = i + 1 If i > Len(s) Then Exit Do End If Loop End If FirstNonWhiteSpace = i End Function '************************************************************************* '** Is the specified character whitespace? The answer is true if the '** character is a tab, CR, LF, space, or a non-breaking space character! '** These correspond to the ASCII values 9, 10, 13, 32, and 160 '************************************************************************* Function IsWhiteSpace(iChar As Integer) As Boolean Select Case iChar Case 9, 10, 13, 32, 160 IsWhiteSpace = True Case Else IsWhiteSpace = False End Select End Function Function ADPTrim(s As String) As String s = Trim(s) Do While Len(s) > 0 If Not IsWhiteSpace(ASC(s)) Then Exit Do s = Right(s, Len(s) - 1) Loop Do While Len(s) > 0 If Not IsWhiteSpace(ASC(Right(s, 1))) Then Exit Do s = Left(s, Len(s) - 1) Loop ADPTrim = s End Function '************************************************************************* '** This routine parses the strings returned from the dbg_Methods, '** dbg_Properties, and dbg_SupportedServices calls. The interesting '** data starts after the first colon. '** '** Because of this, all data before the first colon is discarded '** and then the string is separated into pieces based on the '** separator string that is passed in. '** '** All instances of the string Sbx are removed. If this string '** is valid and exists in a method name, it will still be removed so perhaps '** it is not the safest thing to do, but I have never seen this case and it '** makes the output easier to read. '** '** the vItems() contains all of the parsed sections on output. '** '** '************************************************************************* Sub BuildItemArray(s$, sep$, vItems()) On Error Goto BadErrorHere Dim iCount%, iPos%, sNew$, i%, j% Dim sFront() As String, sMid() As String Dim iIdx() As Integer Dim nFrontMax As Integer 'Maximum length of front section nFrontMax = 0 REM First, we only care about what is after the colon. iPos = InStr(1, s, ":") + 1 If iPos > 0 Then s = ADPTrim(Right(s, Len(s) - iPos)) REM Now, remove all of the "SbX" charcters s = Join(Split(s, "Sbx"), "") If ASC(sep$) <> 10 Then s = Join(Split(s, CHR$(10)), "") REM split on the separator character vItems() = Split(s, sep$) Rem Create arrays to hold the different portions of the text. Rem the string usually contains text similar to "SbxString getName()" Rem sFront() holds the data type if it exists and "" if it does not. Rem sMid() holds the rest ReDim sFront(UBound(vItems)) As String ReDim sMid(UBound(vItems)) As String ReDim iIdx(UBound(vItems)) As Integer iCount = UBound(vItems()) ReDim Preserve vItems(iCount) Exit Sub BadErrorHere: MsgBox "Error " & err & ": " & error$ + chr(13) + "In line : " + Erl End Sub
This seems to be fixed in 1.1.1rc on my linux computer! I have not yet tested this on my windows computer at work.
I haven't found time so far to verify it, but this confirms my assumption that this task is duplicate to an StarOffice internal task that has already been fixed for PP2. This task also deals with arrays passed as parameters.
Could not reproduce any more on src680 m43, so I set this task to fixed.
-> Closed