feat: added icon for para tail balance

This commit is contained in:
Georgy Litvinov 2021-08-27 13:01:47 +02:00
parent f39f25b053
commit be702bc60f
3 changed files with 182 additions and 16 deletions

View file

@ -3,6 +3,10 @@
<node oor:name="AddonUI">
<node oor:name="OfficeToolBar">
<node oor:name="pro.litvinovg.ePublishing.panel" oor:op="replace">
<prop oor:name="Docked" oor:op="fuse"><value>true</value></prop>
<prop oor:name="HideFromToolbarMenu" oor:op="fuse"><value>false</value></prop>
<prop oor:name="Locked" oor:op="fuse"><value>false</value></prop>
<node oor:name="buttonShrinkText" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.WebDocument</value>
@ -84,6 +88,10 @@
</node>
<node oor:name="OfficeToolBar">
<node oor:name="pro.litvinovg.ePublishing.makeuppanel" oor:op="replace">
<prop oor:name="Docked" oor:op="fuse"><value>true</value></prop>
<prop oor:name="HideFromToolbarMenu" oor:op="fuse"><value>false</value></prop>
<prop oor:name="Locked" oor:op="fuse"><value>false</value></prop>
<node oor:name="percentPlus" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.WebDocument</value>
@ -161,6 +169,26 @@
<value>_self</value>
</prop>
</node>
<node oor:name="balanceTail" 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="ru">Балансировка хвоста</value>
<value xml:lang="fr">Équilibrer la dernière ligne</value>
<value xml:lang="en">Balance the last line </value>
<value xml:lang="sr">Уравнотежите последњу линију</value>
<value xml:lang="hr">Uravnotežite posljednji redak</value>
<value xml:lang="bs">Uravnotežite posljednji redak</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///ePublishing.Archive.adjustLastLineCurPara</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
</node>
</node>
</node>
@ -246,6 +274,17 @@
</prop>
</node>
</node>
<node oor:name="balance-tail" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///ePublishing.Archive.adjustLastLineCurPara</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageBigURL">
<value>%origin%/icons/tail.svg</value>
</prop>
</node>
</node>

View file

@ -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 = &quot; &quot;) Then
oTextCursor.String = &quot;&quot;
oTextCursor.String = &quot;&quot;
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
&apos; Globalscope.BasicLibraries.LoadLibrary( &quot;MRILib&quot; )
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 &lt; 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
&apos; Globalscope.BasicLibraries.LoadLibrary( &quot;MRILib&quot; )
@ -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)
&apos;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 &gt; 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 &gt; 0 Then
calculateMedianParaLen = linesLen / lineCount

108
icons/tail.svg Normal file
View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
sodipodi:docname="hvost.svg"
inkscape:version="1.0 (4035a4f, 2020-05-01)"
id="svg2650"
version="1.1"
viewBox="0 0 67.73333 67.73333"
height="67.73333mm"
width="67.73333mm">
<defs
id="defs2644" />
<sodipodi:namedview
inkscape:window-maximized="1"
inkscape:window-y="25"
inkscape:window-x="0"
inkscape:window-height="992"
inkscape:window-width="1920"
showgrid="false"
inkscape:document-rotation="0"
inkscape:current-layer="layer1"
inkscape:document-units="mm"
inkscape:cy="161.53655"
inkscape:cx="48.279563"
inkscape:zoom="0.98994949"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
borderopacity="1.0"
bordercolor="#666666"
pagecolor="#ffffff"
id="base" />
<metadata
id="metadata2647">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(-94.593422,-56.778362)"
id="layer1"
inkscape:groupmode="layer"
inkscape:label="Layer 1">
<rect
inkscape:export-ydpi="96.000023"
inkscape:export-xdpi="96.000023"
style="opacity:1;fill:#484848;fill-opacity:1;stroke:none;stroke-width:2.02445;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill;stop-color:#000000;stop-opacity:1"
id="rect851-8-3-8-3-37-8-5-8-6-0-0-6"
width="18.675617"
height="10.240829"
x="96.890099"
y="108.6032" />
<path
d="m 148.55629,103.93948 11.61928,9.55377 -11.61928,9.55393 -0.0327,-6.34998 h -7.8785 v -6.4078 h 7.87849 z"
id="path966-9-6-0-2-0-0-9-4-7-4-8-3"
inkscape:connector-curvature="0"
style="opacity:1;fill:#e60002;fill-opacity:1;stroke-width:3.42818;stop-opacity:1"
sodipodi:nodetypes="cccccccc"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" />
<path
inkscape:export-ydpi="96"
inkscape:export-xdpi="96"
sodipodi:nodetypes="cccccccc"
style="opacity:1;fill:#e60002;fill-opacity:1;stroke-width:3.42818;stop-opacity:1"
inkscape:connector-curvature="0"
id="path966-9-6-0-2-0-0-9-4-7-4-8-3-8"
d="m 128.61418,123.04712 -11.61928,-9.55377 11.61928,-9.55392 0.0327,6.34997 h 7.8785 v 6.4078 h -7.87849 z" />
<rect
y="91.483078"
x="96.890099"
height="10.240829"
width="62.825058"
id="rect851-8-3-8-3-37-8-5-8-6-0-0-6-2"
style="opacity:1;fill:#484848;fill-opacity:1;stroke:none;stroke-width:3.71308;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill;stop-color:#000000;stop-opacity:1"
inkscape:export-xdpi="96.000023"
inkscape:export-ydpi="96.000023" />
<rect
inkscape:export-ydpi="96.000023"
inkscape:export-xdpi="96.000023"
style="opacity:1;fill:#484848;fill-opacity:1;stroke:none;stroke-width:3.71308;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill;stop-color:#000000;stop-opacity:1"
id="rect851-8-3-8-3-37-8-5-8-6-0-0-6-2-8"
width="62.825058"
height="10.240829"
x="96.890099"
y="74.892128" />
<rect
y="59.359539"
x="96.890099"
height="10.240829"
width="62.825058"
id="rect851-8-3-8-3-37-8-5-8-6-0-0-6-2-8-3"
style="opacity:1;fill:#484848;fill-opacity:1;stroke:none;stroke-width:3.71308;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill;stop-color:#000000;stop-opacity:1"
inkscape:export-xdpi="96.000023"
inkscape:export-ydpi="96.000023" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB