Fixed headings settings while working with archive
This commit is contained in:
parent
8fab22ff8c
commit
85e11b73a5
3 changed files with 237 additions and 20 deletions
18
Addons.xcu
18
Addons.xcu
|
@ -323,6 +323,24 @@
|
|||
<value xml:lang="bs">Oporavak prekida stranice</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name="ConfigureArchiveHeadings" oor:op="replace">
|
||||
<prop oor:name="URL" oor:type="xs:string">
|
||||
<value>macro:///ePublishing.Archive.configureHeadings</value>
|
||||
</prop>
|
||||
<prop oor:name="Target" oor:type="xs:string">
|
||||
<value>_self</value>
|
||||
</prop>
|
||||
<prop oor:name="Title" oor:type="xs:string">
|
||||
<value/>
|
||||
<value xml:lang="en">Configure headings</value>
|
||||
<value xml:lang="ru">Настроить заголовки</value>
|
||||
<value xml:lang="fr">Configurer les en-têtes</value>
|
||||
<value xml:lang="sr">Конфигурише заглавља</value>
|
||||
<value xml:lang="hr">Konfiguriranje naslova</value>
|
||||
<value xml:lang="bs">Konfiguriranje naslova</value>
|
||||
</prop>
|
||||
</node>
|
||||
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?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="Archive" script:language="StarBasic" script:moduleType="normal">Sub archMark11
|
||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Archive" script:language="StarBasic" script:moduleType="normal">Sub archMark14
|
||||
|
||||
End Sub
|
||||
|
||||
|
@ -142,10 +142,13 @@ sub convertIndesignPageBreaks
|
|||
Dim firstBreak As Boolean
|
||||
firstBreak = true
|
||||
Dim charNum As Long
|
||||
Dim character As String
|
||||
Dim prevParaLastCharacter As String
|
||||
Dim oFound As Object
|
||||
Dim pageNumber As Integer
|
||||
Dim prevPageNumber As Integer
|
||||
Dim nextPara As Object
|
||||
Dim prevPara As Object
|
||||
Dim nextParaFirstCharacter As String
|
||||
firstLowercase = false
|
||||
|
||||
oSearch = ThisComponent.createSearchDescriptor()
|
||||
|
@ -161,10 +164,12 @@ sub convertIndesignPageBreaks
|
|||
oTextCursor.goRight(1,true)
|
||||
oTextCursor.String = ""
|
||||
oTextCursor.BreakType = com.sun.star.style.BreakType.PAGE_BEFORE
|
||||
'Go to Start of new paragraph to shrink prev page if necessary
|
||||
oViewCursor.goToRange(oTextCursor.End,false)
|
||||
oViewCursor.goLeft(1,false)
|
||||
'
|
||||
Wait 100
|
||||
pageNumber = getPageNumber(oTextCursor.Text.createTextCursorByRange(oTextCursor.End)
|
||||
pageNumber = getPageNumber(oTextCursor.Text.createTextCursorByRange(oTextCursor.End))
|
||||
If firstBreak Then
|
||||
firstBreak = false
|
||||
prevPageNumber = pageNumber
|
||||
|
@ -172,34 +177,42 @@ sub convertIndesignPageBreaks
|
|||
If pageNumber - prevPageNumber > 1 Then
|
||||
shrinkPageContent
|
||||
Wait 100
|
||||
pageNumber = getPageNumber(oTextCursor.Text.createTextCursorByRange(oTextCursor.End)
|
||||
pageNumber = getPageNumber(oTextCursor.Text.createTextCursorByRange(oTextCursor.End))
|
||||
EndIf
|
||||
'check first character
|
||||
oTextCursor.goRight(1,true)
|
||||
If (isLowerCase(oTextCursor.getString())) Then
|
||||
oTextCursor.ParaFirstLineIndent = 0
|
||||
nextPara = oTextCursor.End
|
||||
nextParaFirstCharacter = oTextCursor.getString()
|
||||
If (isLowerCase(nextParaFirstCharacter)) Then
|
||||
adjustFirstLine(nextPara)
|
||||
firstLowercase = true
|
||||
End If
|
||||
'check last character
|
||||
oTextCursor.goLeft(2,false)
|
||||
prevPara = oTextCursor.Start
|
||||
oTextCursor.goLeft(1,true)
|
||||
character = oTextCursor.getString()
|
||||
prevParaLastCharacter = oTextCursor.getString()
|
||||
|
||||
If (character = " ") Then
|
||||
If (prevParaLastCharacter = " ") Then
|
||||
' oTextCursor.String=""
|
||||
'last paragraph
|
||||
adjustLastLine(oTextCursor)
|
||||
|
||||
adjustLastLine(prevPara)
|
||||
adjustFirstLine(nextPara)
|
||||
EndIf
|
||||
If (isLowerCase(character)) Then
|
||||
If (isLowerCase(prevParaLastCharacter)) Then
|
||||
If firstLowercase Then
|
||||
oTextCursor.collapseToEnd()
|
||||
oTextCursor.setString("-")
|
||||
oTextCursor.collapseToEnd()
|
||||
adjustLastLine(oTextCursor)
|
||||
adjustFirstLine(oTextCursor)
|
||||
adjustLastLine(prevPara)
|
||||
adjustFirstLine(nextPara)
|
||||
EndIf
|
||||
End If
|
||||
|
||||
If pageNumber - prevPageNumber < 2 Then
|
||||
' stretchPrevPage(prevPara)
|
||||
EndIf
|
||||
|
||||
prevPageNumber = pageNumber
|
||||
oFound = ThisComponent.findNext(oFound.End, oSearch)
|
||||
Loop
|
||||
|
@ -207,15 +220,199 @@ sub convertIndesignPageBreaks
|
|||
MsgBox getTranslation("convertIndesignPageBreaksFinish")
|
||||
end Sub
|
||||
|
||||
Sub adjustLastLine(oTextCursor As Object)
|
||||
oTextCursor.ParaAdjust = 2
|
||||
oTextCursor.ParaLastLineAdjust = 2
|
||||
balancePara(oTextCursor)
|
||||
Sub configureHeadings
|
||||
configureArchiveHeading1
|
||||
configureOtherArchiveHeadings
|
||||
End Sub
|
||||
|
||||
Sub adjustFirstLine(oTextCursor As Object)
|
||||
oTextCursor.goRight(1,false)
|
||||
oTextCursor.ParaFirstLineIndent = 0
|
||||
|
||||
Sub configureArchiveHeading1
|
||||
Dim outline1() As Object
|
||||
Dim oViewCursor As Object
|
||||
Dim oSavePosition As Object
|
||||
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
||||
oSavePosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||
outline1 = getHeadingWithLevel(1)
|
||||
Dim startViewPageNum As Integer
|
||||
Dim pageNumberCursor As Object
|
||||
Dim i As Integer
|
||||
Dim j As Integer
|
||||
Dim initialPageCount As Integer
|
||||
initialPageCount = ThisComponent.currentController.pageCount
|
||||
For i = LBound(outline1) To UBound(outline1)
|
||||
oViewCursor.goToRange(outline1(i), false)
|
||||
oViewCursor.jumpToEndOfPage()
|
||||
pageNumberCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||
pageNumberCursor.goToStartOfWord(false)
|
||||
startViewPageNum = getPageNumber(pageNumberCursor)
|
||||
|
||||
Do While startViewPageNum = getPageNumber(pageNumberCursor) And initialPageCount = ThisComponent.currentController.pageCount
|
||||
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin + 100
|
||||
Loop
|
||||
If outline1(i).ParaTopMargin >= 100 Then
|
||||
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin - 100
|
||||
EndIf
|
||||
Next i
|
||||
oViewCursor.goToRange(oSavePosition,false)
|
||||
End Sub
|
||||
|
||||
Sub configureOtherArchiveHeadings
|
||||
Dim outline1() As Object
|
||||
Dim oViewCursor As Object
|
||||
Dim oSavePosition As Object
|
||||
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
||||
oSavePosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||
|
||||
Dim startViewPageNum As Integer
|
||||
Dim pageNumberCursor As Object
|
||||
Dim i As Integer
|
||||
Dim j As Integer
|
||||
Dim initialPageCount As Integer
|
||||
initialPageCount = ThisComponent.currentController.pageCount
|
||||
For j = 2 To 10
|
||||
outline1 = getHeadingWithLevel(j)
|
||||
For i = LBound(outline1) To UBound(outline1)
|
||||
If outline1(i).BreakType <> 4 Then
|
||||
oViewCursor.goToRange(outline1(i), false)
|
||||
oViewCursor.jumpToEndOfPage()
|
||||
pageNumberCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||
pageNumberCursor.goToStartOfWord(false)
|
||||
startViewPageNum = getPageNumber(pageNumberCursor)
|
||||
|
||||
Do While startViewPageNum = getPageNumber(pageNumberCursor) And initialPageCount = ThisComponent.currentController.pageCount
|
||||
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin + 100
|
||||
If (outline1(i).ParaTopMargin > outline1(i).ParaBottomMargin) Then
|
||||
Exit Do
|
||||
EndIf
|
||||
Loop
|
||||
If outline1(i).ParaTopMargin >= 100 Then
|
||||
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin - 100
|
||||
EndIf
|
||||
EndIf
|
||||
Next i
|
||||
Next j
|
||||
oViewCursor.goToRange(oSavePosition,false)
|
||||
End Sub
|
||||
|
||||
|
||||
Sub stretchPrevPage()
|
||||
'Assumption hard breaks at start of stretching page and at start of next page
|
||||
Dim pageCount As Integer
|
||||
Dim curViewPageNum As Integer
|
||||
Dim startViewPageNum As Integer
|
||||
Dim successOperation As Boolean
|
||||
Dim paragraphs() As Object
|
||||
Dim outline1() As Object
|
||||
Dim outline2() As Object
|
||||
initialPageCount = thiscomponent.currentController.pageCount
|
||||
Dim oViewCursor As Object
|
||||
Dim textCursor As Object
|
||||
Dim pageNumberCursor As Object
|
||||
Dim oSavePosition As Object
|
||||
Dim pageStartPosition As Object
|
||||
Dim i As Integer
|
||||
Dim curPara As Object
|
||||
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
||||
oSavePosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||
oViewCursor.goToRange(prevPara, false)
|
||||
'oViewCursor.goToStartOfLine(false)
|
||||
pageNumberCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||
pageNumberCursor.goToStartOfWord(false)
|
||||
'Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
||||
'MRI pageNumberCursor
|
||||
oViewCursor.jumpToStartOfPage()
|
||||
startViewPageNum = getPageNumber(pageNumberCursor)
|
||||
textCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||
Do While oViewCursor.getPage() = startViewPageNum
|
||||
curPara = textCursor.textParagraph
|
||||
If curPara.outlineLevel = 1 Then
|
||||
addToArray(outline1, curPara)
|
||||
ElseIf curPara.outlineLevel = 2 Then
|
||||
addToArray(outline2, curPara)
|
||||
Else
|
||||
addToArray(paragraphs, curPara)
|
||||
EndIf
|
||||
successOperation = textCursor.goToNextParagraph(false)
|
||||
If NOT successOperation Then
|
||||
Exit Do
|
||||
EndIf
|
||||
oViewCursor.goToRange(textCursor,false)
|
||||
Loop
|
||||
|
||||
If UBound(outline1) > -1 Then
|
||||
Do While startViewPageNum = getPageNumber(pageNumberCursor)
|
||||
For i = LBound(outline1) To UBound(outline1)
|
||||
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin + 100
|
||||
Next i
|
||||
Loop
|
||||
For i = LBound(outline1) To UBound(outline1)
|
||||
If outline1(i).ParaTopMargin >= 100 Then
|
||||
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin - 100
|
||||
EndIf
|
||||
Next i
|
||||
Exit Sub
|
||||
EndIf
|
||||
|
||||
If UBound(outline2) > -1 Then
|
||||
Do While startViewPageNum = getPageNumber(pageNumberCursor)
|
||||
For i = LBound(outline2) To UBound(outline2)
|
||||
outline2(i).ParaTopMargin = outline2(i).ParaTopMargin + 100
|
||||
If outline2(i).ParaTopMargin > outline2(i).ParaBottomMargin Then
|
||||
Exit Do
|
||||
EndIf
|
||||
Next i
|
||||
Loop
|
||||
For i = LBound(outline2) To UBound(outline2)
|
||||
If outline2(i).ParaTopMargin >= 100 Then
|
||||
outline2(i).ParaTopMargin = outline2(i).ParaTopMargin - 100
|
||||
EndIf
|
||||
Next i
|
||||
Exit Sub
|
||||
EndIf
|
||||
|
||||
'Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
||||
'Mri curPara
|
||||
Dim paraLineSpacing As Object
|
||||
Dim tmpPageNum As Integer
|
||||
tmpPageNum = getPageNumber(pageNumberCursor)
|
||||
If UBound(paragraphs) > -1 Then
|
||||
Dim iterations As Integer
|
||||
iterations = 0
|
||||
Do While startViewPageNum = getPageNumber(pageNumberCursor)
|
||||
For i = LBound(paragraphs) To UBound(paragraphs)
|
||||
paraLineSpacing = paragraphs(i).paraLineSpacing
|
||||
paraLineSpacing.Height = paraLineSpacing.Height + 5
|
||||
paragraphs(i).paraLineSpacing = paraLineSpacing
|
||||
Next i
|
||||
iterations = iterations + 1
|
||||
If iterations > 4 Then
|
||||
Exit Do
|
||||
EndIf
|
||||
tmpPageNum = getPageNumber(pageNumberCursor)
|
||||
Loop
|
||||
For i = LBound(paragraphs) To UBound(paragraphs)
|
||||
paraLineSpacing = paragraphs(i).paraLineSpacing
|
||||
paraLineSpacing.Height = paraLineSpacing.Height - 5
|
||||
paragraphs(i).paraLineSpacing = paraLineSpacing
|
||||
Next i
|
||||
Exit Sub
|
||||
EndIf
|
||||
|
||||
|
||||
|
||||
|
||||
oViewCursor.goToRange(oSavePosition,false)
|
||||
End Sub
|
||||
|
||||
|
||||
Sub adjustLastLine(anchor As Object)
|
||||
anchor.ParaAdjust = 2
|
||||
anchor.ParaLastLineAdjust = 2
|
||||
balancePara(anchor)
|
||||
End Sub
|
||||
|
||||
Sub adjustFirstLine(anchor As Object)
|
||||
anchor.ParaFirstLineIndent = 0
|
||||
End Sub
|
||||
|
||||
|
||||
|
|
|
@ -1615,6 +1615,8 @@ Function getPageNumber(cursor As Object) As String
|
|||
oField.NumberingType = 4
|
||||
oField.SubType = com.sun.star.text.PageNumberType.CURRENT
|
||||
oTextCursor.Text.insertTextContent(oTextCursor, oField, False)
|
||||
oField.Anchor.CharHidden = False
|
||||
oField.Anchor.CharHidden = True
|
||||
getPageNumber = oField.getPresentation(false)
|
||||
oTextCursor.Text.removeTextContent(oField)
|
||||
End Function
|
||||
|
|
Loading…
Add table
Reference in a new issue