Added check for colored text areas

This commit is contained in:
Georgy Litvinov 2021-06-04 22:28:27 +02:00
parent 9846e2933c
commit fae0f0b494
4 changed files with 89 additions and 14 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="Validation" script:language="StarBasic">Sub markval24
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Validation" script:language="StarBasic">Sub markval25
End Sub
@ -34,6 +34,7 @@ Sub validateButton
Dim badNumberings As Boolean
Dim needExtendedInfo As Boolean
Dim config As Object
Dim needFixColoredText As Boolean
config = initRedactionConfiguration()
Dim statusIndicator as Object
@ -83,9 +84,11 @@ Sub validateButton
needExtendedInfo = false
EndIf
needFixColoredText = findColoredBackgroundInDoc
numberingsErros = printNumberingSymbols(needExtendedInfo)
statusIndicator.setValue(80)
If numberingsErros OR badText OR badNumberings OR footnotesReport &lt;&gt; &quot;&quot; OR graphicsReport &lt;&gt; &quot;&quot; Or outlineInNotesReport &lt;&gt; &quot;&quot; Or sectionsReport &lt;&gt; &quot;&quot; OR oulineInTablesReport &lt;&gt; &quot;&quot; OR outlinePageStylesReport &lt;&gt; &quot;&quot; Then
If needFixColoredText OR numberingsErros OR badText OR badNumberings OR footnotesReport &lt;&gt; &quot;&quot; OR graphicsReport &lt;&gt; &quot;&quot; Or outlineInNotesReport &lt;&gt; &quot;&quot; Or sectionsReport &lt;&gt; &quot;&quot; OR oulineInTablesReport &lt;&gt; &quot;&quot; OR outlinePageStylesReport &lt;&gt; &quot;&quot; Then
MsgBox getTranslation(&quot;validationWarning&quot;)
If badText Then
MsgBox getTranslation(&quot;validationBadSymbolsNotification&quot;)
@ -851,8 +854,7 @@ Function getCharsInFont(fontName As String) As String
EndIf
End Function
Sub findColoredBackgroundInDoc()
Function findColoredBackgroundInDoc() As Boolean
Dim founds As Object
Dim sDesc As Object
Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
@ -866,22 +868,36 @@ End Function
sDesc.searchStyles = true
sDesc.SetSearchAttributes(SrchAttributes())
founds = Thiscomponent.findAll(sDesc)
findColoredBackgroundInDoc = false
If founds.count &lt;&gt; 0 Then
MsgBox founds.count
Else
MsgBox getTranslation(&quot;No colored text excerpts found&quot;)
MsgBox getTranslation(&quot;foundColoredTextMessage&quot;)
startNavigatorDialog(getTranslation(&quot;coloredTextDescription&quot;),founds)
findColoredBackgroundInDoc = true
EndIf
End Sub
End Function
Sub starNavigatorDialog(objectsDescription As Text,founds As Object)
Sub startNavigatorDialog(objectsDescription As String,founds As Object)
Dim dialog As Object
Dim leftImageURL As String
Dim rightImageURL As String
Dim curNum As Long
Dim maxNum As Long
Dim found As Object
Dim oViewCursor As Object
&apos;Globalscope.BasicLibraries.LoadLibrary( &quot;MRILib&quot; )
&apos;Mri founds
oViewCursor = ThisComponent.CurrentController.getViewCursor()
waitingForDialog = true
maxNum = founds.count - 1
dialog = notModalDialog(&quot;Navigator&quot;)
&apos; dialog.getControl(&quot;found&quot;).SetText(getTranslation(&quot;EndnotesNativeDialogFound&quot;) &amp; CStr(UBound(foundEndNotes)+1))
&apos; dialog.getControl(&quot;description&quot;).SetText(getTranslation(&quot;EndnotesNativeDialogDescriptionSelect&quot;))
dialog.getControl(&quot;found&quot;).SetText(getTranslation(&quot;navigatorFound&quot;) &amp; CStr(maxNum+1))
curNum = 0
found = founds.getByIndex(curNum)
dialog.getControl(&quot;current&quot;).SetText(CStr(curNum+1))
dialog.getControl(&quot;description&quot;).SetText(objectsDescription)
&apos; dialog.getControl(&quot;cancel&quot;).Label = getTranslation(&quot;buttonCancel&quot;)
dialog.getControl(&quot;close&quot;).Label = getTranslation(&quot;buttonClose&quot;)
leftImageURL = convertToURL(getExtensionPath() &amp; &quot;/images/left-navigator.svg&quot;)
@ -891,13 +907,24 @@ Sub starNavigatorDialog(objectsDescription As Text,founds As Object)
dialog.getControl(&quot;next&quot;).model.imageURL = rightImageURL
&apos;dialog.getControl(&quot;next&quot;).model.ScaleMode = 2
dialog.setvisible(true)
oViewCursor.goToRange(found,false)
Do While waitingForDialog
If dialog.getControl(&quot;close&quot;).model.state = 1 then
exit Do
EndIf
If dialog.getControl(&quot;prev&quot;).model.state = 1 then
curNum = getPrevFound(curNum, maxNum)
found = founds.getByIndex(curNum)
oViewCursor.goToRange(found,false)
dialog.getControl(&quot;current&quot;).SetText(CStr(curNum+1))
dialog.getControl(&quot;prev&quot;).model.state = 0
EndIf
If dialog.getControl(&quot;next&quot;).model.state = 1 then
curNum = getNextFound(curNum, maxNum)
found = founds.getByIndex(curNum)
oViewCursor.goToRange(found,false)
dialog.getControl(&quot;current&quot;).SetText(CStr(curNum+1))
dialog.getControl(&quot;next&quot;).model.state = 0
EndIf
wait (100)
@ -905,6 +932,24 @@ Sub starNavigatorDialog(objectsDescription As Text,founds As Object)
dialog.dispose
End Sub
Function getNextFound(curNum As Long, max As Long) As Long
If curNum &lt; max Then
getNextFound = curNum + 1
Else
getNextFound = 0
EndIf
End Function
Function getPrevFound(curNum As Long, max As Long) As Long
If curNum = 0 Then
getPrevFound = max
Else
getPrevFound = curNum - 1
EndIf
End Function
Function getExtensionPath() As String
Dim extensionIdentifier As String
Dim pip As Object