Footnotes numbering

This commit is contained in:
Georgy Litvinov 2020-03-13 16:36:45 +01:00
parent 62fafde775
commit bb69f14e26
6 changed files with 167 additions and 6 deletions

View file

@ -116,6 +116,22 @@
<value>_self</value>
</prop>
</node>
<node oor:name="footNotesNumbering" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.WebDocument</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en">Footnotes numbering configuration</value>
<value xml:lang="ru">Настройка нумерации сносок</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///ePublishing.Footnotes.openFootNotesDialog</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
</node>
</node>

127
ePublishing/Footnotes.xba Normal file
View 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(&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()
End Sub
</script:module>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="FootnotesConfig" dlg:left="99" dlg:top="62" dlg:width="160" dlg:height="98" dlg:closeable="true" dlg:moveable="true">
<dlg:bulletinboard>
<dlg:text dlg:id="Label1" dlg:tab-index="0" dlg:left="16" dlg:top="41" dlg:width="112" dlg:height="10" dlg:value="Начинать нумерацию сносок заново "/>
<dlg:text dlg:id="Label2" dlg:tab-index="1" dlg:left="158" dlg:top="132" dlg:width="0" dlg:height="2" dlg:value="Label2"/>
<dlg:button dlg:id="CommandButton1" dlg:tab-index="2" dlg:left="5" dlg:top="78" dlg:width="69" dlg:height="17" dlg:value="OK" dlg:button-type="ok"/>
<dlg:button dlg:id="CommandButton2" dlg:tab-index="3" dlg:left="77" dlg:top="122" dlg:width="2" dlg:height="0" dlg:value="CommandButton2"/>
<dlg:button dlg:id="CommandButton3" dlg:tab-index="4" dlg:left="86" dlg:top="78" dlg:width="69" dlg:height="17" dlg:value="Отмена" dlg:button-type="cancel"/>
<dlg:text dlg:id="Label3" dlg:tab-index="5" dlg:left="96" dlg:top="55" dlg:width="24" dlg:height="10" dlg:value="уровня"/>
<dlg:text dlg:id="Label4" dlg:tab-index="7" dlg:left="16" dlg:top="55" dlg:width="58" dlg:height="10" dlg:value="после заголовков"/>
<dlg:text dlg:id="Label5" dlg:tab-index="8" dlg:left="16" dlg:top="15" dlg:width="109" dlg:height="10" dlg:value="Введите в поле число от 0 до 10"/>
<dlg:text dlg:id="Label6" dlg:tab-index="9" dlg:left="9" dlg:top="120" dlg:width="2" dlg:height="0" dlg:value="Label6"/>
<dlg:text dlg:id="Label7" dlg:tab-index="10" dlg:left="17" dlg:top="28" dlg:width="122" dlg:height="10" dlg:value="0 - возврат к стандартной нумерации"/>
<dlg:numericfield dlg:id="level" dlg:tab-index="6" dlg:left="77" dlg:top="55" dlg:width="17" dlg:height="10"/>
</dlg:bulletinboard>
</dlg:window>

View file

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="ePublishing" library:readonly="false" library:passwordprotected="false">
</library:library>
<library:element library:name="FootnotesConfig"/>
</library:library>

View file

@ -60,7 +60,7 @@ Private Sub makeUpIssue
&apos; Add article for each section
&apos;Go to article first page
page = findFirstPageWithStyle(&quot;Первая страница статьи&quot;)
page = findFirstPageNumberWithStyle(&quot;Первая страница статьи&quot;)
firstPage = page
oViewCursor.jumpToPage(page)
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
@ -152,7 +152,7 @@ Private Sub setPageNumbersDeprecated()
Dim firstPage as String
oViewCursor = ThisComponent.CurrentController.getViewCursor()
oViewCursor.jumpToFirstPage()
firstPage = findFirstPageWithStyle(&quot;Статья 1 стр.1&quot;)
firstPage = findFirstPageNumberWithStyle(&quot;Статья 1 стр.1&quot;)
oViewCursor.jumpToPage(firstPage)
For i = 1 To 25
pageNum = lastPageNum(i)
@ -539,13 +539,13 @@ Private Sub setAritclePageHeaders(i)
Dim leftHeaderCell As Object
Dim curStyleName As String
Dim curStyle As Object
Dim page As String
Dim page As Integer
Dim pageStyles As Object
Dim articleStartPosition As Object
oViewCursor = ThisComponent.CurrentController.getViewCursor()
oSavePosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
pageStyles = ThisComponent.StyleFamilies.getByName(&quot;PageStyles&quot;)
page = findFirstPageWithStyle(&quot;Статья &quot; + i + &quot; стр.1&quot;)
page = findFirstPageNumberWithStyle(&quot;Статья &quot; + i + &quot; стр.1&quot;)
oViewCursor.jumpToPage(page)
articleStartPosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)

View file

@ -4,5 +4,5 @@
<library:element library:name="Hyphenations"/>
<library:element library:name="Books"/>
<library:element library:name="journals"/>
<library:element library:name="Footnotes"/>
</library:library>