Fixes for Foontote/Endnote numeration functions

This commit is contained in:
Georgy Litvinov 2021-05-19 17:33:27 +02:00
parent 55f8f9e79b
commit 58f1fb4c34

View file

@ -34,7 +34,7 @@ Sub openFootNotesDialog
dialog.dispose() dialog.dispose()
End Sub End Sub
Sub setFootnotesNumberingFrom(dialog) Sub setFootnotesNumberingFrom(dialog As Object)
Dim statusIndicator as Object Dim statusIndicator as Object
Dim targetLevel As Integer Dim targetLevel As Integer
Dim stringLevelInput As String Dim stringLevelInput As String
@ -93,8 +93,9 @@ Sub setNotesPaginatedNumbering(noteType As Integer, pageNums() As Integer)
enum2 = enum1Element.createEnumeration enum2 = enum1Element.createEnumeration
While enum2.hasMoreElements While enum2.hasMoreElements
thisPortion = enum2.nextElement thisPortion = enum2.nextElement
If isTargetNote(thisPortion, noteType) Then If isTargetNote(thisPortion, noteType) Then
curPage = getPageNumber(thisPortion) curPage = getPageNumber(thisPortion)
If ( IsInArray(pageNums, CInt(curPage) ) ) Then
If (curPage <> prevPage) Then If (curPage <> prevPage) Then
curNum = 1 curNum = 1
prevPage = curPage prevPage = curPage
@ -104,16 +105,14 @@ Sub setNotesPaginatedNumbering(noteType As Integer, pageNums() As Integer)
If label = "" Then If label = "" Then
footnoteText.setLabel(CStr(curNum)) footnoteText.setLabel(CStr(curNum))
curNum = curNum + 1 curNum = curNum + 1
Else Else
labelNum = CLng(label) labelNum = CLng(label)
If labelNum > 0 Then If labelNum > 0 Then
footnoteText.setLabel(CStr(curNum)) footnoteText.setLabel(CStr(curNum))
curNum = curNum + 1 curNum = curNum + 1
EndIf EndIf
EndIf EndIf
EndIf
EndIf EndIf
Wend Wend
ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then
@ -128,8 +127,9 @@ Sub setNotesPaginatedNumbering(noteType As Integer, pageNums() As Integer)
While cellEnum2.hasMoreElements While cellEnum2.hasMoreElements
thisPortion = cellEnum2.nextElement thisPortion = cellEnum2.nextElement
If isTargetNote(thisPortion, noteType) Then If isTargetNote(thisPortion, noteType) Then
curPage = getPageNumber(thisPortion) curPage = getPageNumber(thisPortion)
If (curPage <> prevPage) Then If ( IsInArray(pageNums, CInt(curPage) ) ) Then
If (curPage <> prevPage) Then
curNum = 1 curNum = 1
prevPage = curPage prevPage = curPage
EndIf EndIf
@ -146,6 +146,7 @@ Sub setNotesPaginatedNumbering(noteType As Integer, pageNums() As Integer)
curNum = curNum + 1 curNum = curNum + 1
EndIf EndIf
EndIf EndIf
EndIf
EndIf EndIf
Wend Wend
EndIf EndIf
@ -274,7 +275,7 @@ Sub getPageNumsFrom(inputString As String, pageNums() As Integer)
Next i Next i
End Sub End Sub
Function IsInArray(array, content) Function IsInArray(array As Variant, content As Variant) As Boolean
IsInArray = false IsInArray = false
For i = LBound(array) To UBound(array) For i = LBound(array) To UBound(array)
inArr = array(i) inArr = array(i)