Improved archive macro

This commit is contained in:
Georgy Litvinov 2020-06-22 22:29:58 +02:00
parent 07624d0907
commit f8887020b9

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 archMark10
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Archive" script:language="StarBasic" script:moduleType="normal">Sub archMark11
End Sub
@ -124,34 +124,32 @@ End Function
sub convertIndesignPageBreaks
Dim description As String
Dim pageBreakMarker As String
pageBreakMarker = &quot;---XYXYX---&quot;
description = getTranslation(&quot;convertIndesignPageBreaksConfirmation&quot;)
If NOT confirm(description) Then
Exit Sub
EndIf
Dim document As Object
document = ThisComponent.CurrentController.Frame
Dim dispatcher As Object
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
turnOffTracking()
Dim oViewCursor As Object
oViewCursor = thisComponent.getCurrentController.getViewCursor
oViewCursor.jumpToFirstPage
Dim args(0) as new com.sun.star.beans.PropertyValue
rem Turn off tracking changes to prevent infinite
args(0).Name = &quot;TrackChanges&quot;
args(0).Value = false
dispatcher.executeDispatch(document, &quot;.uno:TrackChanges&quot;, &quot;&quot;, 0, args())
Dim oSearch As Object
Dim oTextCursor As Object
Dim firstLowercase As Boolean
Dim firstBreak As Boolean
firstBreak = true
Dim charNum As Long
Dim character As String
Dim oFound As Object
Dim pageNumber As Integer
Dim prevPageNumber As Integer
firstLowercase = false
oSearch = ThisComponent.createSearchDescriptor()
oSearch.SearchString = &quot;---XYXYX---&quot;
oSearch.SearchString = pageBreakMarker
oSearch.SearchRegularExpression=True
oSearch.searchAll=True
oFound = ThisComponent.findFirst(oSearch)
@ -163,7 +161,19 @@ sub convertIndesignPageBreaks
oTextCursor.goRight(1,true)
oTextCursor.String = &quot;&quot;
oTextCursor.BreakType = com.sun.star.style.BreakType.PAGE_BEFORE
oViewCursor.goToRange(oTextCursor.End,false)
oViewCursor.goLeft(1,false)
Wait 100
pageNumber = getPageNumber(oTextCursor.Text.createTextCursorByRange(oTextCursor.End)
If firstBreak Then
firstBreak = false
prevPageNumber = pageNumber
EndIf
If pageNumber - prevPageNumber &gt; 1 Then
shrinkPageContent
Wait 100
pageNumber = getPageNumber(oTextCursor.Text.createTextCursorByRange(oTextCursor.End)
EndIf
&apos;check first character
oTextCursor.goRight(1,true)
If (isLowerCase(oTextCursor.getString())) Then
@ -174,10 +184,12 @@ sub convertIndesignPageBreaks
oTextCursor.goLeft(2,false)
oTextCursor.goLeft(1,true)
character = oTextCursor.getString()
If (character = &quot; &quot;) Then
oTextCursor.String=&quot;&quot;
&apos; oTextCursor.String=&quot;&quot;
&apos;last paragraph
adjustLastLine(oTextCursor)
adjustFirstLine(oTextCursor)
EndIf
If (isLowerCase(character)) Then
If firstLowercase Then
@ -188,8 +200,10 @@ sub convertIndesignPageBreaks
adjustFirstLine(oTextCursor)
EndIf
End If
prevPageNumber = pageNumber
oFound = ThisComponent.findNext(oFound.End, oSearch)
Loop
setUniqPageStyles
MsgBox getTranslation(&quot;convertIndesignPageBreaksFinish&quot;)
end Sub
@ -259,7 +273,7 @@ Sub balancePara(targetPara As Object)
Do
&apos;Not first iteration
If minLastLineLength &lt;&gt; 0 Then
If oPara.CharKerning &lt; 30 Then
If oPara.CharKerning &lt; 50 Then
If(IsEmpty(oPara.CharKerning)) Then
oPara.CharKerning = 0
Else