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