cleanandvalidate/Redaction/Validation.xba

1212 lines
42 KiB
Text
Raw Normal View History

2019-10-16 15:42:48 +03:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
2021-10-25 21:08:07 +02:00
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Validation" script:language="StarBasic">Sub markval31
2019-10-16 15:42:48 +03:00
End Sub
2019-10-17 18:48:22 +03:00
2019-10-16 16:17:28 +03:00
Sub validateButton
Dim badFootnoteSigns As Boolean
Dim badGraphics As Boolean
Dim badSectionsInTables As Boolean
Dim badHeadingsInFootnotes As Boolean
Dim outlinePageStylesReport As String
Dim badHeadingsInTables As Boolean
2019-10-17 18:48:22 +03:00
Dim badText As Boolean
2020-03-06 17:37:35 +01:00
Dim needExtendedInfo As Boolean
Dim config As Object
2021-06-04 22:28:27 +02:00
Dim needFixColoredText As Boolean
Dim brokenCharBackTransparent As Boolean
config = initRedactionConfiguration()
2020-07-06 11:49:35 +02:00
Dim statusIndicator as Object
statusIndicator = ThisComponent.getCurrentController.statusIndicator
statusIndicator.Start(getTranslation(&quot;validationStarted&quot;),100)
badFootnoteSigns = noteSignsCheck()
2020-07-06 11:49:35 +02:00
statusIndicator.setValue(10)
badGraphics = checkGraphics()
badText = findBadCharacters()
needFixColoredText = findColoredBackgroundInDoc()
2020-07-06 11:49:35 +02:00
statusIndicator.setValue(20)
badSectionsInTables = checkSectionsInTables()
2020-07-06 11:49:35 +02:00
statusIndicator.setValue(30)
badHeadingsInFootnotes = checkNotesOutline()
2020-07-06 11:49:35 +02:00
statusIndicator.setValue(40)
outlinePageStylesReport = checkHeadingsInHeadersFooters()
2020-07-06 11:49:35 +02:00
statusIndicator.setValue(50)
badHeadingsInTables = checkHeadingsInTextTables()
2020-07-06 11:49:35 +02:00
statusIndicator.setValue(60)
If outlinePageStylesReport &lt;&gt; &quot;&quot; Then
MsgBox outlinePageStylesReport
EndIf
2020-03-06 17:37:35 +01:00
If config.getPropertyValue(&quot;complexity&quot;) = &quot;makerUp&quot; then
needExtendedInfo = true
Else
needExtendedInfo = false
EndIf
brokenCharBackTransparent = hasbrokenCharBackTransparent()
If (brokenCharBackTransparent) Then
MsgBox getTranslation(&quot;invalidParagraphFormattingFound&quot;)
EndIf
2021-05-29 14:32:18 +02:00
numberingsErros = printNumberingSymbols(needExtendedInfo)
2020-07-06 11:49:35 +02:00
statusIndicator.setValue(80)
If brokenCharBackTransparent OR needFixColoredText OR numberingsErros OR badText OR badFootnoteSigns OR badGraphics Or badHeadingsInFootnotes Or badSectionsInTables OR badHeadingsInTables OR outlinePageStylesReport &lt;&gt; &quot;&quot; Then
2020-05-04 15:52:04 +02:00
MsgBox getTranslation(&quot;validationWarning&quot;)
2019-10-17 18:48:22 +03:00
Else
MsgBox getTranslation(&quot;validationSuccess&quot;)
2019-10-17 18:48:22 +03:00
EndIf
2020-07-06 11:49:35 +02:00
statusIndicator.end()
2019-10-17 00:31:08 +03:00
End Sub
Function checkGraphics() As Boolean
2019-10-17 18:48:22 +03:00
Dim drawPages As Object
Dim count as Integer
Dim draw As Object
Dim shapeType As String
2019-10-18 18:56:22 +03:00
Dim embeededObject As Object
2019-10-17 18:48:22 +03:00
drawPages = ThisComponent.DrawPage
Dim i As Long
Dim badDrawings() As Object
Dim badFrames() As Object
2019-10-17 18:48:22 +03:00
count = drawPages.getCount()
For i = 0 to count - 1
2019-10-17 18:48:22 +03:00
draw = drawPages.getByIndex(i)
shapeType = draw.ShapeType
If InStr(shapeType,&quot;com.sun.star.drawing&quot;) = 1 Then
addToArray(badDrawings, draw.Anchor)
2019-10-17 18:48:22 +03:00
EndIf
2019-10-18 18:56:22 +03:00
If InStr(shapeType,&quot;FrameShape&quot;) = 1 Then
2019-10-21 13:25:47 +03:00
If draw.supportsService(&quot;com.sun.star.text.TextEmbeddedObject&quot;) Then
embeededObject = draw.getEmbeddedObject()
2020-01-13 16:08:46 +01:00
If IsNull(embeededObject) Then
addToArray(badFrames, draw.Anchor)
2019-10-21 13:25:47 +03:00
Else
2020-01-13 16:08:46 +01:00
If Not embeededObject.supportsService(&quot;com.sun.star.formula.FormulaProperties&quot;) Then
addToArray(badFrames, draw.Anchor)
2020-01-13 16:08:46 +01:00
Else
&apos;Formula
EndIf
2019-10-21 13:25:47 +03:00
EndIf
2019-10-18 18:56:22 +03:00
EndIf
EndIf
2019-10-17 18:48:22 +03:00
Next i
checkGraphics = false
If UBound(badDrawings) &gt; -1 Then
startNavigatorDialog(getTranslation(&quot;validationBadDrawings&quot;) &amp; (UBound(badDrawings) + 1) &amp; getTranslation(&quot;validationExcerptNotSuitable&quot;),badDrawings)
checkGraphics = true
2019-10-18 18:56:22 +03:00
EndIf
If UBound(badFrames) &gt; -1 Then
startNavigatorDialog(getTranslation(&quot;validationBadEmbeededObjects&quot;) &amp; (UBound(badFrames) + 1) &amp; getTranslation(&quot;validationExcerptNotSuitable&quot;),badFrames)
checkGraphics = true
2019-10-17 18:48:22 +03:00
EndIf
End Function
2020-12-09 12:00:05 +01:00
Private Sub fixDOI
StartTracking
replaceCharsInDOI
StopTracking
End Sub
Sub replaceCharsInDOI
AskAndReplace(&quot;(?&lt;=DOI[0-9. /XVI:ХOО?-]{1,50})[Х]{1,5}&quot;,&quot;X&quot;)
AskAndReplace(&quot;(?&lt;=DOI[0-9. /XVI:ХOО?-]{1,50})[OО]{1,5}&quot;,&quot;0&quot;)
AskAndReplace(&quot;(?&lt;=DOI[0-9. /XVI:ХOО?-]{1,50})[‒–—−]{1,5}&quot;,&quot;-&quot;)
End sub
Private Function noteSignsCheck() As Boolean
2019-10-17 00:31:08 +03:00
Dim footnotes As Object
2020-07-03 15:47:47 +02:00
Dim footnote As Object
Dim endnote As Object
Dim endnotes As Object
2019-10-17 00:31:08 +03:00
Dim count as Integer
Dim charNum as Long
Dim char As Long
Dim label As String
Dim result As String
Dim founds() As Object
noteSignsCheck = false
2019-10-17 00:31:08 +03:00
result = &quot;&quot;
footnotes = ThisComponent.Footnotes
endnotes = ThisComponent.Endnotes
2019-10-17 00:31:08 +03:00
count = footnotes.getCount
2020-03-21 12:37:32 +01:00
Dim i As Integer
Dim j As Integer
2019-10-17 00:31:08 +03:00
For i = 0 to count-1
footnote = footnotes.getByIndex(i)
label = footnote.Label
charNum = Len(label)
For j = 1 to charNum
char = Asc(Right(Left(label,j),1))
If char &gt;= 57344 AND char &lt;= 63743 Then
addToArray(founds,footnote.Anchor)
&apos;result = result &amp; getTranslation(&quot;validateFootnotes1&quot;) &amp; &quot; &quot; &amp; Chr(char) &amp; &quot; &quot; &amp; getTranslation(&quot;validateFootnotes2&quot;) &amp; &quot; &quot; &amp; i &amp; &quot; &quot; &amp; getTranslation(&quot;validateFootnotes3&quot;) &amp; chr(10)
2019-10-17 00:31:08 +03:00
End If
Next j
Next i
2020-07-03 15:47:47 +02:00
count = endnotes.getCount
For i = 0 to count-1
endnote = endnotes.getByIndex(i)
label = endnote.Label
charNum = Len(label)
For j = 1 to charNum
char = Asc(Right(Left(label,j),1))
If char &gt;= 57344 AND char &lt;= 63743 Then
addToArray(founds,endnote.Anchor)
&apos;result = result &amp; getTranslation(&quot;validateFootnotes1&quot;) &amp; &quot; &quot; &amp; Chr(char) &amp; &quot; &quot; &amp; getTranslation(&quot;validateEndnotes1&quot;) &amp; &quot; &quot; &amp; i &amp; &quot; &quot; &amp; getTranslation(&quot;validateFootnotes3&quot;) &amp; chr(10)
2020-07-03 15:47:47 +02:00
End If
Next j
Next i
If (UBound(founds) &gt; -1) Then
noteSignsCheck = true
MsgBox(getTranslation(&quot;validationBadFootnotesSymbolsNotification&quot;))
startNavigatorDialog(getTranslation(&quot;badNoteSings&quot;),founds)
EndIf
&apos;noteSignsCheck = result
2019-10-17 18:48:22 +03:00
End Function
2019-10-16 15:42:48 +03:00
Function checkNotesOutline As Boolean
Dim footNotes As Object
2020-07-06 09:43:46 +02:00
Dim endNotes As Object
Dim x As Long
Dim aNote As Object
Dim oEnum As Object
Dim oCurPar As Object
&apos; Dim result As String
Dim founds() As Object
&apos; result = &quot;&quot;
footNotes = thisComponent.footNotes
2020-07-03 16:58:00 +02:00
endNotes = thisComponent.EndNotes
for x = 0 to footNotes.Count -1
aNote = footNotes.getByIndex(x)
aNote.Anchor.CharStyleName=&quot;Footnote anchor&quot;
oEnum = aNote.Text.createEnumeration()
Do While oEnum.hasMoreElements()
oCurPar = oEnum.nextElement()
If oCurPar.OutlineLevel &gt; 0 Then
addToArray(founds,oCurPar)
&apos; result = result &amp; getTranslation(&quot;validateFootnotes2&quot;) &amp; &quot; &quot; &amp; x &amp; &quot; &quot; &amp; getTranslation(&quot;setOutlineLevel&quot;) &amp; &quot; &quot; &amp; oCurPar.OutlineLevel &amp; chr(10)
EndIf
Loop
Next
for x = 0 to endNotes.Count -1
aNote = endNotes.getByIndex(x)
aNote.Anchor.CharStyleName=&quot;Footnote anchor&quot;
oEnum = aNote.Text.createEnumeration()
Do While oEnum.hasMoreElements()
oCurPar = oEnum.nextElement()
If oCurPar.OutlineLevel &gt; 0 Then
addToArray(founds,oCurPar)
&apos; result = result &amp; getTranslation(&quot;validateEndnotes1&quot;) &amp; &quot; &quot; &amp; x &amp; &quot; &quot; &amp; getTranslation(&quot;setOutlineLevel&quot;) &amp; &quot; &quot; &amp; oCurPar.OutlineLevel &amp; chr(10)
EndIf
Loop
Next
If (UBound(founds) &gt; -1) Then
startNavigatorDialog(getTranslation(&quot;badHeadingsInFootnotes&quot;),founds)
checkNotesOutline = true
Else
checkNotesOutline = false
EndIf
End Function
Function checkSectionsInTables As Boolean
2020-07-06 09:43:46 +02:00
Dim x As Integer
Dim oEnum As Object
&apos;Dim result As String
2020-07-06 09:43:46 +02:00
Dim sections As Object
Dim section As Object
Dim anchor As Object
Dim anchorText As Object
Dim badSections() As Object
2020-07-06 09:43:46 +02:00
result = &quot;&quot;
sections = thisComponent.TextSections
for x = 0 to sections.Count -1
section = sections.getByIndex(x)
anchor = section.getAnchor()
anchorText = anchor.getText()
If anchorText.supportsService(&quot;com.sun.star.text.CellProperties&quot;) Then
addToArray(badSections(),anchor)
&apos;result = result &amp; getTranslation(&quot;section&quot;) &amp; &quot; &quot; &amp; section.Name &amp; &quot; &quot; &amp; getTranslation(&quot;isInTable&quot;) &amp; chr(10)
2020-07-06 09:43:46 +02:00
EndIf
Next
If (UBound(badSections) &gt; -1) Then
checkSectionsInTables = true
startNavigatorDialog(getTranslation(&quot;badSectionsInTables&quot;),badSections)
Else
checkSectionsInTables = false
EndIf
2020-07-06 09:43:46 +02:00
End Function
Function checkHeadingsInHeadersFooters As String
Dim result As String
Dim count As Integer
Dim oStyle As Object
Dim i As Integer
result = &quot;&quot;
Dim pageStyles As Object
pageStyles = ThisComponent.StyleFamilies.getByName(&quot;PageStyles&quot;)
count = pageStyles.count - 1
For i = 0 to count
oStyle = pageStyles.getByIndex(i)
If oStyle.isInUse Then
If oStyle.HeaderIsOn Then
If oStyle.HeaderIsShared Then
If isHeadingsInText(oStyle.HeaderText) Then
result = result &amp; getTranslation(&quot;foundHeadingIn&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inHeader&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inPageStyle&quot;) &amp; &quot; &quot; &amp; oStyle.getName() &amp; chr(10)
EndIf
Else
If isHeadingsInText(oStyle.HeaderTextLeft) Then
result = result &amp; getTranslation(&quot;foundHeadingIn&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inHeader&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inPageStyle&quot;) &amp; &quot; &quot; &amp; oStyle.getName() &amp; chr(10)
EndIf
If isHeadingsInText(oStyle.HeaderTextRight) Then
result = result &amp; getTranslation(&quot;foundHeadingIn&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inHeader&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inPageStyle&quot;) &amp; &quot; &quot; &amp; oStyle.getName() &amp; chr(10)
EndIf
EndIf
If NOT oStyle.FirstIsShared Then
If isHeadingsInText(oStyle.HeaderTextFirst) Then
result = result &amp; getTranslation(&quot;foundHeadingIn&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inHeader&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inPageStyle&quot;) &amp; &quot; &quot; &amp; oStyle.getName() &amp; chr(10)
EndIf
EndIf
EndIf
If oStyle.FooterIsOn Then
If oStyle.FooterIsShared Then
If isHeadingsInText(oStyle.FooterText) Then
result = result &amp; getTranslation(&quot;foundHeadingIn&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inFooter&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inPageStyle&quot;) &amp; &quot; &quot; &amp; oStyle.getName() &amp; chr(10)
EndIf
Else
If isHeadingsInText(oStyle.FooterTextLeft) Then
result = result &amp; getTranslation(&quot;foundHeadingIn&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inFooter&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inPageStyle&quot;) &amp; &quot; &quot; &amp; oStyle.getName() &amp; chr(10)
EndIf
If isHeadingsInText(oStyle.FooterTextRight) Then
result = result &amp; getTranslation(&quot;foundHeadingIn&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inFooter&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inPageStyle&quot;) &amp; &quot; &quot; &amp; oStyle.getName() &amp; chr(10)
EndIf
EndIf
If NOT oStyle.FirstIsShared Then
If isHeadingsInText(oStyle.FooterTextFirst) Then
result = result &amp; getTranslation(&quot;foundHeadingIn&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inFooter&quot;) &amp; &quot; &quot; &amp; getTranslation(&quot;inPageStyle&quot;) &amp; &quot; &quot; &amp; oStyle.getName() &amp; chr(10)
EndIf
EndIf
EndIf
EndIf
Next i
checkHeadingsInHeadersFooters = result
End Function
Function checkHeadingsInTextTables() As Boolean
2020-07-06 11:39:01 +02:00
Dim enum1Element As Object
Dim enum1 As Object
Dim enum2 As Object
Dim thisPortion As Object
Dim footnoteText As Object
Dim label As String
Dim labelNum As Integer
Dim i As Integer
Dim count As Integer
Dim cell As Object
Dim cellText As Object
Dim firstCellName As String
Dim founds() As Object
2020-07-06 11:39:01 +02:00
enum1 = ThisComponent.Text.createEnumeration
While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.TextTable&quot;) Then
firstCellName = enum1Element.getCellByPosition(0,0).cellName
cellNames = enum1Element.cellNames
For i = LBound(cellNames) To Ubound(cellNames)
cell = enum1Element.getCellByName(cellNames(i))
cellText = cell.getText()
If cellNames(i) = firstCellName Then
addHeadingNotFirstInText(cellText,founds)
2020-07-06 11:39:01 +02:00
Else
addHeadingsInText(cellText,founds)
2020-07-06 11:39:01 +02:00
EndIf
Next i
EndIf
Wend
If (UBound(founds) &gt; -1) Then
checkHeadingsInTextTables = true
startNavigatorDialog(getTranslation(&quot;badHeadingsInTables&quot;),founds)
Else
checkHeadingsInTextTables = false
EndIf
2020-07-06 11:39:01 +02:00
End Function
Sub addHeadingNotFirstInText(oText As Object, founds() As Object)
Dim enum1Element As Object
Dim enum1 As Object
Dim enum2 As Object
Dim thisPortion As Object
Dim footnoteText As Object
Dim label As String
Dim labelNum As Integer
Dim i As Integer
Dim count As Integer
Dim cell As Object
Dim cellText As Object
Dim first As Boolean
first = true
enum1 = oText.createEnumeration
While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
If Not first Then
If enum1Element.OutlineLevel &gt; 0 Then
addToArray(founds,enum1Element)
EndIf
EndIf
ElseIf enum1Element.supportsService(&quot;com.sun.star.text.TextTable&quot;) Then
cellNames = enum1Element.cellNames
For i = LBound(cellNames) To Ubound(cellNames)
cell = enum1Element.getCellByName(cellNames(i))
cellText = cell.getText()
addHeadingsInText(cellText,founds)
Next i
EndIf
first = false
Wend
End Sub
Sub addHeadingsInText(oText As Object, founds() As Object)
Dim enum1Element As Object
Dim enum1 As Object
Dim enum2 As Object
Dim thisPortion As Object
Dim footnoteText As Object
Dim label As String
Dim labelNum As Integer
Dim i As Integer
Dim count As Integer
Dim cell As Object
Dim cellText As Object
enum1 = oText.Text.createEnumeration
While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
If enum1Element.OutlineLevel &gt; 0 Then
addToArray(founds,enum1Element)
EndIf
ElseIf enum1Element.supportsService(&quot;com.sun.star.text.TextTable&quot;) Then
cellNames = enum1Element.cellNames
For i = LBound(cellNames) To Ubound(cellNames)
cell = enum1Element.getCellByName(cellNames(i))
cellText = cell.getText()
addHeadingsInText(cellText,founds)
Next i
EndIf
Wend
End Sub
2020-07-06 11:39:01 +02:00
Function isHeadingNotFirstInText(oText As Object) As Boolean
Dim enum1Element As Object
Dim enum1 As Object
Dim enum2 As Object
Dim thisPortion As Object
Dim footnoteText As Object
Dim label As String
Dim labelNum As Integer
Dim i As Integer
Dim count As Integer
Dim cell As Object
Dim cellText As Object
Dim first As Boolean
first = true
enum1 = oText.createEnumeration
While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
If Not first Then
If enum1Element.OutlineLevel &gt; 0 Then
isHeadingNotFirstInText = true
Exit Function
EndIf
EndIf
ElseIf enum1Element.supportsService(&quot;com.sun.star.text.TextTable&quot;) Then
cellNames = enum1Element.cellNames
For i = LBound(cellNames) To Ubound(cellNames)
cell = enum1Element.getCellByName(cellNames(i))
cellText = cell.getText()
If isHeadingsInText(cellText) Then
isHeadingNotFirstInText = true
Exit Function
EndIf
Next i
EndIf
first = false
Wend
isHeadingNotFirstInText = false
End Function
Function isHeadingsInText(oText As Object) As Boolean
Dim enum1Element As Object
Dim enum1 As Object
Dim enum2 As Object
Dim thisPortion As Object
Dim footnoteText As Object
Dim label As String
Dim labelNum As Integer
Dim i As Integer
Dim count As Integer
Dim cell As Object
Dim cellText As Object
enum1 = oText.Text.createEnumeration
While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
If enum1Element.OutlineLevel &gt; 0 Then
isHeadingsInText = true
Exit Function
EndIf
ElseIf enum1Element.supportsService(&quot;com.sun.star.text.TextTable&quot;) Then
cellNames = enum1Element.cellNames
For i = LBound(cellNames) To Ubound(cellNames)
cell = enum1Element.getCellByName(cellNames(i))
cellText = cell.getText()
If isHeadingsInText(cellText) Then
isHeadingsInText = true
Exit Function
EndIf
Next i
EndIf
Wend
isHeadingsInText = false
End Function
Function hasBrokenCharBackTransparent As Boolean
Dim footNotes As Object
Dim endNotes As Object
Dim i As Long
Dim oStyles As Object
Dim pageStyles As Object
Dim pageStyle As Object
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(ThisComponent.Text)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
footNotes = ThisComponent.FootNotes
For i = 0 to footNotes.getCount - 1
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(footNotes.getByIndex(i).Text)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
Next i
endNotes = thisComponent.footNotes
For i = 0 to footNotes.Count -1
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(endNotes.getByIndex(i).Text)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
Next i
oStyles = ThisComponent.StyleFamilies
pageStyles = oStyles.getByName(oStyles.elementNames(2))
For i = 0 to pageStyles.Count -1
pageStyle = pageStyles.getByIndex(i)
If Not IsEmpty(pageStyle.FooterText) Then
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(pageStyle.FooterText)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
EndIf
If Not IsEmpty(pageStyle.FooterTextFirst) Then
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(pageStyle.FooterTextFirst)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
EndIf
If Not IsEmpty(pageStyle.FooterTextRight) Then
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(pageStyle.FooterTextRight)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
EndIf
If Not IsEmpty(pageStyle.FooterTextLeft) Then
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(pageStyle.FooterTextLeft)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
EndIf
If Not IsEmpty(pageStyle.HeaderText) Then
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(pageStyle.HeaderText)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
EndIf
If Not IsEmpty(pageStyle.HeaderTextFirst) Then
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(pageStyle.HeaderTextFirst)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
EndIf
If Not IsEmpty(pageStyle.HeaderTextRight) Then
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(pageStyle.HeaderTextRight)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
EndIf
If Not IsEmpty(pageStyle.HeaderTextLeft) Then
2021-07-26 12:58:33 +02:00
hasBrokenCharBackTransparent = isManualCharBackTransparentInTextParas(pageStyle.HeaderTextLeft)
If (hasBrokenCharBackTransparent) Then
Exit Function
EndIf
EndIf
Next i
End Function
2021-07-26 12:58:33 +02:00
Function isManualCharBackTransparent(para As Object) As Boolean
Dim styleName As String
Dim paraStyles As Object
isManualCharBackTransparent = false
If para.CharBackTransparent = false Then
styleName = para.ParaStyleName
paraStyles = ThisComponent.StyleFamilies.getByName(&quot;ParagraphStyles&quot;)
paraStyle = paraStyles.GetByName(styleName)
If paraStyle.CharBackTransparent = true Then
isManualCharBackTransparent = true
EndIf
EndIf
End Function
2021-07-26 12:58:33 +02:00
Function isManualCharBackTransparentInTextParas(oText As Object) As Boolean
Dim enum1Element As Object
Dim enum1 As Object
Dim enum2 As Object
Dim thisPortion As Object
Dim footnoteText As Object
Dim label As String
Dim labelNum As Integer
Dim i As Integer
Dim count As Integer
Dim cell As Object
Dim cellText As Object
enum1 = oText.Text.createEnumeration
While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
2021-07-26 12:58:33 +02:00
If isManualCharBackTransparent(enum1Element) Then
isManualCharBackTransparentInTextParas = true
Exit Function
EndIf
ElseIf enum1Element.supportsService(&quot;com.sun.star.text.TextTable&quot;) Then
cellNames = enum1Element.cellNames
For i = LBound(cellNames) To Ubound(cellNames)
cell = enum1Element.getCellByName(cellNames(i))
cellText = cell.getText()
2021-07-26 12:58:33 +02:00
If isManualCharBackTransparentInTextParas(cellText) Then
isManualCharBackTransparentInTextParas = true
Exit Function
EndIf
Next i
EndIf
Wend
2021-07-26 12:58:33 +02:00
isManualCharBackTransparentInTextParas = false
End Function
2021-05-29 14:32:18 +02:00
Function printNumberingSymbols(needExtendedInfo) As Boolean
2020-03-06 17:37:35 +01:00
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
2020-03-21 12:37:32 +01:00
Dim excerpt As String
Dim exLength As Integer
Dim report As String
Dim k As Integer
2021-05-29 14:32:18 +02:00
printNumberingSymbols = false
2020-03-06 17:37:35 +01:00
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
2020-03-18 22:14:07 +01:00
If fontChar &lt;&gt; &quot;&quot; Then
2021-05-29 14:32:18 +02:00
tmp = numRules.Name &amp;&quot; &quot;&amp; getTranslation(&quot;validateNumberingLevel&quot;) &amp;&quot; &quot; &amp; (j + 1) &amp; &quot; &quot; &amp; getTranslation(&quot;validateNumberingFont&quot;) &amp; &quot; &quot; &amp; fontName &amp; &quot; &quot; &amp; getTranslation(&quot;validateNumberingSymbol&quot;) &amp; &quot; &quot; &amp; fontChar &amp; &quot; (&quot; &amp; Hex(Asc(fontChar)) &amp; &quot;) &quot;&amp; Left(excerpt,exLength) &amp; chr(10)
2020-03-18 22:14:07 +01:00
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
2020-03-06 17:37:35 +01:00
EndIf
EndIf
EndIf
EndIf
Loop
2020-03-21 12:37:32 +01:00
2020-03-06 17:37:35 +01:00
report = &quot;&quot;
If result = &quot;&quot; AND resultBad = &quot;&quot; Then
2021-05-29 14:32:18 +02:00
Exit Function
Else
printNumberingSymbols = true
2020-03-06 17:37:35 +01:00
If resultBad &lt;&gt; &quot;&quot; Then
2020-05-04 15:52:04 +02:00
report = getTranslation(&quot;validateNumberingsReportSymbols&quot;) &amp; chr(10) &amp; resultBad
2020-03-06 17:37:35 +01:00
EndIf
If result &lt;&gt; &quot;&quot; Then
2020-05-04 15:52:04 +02:00
report = report &amp; getTranslation(&quot;validateNumberingsReportFonts&quot;) &amp; &quot; &quot;&amp; chr(10)&amp; result
2020-03-06 17:37:35 +01:00
EndIf
EndIf
MsgBox report
2021-05-29 14:32:18 +02:00
End Function
2020-03-06 17:37:35 +01:00
2019-10-17 00:31:08 +03:00
Private Sub showTrackedChanges
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
dispatcher.executeDispatch(document, &quot;.uno:AcceptTrackedChanges&quot;, &quot;&quot;, 0, Array())
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = &quot;ShowTrackedChanges&quot;
args2(0).Value = true
dispatcher.executeDispatch(document, &quot;.uno:ShowTrackedChanges&quot;, &quot;&quot;, 0, args2())
end Sub
Private Sub StartTracking
2020-03-21 12:37:32 +01:00
Dim dispatcher As Object
Dim document As Object
2019-10-17 00:31:08 +03:00
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
document = ThisComponent.CurrentController.Frame
dim trackProperties(0) as new com.sun.star.beans.PropertyValue
trackProperties(0).Name = &quot;TrackChanges&quot;
trackProperties(0).Value = true
dispatcher.executeDispatch(document, &quot;.uno:TrackChanges&quot;, &quot;&quot;, 0, trackProperties())
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = &quot;ShowTrackedChanges&quot;
args1(0).Value = true
dispatcher.executeDispatch(document, &quot;.uno:ShowTrackedChanges&quot;, &quot;&quot;, 0, args1())
End Sub
Private Sub StopTracking
2020-03-21 12:37:32 +01:00
Dim dispatcher As Object
Dim document As Object
2019-10-17 00:31:08 +03:00
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
document = ThisComponent.CurrentController.Frame
2020-03-21 12:37:32 +01:00
Dim trackProperties(0) as new com.sun.star.beans.PropertyValue
2019-10-17 00:31:08 +03:00
trackProperties(0).Name = &quot;TrackChanges&quot;
trackProperties(0).Value = false
dispatcher.executeDispatch(document, &quot;.uno:TrackChanges&quot;, &quot;&quot;, 0, trackProperties())
2020-03-21 12:37:32 +01:00
Dim args1(0) as new com.sun.star.beans.PropertyValue
2019-10-17 00:31:08 +03:00
args1(0).Name = &quot;ShowTrackedChanges&quot;
args1(0).Value = true
dispatcher.executeDispatch(document, &quot;.uno:ShowTrackedChanges&quot;, &quot;&quot;, 0, args1())
End Sub
2020-04-23 14:15:18 +02:00
2020-07-12 14:55:40 +02:00
Dim fontDialog As Object
Sub fontReportButton
Dim fontNames() As String
Dim listBox As Object
Dim description As Object
Dim statusIndicator as Object
statusIndicator = ThisComponent.getCurrentController.statusIndicator
statusIndicator.Start(getTranslation(&quot;fontReportInProgress&quot;),100)
fontNames = getODGFontNames()
DialogLibraries.LoadLibrary(&quot;Redaction&quot;)
fontDialog = CreateUnoDialog( DialogLibraries.Redaction.ChooseFontname )
listBox = fontDialog.getControl(&quot;fontList&quot;)
listBox.addItems(fontNames , 0)
fontDialog.Title = getTranslation(&quot;chooseFontNameDialogTitle&quot;)
description = fontDialog.getControl(&quot;description&quot;)
description.SetText(getTranslation(&quot;chooseFontNameDialogDescription&quot;))
statusIndicator.setValue(50)
fontDialog.Execute()
Dim targetFontName As String
targetFontName = fontDialog.model.Tag
If targetFontName=&quot;0&quot; or targetFontName=&quot;&quot; Then
2020-07-12 16:34:42 +02:00
statusIndicator.end()
2020-07-12 14:55:40 +02:00
Exit sub
EndIf
2020-07-12 16:34:42 +02:00
Dim FileName As String
2021-10-25 21:08:07 +02:00
getCharsInFont(targetFontName)
2020-07-12 14:55:40 +02:00
statusIndicator.end()
2021-10-25 21:08:07 +02:00
2020-07-12 14:55:40 +02:00
End Sub
Sub onSelectFont(oEvent)
fontDialog.endExecute()
fontDialog.model.Tag = oEvent.ActionCommand
End Sub
Function getODGFontNames() As Variant
&apos;Globalscope.BasicLibraries.LoadLibrary( &quot;MRILib&quot; )
2020-07-12 14:55:40 +02:00
Dim fontNames() As String
Dim pages As Object
Dim pageCount As Long
Dim page As Object
Dim elementCount As Long
Dim groupCount As Long
2020-07-12 14:55:40 +02:00
Dim i As Long
Dim j As Long
Dim k As Long
Dim element As Object
Dim elementText As Object
Dim groupElement As Object
2020-07-12 14:55:40 +02:00
Dim enum1 As Object
Dim enum1Element As Object
Dim enum2 As Object
Dim thisPortion As Object
Dim fontChar As Long
Dim fontName As String
pages = ThisComponent.getDrawPages()
pagesCount = pages.getCount()
For i = 0 To pagesCount - 1
page = pages.getByIndex(i)
elementCount = page.getCount()
For j = 0 To elementCount - 1
element = page.getByIndex(j)
2020-07-26 11:21:47 +02:00
If element.supportsService(&quot;com.sun.star.drawing.Text&quot;) Then
elementText = element.getText()
enum1 = elementText.createEnumeration()
While enum1.hasMoreElements
2020-07-12 14:55:40 +02:00
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
enum2 = enum1Element.createEnumeration
While enum2.hasMoreElements
thisPortion = enum2.nextElement
2020-07-12 16:34:42 +02:00
If Len(thisPortion.String) &gt; 0 Then
fontName = thisPortion.CharFontName
If NOT fontIsAlreadyFound(fontNames, fontName) Then
2020-07-12 14:55:40 +02:00
AddToArray(fontNames, fontName)
2020-07-12 16:34:42 +02:00
EndIf
2020-07-12 14:55:40 +02:00
EndIf
Wend
EndIf
2020-07-26 11:21:47 +02:00
Wend
EndIf
If element.supportsService(&quot;com.sun.star.drawing.GroupShape&quot;) Then
groupCount = element.getCount()
For k = 0 To groupCount - 1
groupElement = element.getByIndex(k)
If groupElement.supportsService(&quot;com.sun.star.drawing.Text&quot;) Then
elementText = groupElement.getText()
enum1 = elementText.createEnumeration()
While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
enum2 = enum1Element.createEnumeration
While enum2.hasMoreElements
thisPortion = enum2.nextElement
If Len(thisPortion.String) &gt; 0 Then
fontName = thisPortion.CharFontName
If NOT fontIsAlreadyFound(fontNames, fontName) Then
AddToArray(fontNames, fontName)
EndIf
EndIf
Wend
EndIf
Wend
EndIf
Next k
EndIf
2020-07-12 14:55:40 +02:00
Next j
Next i
getODGFontNames = fontNames
End Function
Function fontIsAlreadyFound(fontNames() As String, proposeName As String) As Boolean
If IsEmpty(fontNames) Then
fontIsAlreadyFound = false
Exit Function
EndIf
If getIndex(fontNames(), proposeName) &gt; -1 Then
fontIsAlreadyFound = True
Exit Function
EndIf
fontIsAlreadyFound = False
End Function
Function IsInArray(array, content)
IsInArray = false
For i = LBound(array) To UBound(array)
inArr = array(i)
If inArr = content Then
IsInArray = true
EndIf
Next i
End Function
Function getIndex(array As variant, value As variant) As Integer
Dim id As Integer
Dim nRight As Integer
Dim nLen As Integer
id = 0
nRight = uBound(array)
nLen = len(value)
while id &lt;= nRight
If array(id) = value Then
getIndex = id
exit Function
Else
id = id + 1
end if
wend
getIndex = -1
End Function
Sub addToArray(xArray(),vNextElement)
Dim iUB As Integer
Dim iLB As Integer
iLB = lBound(xArray())
iUB = uBound(xArray())
If iLB &gt; iUB then
iUB = iLB
redim xArray(iLB To iUB)
Else
iUB = iUB +1
redim preserve xArray(iLB To iUB)
Endif
xArray(iUB) = vNextElement
End Sub
2021-10-25 21:08:07 +02:00
Sub getCharsInFont(fontName As String)
2020-07-12 14:55:40 +02:00
Dim resultArray() As String
2020-07-12 16:34:42 +02:00
Dim pageNums() As Long
2020-07-12 14:55:40 +02:00
Dim firstPages() As Long
Dim resultString As String
Dim pages As Object
Dim pageCount As Long
Dim page As Object
Dim elementCount As Long
Dim i As Long
Dim j As Long
Dim k As Long
Dim element As Object
Dim elementText As Object
Dim enum1 As Object
Dim enum1Element As Object
Dim enum2 As Object
Dim thisPortion As Object
Dim fontChar As String
Dim groupCount As Long
Dim groupElement As Object
Dim charString As String
Dim charNum As Long
2020-07-12 14:55:40 +02:00
pages = ThisComponent.getDrawPages()
pagesCount = pages.getCount()
For i = 0 To pagesCount - 1
page = pages.getByIndex(i)
elementCount = page.getCount()
For j = 0 To elementCount - 1
element = page.getByIndex(j)
2020-07-26 11:21:47 +02:00
If element.supportsService(&quot;com.sun.star.drawing.Text&quot;) Then
elementText = element.getText()
enum1 = elementText.createEnumeration()
While enum1.hasMoreElements
2020-07-12 14:55:40 +02:00
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
enum2 = enum1Element.createEnumeration
While enum2.hasMoreElements
thisPortion = enum2.nextElement
If thisPortion.CharFontName = fontName Then
resultString = thisPortion.String
For k = 0 To Len(resultString) - 1
charString = Mid(resultString,k+1,1)
charNum = Asc(charString)
fontChar = Hex(charNum)
2020-07-12 14:55:40 +02:00
If NOT IsInArray(resultArray,fontChar) Then
AddToArray(resultArray(), fontChar)
2020-07-12 16:34:42 +02:00
AddToArray(pageNums(), i + 1)
2020-07-12 14:55:40 +02:00
EndIf
Next k
EndIf
Wend
EndIf
2020-07-26 11:21:47 +02:00
Wend
EndIf
If element.supportsService(&quot;com.sun.star.drawing.GroupShape&quot;) Then
groupCount = element.getCount()
For k = 0 To groupCount - 1
groupElement = element.getByIndex(k)
If groupElement.supportsService(&quot;com.sun.star.drawing.Text&quot;) Then
elementText = groupElement.getText()
enum1 = elementText.createEnumeration()
While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
enum2 = enum1Element.createEnumeration
While enum2.hasMoreElements
thisPortion = enum2.nextElement
If thisPortion.CharFontName = fontName Then
resultString = thisPortion.String
For k = 0 To Len(resultString) - 1
fontChar = Hex(Asc(Mid(resultString,k+1,1)))
If NOT IsInArray(resultArray,fontChar) Then
AddToArray(resultArray(), fontChar)
AddToArray(pageNums(), i + 1)
EndIf
Next k
EndIf
Wend
EndIf
Wend
EndIf
Next k
EndIf
2020-07-12 14:55:40 +02:00
Next j
Next i
If resultString &lt;&gt; &quot;&quot; Then
2021-10-25 21:08:07 +02:00
Dim newDocCursor As Object
Dim newDoc As Object
newDoc = starDesktop.loadComponentFromURL(&quot;private:factory/swriter&quot;, &quot;_blank&quot;, 0, Array())
newDocCursor = newDoc.getCurrentController().getViewCursor()
newDocCursor.String = getTranslation(&quot;symbolsInFontHeading&quot;) &amp; &quot; &quot; &amp; fontName
newDocCursor.ParaStyleName = &quot;Heading 1&quot;
newDocCursor.collapseToEnd()
newDocCursor.Text.insertControlCharacter(newDocCursor.End,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
For i = LBound(resultArray) To UBound(resultArray)
newDocCursor.ParaStyleName = &quot;Text body&quot;
newDocCursor.String = &quot;https://unicode-table.com/ru/&quot; &amp; resultArray(i)
newDocCursor.HyperLinkURL = &quot;https://unicode-table.com/ru/&quot; &amp; resultArray(i)
newDocCursor.collapseToEnd()
newDocCursor.String = &quot; &quot; &amp; getTranslation(&quot;charFirstPage&quot;) &amp; &quot; &quot; &amp; pageNums(i)
newDocCursor.collapseToEnd()
newDocCursor.Text.insertControlCharacter(newDocCursor.End,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
Next i
Exit Sub
2020-07-12 16:34:42 +02:00
2020-07-12 14:55:40 +02:00
Else
2020-07-12 16:34:42 +02:00
MsgBox getTranslation(&quot;symbolsInFontNotFound1&quot;) &amp; &quot; &quot; &amp; fontName &amp; &quot; &quot; &amp; getTranslation(&quot;symbolsInFontNotFound2&quot;)
2020-07-12 14:55:40 +02:00
EndIf
2021-10-25 21:08:07 +02:00
End Sub
2020-07-12 16:34:42 +02:00
Function findBadCharacters() As Boolean
Dim founds As Object
Dim foundObjects() As Object
founds = findInDoc(&quot;[\uE000-\uF8FF]+&quot;)
findBadCharacters = false
If founds.count &lt;&gt; 0 Then
&apos;MsgBox getTranslation(&quot;validationBadSymbolsNotification&quot;)
foundObjects = convertXIndexAccessToArray(founds)
startNavigatorDialog(getTranslation(&quot;badSymbols&quot;),foundObjects)
findBadCharacters = true
EndIf
End Function
2021-06-04 22:28:27 +02:00
Function findColoredBackgroundInDoc() As Boolean
2021-06-04 20:42:13 +02:00
Dim founds As Object
Dim sDesc As Object
Dim foundObjects() As Object
2021-06-04 20:42:13 +02:00
Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
SrchAttributes(0).Name = &quot;CharBackTransparent&quot;
SrchAttributes(0).Value = False
sDesc = Thiscomponent.createSearchDescriptor()
sDesc.SearchAll = true
sDesc.ValueSearch = false
sDesc.SearchRegularExpression = true
sDesc.searchStyles = true
sDesc.SetSearchAttributes(SrchAttributes())
founds = Thiscomponent.findAll(sDesc)
2021-06-04 22:28:27 +02:00
findColoredBackgroundInDoc = false
2021-06-04 20:42:13 +02:00
If founds.count &lt;&gt; 0 Then
2021-06-04 22:28:27 +02:00
MsgBox getTranslation(&quot;foundColoredTextMessage&quot;)
foundObjects = convertXIndexAccessToArray(founds)
startNavigatorDialog(getTranslation(&quot;coloredTextDescription&quot;),foundObjects)
2021-06-04 22:28:27 +02:00
findColoredBackgroundInDoc = true
2021-06-04 20:42:13 +02:00
EndIf
2021-06-04 22:28:27 +02:00
End Function
2021-06-04 20:42:13 +02:00
Sub startNavigatorDialog(objectsDescription As String,foundObjects() As Object)
2021-06-04 20:42:13 +02:00
Dim dialog As Object
Dim leftImageURL As String
Dim rightImageURL As String
2021-06-04 22:28:27 +02:00
Dim curNum As Long
Dim maxNum As Long
Dim found As Object
2021-06-04 20:42:13 +02:00
waitingForDialog = true
maxNum = UBound(foundObjects)
2021-06-04 20:42:13 +02:00
dialog = notModalDialog(&quot;Navigator&quot;)
2021-06-04 22:28:27 +02:00
dialog.getControl(&quot;found&quot;).SetText(getTranslation(&quot;navigatorFound&quot;) &amp; CStr(maxNum+1))
curNum = 0
found = foundObjects(curNum)
2021-06-04 22:28:27 +02:00
dialog.getControl(&quot;current&quot;).SetText(CStr(curNum+1))
dialog.getControl(&quot;description&quot;).SetText(objectsDescription)
2021-06-04 20:42:13 +02:00
&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;)
rightImageURL = convertToURL(getExtensionPath() &amp; &quot;/images/right-navigator.svg&quot;)
dialog.getControl(&quot;prev&quot;).model.imageURL = leftImageURL
&apos;dialog.getControl(&quot;prev&quot;).model.ScaleMode = 2
dialog.getControl(&quot;next&quot;).model.imageURL = rightImageURL
&apos;dialog.getControl(&quot;next&quot;).model.ScaleMode = 2
dialog.setvisible(true)
&apos;select first found &apos;
&apos;not using view cursor as if shape was prevously selected runtime exception will appear
Thiscomponent.CurrentController.select(found)
2021-06-04 20:42:13 +02:00
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
2021-06-04 22:28:27 +02:00
curNum = getPrevFound(curNum, maxNum)
found = foundObjects(curNum)
Thiscomponent.CurrentController.select(found)
2021-06-04 22:28:27 +02:00
dialog.getControl(&quot;current&quot;).SetText(CStr(curNum+1))
dialog.getControl(&quot;prev&quot;).model.state = 0
2021-06-04 20:42:13 +02:00
EndIf
If dialog.getControl(&quot;next&quot;).model.state = 1 then
2021-06-04 22:28:27 +02:00
curNum = getNextFound(curNum, maxNum)
found = foundObjects(curNum)
Thiscomponent.CurrentController.select(found)
2021-06-04 22:28:27 +02:00
dialog.getControl(&quot;current&quot;).SetText(CStr(curNum+1))
dialog.getControl(&quot;next&quot;).model.state = 0
2021-06-04 20:42:13 +02:00
EndIf
wait (100)
Loop
dialog.dispose
End Sub
Function convertXIndexAccessToArray(founds As Object) As Variant
Dim i As Integer
Dim maxNum As Integer
Dim arrayOfObjects() As Object
maxNum = founds.count - 1
For i = 0 To maxNum
addToArray(arrayOfObjects,founds.getByIndex(i))
Next i
convertXIndexAccessToArray = arrayOfObjects
End Function
2021-06-04 22:28:27 +02:00
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
2021-06-04 20:42:13 +02:00
Function getExtensionPath() As String
Dim extensionIdentifier As String
Dim pip As Object
extensionIdentifier = &quot;pro.litvinovg.Redaction&quot;
pip = GetDefaultContext.getByName(&quot;/singletons/com.sun.star.deployment.PackageInformationProvider&quot;)
getExtensionPath = pip.getPackageLocation(extensionIdentifier)
End Function
Function notModalDialog(dialogName As String) As Variant
Dim windowProvider As Object
Dim containerWindow As Object
Dim handler As Object
Dim dialogUrl As String
Dim dialog As Object
containerWindow = ThisComponent.getCurrentController().getFrame().getContainerWindow()
dialogUrl = &quot;vnd.sun.star.script:Redaction.&quot; &amp; dialogName &amp; &quot;?location=application&quot;
windowProvider = CreateUnoService(&quot;com.sun.star.awt.ContainerWindowProvider&quot;)
dialog = windowProvider.createContainerWindow(dialogUrl, &quot;&quot;, containerWindow, handler)
notModalDialog = dialog
End Function
2020-07-12 14:55:40 +02:00
2020-07-12 16:34:42 +02:00
sub openReport(fileName As String)
dim document as object
dim dispatcher as object
Dim path As String
Dim tmpName As String
Dim oldName As String
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = &quot;URL&quot;
args1(0).Value = fileName
args1(1).Name = &quot;FilterName&quot;
args1(1).Value = &quot;HTML (StarWriter)&quot;
dispatcher.executeDispatch(document, &quot;.uno:Open&quot;, &quot;&quot;, 0, args1())
If FileExists(tmpName) Then
Kill(tmpName)
End If
End Sub
Function isInDoc(searchString As String) As Boolean
Dim founds As Variant
founds = findInDoc(searchString)
If founds.count &lt;&gt; 0 Then
isInDoc = true
Else
isInDoc = false
EndIf
End Function
Function findInDoc(searchString As String) As Variant
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.SearchCaseSensitive = true
sDesc.SearchRegularExpression = true
sDesc.SearchString = searchString
founds = Thiscomponent.findAll(sDesc)
findInDoc = founds
End Function
</script:module>