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"?>
|
||||
<!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 = "---XYXYX---"
|
||||
description = getTranslation("convertIndesignPageBreaksConfirmation")
|
||||
If NOT confirm(description) Then
|
||||
Exit Sub
|
||||
EndIf
|
||||
Dim document As Object
|
||||
document = ThisComponent.CurrentController.Frame
|
||||
Dim dispatcher As Object
|
||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||
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 = "TrackChanges"
|
||||
args(0).Value = false
|
||||
dispatcher.executeDispatch(document, ".uno:TrackChanges", "", 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 = "---XYXYX---"
|
||||
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 = ""
|
||||
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
|
||||
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 = " ") Then
|
||||
oTextCursor.String=""
|
||||
' oTextCursor.String=""
|
||||
'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("convertIndesignPageBreaksFinish")
|
||||
end Sub
|
||||
|
||||
|
@ -259,7 +273,7 @@ Sub balancePara(targetPara As Object)
|
|||
Do
|
||||
'Not first iteration
|
||||
If minLastLineLength <> 0 Then
|
||||
If oPara.CharKerning < 30 Then
|
||||
If oPara.CharKerning < 50 Then
|
||||
If(IsEmpty(oPara.CharKerning)) Then
|
||||
oPara.CharKerning = 0
|
||||
Else
|
||||
|
|
Loading…
Add table
Reference in a new issue