Cleaning button...
57
Addons.xcu
|
@ -4,26 +4,6 @@
|
||||||
oor:name="Addons"
|
oor:name="Addons"
|
||||||
oor:package="org.openoffice.Office">
|
oor:package="org.openoffice.Office">
|
||||||
<node oor:name="AddonUI">
|
<node oor:name="AddonUI">
|
||||||
<node oor:name="AddonMenu">
|
|
||||||
<node oor:name="pro.litvinovg.IPHRedaction" oor:op="replace">
|
|
||||||
<prop oor:name="Context" oor:type="xs:string">
|
|
||||||
<value>com.sun.star.text.GlobalDocument,com.sun.star.text.TextDocument,com.sun.star.text.WebDocument</value>
|
|
||||||
</prop>
|
|
||||||
<prop oor:name="Title" oor:type="xs:string">
|
|
||||||
<value xml:lang="en">Extension for document publishing preparation</value>
|
|
||||||
<value xml:lang="ru">Расширение для подготовки рукописей к изданию</value>
|
|
||||||
</prop>
|
|
||||||
<prop oor:name="URL" oor:type="xs:string">
|
|
||||||
<value>macro:///IPHRedaction.Validation.validate</value>
|
|
||||||
</prop>
|
|
||||||
<prop oor:name="Target" oor:type="xs:string">
|
|
||||||
<value>_self</value>
|
|
||||||
</prop>
|
|
||||||
<prop oor:name="ImageIdentifier" oor:type="xs:string">
|
|
||||||
<value>%origin%/icons/img-48</value>
|
|
||||||
</prop>
|
|
||||||
</node>
|
|
||||||
</node>
|
|
||||||
<node oor:name="OfficeToolBar">
|
<node oor:name="OfficeToolBar">
|
||||||
<node oor:name="pro.litvinovg.IPHRedaction.panel" oor:op="replace">
|
<node oor:name="pro.litvinovg.IPHRedaction.panel" oor:op="replace">
|
||||||
<node oor:name="ToolBarItems">
|
<node oor:name="ToolBarItems">
|
||||||
|
@ -40,9 +20,6 @@
|
||||||
<prop oor:name="Target" oor:type="xs:string">
|
<prop oor:name="Target" oor:type="xs:string">
|
||||||
<value>_self</value>
|
<value>_self</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="ImageIdentifier" oor:type="xs:string">
|
|
||||||
<value>%origin%/IPHRedaction/validate</value>
|
|
||||||
</prop>
|
|
||||||
</node>
|
</node>
|
||||||
<node oor:name="buttonClean" oor:op="replace">
|
<node oor:name="buttonClean" oor:op="replace">
|
||||||
<prop oor:name="Context" oor:type="xs:string">
|
<prop oor:name="Context" oor:type="xs:string">
|
||||||
|
@ -57,9 +34,6 @@
|
||||||
<prop oor:name="Target" oor:type="xs:string">
|
<prop oor:name="Target" oor:type="xs:string">
|
||||||
<value>_self</value>
|
<value>_self</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="ImageIdentifier" oor:type="xs:string">
|
|
||||||
<value>%origin%/IPHRedaction/testfont</value>
|
|
||||||
</prop>
|
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node oor:name="buttonValidate" oor:op="replace">
|
<node oor:name="buttonValidate" oor:op="replace">
|
||||||
|
@ -76,9 +50,6 @@
|
||||||
<prop oor:name="Target" oor:type="xs:string">
|
<prop oor:name="Target" oor:type="xs:string">
|
||||||
<value>_self</value>
|
<value>_self</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="ImageIdentifier" oor:type="xs:string">
|
|
||||||
<value>%origin%/IPHRedaction/validate</value>
|
|
||||||
</prop>
|
|
||||||
</node>
|
</node>
|
||||||
<node oor:name="buttonClean" oor:op="replace">
|
<node oor:name="buttonClean" oor:op="replace">
|
||||||
<prop oor:name="Context" oor:type="xs:string">
|
<prop oor:name="Context" oor:type="xs:string">
|
||||||
|
@ -86,7 +57,7 @@
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="Title" oor:type="xs:string">
|
<prop oor:name="Title" oor:type="xs:string">
|
||||||
<value xml:lang="ru">Чистка</value>
|
<value xml:lang="ru">Чистка</value>
|
||||||
<value xml:lang="en">Purification</value>
|
<value xml:lang="en">Cleaning</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="URL" oor:type="xs:string">
|
<prop oor:name="URL" oor:type="xs:string">
|
||||||
<value>macro:///IPHRedaction.Clean.cleanButton</value>
|
<value>macro:///IPHRedaction.Clean.cleanButton</value>
|
||||||
|
@ -94,13 +65,29 @@
|
||||||
<prop oor:name="Target" oor:type="xs:string">
|
<prop oor:name="Target" oor:type="xs:string">
|
||||||
<value>_self</value>
|
<value>_self</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="ImageIdentifier" oor:type="xs:string">
|
</node>
|
||||||
<value>%origin%/IPHRedaction/testfont</value>
|
</node>
|
||||||
|
</node>
|
||||||
|
<node oor:name="Images">
|
||||||
|
<node oor:name="image-clean-button" oor:op="replace">
|
||||||
|
<prop oor:name="URL" oor:type="xs:string">
|
||||||
|
<value>macro:///IPHRedaction.Clean.cleanButton</value>
|
||||||
|
</prop>
|
||||||
|
<node oor:name="UserDefinedImages">
|
||||||
|
<prop oor:name="ImageBigURL">
|
||||||
|
<value>%origin%/icons/clean.png</value>
|
||||||
|
</prop>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node oor:name="image-verify-button" oor:op="replace">
|
||||||
|
<prop oor:name="URL" oor:type="xs:string">
|
||||||
|
<value>macro:///IPHRedaction.Validation.validateButton</value>
|
||||||
|
</prop>
|
||||||
|
<node oor:name="UserDefinedImages">
|
||||||
|
<prop oor:name="ImageBigURL">
|
||||||
|
<value>%origin%/icons/validate.png</value>
|
||||||
</prop>
|
</prop>
|
||||||
</node>
|
</node>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
|
|
|
@ -1,479 +1,503 @@
|
||||||
<?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 fixFrequentMistakes
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Clean" script:language="StarBasic">Sub cleanButton
|
||||||
Dim description As String
|
Dim description As String
|
||||||
description = "Вы уверены, что хотите запустить исправление часто встречающихся ошибок?"
|
Dim statusIndicator as Object
|
||||||
|
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
||||||
|
description = "Вы уверены, что хотите выполнить чистку документа?"
|
||||||
If NOT confirm(description) Then
|
If NOT confirm(description) Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
EndIf
|
EndIf
|
||||||
saveDocument()
|
saveDocument
|
||||||
saveVersion("Перед выполнением макроса Ошибки")
|
doNotTrack
|
||||||
StopTracking
|
statusIndicator.Start("Чистка документа начата, подождите",30)
|
||||||
Dim statusIndicator as Object
|
cleanFormatting
|
||||||
Dim NBSP As String
|
|
||||||
Dim space As String
|
|
||||||
NBSP = " "
|
|
||||||
space = " "
|
|
||||||
|
|
||||||
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
|
||||||
statusIndicator.Start("Исправление ошибок начато, подождите",30)
|
|
||||||
'Не должно быть символов табуляции
|
|
||||||
AskAndReplace("\t","")
|
|
||||||
'Не должно быть подряд больше одного пробела
|
|
||||||
AskAndReplace("(?<=[:space:])[:space:]+","")
|
|
||||||
'Не должно быть ни одного пробела в начале абзацев
|
|
||||||
AskAndReplace("^[:space:]+","")
|
|
||||||
'Не должно быть пробелов в конце абзацев
|
|
||||||
AskAndReplace("[:space:]+$","")
|
|
||||||
'Не должно быть пустых абзацев
|
|
||||||
AskAndReplace("^$","")
|
|
||||||
'Не должно быть пробелов перед знаками пунктуации .,;:?!)]}»¡¿”‘’
|
|
||||||
AskAndReplace("[:space:]+(?=[\.,;:?!\)\]\}»¡¿”‘’])","")
|
|
||||||
'Между словом том и цифрой должен быть неразрывный пробел, а не обычный
|
|
||||||
AskAndReplace("(?<=\b[тТ](ом|\.))\ (?=[:digit:])",NBSP)
|
|
||||||
'Между словом серия и цифрой должен быть неразрывный пробел, а не обычный
|
|
||||||
AskAndReplace("(?<=\b[сС](ерия|\.))\ +(?=[:digit:])",NBSP)
|
|
||||||
'Между словом часть и цифрой должен быть неразрывный пробел, а не обычный
|
|
||||||
AskAndReplace("(?<=\b[чЧ](асть|\.))\ +(?=[:digit:])",NBSP)
|
|
||||||
'Между числом и "г." должен быть неразрывный пробел, а не обычный
|
|
||||||
AskAndReplace("(?<=[0-9])[:space:]*г(?=\.)",NBSP & "г")
|
|
||||||
'Между инициалами и Фамилией должен быть неразрывный пробел, а не обычный
|
|
||||||
AskAndReplace("(?<=[:upper:]\.[:space:][:upper:]\.)\ (?=[:upper:][:lower:]+)",NBSP)
|
|
||||||
'Между Фамилией и инициалами должен быть неразрывный пробел, а не обычный
|
|
||||||
AskAndReplace("(?<=[:upper:][:lower:]{1,30})\ (?=[:upper:]\.[:space:][:upper:]\.)",NBSP)
|
|
||||||
|
|
||||||
'Не должно быть пробелов после скобок [({ и кавычек «„
|
|
||||||
AskAndReplace("(?<=[\(\[\{«„])[:space:]","")
|
|
||||||
'Между "и" и "т." должен быть неразрывный пробел, а не обычный
|
|
||||||
AskAndReplace("(?<=\bи)\ (?=т\.)",NBSP)
|
|
||||||
'Между "т." и "е./н./д./п./к." должен быть неразрывный пробел, а не обычный
|
|
||||||
AskAndReplace("(?<=\bт)\.\ ?(?=[ендпк]\.)","." & NBSP)
|
|
||||||
|
|
||||||
'Между буквами среднее тире должно обрамляться пробелами
|
|
||||||
AskAndReplace("(?<=[:alpha:])–(?=[:alpha:])",NBSP & "–" & NBSP)
|
|
||||||
'Между буквами дефис-минус, цифровое тире и длинное тире заменяется на среднее тире
|
|
||||||
AskAndReplace("(?<=[:alpha:][:space:])[-‒—](?=[:space:][:alpha:])","–")
|
|
||||||
'Между двумя цифрами и тире между ними не долнжо быть пробелов. А также тире должно быть цифровым
|
|
||||||
AskAndReplace("(?<=[:digit:])(?:[:space:])?[-‒–—](?:[:space:])?(?=[:digit:])","‒")
|
|
||||||
|
|
||||||
'Между двумя римскими цифрами и тире между ними не долнжо быть пробелов. А также тире должно быть средним
|
|
||||||
AskAndReplace("(?<=[MDCLXVI])(?:[:space:])?[-‒–—](?:[:space:])?(?=[MDCLXVI])","–")
|
|
||||||
|
|
||||||
'Между буквой и угловой открывающейся скобкой должен быть пробел
|
|
||||||
AskAndReplace("(?<=[:alpha:])<(?=…>)",space & "<")
|
|
||||||
'Между угловой закрывающейся скобкой и буквой должен быть пробел
|
|
||||||
AskAndReplace("(?<=<…)>(?=[:alpha:])",">" & space)
|
|
||||||
statusIndicator.end()
|
statusIndicator.end()
|
||||||
saveAndreload()
|
saveAndreload()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub cleanButton
|
Private Sub saveAndreload()
|
||||||
MsgBox "Clean Works!"
|
|
||||||
End Sub
|
dim document as object
|
||||||
Sub workaroundForDiacriticKerningBug
|
dim dispatcher as object
|
||||||
AskAndReplace("([:print:][\u0300-\u036F])","$1")
|
document = ThisComponent.CurrentController.Frame
|
||||||
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
|
dispatcher.executeDispatch(document, ".uno:Save", "", 0, Array())
|
||||||
|
dispatcher.executeDispatch(document, ".uno:Reload", "", 0, Array())
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub executeCitationCorrection
|
Private Sub saveDocument()
|
||||||
StartTracking
|
|
||||||
AskAndReplace("(?<=[:alpha:])<(?=…>)"," <")
|
dim document as object
|
||||||
AskAndReplace("(?<=<…)>(?=[:alpha:])","> ")
|
dim dispatcher as object
|
||||||
AskAndReplace("(?<=[:alpha:])–(?=[:alpha:])"," – ")
|
document = ThisComponent.CurrentController.Frame
|
||||||
StopTracking
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
|
dispatcher.executeDispatch(document, ".uno:Save", "", 0, Array())
|
||||||
|
|
||||||
|
end Sub
|
||||||
|
|
||||||
|
Private Sub cleanFormatting
|
||||||
|
|
||||||
|
'Не должно быть символов табуляции
|
||||||
|
AskAndReplace("\t","")
|
||||||
|
'Не должно быть подряд больше одного пробела
|
||||||
|
AskAndReplace("(?<=[:space:])[:space:]+","")
|
||||||
|
'Не должно быть ни одного пробела в начале абзацев
|
||||||
|
AskAndReplace("^[:space:]+","")
|
||||||
|
'Не должно быть пустых абзацев
|
||||||
|
AskAndReplace("^$","")
|
||||||
|
|
||||||
|
replaceBaseWithStandard
|
||||||
|
|
||||||
|
convertFormattingToText
|
||||||
|
|
||||||
|
manualFontsToCharStyle
|
||||||
|
|
||||||
|
removeDirectFormatting
|
||||||
|
|
||||||
|
convertFormattingFromText
|
||||||
|
|
||||||
|
resetFootnotesStyle
|
||||||
|
|
||||||
|
removeUnusedStyles
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Sub manualFontsToCharStyle
|
||||||
Sub executeRemoveConsequentSpaces
|
Dim oDoc
|
||||||
StartTracking
|
oDoc = Thiscomponent
|
||||||
AskAndReplace("(?<=[:space:])[:space:]+","")
|
Dim srch(0) as new com.sun.star.beans.PropertyValue
|
||||||
StopTracking
|
SDesc = Thiscomponent.createSearchDescriptor()
|
||||||
End Sub
|
SDesc.SearchAll = true
|
||||||
Sub removeBadCharacters
|
SDesc.ValueSearch = false
|
||||||
StartTracking
|
SDesc.SearchStyles = false
|
||||||
AskAndReplace("[\uE000-\uF8FF]+","")
|
SDesc.SearchRegularExpression = false
|
||||||
checkAllFootnotes
|
SDesc.SearchString = ""
|
||||||
StopTracking
|
srch(0).Name = "CharFontName"
|
||||||
showTrackedChanges
|
SDesc.SetSearchAttributes(srch())
|
||||||
|
founds = Thiscomponent.findFirst(SDesc)
|
||||||
|
do while not isNull(founds)
|
||||||
|
curFont = founds.CharFontName
|
||||||
|
If curFont <> "IPH Astra Serif" AND curFont <> "" Then
|
||||||
|
If Not DocHasCharStyle(oDoc,curFont) Then
|
||||||
|
oProps() = Array(CreateProperty("CharFontName", curFont))
|
||||||
|
CreateCharacterStyle(curFont, oProps())
|
||||||
|
End If
|
||||||
|
founds.CharStyleNames = Array(curFont)
|
||||||
|
End If
|
||||||
|
founds = Thiscomponent.findNext(founds.getend, SDesc)
|
||||||
|
loop
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub executeRemoveSpacesBeforeStops
|
Private Sub replaceBaseWithStandard
|
||||||
StartTracking
|
dim document as Object
|
||||||
AskAndReplace("[:space:]+(?=[\.,;:?!\)\]\}»¡¿”‘’])","")
|
dim dispatcher as object
|
||||||
'removed “
|
document = ThisComponent.CurrentController.Frame
|
||||||
StopTracking
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
|
dim args1(21) as new com.sun.star.beans.PropertyValue
|
||||||
|
args1(0).Name = "SearchItem.StyleFamily"
|
||||||
|
args1(0).Value = 2
|
||||||
|
args1(1).Name = "SearchItem.CellType"
|
||||||
|
args1(1).Value = 0
|
||||||
|
args1(2).Name = "SearchItem.RowDirection"
|
||||||
|
args1(2).Value = true
|
||||||
|
args1(3).Name = "SearchItem.AllTables"
|
||||||
|
args1(3).Value = false
|
||||||
|
args1(4).Name = "SearchItem.SearchFiltered"
|
||||||
|
args1(4).Value = false
|
||||||
|
args1(5).Name = "SearchItem.Backward"
|
||||||
|
args1(5).Value = false
|
||||||
|
args1(6).Name = "SearchItem.Pattern"
|
||||||
|
args1(6).Value = true
|
||||||
|
args1(7).Name = "SearchItem.Content"
|
||||||
|
args1(7).Value = false
|
||||||
|
args1(8).Name = "SearchItem.AsianOptions"
|
||||||
|
args1(8).Value = false
|
||||||
|
args1(9).Name = "SearchItem.AlgorithmType"
|
||||||
|
args1(9).Value = 0
|
||||||
|
args1(10).Name = "SearchItem.SearchFlags"
|
||||||
|
args1(10).Value = 65536
|
||||||
|
args1(11).Name = "SearchItem.SearchString"
|
||||||
|
args1(11).Value = "Базовый"
|
||||||
|
args1(12).Name = "SearchItem.ReplaceString"
|
||||||
|
args1(12).Value = "Основной текст"
|
||||||
|
args1(13).Name = "SearchItem.Locale"
|
||||||
|
args1(13).Value = 255
|
||||||
|
args1(14).Name = "SearchItem.ChangedChars"
|
||||||
|
args1(14).Value = 2
|
||||||
|
args1(15).Name = "SearchItem.DeletedChars"
|
||||||
|
args1(15).Value = 2
|
||||||
|
args1(16).Name = "SearchItem.InsertedChars"
|
||||||
|
args1(16).Value = 2
|
||||||
|
args1(17).Name = "SearchItem.TransliterateFlags"
|
||||||
|
args1(17).Value = 1280
|
||||||
|
args1(18).Name = "SearchItem.Command"
|
||||||
|
args1(18).Value = 3
|
||||||
|
args1(19).Name = "SearchItem.SearchFormatted"
|
||||||
|
args1(19).Value = false
|
||||||
|
args1(20).Name = "SearchItem.AlgorithmType2"
|
||||||
|
args1(20).Value = 1
|
||||||
|
args1(21).Name = "Quiet"
|
||||||
|
args1(21).Value = true
|
||||||
|
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub executeNumericDashBetweenNumbers
|
Private Sub doNotTrack
|
||||||
StartTracking
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
AskAndReplace("(?<=[:digit:])(?:[:space:])?[-‒–—](?:[:space:])?(?=[:digit:])","‒")
|
|
||||||
StopTracking
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Sub executeReplaceLongDashWithSpacesBetweenWords
|
|
||||||
StartTracking
|
|
||||||
AskAndReplace("(?<=[:alpha:][:space:])[-‒—](?=[:space:][:alpha:])","–")
|
|
||||||
StopTracking
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Sub executeRemoveSpacesAfterOpenedQuoteOrBracket
|
|
||||||
StartTracking
|
|
||||||
AskAndReplace("(?<=[\(\[\{«„])[:space:]","")
|
|
||||||
StopTracking
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
|
|
||||||
Sub executeNonBreakingSpaceBetweenLastnameAndInitials
|
|
||||||
StartTracking
|
|
||||||
AskAndReplace("(?<=[^.!?][:space:][:upper:][:lower:]{1,30})\ (?=[:upper:]\.[:upper:]\.)"," ")
|
|
||||||
StopTracking
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
|
|
||||||
Sub executeNonBreakingSpaceBetweenInitialsAndLastName
|
|
||||||
StartTracking
|
|
||||||
AskAndReplace("(?<=[:upper:]\.[:upper:]\.)\ (?=[:upper:][:lower:]+)"," ")
|
|
||||||
StopTracking
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Sub executeNonBreakingSpaceBetweenEtc
|
|
||||||
StartTracking
|
|
||||||
AskAndReplace("(?<=\bи)\ (?=т\.)"," ")
|
|
||||||
AskAndReplace("(?<=\bт)\.\ ?(?=[ендпк]\.)",". ")
|
|
||||||
StopTracking
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
'Sub executeNonBreakingSpaceAfterPageOrVolume
|
|
||||||
' StartTracking
|
|
||||||
' AskAndReplace("(?<=\b[сСтТ]\.)[:space:](?=[:digit:])"," ")
|
|
||||||
' StopTracking
|
|
||||||
'End Sub
|
|
||||||
|
|
||||||
Sub executeNonBreakingSpaceBetweenVol
|
|
||||||
StartTracking
|
|
||||||
AskAndReplace("(?<=\b[тТ](ом|\.))[:space:](?=[:digit:])"," ")
|
|
||||||
StopTracking
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Sub executeNonBreakingSpaceBetweenSeries
|
|
||||||
StartTracking
|
|
||||||
AskAndReplace("(?<=\b[сС](ерия|\.))[:space:](?=[:digit:])"," ")
|
|
||||||
StopTracking
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Sub executeNonBreakingSpaceBetweenPart
|
|
||||||
StartTracking
|
|
||||||
AskAndReplace("(?<=\b[чЧ](асть|\.))[:space:]+(?=[:digit:])"," ")
|
|
||||||
StopTracking
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
|
|
||||||
Sub executeNonBreakingSpaceBetweenYear
|
|
||||||
StartTracking
|
|
||||||
AskAndReplace("(?<=[0-9])[:space:]*г(?=\.)"," г")
|
|
||||||
StopTracking
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Sub StartTracking
|
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
|
||||||
document = ThisComponent.CurrentController.Frame
|
document = ThisComponent.CurrentController.Frame
|
||||||
dim trackProperties(0) as new com.sun.star.beans.PropertyValue
|
dim trackProperties(0) as new com.sun.star.beans.PropertyValue
|
||||||
trackProperties(0).Name = "TrackChanges"
|
trackProperties(0).Name = "TrackChanges"
|
||||||
trackProperties(0).Value = true
|
|
||||||
dispatcher.executeDispatch(document, ".uno:TrackChanges", "", 0, trackProperties())
|
|
||||||
dim args1(0) as new com.sun.star.beans.PropertyValue
|
|
||||||
args1(0).Name = "ShowTrackedChanges"
|
|
||||||
args1(0).Value = true
|
|
||||||
dispatcher.executeDispatch(document, ".uno:ShowTrackedChanges", "", 0, args1())
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Sub StopTracking
|
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
|
||||||
document = ThisComponent.CurrentController.Frame
|
|
||||||
dim trackProperties(0) as new com.sun.star.beans.PropertyValue
|
|
||||||
trackProperties(0).Name = "TrackChanges"
|
|
||||||
trackProperties(0).Value = false
|
trackProperties(0).Value = false
|
||||||
dispatcher.executeDispatch(document, ".uno:TrackChanges", "", 0, trackProperties())
|
dispatcher.executeDispatch(document, ".uno:TrackChanges", "", 0, trackProperties())
|
||||||
dim args1(0) as new com.sun.star.beans.PropertyValue
|
dim args1(0) as new com.sun.star.beans.PropertyValue
|
||||||
args1(0).Name = "ShowTrackedChanges"
|
args1(0).Name = "ShowTrackedChanges"
|
||||||
args1(0).Value = true
|
args1(0).Value = true
|
||||||
dispatcher.executeDispatch(document, ".uno:ShowTrackedChanges", "", 0, args1())
|
dispatcher.executeDispatch(document, ".uno:ShowTrackedChanges", "", 0, args1())
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Sub executeRemoveWhiteBackground
|
Private Sub removeDirectFormatting
|
||||||
Dim description As String
|
Dim oDescriptor 'The search descriptor
|
||||||
Dim searchPattern As String
|
dim dispatcher as Object
|
||||||
searchPattern = ""
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
description = "Вы уверены, что хотите заменить белый фон на прозрачный в текущем документе?"
|
dim document as Object
|
||||||
If NOT confirm(description) Then
|
document = ThisComponent.CurrentController.Frame
|
||||||
Exit Sub
|
Dim oViewCursor As Object 'View cursor
|
||||||
EndIf
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
Dim statusIndicator as Object
|
oViewCursor.gotoStart(false)
|
||||||
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
oViewCursor.gotoEnd(true)
|
||||||
statusIndicator.Start("Замена белого фона на прозрачный начата",100)
|
dispatcher.executeDispatch(document, ".uno:ResetAttributes", "", 0, Array())
|
||||||
Dim SrchAttributes(1) as new com.sun.star.beans.PropertyValue
|
footNotes = thisComponent.Footnotes
|
||||||
Dim ReplAttributes(1) as new com.sun.star.beans.PropertyValue
|
For x = 0 to footNotes.Count -1
|
||||||
SrchAttributes(0).Name = "CharBackTransparent"
|
aNote = footNotes.getByIndex(x)
|
||||||
SrchAttributes(0).Value = False
|
footNoteText = aNote.getText()
|
||||||
SrchAttributes(1).Name = "CharBackColor"
|
oTextcursor = footNoteText.createTextCursor()
|
||||||
SrchAttributes(1).Value = 16777215
|
oViewCursor.gotoRange(oTextcursor.getStart(),false)
|
||||||
ReplAttributes(0).Name = "CharBackTransparent"
|
oViewCursor.gotoEnd(true)
|
||||||
ReplAttributes(0).Value = True
|
dispatcher.executeDispatch(document, ".uno:ResetAttributes", "", 0, Array())
|
||||||
ReplAttributes(1).Name = "CharBackColor"
|
Next
|
||||||
ReplAttributes(1).Value = -1
|
endNotes = thisComponent.Endnotes
|
||||||
setAttributesBySearchPattern(searchPattern,SrchAttributes,ReplAttributes)
|
for x = 0 to endNotes.Count -1
|
||||||
statusIndicator.end()
|
aNote = endNotes.getByIndex(x)
|
||||||
|
endNoteText = aNote.getText()
|
||||||
|
oTextcursor = endNoteText.createTextCursor()
|
||||||
|
oViewCursor.gotoRange(oTextcursor.getStart(),false)
|
||||||
|
oViewCursor.gotoEnd(true)
|
||||||
|
dispatcher.executeDispatch(document, ".uno:ResetAttributes", "", 0, Array())
|
||||||
|
next
|
||||||
|
|
||||||
|
oViewCursor.gotoStart(false)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub ReplaceEverywhere(SearchString,oReplaceString)
|
Private Sub resetFootnotesStyle
|
||||||
Dim oDoc,oText,oViewCursor,oStart,oEnd,oFind,FandR As Object
|
Dim oDescriptor 'The search descriptor
|
||||||
oDoc = ThisComponent
|
dim dispatcher as Object
|
||||||
oText = oDoc.Text
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
Footnotes = oDoc.Footnotes
|
dim document as Object
|
||||||
oViewCursor = oDoc.CurrentController.getViewCursor
|
document = ThisComponent.CurrentController.Frame
|
||||||
oStart = oViewCursor.Text.createTextCursorByRange(oViewCursor.Start)
|
Dim oViewCursor As Object 'View cursor
|
||||||
FandR = oDoc.createReplaceDescriptor
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
With FandR
|
allNotes= thisComponent.FootNotes
|
||||||
.SearchString = SearchString
|
for x = 0 to allNotes.Count -1
|
||||||
.ReplaceString = oReplaceString
|
aNote = allNotes.getByIndex(x)
|
||||||
.SearchRegularExpression=True
|
aNote.Anchor.CharStyleName="Footnote anchor"
|
||||||
.searchAll=True
|
oEnum = aNote.Text.createEnumeration()
|
||||||
End With
|
Do While oEnum.hasMoreElements()
|
||||||
If Not oViewCursor.isCollapsed then
|
oCurPar = oEnum.nextElement()
|
||||||
oEnd = oViewCursor.Text.createTextCursorByRange(oViewCursor.End)
|
oCurPar.ParaStyleName = "Footnote"
|
||||||
End If
|
|
||||||
If isEmpty(oEnd) then 'Do whole document.
|
|
||||||
oDoc.replaceAll(FandR)
|
|
||||||
Else 'Do selection.
|
|
||||||
Do
|
|
||||||
oFind = oDoc.FindNext(oStart.End,FandR)
|
|
||||||
If isNull(oFind) then
|
|
||||||
Exit Do
|
|
||||||
End If
|
|
||||||
If oViewCursor.Text.compareRegionEnds(oFind,oEnd) < 0 then
|
|
||||||
Exit Do
|
|
||||||
End If
|
|
||||||
oFind.setString(FandR.ReplaceString)
|
|
||||||
oFind = oDoc.FindNext(oFind.End,FandR)
|
|
||||||
Loop
|
Loop
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub removeUnusedStyles
|
||||||
|
'calls: RemoveUnusedStyles
|
||||||
|
Dim sElements() as string, oFamilies, oFamily, sFamily$, sLabel, oDlg, i%
|
||||||
|
Dim oDoc as object
|
||||||
|
oDoc = ThisComponent
|
||||||
|
oFamilies = thiscomponent.StyleFamilies
|
||||||
|
sElements() = oFamilies.getElementNames()
|
||||||
|
For i = 0 to uBound(sElements()) -2
|
||||||
|
oFamily = oFamilies.getByName(sElements(i))
|
||||||
|
removeUnusedStyle(oFamily,sElements(i),True)
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub removeUnusedStyle(oFamily,sFamily as string, bAsk as Boolean)
|
||||||
|
'calls: getStyleNames
|
||||||
|
Dim sUsed() as String, sMsg$,iAnswer%, bStop as boolean
|
||||||
|
sUsed() = getStyleNames(oFamily,bLocalized:=True,bUsed:=False,bUserDef:=true)
|
||||||
|
If uBound(sUsed()) > -1 then
|
||||||
|
For i = 0 to uBound(sUsed())
|
||||||
|
oFamily.removeByName(sUsed(i))
|
||||||
|
Next
|
||||||
EndIf
|
EndIf
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub convertFormatToEnclosure(identifier, styleNames, styleValues)
|
||||||
|
leftEnclosure = compileLeftEnclosure(identifier)
|
||||||
|
rightEnclosure = compileRightEnclosure(identifier)
|
||||||
|
Dim oTextCursor As Object
|
||||||
|
Dim startTextRange As Object
|
||||||
|
Dim endTextRange As Object
|
||||||
|
Dim foundString As String
|
||||||
|
Dim SrchAttributes(Ubound(styleNames)) as new com.sun.star.beans.PropertyValue
|
||||||
|
For i = 0 To Ubound(styleNames)
|
||||||
|
SrchAttributes(i).Name = styleNames(i)
|
||||||
|
SrchAttributes(i).Value = styleValues(i)
|
||||||
|
Next i
|
||||||
|
SDesc = Thiscomponent.createSearchDescriptor()
|
||||||
|
SDesc.SearchAll = true
|
||||||
|
SDesc.SearchRegularExpression = true
|
||||||
|
SDesc.SearchString = ""
|
||||||
|
SDesc.searchStyles = false
|
||||||
|
SDesc.SetSearchAttributes(SrchAttributes)
|
||||||
|
found = Thiscomponent.findFirst(SDesc)
|
||||||
|
Do While not isNull(found)
|
||||||
|
oTextCursor = found.Text.createTextCursor()
|
||||||
|
oTextCursor.goToRange(found.Start, false)
|
||||||
|
oTextCursor.goToRange(found.End, true)
|
||||||
|
For i = 0 To Ubound(styleNames)
|
||||||
|
oTextCursor.setPropertyToDefault(styleNames(i))
|
||||||
|
Next i
|
||||||
|
foundString = found.getString()
|
||||||
|
If Len(foundString) <> 0 Then
|
||||||
|
oTextCursor.collapseToEnd()
|
||||||
|
oTextCursor.String = rightEnclosure
|
||||||
|
endTextRange = oTextCursor.getEnd()
|
||||||
|
oTextCursor.goToRange(found.start,false)
|
||||||
|
oTextCursor.String = leftEnclosure
|
||||||
|
EndIf
|
||||||
|
found = Thiscomponent.findNext(found.End, SDesc)
|
||||||
|
Loop
|
||||||
|
End Sub
|
||||||
|
|
||||||
Function IsAnythingSelected(oDoc As Object) As Boolean
|
Private Sub convertEnclosuresToFormat(identifier, styleNames, styleValues)
|
||||||
Dim oSelections 'Contains all of the selections
|
Dim oTextCursor As Object
|
||||||
Dim oSel
|
Dim startTextRange As Object
|
||||||
'Contains one specific selection
|
Dim endTextRange As Object
|
||||||
Dim oCursor
|
Dim leftEnclosure As String
|
||||||
'Text cursor to check for a collapsed range
|
Dim rightEnclosure As String
|
||||||
REM Assume nothing is selected
|
leftEnclosure = compileLeftEnclosure(identifier)
|
||||||
IsAnythingSelected = False
|
rightEnclosure = compileRightEnclosure(identifier)
|
||||||
If IsNull(ThisComponent) Then
|
SDesc = Thiscomponent.createSearchDescriptor()
|
||||||
Exit Function
|
SDesc.SearchAll = true
|
||||||
End If
|
SDesc.SearchRegularExpression = true
|
||||||
' The current selection in the current controller.
|
SDesc.SearchString = leftEnclosure + "([^" + identifier+ "]*)" + rightEnclosure
|
||||||
'If there is no current controller, it returns NULL.
|
|
||||||
oSelections = ThisComponent.getCurrentSelection()
|
found = Thiscomponent.findFirst(SDesc)
|
||||||
If IsNull(oSelections) Then
|
Do While not isNull(found)
|
||||||
Exit Function
|
oTextCursor = found.Text.createTextCursor()
|
||||||
End If
|
oTextCursor.goToRange(found.Start, false)
|
||||||
If oSelections.getCount() = 0 Then
|
oTextCursor.goToRange(found.End, true)
|
||||||
Exit Function
|
oTextCursor.setPropertyValues(styleNames, styleValues)
|
||||||
End If
|
oTextCursor.collapseToEnd()
|
||||||
If oSelections.getCount() > 1 Then
|
oTextCursor.goLeft(Len(rightEnclosure), true)
|
||||||
REM There is more than one selection so return True
|
oTextCursor.String = ""
|
||||||
IsAnythingSelected = True
|
endTextRange = oTextCursor.getEnd()
|
||||||
Exit Function
|
oTextCursor.goToRange(found.start,false)
|
||||||
End If
|
oTextCursor.goRight(Len(leftEnclosure), true)
|
||||||
REM There is only one selection so obtain the first selection
|
oTextCursor.String = ""
|
||||||
oSel = oSelections.getByIndex(0)
|
found = Thiscomponent.findNext(endTextRange, SDesc)
|
||||||
lenght = Len(oSel.String)
|
Loop
|
||||||
If lenght > 0 Then
|
End Sub
|
||||||
IsAnythingSelected = True
|
|
||||||
|
|
||||||
|
Private Function compileSearchString(identifier)
|
||||||
|
compileSearchString = "<"+identifier+">"+"(.*?)"+"</"+identifier+">"
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function compileLeftEnclosure(identifier)
|
||||||
|
compileLeftEnclosure = "<"+identifier+">"
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function compileRightEnclosure(identifier)
|
||||||
|
compileRightEnclosure = "</"+identifier+">"
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub toTextBold
|
||||||
|
styleNames = Array("CharWeight")
|
||||||
|
styleValues = Array(com.sun.star.awt.FontWeight.BOLD)
|
||||||
|
convertFormatToEnclosure(CHR(867), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub fromTextBold
|
||||||
|
styleNames = Array("CharWeight")
|
||||||
|
styleValues = Array(com.sun.star.awt.FontWeight.BOLD)
|
||||||
|
convertEnclosuresToFormat(CHR(867), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub toTextItalic
|
||||||
|
styleNames = Array("CharPosture")
|
||||||
|
styleValues = Array(com.sun.star.awt.FontSlant.ITALIC)
|
||||||
|
convertFormatToEnclosure(CHR(868), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub fromTextItalic
|
||||||
|
styleNames = Array("CharPosture")
|
||||||
|
styleValues = Array(com.sun.star.awt.FontSlant.ITALIC)
|
||||||
|
convertEnclosuresToFormat(CHR(868), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub toTextStrikeout
|
||||||
|
styleNames = Array("CharStrikeout")
|
||||||
|
styleValues = Array(com.sun.star.awt.FontStrikeout.SINGLE)
|
||||||
|
convertFormatToEnclosure(CHR(869), styleNames, styleValues)
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub fromTextStrikeout
|
||||||
|
styleNames = Array("CharStrikeout")
|
||||||
|
styleValues = Array(com.sun.star.awt.FontStrikeout.SINGLE)
|
||||||
|
convertEnclosuresToFormat(CHR(869), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub toTextUnderline
|
||||||
|
styleNames = Array("CharUnderline")
|
||||||
|
styleValues = Array(com.sun.star.awt.FontUnderline.SINGLE)
|
||||||
|
convertFormatToEnclosure(CHR(870), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub fromTextUnderline
|
||||||
|
styleNames = Array("CharUnderline")
|
||||||
|
styleValues = Array(com.sun.star.awt.FontUnderline.SINGLE)
|
||||||
|
convertEnclosuresToFormat(CHR(870), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub toTextSuperscript
|
||||||
|
styleNames = Array("CharEscapementHeight","CharEscapement")
|
||||||
|
styleValues = Array(58,101)
|
||||||
|
convertFormatToEnclosure(CHR(871), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub fromTextSuperscript
|
||||||
|
styleNames = Array("CharEscapementHeight","CharEscapement")
|
||||||
|
styleValues = Array(58,101)
|
||||||
|
convertEnclosuresToFormat(CHR(871), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub toTextSubscript
|
||||||
|
styleNames = Array("CharEscapementHeight","CharEscapement")
|
||||||
|
styleValues = Array(58,-101)
|
||||||
|
convertFormatToEnclosure(CHR(872), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub fromTextSubscript
|
||||||
|
styleNames = Array("CharEscapementHeight","CharEscapement")
|
||||||
|
styleValues = Array(58,-101)
|
||||||
|
convertEnclosuresToFormat(CHR(872), styleNames, styleValues)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub toTextSparce
|
||||||
|
styleNames = Array("CharKerning")
|
||||||
|
For i=70 To 70
|
||||||
|
styleValues = Array(i)
|
||||||
|
convertFormatToEnclosure(CHR(873) & i, styleNames, styleValues)
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub fromTextSparce
|
||||||
|
styleNames = Array("CharKerning")
|
||||||
|
For i=70 To 70
|
||||||
|
styleValues = Array(i)
|
||||||
|
convertEnclosuresToFormat(CHR(873) & i, styleNames, styleValues)
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub convertFormattingToText
|
||||||
|
toTextBold
|
||||||
|
toTextItalic
|
||||||
|
toTextStrikeout
|
||||||
|
toTextUnderline
|
||||||
|
toTextSuperscript
|
||||||
|
toTextSubscript
|
||||||
|
toTextSparce
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub convertFormattingFromText
|
||||||
|
fromTextSparce
|
||||||
|
fromTextSuperscript
|
||||||
|
fromTextSubscript
|
||||||
|
fromTextUnderline
|
||||||
|
fromTextStrikeout
|
||||||
|
fromTextItalic
|
||||||
|
fromTextBold
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Function confirm(description)
|
||||||
|
If MsgBox (description, 4) =6 Then
|
||||||
|
confirm = true
|
||||||
|
Else
|
||||||
|
confirm = false
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Private Sub ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, searchStyles)
|
||||||
|
Dim oReplace
|
||||||
|
oReplace = ThisComponent.createReplaceDescriptor()
|
||||||
|
oReplace.SearchString = SearchString
|
||||||
|
oReplace.ReplaceString = oReplaceString
|
||||||
|
oReplace.SearchRegularExpression=True
|
||||||
|
oReplace.SearchCaseSensitive = True
|
||||||
|
|
||||||
Sub AskAndReplace(SearchString, oReplaceString)
|
oReplace.searchAll=True
|
||||||
Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
|
If Not IsEmpty(SrchAttributes(0).Value) Then
|
||||||
Dim ReplAttributes(0) as new com.sun.star.beans.PropertyValue
|
oReplace.SetSearchAttributes(SrchAttributes())
|
||||||
If IsAnythingSelected() Then
|
oReplace.searchStyles = searchStyles
|
||||||
oSelections = ThisComponent.getCurrentSelection()
|
End If
|
||||||
ReplaceInSelection(SearchString, oReplaceString)
|
If Not IsEmpty(ReplAttributes(0).Value) Then
|
||||||
thisComponent.currentController.select(oSelections)
|
oReplace.SetReplaceAttributes(ReplAttributes())
|
||||||
|
End If
|
||||||
|
ThisComponent.replaceAll(oReplace)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Function getStyleNames(oFamily,bLocalized as Boolean, _
|
||||||
|
optional bUsed, optional bUserDef)
|
||||||
|
Dim oStyle,i%,sNames$(),sName$,chkUse as Boolean, chkUDef as Boolean
|
||||||
|
For i = 0 to oFamily.getCount -1
|
||||||
|
oStyle = oFamily.getByIndex(i)
|
||||||
|
If bLocalized then
|
||||||
|
sName = oStyle.DisplayName
|
||||||
Else
|
Else
|
||||||
ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, true)
|
sName = oStyle.getName
|
||||||
' ReplaceEverywhere(SearchString, oReplaceString)
|
Endif
|
||||||
End If
|
If (vartype(bUsed) = 11)then
|
||||||
End Sub
|
chkUse = (bUsed EQV oStyle.isInUse)
|
||||||
|
Else
|
||||||
|
chkUse = True
|
||||||
|
Endif
|
||||||
|
If (vartype(bUserDef) = 11) then
|
||||||
Sub ReplaceInSelection(SearchString,oReplaceString)
|
chkUDef = (bUserDef EQV oStyle.isUserDefined)
|
||||||
rem ----------------------------------------------------------------------
|
Else
|
||||||
rem define variables
|
chkUDef = True
|
||||||
dim document as object
|
|
||||||
dim dispatcher as object
|
|
||||||
rem ----------------------------------------------------------------------
|
|
||||||
rem get access to the document
|
|
||||||
document = ThisComponent.CurrentController.Frame
|
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
|
||||||
|
|
||||||
rem ----------------------------------------------------------------------
|
|
||||||
dim args1(21) as new com.sun.star.beans.PropertyValue
|
|
||||||
args1(0).Name = "SearchItem.StyleFamily"
|
|
||||||
args1(0).Value = 2
|
|
||||||
args1(1).Name = "SearchItem.CellType"
|
|
||||||
args1(1).Value = 0
|
|
||||||
args1(2).Name = "SearchItem.RowDirection"
|
|
||||||
args1(2).Value = true
|
|
||||||
args1(3).Name = "SearchItem.AllTables"
|
|
||||||
args1(3).Value = false
|
|
||||||
args1(4).Name = "SearchItem.SearchFiltered"
|
|
||||||
args1(4).Value = false
|
|
||||||
args1(5).Name = "SearchItem.Backward"
|
|
||||||
args1(5).Value = false
|
|
||||||
args1(6).Name = "SearchItem.Pattern"
|
|
||||||
args1(6).Value = false
|
|
||||||
args1(7).Name = "SearchItem.Content"
|
|
||||||
args1(7).Value = false
|
|
||||||
args1(8).Name = "SearchItem.AsianOptions"
|
|
||||||
args1(8).Value = false
|
|
||||||
args1(9).Name = "SearchItem.AlgorithmType"
|
|
||||||
args1(9).Value = 1
|
|
||||||
args1(10).Name = "SearchItem.SearchFlags"
|
|
||||||
args1(10).Value = 71680
|
|
||||||
args1(11).Name = "SearchItem.SearchString"
|
|
||||||
args1(11).Value = SearchString
|
|
||||||
args1(12).Name = "SearchItem.ReplaceString"
|
|
||||||
args1(12).Value = oReplaceString
|
|
||||||
args1(13).Name = "SearchItem.Locale"
|
|
||||||
args1(13).Value = 255
|
|
||||||
args1(14).Name = "SearchItem.ChangedChars"
|
|
||||||
args1(14).Value = 2
|
|
||||||
args1(15).Name = "SearchItem.DeletedChars"
|
|
||||||
args1(15).Value = 2
|
|
||||||
args1(16).Name = "SearchItem.InsertedChars"
|
|
||||||
args1(16).Value = 2
|
|
||||||
args1(17).Name = "SearchItem.TransliterateFlags"
|
|
||||||
args1(17).Value = 1024
|
|
||||||
args1(18).Name = "SearchItem.Command"
|
|
||||||
args1(18).Value = 3
|
|
||||||
args1(19).Name = "SearchItem.SearchFormatted"
|
|
||||||
args1(19).Value = false
|
|
||||||
args1(20).Name = "SearchItem.AlgorithmType2"
|
|
||||||
args1(20).Value = 2
|
|
||||||
args1(21).Name = "Quiet"
|
|
||||||
args1(21).Value = true
|
|
||||||
|
|
||||||
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
|
|
||||||
|
|
||||||
|
|
||||||
end Sub
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub insertSpecialCharacterInFont(sCharacter As String, sFont As String)
|
|
||||||
rem ----------------------------------------------------------------------
|
|
||||||
rem define variables
|
|
||||||
dim document as object
|
|
||||||
dim dispatcher as object
|
|
||||||
rem ----------------------------------------------------------------------
|
|
||||||
rem get access to the document
|
|
||||||
document = ThisComponent.CurrentController.Frame
|
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
|
||||||
|
|
||||||
rem ----------------------------------------------------------------------
|
|
||||||
dim args1(1) as new com.sun.star.beans.PropertyValue
|
|
||||||
args1(0).Name = "Symbols"
|
|
||||||
args1(0).Value = sCharacter
|
|
||||||
args1(1).Name = "FontName"
|
|
||||||
args1(1).Value = sFont
|
|
||||||
|
|
||||||
dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0, args1())
|
|
||||||
|
|
||||||
end Sub
|
|
||||||
|
|
||||||
|
|
||||||
Sub searchAndRemoveDirectFormatting(searchString)
|
|
||||||
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
|
||||||
oViewCursor.jumpToFirstPage
|
|
||||||
oSearch = ThisComponent.createSearchDescriptor()
|
|
||||||
oSearch.SearchString = searchString
|
|
||||||
oSearch.SearchRegularExpression=True
|
|
||||||
oSearch.searchAll=True
|
|
||||||
oFound = ThisComponent.findFirst(oSearch)
|
|
||||||
Do While Not IsNull(oFound)
|
|
||||||
oTextCursor = oFound.Text.createTextCursor()
|
|
||||||
oFound.setString(oFound.getString)
|
|
||||||
oFound = ThisComponent.findNext(oFound.End, oSearch)
|
|
||||||
Loop
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
|
|
||||||
sub RemoveStyleByName(styleName As String)
|
|
||||||
Dim oDoc as Object
|
|
||||||
Dim propertySetInfo As Object
|
|
||||||
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)
|
|
||||||
|
|
||||||
If oStyle.Name = styleName Then
|
|
||||||
oFamily.removeByName(oStyle.Name)
|
|
||||||
Exit For
|
|
||||||
EndIf
|
EndIf
|
||||||
|
If sName = "Автор" Or sName = "Автор по-английски" Or sName = "Ключевые слова" Or sName = "Текст списка литературы" Or sName = "Эпиграф" or sName = "Цитирование" or sName = "Сведения об авторе" or sName = "Аннотация" Then
|
||||||
|
chkUse = False
|
||||||
|
Endif
|
||||||
|
If chkUse AND chkUDef then
|
||||||
|
bas_Pusharray sNames(),sName
|
||||||
|
Endif
|
||||||
Next
|
Next
|
||||||
Next
|
getStyleNames = sNames()
|
||||||
End Sub
|
End Function
|
||||||
|
|
||||||
sub showTrackedChanges
|
'very simple routine appending some element to an array which can be undimensioned (LBound > UBound)
|
||||||
dim document as object
|
Sub bas_PushArray(xArray(),vNextElement)
|
||||||
dim dispatcher as object
|
Dim iUB%,iLB%
|
||||||
document = ThisComponent.CurrentController.Frame
|
iLB = lBound(xArray())
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
iUB = uBound(xArray())
|
||||||
dispatcher.executeDispatch(document, ".uno:AcceptTrackedChanges", "", 0, Array())
|
If iLB > iUB then
|
||||||
dim args2(0) as new com.sun.star.beans.PropertyValue
|
iUB = iLB
|
||||||
args2(0).Name = "ShowTrackedChanges"
|
redim xArray(iLB To iUB)
|
||||||
args2(0).Value = true
|
Else
|
||||||
dispatcher.executeDispatch(document, ".uno:ShowTrackedChanges", "", 0, args2())
|
iUB = iUB +1
|
||||||
|
redim preserve xArray(iLB To iUB)
|
||||||
end sub
|
Endif
|
||||||
|
xArray(iUB) = vNextElement
|
||||||
Sub checkAllFootnotes()
|
|
||||||
Dim footnotes As Object
|
|
||||||
Dim count as Integer
|
|
||||||
Dim charNum as Long
|
|
||||||
Dim char As Long
|
|
||||||
Dim label As String
|
|
||||||
Dim result As String
|
|
||||||
result = ""
|
|
||||||
footnotes = ThisComponent.Footnotes
|
|
||||||
count = footnotes.getCount
|
|
||||||
For i = 0 to count-1
|
|
||||||
footnote = footnotes.getByIndex(i)
|
|
||||||
' Mri footnote
|
|
||||||
label = footnote.Label
|
|
||||||
charNum = Len(label)
|
|
||||||
For j = 1 to charNum
|
|
||||||
char = Asc(Right(Left(label,j),1))
|
|
||||||
If char >= 57344 AND char <= 63743 then
|
|
||||||
result = result & "Символ "& Chr(char) &" сноски "& i &" находится в диапазоне для частного использования"& chr(10)
|
|
||||||
'Mri footnote
|
|
||||||
'footNote.setLabel(Left(label,j-1) & "*" & Right(label,charNum-j))
|
|
||||||
End If
|
|
||||||
Next j
|
|
||||||
Next i
|
|
||||||
If result <> "" then
|
|
||||||
MsgBox result
|
|
||||||
EndIf
|
|
||||||
End Sub
|
End Sub
|
||||||
</script:module>
|
</script:module>
|
Before Width: | Height: | Size: 822 B |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 837 B |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 837 B |
|
@ -29,8 +29,8 @@
|
||||||
</extension-description>
|
</extension-description>
|
||||||
|
|
||||||
<icon>
|
<icon>
|
||||||
<default xlink:href="icons/img-48.png" />
|
<default xlink:href="icons/addon_icon.png" />
|
||||||
<high-contrast xlink:href="icons/img-48.png" />
|
<high-contrast xlink:href="icons/addon_icon.png" />
|
||||||
</icon>
|
</icon>
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
|
|
BIN
icons/addon_icon.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
icons/clean.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
icons/img-16.png
Before Width: | Height: | Size: 910 B |
BIN
icons/img-22.png
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 46 KiB |
BIN
icons/img-32.png
Before Width: | Height: | Size: 2 KiB |
BIN
icons/img-48.png
Before Width: | Height: | Size: 3.3 KiB |
BIN
icons/validate.png
Normal file
After Width: | Height: | Size: 2.8 KiB |