New version with unicode fonts conversion
This commit is contained in:
parent
6e1794a27e
commit
488cce991e
3 changed files with 77 additions and 28 deletions
|
@ -1,6 +1,7 @@
|
||||||
<?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">Private Sub markFxFxF
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Clean" script:language="StarBasic">Sub markXXFXK
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub cleanButton
|
Sub cleanButton
|
||||||
|
@ -14,7 +15,7 @@ Sub cleanButton
|
||||||
saveDocument
|
saveDocument
|
||||||
doNotTrack
|
doNotTrack
|
||||||
statusIndicator.Start("Чистка документа начата, подождите",30)
|
statusIndicator.Start("Чистка документа начата, подождите",30)
|
||||||
|
unicodeSymbolsConversion
|
||||||
convertFontsToCharStyles
|
convertFontsToCharStyles
|
||||||
cleanFormatting
|
cleanFormatting
|
||||||
disposeAllLinks
|
disposeAllLinks
|
||||||
|
@ -27,6 +28,54 @@ Sub cleanButton
|
||||||
saveAndreload()
|
saveAndreload()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub unicodeSymbolsConversion
|
||||||
|
Dim newFontName As String
|
||||||
|
newFontName = "IPH Astra Serif"
|
||||||
|
Dim RAtts(2) as new com.sun.star.beans.PropertyValue
|
||||||
|
RAtts(0).Name = "CharFontName"
|
||||||
|
RAtts(1).Name = "CharFontNameComplex"
|
||||||
|
RAtts(2).Name = "CharFontNameAsian"
|
||||||
|
|
||||||
|
'Basic Astra
|
||||||
|
RAtts(0).Value = newFontName
|
||||||
|
RAtts(1).Value = newFontName
|
||||||
|
RAtts(2).Value = newFontName
|
||||||
|
'Cyrillic unicode block range \u0400-\u04FF
|
||||||
|
'Basic Latin \u0020-\u007E
|
||||||
|
'Combining diacritical marks 0301 0304 0323 032e 0331 035f
|
||||||
|
'General Punctuation \u2000-\u206f
|
||||||
|
unicodeConversionEverywhere("[\u0400-\u04FF,\u0020-\u007E,\u2000-\u206f,\u0301,\u0304,\u0323,\u032e,\u0331,\u035f]+",RAtts)
|
||||||
|
|
||||||
|
'Arabic Scheherazade
|
||||||
|
newFontName = "Scheherazade"
|
||||||
|
RAtts(0).Value = newFontName
|
||||||
|
RAtts(1).Value = newFontName
|
||||||
|
RAtts(2).Value = newFontName
|
||||||
|
unicodeConversionEverywhere("[\u0600-\u06FF]+",RAtts)
|
||||||
|
|
||||||
|
'Greek Tinos
|
||||||
|
newFontName = "Tinos"
|
||||||
|
RAtts(0).Value = newFontName
|
||||||
|
RAtts(1).Value = newFontName
|
||||||
|
RAtts(2).Value = newFontName
|
||||||
|
'Greek and Coptic
|
||||||
|
unicodeConversionEverywhere("[\u0370-\u03FF]+",RAtts)
|
||||||
|
'DejaVu Sans Mathematical operators
|
||||||
|
newFontName = "DejaVu Sans"
|
||||||
|
RAtts(0).Value = newFontName
|
||||||
|
RAtts(1).Value = newFontName
|
||||||
|
RAtts(2).Value = newFontName
|
||||||
|
'\u2200-\u22FF Mathematical operators
|
||||||
|
unicodeConversionEverywhere("[\u2200-\u22FF]+",RAtts)
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub unicodeConversionEverywhere(searchPattern,rAtts)
|
||||||
|
'in text
|
||||||
|
setAttributesBySearchPattern(searchPattern,RAtts)
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
'Replaces manual formatting text with font into character style with assigned font
|
'Replaces manual formatting text with font into character style with assigned font
|
||||||
Private Sub convertFontsToCharStyles
|
Private Sub convertFontsToCharStyles
|
||||||
|
@ -199,7 +248,7 @@ Private Sub disposeAllLinks()
|
||||||
ReplAttributes(1).Value = ""
|
ReplAttributes(1).Value = ""
|
||||||
ReplAttributes(2).Name = "CharStyleName"
|
ReplAttributes(2).Name = "CharStyleName"
|
||||||
ReplAttributes(2).Value = ThisComponent.getStyleFamilies().getByIndex(0).ElementNames(0)
|
ReplAttributes(2).Value = ThisComponent.getStyleFamilies().getByIndex(0).ElementNames(0)
|
||||||
setAttributesBySearchPattern("",SrchAttributes,ReplAttributes)
|
setAttributesBySearchPattern("",ReplAttributes,SrchAttributes)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub disposeAllBookmarks()
|
Private Sub disposeAllBookmarks()
|
||||||
|
@ -236,42 +285,42 @@ Private Sub disposePageBreaks
|
||||||
Wend
|
Wend
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub setAttributesBySearchPattern(searchPattern As String, SrchAttributes, ReplAttributes)
|
Sub setAttributesBySearchPattern(searchPattern As String,ReplAttributes, Optional SrchAttributes)
|
||||||
|
turnOffTracking
|
||||||
|
dim stringValue1 As String
|
||||||
|
dim stringValue2 As String
|
||||||
Dim oSearch
|
Dim oSearch
|
||||||
Dim oTextCursor As Object
|
Dim oTextCursor As Object
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
Dim lineIndent
|
Dim lineIndent
|
||||||
dim stringValue1 As String
|
Dim replace As Boolean
|
||||||
dim stringValue2 As String
|
|
||||||
Dim foundPatterns() As Object
|
|
||||||
document = ThisComponent.CurrentController.Frame
|
|
||||||
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
|
||||||
oSearch.SearchRegularExpression=True
|
oSearch.SearchRegularExpression=True
|
||||||
oSearch.SearchAll = True
|
oSearch.SearchAll = True
|
||||||
oSearch.searchStyles = true
|
If Not IsMissing (SrchAttributes) Then
|
||||||
If Not IsEmpty(SrchAttributes(0).Value) Then
|
If Not IsEmpty(SrchAttributes(0).Value) Then
|
||||||
oSearch.SetSearchAttributes(SrchAttributes())
|
oSearch.searchStyles = true
|
||||||
End If
|
oSearch.SetSearchAttributes(SrchAttributes())
|
||||||
|
End If
|
||||||
|
EndIf
|
||||||
oFound = ThisComponent.findFirst(oSearch)
|
oFound = ThisComponent.findFirst(oSearch)
|
||||||
Dim replace As Boolean
|
|
||||||
|
|
||||||
Do While Not IsNull(oFound)
|
Do While Not IsNull(oFound)
|
||||||
replace = true
|
replace = true
|
||||||
|
If Not IsMissing(SrchAttributes) Then
|
||||||
For j = LBound(SrchAttributes) To Ubound(SrchAttributes)
|
For j = LBound(SrchAttributes) To Ubound(SrchAttributes)
|
||||||
If oFound.getPropertySetInfo.hasPropertyByName(SrchAttributes(j).Name) Then
|
If oFound.getPropertySetInfo.hasPropertyByName(SrchAttributes(j).Name) Then
|
||||||
stringValue1 = "" & oFound.getPropertyValue(SrchAttributes(j).Name)
|
stringValue1 = "" & oFound.getPropertyValue(SrchAttributes(j).Name)
|
||||||
stringValue2 = "" & SrchAttributes(j).Value
|
stringValue2 = "" & SrchAttributes(j).Value
|
||||||
If stringValue1 <> stringValue2 Then
|
If stringValue1 <> stringValue2 Then
|
||||||
|
replace = replace AND False
|
||||||
|
EndIf
|
||||||
|
Else
|
||||||
replace = replace AND False
|
replace = replace AND False
|
||||||
EndIf
|
EndIf
|
||||||
Else
|
Next j
|
||||||
replace = replace AND False
|
EndIf
|
||||||
EndIf
|
|
||||||
Next j
|
|
||||||
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
|
If oFound.getPropertySetInfo.hasPropertyByName(ReplAttributes(i).Name) Then
|
||||||
|
|
|
@ -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.2.4" />
|
<version value="0.2.5" />
|
||||||
<platform value="all" />
|
<platform value="all" />
|
||||||
<display-name>
|
<display-name>
|
||||||
<name lang="en">Redaction for publishing in Institute of philosophy</name>
|
<name lang="en">Redaction for publishing in Institute of philosophy</name>
|
||||||
|
|
BIN
redaction.oxt
BIN
redaction.oxt
Binary file not shown.
Loading…
Add table
Reference in a new issue