epublishing/ePublishing/Footnotes.xba

145 lines
4.7 KiB
Text
Raw Normal View History

2020-03-13 16:36:45 +01:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
2020-03-13 16:40:24 +01:00
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Footnotes" script:language="StarBasic" script:moduleType="normal">sub footMark1
2020-03-13 16:42:10 +01:00
End Sub
2020-03-13 16:40:24 +01:00
Sub openFootNotesDialog
2020-03-13 16:36:45 +01:00
Dim dialog As Object
DialogLibraries.LoadLibrary(&quot;ePublishing&quot;)
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(&quot;level&quot;).Value
If targetLevel &gt; -1 AND targetLevel &lt; 11 Then
statusIndicator.Start(&quot;Нумерую сноски&quot;,100)
setFootnotesNumberingLevel(targetLevel)
Else
MsgBox &quot;Значение уровня заголовков вне допустимого диапазона. Введите число от 0 до 10.&quot;
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(&quot;Нумерация сносок запущена, подождите&quot;,30)
curNum = 1
enum1 = ThisComponent.Text.createEnumeration
While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
If enum1Element.OutlineLevel = level Then
curNum = 1
EndIf
enum2 = enum1Element.createEnumeration
While enum2.hasMoreElements
thisPortion = enum2.nextElement
If thisPortion.TextPortionType = &quot;Footnote&quot; Then
footnoteText = thisPortion.Footnote
label = footnoteText.getLabel
If label = &quot;&quot; Then
If level &gt; 0 Then
footnoteText.setLabel(CStr(curNum))
curNum = curNum + 1
EndIf
Else
labelNum = CInt(label)
If labelNum &gt; 0 Then
If level &lt; 1 Then
footnoteText.setLabel(&quot;&quot;)
Else
footnoteText.setLabel(CStr(curNum))
EndIf
curNum = curNum + 1
EndIf
EndIf
EndIf
Wend
ElseIf enum1Element.supportsService(&quot;com.sun.star.text.TextTable&quot;) 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(&quot;com.sun.star.text.Paragraph&quot;) Then
If cellEnumElement.OutlineLevel = level Then
curNum = 1
EndIf
cellEnum2 = cellEnumElement.createEnumeration
While cellEnum2.hasMoreElements
thisPortion = cellEnum2.nextElement
If thisPortion.TextPortionType = &quot;Footnote&quot; Then
footnoteText = thisPortion.Footnote
label = footnoteText.getLabel
If label = &quot;&quot; Then
If level &gt; 0 Then
footnoteText.setLabel(CStr(curNum))
curNum = curNum + 1
EndIf
Else
labelNum = CInt(label)
If labelNum &gt; 0 Then
If level &lt; 1 Then
footnoteText.setLabel(&quot;&quot;)
Else
footnoteText.setLabel(CStr(curNum))
EndIf
curNum = curNum + 1
EndIf
EndIf
EndIf
Wend
EndIf
Wend
Next i
EndIf
Wend
statusIndicator.end()
2020-03-13 16:40:24 +01:00
MsgBox &quot;Нумерация сносок успешно завершена.&quot;
End Sub
Private Sub doNotTrack
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
document = ThisComponent.CurrentController.Frame
dim trackProperties(0) as new com.sun.star.beans.PropertyValue
trackProperties(0).Name = &quot;TrackChanges&quot;
trackProperties(0).Value = false
dispatcher.executeDispatch(document, &quot;.uno:TrackChanges&quot;, &quot;&quot;, 0, trackProperties())
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = &quot;ShowTrackedChanges&quot;
args1(0).Value = true
dispatcher.executeDispatch(document, &quot;.uno:ShowTrackedChanges&quot;, &quot;&quot;, 0, args1())
2020-03-13 16:36:45 +01:00
End Sub
2020-03-13 16:42:10 +01:00
</script:module>