154 lines
No EOL
5.3 KiB
XML
154 lines
No EOL
5.3 KiB
XML
<?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 footMark1
|
|
End Sub
|
|
|
|
Sub openFootNotesDialog
|
|
Dim dialog As Object
|
|
DialogLibraries.LoadLibrary("ePublishing")
|
|
dialog = CreateUnoDialog(DialogLibraries.ePublishing.FootnotesConfig)
|
|
dialog.getControl("buttonOK").Label = getTranslation("buttonOk")
|
|
dialog.getControl("buttonCancel").Label = getTranslation("buttonCancel")
|
|
dialog.getControl("configText1").setText(getTranslation("configText1"))
|
|
dialog.getControl("configText2").setText(getTranslation("configText2"))
|
|
dialog.getControl("configText3").setText(getTranslation("configText3"))
|
|
dialog.getControl("configText4").setText(getTranslation("configText4"))
|
|
dialog.getControl("configText5").setText(getTranslation("configText5"))
|
|
dialog.Title = getTranslation("footnotesConfigDialogTitle")
|
|
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(getTranslation("statusNumberingInProcess"),100)
|
|
setFootnotesNumberingLevel(targetLevel)
|
|
Else
|
|
MsgBox getTranslation("numberingInputOutOfRange")
|
|
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(getTranslation("statusNumberingInProcess"),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()
|
|
MsgBox getTranslation("statusNumberingFinished")
|
|
End Sub
|
|
|
|
Private Sub doNotTrack
|
|
Dim dispatcher As Object
|
|
Dim document As Object
|
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
|
document = ThisComponent.CurrentController.Frame
|
|
dim trackProperties(0) as new com.sun.star.beans.PropertyValue
|
|
trackProperties(0).Name = "TrackChanges"
|
|
trackProperties(0).Value = false
|
|
dispatcher.executeDispatch(document, ".uno:TrackChanges", "", 0, trackProperties())
|
|
dim args1(0) as new com.sun.star.beans.PropertyValue
|
|
args1(0).Name = "ShowTrackedChanges"
|
|
args1(0).Value = true
|
|
dispatcher.executeDispatch(document, ".uno:ShowTrackedChanges", "", 0, args1())
|
|
End Sub
|
|
</script:module> |