Added numberings validation

This commit is contained in:
Georgy Litvinov 2020-03-06 17:37:35 +01:00
parent fa3ff2c16b
commit 6d4031e1aa
4 changed files with 87 additions and 2 deletions

View file

@ -2,7 +2,7 @@
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd"> <!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="ConfigDialog" dlg:left="196" dlg:top="109" dlg:width="157" dlg:height="64" dlg:closeable="true" dlg:moveable="true"> <dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="ConfigDialog" dlg:left="196" dlg:top="109" dlg:width="157" dlg:height="64" dlg:closeable="true" dlg:moveable="true">
<dlg:bulletinboard> <dlg:bulletinboard>
<dlg:checkbox dlg:id="CB_complexity" dlg:tab-index="0" dlg:left="5" dlg:top="13" dlg:width="150" dlg:height="19" dlg:value="Включить расширенное управление чисткой" dlg:checked="false"/> <dlg:checkbox dlg:id="CB_complexity" dlg:tab-index="0" dlg:left="5" dlg:top="13" dlg:width="150" dlg:height="19" dlg:value="Включить режим эксперта" dlg:checked="false"/>
<dlg:button dlg:id="OK" dlg:tab-index="1" dlg:left="9" dlg:top="45" dlg:width="59" dlg:height="13" dlg:value="Сохранить" dlg:button-type="ok"/> <dlg:button dlg:id="OK" dlg:tab-index="1" dlg:left="9" dlg:top="45" dlg:width="59" dlg:height="13" dlg:value="Сохранить" dlg:button-type="ok"/>
<dlg:button dlg:id="CommandButton1" dlg:tab-index="2" dlg:left="-132" dlg:top="41" dlg:width="2" dlg:height="0" dlg:value="CommandButton1"/> <dlg:button dlg:id="CommandButton1" dlg:tab-index="2" dlg:left="-132" dlg:top="41" dlg:width="2" dlg:height="0" dlg:value="CommandButton1"/>
<dlg:button dlg:id="CANCEL" dlg:tab-index="3" dlg:left="77" dlg:top="45" dlg:width="59" dlg:height="13" dlg:value="Отмена" dlg:button-type="cancel"/> <dlg:button dlg:id="CANCEL" dlg:tab-index="3" dlg:left="77" dlg:top="45" dlg:width="59" dlg:height="13" dlg:value="Отмена" dlg:button-type="cancel"/>

View file

@ -29,6 +29,7 @@ Sub validateButton
Dim badNumberings As Boolean Dim badNumberings As Boolean
Dim badFootnoteSigns As Boolean Dim badFootnoteSigns As Boolean
Dim badGraphics As Boolean Dim badGraphics As Boolean
Dim needExtendedInfo As Boolean
badGraphics = false badGraphics = false
badText = false badText = false
badFootnoteSigns = false badFootnoteSigns = false
@ -50,6 +51,15 @@ Sub validateButton
If badGraphics Then If badGraphics Then
MsgBox graphicsReport MsgBox graphicsReport
EndIf EndIf
Dim config As Object
config = initRedactionConfiguration()
If config.getPropertyValue(&quot;complexity&quot;) = &quot;makerUp&quot; then
needExtendedInfo = true
Else
needExtendedInfo = false
EndIf
printNumberingSymbols(needExtendedInfo)
If badText OR badNumberings OR badFootnoteSigns OR badGraphics Then If badText OR badNumberings OR badFootnoteSigns OR badGraphics Then
MsgBox &quot;Перед публикацией документа следует исправить все найденные замечания.&quot; MsgBox &quot;Перед публикацией документа следует исправить все найденные замечания.&quot;
If badText Then If badText Then
@ -148,6 +158,80 @@ Private Function checkAllFootnotes()
checkAllFootnotes = result checkAllFootnotes = result
End Function End Function
Private Sub printNumberingSymbols(needExtendedInfo)
Dim families As Object
Dim numStyles As Object
Dim numStyle As Object
Dim numRules As Object
Dim numRule As Object
Dim prop As Object
Dim enum1 As Object
Dim enum1Element As Object
Dim fontProp As Object
Dim fontName As String
Dim result As String
Dim resultBad As String
dim excerpt As String
dim exLength As Integer
families = ThisComponent.StyleFamilies
numStyles = families.getByName(&quot;NumberingStyles&quot;)
result = &quot;&quot;
resultBad = &quot;&quot;
enum1 = ThisComponent.Text.createEnumeration
Do While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
If NOT IsMissing(enum1Element.NumberingRules) AND NOT IsEmpty(enum1Element.NumberingRules) Then
numRules = enum1Element.NumberingRules
If numRules.hasElements Then
numRule = numRules.getByIndex(enum1Element.NumberingLevel)
fontName = &quot;&quot;
fontChar = &quot;&quot;
For k = 0 To Ubound(numRule)
prop = numRule(k)
If prop.Name = &quot;BulletFont&quot; Then
fontName = prop.Value.Name
EndIf
If prop.Name = &quot;BulletChar&quot; Then
fontChar = prop.Value
EndIf
Next k
exLength = 15
excerpt = enum1Element.String
If Len(excerpt) &lt; exLength Then
exLength = Len(excerpt)
EndIf
tmp = &quot;Уровень &quot; &amp; (j + 1) &amp; &quot; шрифт &quot; &amp; fontName &amp; &quot; символ &quot; &amp; fontChar &amp; &quot; (&quot; &amp; Hex(Asc(fontChar)) &amp; &quot;) &quot;&amp; Left(excerpt,exLength) &amp; chr(10)
If Asc(fontChar) &gt; 57344 AND Asc(fontChar) &lt; 63743 Then
resultBad = resultBad &amp; tmp
ElseIf fontName &lt;&gt; &quot;IPH Astra Serif&quot; _
AND fontName &lt;&gt; &quot;OpenSymbol&quot; _
AND fontName &lt;&gt; &quot;IPH Lib Serif&quot; _
AND fontName &lt;&gt; &quot;IPH Lib Sans&quot; _
AND fontName &lt;&gt; &quot;Liberation Serif&quot; _
AND fontName &lt;&gt; &quot;Liberation Sans&quot; _
AND needExtendedInfo Then
result = result &amp; tmp
EndIf
EndIf
EndIf
EndIf
Loop
dim report as String
report = &quot;&quot;
If result = &quot;&quot; AND resultBad = &quot;&quot; Then
Exit sub
Else
If resultBad &lt;&gt; &quot;&quot; Then
report = &quot;Маркером в следующих списках нумерации задан некорректный символ&quot;&amp; chr(10) &amp; resultBad
EndIf
If result &lt;&gt; &quot;&quot; Then
report = report &amp; &quot;В следующих списках нумерации найдены шрифты &quot;&amp; chr(10)&amp; result
EndIf
EndIf
MsgBox report
End Sub
Private Sub showTrackedChanges Private Sub showTrackedChanges
dim document as object dim document as object
dim dispatcher as object dim dispatcher as object

View file

@ -3,7 +3,7 @@
xmlns:dep="http://openoffice.org/extensions/description/2006" xmlns:dep="http://openoffice.org/extensions/description/2006"
xmlns:xlink="http://www.w3.org/1999/xlink"> xmlns:xlink="http://www.w3.org/1999/xlink">
<identifier value="pro.litvinovg.Redaction" /> <identifier value="pro.litvinovg.Redaction" />
<version value="0.5.2" /> <version value="0.5.3" />
<platform value="all" /> <platform value="all" />
<display-name> <display-name>
<name lang="en">Cleaning and validation documents for publishing in html and epub with pagination</name> <name lang="en">Cleaning and validation documents for publishing in html and epub with pagination</name>

View file

@ -1,3 +1,4 @@
0.5.1 Added validation for numberings
0.5.1 Added menu to control over cleaning process 0.5.1 Added menu to control over cleaning process
0.4.8 Added conversion for И + \u0306 to Й and еЕ + \u308 to ёЁ 0.4.8 Added conversion for И + \u0306 to Й and еЕ + \u308 to ёЁ
0.4.7 Added conversion for и + \u0306 to й 0.4.7 Added conversion for и + \u0306 to й