fix: refactoring and fixes for working with archive
This commit is contained in:
parent
82c63c82ca
commit
fe1fc573eb
3 changed files with 72 additions and 60 deletions
40
Addons.xcu
40
Addons.xcu
|
@ -83,6 +83,26 @@
|
||||||
<value>_self</value>
|
<value>_self</value>
|
||||||
</prop>
|
</prop>
|
||||||
</node>
|
</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>
|
||||||
</node>
|
</node>
|
||||||
|
@ -169,26 +189,6 @@
|
||||||
<value>_self</value>
|
<value>_self</value>
|
||||||
</prop>
|
</prop>
|
||||||
</node>
|
</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>
|
||||||
</node>
|
</node>
|
||||||
|
|
|
@ -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 archMark25
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Archive" script:language="StarBasic" script:moduleType="normal">Sub archMark26
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
@ -274,14 +274,16 @@ end Sub
|
||||||
|
|
||||||
Sub configureHeadings
|
Sub configureHeadings
|
||||||
configureArchiveHeading1
|
configureArchiveHeading1
|
||||||
configureOtherArchiveHeadings
|
configureArchiveHeadings()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Sub configureArchiveHeading1
|
Sub configureArchiveHeading1
|
||||||
Dim outline1() As Object
|
Dim outline1() As Object
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
Dim oSavePosition As Object
|
Dim oSavePosition As Object
|
||||||
|
Dim initPosition As Object
|
||||||
|
Dim initPageNum As Integer
|
||||||
|
fixViewCursor()
|
||||||
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
||||||
oSavePosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
oSavePosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
outline1 = getHeadingWithLevel(1)
|
outline1 = getHeadingWithLevel(1)
|
||||||
|
@ -289,33 +291,35 @@ Sub configureArchiveHeading1
|
||||||
Dim pageNumberCursor As Object
|
Dim pageNumberCursor As Object
|
||||||
Dim i As Integer
|
Dim i As Integer
|
||||||
Dim j As Integer
|
Dim j As Integer
|
||||||
Dim initialPageCount As Integer
|
|
||||||
initialPageCount = ThisComponent.currentController.pageCount
|
|
||||||
For i = LBound(outline1) To UBound(outline1)
|
For i = LBound(outline1) To UBound(outline1)
|
||||||
oViewCursor.goToRange(outline1(i), false)
|
oViewCursor.goToRange(outline1(i), false)
|
||||||
oViewCursor.jumpToEndOfPage()
|
oViewCursor.jumpToEndOfPage()
|
||||||
pageNumberCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
initPosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
pageNumberCursor.goToStartOfWord(false)
|
initPageNum = oViewcursor.getPage()
|
||||||
startViewPageNum = getPageNumber(pageNumberCursor)
|
|
||||||
|
|
||||||
Do While startViewPageNum = getPageNumber(pageNumberCursor) And initialPageCount = ThisComponent.currentController.pageCount
|
Do While Not isContentPageChanged(initPosition, initPageNum) AND outline1(i).ParaBottomMargin < 10000
|
||||||
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin + 100
|
outline1(i).ParaBottomMargin = outline1(i).ParaBottomMargin + 100
|
||||||
|
Loop
|
||||||
|
Do While isContentPageChanged(initPosition, initPageNum)
|
||||||
|
If outline1(i).ParaBottomMargin < 0 Then
|
||||||
|
Exit Do
|
||||||
|
EndIf
|
||||||
|
outline1(i).ParaBottomMargin = outline1(i).ParaBottomMargin - 100
|
||||||
Loop
|
Loop
|
||||||
If outline1(i).ParaTopMargin >= 100 Then
|
|
||||||
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin - 100
|
|
||||||
EndIf
|
|
||||||
Next i
|
Next i
|
||||||
oViewCursor.goToRange(oSavePosition,false)
|
oViewCursor.goToRange(oSavePosition,false)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub configureOtherArchiveHeadings
|
Sub configureArchiveHeadings()
|
||||||
Dim outline1() As Object
|
Dim outline1() As Object
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
Dim oSavePosition As Object
|
Dim initPosition As Object
|
||||||
|
Dim initPageNum As Integer
|
||||||
|
Dim savePosition As Object
|
||||||
|
fixViewCursor()
|
||||||
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
||||||
oSavePosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
savePosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
|
||||||
Dim startViewPageNum As Integer
|
|
||||||
Dim pageNumberCursor As Object
|
Dim pageNumberCursor As Object
|
||||||
Dim i As Integer
|
Dim i As Integer
|
||||||
Dim j As Integer
|
Dim j As Integer
|
||||||
|
@ -327,23 +331,25 @@ Sub configureOtherArchiveHeadings
|
||||||
If outline1(i).BreakType <> 4 Then
|
If outline1(i).BreakType <> 4 Then
|
||||||
oViewCursor.goToRange(outline1(i), false)
|
oViewCursor.goToRange(outline1(i), false)
|
||||||
oViewCursor.jumpToEndOfPage()
|
oViewCursor.jumpToEndOfPage()
|
||||||
pageNumberCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
initPosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
pageNumberCursor.goToStartOfWord(false)
|
initPageNum = oViewcursor.getPage()
|
||||||
startViewPageNum = getPageNumber(pageNumberCursor)
|
|
||||||
|
|
||||||
Do While startViewPageNum = getPageNumber(pageNumberCursor) And initialPageCount = ThisComponent.currentController.pageCount
|
Do While Not isContentPageChanged(initPosition, initPageNum)
|
||||||
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin + 100
|
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin + 100
|
||||||
If (outline1(i).ParaTopMargin > outline1(i).ParaBottomMargin) Then
|
If (outline1(i).ParaTopMargin > outline1(i).ParaBottomMargin) Then
|
||||||
Exit Do
|
Exit Do
|
||||||
EndIf
|
EndIf
|
||||||
Loop
|
Loop
|
||||||
If outline1(i).ParaTopMargin >= 100 Then
|
Do While isContentPageChanged(initPosition, initPageNum)
|
||||||
|
If outline1(i).ParaBottomMargin < 0 Then
|
||||||
|
Exit Do
|
||||||
|
EndIf
|
||||||
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin - 100
|
outline1(i).ParaTopMargin = outline1(i).ParaTopMargin - 100
|
||||||
EndIf
|
Loop
|
||||||
EndIf
|
EndIf
|
||||||
Next i
|
Next i
|
||||||
Next j
|
Next j
|
||||||
oViewCursor.goToRange(oSavePosition,false)
|
oViewCursor.goToRange(savePosition,false)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,10 +455,6 @@ Sub stretchPrevPage()
|
||||||
Next i
|
Next i
|
||||||
Exit Sub
|
Exit Sub
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
oViewCursor.goToRange(oSavePosition,false)
|
oViewCursor.goToRange(oSavePosition,false)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
@ -463,6 +465,7 @@ Sub adjustLastLineCurPara()
|
||||||
Dim success As Boolean
|
Dim success As Boolean
|
||||||
Dim adjustType As Integer
|
Dim adjustType As Integer
|
||||||
Dim hyph As Boolean
|
Dim hyph As Boolean
|
||||||
|
fixViewCursor()
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
oTextCursor = oViewCursor.Text.CreateTextCursorByRange(oViewCursor)
|
oTextCursor = oViewCursor.Text.CreateTextCursorByRange(oViewCursor)
|
||||||
paraEnd = getParaEnd(oTextCursor)
|
paraEnd = getParaEnd(oTextCursor)
|
||||||
|
|
|
@ -1141,16 +1141,11 @@ Sub configureCursorPositionForContentShrink()
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
Dim oTextCursor As Object
|
Dim oTextCursor As Object
|
||||||
Dim curSelection As Object
|
Dim curSelection As Object
|
||||||
Dim selectionTextRange
|
Dim selectionTextRange As Object
|
||||||
Dim nextChar As String
|
Dim nextChar As String
|
||||||
Dim prefChar As String
|
Dim prefChar As String
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
curSelection = ThisComponent.getCurrentSelection()
|
fixViewCursor()
|
||||||
If Not curSelection.supportsService("com.sun.star.text.TextRanges") Then
|
|
||||||
selectionTextRange = curSelection.Anchor
|
|
||||||
oViewCursor.JumpToFirstPage(false)
|
|
||||||
oViewCursor.goToRange(selectionTextRange,false)
|
|
||||||
EndIf
|
|
||||||
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
'At start of Para
|
'At start of Para
|
||||||
oTextCursor.collapseToEnd()
|
oTextCursor.collapseToEnd()
|
||||||
|
@ -1160,14 +1155,28 @@ Sub configureCursorPositionForContentShrink()
|
||||||
oViewCursor.goToRange(oTextCursor,false)
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Function isShrinkPageSucceded(initPosition As Object,initPageNum As String) As Boolean
|
Sub fixViewCursor()
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim curSelection As Object
|
||||||
|
Dim selectionTextRange As Object
|
||||||
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
|
curSelection = ThisComponent.getCurrentSelection()
|
||||||
|
If Not curSelection.supportsService("com.sun.star.text.TextRanges") Then
|
||||||
|
selectionTextRange = curSelection.Anchor
|
||||||
|
oViewCursor.JumpToFirstPage(false)
|
||||||
|
oViewCursor.goToRange(selectionTextRange,false)
|
||||||
|
EndIf
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Function isContentPageChanged(initPosition As Object,initPageNum As String) As Boolean
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
Dim oTextCursor As Object
|
Dim oTextCursor As Object
|
||||||
isShrinkPageSucceded = false
|
isShrinkPageSucceded = false
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
oViewCursor.goToRange(initPosition,false)
|
oViewCursor.goToRange(initPosition,false)
|
||||||
If (oViewCursor.getPage <> initPageNum) Then
|
If (oViewCursor.getPage <> initPageNum) Then
|
||||||
isShrinkPageSucceded = true
|
isContentPageChanged = true
|
||||||
EndIf
|
EndIf
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
@ -1295,7 +1304,7 @@ Function shrinkPageContent() As Boolean
|
||||||
targetContent = selectContentToShrink(initPosition,startPosition)
|
targetContent = selectContentToShrink(initPosition,startPosition)
|
||||||
For i = LBound(targetContent) To Ubound(targetContent)
|
For i = LBound(targetContent) To Ubound(targetContent)
|
||||||
shrinkContentSpacing(targetContent(i))
|
shrinkContentSpacing(targetContent(i))
|
||||||
If isShrinkPageSucceded(initPosition, initPageNum) Then
|
If isContentPageChanged(initPosition, initPageNum) Then
|
||||||
Exit Function
|
Exit Function
|
||||||
EndIf
|
EndIf
|
||||||
Next i
|
Next i
|
||||||
|
@ -1309,7 +1318,7 @@ Function shrinkPageContent() As Boolean
|
||||||
If shrinkContentWithKerning(targetContent(i)) Then
|
If shrinkContentWithKerning(targetContent(i)) Then
|
||||||
balanceContentTail(targetContent(i))
|
balanceContentTail(targetContent(i))
|
||||||
EndIf
|
EndIf
|
||||||
If isShrinkPageSucceded(initPosition, initPageNum) Then
|
If isContentPageChanged(initPosition, initPageNum) Then
|
||||||
Exit Function
|
Exit Function
|
||||||
EndIf
|
EndIf
|
||||||
Next i
|
Next i
|
||||||
|
@ -1317,7 +1326,7 @@ Function shrinkPageContent() As Boolean
|
||||||
For j = 1 To roundsLineHeight
|
For j = 1 To roundsLineHeight
|
||||||
For i = LBound(targetContent) To Ubound(targetContent)
|
For i = LBound(targetContent) To Ubound(targetContent)
|
||||||
decreaseIntervalHeight(targetContent(i))
|
decreaseIntervalHeight(targetContent(i))
|
||||||
If isShrinkPageSucceded(initPosition, initPageNum) Then
|
If isContentPageChanged(initPosition, initPageNum) Then
|
||||||
Exit Function
|
Exit Function
|
||||||
EndIf
|
EndIf
|
||||||
Next i
|
Next i
|
||||||
|
|
Loading…
Add table
Reference in a new issue