Improvements for validation button
This commit is contained in:
parent
be9907ea22
commit
2038c92784
2 changed files with 98 additions and 11 deletions
|
@ -1,22 +1,113 @@
|
||||||
<?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="Validation" script:language="StarBasic">Sub markYX
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Validation" script:language="StarBasic">Sub markZ
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Function isInDoc(searchString As String)
|
||||||
|
Dim founds As Object
|
||||||
|
Dim sDesc As Object
|
||||||
|
Dim srch(0) as new com.sun.star.beans.PropertyValue
|
||||||
|
sDesc = Thiscomponent.createSearchDescriptor()
|
||||||
|
sDesc.SearchAll = true
|
||||||
|
sDesc.ValueSearch = false
|
||||||
|
sDesc.SearchStyles = false
|
||||||
|
sDesc.SearchRegularExpression = true
|
||||||
|
sDesc.SearchString = searchString
|
||||||
|
founds = Thiscomponent.findAll(sDesc)
|
||||||
|
If founds.count <> 0 Then
|
||||||
|
isInDoc = true
|
||||||
|
Else
|
||||||
|
isInDoc = false
|
||||||
|
EndIf
|
||||||
|
End Function
|
||||||
|
|
||||||
Sub validateButton
|
Sub validateButton
|
||||||
removeBadCharacters
|
Dim footnotesReport As String
|
||||||
|
Dim graphicsReport As String
|
||||||
|
Dim badText As Boolean
|
||||||
|
Dim badNumberings As Boolean
|
||||||
|
Dim badFootnoteSigns As Boolean
|
||||||
|
Dim badGraphics As Boolean
|
||||||
|
badGraphics = false
|
||||||
|
badText = false
|
||||||
|
badFootnoteSigns = false
|
||||||
|
badNumberings = false
|
||||||
|
footnotesReport = checkAllFootnotes
|
||||||
|
graphicsReport = checkGraphics
|
||||||
|
If footnotesReport <> "" Then
|
||||||
|
badFootnoteSigns = true
|
||||||
|
EndIf
|
||||||
|
If graphicsReport <> "" Then
|
||||||
|
badGraphics = true
|
||||||
|
EndIf
|
||||||
|
If isInDoc("[\uE000-\uF8FF]") Then
|
||||||
|
badText = true
|
||||||
|
EndIf
|
||||||
|
If badFootnoteSigns Then
|
||||||
|
MsgBox footnotesReport
|
||||||
|
EndIf
|
||||||
|
If badGraphics Then
|
||||||
|
MsgBox graphicsReport
|
||||||
|
EndIf
|
||||||
|
If badText OR badNumberings OR badFootnoteSigns OR badGraphics Then
|
||||||
|
MsgBox "Отошлите данную статью в отдел подготовки рукописей к изданию для получения дополнительной информации."
|
||||||
|
If badText Then
|
||||||
|
MsgBox "В тексте обнаружены неподходящие для публикции символы." & chr(10) & " Далее будет представлен список отрывков текста с подобными символами."
|
||||||
|
removeBadCharacters
|
||||||
|
EndIf
|
||||||
|
Else
|
||||||
|
MsgBox "Документ успешно прошел проверку. " & chr(10) & "Неподходящих для публикации символов найдено не было."
|
||||||
|
EndIf
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Sub testcheckGraphics
|
||||||
|
checkGraphics
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Function checkGraphics
|
||||||
|
Dim drawPages As Object
|
||||||
|
Dim count as Integer
|
||||||
|
Dim draw As Object
|
||||||
|
Dim result As String
|
||||||
|
Dim shapeType As String
|
||||||
|
Dim oleN As Long
|
||||||
|
oleN = 0
|
||||||
|
Dim graphicN As Long
|
||||||
|
graphicN = 0
|
||||||
|
Dim formulaN As Long
|
||||||
|
formulaN = 0
|
||||||
|
Dim frameShapeN As Long
|
||||||
|
frameShapeN = 0
|
||||||
|
Dim drawingN As Long
|
||||||
|
drawingN = 0
|
||||||
|
drawPages = ThisComponent.DrawPage
|
||||||
|
' Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
||||||
|
' MRI ThisComponent
|
||||||
|
count = drawPages.getCount()
|
||||||
|
For i = 0 to count-1
|
||||||
|
draw = drawPages.getByIndex(i)
|
||||||
|
shapeType = draw.ShapeType
|
||||||
|
If InStr(shapeType,"com.sun.star.drawing") = 1 Then
|
||||||
|
drawingN = drawingN + 1
|
||||||
|
EndIf
|
||||||
|
Next i
|
||||||
|
If drawingN <> 0 Then
|
||||||
|
result = "В документе найдены рисунки (" & drawingN & "), неподходящие для публикации."
|
||||||
|
EndIf
|
||||||
|
checkGraphics = result
|
||||||
|
End Function
|
||||||
|
|
||||||
Private Sub removeBadCharacters
|
Private Sub removeBadCharacters
|
||||||
StartTracking
|
StartTracking
|
||||||
AskAndReplace("[\uE000-\uF8FF]+","")
|
AskAndReplace("[\uE000-\uF8FF]+","")
|
||||||
checkAllFootnotes
|
|
||||||
StopTracking
|
StopTracking
|
||||||
showTrackedChanges
|
showTrackedChanges
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub checkAllFootnotes()
|
Private Function checkAllFootnotes()
|
||||||
Dim footnotes As Object
|
Dim footnotes As Object
|
||||||
Dim count as Integer
|
Dim count as Integer
|
||||||
Dim charNum as Long
|
Dim charNum as Long
|
||||||
|
@ -34,16 +125,12 @@ Private Sub checkAllFootnotes()
|
||||||
For j = 1 to charNum
|
For j = 1 to charNum
|
||||||
char = Asc(Right(Left(label,j),1))
|
char = Asc(Right(Left(label,j),1))
|
||||||
If char >= 57344 AND char <= 63743 then
|
If char >= 57344 AND char <= 63743 then
|
||||||
result = result & "Символ "& Chr(char) &" сноски "& i &" находится в диапазоне для частного использования"& chr(10)
|
result = result & "Символ "& Chr(char) &" сноски "& i &" не подходит для публикации"& chr(10)
|
||||||
'Mri footnote
|
|
||||||
'footNote.setLabel(Left(label,j-1) & "*" & Right(label,charNum-j))
|
|
||||||
End If
|
End If
|
||||||
Next j
|
Next j
|
||||||
Next i
|
Next i
|
||||||
If result <> "" then
|
checkAllFootnotes = result
|
||||||
MsgBox result
|
End Function
|
||||||
EndIf
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub showTrackedChanges
|
Private Sub showTrackedChanges
|
||||||
dim document as object
|
dim document as object
|
||||||
|
|
BIN
redaction.oxt
BIN
redaction.oxt
Binary file not shown.
Loading…
Add table
Reference in a new issue