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"?>
|
||||
<!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
|
||||
|
||||
Sub openFootNotesDialog
|
||||
|
@ -64,98 +64,56 @@ Sub setFootnotesNumberingFrom(dialog As Object)
|
|||
EndIf
|
||||
|
||||
statusIndicator.end()
|
||||
MsgBox getTranslation("statusNumberingFinished")
|
||||
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 allNotes As Object
|
||||
Dim statusIndicator as Object
|
||||
Dim i As Integer
|
||||
Dim cell As Object
|
||||
Dim cellEnum As Object
|
||||
Dim cellEnum2 As Object
|
||||
Dim curNote As Object
|
||||
Dim curPage As String
|
||||
Dim prevPage As String
|
||||
prevPage = ""
|
||||
Dim statusIndicator as Object
|
||||
Dim curNum As Integer
|
||||
Dim notesToValidate() 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 ( 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
|
||||
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
|
||||
prevPage = ""
|
||||
If noteType = 0 Then
|
||||
allNotes = thisComponent.FootNotes
|
||||
Else
|
||||
allNotes = thisComponent.EndNotes
|
||||
EndIf
|
||||
For i = 0 to allNotes.Count -1
|
||||
curNote = allNotes.getByIndex(i)
|
||||
curPage = getPageNumberVCurs(curNote.Anchor)
|
||||
If ( IsInArray(pageNums, CInt(curPage) ) ) Then
|
||||
If (curPage <> prevPage) Then
|
||||
curNum = 1
|
||||
prevPage = curPage
|
||||
EndIf
|
||||
Wend
|
||||
label = curNote.getLabel
|
||||
If label = "" Or IsNumeric(label) Then
|
||||
curNote.setLabel(CStr(curNum))
|
||||
addToArray(notesToValidate,curnote)
|
||||
curNum = curNum + 1
|
||||
EndIf
|
||||
EndIf
|
||||
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
|
||||
curNote.setLabel(CStr(curNum))
|
||||
curNum = curNum + 1
|
||||
Next i
|
||||
statusIndicator.end()
|
||||
MsgBox getTranslation("statusNumberingFinished")
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
@ -163,17 +121,12 @@ Sub setFootnotesNumberingLevel(level As Integer,noteType 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 statusIndicator as Object
|
||||
|
||||
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
||||
statusIndicator.Start(getTranslation("statusNumberingInProcess"),30)
|
||||
curNum = 1
|
||||
|
@ -181,34 +134,7 @@ Sub setFootnotesNumberingLevel(level As Integer,noteType As Integer)
|
|||
While enum1.hasMoreElements
|
||||
enum1Element = enum1.nextElement
|
||||
If enum1Element.supportsService("com.sun.star.text.Paragraph") Then
|
||||
If enum1Element.OutlineLevel = level Then
|
||||
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
|
||||
traverseNoteParagraphs(curNum, enum1Element ,noteType, level)
|
||||
ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then
|
||||
cellNames = enum1Element.cellNames
|
||||
For i = LBound(cellNames) To Ubound(cellNames)
|
||||
|
@ -217,48 +143,60 @@ Sub setFootnotesNumberingLevel(level As Integer,noteType As Integer)
|
|||
While cellEnum.hasMoreElements
|
||||
cellEnumElement = cellEnum.nextElement
|
||||
If cellEnumElement.supportsService("com.sun.star.text.Paragraph") Then
|
||||
If cellEnumElement.OutlineLevel = level Then
|
||||
curNum = 1
|
||||
EndIf
|
||||
cellEnum2 = cellEnumElement.createEnumeration
|
||||
While cellEnum2.hasMoreElements
|
||||
thisPortion = cellEnum2.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
|
||||
traverseNoteParagraphs(curNum, cellEnumElement ,noteType, level)
|
||||
EndIf
|
||||
Wend
|
||||
Next i
|
||||
EndIf
|
||||
Wend
|
||||
statusIndicator.end()
|
||||
MsgBox getTranslation("statusNumberingFinished")
|
||||
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
|
||||
EndIf
|
||||
textPortions = enum1Element.createEnumeration
|
||||
While textPortions.hasMoreElements
|
||||
thisPortion = textPortions.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
|
||||
If IsNumeric(label) Then
|
||||
If level < 1 Then
|
||||
footnoteText.setLabel("")
|
||||
Else
|
||||
footnoteText.setLabel(CStr(curNum))
|
||||
curNum = curNum + 1
|
||||
EndIf
|
||||
EndIf
|
||||
EndIf
|
||||
EndIf
|
||||
Wend
|
||||
End Sub
|
||||
|
||||
|
||||
Function isTargetNote(portion As Object, noteType As Integer) As Boolean
|
||||
If ( portion.TextPortionType = "Footnote" And isEndNote(portion) = CBool(noteType) ) Then
|
||||
isTargetNote = true
|
||||
Else
|
||||
If ( portion.TextPortionType <> "Footnote" ) Then
|
||||
isTargetNote = false
|
||||
Exit Function
|
||||
EndIf
|
||||
If ( isEndNote(portion) = CBool(noteType) ) Then
|
||||
isTargetNote = true
|
||||
Exit Function
|
||||
EndIf
|
||||
isTargetNote = false
|
||||
End Function
|
||||
|
||||
'Sub testRange
|
||||
|
@ -281,6 +219,7 @@ Function IsInArray(array As Variant, content As Variant) As Boolean
|
|||
inArr = array(i)
|
||||
If inArr = content Then
|
||||
IsInArray = true
|
||||
Exit Function
|
||||
EndIf
|
||||
Next i
|
||||
End Function
|
||||
|
|
Loading…
Add table
Reference in a new issue