Bugfixes
This commit is contained in:
parent
d1ab0c9de1
commit
3f8fd4f186
1 changed files with 36 additions and 8 deletions
|
@ -1,10 +1,9 @@
|
||||||
<?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="Hyphenations" script:language="StarBasic">Private Sub markHyph2
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Hyphenations" script:language="StarBasic">Private Sub markHyph3
|
||||||
End sub
|
End sub
|
||||||
|
|
||||||
Private Sub convertHyphInDoc()
|
Private Sub convertHyphInDoc()
|
||||||
|
|
||||||
Dim description As String
|
Dim description As String
|
||||||
Dim allNotes As Object
|
Dim allNotes As Object
|
||||||
dim aNote As Object
|
dim aNote As Object
|
||||||
|
@ -69,26 +68,32 @@ Private Sub convertHyphInText(textElement)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub convertParaHyphens(para)
|
Private Sub convertParaHyphens(para)
|
||||||
Dim lineEnd As String
|
Dim lineEnds() As Object
|
||||||
Dim autoHyphens() As Object
|
Dim autoHyphens() As Object
|
||||||
Dim autoBreaks() As Object
|
Dim autoBreaks() As Object
|
||||||
Dim lineNumbers() As Integer
|
Dim lineNumbers() As Integer
|
||||||
|
' Dim lineShifts() As Integer
|
||||||
Dim charNum as Integer
|
Dim charNum as Integer
|
||||||
Dim lineLength As Integer
|
Dim lineLength As Integer
|
||||||
Dim i As Integer
|
Dim i As Integer
|
||||||
|
Dim vCurs As Object
|
||||||
|
Dim tCurs As Object
|
||||||
|
Dim lineCurs As Object
|
||||||
'No hyphenation needed
|
'No hyphenation needed
|
||||||
If para.ParaIsHyphenation = false Then
|
If para.ParaIsHyphenation = false Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
EndIf
|
EndIf
|
||||||
vCurs = ThisComponent.currentController.getViewCursor()
|
vCurs = ThisComponent.currentController.getViewCursor()
|
||||||
vCurs.goToRange(para.Anchor,false)
|
vCurs.goToRange(para.Start,false)
|
||||||
tCurs = vCurs.Text.createTextCursorByRange(vCurs)
|
tCurs = para.Text.createTextCursorByRange(vCurs)
|
||||||
tCurs.goToStartOfParagraph(false)
|
tCurs.goToStartOfParagraph(false)
|
||||||
vCurs.goToRange(tCurs,false)
|
vCurs.goToRange(tCurs,false)
|
||||||
i = 0
|
i = 0
|
||||||
Do While NOT tCurs.isEndOfParagraph() OR NOT tCurs.isStartOfParagraph()
|
Do While NOT tCurs.isEndOfParagraph() OR NOT tCurs.isStartOfParagraph()
|
||||||
vCurs.gotoEndOfLine(true)
|
vCurs.gotoEndOfLine(false)
|
||||||
lineLength = Len(vCurs.String)
|
lineCursor = para.Text.createTextCursorByRange(vCurs.End)
|
||||||
|
lineCursor.goToRange(tCurs,true)
|
||||||
|
lineLength = Len(lineCursor.String)
|
||||||
vCurs.collapseToEnd()
|
vCurs.collapseToEnd()
|
||||||
i = i + 1
|
i = i + 1
|
||||||
tCurs.goToRange(vCurs.End,false)
|
tCurs.goToRange(vCurs.End,false)
|
||||||
|
@ -110,10 +115,15 @@ Private Sub convertParaHyphens(para)
|
||||||
If needHyphen(lastChar,nextChar,lineLength) Then
|
If needHyphen(lastChar,nextChar,lineLength) Then
|
||||||
addToArray(autoHyphens(),tCurs.Text.createTextCursorByRange(tCurs))
|
addToArray(autoHyphens(),tCurs.Text.createTextCursorByRange(tCurs))
|
||||||
addToArray(lineNumbers(),i)
|
addToArray(lineNumbers(),i)
|
||||||
|
' addToArray(lineShifts(),1)
|
||||||
'replaceHyphen(tCurs,vCurs)
|
'replaceHyphen(tCurs,vCurs)
|
||||||
ElseIf needLineBreak(lastChar,newChar) Then
|
ElseIf needLineBreak(lastChar,newChar) Then
|
||||||
addToArray(autoBreaks(),tCurs.Text.createTextCursorByRange(tCurs))
|
addToArray(autoBreaks(),tCurs.Text.createTextCursorByRange(tCurs))
|
||||||
|
' addToArray(lineShifts(),1)
|
||||||
|
Else
|
||||||
|
' addToArray(lineShifts(),0)
|
||||||
EndIf
|
EndIf
|
||||||
|
addToArray(lineEnds(),tCurs.Text.createTextCursorByRange(tCurs))
|
||||||
tCurs.goRight(1,false)
|
tCurs.goRight(1,false)
|
||||||
vCurs.goToRange(tCurs,false)
|
vCurs.goToRange(tCurs,false)
|
||||||
Loop
|
Loop
|
||||||
|
@ -129,9 +139,27 @@ Private Sub convertParaHyphens(para)
|
||||||
replaceHyphen(autoHyphens(i),lineNumbers(i))
|
replaceHyphen(autoHyphens(i),lineNumbers(i))
|
||||||
Next i
|
Next i
|
||||||
EndIf
|
EndIf
|
||||||
|
' verifyHyphenation(lineEnds,lineShifts)
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub verifyHyphenation(lineEnds() As Object)
|
||||||
|
Dim i As Integer
|
||||||
|
If Lbound(lineEnds) > Ubound(lineEnds) Then
|
||||||
|
Exit Sub
|
||||||
|
EndIf
|
||||||
|
Dim vCurs As Object
|
||||||
|
vCurs = ThisComponent.currentController.getViewCursor()
|
||||||
|
For i = (Lbound(lineEnds)) To (Ubound(lineEnds))
|
||||||
|
vCurs.goToRange(lineEnds(i),false)
|
||||||
|
If NOT (vCurs.isAtEndOfLine() OR vCurs.isAtStartOfLine()) Then
|
||||||
|
MsgBox "Конвертация прервана. Обратитесь к разработчику."
|
||||||
|
Stop
|
||||||
|
EndIf
|
||||||
|
Next i
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Private Sub insertBreak(tCursor As Object)
|
Private Sub insertBreak(tCursor As Object)
|
||||||
'U+200B Zero length space
|
'U+200B Zero length space
|
||||||
tCursor.String = ""
|
tCursor.String = ""
|
||||||
|
|
Loading…
Add table
Reference in a new issue