chore: cleaning a bit
This commit is contained in:
parent
48ebe71c8e
commit
f58b4f58de
3 changed files with 297 additions and 206 deletions
|
@ -434,7 +434,5 @@ Private Function confirm(description)
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Sub Macro1
|
|
||||||
|
|
||||||
End Sub
|
|
||||||
</script:module>
|
</script:module>
|
|
@ -263,7 +263,7 @@ Sub getFNAreaStart
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Function changeCharWidth(delta) As Boolean
|
Function changeCharWidth(delta As Integer) As Boolean
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
Dim oTextCursor As Object
|
Dim oTextCursor As Object
|
||||||
Dim charScale As Integer
|
Dim charScale As Integer
|
||||||
|
@ -277,7 +277,7 @@ Function changeCharWidth(delta) As Boolean
|
||||||
oViewCursor.charScaleWidth = charScale + delta
|
oViewCursor.charScaleWidth = charScale + delta
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Function changeKern(delta) As Boolean
|
Function changeKern(delta As Integer) As Boolean
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
Dim oTextCursor As Object
|
Dim oTextCursor As Object
|
||||||
Dim kerning As Integer
|
Dim kerning As Integer
|
||||||
|
|
|
@ -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="journals" script:language="StarBasic">Private sub journalsMark31
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="journals" script:language="StarBasic">Private sub journalsMark33
|
||||||
End sub
|
End sub
|
||||||
|
|
||||||
Dim templateName As String
|
Dim templateName As String
|
||||||
|
@ -1132,36 +1132,25 @@ sub backspace
|
||||||
dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array())
|
dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array())
|
||||||
end Sub
|
end Sub
|
||||||
|
|
||||||
Sub shrinkPageContent
|
Function shrinkPageContent() As Boolean
|
||||||
Dim oViewCursor As Object 'View cursor
|
Dim oViewCursor As Object 'View cursor
|
||||||
Dim oTextCursor As Object 'Text cursor
|
Dim oTextCursor As Object 'Text cursor
|
||||||
Dim oViewCurInitPosition As Object
|
Dim oViewCurInitPosition As Object
|
||||||
Dim oSaveEndSelection As Object 'Text cursor
|
Dim oSaveEndSelection As Object 'Text cursor
|
||||||
Dim oEnum As Variant'Cursor enumeration
|
Dim oEnum As Variant'Cursor enumeration
|
||||||
Dim oPar As Object'Current paragraph
|
Dim oPar As Object'Current paragraph
|
||||||
Dim sTextContent As String 'Service name for text content.
|
|
||||||
Dim scaleWidthShrinkValue As Integer
|
|
||||||
Dim scaleCharHeight As Integer
|
Dim scaleCharHeight As Integer
|
||||||
Dim scaleIntervalHeight As Integer
|
Dim scaleIntervalHeight As Integer
|
||||||
Dim kernShrinkValue As Integer
|
Dim kernShrinkValue As Integer
|
||||||
Dim startOfPara As Boolean
|
Dim startOfPara As Boolean
|
||||||
'saveCurrentVersion
|
|
||||||
kernShrinkValue = 8
|
kernShrinkValue = 8
|
||||||
scaleWidthShrinkValue = 7
|
|
||||||
scaleCharHeight = 2
|
scaleCharHeight = 2
|
||||||
scaleIntervalHeight = 3
|
scaleIntervalHeight = 3
|
||||||
sTextContent = "com.sun.star.text.TextContent"
|
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
oViewCurInitPosition = oViewcursor.Text.createTextCursorByRange(oViewCursor)
|
oViewCurInitPosition = oViewcursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
'Check if we are at start of paragraph go to the end of previous paragraph
|
|
||||||
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
If oTextCursor.isStartOfParagraph() Then
|
|
||||||
oTextCursor.goLeft(1,false)
|
|
||||||
If Len(oTextCursor.String) <> 1 Then
|
|
||||||
oTextCursor.goRight(1,false)
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'Move right to select left and right characters and save position to the right
|
'Move right to select left and right characters and save position to the right
|
||||||
oTextCursor.goRight(1,false)
|
oTextCursor.goRight(1,false)
|
||||||
oSaveEndSelection = oTextCursor.Text.createTextCursorByRange(oTextCursor)
|
oSaveEndSelection = oTextCursor.Text.createTextCursorByRange(oTextCursor)
|
||||||
|
@ -1171,169 +1160,253 @@ Sub shrinkPageContent
|
||||||
oLastChars = oTextCursor.Text.createTextCursorByRange(oTextCursor)
|
oLastChars = oTextCursor.Text.createTextCursorByRange(oTextCursor)
|
||||||
oViewCursor.goToRange(oTextCursor, false)
|
oViewCursor.goToRange(oTextCursor, false)
|
||||||
'Insert hyphen if needed
|
'Insert hyphen if needed
|
||||||
insertHyphen(oLastChars,oViewCursor)
|
insertHyphen()
|
||||||
End If
|
End If
|
||||||
'Return to initial position
|
'Return to initial position
|
||||||
oTextCursor.gotoRange(oSaveEndSelection,false) 'Go to end of text to check page changes
|
oTextCursor.gotoRange(oSaveEndSelection,false) 'Go to end of text to check page changes
|
||||||
oTextCursor.goLeft(1,false)
|
oTextCursor.goLeft(1,false)
|
||||||
'Set saved position to initial state
|
'Set saved position to initial state
|
||||||
oSaveEndSelection = oTextCursor.Text.createTextCursorByRange(oTextCursor)
|
oSaveEndSelection = oTextCursor.Text.createTextCursorByRange(oTextCursor)
|
||||||
|
'If one of textRanges is Footnote or Endnote we can't select them so it is better to exit now
|
||||||
|
If oTextCursor.Text.supportsService("com.sun.star.text.Endnote") OR _
|
||||||
|
oTextCursor.Text.supportsService("com.sun.star.text.Footnote") OR _
|
||||||
|
oTextCursor.Text.supportsService("com.sun.star.text.CellProperties") OR _
|
||||||
|
oSaveEndSelection.Text.supportsService("com.sun.star.text.Endnote") OR _
|
||||||
|
oSaveEndSelection.Text.supportsService("com.sun.star.text.Footnote") OR _
|
||||||
|
oSaveEndSelection.Text.supportsService("com.sun.star.text.CellProperties") Then
|
||||||
|
shrinkPageContent = false
|
||||||
|
oViewCursor.gotoRange(oViewCurInitPosition,false)
|
||||||
|
Exit Function
|
||||||
|
EndIf
|
||||||
|
|
||||||
oViewCursor.goToRange(oTextCursor,false)
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
|
||||||
oViewCursor.jumpToPreviousPage()
|
oViewCursor.jumpToPreviousPage()
|
||||||
oViewCursor.jumpToStartOfPage()
|
oViewCursor.jumpToStartOfPage()
|
||||||
|
|
||||||
'If one of textRanges is Footnote or Endnote we can't select them so it is better to exit now
|
|
||||||
If oTextCursor.Text.supportsService("com.sun.star.text.Endnote") OR oTextCursor.Text.supportsService("com.sun.star.text.Footnote") Or oTextCursor.Text.supportsService("com.sun.star.text.CellProperties") Then
|
|
||||||
shrinkPageContent = false
|
|
||||||
oViewCursor.gotoRange(oViewCurInitPosition,false)
|
|
||||||
Exit Sub
|
|
||||||
EndIf
|
|
||||||
If oSaveEndSelection.Text.supportsService("com.sun.star.text.Endnote") OR oSaveEndSelection.Text.supportsService("com.sun.star.text.Footnote") Or oTextCursor.Text.supportsService("com.sun.star.text.CellProperties") Then
|
|
||||||
shrinkPageContent = false
|
|
||||||
oViewCursor.gotoRange(oViewCurInitPosition,false)
|
|
||||||
Exit Sub
|
|
||||||
EndIf
|
|
||||||
oTextCursor.gotoRange(oSaveEndSelection,true)
|
oTextCursor.gotoRange(oSaveEndSelection,true)
|
||||||
oViewCursor.gotoRange(oSaveEndSelection,false) 'Go to end of text to check page changes
|
oViewCursor.gotoRange(oSaveEndSelection,false) 'Go to end of text to check page changes
|
||||||
|
|
||||||
If shrinkIntervalHeight(oTextCursor,oViewCursor,scaleIntervalHeight) Then
|
If shrinkKern(oTextCursor,oViewCursor,kernShrinkValue) Or _
|
||||||
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
shrinkCharHeight(oTextCursor,oViewCursor,scaleCharHeight) Or _
|
||||||
If oTextCursor.isEndOfParagraph() Then
|
shrinkIntervalHeight(oTextCursor,oViewCursor,scaleIntervalHeight) Then
|
||||||
pos1 = oViewCursor.getPage()
|
insertHardPageBreakIfNotOnPageBorder()
|
||||||
oViewCursor.goRight(1,false)
|
Exit Function
|
||||||
pos2 = oViewCursor.getPage()
|
|
||||||
'If we moved right to the next para and page haven't changed insert pageBreak
|
|
||||||
If pos1 = pos2 Then
|
|
||||||
insertPageBreak
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
insertPageBreak
|
|
||||||
If Not IsNull(oTextCursor.ParaFirstLineIndent) Then
|
|
||||||
oTextCursor.ParaFirstLineIndent = 0
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
Exit Sub
|
|
||||||
End If
|
End If
|
||||||
If shrinkCharHeight(oTextCursor,oViewCursor,scaleCharHeight) Then
|
|
||||||
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
|
||||||
If oTextCursor.isEndOfParagraph() Then
|
|
||||||
pos1 = oViewCursor.getPage()
|
|
||||||
oViewCursor.goRight(1,false)
|
|
||||||
pos2 = oViewCursor.getPage()
|
|
||||||
'If we moved right to the next para and page haven't changed insert pageBreak
|
|
||||||
If pos1 = pos2 Then
|
|
||||||
insertPageBreak
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
insertPageBreak
|
|
||||||
If Not IsNull(oTextCursor.ParaFirstLineIndent) Then
|
|
||||||
oTextCursor.ParaFirstLineIndent = 0
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
If shrinkKern(oTextCursor,oViewCursor,kernShrinkValue) Then
|
|
||||||
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
|
||||||
If oTextCursor.isEndOfParagraph() Then
|
|
||||||
pos1 = oViewCursor.getPage()
|
|
||||||
oViewCursor.goRight(1,false)
|
|
||||||
pos2 = oViewCursor.getPage()
|
|
||||||
'If we moved right to the next para and page haven't changed insert pageBreak
|
|
||||||
If pos1 = pos2 Then
|
|
||||||
insertPageBreak
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
insertPageBreak
|
|
||||||
If Not IsNull(oTextCursor.ParaFirstLineIndent) Then
|
|
||||||
oTextCursor.ParaFirstLineIndent = 0
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Sub splitPages
|
|
||||||
Dim oViewCursor As Object 'View cursor
|
|
||||||
Dim oText As Object 'Text object in current document
|
|
||||||
Dim oSaveEndSelection As Object 'Text cursor
|
|
||||||
'saveCurrentVersion
|
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
|
||||||
Dim saveFirstLineIndent As Boolean
|
|
||||||
|
|
||||||
'Check if we are at start of paragraph go to the end of previous paragraph
|
|
||||||
If oViewCursor.Text.createTextCursorByRange(oViewCursor).isEndOfParagraph() Then
|
|
||||||
oViewCursor.goRight(1,false)
|
|
||||||
End If
|
|
||||||
If oViewCursor.Text.createTextCursorByRange(oViewCursor).isStartOfParagraph() Then
|
|
||||||
saveFirstLineIndent = true
|
|
||||||
Else
|
|
||||||
saveFirstLineIndent = false
|
|
||||||
End If
|
|
||||||
|
|
||||||
oViewCursor.goRight(1,false)
|
|
||||||
oSaveEndSelection = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
|
||||||
'Select last 2 characters
|
|
||||||
oViewCursor.goLeft(2,true)
|
|
||||||
|
|
||||||
If Len(oViewCursor.String) = 2 Then
|
|
||||||
'Insert hyphen if needed
|
|
||||||
oLastChars = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
|
||||||
insertHyphen(oLastChars,oViewCursor)
|
|
||||||
End If
|
|
||||||
'Return to initial position
|
|
||||||
oViewCursor.gotoRange(oSaveEndSelection,false) 'Go to end of text to check page changes
|
|
||||||
oViewCursor.goLeft(1,false)
|
|
||||||
insertPageBreak
|
|
||||||
If Not saveFirstLineIndent Then
|
|
||||||
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
|
||||||
If Not IsNull(oTextCursor.ParaFirstLineIndent) Then
|
|
||||||
oTextCursor.ParaFirstLineIndent = 0
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function shrinkScaleWidth(oTextCursor,oViewCursor,iterations) As Boolean
|
|
||||||
Dim oParEnum 'paragraph enumeration
|
|
||||||
Dim oPar 'current paragraph
|
|
||||||
Dim oSecEnum 'sections enumeration
|
|
||||||
Dim oParSection 'paragraph text section
|
|
||||||
Dim pageNum As Integer
|
|
||||||
pageNum = oViewCursor.getPage()
|
|
||||||
For i = 1 To iterations Step 1
|
|
||||||
oParEnum = oTextCursor.createEnumeration()
|
|
||||||
Do While oParEnum.hasMoreElements()
|
|
||||||
oPar = oParEnum.nextElement()
|
|
||||||
If oPar.supportsService("com.sun.star.text.Paragraph") Then
|
|
||||||
oPar.charScaleWidth = 100 - i
|
|
||||||
If pageNum <> oViewCursor.getPage() Then
|
|
||||||
shrinkScaleWidth = true
|
|
||||||
Exit Function
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
Loop
|
|
||||||
Next i
|
|
||||||
shrinkScaleWidth = false
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Function shrinkKern(oTextCursor,oViewCursor,iterations) As Boolean
|
Sub configureCursorPositionForContentShrink()
|
||||||
Dim oParEnum 'paragraph enumeration
|
' Globalscope.BasicLibraries.LoadLibrary("MRILib")
|
||||||
Dim oPar 'current paragraph
|
Dim oViewCursor As Object
|
||||||
Dim oSecEnum 'sections enumeration
|
Dim oTextCursor As Object
|
||||||
Dim oParSection 'paragraph text section
|
Dim curSelection As Object
|
||||||
|
Dim selectionTextRange
|
||||||
|
Dim nextChar As String
|
||||||
|
Dim prefChar As String
|
||||||
|
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
|
||||||
|
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
'At start of Para
|
||||||
|
oTextCursor.collapseToEnd()
|
||||||
|
If oTextCursor.isStartOfParagraph() AND NOT oTextCursor.isEndOfParagraph() Then
|
||||||
|
oTextCursor.goLeft(1,false)
|
||||||
|
EndIf
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Function isShrinkPageSucceded(initPosition As Object,initPageNum As String) As Boolean
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim oTextCursor As Object
|
||||||
|
isShrinkPageSucceded = false
|
||||||
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
|
oViewCursor.goToRange(initPosition,false)
|
||||||
|
If (oViewCursor.getPage <> initPageNum) Then
|
||||||
|
isShrinkPageSucceded = true
|
||||||
|
Else
|
||||||
|
oTextCursor = oViewcursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
oTextCursor.goRight(1,false)
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
If oViewCursor.getPage <> initPageNum Then
|
||||||
|
isShrinkPageSucceded = true
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Function getShrinkPageContentInitPosition() As Object
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim oTextCursor As Object
|
||||||
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
|
oTextCursor = oViewcursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
If NOT oTextCursor.isEndOfParagraph() Then
|
||||||
|
oTextCursor.goLeft(1,false)
|
||||||
|
oTextCursor.goRight(2,true)
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
insertHyphen()
|
||||||
|
oTextCursor.goLeft(1,false)
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
insertPageBreak
|
||||||
|
oTextCursor.goLeft(1,false)
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
getShrinkPageContentInitPosition = oViewcursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
Else
|
||||||
|
oTextCursor.goRight(1,false)
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
oViewCursor.BreakType = com.sun.star.style.BreakType.PAGE_BEFORE
|
||||||
|
oTextCursor.goLeft(1,false)
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
getShrinkPageContentInitPosition = oViewcursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
EndIf
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Function canShrinkContent() As Boolean
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim oTextCursor As Object
|
||||||
|
Dim oSavePosition As Object
|
||||||
|
Dim oStartPosition As Object
|
||||||
|
Dim initPageNum As Long
|
||||||
|
Dim startPageNum As Long
|
||||||
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
|
oSavePosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
canShrinkContent = true
|
||||||
|
'In endntote footnote or table shrink is not possible
|
||||||
|
If oViewCursor.Text.supportsService("com.sun.star.text.Endnote") OR _
|
||||||
|
oViewCursor.Text.supportsService("com.sun.star.text.Footnote") OR _
|
||||||
|
oViewCursor.Text.supportsService("com.sun.star.text.CellProperties") Then
|
||||||
|
canShrinkContent = false
|
||||||
|
oViewCursor.goToRange(oSavePosition,false)
|
||||||
|
Exit Function
|
||||||
|
EndIf
|
||||||
|
'If current paragraph has page break before
|
||||||
|
If oSavePosition.BreakType <> 0 Then
|
||||||
|
canShrinkContent = false
|
||||||
|
oViewCursor.goToRange(oSavePosition,false)
|
||||||
|
Exit Function
|
||||||
|
EndIf
|
||||||
|
initPageNum = oViewcursor.getPage()
|
||||||
|
oViewCursor.JumpToPreviousPage(false)
|
||||||
|
oViewCursor.jumpToStartOfPage()
|
||||||
|
startPageNum = oViewcursor.getPage()
|
||||||
|
'No previous page exists
|
||||||
|
If startPageNum = initPageNum Then
|
||||||
|
oViewCursor.goToRange(oSavePosition,false)
|
||||||
|
canShrinkContent = false
|
||||||
|
Exit Function
|
||||||
|
EndIf
|
||||||
|
oViewCursor.goToRange(oSavePosition,false)
|
||||||
|
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
Do While oViewcursor.getPage() = initPageNum
|
||||||
|
oTextCursor.gotoPreviousParagraph(false)
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
If oTextCursor.BreakType <> 0 Then
|
||||||
|
canShrinkContent = false
|
||||||
|
oViewCursor.goToRange(oSavePosition,false)
|
||||||
|
Exit Function
|
||||||
|
EndIf
|
||||||
|
Loop
|
||||||
|
oViewCursor.goToRange(oSavePosition,false)
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
Function shrinkPageContentNew() As Boolean
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim oTextCursor As Object
|
||||||
|
Dim initPosition As Object
|
||||||
|
Dim initPageNum As String
|
||||||
|
Dim oSaveEndSelection As Object
|
||||||
|
Dim oEnum As Variant
|
||||||
|
Dim oPar As Object
|
||||||
|
Dim startOfPara As Boolean
|
||||||
|
Dim targetContent() As Object
|
||||||
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
|
|
||||||
|
configureCursorPositionForContentShrink()
|
||||||
|
If Not canShrinkContent() Then
|
||||||
|
Exit Function
|
||||||
|
EndIf
|
||||||
|
initPageNum = oViewcursor.getPage()
|
||||||
|
initPosition = getShrinkPageContentInitPosition()
|
||||||
|
oViewcursor.goToRange(initPosition,false)
|
||||||
|
oViewCursor.JumpToPreviousPage(false)
|
||||||
|
oViewCursor.jumpToStartOfPage()
|
||||||
|
startPosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
targetContent = selectContentToShrink(initPosition,startPosition)
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Function selectContentToShrink(initPosition As Object, startPosition As Object)
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim oTextCursor As Object
|
||||||
|
Dim startPageNum As Long
|
||||||
|
Dim prevPageNum As Long
|
||||||
|
Dim savePosition As Object
|
||||||
|
Dim targetContent() As Variant
|
||||||
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
|
oViewcursor.goToRange(startPosition,false)
|
||||||
|
prevPageNum = oViewcursor.getPage()
|
||||||
|
oViewcursor.goToRange(initPosition,false)
|
||||||
|
startPageNum = oViewcursor.getPage()
|
||||||
|
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
|
||||||
|
'If Len(oTextCursor.String) > 0 Then
|
||||||
|
' AddToArray(targetContent,oTextCursor.Text.createTextCursorByRange(oTextCursor))
|
||||||
|
' EndIf
|
||||||
|
Do While startPageNum = oViewcursor.getPage() OR prevPageNum = oViewcursor.getPage()
|
||||||
|
savePosition = oTextCursor.getStart()
|
||||||
|
oTextCursor.gotoStartOfParagraph(true)
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
oViewCursor.collapseToStart()
|
||||||
|
If Len(oTextCursor.String) > 0 Then
|
||||||
|
If (startPageNum = oViewcursor.getPage() OR prevPageNum = oViewcursor.getPage()) Then
|
||||||
|
AddToArray(targetContent,oTextCursor.Text.createTextCursorByRange(oTextCursor))
|
||||||
|
Else
|
||||||
|
oTextCursor.goToRange(savePosition,false)
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
oViewCursor.JumpToStartOfPage(false)
|
||||||
|
oTextCursor.goToRange(oViewCursor,true)
|
||||||
|
AddToArray(targetContent,oTextCursor.Text.createTextCursorByRange(oTextCursor))
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
oTextCursor.gotoPreviousParagraph(false)
|
||||||
|
oTextCursor.gotoEndOfParagraph(false)
|
||||||
|
oViewCursor.goToRange(oTextCursor,false)
|
||||||
|
Loop
|
||||||
|
selectContentToShrink = targetContent
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Sub insertHardPageBreakIfNotOnPageBorder()
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim oTextCursor As Object
|
||||||
|
Dim pos1 As Integer
|
||||||
|
Dim pos2 As Integer
|
||||||
|
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
If oTextCursor.isEndOfParagraph() Then
|
||||||
|
pos1 = oViewCursor.getPage()
|
||||||
|
oViewCursor.goRight(1,false)
|
||||||
|
pos2 = oViewCursor.getPage()
|
||||||
|
'If we moved right to the next para and page haven't changed insert pageBreak
|
||||||
|
If pos1 = pos2 Then
|
||||||
|
insertPageBreak
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
insertPageBreak
|
||||||
|
If Not IsNull(oTextCursor.ParaFirstLineIndent) Then
|
||||||
|
oTextCursor.ParaFirstLineIndent = 0
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Function shrinkKern(oTextCursor As Object, oViewCursor As Object,iterations As Integer) As Boolean
|
||||||
|
Dim oParEnum As Object'paragraph enumeration
|
||||||
|
Dim oPar As Object 'current paragraph
|
||||||
|
Dim oSecEnum As Object'sections enumeration
|
||||||
|
Dim oParSection As Object'paragraph text section
|
||||||
Dim pageNum As Integer
|
Dim pageNum As Integer
|
||||||
|
Dim i As Integer
|
||||||
pageNum = oViewCursor.getPage()
|
pageNum = oViewCursor.getPage()
|
||||||
For i = 2 To iterations Step 2
|
For i = 2 To iterations Step 2
|
||||||
oParEnum = oTextCursor.createEnumeration()
|
oParEnum = oTextCursor.createEnumeration()
|
||||||
|
@ -1351,13 +1424,14 @@ Function shrinkKern(oTextCursor,oViewCursor,iterations) As Boolean
|
||||||
shrinkKern = false
|
shrinkKern = false
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Function shrinkCharHeight(oTextCursor,oViewCursor,iterations) As Boolean
|
Function shrinkCharHeight(oTextCursor As Object, oViewCursor As Object, iterations As Integer) As Boolean
|
||||||
Dim oParEnum 'paragraph enumeration
|
Dim oParEnum As Object'paragraph enumeration
|
||||||
Dim oPar 'current paragraph
|
Dim oPar As Object'current paragraph
|
||||||
Dim oSecEnum 'sections enumeration
|
Dim oSecEnum As Object'sections enumeration
|
||||||
Dim oParSection 'paragraph text section
|
Dim oParSection As Object'paragraph text section
|
||||||
Dim pageNum As Integer
|
Dim pageNum As Integer
|
||||||
Dim parCursor As Object
|
Dim parCursor As Object
|
||||||
|
Dim i As Integer
|
||||||
pageNum = oViewCursor.getPage()
|
pageNum = oViewCursor.getPage()
|
||||||
For i = 1 To iterations Step 1
|
For i = 1 To iterations Step 1
|
||||||
oParEnum = oTextCursor.createEnumeration()
|
oParEnum = oTextCursor.createEnumeration()
|
||||||
|
@ -1392,13 +1466,13 @@ Function roundHeight(nHeight)
|
||||||
roundHeight=lHeight
|
roundHeight=lHeight
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Function shrinkIntervalHeight(oTextCursor,oViewCursor,iterations) As Boolean
|
Function shrinkIntervalHeight(oTextCursor As Object ,oViewCursor As Object,iterations As Integer) As Boolean
|
||||||
Dim oParEnum 'paragraph enumeration
|
Dim oParEnum As Object 'paragraph enumeration
|
||||||
Dim oPar 'current paragraph
|
Dim oPar As Object 'current paragraph
|
||||||
Dim oSecEnum 'sections enumeration
|
Dim oSecEnum As Object 'sections enumeration
|
||||||
Dim oParSection 'paragraph text section
|
Dim oParSection As Object 'paragraph text section
|
||||||
Dim pageNum As Integer
|
Dim pageNum As Integer
|
||||||
Dim lineSpacing
|
Dim lineSpacing As Object
|
||||||
pageNum = oViewCursor.getPage()
|
pageNum = oViewCursor.getPage()
|
||||||
For i = 1 To iterations Step 1
|
For i = 1 To iterations Step 1
|
||||||
oParEnum = oTextCursor.createEnumeration()
|
oParEnum = oTextCursor.createEnumeration()
|
||||||
|
@ -1420,15 +1494,13 @@ Function shrinkIntervalHeight(oTextCursor,oViewCursor,iterations) As Boolean
|
||||||
shrinkIntervalHeight = false
|
shrinkIntervalHeight = false
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Sub savecursor
|
Sub savecursor()
|
||||||
Dim oViewCursor As Object 'View cursor
|
Dim oViewCursor As Object 'View cursor
|
||||||
Dim oTextCursor As Object'Text cursor
|
Dim oTextCursor As Object'Text cursor
|
||||||
Dim oSaveEndSelection As Object 'Text cursor
|
Dim oSaveEndSelection As Object 'Text cursor
|
||||||
Dim oEnum As Object'Cursor enumeration
|
Dim oEnum As Object'Cursor enumeration
|
||||||
Dim oText As Object'Text object in current document
|
Dim oText As Object'Text object in current document
|
||||||
Dim oPar As Object'Current paragraph
|
Dim oPar As Object'Current paragraph
|
||||||
Dim sTextContent As String'Service name for text content.
|
|
||||||
sTextContent = "com.sun.star.text.TextContent"
|
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
oSaveEndSelection = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
oSaveEndSelection = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
REM oViewCursor.getText.insertString(oViewCursor.getStart(), CHR$(257), False)
|
REM oViewCursor.getText.insertString(oViewCursor.getStart(), CHR$(257), False)
|
||||||
|
@ -1477,37 +1549,57 @@ Sub savecursor
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Sub splitPages
|
||||||
sub insertPageBreak
|
Dim oViewCursor As Object 'View cursor
|
||||||
rem ----------------------------------------------------------------------
|
Dim oText As Object 'Text object in current document
|
||||||
rem define variables
|
Dim oSaveEndSelection As Object 'Text cursor
|
||||||
dim document as object
|
'saveCurrentVersion
|
||||||
dim dispatcher as object
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
rem ----------------------------------------------------------------------
|
Dim saveFirstLineIndent As Boolean
|
||||||
rem get access to the document
|
|
||||||
document = ThisComponent.CurrentController.Frame
|
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
|
||||||
|
|
||||||
rem ----------------------------------------------------------------------
|
'Check if we are at start of paragraph go to the end of previous paragraph
|
||||||
dispatcher.executeDispatch(document, ".uno:InsertPagebreak", "", 0, Array())
|
If oViewCursor.Text.createTextCursorByRange(oViewCursor).isEndOfParagraph() Then
|
||||||
|
oViewCursor.goRight(1,false)
|
||||||
|
End If
|
||||||
end sub
|
If oViewCursor.Text.createTextCursorByRange(oViewCursor).isStartOfParagraph() Then
|
||||||
|
saveFirstLineIndent = true
|
||||||
Sub insertHyphen(oTextCursor,oViewCursor)
|
Else
|
||||||
Dim lastChars
|
saveFirstLineIndent = false
|
||||||
'lastChars = oTextCursor.getString()
|
End If
|
||||||
replacementhyp
|
|
||||||
'MsgBox lastChars
|
oViewCursor.goRight(1,false)
|
||||||
|
oSaveEndSelection = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
'Select last 2 characters
|
||||||
|
oViewCursor.goLeft(2,true)
|
||||||
|
|
||||||
|
If Len(oViewCursor.String) = 2 Then
|
||||||
|
'Insert hyphen if needed
|
||||||
|
oLastChars = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
insertHyphen()
|
||||||
|
End If
|
||||||
|
'Return to initial position
|
||||||
|
oViewCursor.gotoRange(oSaveEndSelection,false) 'Go to end of text to check page changes
|
||||||
|
oViewCursor.goLeft(1,false)
|
||||||
|
insertPageBreak
|
||||||
|
If Not saveFirstLineIndent Then
|
||||||
|
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
If Not IsNull(oTextCursor.ParaFirstLineIndent) Then
|
||||||
|
oTextCursor.ParaFirstLineIndent = 0
|
||||||
|
End If
|
||||||
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
sub replacementhyp
|
Sub insertPageBreak
|
||||||
rem ----------------------------------------------------------------------
|
dim document as object
|
||||||
rem define variables
|
dim dispatcher as object
|
||||||
|
document = ThisComponent.CurrentController.Frame
|
||||||
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
|
dispatcher.executeDispatch(document, ".uno:InsertPagebreak", "", 0, Array())
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub insertHyphen()
|
||||||
dim document as object
|
dim document as object
|
||||||
dim dispatcher as object
|
dim dispatcher as object
|
||||||
rem ----------------------------------------------------------------------
|
|
||||||
rem get access to the document
|
|
||||||
document = ThisComponent.CurrentController.Frame
|
document = ThisComponent.CurrentController.Frame
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
|
|
||||||
|
@ -1538,6 +1630,7 @@ sub replacementhyp
|
||||||
args1(11).Name = "SearchItem.SearchString"
|
args1(11).Name = "SearchItem.SearchString"
|
||||||
args1(11).Value = "([a-zA-Zа-яА-Я])([a-zA-Zа-яА-Я])"
|
args1(11).Value = "([a-zA-Zа-яА-Я])([a-zA-Zа-яА-Я])"
|
||||||
args1(12).Name = "SearchItem.ReplaceString"
|
args1(12).Name = "SearchItem.ReplaceString"
|
||||||
|
' "$1 U+00AD $2"
|
||||||
args1(12).Value = "$1$2"
|
args1(12).Value = "$1$2"
|
||||||
args1(13).Name = "SearchItem.Locale"
|
args1(13).Name = "SearchItem.Locale"
|
||||||
args1(13).Value = 255
|
args1(13).Value = 255
|
||||||
|
|
Loading…
Add table
Reference in a new issue