Footnotes numbering
This commit is contained in:
parent
62fafde775
commit
bb69f14e26
6 changed files with 167 additions and 6 deletions
127
ePublishing/Footnotes.xba
Normal file
127
ePublishing/Footnotes.xba
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?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 openFootNotesDialog
|
||||
Dim dialog As Object
|
||||
DialogLibraries.LoadLibrary("ePublishing")
|
||||
dialog = CreateUnoDialog(DialogLibraries.ePublishing.FootnotesConfig)
|
||||
dialog.setVisible(true)
|
||||
Select Case dialog.Execute()
|
||||
Case 1
|
||||
setFootnotesNumberingFrom(dialog)
|
||||
Case 0
|
||||
End Select
|
||||
dialog.dispose()
|
||||
End Sub
|
||||
|
||||
Sub setFootnotesNumberingFrom(dialog)
|
||||
Dim statusIndicator as Object
|
||||
Dim targetLevel As Integer
|
||||
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
||||
dialog.setVisible(false)
|
||||
doNotTrack
|
||||
targetLevel = dialog.getControl("level").Value
|
||||
|
||||
If targetLevel > -1 AND targetLevel < 11 Then
|
||||
statusIndicator.Start("Нумерую сноски",100)
|
||||
setFootnotesNumberingLevel(targetLevel)
|
||||
Else
|
||||
MsgBox "Значение уровня заголовков вне допустимого диапазона. Введите число от 0 до 10."
|
||||
EndIf
|
||||
|
||||
statusIndicator.end()
|
||||
End Sub
|
||||
|
||||
Sub setFootnotesNumberingLevel(level)
|
||||
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 Integer
|
||||
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("Нумерация сносок запущена, подождите",30)
|
||||
|
||||
|
||||
curNum = 1
|
||||
enum1 = ThisComponent.Text.createEnumeration
|
||||
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 thisPortion.TextPortionType = "Footnote" Then
|
||||
footnoteText = thisPortion.Footnote
|
||||
label = footnoteText.getLabel
|
||||
If label = "" Then
|
||||
If level > 0 Then
|
||||
footnoteText.setLabel(CStr(curNum))
|
||||
curNum = curNum + 1
|
||||
EndIf
|
||||
Else
|
||||
labelNum = CInt(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
|
||||
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
|
||||
If cellEnumElement.OutlineLevel = level Then
|
||||
curNum = 1
|
||||
EndIf
|
||||
cellEnum2 = cellEnumElement.createEnumeration
|
||||
While cellEnum2.hasMoreElements
|
||||
thisPortion = cellEnum2.nextElement
|
||||
If thisPortion.TextPortionType = "Footnote" Then
|
||||
footnoteText = thisPortion.Footnote
|
||||
label = footnoteText.getLabel
|
||||
If label = "" Then
|
||||
If level > 0 Then
|
||||
footnoteText.setLabel(CStr(curNum))
|
||||
curNum = curNum + 1
|
||||
EndIf
|
||||
Else
|
||||
labelNum = CInt(label)
|
||||
If labelNum > 0 Then
|
||||
If level < 1 Then
|
||||
footnoteText.setLabel("")
|
||||
Else
|
||||
footnoteText.setLabel(CStr(curNum))
|
||||
EndIf
|
||||
curNum = curNum + 1
|
||||
EndIf
|
||||
EndIf
|
||||
EndIf
|
||||
Wend
|
||||
EndIf
|
||||
Wend
|
||||
Next i
|
||||
EndIf
|
||||
Wend
|
||||
statusIndicator.end()
|
||||
End Sub
|
||||
</script:module>
|
Loading…
Add table
Add a link
Reference in a new issue