Added line length limit to subscript and superscript for cleaning

This commit is contained in:
Georgy Litvinov 2021-01-23 20:36:09 +01:00
parent 7694a8911a
commit d9b458210a
5 changed files with 71 additions and 2 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Clean" script:language="StarBasic">Sub mark75
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Clean" script:language="StarBasic">Sub mark76
End Sub
@ -1482,6 +1482,8 @@ End Function
Private Sub convertFormatToUserFields(identifier As String, styleNames, styleValues)
Dim maxLength As Integer
maxLength = getMaxLength(identifier)
Dim leftField As String
Dim rightField As String
Dim i As Integer
@ -1505,15 +1507,31 @@ Private Sub convertFormatToUserFields(identifier As String, styleNames, styleVal
i = 0
Do While not isNull(found)
If Len(found.String) &lt;&gt; 0 AND NOT IsNull(found.Text) Then
If maxLength &lt; 0 Or Len(found.String) &lt; maxLength Then
insertUserField(found.End,rightField &amp; i,&quot;&quot;)
insertUserField(found.start,leftField &amp; i,&quot;&quot;)
i = i + 1
EndIf
EndIf
found = Thiscomponent.findNext(found.End, SDesc)
Loop
End Sub
Function getMaxLength(identifier As String) As Integer
Dim config As Object
config = initRedactionConfiguration()
If identifier = &quot;SubScript&quot; Then
getMaxLength = CInt(config.getPropertyValue(&quot;subscript_max_length&quot;))
Exit Function
EndIf
If identifier = &quot;SuperScript&quot; Then
getMaxLength = CInt(config.getPropertyValue(&quot;superscript_max_length&quot;))
Exit Function
EndIf
getMaxLength = -1
End Function
Private Sub convertUserFieldsToFormat(identifier As String, styleNames , styleValues)
Dim oTextCursor As Object
Dim oMasters As Object

View file

@ -7,5 +7,9 @@
<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="83" dlg:top="85" dlg:width="59" dlg:height="13" dlg:value="Отмена" dlg:button-type="cancel"/>
<dlg:checkbox dlg:id="cb_russian_fixes_iph" dlg:tab-index="4" dlg:left="5" dlg:top="26" dlg:width="150" dlg:height="11" dlg:value="Исправления для института философии" dlg:checked="true"/>
<dlg:textfield dlg:id="tf_max_subscript" dlg:tab-index="7" dlg:left="5" dlg:top="52" dlg:width="24" dlg:height="12" dlg:value="10000"/>
<dlg:text dlg:id="label_max_subscript" dlg:tab-index="8" dlg:left="32" dlg:top="52" dlg:width="123" dlg:height="11" dlg:value="Label1"/>
<dlg:text dlg:id="label_max_superscript" dlg:tab-index="6" dlg:left="32" dlg:top="39" dlg:width="123" dlg:height="11" dlg:value="Label1"/>
<dlg:textfield dlg:id="tf_max_superscript" dlg:tab-index="5" dlg:left="5" dlg:top="38" dlg:width="24" dlg:height="12" dlg:value="10000"/>
</dlg:bulletinboard>
</dlg:window>

View file

@ -13,6 +13,12 @@ Function initRedactionConfiguration()
reg = regFactory.createPropertySetRegistry(redactionExtensionName)
redactionProps = reg.openPropertySet(redactionExtensionName, TRUE)
propSetInfo = redactionProps.getPropertySetInfo()
If Not propSetInfo.hasPropertyByName(&quot;superscript_max_length&quot;) Then
redactionProps.addProperty(&quot;superscript_max_length&quot;, 128, &quot;10&quot;)
EndIf
If Not propSetInfo.hasPropertyByName(&quot;subscript_max_length&quot;) Then
redactionProps.addProperty(&quot;subscript_max_length&quot;, 128, &quot;10&quot;)
EndIf
If Not propSetInfo.hasPropertyByName(&quot;fixes_russian_iph&quot;) Then
redactionProps.addProperty(&quot;fixes_russian_iph&quot;, 128, &quot;true&quot;)
EndIf
@ -46,6 +52,9 @@ Private Sub setConfigFromDialog(dialog As Object)
config.setPropertyValue(&quot;fixes_russian_iph&quot;, &quot;false&quot;)
EndIf
config.setPropertyValue(&quot;superscript_max_length&quot;, dialog.getControl(&quot;tf_max_superscript&quot;).getText())
config.setPropertyValue(&quot;subscript_max_length&quot;, dialog.getControl(&quot;tf_max_subscript&quot;).getText())
End Sub
Private Sub loadConfigToDialog(dialog As Object)
@ -62,7 +71,11 @@ Private Sub loadConfigToDialog(dialog As Object)
Else
dialog.getControl(&quot;cb_russian_fixes_iph&quot;).state = 0
EndIf
dialog.getControl(&quot;tf_max_superscript&quot;).setText(config.getPropertyValue(&quot;superscript_max_length&quot;))
dialog.getControl(&quot;tf_max_subscript&quot;).setText(config.getPropertyValue(&quot;subscript_max_length&quot;))
End Sub
@ -73,6 +86,10 @@ Private Sub configurationDialog
loadConfigToDialog(dialog)
dialog.getControl(&quot;CB_complexity&quot;).Label = getTranslation(&quot;dialogConfigComplexity&quot;)
dialog.getControl(&quot;cb_russian_fixes_iph&quot;).Label = getTranslation(&quot;dialogRussianFixesIPH&quot;)
dialog.getControl(&quot;label_max_superscript&quot;).setText(getTranslation(&quot;dialogConfigMaxSuperscript&quot;))
dialog.getControl(&quot;label_max_subscript&quot;).setText(getTranslation(&quot;dialogConfigMaxSubscript&quot;))
dialog.Title = getTranslation(&quot;dialogConfigTitle&quot;)
dialog.getControl(&quot;OK&quot;).Label = getTranslation(&quot;buttonYes&quot;)
dialog.getControl(&quot;CANCEL&quot;).Label = getTranslation(&quot;buttonStop&quot;)

View file

@ -272,6 +272,12 @@ Function getRussian(identifier As String) As String
Case &quot;advancedMenuResetChapterNumberingRules&quot;
getRussian = &quot;Сбросить настройки нумерации глав&quot;
Exit Function
Case &quot;dialogConfigMaxSuperscript&quot;
getRussian = &quot;Макс. длина текста в верхнем индексе&quot;
Exit Function
Case &quot;dialogConfigMaxSubscript&quot;
getRussian = &quot;Макс. длина текста в нижнем индексе&quot;
Exit Function
Case Else
getRussian = &quot;Перевод не найден&quot;
End Select
@ -526,6 +532,12 @@ Function getEnglish(identifier As String) As String
Case &quot;advancedMenuResetChapterNumberingRules&quot;
getEnglish = &quot;Reset chapter numbering settings&quot;
Exit Function
Case &quot;dialogConfigMaxSuperscript&quot;
getEnglish = &quot;Max line length in superscript&quot;
Exit Function
Case &quot;dialogConfigMaxSubscript&quot;
getEnglish = &quot;Max line length in subscript&quot;
Exit Function
Case Else
getEnglish = &quot;No translation&quot;
End Select
@ -779,6 +791,12 @@ Function getCroatian(identifier As String) As String
Case &quot;advancedMenuResetChapterNumberingRules&quot;
getCroatian = &quot;Resetirajte postavke numeriranja poglavlja&quot;
Exit Function
Case &quot;dialogConfigMaxSuperscript&quot;
getCroatian = &quot;Maksimalna duljina retka u natpisu&quot;
Exit Function
Case &quot;dialogConfigMaxSubscript&quot;
getCroatian = &quot;Maksimalna duljina retka u indeksu&quot;
Exit Function
Case Else
getCroatian = &quot;No translation&quot;
End Select
@ -1032,6 +1050,12 @@ Function getSerbian(identifier As String) As String
Case &quot;advancedMenuResetChapterNumberingRules&quot;
getSerbian = &quot;Ресетујте поставке нумерисања поглавља&quot;
Exit Function
Case &quot;dialogConfigMaxSuperscript&quot;
getSerbian = &quot;Максимална дужина реда у натпису&quot;
Exit Function
Case &quot;dialogConfigMaxSubscript&quot;
getSerbian = &quot;Максимална дужина реда у индексу&quot;
Exit Function
Case Else
getSerbian = &quot;No translation&quot;
End Select
@ -1285,6 +1309,12 @@ Function getBosnian(identifier As String) As String
Case &quot;advancedMenuResetChapterNumberingRules&quot;
getBosnian = &quot;Resetirajte postavke numeriranja poglavlja&quot;
Exit Function
Case &quot;dialogConfigMaxSuperscript&quot;
getBosnian = &quot;Maksimalna dužina retka u natpisu&quot;
Exit Function
Case &quot;dialogConfigMaxSubscript&quot;
getBosnian = &quot;Maksimalna dužina retka u indeksu&quot;
Exit Function
Case Else
getBosnian = &quot;No translation&quot;
End Select

Binary file not shown.