diff options
author | Tom Verbeek <tv@openoffice.org> | 2001-05-16 11:48:54 +0000 |
---|---|---|
committer | Tom Verbeek <tv@openoffice.org> | 2001-05-16 11:48:54 +0000 |
commit | 3c9942db1ccb44392be1261061dd2335898149e2 (patch) | |
tree | 6ea3041569602dd30e13010c4dc3fd8285eb1dd9 /wizards/source/tools/Strings.xba | |
parent | 8977c7a2fe82cd2176e0c2e7f989e5a7cbce5ef1 (diff) |
#75761# fixed sorting of webwizard and calc styles
Diffstat (limited to 'wizards/source/tools/Strings.xba')
-rw-r--r-- | wizards/source/tools/Strings.xba | 96 |
1 files changed, 67 insertions, 29 deletions
diff --git a/wizards/source/tools/Strings.xba b/wizards/source/tools/Strings.xba index 2e70535b9d49..987796299e78 100644 --- a/wizards/source/tools/Strings.xba +++ b/wizards/source/tools/Strings.xba @@ -35,8 +35,7 @@ End Function ' Finds a PartString, that is framed by the Strings 'Prestring' and 'PostString' Function FindPartString(BigString, PreString, PostString as String, SearchPos as Integer) as String Dim StartPos%, EndPos% -Dim BigLen%,PreLen%,PostLen% - +Dim BigLen%, PreLen%, PostLen% StartPos = Instr(SearchPos,BigString,PreString) If StartPos <> 0 Then PreLen = Len(PreString) @@ -61,9 +60,8 @@ End Function ' Deletes the String 'SmallString' out of the String 'BigString' ' in case SmallString's Position in BigString is right at the end Function RTrimStr(ByVal BigString, SmallString as String) as String -Dim SmallLen% -Dim BigLen% - +Dim SmallLen as Integer +Dim BigLen as Integer SmallLen = Len(SmallString) BigLen = Len(BigString) If Mid(BigString,BigLen + 1 - SmallLen, SmallLen) = SmallString Then @@ -96,26 +94,34 @@ End Function ' The Array MaxLocindex delivers the highest Index of this Array Function ArrayOutOfString(BigString, Separator as String, Optional MaxIndex as integer) Dim i%, OldPos%, Pos%, SepLen%, BigLen% -Dim LocList(200) as string - +Dim CurUbound as Integer +Dim StartUbound as Integer + StartUbound = 50 + Dim LocList(StartUbound) as String + CurUbound = StartUbound OldPos = 1 i = -1 SepLen = Len(Separator) BigLen = Len(BigString) Do - Pos = Instr(OldPos,BigString,Separator) + Pos = Instr(OldPos,BigString, Separator) i = i + 1 If Pos = 0 Then - LocList(i) = Mid(BigString,OldPos,BigLen - OldPos + 1 ) + LocList(i) = Mid(BigString, OldPos, BigLen - OldPos + 1 ) Else - LocList(i) = Mid(BigString,OldPos,Pos-OldPos ) + LocList(i) = Mid(BigString, OldPos, Pos-OldPos ) OldPos = Pos + SepLen End If + If i = CurUbound Then + CurUbound = CurUbound + StartUbound + ReDim Preserve LocList(CurUbound) as String + End If Loop until Pos = 0 - If Vartype(Maxindex) <> 0 Then - MaxIndex = i + If Not IsMissing(Maxindex) Then + MaxIndex = i End If - ArrayoutofString = LocList() + ReDim Preserve LocList(i) as String + ArrayOutofString = LocList() End Function @@ -154,7 +160,6 @@ Dim i as integer End Function - ' Checks if a Field (LocField) is already defined in an Array ' Returns 'True' or 'False' Function FieldinList(LocField, BigList()) As Boolean @@ -353,25 +358,58 @@ Dim LocCount%, LocPos% End Function -Function BubbleSortList(ByVal SortList()) -Dim s as Integer -Dim t as Integer -Dim i as Integer -Dim DisplayDummy as String - i = Val(SortList(0,0)) +Function BubbleSortList(ByVal SortList(),optional sort2ndValue as Boolean) + Dim s as Integer + Dim t as Integer + Dim i,k as Integer + Dim bJustOneDim, bSort2nd as Boolean + Dim DisplayDummy as String + bJustOneDim = false + bSort2nd = false +On Local Error Goto No2ndDim + k = Ubound(SortList(),2) + No2ndDim: + bJustOneDim = Err <> 0 + i = Ubound(SortList(),1) + If ismissing(sort2ndValue) then + bSort2nd = false + else + bSort2nd = sort2ndValue + end if + For s = 1 to i - 1 For t = 0 to i-s - If SortList(t,0) > SortList(t+1, 0) Then - DisplayDummy = SortList(t,0) - SortList(t,0) = SortList(t+1,0) - SortList(t+1,0) = DisplayDummy - - DisplayDummy = SortList(t,1) - SortList(t,1) = SortList(t+1,1) - SortList(t+1,1) = DisplayDummy + If bJustOneDim Then + If SortList(t) > SortList(t+1) Then + DisplayDummy = SortList(t) + SortList(t) = SortList(t+1) + SortList(t+1) = DisplayDummy + End If + Else + If bSort2nd Then + If SortList(t,1) > SortList(t+1,1) Then + DisplayDummy = SortList(t,0) + SortList(t,0) = SortList(t+1,0) + SortList(t+1,0) = DisplayDummy + + DisplayDummy = SortList(t,1) + SortList(t,1) = SortList(t+1,1) + SortList(t+1,1) = DisplayDummy + End If + Else + If SortList(t,0) > SortList(t+1,0) Then + DisplayDummy = SortList(t,0) + SortList(t,0) = SortList(t+1,0) + SortList(t+1,0) = DisplayDummy + + DisplayDummy = SortList(t,1) + SortList(t,1) = SortList(t+1,1) + SortList(t+1,1) = DisplayDummy + End If + End If End If Next t Next s - BubbleSortList = SortList() + BubbleSortList = SortList() End Function </script:module>
\ No newline at end of file |