feat: predefined templates provided
This commit is contained in:
parent
65dee0354c
commit
52e00175a2
12 changed files with 200 additions and 54 deletions
|
@ -1,7 +1,20 @@
|
|||
<?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.30"
|
||||
<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"
|
||||
|
||||
Function initRedactionConfiguration()
|
||||
On Error Goto exceptionHandler
|
||||
Dim regFactory As Object
|
||||
|
@ -21,6 +34,9 @@ Function initRedactionConfiguration()
|
|||
EndIf
|
||||
If Not propSetInfo.hasPropertyByName("fixes_russian_iph") Then
|
||||
redactionProps.addProperty("fixes_russian_iph", 128, "true")
|
||||
EndIf
|
||||
If Not propSetInfo.hasPropertyByName("predefined_template") Then
|
||||
redactionProps.addProperty("predefined_template", 128, "false")
|
||||
EndIf
|
||||
If Not propSetInfo.hasPropertyByName("complexity") Then
|
||||
redactionProps.addProperty("complexity", 128, "user")
|
||||
|
@ -30,7 +46,10 @@ Function initRedactionConfiguration()
|
|||
On Error Goto exceptionHandler2
|
||||
If Not propSetInfo.hasPropertyByName("defaultTemplate") Then
|
||||
redactionProps.addProperty("defaultTemplate", 128, "Статья.ott")
|
||||
EndIf
|
||||
EndIf
|
||||
If Not propSetInfo.hasPropertyByName("predefined_template") Then
|
||||
redactionProps.addProperty("predefined_template", 128, "false")
|
||||
EndIf
|
||||
exceptionHandler2:
|
||||
Resume Next
|
||||
initRedactionConfiguration = redactionProps
|
||||
|
@ -137,38 +156,71 @@ Private Sub quietStartDialog
|
|||
Exit sub
|
||||
End Sub
|
||||
|
||||
Private Sub noStylesFileDialog
|
||||
Dim styleFileDialog As Object
|
||||
|
||||
Private Sub configureStyleFileDialog
|
||||
'Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
||||
Dim config As Object
|
||||
Dim dialog As Object
|
||||
Dim predefined As String
|
||||
Dim description As String
|
||||
Dim customFile As String
|
||||
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()
|
||||
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()
|
||||
Case 0
|
||||
|
||||
End Select
|
||||
dialog.setVisible(false)
|
||||
dialog.dispose()
|
||||
Exit sub
|
||||
styleFileDialog.setVisible(false)
|
||||
styleFileDialog.dispose()
|
||||
End Sub
|
||||
|
||||
|
||||
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")
|
||||
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
|
||||
|
||||
Sub setDeafultTemplate()
|
||||
Sub setManualTemplate()
|
||||
Dim description As String
|
||||
Dim selectedTemplate As String
|
||||
selectedTemplate = getFileURLDialog()
|
||||
oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" )
|
||||
|
@ -180,13 +232,16 @@ Sub setDeafultTemplate()
|
|||
config = initRedactionConfiguration()
|
||||
fileName = Dir(selectedTemplate)
|
||||
config.setPropertyValue("defaultTemplate",fileName)
|
||||
config.setPropertyValue("predefined_template", template_manual)
|
||||
Dim templatePath As String
|
||||
templatePath = getTemplatePath()
|
||||
MkDir(templatePath)
|
||||
FileCopy(selectedTemplate, templatePath & "/" & fileName)
|
||||
FileCopy(selectedTemplate, templatePath & "/" & fileName)
|
||||
description = getTranslation("manualStyleFileSet") & " «" & fileName & "»"
|
||||
styleFileDialog.getControl("Description").setText(description)
|
||||
End Sub
|
||||
|
||||
Function getFileURLDialog() As String
|
||||
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
|
||||
|
@ -215,5 +270,48 @@ End Sub
|
|||
End If
|
||||
End If
|
||||
getFileURLDialog = ""
|
||||
End Function
|
||||
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
|
||||
</script:module>
|
Loading…
Add table
Add a link
Reference in a new issue