Foontote/Endnote numeration functions added
This commit is contained in:
parent
90207f01d0
commit
55f8f9e79b
1 changed files with 156 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
||||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Footnotes" script:language="StarBasic" script:moduleType="normal">sub footMark2
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Footnotes" script:language="StarBasic" script:moduleType="normal">sub footMark3
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub openFootNotesDialog
|
Sub openFootNotesDialog
|
||||||
|
@ -57,15 +57,107 @@ Sub setFootnotesNumberingFrom(dialog)
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
If (stringPageRangeInput <> "") Then
|
If (stringPageRangeInput <> "") Then
|
||||||
|
Dim pageNums() As Integer
|
||||||
|
getPageNumsFrom(stringPageRangeInput, pageNums())
|
||||||
statusIndicator.Start(getTranslation("statusNumberingInProcess"),100)
|
statusIndicator.Start(getTranslation("statusNumberingInProcess"),100)
|
||||||
setNotesPaginatedNumbering(noteType, pageArray)
|
setNotesPaginatedNumbering(noteType, pageNums())
|
||||||
|
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
statusIndicator.end()
|
statusIndicator.end()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Sub setNotesPaginatedNumbering(noteType As Integer, pageNums() As Integer)
|
||||||
|
Dim enum1Element As Object
|
||||||
|
Dim enum1 As Object
|
||||||
|
Dim enum2 As Object
|
||||||
|
Dim thisPortion As Object
|
||||||
|
Dim curNum As Integer
|
||||||
|
Dim footnoteText As Object
|
||||||
|
Dim label As String
|
||||||
|
Dim labelNum As Long
|
||||||
|
Dim i As Integer
|
||||||
|
Dim cell As Object
|
||||||
|
Dim cellEnum As Object
|
||||||
|
Dim cellEnum2 As Object
|
||||||
|
Dim curPage As String
|
||||||
|
Dim prevPage As String
|
||||||
|
prevPage = ""
|
||||||
|
Dim statusIndicator as Object
|
||||||
|
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
||||||
|
statusIndicator.Start(getTranslation("statusNumberingInProcess"),30)
|
||||||
|
curNum = 1
|
||||||
|
enum1 = ThisComponent.Text.createEnumeration
|
||||||
|
While enum1.hasMoreElements
|
||||||
|
enum1Element = enum1.nextElement
|
||||||
|
If enum1Element.supportsService("com.sun.star.text.Paragraph") Then
|
||||||
|
enum2 = enum1Element.createEnumeration
|
||||||
|
While enum2.hasMoreElements
|
||||||
|
thisPortion = enum2.nextElement
|
||||||
|
If isTargetNote(thisPortion, noteType) Then
|
||||||
|
curPage = getPageNumber(thisPortion)
|
||||||
|
If (curPage <> prevPage) Then
|
||||||
|
curNum = 1
|
||||||
|
prevPage = curPage
|
||||||
|
EndIf
|
||||||
|
footnoteText = thisPortion.Footnote
|
||||||
|
label = footnoteText.getLabel
|
||||||
|
If label = "" Then
|
||||||
|
footnoteText.setLabel(CStr(curNum))
|
||||||
|
curNum = curNum + 1
|
||||||
|
|
||||||
|
Else
|
||||||
|
labelNum = CLng(label)
|
||||||
|
If labelNum > 0 Then
|
||||||
|
|
||||||
|
footnoteText.setLabel(CStr(curNum))
|
||||||
|
|
||||||
|
curNum = curNum + 1
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then
|
||||||
|
cellNames = enum1Element.cellNames
|
||||||
|
For i = LBound(cellNames) To Ubound(cellNames)
|
||||||
|
cell = enum1Element.getCellByName(cellNames(i))
|
||||||
|
cellEnum = cell.getText().createEnumeration()
|
||||||
|
While cellEnum.hasMoreElements
|
||||||
|
cellEnumElement = cellEnum.nextElement
|
||||||
|
If cellEnumElement.supportsService("com.sun.star.text.Paragraph") Then
|
||||||
|
cellEnum2 = cellEnumElement.createEnumeration
|
||||||
|
While cellEnum2.hasMoreElements
|
||||||
|
thisPortion = cellEnum2.nextElement
|
||||||
|
If isTargetNote(thisPortion, noteType) Then
|
||||||
|
curPage = getPageNumber(thisPortion)
|
||||||
|
If (curPage <> prevPage) Then
|
||||||
|
curNum = 1
|
||||||
|
prevPage = curPage
|
||||||
|
EndIf
|
||||||
|
footnoteText = thisPortion.Footnote
|
||||||
|
label = footnoteText.getLabel
|
||||||
|
If label = "" Then
|
||||||
|
footnoteText.setLabel(CStr(curNum))
|
||||||
|
curNum = curNum + 1
|
||||||
|
|
||||||
|
Else
|
||||||
|
labelNum = CLng(label)
|
||||||
|
If labelNum > 0 Then
|
||||||
|
footnoteText.setLabel(CStr(curNum))
|
||||||
|
curNum = curNum + 1
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
Next i
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
statusIndicator.end()
|
||||||
|
MsgBox getTranslation("statusNumberingFinished")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Sub setFootnotesNumberingLevel(level As Integer,noteType As Integer)
|
Sub setFootnotesNumberingLevel(level As Integer,noteType As Integer)
|
||||||
Dim enum1Element As Object
|
Dim enum1Element As Object
|
||||||
Dim enum1 As Object
|
Dim enum1 As Object
|
||||||
|
@ -83,8 +175,6 @@ Sub setFootnotesNumberingLevel(level As Integer,noteType As Integer)
|
||||||
Dim statusIndicator as Object
|
Dim statusIndicator as Object
|
||||||
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
||||||
statusIndicator.Start(getTranslation("statusNumberingInProcess"),30)
|
statusIndicator.Start(getTranslation("statusNumberingInProcess"),30)
|
||||||
|
|
||||||
|
|
||||||
curNum = 1
|
curNum = 1
|
||||||
enum1 = ThisComponent.Text.createEnumeration
|
enum1 = ThisComponent.Text.createEnumeration
|
||||||
While enum1.hasMoreElements
|
While enum1.hasMoreElements
|
||||||
|
@ -170,6 +260,66 @@ Function isTargetNote(portion As Object, noteType As Integer) As Boolean
|
||||||
EndIf
|
EndIf
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
'Sub testRange
|
||||||
|
' Dim pageNums() As Integer
|
||||||
|
' getPageNumsFrom("9-10,8-12,-111-099,99,102,105,187,187",pageNums())
|
||||||
|
'End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Sub getPageNumsFrom(inputString As String, pageNums() As Integer)
|
||||||
|
Dim ranges() As String
|
||||||
|
ranges = split(inputString,",")
|
||||||
|
For i = Lbound(ranges) To (Ubound(ranges))
|
||||||
|
processNumRange(ranges(i),pageNums())
|
||||||
|
Next i
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Function IsInArray(array, content)
|
||||||
|
IsInArray = false
|
||||||
|
For i = LBound(array) To UBound(array)
|
||||||
|
inArr = array(i)
|
||||||
|
If inArr = content Then
|
||||||
|
IsInArray = true
|
||||||
|
EndIf
|
||||||
|
Next i
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
Sub processNumRange(range As String, pageNums() As Integer)
|
||||||
|
Dim rangeParts() As String
|
||||||
|
Dim firstValue As String
|
||||||
|
Dim secondValue As String
|
||||||
|
Dim firstNum As Integer
|
||||||
|
Dim secondNum As Integer
|
||||||
|
rangeParts = split( range, "-")
|
||||||
|
|
||||||
|
If UBound(rangeParts) = 1 Then
|
||||||
|
firstValue = trim(rangeParts(0))
|
||||||
|
secondValue = trim(rangeParts(1))
|
||||||
|
If ( IsDigit(firstValue) And IsDigit(secondValue)) Then
|
||||||
|
firstNum = CInt(firstValue)
|
||||||
|
secondNum = CInt(secondValue)
|
||||||
|
If firstNum <= secondNum Then
|
||||||
|
For i = firstNum To secondNum
|
||||||
|
If (NOT IsInArray(pageNums, i)) Then
|
||||||
|
addToArray(pageNums, i)
|
||||||
|
EndIf
|
||||||
|
Next i
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
If UBound(rangeParts) = 0 Then
|
||||||
|
firstValue = trim(rangeParts(0))
|
||||||
|
If IsDigit(firstValue) Then
|
||||||
|
firstNum = CInt(firstValue)
|
||||||
|
If (NOT IsInArray(pageNums, firstNum)) Then
|
||||||
|
addToArray(pageNums, firstNum)
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function isEndNote(portion As Object) As Boolean
|
Function isEndNote(portion As Object) As Boolean
|
||||||
|
|
Loading…
Add table
Reference in a new issue