diff --git a/Addons.xcu b/Addons.xcu index 3199689..7cf0ff5 100644 --- a/Addons.xcu +++ b/Addons.xcu @@ -3,6 +3,10 @@ + true + false + false + com.sun.star.text.TextDocument,com.sun.star.text.WebDocument @@ -84,6 +88,10 @@ + true + false + false + com.sun.star.text.TextDocument,com.sun.star.text.WebDocument @@ -161,6 +169,26 @@ _self + + + com.sun.star.text.TextDocument,com.sun.star.text.WebDocument + + + Балансировка хвоста + Équilibrer la dernière ligne + Balance the last line + Уравнотежите последњу линију + Uravnotežite posljednji redak + Uravnotežite posljednji redak + + + macro:///ePublishing.Archive.adjustLastLineCurPara + + + _self + + + @@ -246,6 +274,17 @@ + + + macro:///ePublishing.Archive.adjustLastLineCurPara + + + + %origin%/icons/tail.svg + + + + diff --git a/ePublishing/Archive.xba b/ePublishing/Archive.xba index 8fcb552..ba72536 100644 --- a/ePublishing/Archive.xba +++ b/ePublishing/Archive.xba @@ -1,6 +1,6 @@ -Sub archMark23 +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 diff --git a/icons/tail.svg b/icons/tail.svg new file mode 100644 index 0000000..14b2f1c --- /dev/null +++ b/icons/tail.svg @@ -0,0 +1,108 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + +