201 lines
No EOL
7.8 KiB
XML
201 lines
No EOL
7.8 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Configuration" script:language="StarBasic" script:moduleType="normal">Public Const redactionExtensionName As String = "cleanAndValidate"
|
|
Public Const redactionExtensionVersion = "0.9.17"
|
|
Function initRedactionConfiguration()
|
|
On Error Goto exceptionHandler
|
|
Dim regFactory As Object
|
|
Dim reg As Object
|
|
Dim redactionProps As Object
|
|
Dim props(2) As New com.sun.star.beans.PropertyValue
|
|
Dim propSetInfo As Object
|
|
regFactory = CreateUnoService("com.sun.star.ucb.Store")
|
|
reg = regFactory.createPropertySetRegistry(redactionExtensionName)
|
|
redactionProps = reg.openPropertySet(redactionExtensionName, TRUE)
|
|
propSetInfo = redactionProps.getPropertySetInfo()
|
|
If Not propSetInfo.hasPropertyByName("fixes_russian_iph") Then
|
|
redactionProps.addProperty("fixes_russian_iph", 128, "true")
|
|
EndIf
|
|
If Not propSetInfo.hasPropertyByName("complexity") Then
|
|
redactionProps.addProperty("complexity", 128, "user")
|
|
EndIf
|
|
exceptionHandler:
|
|
Resume Next
|
|
On Error Goto exceptionHandler2
|
|
If Not propSetInfo.hasPropertyByName("complexity") Then
|
|
redactionProps.addProperty("defaultTemplate", 128, "Статья.ott")
|
|
EndIf
|
|
exceptionHandler2:
|
|
Resume Next
|
|
initRedactionConfiguration = redactionProps
|
|
End Function
|
|
|
|
Private Sub setConfigFromDialog(dialog As Object)
|
|
Dim config As Object
|
|
config = initRedactionConfiguration()
|
|
|
|
If dialog.getControl("CB_complexity").state = 1 Then
|
|
config.setPropertyValue("complexity", "makerUp")
|
|
Else
|
|
config.setPropertyValue("complexity", "user")
|
|
EndIf
|
|
|
|
If dialog.getControl("cb_russian_fixes_iph").state = 1 Then
|
|
config.setPropertyValue("fixes_russian_iph", "true")
|
|
Else
|
|
config.setPropertyValue("fixes_russian_iph", "false")
|
|
EndIf
|
|
|
|
End Sub
|
|
|
|
Private Sub loadConfigToDialog(dialog As Object)
|
|
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
|
|
|
|
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
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub configurationDialog
|
|
Dim dialog As Object
|
|
DialogLibraries.LoadLibrary("Redaction")
|
|
dialog = CreateUnoDialog(DialogLibraries.Redaction.ConfigDialog)
|
|
loadConfigToDialog(dialog)
|
|
dialog.getControl("CB_complexity").Label = getTranslation("dialogConfigComplexity")
|
|
dialog.getControl("cb_russian_fixes_iph").Label = getTranslation("dialogRussianFixesIPH")
|
|
dialog.Title = getTranslation("dialogConfigTitle")
|
|
dialog.getControl("OK").Label = getTranslation("buttonYes")
|
|
dialog.getControl("CANCEL").Label = getTranslation("buttonStop")
|
|
dialog.setVisible(true)
|
|
Select Case dialog.Execute()
|
|
Case 1
|
|
setConfigFromDialog(dialog)
|
|
Case 0
|
|
End Select
|
|
dialog.setVisible(false)
|
|
dialog.dispose()
|
|
Exit sub
|
|
End Sub
|
|
|
|
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
|
|
Dim dialogTitle As String
|
|
description = getTranslation("startQuietCleaningDescription")
|
|
buttonNameOk = getTranslation("buttonYes")
|
|
buttonNameStop = getTranslation("buttonStop")
|
|
buttonNameLoad = getTranslation("buttonLoad")
|
|
dialogTitle = getTranslation("quietStartCleaningTitle")
|
|
dialog.Title = dialogTitle
|
|
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
|
|
|
|
Private Sub noStylesFileDialog
|
|
'Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
|
Dim dialog As Object
|
|
DialogLibraries.LoadLibrary("Redaction")
|
|
dialog = CreateUnoDialog(DialogLibraries.Redaction.NoStyleFile)
|
|
Dim description As String
|
|
Dim buttonName As String
|
|
Dim dialogTitle As String
|
|
Dim buttonTemplateNotFoundSkip As String
|
|
dialogTitle = getTranslation("noStylesFileDialogTitle")
|
|
description = getTranslation("noFileWithStylesFound")
|
|
buttonName = getTranslation("buttonNameToSelectFileWithStyles")
|
|
buttonTemplateNotFoundSkip = getTranslation("buttonTemplateNotFoundSkip")
|
|
dialog.Title = dialogTitle
|
|
dialog.getControl("Description").setText(description)
|
|
dialog.getControl("FileSelection").Label = buttonName
|
|
dialog.getControl("buttonOk").Label = buttonTemplateNotFoundSkip
|
|
dialog.setVisible(true)
|
|
Select Case dialog.Execute()
|
|
Case 1
|
|
setDeafultTemplate()
|
|
Case 0
|
|
|
|
End Select
|
|
dialog.setVisible(false)
|
|
dialog.dispose()
|
|
Exit sub
|
|
End Sub
|
|
|
|
|
|
|
|
Sub setDeafultTemplate()
|
|
Dim selectedTemplate As String
|
|
selectedTemplate = getFileURLDialog()
|
|
oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" )
|
|
If NOT (oSimpleFileAccess.exists( selectedTemplate ) AND NOT oSimpleFileAccess.isFolder( selectedTemplate ) ) Then
|
|
Exit sub
|
|
End If
|
|
Dim fileName As String
|
|
Dim config As Object
|
|
config = initRedactionConfiguration()
|
|
fileName = Dir(selectedTemplate)
|
|
config.setPropertyValue("defaultTemplate",fileName)
|
|
Dim templatePath As String
|
|
templatePath = getTemplatePath()
|
|
FileCopy(selectedTemplate, templatePath & "/" & fileName)
|
|
End Sub
|
|
|
|
Function getFileURLDialog() As String
|
|
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 = ""
|
|
End Function
|
|
</script:module> |