2020-03-05 20:23:54 +01:00
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
2021-07-29 11:43:13 +02:00
|
|
|
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Configuration" script:language="StarBasic" script:moduleType="normal">Public Const redactionExtensionName = "cleanAndValidate"
|
|
|
|
|
Public Const redactionExtensionVersion = "0.9.38"
|
|
|
|
|
Public Const template_name_monography = "Монография"
|
|
|
|
|
Public Const template_name_pj = "Философский журнал"
|
|
|
|
|
Public Const template_name_pq = "Вопросы философии"
|
|
|
|
|
Public Const template_name_hp = "История философии"
|
|
|
|
|
Public Const template_name_hpe = "Историко-философский ежегодник"
|
|
|
|
|
Public Const template_name_pr = "Философия религии"
|
|
|
|
|
Public Const template_name_fnit = "Философия науки и техники"
|
|
|
|
|
Public Const template_name_pa = "Философская антропология"
|
|
|
|
|
Public Const template_name_pcr = "Путь цивилизационного развития"
|
|
|
|
|
Public Const template_name_eifn = "Эпистемология и философия науки"
|
|
|
|
|
Public Const template_name_et = "Этическая мысль"
|
|
|
|
|
Public Const template_manual = "custom_selected_template"
|
|
|
|
|
|
2020-03-05 20:23:54 +01:00
|
|
|
|
Function initRedactionConfiguration()
|
|
|
|
|
On Error Goto exceptionHandler
|
|
|
|
|
Dim regFactory As Object
|
|
|
|
|
Dim reg As Object
|
2020-03-21 11:55:13 +01:00
|
|
|
|
Dim redactionProps As Object
|
2020-03-05 20:23:54 +01:00
|
|
|
|
Dim props(2) As New com.sun.star.beans.PropertyValue
|
2020-11-08 15:08:22 +01:00
|
|
|
|
Dim propSetInfo As Object
|
2020-03-05 20:23:54 +01:00
|
|
|
|
regFactory = CreateUnoService("com.sun.star.ucb.Store")
|
2020-03-05 20:55:14 +01:00
|
|
|
|
reg = regFactory.createPropertySetRegistry(redactionExtensionName)
|
|
|
|
|
redactionProps = reg.openPropertySet(redactionExtensionName, TRUE)
|
2020-11-08 15:08:22 +01:00
|
|
|
|
propSetInfo = redactionProps.getPropertySetInfo()
|
2021-01-23 20:36:09 +01:00
|
|
|
|
If Not propSetInfo.hasPropertyByName("superscript_max_length") Then
|
|
|
|
|
redactionProps.addProperty("superscript_max_length", 128, "10")
|
|
|
|
|
EndIf
|
|
|
|
|
If Not propSetInfo.hasPropertyByName("subscript_max_length") Then
|
|
|
|
|
redactionProps.addProperty("subscript_max_length", 128, "10")
|
|
|
|
|
EndIf
|
2020-11-08 15:08:22 +01:00
|
|
|
|
If Not propSetInfo.hasPropertyByName("fixes_russian_iph") Then
|
|
|
|
|
redactionProps.addProperty("fixes_russian_iph", 128, "true")
|
2021-07-29 11:43:13 +02:00
|
|
|
|
EndIf
|
|
|
|
|
If Not propSetInfo.hasPropertyByName("predefined_template") Then
|
|
|
|
|
redactionProps.addProperty("predefined_template", 128, "false")
|
2020-11-08 15:08:22 +01:00
|
|
|
|
EndIf
|
|
|
|
|
If Not propSetInfo.hasPropertyByName("complexity") Then
|
|
|
|
|
redactionProps.addProperty("complexity", 128, "user")
|
|
|
|
|
EndIf
|
2020-04-23 14:15:18 +02:00
|
|
|
|
exceptionHandler:
|
2020-03-21 12:37:32 +01:00
|
|
|
|
Resume Next
|
2020-04-23 14:15:18 +02:00
|
|
|
|
On Error Goto exceptionHandler2
|
2021-01-14 12:09:53 +01:00
|
|
|
|
If Not propSetInfo.hasPropertyByName("defaultTemplate") Then
|
2020-11-08 15:08:22 +01:00
|
|
|
|
redactionProps.addProperty("defaultTemplate", 128, "Статья.ott")
|
2021-07-29 11:43:13 +02:00
|
|
|
|
EndIf
|
|
|
|
|
If Not propSetInfo.hasPropertyByName("predefined_template") Then
|
|
|
|
|
redactionProps.addProperty("predefined_template", 128, "false")
|
|
|
|
|
EndIf
|
2020-04-23 14:15:18 +02:00
|
|
|
|
exceptionHandler2:
|
|
|
|
|
Resume Next
|
2020-03-05 20:23:54 +01:00
|
|
|
|
initRedactionConfiguration = redactionProps
|
|
|
|
|
End Function
|
|
|
|
|
|
2020-03-21 11:55:13 +01:00
|
|
|
|
Private Sub setConfigFromDialog(dialog As Object)
|
2020-03-05 20:23:54 +01:00
|
|
|
|
Dim config As Object
|
|
|
|
|
config = initRedactionConfiguration()
|
2020-05-18 17:16:20 +02:00
|
|
|
|
|
2020-03-05 20:55:14 +01:00
|
|
|
|
If dialog.getControl("CB_complexity").state = 1 Then
|
|
|
|
|
config.setPropertyValue("complexity", "makerUp")
|
|
|
|
|
Else
|
|
|
|
|
config.setPropertyValue("complexity", "user")
|
|
|
|
|
EndIf
|
2020-05-18 17:16:20 +02:00
|
|
|
|
|
|
|
|
|
If dialog.getControl("cb_russian_fixes_iph").state = 1 Then
|
|
|
|
|
config.setPropertyValue("fixes_russian_iph", "true")
|
|
|
|
|
Else
|
|
|
|
|
config.setPropertyValue("fixes_russian_iph", "false")
|
|
|
|
|
EndIf
|
|
|
|
|
|
2021-01-23 20:36:09 +01:00
|
|
|
|
config.setPropertyValue("superscript_max_length", dialog.getControl("tf_max_superscript").getText())
|
|
|
|
|
config.setPropertyValue("subscript_max_length", dialog.getControl("tf_max_subscript").getText())
|
|
|
|
|
|
2020-03-05 20:55:14 +01:00
|
|
|
|
End Sub
|
|
|
|
|
|
2020-03-21 11:55:13 +01:00
|
|
|
|
Private Sub loadConfigToDialog(dialog As Object)
|
2020-03-05 20:55:14 +01:00
|
|
|
|
Dim config As Object
|
|
|
|
|
config = initRedactionConfiguration()
|
|
|
|
|
If config.getPropertyValue("complexity") = "makerUp" Then
|
|
|
|
|
dialog.getControl("CB_complexity").state = 1
|
|
|
|
|
Else
|
|
|
|
|
dialog.getControl("CB_complexity").state = 0
|
|
|
|
|
EndIf
|
2020-05-18 17:16:20 +02:00
|
|
|
|
|
|
|
|
|
If config.getPropertyValue("fixes_russian_iph") = "true" Then
|
|
|
|
|
dialog.getControl("cb_russian_fixes_iph").state = 1
|
|
|
|
|
Else
|
|
|
|
|
dialog.getControl("cb_russian_fixes_iph").state = 0
|
|
|
|
|
EndIf
|
2021-01-23 20:36:09 +01:00
|
|
|
|
|
|
|
|
|
dialog.getControl("tf_max_superscript").setText(config.getPropertyValue("superscript_max_length"))
|
|
|
|
|
dialog.getControl("tf_max_subscript").setText(config.getPropertyValue("subscript_max_length"))
|
|
|
|
|
|
|
|
|
|
|
2020-03-05 20:55:14 +01:00
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub configurationDialog
|
|
|
|
|
Dim dialog As Object
|
|
|
|
|
DialogLibraries.LoadLibrary("Redaction")
|
|
|
|
|
dialog = CreateUnoDialog(DialogLibraries.Redaction.ConfigDialog)
|
2020-05-04 14:28:39 +02:00
|
|
|
|
loadConfigToDialog(dialog)
|
2020-05-04 16:43:15 +02:00
|
|
|
|
dialog.getControl("CB_complexity").Label = getTranslation("dialogConfigComplexity")
|
2020-05-18 17:16:20 +02:00
|
|
|
|
dialog.getControl("cb_russian_fixes_iph").Label = getTranslation("dialogRussianFixesIPH")
|
2021-01-23 20:36:09 +01:00
|
|
|
|
|
|
|
|
|
dialog.getControl("label_max_superscript").setText(getTranslation("dialogConfigMaxSuperscript"))
|
|
|
|
|
dialog.getControl("label_max_subscript").setText(getTranslation("dialogConfigMaxSubscript"))
|
|
|
|
|
|
2020-05-04 16:43:15 +02:00
|
|
|
|
dialog.Title = getTranslation("dialogConfigTitle")
|
|
|
|
|
dialog.getControl("OK").Label = getTranslation("buttonYes")
|
|
|
|
|
dialog.getControl("CANCEL").Label = getTranslation("buttonStop")
|
2020-03-05 20:55:14 +01:00
|
|
|
|
dialog.setVisible(true)
|
|
|
|
|
Select Case dialog.Execute()
|
|
|
|
|
Case 1
|
|
|
|
|
setConfigFromDialog(dialog)
|
|
|
|
|
Case 0
|
|
|
|
|
End Select
|
|
|
|
|
dialog.setVisible(false)
|
|
|
|
|
dialog.dispose()
|
|
|
|
|
Exit sub
|
2020-03-05 20:23:54 +01:00
|
|
|
|
End Sub
|
2020-04-23 14:15:18 +02:00
|
|
|
|
|
|
|
|
|
Private Sub quietStartDialog
|
|
|
|
|
Dim dialog As Object
|
|
|
|
|
DialogLibraries.LoadLibrary("Redaction")
|
|
|
|
|
dialog = CreateUnoDialog(DialogLibraries.Redaction.StartQuietCleaning)
|
|
|
|
|
Dim description As String
|
|
|
|
|
Dim buttonNameOk As String
|
|
|
|
|
Dim buttonNameStop As String
|
|
|
|
|
Dim buttonNameLoad As String
|
2020-04-23 14:33:18 +02:00
|
|
|
|
Dim dialogTitle As String
|
2020-05-04 14:28:39 +02:00
|
|
|
|
description = getTranslation("startQuietCleaningDescription")
|
|
|
|
|
buttonNameOk = getTranslation("buttonYes")
|
|
|
|
|
buttonNameStop = getTranslation("buttonStop")
|
|
|
|
|
buttonNameLoad = getTranslation("buttonLoad")
|
|
|
|
|
dialogTitle = getTranslation("quietStartCleaningTitle")
|
2020-04-23 14:33:18 +02:00
|
|
|
|
dialog.Title = dialogTitle
|
2020-04-23 14:15:18 +02:00
|
|
|
|
dialog.getControl("Description").setText(description)
|
|
|
|
|
dialog.getControl("buttonOk").Label = buttonNameOk
|
|
|
|
|
dialog.getControl("buttonStop").Label = buttonNameStop
|
|
|
|
|
dialog.getControl("buttonLoad").Label = buttonNameLoad
|
|
|
|
|
dialog.setVisible(true)
|
|
|
|
|
Select Case dialog.Execute()
|
|
|
|
|
Case 1
|
|
|
|
|
dialog.setVisible(false)
|
|
|
|
|
dialog.dispose()
|
|
|
|
|
quietCleaning
|
|
|
|
|
Case 0
|
|
|
|
|
dialog.setVisible(false)
|
|
|
|
|
dialog.dispose()
|
|
|
|
|
End Select
|
|
|
|
|
|
|
|
|
|
Exit sub
|
|
|
|
|
End Sub
|
|
|
|
|
|
2021-07-29 11:43:13 +02:00
|
|
|
|
Dim styleFileDialog As Object
|
|
|
|
|
|
|
|
|
|
Private Sub configureStyleFileDialog
|
2020-04-23 14:15:18 +02:00
|
|
|
|
'Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
2021-07-29 11:43:13 +02:00
|
|
|
|
Dim config As Object
|
2020-04-23 14:15:18 +02:00
|
|
|
|
Dim dialog As Object
|
2021-07-29 11:43:13 +02:00
|
|
|
|
Dim predefined As String
|
|
|
|
|
Dim description As String
|
|
|
|
|
Dim customFile As String
|
2020-04-23 14:15:18 +02:00
|
|
|
|
DialogLibraries.LoadLibrary("Redaction")
|
2021-07-29 11:43:13 +02:00
|
|
|
|
styleFileDialog = CreateUnoDialog(DialogLibraries.Redaction.NoStyleFile)
|
|
|
|
|
config = initRedactionConfiguration()
|
|
|
|
|
predefined = config.getPropertyValue("predefined_template")
|
|
|
|
|
customFile = config.getPropertyValue("defaultTemplate")
|
|
|
|
|
If predefined = "false" Then
|
|
|
|
|
description = getTranslation("noFileWithStylesFound")
|
|
|
|
|
ElseIf predefined = template_manual Then
|
|
|
|
|
description = getTranslation("manualStyleFileSet") & " «" & customFile & "»"
|
|
|
|
|
Else
|
|
|
|
|
description = getTranslation("predefiendTemplateSelected") & " «" & predefined & "»"
|
|
|
|
|
EndIf
|
|
|
|
|
styleFileDialog.Title = getTranslation("noStylesFileDialogTitle")
|
|
|
|
|
styleFileDialog.getControl("Description").setText(description)
|
|
|
|
|
styleFileDialog.getControl("FileSelection").Label = getTranslation("buttonNameToSelectFileWithStyles")
|
|
|
|
|
styleFileDialog.getControl("buttonOk").Label = getTranslation("buttonTemplateNotFoundSkip")
|
|
|
|
|
styleFileDialog.setVisible(true)
|
|
|
|
|
Select Case styleFileDialog.Execute()
|
2020-04-23 14:15:18 +02:00
|
|
|
|
Case 0
|
|
|
|
|
End Select
|
2021-07-29 11:43:13 +02:00
|
|
|
|
styleFileDialog.setVisible(false)
|
|
|
|
|
styleFileDialog.dispose()
|
2020-04-23 14:15:18 +02:00
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
2021-07-29 11:43:13 +02:00
|
|
|
|
Sub selectTemplateDialog()
|
|
|
|
|
Dim config As Object
|
|
|
|
|
Dim description As String
|
|
|
|
|
Dim templateName As String
|
|
|
|
|
Dim templateNames() As String
|
|
|
|
|
Dim i As Integer
|
|
|
|
|
Dim listComponent As Object
|
|
|
|
|
config = initRedactionConfiguration()
|
|
|
|
|
Dim dialog As Object
|
|
|
|
|
DialogLibraries.LoadLibrary("Redaction")
|
|
|
|
|
dialog = CreateUnoDialog(DialogLibraries.Redaction.SelectTemplate)
|
|
|
|
|
listComponent = dialog.getControl("ListBox")
|
2021-07-29 12:23:25 +02:00
|
|
|
|
dialog.getControl("buttonOk").Label = getTranslation("buttonYes")
|
|
|
|
|
dialog.getControl("buttonStop").Label = getTranslation("buttonStop")
|
|
|
|
|
dialog.Title = getTranslation("selectTemplateDialogTitle")
|
2021-07-29 11:43:13 +02:00
|
|
|
|
templateNames = getTemplateNames()
|
|
|
|
|
listComponent.addItems(templateNames , 0)
|
|
|
|
|
dialog.setVisible(true)
|
|
|
|
|
Select Case dialog.Execute()
|
|
|
|
|
Case 1
|
|
|
|
|
templateName = listComponent.SelectedItem
|
|
|
|
|
If NOT (templateName="0" or templateName="") Then
|
|
|
|
|
config.setPropertyValue("predefined_template", templateName)
|
|
|
|
|
description = getTranslation("predefiendTemplateSelected") & " «" & templateName & "»"
|
|
|
|
|
styleFileDialog.getControl("Description").setText(description)
|
|
|
|
|
EndIf
|
|
|
|
|
Case 0
|
|
|
|
|
End Select
|
|
|
|
|
dialog.setVisible(false)
|
|
|
|
|
dialog.dispose()
|
|
|
|
|
End Sub
|
2020-04-23 14:15:18 +02:00
|
|
|
|
|
2021-07-29 11:43:13 +02:00
|
|
|
|
Sub setManualTemplate()
|
|
|
|
|
Dim description As String
|
2020-04-23 14:15:18 +02:00
|
|
|
|
Dim selectedTemplate As String
|
|
|
|
|
selectedTemplate = getFileURLDialog()
|
2020-04-23 14:33:18 +02:00
|
|
|
|
oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" )
|
|
|
|
|
If NOT (oSimpleFileAccess.exists( selectedTemplate ) AND NOT oSimpleFileAccess.isFolder( selectedTemplate ) ) Then
|
|
|
|
|
Exit sub
|
|
|
|
|
End If
|
2020-04-23 14:15:18 +02:00
|
|
|
|
Dim fileName As String
|
|
|
|
|
Dim config As Object
|
|
|
|
|
config = initRedactionConfiguration()
|
|
|
|
|
fileName = Dir(selectedTemplate)
|
|
|
|
|
config.setPropertyValue("defaultTemplate",fileName)
|
2021-07-29 11:43:13 +02:00
|
|
|
|
config.setPropertyValue("predefined_template", template_manual)
|
2020-04-23 14:15:18 +02:00
|
|
|
|
Dim templatePath As String
|
|
|
|
|
templatePath = getTemplatePath()
|
2021-01-14 12:09:53 +01:00
|
|
|
|
MkDir(templatePath)
|
2021-07-29 11:43:13 +02:00
|
|
|
|
FileCopy(selectedTemplate, templatePath & "/" & fileName)
|
|
|
|
|
description = getTranslation("manualStyleFileSet") & " «" & fileName & "»"
|
|
|
|
|
styleFileDialog.getControl("Description").setText(description)
|
2020-04-23 14:15:18 +02:00
|
|
|
|
End Sub
|
|
|
|
|
|
2021-07-29 11:43:13 +02:00
|
|
|
|
Function getFileURLDialog() As String
|
2020-04-23 14:15:18 +02:00
|
|
|
|
Dim oFilePicker As Object, oSimpleFileAccess As Object
|
|
|
|
|
Dim oSettings As Object, oPathSettings As Object
|
|
|
|
|
Dim oTextField As Object, oTextFieldModel As Object
|
|
|
|
|
Dim sFileURL As String
|
|
|
|
|
Dim sFiles As Variant
|
|
|
|
|
oFilePicker = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" )
|
|
|
|
|
oFilePicker.AppendFilter( "All files (*.*)", "*.*" )
|
|
|
|
|
oFilePicker.AppendFilter( "Open Document Text", "*.odt;*.ott" )
|
|
|
|
|
oFilePicker.SetCurrentFilter( "Open Document Text" )
|
|
|
|
|
If sFileURL = "" Then
|
|
|
|
|
oPathSettings = CreateUnoService( "com.sun.star.util.PathSettings" )
|
|
|
|
|
sFileURL = oPathSettings.Work
|
|
|
|
|
End If
|
|
|
|
|
REM set display directory
|
|
|
|
|
oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" )
|
|
|
|
|
If oSimpleFileAccess.exists( sFileURL ) And oSimpleFileAccess.isFolder( sFileURL ) Then
|
|
|
|
|
oFilePicker.setDisplayDirectory( sFileURL )
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
If oFilePicker.execute() Then
|
|
|
|
|
sFiles = oFilePicker.getFiles()
|
|
|
|
|
sFileURL = sFiles(0)
|
|
|
|
|
If oSimpleFileAccess.exists( sFileURL ) Then
|
|
|
|
|
getFileURLDialog = sFileURL
|
|
|
|
|
Exit Function
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
getFileURLDialog = ""
|
2021-07-29 11:43:13 +02:00
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Function getTemplateNames() As Variant
|
|
|
|
|
Dim names() As String
|
|
|
|
|
AddToArray(names, template_name_monography)
|
|
|
|
|
AddToArray(names, template_name_pq)
|
|
|
|
|
AddToArray(names, template_name_hp)
|
|
|
|
|
AddToArray(names, template_name_hpe)
|
|
|
|
|
AddToArray(names, template_name_pr)
|
|
|
|
|
AddToArray(names, template_name_fnit)
|
|
|
|
|
AddToArray(names, template_name_pa)
|
|
|
|
|
AddToArray(names, template_name_pcr)
|
|
|
|
|
AddToArray(names, template_name_eifn)
|
|
|
|
|
AddToArray(names, template_name_et)
|
|
|
|
|
getTemplateNames = names
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Function extensionPath() As String
|
|
|
|
|
Dim oPackageInfoProvider As Object
|
|
|
|
|
oPackageInfoProvider = GetDefaultContext.getByName("/singletons/com.sun.star.deployment.PackageInformationProvider")
|
|
|
|
|
extensionPath = oPackageInfoProvider.getPackageLocation("pro.litvinovg.Redaction")
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Function getTemplateFile(templateName As String) As String
|
|
|
|
|
Dim config As Object
|
|
|
|
|
Dim fileName As String
|
|
|
|
|
Select Case templateName
|
|
|
|
|
Case template_manual
|
|
|
|
|
config = initRedactionConfiguration()
|
|
|
|
|
fileName = config.getPropertyValue("defaultTemplate")
|
|
|
|
|
getTemplateFile = getTemplatePath() & "/" & fileName
|
|
|
|
|
Exit Function
|
|
|
|
|
Case template_name_pj
|
|
|
|
|
getTemplateFile = extensionPath() & "/templates/articles/default_article_template_ru.ott"
|
|
|
|
|
Exit Function
|
|
|
|
|
Case template_name_eifn
|
|
|
|
|
getTemplateFile = extensionPath() & "/templates/articles/статья_журнала_ЭиФН.ott"
|
|
|
|
|
Exit Function
|
|
|
|
|
Case Else
|
|
|
|
|
getTemplateFile = extensionPath() & "/templates/articles/default_article_template_ru.ott"
|
|
|
|
|
Exit Function
|
|
|
|
|
End Select
|
|
|
|
|
End Function
|
2021-01-15 20:03:04 +01:00
|
|
|
|
</script:module>
|