1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"DialogModul" script:
language=
"StarBasic">Option Explicit
22 Public Const bDebugWizard = True
24 Public Const SBFIRSTAPPLCHECKED =
0
25 Public Const SBSECONDAPPLCHECKED =
1
26 Public Const SBTHIRDAPPLCHECKED =
2
27 Public Const SBFOURTHAPPLCHECKED =
3
28 Public WizardMode as String
29 Public Const SBMICROSOFTMODE =
"MS
"
30 ' The absolute maximal Number of possible Applications
31 Public Const SBMAXAPPLCOUNT =
4
32 Public Const Twip =
425
33 Public MaxApplCount as Integer
34 Public CurOffice As Integer
35 Public SOBitmapPath As String
36 Public SOWorkPath As String
37 Public SOTemplatePath as String
38 Public bCancelTask As Boolean
39 Public bDoKeepApplValues as Boolean
40 Public iApplSection as Integer
42 Public PathSeparator as String
44 Public ApplCount as Integer
45 Public sKeyName(SBMAXAPPLCOUNT-
1) as String
46 Public sValueName(SBMAXAPPLCOUNT-
1) as String
47 Public sCRLF as String
48 Public MSFilterName(
5,
4) as String
50 Public Applications(SBMAXAPPLCOUNT-
1,
9)
52 Public Const SBAPPLCONVERT =
0
53 Public Const SBDOCCONVERT =
1
54 Public Const SBDOCRECURSIVE =
2
55 Public Const SBDOCSOURCE =
3
56 Public Const SBDOCTARGET =
4
57 Public Const SBTEMPLCONVERT =
5
58 Public Const SBTEMPLRECURSIVE =
6
59 Public Const SBTEMPLSOURCE =
7
60 Public Const SBTEMPLTARGET =
8
61 Public Const SBAPPLKEY =
9
62 Public XMLTemplateList()
64 ' Application-relating Data are stored in this Array
65 ' according to the following structure:
66 ' Applications(X,
0) = True/False (Application is to be converted)
67 ' Applications(X,
1) = True/False (Documents are to be converted)
68 ' Applications(X,
2) = True/False (Including Subdirectories)
69 ' Applications(X,
3) =
"File:///...
" (SourceUrl of the documents)
70 ' Applications(X,
4) =
"File///:...
" (TargetUrl of the documents)
71 ' Applications(X,
5) = True/False (Templates are to be converted)
72 ' Applications(X,
6) = True/False (Including Subdirectories)
73 ' Applications(X,
7) =
"File:///...
" (SourceUrl of the templates)
74 ' Applications(X,
8) =
"File:///...
" (TargetUrl of the templates)
75 ' Applications(X,
9) =
0 (Key to the original Index of the Applications)
78 Sub FillStep_Welcome()
80 ' bDoKeepApplValues = False
81 ImportDialogArea.Title = sTitle
83 .cmdHelp.Label = sHelpButton
84 .cmdCancel.Label = sCancelButton
85 .cmdBack.Label = sBackButton
86 .cmdGoOn.Label = sNextButton
87 .WelcomeTextLabel.Label = sWelcomeTextLabel1
88 .WelcomeTextLabel3.Label = sWelcomeTextLabel3
90 .optMSDocuments.Label = sContainerName(
0)
91 .chkMSApplication1.Label = sMsDocumentCheckbox(
0)
92 .chkMSApplication2.Label = sMsDocumentCheckbox(
1)
93 .chkMSApplication3.Label = sMsDocumentCheckbox(
2)
95 .cmdBack.Enabled = False
98 If Not oFactoryKey.hasbyName(
"com.sun.star.text.TextDocument
") Then
100 .chkLogfile.Enabled = False
103 CheckModuleInstallation()
108 Sub FillStep_InputPaths(OfficeIndex as Integer, bStartup as Boolean)
110 Dim oNullObject as Object
111 If bStartup And Not bDoKeepApplValues Then
112 If ImportDialog.optMSDocuments.State =
1 Then
113 SetupMSConfiguration()
115 'Not supposed to happen - is there an assert in BASIC...
117 FillUpApplicationList()
119 CurOffice = OfficeIndex
120 Index = Applications(CurOffice,SBAPPLKEY)
121 InitializePathsforCurrentApplication(Index)
123 .chkTemplatePath.Label = sTemplateCheckbox(Index)
124 .chkDocumentPath.State = Abs(Applications(CurOffice,SBDOCCONVERT))
125 .chkDocumentSearchSubDir.State = Abs(Applications(CurOffice,SBDOCRECURSIVE))
126 .txtDocumentImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCSOURCE))
127 .txtDocumentExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCTARGET))
128 .hlnDocuments.Label = sProgressMoreDocs
129 If WizardMode = SBMICROSOFTMODE Then
130 ImportDialogArea.Title = sTitle
& " -
" & sMSDocumentCheckBox(Index)
132 .chkTemplatePath.Enabled = True
133 .chkDocumentPath.Enabled = True
134 .chkTemplatePath.Label = sTemplateCheckbox(Index)
135 .chkDocumentPath.Label = sDocumentCheckbox(Index)
136 .hlnTemplates.Label = sProgressMoreTemplates
137 .chkTemplatePath.State = Abs(Applications(CurOffice,SBTEMPLCONVERT))
138 ToggleInputPaths(oNullObject,
"Template
")
139 ToggleInputPaths(oNullObject,
"Document
")
140 .chkTemplateSearchSubDir.State = Abs(Applications(CurOffice,SBTEMPLRECURSIVE))
141 .txtTemplateImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLSOURCE))
142 .txtTemplateExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLTARGET))
143 .cmdGoOn.Label = sNextButton
144 .cmdBack.Enabled = True
145 ImportDialog.Step =
2
147 ImportDialogArea.GetControl(
"chkTemplatePath
").SetFocus()
152 Sub FillUpApplicationList()
155 Dim BoolValue as Boolean
156 If Not bDoKeepApplValues Then
158 For i =
1 To ApplCount
159 If ImportDialog.optMSDocuments.State =
1 Then
160 BoolValue = ImportDialogArea.GetControl(
"chkMSApplication
" & i).Model.State =
1
162 Applications(a,SBAPPLCONVERT) = BoolValue
163 Applications(a,SBDOCCONVERT) = BoolValue
164 Applications(a,SBDOCRECURSIVE) = BoolValue
165 Applications(a,SBDOCSOURCE) =
"" ' GetDefaultPath(i)
166 Applications(a,SBDOCTARGET) =
"" ' SOWorkPath
167 Applications(a,SBTEMPLCONVERT) = BoolValue
168 Applications(a,SBTEMPLRECURSIVE) = BoolValue
169 Applications(a,SBTEMPLSOURCE) =
"" ' GetTemplateDefaultPath(i)
170 Applications(a,SBTEMPLTARGET) =
"" ' GetTargetTemplatePath(i)
171 Applications(a,SBAPPLKEY) = i-
1
181 Sub InitializePathsforCurrentApplication(i as Integer)
182 AssignPathToCurrentApplication(SBDOCSOURCE, GetDefaultPath(i))
183 AssignPathToCurrentApplication(SBDOCTARGET, SOWorkPath)
184 AssignPathToCurrentApplication(SBTEMPLSOURCE, GetTemplateDefaultPath(i))
185 AssignPathToCurrentApplication(SBTEMPLTARGET, GetTargetTemplatePath(i))
189 Sub AssignPathToCurrentApplication(Index as Integer, NewPath as String)
190 If Applications(CurOffice,Index) =
"" Then
191 If CurOffice
> 0 Then
192 Applications(CurOffice,Index) = Applications(CurOffice-
1,Index)
194 Applications(CurOffice,Index) = NewPath
200 Sub SaveStep_InputPath()
201 Applications(CurOffice,SBDOCCONVERT) = ImportDialog.chkDocumentPath.State =
1
202 Applications(CurOffice,SBDOCRECURSIVE) = ImportDialog.chkDocumentSearchSubDir.State =
1
203 Applications(CurOffice,SBDOCSOURCE) = ConvertToURL(ImportDialog.txtDocumentImportPath.Text)
204 Applications(CurOffice,SBDOCTARGET) = ConvertToUrl(ImportDialog.txtDocumentExportPath.Text)
205 Applications(CurOffice,SBTEMPLCONVERT) = ImportDialog.chkTemplatePath.State =
1
206 Applications(CurOffice,SBTEMPLRECURSIVE) = ImportDialog.chkTemplateSearchSubDir.State =
1
207 Applications(CurOffice,SBTEMPLSOURCE) = ConvertToURL(ImportDialog.txtTemplateImportPath.Text)
208 Applications(CurOffice,SBTEMPLTARGET) = ConvertToURL(ImportDialog.txtTemplateExportPath.Text)
212 Sub ToggleInputPaths(aEvent as Object, Optional sDocType)
213 Dim bDoEnable as Boolean
214 Dim sLocDocType as String
215 Dim oCheckBox as Object
216 If Not IsNull(aEvent) Then
217 sLocDocType = aEvent.Source.Model.Tag
219 sLocDocType = sDocType
221 With ImportDialogArea
222 oCheckBox = .GetControl(
"chk
" & sLocDocType
& "Path
").Model
223 bDoEnable = oCheckBox.State =
1 And oCheckBox.Enabled
224 .GetControl(
"lbl
" & sLocDocType
& "Import
").Model.Enabled = bDoEnable
225 .GetControl(
"lbl
" & sLocDocType
& "Export
").Model.Enabled = bDoEnable
226 .GetControl(
"txt
" & sLocDocType
& "ImportPath
").Model.Enabled = bDoEnable
227 .GetControl(
"txt
" & sLocDocType
& "ExportPath
").Model.Enabled = bDoEnable
228 .GetControl(
"chk
" & sLocDocType
& "SearchSubDir
").Model.Enabled = bDoEnable
229 .GetControl(
"cmd
" & sLocDocType
& "Import
").Model.Enabled = bDoEnable
230 .GetControl(
"cmd
" & sLocDocType
& "Export
").Model.Enabled = bDoEnable
236 Function MakeSummaryString()
237 Dim sTmpText As String
240 Dim sAddText as String
241 For i =
0 To ApplCount -
1
242 Index = Applications(i,SBAPPLKEY)
243 If Applications(i,SBTEMPLCONVERT) Then
244 ' Templates are to be converted
245 sAddText =
""
246 If WizardMode = SBMICROSOFTMODE Then
247 sAddText = sSumMSTemplates(Index)
& sCRLF
249 sTmpText = sTmpText
& sAddText
& ConvertFromUrl(Applications(i,SBTEMPLSOURCE))
& sCRLF
250 If Applications(i,SBTEMPLRECURSIVE) Then
251 ' Including Subdirectories
252 sTmpText = sTmpText
& sSumInclusiveSubDir
& sCRLF
254 sTmpText = sTmpText
& sSumSaveDocuments
& sCRLF
255 sTmpText = sTmpText
& ConvertFromUrl(Applications(i,SBTEMPLTARGET))
& sCRLF
256 sTmpText = sTmpText
& sCRLF
259 If Applications(i,SBDOCCONVERT) Then
260 ' Documents are to be converted
261 If WizardMode = SBMICROSOFTMODE Then
262 sAddText = sSumMSDocuments(Index)
& sCRLF
264 sTmpText = sTmpText
& sAddText
& ConvertFromUrl(Applications(i,SBDOCSOURCE))
& sCRLF
266 If Applications(i,SBDOCRECURSIVE) Then
267 ' Including Subdirectories
268 sTmpText = sTmpText
& sSumInclusiveSubDir
& sCRLF
271 sTmpText = sTmpText
& sSumSaveDocuments
& sCRLF
272 sTmpText = sTmpText
& ConvertFromUrl(Applications(i,SBDOCTARGET))
& sCRLF
273 sTmpText = sTmpText
& sCRLF
276 MakeSummaryString = sTmpText
280 Sub FillStep_Summary()
281 ImportDialogArea.Title = sTitle
283 .SummaryTextbox.Text = MakeSummaryString()
284 .cmdGoOn.Enabled = .SummaryTextbox.Text
<> ""
285 .cmdGoOn.Label = sBeginButton
286 .SummaryHeaderLabel.Label = sSummaryHeader
289 ImportDialogArea.GetControl(
"SummaryHeaderLabel
").SetFocus()
293 Sub FillStep_Progress()
295 .cmdBack.Enabled = False
296 .cmdGoOn.Enabled = False
297 .hlnProgress.Label = sProgressPage_1
298 .LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.BOLD
299 .LabelRetrieval.Label = sProgressPage_2
300 .LabelCurProgress.Label = sProgressPage_3
301 .LabelCurDocumentRetrieval.Label =
""
302 .LabelCurTemplateRetrieval.Label =
""
303 .LabelCurDocument.Label =
""
306 ImportDialogArea.GetControl(
"LabelRetrieval
").SetFocus()
307 If ImportDialog.chkLogfile.State =
1 Then
308 ImportDialog.cmdShowLogFile.DefaultButton = True
313 Sub SetupMSConfiguration()
315 Wizardmode = SBMICROSOFTMODE
318 ' chkTemplatePath-Captions
319 GetApplResourceArray(
1009 + iApplSection, ApplCount, sTemplateCheckBox())
320 ' DocumentCheckbox- Captions
321 GetApplResourceArray(
1009 + iApplSection + ApplCount, ApplCount, sDocumentCheckBox())
323 sKeyName(
0) =
"Software\Microsoft\Office\
8.0\Word\Options
"
324 sKeyName(
1) =
"Software\Microsoft\Office\
8.0\Excel\Microsoft Excel
"
325 sKeyName(
2) =
"Software\Microsoft\Office\
8.0\PowerPoint\Recent Folder List\Default
"
327 sValueName(
0) =
"DOC-PATH
"
328 sValueName(
1) =
"DefaultPath
"
329 sValueName(
2) =
""
331 ' See definition of Filtername-Array about meaning of fields
332 MSFilterName(
0,
0) =
"doc|docx|docm
"
333 MSFilterName(
0,
1) =
"writer8|writer8|writer8
"
334 MSFilterName(
0,
2) =
"odt|odt|odt
"
335 MSFilterName(
0,
3) = sMSDocumentCheckBox(
0)
336 MSFilterName(
0,
4) =
"Word
"
339 MSFilterName(
1,
0) =
"xls|xlsx|xlsm
"
340 MSFilterName(
1,
1) =
"calc8|calc8|calc8
"
341 MSFilterName(
1,
2) =
"ods|ods|ods
"
342 MSFilterName(
1,
3) = sMSDocumentCheckBox(
1)
343 MSFilterName(
1,
4) =
"Excel
"
345 MSFilterName(
2,
0) =
"ppt|pps|pptx|pub|pptm|ppsx|ppsm
"
346 MSFilterName(
2,
1) =
"impress8|impress8|impress8|impress8|impress8|impress8|impress8
"
347 MSFilterName(
2,
2) =
"odp|odp|odp|odp|odp|odp|odp
"
348 MSFilterName(
2,
3) = sMSDocumentCheckBox(
2)
349 MSFilterName(
2,
4) =
"PowerPoint/Publisher
"
351 MSFilterName(
3,
0) =
"dot|dotx|dotm
"
352 MSFilterName(
3,
1) =
"writer8_template|writer8_template|writer8_template
"
353 MSFilterName(
3,
2) =
"ott|ott|ott
"
354 MSFilterName(
3,
3) = sMSTemplateCheckBox(
0)
355 MSFilterName(
3,
4) =
"Word
"
357 MSFilterName(
4,
0) =
"xlt|xltx|xltm
"
358 MSFilterName(
4,
1) =
"calc8_template|calc8_template|calc8_template
"
359 MSFilterName(
4,
2) =
"ots|ots|ots
"
360 MSFilterName(
4,
3) = sMSTemplateCheckBox(
1)
361 MSFilterName(
4,
4) =
"Excel
"
363 MSFilterName(
5,
0) =
"pot|potx|potm
"
364 MSFilterName(
5,
1) =
"impress8_template|impress8_template|impress8_template
"
365 MSFilterName(
5,
2) =
"otp|otp|otp
"
366 MSFilterName(
5,
3) = sMSTemplateCheckBox(
2)
367 MSFilterName(
5,
4) =
"PowerPoint
"
371 Function CheckControlPath(oCheckbox as Object, oTextBox as Object, ByVal bDoEnable as Boolean)
373 If Not bDoEnable Then
374 CheckControlPath = False
375 ElseIf oCheckbox.State =
0 Then
376 CheckControlPath = True
378 sPath = ConvertToUrl(Trim(oTextBox.Text))
379 CheckControlPath = oUcb.Exists(sPath)
384 Function CheckInputPaths() as Boolean
385 Dim bChangePage as Boolean
386 bChangePage = CheckTextBoxPath(ImportDialog.txtTemplateImportPath, True, False, sTitle, False)
387 bChangePage = CheckTextBoxPath(ImportDialog.txtTemplateExportPath, bChangePage, True, sTitle, False)
388 bChangePage = CheckTextBoxPath(ImportDialog.txtDocumentImportPath, bChangePage, False, sTitle, False)
389 bChangePage = CheckTextBoxPath(ImportDialog.txtDocumentExportPath, bChangePage, True, sTitle, False)
390 CheckInputPaths = bChangePage
394 Function CheckTextBoxPath(oTextBox as Object, ByVal bCheck as Boolean, bCreateNew as Boolean, sTitle as String, bgetResources as Boolean) as Boolean
395 Dim iCreate as Integer
396 Dim sQueryMessage as String
397 Dim sUrlPath as String
398 Dim sMessageNoDir as String
399 Dim sShowPath as String
400 Dim oLocUcb as Object
401 oLocUcb = createUnoService(
"com.sun.star.ucb.SimpleFileAccess
")
402 If bGetResources Then
403 If InitResources(
"ImportWizard
",
"imp
") then
404 sNoDirCreation = GetResText(
1050)
405 sMsgDirNotThere = GetResText(
1051)
406 sQueryForNewCreation = GetResText(
1052)
408 CheckTextBoxPath() = False
412 If oTextBox.Enabled Then
414 sShowPath = oTextBox.Text
415 sUrlPath = ConvertToUrl(sShowPath)
416 If Not oLocUcb.Exists(sUrlPath) Then
417 If Not bCreateNew Then
418 ' Sourcedirectories must be existing, Targetdirectories may be created new
419 sQueryMessage = ReplaceString(sMsgDirNotThere, sShowPath,
"%
1")
420 Msgbox(sQueryMessage,
16,sTitle)
421 CheckTextBoxPath() = False
424 sQueryMessage = ReplaceString(sMsgDirNotThere, sShowPath,
"%
1")
425 sQueryMessage = sQueryMessage
& Chr(
13)
& sQueryForNewCreation
426 iCreate = Msgbox (sQueryMessage,
36, sTitle)
428 On Local Error Goto NOVALIDPATH
429 CreateFolder(sUrlPath)
430 If Not oLocUcb.Exists(sUrlPath) Then
434 CheckTextBoxPath() = False
439 CheckTextBoxPath() = True
441 CheckTextBoxPath() = False
444 CheckTextBoxPath() = True
448 sMessageNoDir = ReplaceString(sNoDirCreation, sShowPath,
"%
1")
449 Msgbox(sMessageNoDir,
16, sTitle)
450 CheckTextBoxPath() = False
454 Sub InitializeProgressPage(oDialog as Object)
455 oDialog.LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.NORMAL
456 oDialog.LabelCurProgress.FontWeight = com.sun.star.awt.FontWeight.BOLD
460 Sub SetProgressDisplay(AbsFound as Integer)
461 ImportDialog.LabelRetrieval.Label = sProgressPage_2
& " " & ReplaceString(sProgressPage_5, Str(AbsFound)
& " ",
"%
1")
462 ImportDialog.LabelCurDocumentRetrieval.Label = sProgressFound
& " " & CStr(AbsDocuFound)
& " " & sProgressMoreDocs
463 ImportDialog.LabelCurTemplateRetrieval.Label = sProgressFound
& " " & CStr(AbsTemplateFound)
& " " & sProgressMoreTemplates
466 Sub TakoverFolderName(aEvent as Object)
467 Dim RefControlName as String
469 RefControlName = aEvent.Source.Model.Tag
470 oRefControl = ImportDialogArea.GetControl(RefControlName)
471 GetFolderName(oRefControl.Model)
476 Sub FinalizeDialogButtons()
477 ImportDialog.cmdShowLogFile.Enabled = ((Isnull(oLogDocument) = False) And (ImportDialog.chkLogfile.State =
1))
478 ImportDialog.cmdCancel.Enabled = False
479 ImportDialog.cmdGoOn.Label = sCloseButton
480 ImportDialog.cmdGoOn.Enabled = True