summaryrefslogtreecommitdiff
path: root/wizards/source/importwizard/Main.xba
blob: 6d2c93b29aec153e0446c5055ce166296b188602 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?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="Main" script:language="StarBasic">Option Explicit

&apos;  *****  BASIC  *****
&apos; Todo: Problematik der VBA-Makros, die angeblich nicht mit abgespeichert werden koennen.
&apos; Evt. Erkennen der Arbeitsverzeichnisse von MS Office
&apos; Filternamen fuer Ziel-XML-Dokumente und deren Extensionen feststellen (auch fuer StarMath)
&apos; Extension fuer XML-Vorlagen klaeren
Public HeaderPreviews(4) as Object
Public ImportDialog as Object
Public ImportDialogArea as Object

Sub Main
	BasicLibraries.LoadLibrary(&quot;Tools&quot;)
	sCRLF = CHR(10) &amp; CHR(13)
	oUcb = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
	If Not bDebugWizard Then
		On Error Goto RTError
	End If
	SOBitmapPath = GetOfficeSubPath(&quot;Template&quot;, &quot;wizard/bitmap&quot;)
	SOWorkPath = GetPathSettings(&quot;Work&quot;, False)
	SOTemplatePath = GetPathSettings(&quot;Template&quot;,False,1)
  	bCancelTask = False
  	bDoKeepApplValues = False
	CurOffice = 0
	ImportDialogArea = LoadDialog(&quot;ImportWizard&quot;,&quot;ImportDialog&quot;)
	ImportDialog = ImportDialogArea.Model
	LoadLanguage()
	FillStep_Welcome()
	RepaintHeaderPreview()
	SetStates()
	ImportDialogArea.SetVisible(True)
	ImportDialog.cbGoOn.DefaultButton = True
	Exit Sub
RTError:
	Msgbox sRTErrorDesc, 16, sRTErrorHeader
End Sub


Sub SetStates
	With ImportDialog
		.OptSODocuments.State = 1
	    .OptMSDocuments.State = 0
		.TemplateCheckbox.State = 1
		.DocumentPathCheckbox.State = 0
	End With
End Sub


Sub NextStep
Dim iCurStep as Integer
	If Not bDebugWizard Then
		On Error Goto RTError
	End If
	iCurStep = ImportDialog.Step
	Select Case iCurStep
		Case 1
			FillStep_InputPaths(0, True)
		Case 2
			If SaveStep_InputPath Then
				If CurOffice &lt; ApplCount - 1 Then
					CurOffice = CurOffice + 1
					TakeOverPathSettings()
					FillStep_InputPaths(CurOffice, False)
					RepaintHeaderPreview()
				Else
					FillStep_Summary()
				End If
			End If
		Case 3
			FillStep_Progress()
			Select Case WizardMode
				Case SBMICROSOFTMODE
					Call ConvertAllDocuments(MSFilterName())
				CASE SBXMLMODE
					Call ConvertAllDocuments(XMLFilterName())
			End Select
		Case 4
	End Select
	ImportDialog.cbGoOn.DefaultButton = True		
	Exit Sub
RTError:
	Msgbox sRTErrorDesc, 16, sRTErrorHeader
End Sub


Sub PrevStep
Dim iCurStep as Integer
	If Not bDebugWizard Then
		On Error Goto RTError
	End If
	iCurStep = ImportDialog.Step
	Select Case iCurStep
		Case 4
			ImportDialog.cbCancel.Label = sCancelButton
			FillStep_Summary()
		Case 3
&apos;Todo: muessen auch beim Zuruecksteppen wirklich die Importpfade auf ihre Gueltigkeit hin Ueberprueft werden?
			FillStep_InputPaths(Applcount-1, False)
		Case 2
			If SaveStep_InputPath Then
				If CurOffice &gt; 0 Then
					CurOffice = CurOffice - 1
					FillStep_InputPaths(CurOffice, False)
					RepaintHeaderPreview()
				Else
					FillStep_Welcome()
					bDoKeepApplValues = True
				End If
			End If
	End Select
	ImportDialog.cbGoOn.DefaultButton = True
	Exit Sub
RTError:
	Msgbox sRTErrorDesc, 16, sRTErrorHeader
End Sub


Sub CancelButton
&apos;	If ImportDialog.Step = 4 Then
&apos;		Call CancelButtonPressed()
&apos;	Else
		ImportDialogArea.EndExecute
		ImportDialogArea.Dispose()
		End
&apos;	End If
End Sub


Sub CancelTask()
	If Msgbox(sConvertError1, 36, sConvertError2) = 6 Then
		ImportDialogArea.EndExecute
		ImportDialogArea.Dispose
		End
	Else
		bCancelTask = False
		ImportDialog.cbCancel.Enabled = True
	End If
End Sub


&apos;Sub CancelButtonPressed()
&apos;	ImportDialog.cbCancel.Enabled = False
&apos;	bCancelTask = True
&apos;End Sub


Sub TemplateDirSearchDialog()
	CallDirSearchDialog(ImportDialog.TemplateImportPath)
End Sub


Sub RepaintHeaderPreview()
Dim Bitmap As Object
Dim CurStep as Integer
Dim sBitmapPath as String
	CurStep = ImportDialog.Step
	If CurStep = 2 Then
		sBitmapPath = SOBitmapPath &amp; WizardMode &amp; &quot;-Import_&quot; &amp; CurStep &amp; &quot;-&quot; &amp; Applications(CurOffice,SBAPPLKEY) + 1 &amp; &quot;.bmp&quot;
	Else
		sBitmapPath = SOBitmapPath &amp; &quot;Import_&quot; &amp; CurStep &amp; &quot;.bmp&quot;
	End If
	ImportDialog.ImportPreview.ImageURL = sBitmapPath
End Sub


Sub HelperDialog()
&apos;Todo: The String &quot;start&quot; can be replaced by a HelpIndex
	StarDesktop.LoadComponentfromUrl(&quot;vnd.sun.star.help://&quot; &amp; sDocType &amp; &quot;/start&quot;, &quot;_OFFICE_HELP&quot;, 64, NoArgs())
End Sub


Sub DisorEnableCheckboxes(oEvent as Object)
Dim bMSEnable as Boolean
	bMSEnable = oEvent.Source.Model.Tag = &quot;MS&quot;
	With ImportDialog
		.ChkFirstSOApplication.Enabled = Not bMSEnable
		.ChkSecondSOApplication.Enabled = Not bMSEnable
		.ChkThirdSOApplication.Enabled = Not bMSEnable
		.ChkFourthSOApplication.Enabled = Not bMSEnable
		.ChkFirstMSApplication.Enabled = bMSEnable
		.ChkSecondMSApplication.Enabled = bMSEnable
		.ChkThirdMSApplication.Enabled = bMSEnable
		.WelcomeTextLabel2.Enabled = bMSEnable
	End With
	bDoKeepApplValues = False
	DisOrEnableNextButton()
End Sub


Sub DisOrEnableNextButton()
Dim iCurStep as Integer
Dim bDoEnable as Boolean
Dim i as Integer
	iCurStep = ImportDialog.Step
	Select Case iCurStep
		Case 1
			With ImportDialog
				If .OptMSDocuments.State = 1 Then
          			bDoEnable = .ChkFirstMSApplication.State = 1 Or .ChkSecondMSApplication.State = 1 Or .ChkThirdMSApplication.State = 1
				Else
          			bDoEnable = .ChkFirstSOApplication.State = 1 Or .ChkSecondSOApplication.State = 1 Or .ChkThirdSOApplication.State = 1 Or .ChkFourthSOApplication.State = 1
				End If
			End With
			bDoKeepApplValues = False
		Case 2
			bDoEnable = CheckControlPath(ImportDialog.TemplateImportPath, True)
			bDoEnable = CheckControlPath(ImportDialog.TemplateExportPath, bDoEnable)
			bDoEnable = CheckControlPath(ImportDialog.DocumentImportPath, bDoEnable)
			bDoEnable = CheckControlPath(ImportDialog.DocumentExportPath, bDoenable)
	End Select
	ImportDialog.cbGoOn.Enabled = bDoEnable
End Sub


Sub TakeOverPathSettings()					
&apos;Takes over the Pathsettings from the first selected application to the next applications
	Applications(CurOffice,SBDOCSOURCE) = Applications(0,SBDOCSOURCE)
	Applications(CurOffice,SBDOCTARGET) = Applications(0,SBDOCTARGET)
	If WizardMode = SBXMLMODE AND Applications(CurOffice,SBAPPLKEY) = 3 Then	&apos; Helper Applications
		Applications(CurOffice,SBTEMPLSOURCE) = Applications(CurOffice,SBDOCSOURCE)
		Applications(CurOffice,SBTEMPLTARGET) = Applications(CurOffice,SBDOCTARGET)											
	Else
		Applications(CurOffice,SBTEMPLSOURCE) = Applications(0,SBTEMPLSOURCE)
		Applications(CurOffice,SBTEMPLTARGET) = Applications(0,SBTEMPLTARGET)					
	End If
End Sub					
</script:module>