Version 0.4.0
This commit is contained in:
parent
ffbca8cc0a
commit
8b44586932
3 changed files with 105 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
<!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 mark4
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Clean" script:language="StarBasic">Sub mark6
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ Sub cleanButton
|
||||||
saveDocument
|
saveDocument
|
||||||
doNotTrack
|
doNotTrack
|
||||||
statusIndicator.Start("Чистка документа начата, подождите",30)
|
statusIndicator.Start("Чистка документа начата, подождите",30)
|
||||||
|
replaceStyleFonts
|
||||||
unicodeSymbolsConversion
|
unicodeSymbolsConversion
|
||||||
|
|
||||||
cleanFormatting
|
cleanFormatting
|
||||||
removeHyperlinks
|
removeHyperlinks
|
||||||
disposeAllBookmarks
|
disposeAllBookmarks
|
||||||
|
@ -43,7 +43,51 @@ Private Sub removeFirstElementPageBreak
|
||||||
EndIf
|
EndIf
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub replaceStyleFonts
|
||||||
|
' Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
||||||
|
replaceFontsInStyles("IPH Lib Serif","IPH Astra Serif")
|
||||||
|
replaceFontsInStyles("Liberation Serif","IPH Astra Serif")
|
||||||
|
replaceFontsInStyles("PTSerif","IPH Astra Serif")
|
||||||
|
replaceFontsInStyles("PT Serif","IPH Astra Serif")
|
||||||
|
replaceFontsInStyles("ArabicD","IPH Astra Serif")
|
||||||
|
replaceFontsInStyles("Palatino Linotype Greek","Tinos")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub replaceFontsInStyles(oldFontStart,newFontName)
|
||||||
|
' Substitutes font names starts with oldFont value with newFont value
|
||||||
|
Dim oDoc as Object
|
||||||
|
Dim propertySetInfo As Object
|
||||||
|
Dim oPositionOfMatch As Long
|
||||||
|
oDoc = ThisComponent
|
||||||
|
oFamilies = Thiscomponent.StyleFamilies
|
||||||
|
sElements() = oFamilies.getElementNames()
|
||||||
|
For i = 0 to oFamilies.count -1
|
||||||
|
oFamily = oFamilies.getByName(sElements(i))
|
||||||
|
For j = 0 to oFamily.getCount -1
|
||||||
|
oStyle = oFamily.getByIndex(j)
|
||||||
|
propertySetInfo = oStyle.getPropertySetInfo()
|
||||||
|
If propertySetInfo.hasPropertyByName("CharFontName") Then
|
||||||
|
fontName = oStyle.getPropertyValue("CharFontName")
|
||||||
|
oPositionOfMatch = InStr(fontName, oldFontStart)
|
||||||
|
If oPositionOfMatch = 1 Then
|
||||||
|
oStyle.CharFontName = newFontName
|
||||||
|
If propertySetInfo.hasPropertyByName("CharFontNameComplex") Then
|
||||||
|
oStyle.CharFontNameComplex = newFontName
|
||||||
|
ENdIf
|
||||||
|
If propertySetInfo.hasPropertyByName("CharFontNameAsian") Then
|
||||||
|
oStyle.CharFontNameAsian = newFontName
|
||||||
|
ENdIf
|
||||||
|
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
Private Sub unicodeSymbolsConversion
|
Private Sub unicodeSymbolsConversion
|
||||||
|
|
||||||
|
convertWLLatin2IPHAstra
|
||||||
|
|
||||||
Dim newFontName As String
|
Dim newFontName As String
|
||||||
newFontName = "IPH Astra Serif"
|
newFontName = "IPH Astra Serif"
|
||||||
Dim RAtts(2) as new com.sun.star.beans.PropertyValue
|
Dim RAtts(2) as new com.sun.star.beans.PropertyValue
|
||||||
|
@ -61,7 +105,8 @@ Private Sub unicodeSymbolsConversion
|
||||||
'Basic Latin \u0020-\u007E
|
'Basic Latin \u0020-\u007E
|
||||||
'Combining diacritical marks 0301 0304 0323 032e 0331 035f
|
'Combining diacritical marks 0301 0304 0323 032e 0331 035f
|
||||||
'General Punctuation \u2000-\u206f
|
'General Punctuation \u2000-\u206f
|
||||||
unicodeConversionEverywhere("[\u2100-\u214F,\u0080-\u00FF,\u0400-\u04FF,\u0020-\u007E,\u2000-\u206f,\u0301,\u0304,\u0323,\u032e,\u0331,\u035f]+",RAtts)
|
' unicodeConversionEverywhere("[\u0020-\u007F]+",RAtts)
|
||||||
|
unicodeConversionEverywhere("[\u2100-\u214F,\u0020-\u007F,\u0080-\u00FF,\u0400-\u04FF,\u2000-\u206f,\u0301,\u0304,\u0323,\u032e,\u0331,\u035f]+",RAtts)
|
||||||
'Arabic Scheherazade
|
'Arabic Scheherazade
|
||||||
newFontName = "Scheherazade"
|
newFontName = "Scheherazade"
|
||||||
RAtts(0).Value = newFontName
|
RAtts(0).Value = newFontName
|
||||||
|
@ -74,10 +119,11 @@ Private Sub unicodeSymbolsConversion
|
||||||
RAtts(0).Value = newFontName
|
RAtts(0).Value = newFontName
|
||||||
RAtts(1).Value = newFontName
|
RAtts(1).Value = newFontName
|
||||||
RAtts(2).Value = newFontName
|
RAtts(2).Value = newFontName
|
||||||
'Greek and Coptic
|
'Greek and Coptic 0370—03FF
|
||||||
unicodeConversionEverywhere("[\u0370-\u03FF]+",RAtts)
|
'Greek extended 1F00—1FFF
|
||||||
'Greek extended
|
unicodeConversionEverywhere("[\u0370-\u03FF,\u1F00-\u1FFF]+",RAtts)
|
||||||
unicodeConversionEverywhere("[\u1F00-\u1FFF]+",RAtts)
|
|
||||||
|
|
||||||
'DejaVu Sans Mathematical operators
|
'DejaVu Sans Mathematical operators
|
||||||
newFontName = "DejaVu Sans"
|
newFontName = "DejaVu Sans"
|
||||||
RAtts(0).Value = newFontName
|
RAtts(0).Value = newFontName
|
||||||
|
@ -116,7 +162,13 @@ Private Sub convertFontsToCharStyles
|
||||||
EndIf
|
EndIf
|
||||||
If curFont <> "IPH Astra Serif" AND curFont <> "" Then
|
If curFont <> "IPH Astra Serif" AND curFont <> "" Then
|
||||||
If Not DocHasCharStyle(oDoc,curFont) Then
|
If Not DocHasCharStyle(oDoc,curFont) Then
|
||||||
oProps() = Array(CreateProperty("CharFontName", curFont))
|
Dim oProps(2) As New com.sun.star.beans.PropertyValue
|
||||||
|
oProps(0).Name = "CharFontName"
|
||||||
|
oProps(1).Name = "CharFontNameComplex"
|
||||||
|
oProps(2).Name = "CharFontNameAsian"
|
||||||
|
oProps(0).Value = curFont
|
||||||
|
oProps(1).Value = curFont
|
||||||
|
oProps(2).Value = curFont
|
||||||
CreateCharacterStyle(curFont, oProps())
|
CreateCharacterStyle(curFont, oProps())
|
||||||
End If
|
End If
|
||||||
founds.CharStyleNames = Array(curFont)
|
founds.CharStyleNames = Array(curFont)
|
||||||
|
@ -371,16 +423,18 @@ Sub setAttributesBySearchPattern(searchPattern As String,ReplAttributes, Optiona
|
||||||
Dim oSearch
|
Dim oSearch
|
||||||
Dim oTextCursor As Object
|
Dim oTextCursor As Object
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
Dim lineIndent
|
|
||||||
Dim replace As Boolean
|
Dim replace As Boolean
|
||||||
|
Dim attrName As string
|
||||||
|
Dim attrValue As String
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
oSearch = ThisComponent.createSearchDescriptor()
|
oSearch = ThisComponent.createSearchDescriptor()
|
||||||
oSearch.SearchString = searchPattern
|
oSearch.SearchString = searchPattern
|
||||||
|
' Mri oSearch
|
||||||
oSearch.SearchRegularExpression=True
|
oSearch.SearchRegularExpression=True
|
||||||
oSearch.SearchAll = True
|
oSearch.SearchAll = True
|
||||||
If Not IsMissing (SrchAttributes) Then
|
If Not IsMissing (SrchAttributes) Then
|
||||||
If Not IsEmpty(SrchAttributes(0).Value) Then
|
If Not IsEmpty(SrchAttributes(0).Value) Then
|
||||||
oSearch.searchStyles = true
|
oSearch.searchStyles = true
|
||||||
oSearch.SetSearchAttributes(SrchAttributes())
|
oSearch.SetSearchAttributes(SrchAttributes())
|
||||||
End If
|
End If
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -402,8 +456,10 @@ Sub setAttributesBySearchPattern(searchPattern As String,ReplAttributes, Optiona
|
||||||
EndIf
|
EndIf
|
||||||
If replace then
|
If replace then
|
||||||
For i = LBound(ReplAttributes) To Ubound(ReplAttributes)
|
For i = LBound(ReplAttributes) To Ubound(ReplAttributes)
|
||||||
If oFound.getPropertySetInfo.hasPropertyByName(ReplAttributes(i).Name) Then
|
attrName = ReplAttributes(i).Name
|
||||||
oFound.SetPropertyValue(ReplAttributes(i).Name,ReplAttributes(i).Value)
|
attrValue = ReplAttributes(i).Value
|
||||||
|
If oFound.getPropertySetInfo.hasPropertyByName(attrName) Then
|
||||||
|
oFound.SetPropertyValue(attrName,attrValue)
|
||||||
EndIf
|
EndIf
|
||||||
Next i
|
Next i
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -907,4 +963,39 @@ Private Function getStyleNames(oFamily,bLocalized as Boolean, _
|
||||||
Endif
|
Endif
|
||||||
xArray(iUB) = vNextElement
|
xArray(iUB) = vNextElement
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub convertWLLatin2IPHAstra
|
||||||
|
Dim newFontName As String
|
||||||
|
newFontName = "IPH Astra Serif"
|
||||||
|
Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
|
||||||
|
Dim ReplAttributes(0) as new com.sun.star.beans.PropertyValue
|
||||||
|
SrchAttributes(0).Name = "CharFontName"
|
||||||
|
SrchAttributes(0).Value = "WL LatinAllIn1Goth"
|
||||||
|
ReplAttributes(0).Name = "CharFontName"
|
||||||
|
ReplAttributes(0).Value = newFontName
|
||||||
|
|
||||||
|
SearchString = "\uF0D4"
|
||||||
|
oReplaceString = "̱"
|
||||||
|
ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, false)
|
||||||
|
ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, true)
|
||||||
|
|
||||||
|
SearchString = "\uF0D6"
|
||||||
|
oReplaceString = "̣"
|
||||||
|
ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, false)
|
||||||
|
ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, true)
|
||||||
|
|
||||||
|
SearchString = "\uF0F4"
|
||||||
|
oReplaceString = "̄"
|
||||||
|
ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, false)
|
||||||
|
ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, true)
|
||||||
|
|
||||||
|
ReplAttributes(0).Value = newFontName
|
||||||
|
SearchString = "\uF0F1"
|
||||||
|
oReplaceString = "́"
|
||||||
|
ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, false)
|
||||||
|
ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, true)
|
||||||
|
|
||||||
|
replaceFontsInStyles( "WL LatinAllIn1Goth", newFontName)
|
||||||
|
End Sub
|
||||||
</script:module>
|
</script:module>
|
|
@ -3,7 +3,7 @@
|
||||||
xmlns:dep="http://openoffice.org/extensions/description/2006"
|
xmlns:dep="http://openoffice.org/extensions/description/2006"
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<identifier value="pro.litvinovg.Redaction" />
|
<identifier value="pro.litvinovg.Redaction" />
|
||||||
<version value="0.3.7" />
|
<version value="0.4.0" />
|
||||||
<platform value="all" />
|
<platform value="all" />
|
||||||
<display-name>
|
<display-name>
|
||||||
<name lang="en">Cleaning and validation documents for publishing in html and epub with pagination</name>
|
<name lang="en">Cleaning and validation documents for publishing in html and epub with pagination</name>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
0.4.0 Added fonts in styles conversion, also added conversion for WL Latin symbols
|
||||||
0.3.7 Added greek extended conversion to Tinos, extended latin and letter-like symbols to base font
|
0.3.7 Added greek extended conversion to Tinos, extended latin and letter-like symbols to base font
|
||||||
0.3.6 Added check for null EmbeededObject (13.01.2019)
|
0.3.6 Added check for null EmbeededObject (13.01.2019)
|
||||||
0.0.1 (18.10.2019)
|
0.0.1 (18.10.2019)
|
||||||
|
|
Loading…
Add table
Reference in a new issue