Translations and load template dialog
This commit is contained in:
parent
bd3b7706d8
commit
75fd6c8192
11 changed files with 221 additions and 15 deletions
|
@ -1,6 +1,6 @@
|
|||
<?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="Clean" script:language="StarBasic">Sub mark41
|
||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Clean" script:language="StarBasic">Sub mark43
|
||||
|
||||
End Sub
|
||||
|
||||
|
@ -8,7 +8,7 @@ Sub cleanButton
|
|||
Dim config As Object
|
||||
config = initRedactionConfiguration()
|
||||
If config.getPropertyValue("complexity") = "user" then
|
||||
quietCleaning()
|
||||
quietStartDialog()
|
||||
Else
|
||||
makerUpMenu()
|
||||
EndIf
|
||||
|
@ -116,10 +116,6 @@ Private Sub quietCleaning
|
|||
Dim description As String
|
||||
Dim statusIndicator As Object
|
||||
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
||||
description = "Вы уверены, что хотите выполнить чистку документа?"
|
||||
If NOT confirm(description) Then
|
||||
Exit Sub
|
||||
EndIf
|
||||
saveDocument
|
||||
statusIndicator.Start("Чистка документа начата, подождите",100)
|
||||
doNotTrack
|
||||
|
@ -409,12 +405,19 @@ Private Sub loadArticleStyles
|
|||
Dim fileTest As Object
|
||||
Dim fileName As String
|
||||
Dim aArgs(0) As New com.sun.star.beans.PropertyValue
|
||||
fileName = "Статья.ott"
|
||||
Dim config As Object
|
||||
config = initRedactionConfiguration()
|
||||
fileName = config.getPropertyValue("defaultTemplate")
|
||||
filePath = getTemplatePath() & "/" & fileName
|
||||
fileTest = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
|
||||
If NOT fileTest.exists(filePath) Then
|
||||
MsgBox "Файл стилей " & fileName & " не добавлен в Мои шаблоны. Не могу загрузить стили в текущий файл."
|
||||
Exit Sub
|
||||
noStylesFileDialog()
|
||||
fileName = config.getPropertyValue("defaultTemplate")
|
||||
filePath = getTemplatePath() & "/" & fileName
|
||||
If NOT fileTest.exists(filePath) Then
|
||||
'MsgBox "Файл стилей " & fileName & " не добавлен в Мои шаблоны. Не могу загрузить стили в текущий файл."
|
||||
Exit Sub
|
||||
EndIf
|
||||
EndIf
|
||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||
aArgs(0).Name = "OverwriteStyles"
|
||||
|
@ -1674,4 +1677,4 @@ Private Function insertUserField(cursor As Object,fieldName As String,fieldValue
|
|||
cursor.Text.insertTextContent(cursor, oField, False)
|
||||
oField.IsVisible = false
|
||||
End Function
|
||||
</script:module>
|
||||
</script:module>
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
|
||||
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="CleaningDialog" dlg:left="107" dlg:top="22" dlg:width="237" dlg:height="186" dlg:closeable="true" dlg:moveable="true">
|
||||
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="CleaningDialog" dlg:left="107" dlg:top="22" dlg:width="237" dlg:height="186" dlg:help-text="&21.CleaningDialog.HelpText" dlg:closeable="true" dlg:moveable="true" dlg:title="&22.CleaningDialog.Title">
|
||||
<dlg:bulletinboard>
|
||||
<dlg:button dlg:id="Cancel" dlg:tab-index="0" dlg:left="67" dlg:top="171" dlg:width="40" dlg:height="12" dlg:value="Отмена" dlg:button-type="cancel"/>
|
||||
<dlg:button dlg:id="CommandButton1" dlg:tab-index="1" dlg:left="43" dlg:top="170" dlg:width="2" dlg:height="0" dlg:value="CommandButton1"/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
|
||||
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="ConfigDialog" dlg:left="196" dlg:top="109" dlg:width="157" dlg:height="64" dlg:closeable="true" dlg:moveable="true">
|
||||
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="ConfigDialog" dlg:left="196" dlg:top="109" dlg:width="157" dlg:height="64" dlg:help-text="&23.ConfigDialog.HelpText" dlg:closeable="true" dlg:moveable="true" dlg:title="&24.ConfigDialog.Title">
|
||||
<dlg:bulletinboard>
|
||||
<dlg:checkbox dlg:id="CB_complexity" dlg:tab-index="0" dlg:left="5" dlg:top="13" dlg:width="150" dlg:height="19" dlg:value="Включить режим эксперта" dlg:checked="false"/>
|
||||
<dlg:button dlg:id="OK" dlg:tab-index="1" dlg:left="9" dlg:top="45" dlg:width="59" dlg:height="13" dlg:value="Сохранить" dlg:button-type="ok"/>
|
||||
|
|
|
@ -14,9 +14,12 @@ Function initRedactionConfiguration()
|
|||
|
||||
redactionProps = reg.openPropertySet(redactionExtensionName, TRUE)
|
||||
redactionProps.addProperty("complexity", 128, "user")
|
||||
initRedactionConfiguration = redactionProps
|
||||
exceptionHandler:
|
||||
exceptionHandler:
|
||||
Resume Next
|
||||
On Error Goto exceptionHandler2
|
||||
redactionProps.addProperty("defaultTemplate", 128, "Статья.ott")
|
||||
exceptionHandler2:
|
||||
Resume Next
|
||||
initRedactionConfiguration = redactionProps
|
||||
End Function
|
||||
|
||||
|
@ -56,4 +59,111 @@ Private Sub configurationDialog
|
|||
dialog.dispose()
|
||||
Exit sub
|
||||
End Sub
|
||||
|
||||
Private Sub quietStartDialog
|
||||
'Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
||||
Dim dialog As Object
|
||||
DialogLibraries.LoadLibrary("Redaction")
|
||||
dialog = CreateUnoDialog(DialogLibraries.Redaction.StartQuietCleaning)
|
||||
Dim lang As String
|
||||
lang = GetStarOfficeLocale().Language
|
||||
Dim description As String
|
||||
Dim buttonNameOk As String
|
||||
Dim buttonNameStop As String
|
||||
Dim buttonNameLoad As String
|
||||
description = getTranslation(lang,"startQuietCleaningDescription")
|
||||
buttonNameOk = getTranslation(lang,"buttonOk")
|
||||
buttonNameStop = getTranslation(lang,"buttonStop")
|
||||
buttonNameLoad = getTranslation(lang,"buttonLoad")
|
||||
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 lang As String
|
||||
lang = GetStarOfficeLocale().Language
|
||||
Dim description As String
|
||||
Dim buttonName As String
|
||||
description = getTranslation(lang,"noFileWithStylesFound")
|
||||
buttonName = getTranslation(lang,"buttonNameToSelectFileWithStyles")
|
||||
dialog.getControl("Description").setText(description)
|
||||
dialog.getControl("FileSelection").Label = buttonName
|
||||
dialog.setVisible(true)
|
||||
Select Case dialog.Execute()
|
||||
Case 1
|
||||
setDeafultTemplate(selectedTemplate)
|
||||
Case 0
|
||||
|
||||
End Select
|
||||
dialog.setVisible(false)
|
||||
dialog.dispose()
|
||||
Exit sub
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub setDeafultTemplate()
|
||||
Dim selectedTemplate As String
|
||||
selectedTemplate = getFileURLDialog()
|
||||
If IsEmpty(selectedTemplate) Then
|
||||
Exit sub
|
||||
EndIf
|
||||
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>
|
10
Redaction/NoStyleFile.xdl
Normal file
10
Redaction/NoStyleFile.xdl
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
|
||||
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="NoStyleFile" dlg:left="140" dlg:top="101" dlg:width="239" dlg:height="98" dlg:help-text="&5.NoStyleFile.HelpText" dlg:closeable="true" dlg:moveable="true" dlg:title="&6.NoStyleFile.Title">
|
||||
<dlg:bulletinboard>
|
||||
<dlg:button dlg:id="CommandButton1" dlg:tab-index="0" dlg:left="138" dlg:top="75" dlg:width="60" dlg:height="13" dlg:help-text="&13.NoStyleFile.CommandButton1.HelpText" dlg:value="&14.NoStyleFile.CommandButton1.Label" dlg:button-type="cancel"/>
|
||||
<dlg:button dlg:id="CommandButton2" dlg:tab-index="1" dlg:left="167" dlg:top="139" dlg:width="1" dlg:height="0" dlg:help-text="&15.NoStyleFile.CommandButton2.HelpText" dlg:value="&16.NoStyleFile.CommandButton2.Label"/>
|
||||
<dlg:button dlg:id="FileSelection" dlg:tab-index="2" dlg:left="46" dlg:top="75" dlg:width="60" dlg:height="13" dlg:help-text="&19.NoStyleFile.FileSelection.HelpText" dlg:value="&20.NoStyleFile.FileSelection.Label" dlg:button-type="ok"/>
|
||||
<dlg:text dlg:id="Description" dlg:tab-index="3" dlg:left="23" dlg:top="13" dlg:width="192" dlg:height="52" dlg:help-text="&27.NoStyleFile.Description.HelpText" dlg:value="&28.NoStyleFile.Description.Label"/>
|
||||
</dlg:bulletinboard>
|
||||
</dlg:window>
|
12
Redaction/StartQuietCleaning.xdl
Normal file
12
Redaction/StartQuietCleaning.xdl
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
|
||||
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="StartQuietCleaning" dlg:left="124" dlg:top="101" dlg:width="222" dlg:height="96" dlg:help-text="&29.StartQuietCleaning.HelpText" dlg:closeable="true" dlg:moveable="true" dlg:title="&30.StartQuietCleaning.Title">
|
||||
<dlg:bulletinboard>
|
||||
<dlg:text dlg:id="Description" dlg:tab-index="0" dlg:left="15" dlg:top="18" dlg:width="194" dlg:height="40" dlg:help-text="&33.StartQuietCleaning.Description.HelpText" dlg:value="&34.StartQuietCleaning.Description.Label"/>
|
||||
<dlg:button dlg:id="buttonOk" dlg:tab-index="1" dlg:left="15" dlg:top="71" dlg:width="52" dlg:height="17" dlg:help-text="&55.StartQuietCleaning.buttonOk.HelpText" dlg:value="&56.StartQuietCleaning.buttonOk.Label" dlg:button-type="ok"/>
|
||||
<dlg:button dlg:id="buttonStop" dlg:tab-index="3" dlg:left="84" dlg:top="71" dlg:width="52" dlg:height="17" dlg:help-text="&57.StartQuietCleaning.buttonStop.HelpText" dlg:value="&58.StartQuietCleaning.buttonStop.Label" dlg:button-type="cancel"/>
|
||||
<dlg:button dlg:id="buttonLoad" dlg:tab-index="2" dlg:left="156" dlg:top="71" dlg:width="52" dlg:height="17" dlg:help-text="&59.StartQuietCleaning.buttonLoad.HelpText" dlg:value="&60.StartQuietCleaning.buttonLoad.Label">
|
||||
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Redaction.Configuration.noStylesFileDialog?language=Basic&location=application" script:language="Script"/>
|
||||
</dlg:button>
|
||||
</dlg:bulletinboard>
|
||||
</dlg:window>
|
67
Redaction/Translations.xba
Normal file
67
Redaction/Translations.xba
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?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="Translations" script:language="StarBasic" script:moduleType="normal">
|
||||
Function getTranslation(lang As String, identifier As String) As String
|
||||
Select Case lang
|
||||
Case "ru"
|
||||
getTranslation = getRussian(identifier)
|
||||
Exit Function
|
||||
Case Else
|
||||
getTranslation = getEnglish(identifier)
|
||||
Exit Function
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Function getRussian(identifier As String) As String
|
||||
Select Case identifier
|
||||
Case "noFileWithStylesFound"
|
||||
getRussian = "Файл-шаблон, содержащий стили для загрузки в документ не был задан. " & chr(10) &"Вы можете выбрать новый файл-шаблон. " & chr(10) & "Если файл-шаблон не будет выбран, то данный этап чистки будет пропущен."
|
||||
Exit Function
|
||||
Case "startQuietCleaningDescription"
|
||||
getRussian = "Вы хотите запустить чистку документа? " & chr(10) & "Здесь Вы можете также указать новый файл-шаблон." & chr(10) & "Стили из шаблона будут загружены в документ."
|
||||
Exit Function
|
||||
Case "buttonOk"
|
||||
getRussian = "Да"
|
||||
Exit Function
|
||||
Case "buttonStop"
|
||||
getRussian = "Нет"
|
||||
Exit Function
|
||||
Case "buttonLoad"
|
||||
getRussian = "Указать шаблон"
|
||||
Exit Function
|
||||
Case "buttonNameToSelectFileWithStyles"
|
||||
getRussian = "Указать файл"
|
||||
Exit Function
|
||||
Case Else
|
||||
getRussian = getEnglish(identifier)
|
||||
End Select
|
||||
|
||||
End Function
|
||||
|
||||
Function getEnglish(identifier As String) As String
|
||||
Select Case identifier
|
||||
Case "noFileWithStylesFound"
|
||||
getEnglish = "Template with styles wasn't found. You can choose template on your computer. This stage of cleaning will be skipped if no file chosen."
|
||||
Exit Function
|
||||
Case "startQuietCleaningDescription"
|
||||
getEnglish = "Do you want to start document cleaning?" & chr(10) & "You can choose template with styles to load them in process of the cleaning."
|
||||
Exit Function
|
||||
Case "buttonOk"
|
||||
getEnglish = "Ok"
|
||||
Exit Function
|
||||
Case "buttonStop"
|
||||
getEnglish = "Cancel"
|
||||
Exit Function
|
||||
Case "buttonLoad"
|
||||
getEnglish = "Set template"
|
||||
Exit Function
|
||||
Case "buttonNameToSelectFileWithStyles"
|
||||
getEnglish = "Select file"
|
||||
Exit Function
|
||||
Case Else
|
||||
getEnglish = "No translation"
|
||||
End Select
|
||||
End Function
|
||||
|
||||
|
||||
</script:module>
|
|
@ -269,4 +269,5 @@ Private Sub StopTracking
|
|||
args1(0).Value = true
|
||||
dispatcher.executeDispatch(document, ".uno:ShowTrackedChanges", "", 0, args1())
|
||||
End Sub
|
||||
|
||||
</script:module>
|
|
@ -3,4 +3,6 @@
|
|||
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="Redaction" library:readonly="false" library:passwordprotected="false">
|
||||
<library:element library:name="ConfigDialog"/>
|
||||
<library:element library:name="CleaningDialog"/>
|
||||
<library:element library:name="NoStyleFile"/>
|
||||
<library:element library:name="StartQuietCleaning"/>
|
||||
</library:library>
|
|
@ -4,4 +4,5 @@
|
|||
<library:element library:name="Validation"/>
|
||||
<library:element library:name="Clean"/>
|
||||
<library:element library:name="Configuration"/>
|
||||
<library:element library:name="Translations"/>
|
||||
</library:library>
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:dep="http://openoffice.org/extensions/description/2006"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<identifier value="pro.litvinovg.Redaction" />
|
||||
<version value="0.6.6" />
|
||||
<version value="0.7.1" />
|
||||
<platform value="all" />
|
||||
<display-name>
|
||||
<name lang="en">Cleaning and validation documents for publishing in html and epub with pagination</name>
|
||||
|
|
Loading…
Add table
Reference in a new issue