Translations and load template dialog

This commit is contained in:
Georgy Litvinov 2020-04-23 14:15:18 +02:00
parent bd3b7706d8
commit 75fd6c8192
11 changed files with 221 additions and 15 deletions

View file

@ -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(&quot;complexity&quot;) = &quot;user&quot; 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 = &quot;Вы уверены, что хотите выполнить чистку документа?&quot;
If NOT confirm(description) Then
Exit Sub
EndIf
saveDocument
statusIndicator.Start(&quot;Чистка документа начата, подождите&quot;,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 = &quot;Статья.ott&quot;
Dim config As Object
config = initRedactionConfiguration()
fileName = config.getPropertyValue(&quot;defaultTemplate&quot;)
filePath = getTemplatePath() &amp; &quot;/&quot; &amp; fileName
fileTest = CreateUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
If NOT fileTest.exists(filePath) Then
MsgBox &quot;Файл стилей &quot; &amp; fileName &amp; &quot; не добавлен в Мои шаблоны. Не могу загрузить стили в текущий файл.&quot;
Exit Sub
noStylesFileDialog()
fileName = config.getPropertyValue(&quot;defaultTemplate&quot;)
filePath = getTemplatePath() &amp; &quot;/&quot; &amp; fileName
If NOT fileTest.exists(filePath) Then
&apos;MsgBox &quot;Файл стилей &quot; &amp; fileName &amp; &quot; не добавлен в Мои шаблоны. Не могу загрузить стили в текущий файл.&quot;
Exit Sub
EndIf
EndIf
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
aArgs(0).Name = &quot;OverwriteStyles&quot;
@ -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>

View file

@ -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="&amp;21.CleaningDialog.HelpText" dlg:closeable="true" dlg:moveable="true" dlg:title="&amp;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"/>

View file

@ -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="&amp;23.ConfigDialog.HelpText" dlg:closeable="true" dlg:moveable="true" dlg:title="&amp;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"/>

View file

@ -14,9 +14,12 @@ Function initRedactionConfiguration()
redactionProps = reg.openPropertySet(redactionExtensionName, TRUE)
redactionProps.addProperty(&quot;complexity&quot;, 128, &quot;user&quot;)
initRedactionConfiguration = redactionProps
exceptionHandler:
exceptionHandler:
Resume Next
On Error Goto exceptionHandler2
redactionProps.addProperty(&quot;defaultTemplate&quot;, 128, &quot;Статья.ott&quot;)
exceptionHandler2:
Resume Next
initRedactionConfiguration = redactionProps
End Function
@ -56,4 +59,111 @@ Private Sub configurationDialog
dialog.dispose()
Exit sub
End Sub
Private Sub quietStartDialog
&apos;Globalscope.BasicLibraries.LoadLibrary( &quot;MRILib&quot; )
Dim dialog As Object
DialogLibraries.LoadLibrary(&quot;Redaction&quot;)
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,&quot;startQuietCleaningDescription&quot;)
buttonNameOk = getTranslation(lang,&quot;buttonOk&quot;)
buttonNameStop = getTranslation(lang,&quot;buttonStop&quot;)
buttonNameLoad = getTranslation(lang,&quot;buttonLoad&quot;)
dialog.getControl(&quot;Description&quot;).setText(description)
dialog.getControl(&quot;buttonOk&quot;).Label = buttonNameOk
dialog.getControl(&quot;buttonStop&quot;).Label = buttonNameStop
dialog.getControl(&quot;buttonLoad&quot;).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
&apos;Globalscope.BasicLibraries.LoadLibrary( &quot;MRILib&quot; )
Dim dialog As Object
DialogLibraries.LoadLibrary(&quot;Redaction&quot;)
dialog = CreateUnoDialog(DialogLibraries.Redaction.NoStyleFile)
Dim lang As String
lang = GetStarOfficeLocale().Language
Dim description As String
Dim buttonName As String
description = getTranslation(lang,&quot;noFileWithStylesFound&quot;)
buttonName = getTranslation(lang,&quot;buttonNameToSelectFileWithStyles&quot;)
dialog.getControl(&quot;Description&quot;).setText(description)
dialog.getControl(&quot;FileSelection&quot;).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(&quot;defaultTemplate&quot;,fileName)
Dim templatePath As String
templatePath = getTemplatePath()
FileCopy(selectedTemplate, templatePath &amp; &quot;/&quot; &amp; 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( &quot;com.sun.star.ui.dialogs.FilePicker&quot; )
oFilePicker.AppendFilter( &quot;All files (*.*)&quot;, &quot;*.*&quot; )
oFilePicker.AppendFilter( &quot;Open Document Text&quot;, &quot;*.odt;*.ott&quot; )
oFilePicker.SetCurrentFilter( &quot;Open Document Text&quot; )
If sFileURL = &quot;&quot; Then
oPathSettings = CreateUnoService( &quot;com.sun.star.util.PathSettings&quot; )
sFileURL = oPathSettings.Work
End If
REM set display directory
oSimpleFileAccess = CreateUnoService( &quot;com.sun.star.ucb.SimpleFileAccess&quot; )
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 = &quot;&quot;
End Function
</script:module>

10
Redaction/NoStyleFile.xdl Normal file
View 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="&amp;5.NoStyleFile.HelpText" dlg:closeable="true" dlg:moveable="true" dlg:title="&amp;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="&amp;13.NoStyleFile.CommandButton1.HelpText" dlg:value="&amp;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="&amp;15.NoStyleFile.CommandButton2.HelpText" dlg:value="&amp;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="&amp;19.NoStyleFile.FileSelection.HelpText" dlg:value="&amp;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="&amp;27.NoStyleFile.Description.HelpText" dlg:value="&amp;28.NoStyleFile.Description.Label"/>
</dlg:bulletinboard>
</dlg:window>

View 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="&amp;29.StartQuietCleaning.HelpText" dlg:closeable="true" dlg:moveable="true" dlg:title="&amp;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="&amp;33.StartQuietCleaning.Description.HelpText" dlg:value="&amp;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="&amp;55.StartQuietCleaning.buttonOk.HelpText" dlg:value="&amp;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="&amp;57.StartQuietCleaning.buttonStop.HelpText" dlg:value="&amp;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="&amp;59.StartQuietCleaning.buttonLoad.HelpText" dlg:value="&amp;60.StartQuietCleaning.buttonLoad.Label">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Redaction.Configuration.noStylesFileDialog?language=Basic&amp;location=application" script:language="Script"/>
</dlg:button>
</dlg:bulletinboard>
</dlg:window>

View 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 &quot;ru&quot;
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 &quot;noFileWithStylesFound&quot;
getRussian = &quot;Файл-шаблон, содержащий стили для загрузки в документ не был задан. &quot; &amp; chr(10) &amp;&quot;Вы можете выбрать новый файл-шаблон. &quot; &amp; chr(10) &amp; &quot;Если файл-шаблон не будет выбран, то данный этап чистки будет пропущен.&quot;
Exit Function
Case &quot;startQuietCleaningDescription&quot;
getRussian = &quot;Вы хотите запустить чистку документа? &quot; &amp; chr(10) &amp; &quot;Здесь Вы можете также указать новый файл-шаблон.&quot; &amp; chr(10) &amp; &quot;Стили из шаблона будут загружены в документ.&quot;
Exit Function
Case &quot;buttonOk&quot;
getRussian = &quot;Да&quot;
Exit Function
Case &quot;buttonStop&quot;
getRussian = &quot;Нет&quot;
Exit Function
Case &quot;buttonLoad&quot;
getRussian = &quot;Указать шаблон&quot;
Exit Function
Case &quot;buttonNameToSelectFileWithStyles&quot;
getRussian = &quot;Указать файл&quot;
Exit Function
Case Else
getRussian = getEnglish(identifier)
End Select
End Function
Function getEnglish(identifier As String) As String
Select Case identifier
Case &quot;noFileWithStylesFound&quot;
getEnglish = &quot;Template with styles wasn&apos;t found. You can choose template on your computer. This stage of cleaning will be skipped if no file chosen.&quot;
Exit Function
Case &quot;startQuietCleaningDescription&quot;
getEnglish = &quot;Do you want to start document cleaning?&quot; &amp; chr(10) &amp; &quot;You can choose template with styles to load them in process of the cleaning.&quot;
Exit Function
Case &quot;buttonOk&quot;
getEnglish = &quot;Ok&quot;
Exit Function
Case &quot;buttonStop&quot;
getEnglish = &quot;Cancel&quot;
Exit Function
Case &quot;buttonLoad&quot;
getEnglish = &quot;Set template&quot;
Exit Function
Case &quot;buttonNameToSelectFileWithStyles&quot;
getEnglish = &quot;Select file&quot;
Exit Function
Case Else
getEnglish = &quot;No translation&quot;
End Select
End Function
</script:module>

View file

@ -269,4 +269,5 @@ Private Sub StopTracking
args1(0).Value = true
dispatcher.executeDispatch(document, &quot;.uno:ShowTrackedChanges&quot;, &quot;&quot;, 0, args1())
End Sub
</script:module>

View file

@ -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>

View file

@ -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>

View file

@ -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>