feat: added icon for para tail balance
This commit is contained in:
parent
f39f25b053
commit
be702bc60f
3 changed files with 182 additions and 16 deletions
|
@ -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 archMark23
|
||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Archive" script:language="StarBasic" script:moduleType="normal">Sub archMark24
|
||||
|
||||
End Sub
|
||||
|
||||
|
@ -449,16 +449,26 @@ Sub adjustLastLineCurPara()
|
|||
Dim oViewCursor As Object
|
||||
Dim oTextCursor As Object
|
||||
Dim paraEnd As Object
|
||||
Dim success As Boolean
|
||||
Dim adjustType As Integer
|
||||
Dim hyph As Boolean
|
||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||
oTextCursor = oViewCursor.Text.CreateTextCursorByRange(oViewCursor)
|
||||
paraEnd = getParaEnd(oTextCursor)
|
||||
oTextCursor.goToRange(paraEnd,false)
|
||||
oTextCursor.goLeft(1,true)
|
||||
If (oTextCursor.String = " ") Then
|
||||
oTextCursor.String = ""
|
||||
oTextCursor.String = ""
|
||||
EndIf
|
||||
adjustType = oTextCursor.ParaAdjust
|
||||
hyph = oTextCursor.ParaIsHyphenation
|
||||
oTextCursor.ParaIsHyphenation = true
|
||||
adjustLastLine(oTextCursor.Start)
|
||||
success = balanceParaTail(oTextCursor.Start)
|
||||
If success And adjustType = 2 Then
|
||||
oTextCursor.ParaLastLineAdjust = 2
|
||||
Else
|
||||
TextCursor.ParaIsHyphenation = hyph
|
||||
EndIf
|
||||
End Sub
|
||||
|
||||
|
||||
|
@ -489,7 +499,7 @@ End Function
|
|||
|
||||
|
||||
|
||||
Sub balanceParaTail(targetPara As Object)
|
||||
Function balanceParaTail(targetPara As Object) As Boolean
|
||||
Dim oViewCursor As Object
|
||||
Dim oTextCursor As Object
|
||||
Dim oContent As Object
|
||||
|
@ -502,11 +512,12 @@ Sub balanceParaTail(targetPara As Object)
|
|||
oContentStart = getParaStart(oTextCursor)
|
||||
oContentEnd = getParaEnd(oTextCursor)
|
||||
oContent = getParaSelected(oContentStart,oContentEnd)
|
||||
balanceContentTail(oContent)
|
||||
End Sub
|
||||
balanceParaTail = balanceContentTail(oContent)
|
||||
End Function
|
||||
|
||||
Sub balanceContentTail(oContent As Object)
|
||||
Function balanceContentTail(oContent As Object) As Boolean
|
||||
' Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
||||
balanceContentTail = false
|
||||
Dim oViewCursor As Object
|
||||
Dim paraLen As Integer
|
||||
Dim lineCount As Integer
|
||||
|
@ -536,7 +547,7 @@ Sub balanceContentTail(oContent As Object)
|
|||
End If
|
||||
|
||||
If initialLineCount < 2 Then
|
||||
Exit sub
|
||||
Exit Function
|
||||
EndIf
|
||||
|
||||
Do While lastLineIsNotBalanced(lineLen, minLastLineLength)
|
||||
|
@ -554,7 +565,8 @@ Sub balanceContentTail(oContent As Object)
|
|||
EndIf
|
||||
Loop
|
||||
oViewCursor.collapseToEnd()
|
||||
End Sub
|
||||
balanceContentTail = true
|
||||
End Function
|
||||
|
||||
Function shrinkContentWithKerning(oContent As Object) As Boolean
|
||||
' Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
||||
|
@ -771,21 +783,28 @@ Function calculateMedianParaLen(oPara As Object) As Integer
|
|||
calculateMedianParaLen = 0
|
||||
lineCount = 0
|
||||
lineLen = 0
|
||||
If (Len (oPara.String) = 0) Then
|
||||
Exit Function
|
||||
EndIf
|
||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||
oViewCursor.goToRange(oPara, false)
|
||||
oViewCursor.collapseToStart()
|
||||
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||
oParaStart = getParaStart(oTextCursor)
|
||||
oViewCursor.goToRange(oParaStart,false)
|
||||
'Select first line
|
||||
oViewCursor.gotoEndOfLine(true)
|
||||
While NOT oTextCursor.isEndOfParagraph()
|
||||
lineLen = Len(oViewCursor.getString())
|
||||
linesLen = linesLen + lineLen
|
||||
lineCount = lineCount + 1
|
||||
oViewCursor.collapseToEnd()
|
||||
oViewCursor.gotoEndOfLine(true)
|
||||
oTextCursor.goToRange(oViewCursor,false)
|
||||
lineLen = Len(oViewCursor.getString())
|
||||
If lineLen > 0 Then
|
||||
linesLen = linesLen + lineLen
|
||||
lineCount = lineCount + 1
|
||||
oViewCursor.collapseToEnd()
|
||||
oTextCursor.goToRange(oViewCursor,false)
|
||||
Else
|
||||
oTextCursor.goToRange(oViewCursor,false)
|
||||
oTextCursor.goRight(1,false)
|
||||
oViewCursor.goToRange(oTextCursor,false)
|
||||
EndIf
|
||||
Wend
|
||||
If lineCount > 0 Then
|
||||
calculateMedianParaLen = linesLen / lineCount
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue