Footnotes numbering
This commit is contained in:
parent
62fafde775
commit
bb69f14e26
6 changed files with 167 additions and 6 deletions
16
Addons.xcu
16
Addons.xcu
|
@ -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
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>
|
17
ePublishing/FootnotesConfig.xdl
Normal file
17
ePublishing/FootnotesConfig.xdl
Normal 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>
|
|
@ -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>
|
|
@ -60,7 +60,7 @@ Private Sub makeUpIssue
|
|||
|
||||
' Add article for each section
|
||||
'Go to article first page
|
||||
page = findFirstPageWithStyle("Первая страница статьи")
|
||||
page = findFirstPageNumberWithStyle("Первая страница статьи")
|
||||
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("Статья 1 стр.1")
|
||||
firstPage = findFirstPageNumberWithStyle("Статья 1 стр.1")
|
||||
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("PageStyles")
|
||||
page = findFirstPageWithStyle("Статья " + i + " стр.1")
|
||||
page = findFirstPageNumberWithStyle("Статья " + i + " стр.1")
|
||||
oViewCursor.jumpToPage(page)
|
||||
articleStartPosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue