Improved archive macro
This commit is contained in:
parent
07624d0907
commit
f8887020b9
1 changed files with 31 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
<!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
|
End Sub
|
||||||
|
|
||||||
|
@ -124,34 +124,32 @@ End Function
|
||||||
|
|
||||||
sub convertIndesignPageBreaks
|
sub convertIndesignPageBreaks
|
||||||
Dim description As String
|
Dim description As String
|
||||||
|
Dim pageBreakMarker As String
|
||||||
|
pageBreakMarker = "---XYXYX---"
|
||||||
description = getTranslation("convertIndesignPageBreaksConfirmation")
|
description = getTranslation("convertIndesignPageBreaksConfirmation")
|
||||||
If NOT confirm(description) Then
|
If NOT confirm(description) Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
EndIf
|
EndIf
|
||||||
Dim document As Object
|
turnOffTracking()
|
||||||
document = ThisComponent.CurrentController.Frame
|
|
||||||
Dim dispatcher As Object
|
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
||||||
oViewCursor.jumpToFirstPage
|
oViewCursor.jumpToFirstPage
|
||||||
Dim args(0) as new com.sun.star.beans.PropertyValue
|
|
||||||
|
|
||||||
rem Turn off tracking changes to prevent infinite
|
|
||||||
args(0).Name = "TrackChanges"
|
|
||||||
args(0).Value = false
|
|
||||||
dispatcher.executeDispatch(document, ".uno:TrackChanges", "", 0, args())
|
|
||||||
|
|
||||||
Dim oSearch As Object
|
Dim oSearch As Object
|
||||||
Dim oTextCursor As Object
|
Dim oTextCursor As Object
|
||||||
Dim firstLowercase As Boolean
|
Dim firstLowercase As Boolean
|
||||||
|
Dim firstBreak As Boolean
|
||||||
|
firstBreak = true
|
||||||
Dim charNum As Long
|
Dim charNum As Long
|
||||||
Dim character As String
|
Dim character As String
|
||||||
Dim oFound As Object
|
Dim oFound As Object
|
||||||
|
Dim pageNumber As Integer
|
||||||
|
Dim prevPageNumber As Integer
|
||||||
firstLowercase = false
|
firstLowercase = false
|
||||||
|
|
||||||
oSearch = ThisComponent.createSearchDescriptor()
|
oSearch = ThisComponent.createSearchDescriptor()
|
||||||
oSearch.SearchString = "---XYXYX---"
|
oSearch.SearchString = pageBreakMarker
|
||||||
oSearch.SearchRegularExpression=True
|
oSearch.SearchRegularExpression=True
|
||||||
oSearch.searchAll=True
|
oSearch.searchAll=True
|
||||||
oFound = ThisComponent.findFirst(oSearch)
|
oFound = ThisComponent.findFirst(oSearch)
|
||||||
|
@ -163,7 +161,19 @@ sub convertIndesignPageBreaks
|
||||||
oTextCursor.goRight(1,true)
|
oTextCursor.goRight(1,true)
|
||||||
oTextCursor.String = ""
|
oTextCursor.String = ""
|
||||||
oTextCursor.BreakType = com.sun.star.style.BreakType.PAGE_BEFORE
|
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 > 1 Then
|
||||||
|
shrinkPageContent
|
||||||
|
Wait 100
|
||||||
|
pageNumber = getPageNumber(oTextCursor.Text.createTextCursorByRange(oTextCursor.End)
|
||||||
|
EndIf
|
||||||
'check first character
|
'check first character
|
||||||
oTextCursor.goRight(1,true)
|
oTextCursor.goRight(1,true)
|
||||||
If (isLowerCase(oTextCursor.getString())) Then
|
If (isLowerCase(oTextCursor.getString())) Then
|
||||||
|
@ -174,10 +184,12 @@ sub convertIndesignPageBreaks
|
||||||
oTextCursor.goLeft(2,false)
|
oTextCursor.goLeft(2,false)
|
||||||
oTextCursor.goLeft(1,true)
|
oTextCursor.goLeft(1,true)
|
||||||
character = oTextCursor.getString()
|
character = oTextCursor.getString()
|
||||||
|
|
||||||
If (character = " ") Then
|
If (character = " ") Then
|
||||||
oTextCursor.String=""
|
' oTextCursor.String=""
|
||||||
|
'last paragraph
|
||||||
adjustLastLine(oTextCursor)
|
adjustLastLine(oTextCursor)
|
||||||
adjustFirstLine(oTextCursor)
|
|
||||||
EndIf
|
EndIf
|
||||||
If (isLowerCase(character)) Then
|
If (isLowerCase(character)) Then
|
||||||
If firstLowercase Then
|
If firstLowercase Then
|
||||||
|
@ -188,8 +200,10 @@ sub convertIndesignPageBreaks
|
||||||
adjustFirstLine(oTextCursor)
|
adjustFirstLine(oTextCursor)
|
||||||
EndIf
|
EndIf
|
||||||
End If
|
End If
|
||||||
|
prevPageNumber = pageNumber
|
||||||
oFound = ThisComponent.findNext(oFound.End, oSearch)
|
oFound = ThisComponent.findNext(oFound.End, oSearch)
|
||||||
Loop
|
Loop
|
||||||
|
setUniqPageStyles
|
||||||
MsgBox getTranslation("convertIndesignPageBreaksFinish")
|
MsgBox getTranslation("convertIndesignPageBreaksFinish")
|
||||||
end Sub
|
end Sub
|
||||||
|
|
||||||
|
@ -259,7 +273,7 @@ Sub balancePara(targetPara As Object)
|
||||||
Do
|
Do
|
||||||
'Not first iteration
|
'Not first iteration
|
||||||
If minLastLineLength <> 0 Then
|
If minLastLineLength <> 0 Then
|
||||||
If oPara.CharKerning < 30 Then
|
If oPara.CharKerning < 50 Then
|
||||||
If(IsEmpty(oPara.CharKerning)) Then
|
If(IsEmpty(oPara.CharKerning)) Then
|
||||||
oPara.CharKerning = 0
|
oPara.CharKerning = 0
|
||||||
Else
|
Else
|
||||||
|
|
Loading…
Add table
Reference in a new issue