Fixes for footnotes configuration
This commit is contained in:
parent
4d687b4923
commit
edeef39f82
1 changed files with 86 additions and 147 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 footMark4
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Footnotes" script:language="StarBasic" script:moduleType="normal">sub footMark6
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub openFootNotesDialog
|
Sub openFootNotesDialog
|
||||||
|
@ -64,98 +64,56 @@ Sub setFootnotesNumberingFrom(dialog As Object)
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
statusIndicator.end()
|
statusIndicator.end()
|
||||||
|
MsgBox getTranslation("statusNumberingFinished")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub setNotesPaginatedNumbering(noteType As Integer, pageNums() As Integer)
|
Sub setNotesPaginatedNumbering(noteType As Integer, pageNums() As Integer)
|
||||||
Dim enum1Element As Object
|
Dim allNotes As Object
|
||||||
Dim enum1 As Object
|
Dim statusIndicator 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 i As Integer
|
||||||
Dim cell As Object
|
Dim curNote As Object
|
||||||
Dim cellEnum As Object
|
|
||||||
Dim cellEnum2 As Object
|
|
||||||
Dim curPage As String
|
Dim curPage As String
|
||||||
Dim prevPage As String
|
Dim prevPage As String
|
||||||
prevPage = ""
|
Dim curNum As Integer
|
||||||
Dim statusIndicator as Object
|
Dim notesToValidate() 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
|
prevPage = ""
|
||||||
While enum1.hasMoreElements
|
If noteType = 0 Then
|
||||||
enum1Element = enum1.nextElement
|
allNotes = thisComponent.FootNotes
|
||||||
If enum1Element.supportsService("com.sun.star.text.Paragraph") Then
|
Else
|
||||||
enum2 = enum1Element.createEnumeration
|
allNotes = thisComponent.EndNotes
|
||||||
While enum2.hasMoreElements
|
EndIf
|
||||||
thisPortion = enum2.nextElement
|
For i = 0 to allNotes.Count -1
|
||||||
If isTargetNote(thisPortion, noteType) Then
|
curNote = allNotes.getByIndex(i)
|
||||||
curPage = getPageNumber(thisPortion)
|
curPage = getPageNumberVCurs(curNote.Anchor)
|
||||||
If ( IsInArray(pageNums, CInt(curPage) ) ) Then
|
If ( IsInArray(pageNums, CInt(curPage) ) ) Then
|
||||||
If (curPage <> prevPage) Then
|
If (curPage <> prevPage) Then
|
||||||
curNum = 1
|
curNum = 1
|
||||||
prevPage = curPage
|
prevPage = curPage
|
||||||
EndIf
|
EndIf
|
||||||
footnoteText = thisPortion.Footnote
|
label = curNote.getLabel
|
||||||
label = footnoteText.getLabel
|
If label = "" Or IsNumeric(label) Then
|
||||||
If label = "" Then
|
curNote.setLabel(CStr(curNum))
|
||||||
footnoteText.setLabel(CStr(curNum))
|
addToArray(notesToValidate,curnote)
|
||||||
curNum = curNum + 1
|
|
||||||
Else
|
|
||||||
labelNum = CLng(label)
|
|
||||||
If labelNum > 0 Then
|
|
||||||
footnoteText.setLabel(CStr(curNum))
|
|
||||||
curNum = curNum + 1
|
curNum = curNum + 1
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
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 ( IsInArray(pageNums, CInt(curPage) ) ) Then
|
|
||||||
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
|
|
||||||
EndIf
|
|
||||||
Wend
|
|
||||||
EndIf
|
|
||||||
Wend
|
|
||||||
Next i
|
Next i
|
||||||
|
'Second pass in case layout has changed
|
||||||
|
For i = 0 To Ubound(notesToValidate)
|
||||||
|
curNote = notesToValidate(i)
|
||||||
|
curPage = getPageNumberVCurs(curNote.Anchor)
|
||||||
|
If (curPage <> prevPage) Then
|
||||||
|
curNum = 1
|
||||||
|
prevPage = curPage
|
||||||
EndIf
|
EndIf
|
||||||
Wend
|
curNote.setLabel(CStr(curNum))
|
||||||
|
curNum = curNum + 1
|
||||||
|
Next i
|
||||||
statusIndicator.end()
|
statusIndicator.end()
|
||||||
MsgBox getTranslation("statusNumberingFinished")
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,17 +121,12 @@ Sub setFootnotesNumberingLevel(level As Integer,noteType As Integer)
|
||||||
Dim enum1Element As Object
|
Dim enum1Element As Object
|
||||||
Dim enum1 As Object
|
Dim enum1 As Object
|
||||||
Dim enum2 As Object
|
Dim enum2 As Object
|
||||||
Dim thisPortion As Object
|
|
||||||
Dim curNum As Integer
|
Dim curNum As Integer
|
||||||
Dim footnoteText As Object
|
|
||||||
Dim label As String
|
|
||||||
Dim labelNum As Long
|
|
||||||
Dim i As Integer
|
Dim i As Integer
|
||||||
Dim cell As Object
|
Dim cell As Object
|
||||||
Dim cellEnum As Object
|
Dim cellEnum As Object
|
||||||
Dim cellEnum2 As Object
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -181,34 +134,7 @@ Sub setFootnotesNumberingLevel(level As Integer,noteType As Integer)
|
||||||
While enum1.hasMoreElements
|
While enum1.hasMoreElements
|
||||||
enum1Element = enum1.nextElement
|
enum1Element = enum1.nextElement
|
||||||
If enum1Element.supportsService("com.sun.star.text.Paragraph") Then
|
If enum1Element.supportsService("com.sun.star.text.Paragraph") Then
|
||||||
If enum1Element.OutlineLevel = level Then
|
traverseNoteParagraphs(curNum, enum1Element ,noteType, level)
|
||||||
curNum = 1
|
|
||||||
EndIf
|
|
||||||
enum2 = enum1Element.createEnumeration
|
|
||||||
While enum2.hasMoreElements
|
|
||||||
thisPortion = enum2.nextElement
|
|
||||||
If isTargetNote(thisPortion, noteType) Then
|
|
||||||
|
|
||||||
footnoteText = thisPortion.Footnote
|
|
||||||
label = footnoteText.getLabel
|
|
||||||
If label = "" Then
|
|
||||||
If level > 0 Then
|
|
||||||
footnoteText.setLabel(CStr(curNum))
|
|
||||||
curNum = curNum + 1
|
|
||||||
EndIf
|
|
||||||
Else
|
|
||||||
labelNum = CLng(label)
|
|
||||||
If labelNum > 0 Then
|
|
||||||
If level < 1 Then
|
|
||||||
footnoteText.setLabel("")
|
|
||||||
Else
|
|
||||||
footnoteText.setLabel(CStr(curNum))
|
|
||||||
EndIf
|
|
||||||
curNum = curNum + 1
|
|
||||||
EndIf
|
|
||||||
EndIf
|
|
||||||
EndIf
|
|
||||||
Wend
|
|
||||||
ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then
|
ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then
|
||||||
cellNames = enum1Element.cellNames
|
cellNames = enum1Element.cellNames
|
||||||
For i = LBound(cellNames) To Ubound(cellNames)
|
For i = LBound(cellNames) To Ubound(cellNames)
|
||||||
|
@ -217,12 +143,27 @@ Sub setFootnotesNumberingLevel(level As Integer,noteType As Integer)
|
||||||
While cellEnum.hasMoreElements
|
While cellEnum.hasMoreElements
|
||||||
cellEnumElement = cellEnum.nextElement
|
cellEnumElement = cellEnum.nextElement
|
||||||
If cellEnumElement.supportsService("com.sun.star.text.Paragraph") Then
|
If cellEnumElement.supportsService("com.sun.star.text.Paragraph") Then
|
||||||
If cellEnumElement.OutlineLevel = level Then
|
traverseNoteParagraphs(curNum, cellEnumElement ,noteType, level)
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
Next i
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
statusIndicator.end()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub traverseNoteParagraphs(curNum As Integer, enum1Element As Object, noteType As Integer, level As Integer)
|
||||||
|
Dim textPortions As Object
|
||||||
|
Dim thisPortion As Object
|
||||||
|
Dim footnoteText As Object
|
||||||
|
Dim label As String
|
||||||
|
Dim labelNum As Long
|
||||||
|
If enum1Element.OutlineLevel = level Then
|
||||||
curNum = 1
|
curNum = 1
|
||||||
EndIf
|
EndIf
|
||||||
cellEnum2 = cellEnumElement.createEnumeration
|
textPortions = enum1Element.createEnumeration
|
||||||
While cellEnum2.hasMoreElements
|
While textPortions.hasMoreElements
|
||||||
thisPortion = cellEnum2.nextElement
|
thisPortion = textPortions.nextElement
|
||||||
If isTargetNote(thisPortion, noteType) Then
|
If isTargetNote(thisPortion, noteType) Then
|
||||||
footnoteText = thisPortion.Footnote
|
footnoteText = thisPortion.Footnote
|
||||||
label = footnoteText.getLabel
|
label = footnoteText.getLabel
|
||||||
|
@ -232,33 +173,30 @@ Sub setFootnotesNumberingLevel(level As Integer,noteType As Integer)
|
||||||
curNum = curNum + 1
|
curNum = curNum + 1
|
||||||
EndIf
|
EndIf
|
||||||
Else
|
Else
|
||||||
labelNum = CLng(label)
|
If IsNumeric(label) Then
|
||||||
If labelNum > 0 Then
|
|
||||||
If level < 1 Then
|
If level < 1 Then
|
||||||
footnoteText.setLabel("")
|
footnoteText.setLabel("")
|
||||||
Else
|
Else
|
||||||
footnoteText.setLabel(CStr(curNum))
|
footnoteText.setLabel(CStr(curNum))
|
||||||
EndIf
|
|
||||||
curNum = curNum + 1
|
curNum = curNum + 1
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
Wend
|
|
||||||
EndIf
|
EndIf
|
||||||
Wend
|
Wend
|
||||||
Next i
|
|
||||||
EndIf
|
|
||||||
Wend
|
|
||||||
statusIndicator.end()
|
|
||||||
MsgBox getTranslation("statusNumberingFinished")
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Function isTargetNote(portion As Object, noteType As Integer) As Boolean
|
Function isTargetNote(portion As Object, noteType As Integer) As Boolean
|
||||||
If ( portion.TextPortionType = "Footnote" And isEndNote(portion) = CBool(noteType) ) Then
|
If ( portion.TextPortionType <> "Footnote" ) Then
|
||||||
isTargetNote = true
|
|
||||||
Else
|
|
||||||
isTargetNote = false
|
isTargetNote = false
|
||||||
|
Exit Function
|
||||||
EndIf
|
EndIf
|
||||||
|
If ( isEndNote(portion) = CBool(noteType) ) Then
|
||||||
|
isTargetNote = true
|
||||||
|
Exit Function
|
||||||
|
EndIf
|
||||||
|
isTargetNote = false
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
'Sub testRange
|
'Sub testRange
|
||||||
|
@ -281,6 +219,7 @@ Function IsInArray(array As Variant, content As Variant) As Boolean
|
||||||
inArr = array(i)
|
inArr = array(i)
|
||||||
If inArr = content Then
|
If inArr = content Then
|
||||||
IsInArray = true
|
IsInArray = true
|
||||||
|
Exit Function
|
||||||
EndIf
|
EndIf
|
||||||
Next i
|
Next i
|
||||||
End Function
|
End Function
|
||||||
|
|
Loading…
Add table
Reference in a new issue