diff --git a/Redaction/Clean.xba b/Redaction/Clean.xba index dab2f94..f5fc6da 100644 --- a/Redaction/Clean.xba +++ b/Redaction/Clean.xba @@ -1,6 +1,6 @@ -Sub mark81 +Sub mark82 End Sub @@ -45,6 +45,7 @@ Private Sub makerUpMenu dialog.getControl("removeBasic").Label = getTranslation("advancedMenuRemoveBasic") dialog.getControl("resetChapterNumberingRules").Label = getTranslation("advancedMenuResetChapterNumberingRules") dialog.getControl("convertFontsToCharStyles").Label = getTranslation("advancedMenuconvertFontsToCharStyles") + dialog.getControl("fixBrokenCharBackTransparent").Label = getTranslation("fixBrokenCharBackTransparentMenuItem") dialog.getControl("Cancel").Label = getTranslation("buttonCancel") dialog.getControl("OK").Label = getTranslation("buttonOK") dialog.getControl("buttonLoad").Label = getTranslation("buttonLoad") @@ -152,6 +153,10 @@ Private Sub cleanAccordingTo(dialog As Object) If dialog.getControl("convertFontsToCharStyles").state = 1 Then convertFontsToCharStyles() EndIf + If dialog.getControl("fixBrokenCharBackTransparent").state = 1 Then + fixBrokenCharBackTransparent() + EndIf + statusIndicator.end() saveAndreload() @@ -1982,4 +1987,84 @@ Sub replaceNumHyphenRegExp AskAndReplace("(?<!DOI[0-9. /XVI:-‒–—−-]{1,50})(?<=[:digit:])(?:[:space:])?[-‒–—−](?:[:space:])?(?=[:digit:])","‒") End sub +Sub fixBrokenCharBackTransparent + Dim foonNotes As Object + Dim endNotes As Object + Dim i As Integer + Dim oStyles As Object + Dim pageStyles As Object + Dim pageStyle As Object + footNotes = thisComponent.footNotes + For i = 0 to footNotes.Count -1 + setDefaultBackColorInText(footNotes.getByIndex(i).Text) + Next i + endNotes = thisComponent.footNotes + For i = 0 to footNotes.Count -1 + setDefaultBackColorInText(endNotes.getByIndex(i).Text) + 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 + setDefaultBackColorInText(pageStyle.FooterText) + EndIf + If Not IsEmpty(pageStyle.FooterTextFirst) Then + setDefaultBackColorInText(pageStyle.FooterTextFirst) + EndIf + If Not IsEmpty(pageStyle.FooterTextRight) Then + setDefaultBackColorInText(pageStyle.FooterTextRight) + EndIf + If Not IsEmpty(pageStyle.FooterTextLeft) Then + setDefaultBackColorInText(pageStyle.FooterTextLeft) + EndIf + If Not IsEmpty(pageStyle.HeaderText) Then + setDefaultBackColorInText(pageStyle.HeaderText) + EndIf + If Not IsEmpty(pageStyle.HeaderTextFirst) Then + setDefaultBackColorInText(pageStyle.HeaderTextFirst) + EndIf + If Not IsEmpty(pageStyle.HeaderTextRight) Then + setDefaultBackColorInText(pageStyle.HeaderTextRight) + EndIf + If Not IsEmpty(pageStyle.HeaderTextLeft) Then + setDefaultBackColorInText(pageStyle.HeaderTextLeft) + EndIf + Next i + setDefaultBackColorInText(ThisComponent.Text) +End Sub + +Sub setDefaultBackColorInText(oText As Object) + If IsMissing(oText) Then + Exit sub + End If + 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("com.sun.star.text.Paragraph") Then + If enum1Element.CharBackTransparent = false Then + enum1Element.setPropertyToDefault("CharBackTransparent") + EndIf + ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then + cellNames = enum1Element.cellNames + For i = LBound(cellNames) To Ubound(cellNames) + cell = enum1Element.getCellByName(cellNames(i)) + cellText = cell.getText() + setDefaultBackColorInText(cellText) + Next i + EndIf + Wend +End Sub \ No newline at end of file diff --git a/Redaction/CleaningDialog.xdl b/Redaction/CleaningDialog.xdl index bdc60f0..d1c4827 100644 --- a/Redaction/CleaningDialog.xdl +++ b/Redaction/CleaningDialog.xdl @@ -1,10 +1,10 @@ - + - + - + @@ -20,7 +20,7 @@ - + @@ -28,5 +28,6 @@ + \ No newline at end of file diff --git a/Redaction/Translations.xba b/Redaction/Translations.xba index 3d1c5df..130669b 100644 --- a/Redaction/Translations.xba +++ b/Redaction/Translations.xba @@ -298,6 +298,12 @@ Function getRussian(identifier As String) As String Exit Function Case "foundColoredTextMessage" getRussian = "Найден текст c непрозрачным фоном. Обычно это не подходит для электронных публикаций. Вместо белого цвета фона используйте «Без заливки»" + Exit Function + Case "invalidParagraphFormattingFound" + getRussian = "Найдены некорректные настройки форматирования параграфов. Необходима чистка." + Exit Function + Case "fixBrokenCharBackTransparentMenuItem" + getRussian = "Исправить некорректные настройки цветовой заливки абзацев" Exit Function Case Else getRussian = "Перевод не найден" @@ -579,6 +585,12 @@ Function getEnglish(identifier As String) As String Exit Function Case "foundColoredTextMessage" getEnglish = "Found text with an opaque background. This is usually not suitable for electronic publishing. Use „No Fill“ instead of a white background " + Exit Function + Case "invalidParagraphFormattingFound" + getEnglish = "Incorrect paragraph formatting settings found. Cleaning required. " + Exit Function + Case "fixBrokenCharBackTransparentMenuItem" + getEnglish = "Fix incorrect color fill settings for paragraphs " Exit Function Case Else getEnglish = "No translation" @@ -860,6 +872,12 @@ Function getCroatian(identifier As String) As String Case "foundColoredTextMessage" getCroatian = "Pronađen tekst s neprozirnom pozadinom. To obično nije prikladno za elektroničko izdavanje. Upotrijebite „Bez popunjavanja“ umjesto bijele pozadine " Exit Function + Case "invalidParagraphFormattingFound" + getCroatian = "Pronađene su pogrešne postavke oblikovanja odlomaka. Potrebno čišćenje. " + Exit Function + Case "fixBrokenCharBackTransparentMenuItem" + getCroatian = "Ispravite netočne postavke ispunjavanja boja za odlomke " + Exit Function Case Else getCroatian = "No translation" End Select @@ -1140,6 +1158,12 @@ Function getSerbian(identifier As String) As String Case "foundColoredTextMessage" getSerbian = "Пронађен је текст са непрозирном позадином. Ово обично није погодно за електронско издавање. Користите „Без попуњавања“ уместо беле позадине " Exit Function + Case "invalidParagraphFormattingFound" + getSerbian = "Пронађене су нетачне поставке форматирања пасуса. Потребно чишћење. " + Exit Function + Case "fixBrokenCharBackTransparentMenuItem" + getSerbian = "Исправите нетачна подешавања попуњавања боја за пасусе " + Exit Function Case Else getSerbian = "No translation" End Select @@ -1420,6 +1444,12 @@ Function getBosnian(identifier As String) As String Case "foundColoredTextMessage" getBosnian = "Pronađen tekst s neprozirnom pozadinom. To obično nije prikladno za elektroničko izdavanje. Upotrijebite „Bez popunjavanja“ umjesto bijele pozadine " Exit Function + Case "invalidParagraphFormattingFound" + getBosnian = "Pronađene su pogrešne postavke oblikovanja odlomaka. Potrebno čišćenje. " + Exit Function + Case "fixBrokenCharBackTransparentMenuItem" + getBosnian = "Ispravite netočne postavke ispunjavanja boja za odlomke " + Exit Function Case Else getBosnian = "No translation" End Select diff --git a/Redaction/Validation.xba b/Redaction/Validation.xba index 7fd60a1..c9f7ee2 100644 --- a/Redaction/Validation.xba +++ b/Redaction/Validation.xba @@ -35,6 +35,7 @@ Sub validateButton Dim needExtendedInfo As Boolean Dim config As Object Dim needFixColoredText As Boolean + Dim brokenCharBackTransparent As Boolean config = initRedactionConfiguration() Dim statusIndicator as Object @@ -84,11 +85,15 @@ Sub validateButton needExtendedInfo = false EndIf + brokenCharBackTransparent = hasbrokenCharBackTransparent + If (brokenCharBackTransparent) Then + MsgBox getTranslation("invalidParagraphFormattingFound") + EndIf needFixColoredText = findColoredBackgroundInDoc numberingsErros = printNumberingSymbols(needExtendedInfo) statusIndicator.setValue(80) - If needFixColoredText OR numberingsErros OR badText OR badNumberings OR footnotesReport <> "" OR graphicsReport <> "" Or outlineInNotesReport <> "" Or sectionsReport <> "" OR oulineInTablesReport <> "" OR outlinePageStylesReport <> "" Then + If brokenCharBackTransparent OR needFixColoredText OR numberingsErros OR badText OR badNumberings OR footnotesReport <> "" OR graphicsReport <> "" Or outlineInNotesReport <> "" Or sectionsReport <> "" OR oulineInTablesReport <> "" OR outlinePageStylesReport <> "" Then MsgBox getTranslation("validationWarning") If badText Then MsgBox getTranslation("validationBadSymbolsNotification") @@ -321,7 +326,7 @@ Function checkHeadingsInHeadersFooters As String checkHeadingsInHeadersFooters = result End Function -Function checkHeadingsInTextTables(oText As Object) As String +Function checkHeadingsInTextTables() As String Dim enum1Element As Object Dim enum1 As Object Dim enum2 As Object @@ -436,6 +441,126 @@ Function isHeadingsInText(oText As Object) As Boolean isHeadingsInText = false End Function +Function hasBrokenCharBackTransparent As Boolean + Dim foonNotes As Object + Dim endNotes As Object + Dim i As Integer + Dim oStyles As Object + Dim pageStyles As Object + Dim pageStyle As Object + hasBrokenCharBackTransparent = isBackColorInText(ThisComponent.Text) + If (hasBrokenCharBackTransparent) Then + Exit Function + EndIf + footNotes = thisComponent.footNotes + For i = 0 to footNotes.Count -1 + hasBrokenCharBackTransparent = isBackColorInText(footNotes.getByIndex(i).Text) + If (hasBrokenCharBackTransparent) Then + Exit Function + EndIf + Next i + endNotes = thisComponent.footNotes + For i = 0 to footNotes.Count -1 + hasBrokenCharBackTransparent = isBackColorInText(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 + hasBrokenCharBackTransparent = isBackColorInText(pageStyle.FooterText) + If (hasBrokenCharBackTransparent) Then + Exit Function + EndIf + EndIf + If Not IsEmpty(pageStyle.FooterTextFirst) Then + hasBrokenCharBackTransparent = isBackColorInText(pageStyle.FooterTextFirst) + If (hasBrokenCharBackTransparent) Then + Exit Function + EndIf + EndIf + If Not IsEmpty(pageStyle.FooterTextRight) Then + hasBrokenCharBackTransparent = isBackColorInText(pageStyle.FooterTextRight) + If (hasBrokenCharBackTransparent) Then + Exit Function + EndIf + EndIf + If Not IsEmpty(pageStyle.FooterTextLeft) Then + hasBrokenCharBackTransparent = isBackColorInText(pageStyle.FooterTextLeft) + If (hasBrokenCharBackTransparent) Then + Exit Function + EndIf + EndIf + If Not IsEmpty(pageStyle.HeaderText) Then + hasBrokenCharBackTransparent = isBackColorInText(pageStyle.HeaderText) + If (hasBrokenCharBackTransparent) Then + Exit Function + EndIf + EndIf + If Not IsEmpty(pageStyle.HeaderTextFirst) Then + hasBrokenCharBackTransparent = isBackColorInText(pageStyle.HeaderTextFirst) + If (hasBrokenCharBackTransparent) Then + Exit Function + EndIf + EndIf + If Not IsEmpty(pageStyle.HeaderTextRight) Then + hasBrokenCharBackTransparent = isBackColorInText(pageStyle.HeaderTextRight) + If (hasBrokenCharBackTransparent) Then + Exit Function + EndIf + EndIf + If Not IsEmpty(pageStyle.HeaderTextLeft) Then + hasBrokenCharBackTransparent = isBackColorInText(pageStyle.HeaderTextLeft) + If (hasBrokenCharBackTransparent) Then + Exit Function + EndIf + EndIf + Next i +End Function + + + +Function isBackColorInText(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("com.sun.star.text.Paragraph") Then + If enum1Element.CharBackTransparent = false Then + isBackColorInText = true + Exit Function + EndIf + ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then + cellNames = enum1Element.cellNames + For i = LBound(cellNames) To Ubound(cellNames) + cell = enum1Element.getCellByName(cellNames(i)) + cellText = cell.getText() + If isBackColorInText(cellText) Then + isBackColorInText = true + Exit Function + EndIf + Next i + EndIf + Wend + isBackColorInText = false +End Function + + + Function printNumberingSymbols(needExtendedInfo) As Boolean Dim families As Object Dim numStyles As Object @@ -864,7 +989,6 @@ Function findColoredBackgroundInDoc() As Boolean sDesc.SearchAll = true sDesc.ValueSearch = false sDesc.SearchRegularExpression = true - sDesc.SearchString = searchString sDesc.searchStyles = true sDesc.SetSearchAttributes(SrchAttributes()) founds = Thiscomponent.findAll(sDesc) @@ -990,4 +1114,4 @@ sub openReport(fileName As String) Kill(tmpName) End If End Sub - \ No newline at end of file + diff --git a/gradle.properties b/gradle.properties index 985b7ba..1ceb6a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=0.9.30 +version=0.9.31 diff --git a/translations.ods b/translations.ods index e85db2c..8fc0ef1 100644 Binary files a/translations.ods and b/translations.ods differ