fix: multiple fixes for processing archive books
This commit is contained in:
parent
941ac1c9cc
commit
82c63c82ca
2 changed files with 128 additions and 49 deletions
|
@ -1,11 +1,11 @@
|
|||
<?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 archMark24
|
||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Archive" script:language="StarBasic" script:moduleType="normal">Sub archMark25
|
||||
|
||||
End Sub
|
||||
|
||||
Public Const MAX_CHAR_KERNING = 20
|
||||
Public Const MIN_CHAR_KERNING = -15
|
||||
Public Const MAX_CHAR_KERNING = 15
|
||||
Public Const MIN_CHAR_KERNING = -10
|
||||
Public Const MIN_SPACING_TO_SHRINK = 500
|
||||
|
||||
Sub resetNotesStyle
|
||||
|
@ -173,12 +173,14 @@ sub convertIndesignPageBreaks
|
|||
EndIf
|
||||
turnOffTracking()
|
||||
|
||||
balanceFootNotes()
|
||||
Dim oViewCursor As Object
|
||||
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
||||
oViewCursor.jumpToFirstPage
|
||||
|
||||
Dim oSearch As Object
|
||||
Dim oTextCursor As Object
|
||||
Dim testCurs As Object
|
||||
Dim firstLowercase As Boolean
|
||||
Dim firstBreak As Boolean
|
||||
firstBreak = true
|
||||
|
@ -190,6 +192,7 @@ sub convertIndesignPageBreaks
|
|||
Dim nextPara As Object
|
||||
Dim prevPara As Object
|
||||
Dim nextParaFirstCharacter As String
|
||||
Dim stringContents As String
|
||||
firstLowercase = false
|
||||
|
||||
oSearch = ThisComponent.createSearchDescriptor()
|
||||
|
@ -202,7 +205,15 @@ sub convertIndesignPageBreaks
|
|||
oTextCursor.gotoRange(oFound,false)
|
||||
oTextCursor.gotoStartOfParagraph(false)
|
||||
oTextCursor.gotoEndOfParagraph(true)
|
||||
oTextCursor.goRight(1,true)
|
||||
testCurs = oTextCursor.Text.createTextCursorByRange(oTextCursor.End)
|
||||
testCurs.goRight(1,false)
|
||||
testCurs.gotoEndOfParagraph(true)
|
||||
'In case two page breaks go together
|
||||
stringContents = testCurs.String
|
||||
If stringContents <> pageBreakMarker Then
|
||||
oTextCursor.goRight(1,true)
|
||||
EndIf
|
||||
|
||||
oTextCursor.String = ""
|
||||
oTextCursor.BreakType = com.sun.star.style.BreakType.PAGE_BEFORE
|
||||
'Go to Start of new paragraph to shrink prev page if necessary
|
||||
|
@ -251,7 +262,7 @@ sub convertIndesignPageBreaks
|
|||
End If
|
||||
|
||||
If pageNumber - prevPageNumber < 2 Then
|
||||
' stretchPrevPage(prevPara)
|
||||
'stretchPrevPage(prevPara)
|
||||
EndIf
|
||||
|
||||
prevPageNumber = pageNumber
|
||||
|
@ -355,7 +366,7 @@ Sub stretchPrevPage()
|
|||
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)
|
||||
|
@ -467,15 +478,42 @@ Sub adjustLastLineCurPara()
|
|||
If success And adjustType = 2 Then
|
||||
oTextCursor.ParaLastLineAdjust = 2
|
||||
Else
|
||||
TextCursor.ParaIsHyphenation = hyph
|
||||
oTextCursor.ParaIsHyphenation = hyph
|
||||
EndIf
|
||||
End Sub
|
||||
|
||||
Sub balanceFootNotes()
|
||||
Dim allNotes As Object
|
||||
Dim aNote As Object
|
||||
Dim x As Long
|
||||
allNotes = ThisComponent.FootNotes
|
||||
For x = 0 to allNotes.Count -1
|
||||
aNote = allNotes.getByIndex(x)
|
||||
balanceFootNote(aNote)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Sub balanceFootNote(textElement As Object)
|
||||
Dim enum1Element As Object
|
||||
Dim enum1 As Object
|
||||
Dim oViewCursor As Object
|
||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||
enum1 = textElement.createEnumeration()
|
||||
While enum1.hasMoreElements
|
||||
enum1Element = enum1.nextElement
|
||||
If enum1Element.supportsService("com.sun.star.text.Paragraph") Then
|
||||
oViewCursor.goToRange(enum1Element,false)
|
||||
adjustLastLineCurPara()
|
||||
EndIf
|
||||
Wend
|
||||
End Sub
|
||||
|
||||
|
||||
Sub adjustLastLine(anchor As Object)
|
||||
anchor.ParaAdjust = 2
|
||||
anchor.ParaLastLineAdjust = 2
|
||||
balanceParaTail(anchor)
|
||||
Dim oViewCursor As Object
|
||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||
oViewCursor.goToRange(anchor,false)
|
||||
adjustLastLineCurPara()
|
||||
End Sub
|
||||
|
||||
Sub adjustFirstLine(anchor As Object)
|
||||
|
@ -559,7 +597,10 @@ Function balanceContentTail(oContent As Object) As Boolean
|
|||
'Tightened last line but it is still smaller than we need
|
||||
fallBackSuccess = tryExpandPrevLines(oContent, minLastLineLength)
|
||||
If Not fallBackSuccess Then
|
||||
oContent.CharKerning = initialCharKerning
|
||||
oContent.CharKerning = initialCharKerning
|
||||
oViewCursor.collapseToEnd()
|
||||
balanceContentTail = false
|
||||
Exit Function
|
||||
EndIf
|
||||
Exit Do
|
||||
EndIf
|
||||
|
@ -695,23 +736,12 @@ Function getContentLines(oContent As Object) As Variant
|
|||
getContentLines = paraLines
|
||||
End Function
|
||||
|
||||
|
||||
Sub decreaseCharKerning(oPara As Object)
|
||||
Dim initialCharKerning As Integer
|
||||
Dim textExcerpts As Object
|
||||
Dim textExcerpt As Object
|
||||
initialCharKerning = MIN_CHAR_KERNING
|
||||
If(IsEmpty(oPara.CharKerning)) Then
|
||||
textExcerpts = oPara.createEnumeration()
|
||||
While textExcerpts.hasMoreElements
|
||||
textExcerpt = textExcerpts.nextElement
|
||||
If Not IsEmpty(textExcerpt.CharKerning) Then
|
||||
If textExcerpt.CharKerning > initialCharKerning Then
|
||||
initialCharKerning = textExcerpt.CharKerning
|
||||
EndIf
|
||||
EndIf
|
||||
Wend
|
||||
Else
|
||||
initialCharKerning = MIN_CHAR_KERNING + 2
|
||||
If Not (IsEmpty(oPara.CharKerning)) Then
|
||||
initialCharKerning = oPara.CharKerning
|
||||
EndIf
|
||||
If (initialCharKerning >= MIN_CHAR_KERNING) Then
|
||||
|
@ -723,23 +753,12 @@ Sub increaseCharKerning(oPara As Object)
|
|||
Dim initialCharKerning As Integer
|
||||
Dim textExcerpts As Object
|
||||
Dim textExcerpt As Object
|
||||
initialCharKerning = MAX_CHAR_KERNING
|
||||
If(IsEmpty(oPara.CharKerning)) Then
|
||||
textExcerpts = oPara.createEnumeration()
|
||||
While textExcerpts.hasMoreElements
|
||||
textExcerpt = textExcerpts.nextElement
|
||||
If Not IsEmpty(textExcerpt.CharKerning) Then
|
||||
If textExcerpt.CharKerning < initialCharKerning Then
|
||||
initialCharKerning = textExcerpt.CharKerning
|
||||
EndIf
|
||||
EndIf
|
||||
Wend
|
||||
Else
|
||||
initialCharKerning = MAX_CHAR_KERNING - 2
|
||||
If Not (IsEmpty(oPara.CharKerning)) Then
|
||||
initialCharKerning = oPara.CharKerning
|
||||
EndIf
|
||||
oPara.CharKerning = initialCharKerning + 2
|
||||
End Sub
|
||||
|
||||
Function lastLineIsNotBalanced(lineLen As Integer,minLastLineLength As Integer) As Boolean
|
||||
lastLineIsNotBalanced = true
|
||||
If lineLen = 0 Then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue