Code cleaning

This commit is contained in:
Georgy Litvinov 2020-03-21 16:35:38 +01:00
parent 52a5b70bbf
commit dd90a5b726
6 changed files with 102 additions and 80 deletions

View file

@ -5,14 +5,19 @@
End Sub
Sub resetNotesStyle
Dim oDescriptor 'The search descriptor
dim dispatcher as Object
Dim oDescriptor As Object
Dim dispatcher As Object
Dim x As Integer
Dim oViewCursor As Object
Dim document As Object
Dim allNotes As Object
Dim aNote As Object
Dim oEnum As Object
Dim oCurPar As Object
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim document as Object
document = ThisComponent.CurrentController.Frame
Dim oViewCursor As Object 'View cursor
document = ThisComponent.CurrentController.Frame
oViewCursor = ThisComponent.CurrentController.getViewCursor()
allNotes= thisComponent.FootNotes
allNotes = thisComponent.FootNotes
for x = 0 to allNotes.Count -1
aNote = allNotes.getByIndex(x)
aNote.Anchor.CharStyleName="Footnote anchor"
@ -100,15 +105,16 @@ Function RND_String
OutputString=""
randomize
for i = 1 to 20
Select Case i
Case 5, 8, 11, 14
OutputString=OutputString+"-"
Case Else
TempString=Hex(int(rnd*256))
if len(TempString)<2 then TempString=TempString+"0"
OutputString=OutputString+TempString
For i = 1 to 20
Select Case i
Case 5, 8, 11, 14
OutputString=OutputString+"-"
Case Else
TempString=Hex(int(rnd*256))
If len(TempString) < 2 Then
TempString=TempString+"0"
EndIf
OutputString=OutputString+TempString
End Select
next i
@ -198,15 +204,15 @@ End Sub
Function isLowerCase(character)
If (character = "") Then
charNum = ASC(""+0)
Else
charNum = ASC(character)
End If
If ((charNum > 1071 AND charNum < 1104) Or (charNum > 60 AND charNum < 123)) Then
isLowerCase = true
Exit Function
EndIf
isLowerCase = false
charNum = ASC(""+0)
Else
charNum = ASC(character)
End If
If ((charNum > 1071 AND charNum < 1104) Or (charNum > 60 AND charNum < 123)) Then
isLowerCase = true
Exit Function
EndIf
isLowerCase = false
End Function
Sub balancePara(Optional targetPara As Object)
@ -312,10 +318,10 @@ Sub convertBookmarksToFootnotes()
Dim backward As Object
linkPrefix = "footnote-"
backLinkSuffix = "-backlink"
Dim i As Integer
bookmarkName = ThisComponent.Links.ElementNames(6)
bookmarks = ThisComponent.Links.getByName(bookmarkName)
' Mri bookmarks
bookmarkNames = bookmarks.getElementNames()
For i = LBound(bookmarkNames) To Ubound(bookmarkNames)
bookmarkName = bookmarkNames(i)
@ -423,7 +429,7 @@ Sub replaceParaStyle
Dim oViewCursor As Object
Dim enum1 As Object
Dim oTextCursor As Object
Dim i As Integer
oStyles = ThisComponent.StyleFamilies
paraStyles = oStyles.getByName(oStyles.elementNames(1))
oViewCursor = ThisComponent.CurrentController.getViewCursor()
@ -484,7 +490,10 @@ Sub replaceParaStyle
End Sub
function getIndex(a, v)
Function getIndex(a, v)
Dim id As Integer
Dim nRight As Integer
Dim nLen As Integer
id = 0
nRight = uBound(a)
nLen = len(v)
@ -497,34 +506,42 @@ function getIndex(a, v)
end if
wend
getIndex = -1
end function
End Function
sub subShellSort(mArray)
Sub subShellSort(mArray)
dim n as integer, h as integer, i as integer, j as integer, t as string, Ub as integer, LB as Integer
Dim n As Integer
Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim t As String
Dim Ub As Integer
Dim LB As Integer
Lb = lBound(mArray)
Ub = uBound(mArray)
' compute largest increment
n = Ub - Lb + 1
h = 1
if n > 14 then
do while h < n
h = 3 * h + 1
loop
h = h \ 3
h = h \ 3
end if
do while h > 0
for i = Lb + h to Ub
t = mArray(i)
for j = i - h to Lb step -h
if strComp(mArray(j), t, 0) < 1 then exit for
mArray(j + h) = mArray(j)
next j
mArray(j + h) = t
next i
h = h \ 3
loop
end sub
If n > 14 then
do while h < n
h = 3 * h + 1
loop
h = h \ 3
h = h \ 3
End If
Do While h > 0
For i = Lb + h to Ub
t = mArray(i)
For j = i - h to Lb step -h
If strComp(mArray(j), t, 0) < 1 then
Exit For
EndIf
mArray(j + h) = mArray(j)
Next j
mArray(j + h) = t
Next i
h = h \ 3
Loop
End Sub
</script:module>