summaryrefslogtreecommitdiff
path: root/migrationanalysis/src/driver_docs/CreateDriverDocs.wsf
blob: 8fc82d96d53af9935521a8526dcd783af49587cd (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
'/*************************************************************************
' *
' * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
' * 
' * Copyright 2008 by Sun Microsystems, Inc.
' *
' * OpenOffice.org - a multi-platform office productivity suite
' *
' * $RCSfile: CreateDriverDocs.wsf,v $
' * $Revision: 1.2.140.3 $
' *
' * This file is part of OpenOffice.org.
' *
' * OpenOffice.org is free software: you can redistribute it and/or modify
' * it under the terms of the GNU Lesser General Public License version 3
' * only, as published by the Free Software Foundation.
' *
' * OpenOffice.org is distributed in the hope that it will be useful,
' * but WITHOUT ANY WARRANTY; without even the implied warranty of
' * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' * GNU Lesser General Public License version 3 for more details
' * (a copy is included in the LICENSE file that accompanied this code).
' *
' * You should have received a copy of the GNU Lesser General Public License
' * version 3 along with OpenOffice.org.  If not, see
' * http://www.openoffice.org/license.html
' * for a copy of the LGPLv3 License.
' *
' ************************************************************************/
'### Build Support Module for running commands to export and import
'### modules from Word, Excel and PowerPoint Document Analysis driver documents


<job id="DocAnalysisBuildCmd" error="true" debug="true">
   <script language="VBScript" src="DocAnalysisRunMacro.vbs"/>
   <script language="VBScript">

Const CTITLE = "Document Analysis Command"

Const CWORD_DRIVER = "_OOoDocAnalysisWordDriver.doc"
Const CEXCEL_DRIVER = "_OOoDocAnalysisExcelDriver.xls"
Const CPP_DRIVER = "_OOoDocAnalysisPPTDriver.ppt"
Const CStub = "Stripped"

Const CUTIL_APPNAME_WORD = "Word"
Const CUTIL_APPNAME_EXCEL = "Excel"
Const CUTIL_APPNAME_POWERPOINT = "Powerpoint"

Const CDIAG_STD_DELAY = 2

Const CDEFAULT_SOURCE_DIR = ".\sources\"
Const CDEFAULT_TARGET_DIR = "."

Const CSOURCE_DIR_ARG = "X"
Const CTARGET_DIR_ARG = "T"
Const CUSAGE_ARG = "?"

Const CSTR_PAW = "\PAW\"

'######### Doc Analysis Build - Main Script Body ############# 
Dim mArgsNamed, mArgsUnnamed
Dim mSourceDir
Dim mTargetDir

On Error Resume Next

'### Process Arguments ###
Set mArgsNamed = WScript.Arguments.Named
Set mArgsUnnamed = WScript.Arguments.Unnamed

If mArgsNamed.Exists(CUSAGE_ARG) Then
	Usage
	FinalExit
End If

'# Source Dir
if mArgsNamed.Exists(CSOURCE_DIR_ARG) Then
	mSourceDir = mArgsNamed.Item(CSOURCE_DIR_ARG)
Else
	mSourceDir = CDEFAULT_SOURCE_DIR
End If

'# Target Dir
if mArgsNamed.Exists(CTARGET_DIR_ARG ) Then
	mTargetDir = mArgsNamed.Item(CTARGET_DIR_ARG )
Else
	mTargetDir = CDEFAULT_TARGET_DIR
End If

mSourceDir = daFso.GetAbsolutePathName(mSourceDir )
mTargetDir = daFso.GetAbsolutePathName(mTargetDir ) 

'# Check source and target dirs exist
If Not daFso.FolderExists(mSourceDir) Then
	DAErrMsg "Source directory does not exist: " & mSourceDir, CDA_ERR_STD_DELAY 
    FinalExit
End If
If Not daFso.FolderExists(mTargetDir) Then
	DAErrMsg "Target directory does not exist: " & mTargetDir, CDA_ERR_STD_DELAY 
    FinalExit
End If

Set mArgsNamed = Nothing
Set mArgsUnnamed = Nothing

'#### then continue with PAW
ImportAll mTargetDir & CSTR_PAW

'# Cleanup
FinalExit


'######### End - Main Script Body ############# 


'#### Doc Analysis Build - Support Functions ####

Sub Usage()
	DAdiagMsg "Build command line tool to create Document Analysis driver documents" & vbLf & vbLf &_
	"DocAnalysisBuildCmd [/X:<sourceDir>] [/T:<targetDir>]" & vbLf & vbLf &_
	"/X:<sourceDir> base <source> directory " & vbLf & _
	"            The <sourceDir> is the base dir under which all the " & vbLf & _
	"            _res.bas files are located to import from" & vbLf & vbLf & _
	"/T:<targetDir> target directory " & vbLf & _
	"            <targetDir> is where the new Driver docs" & vbLf & _
	"            will be created", 30
End Sub

'######################
Sub FinalExit()
    DACleanUp
	wscript.quit
End Sub

'######################
Sub ImportAll( aTargetDir )

    '#### Create automation servers ####
    DAsetupWrdServer
    DAsetupExcelServer
    DAsetupPPServer
    
    If Not daFso.FolderExists( aTargetDir ) Then
        daFso.CreateFolder( aTargetDir )
    End If
    
    BackupDrivers aTargetDir
    
    DAOpenWrdDriver mSourceDir & "\" & CSTUB & CWORD_DRIVER 
    DAOpenExcelDriver mSourceDir & "\" & CSTUB & CEXCEL_DRIVER
    DAOpenPPDriver mSourceDir & "\" & CSTUB & CPP_DRIVER
    
    DASetTitle CTITLE & " - Import"
    
    ImportSelectedProjectFiles mSourceDir, CUTIL_APPNAME_WORD
    ImportSelectedProjectFiles mSourceDir, CUTIL_APPNAME_EXCEL
    ImportSelectedProjectFiles mSourceDir, CUTIL_APPNAME_POWERPOINT
        
    DAsaveWrdDriver aTargetDir & "\" & CWORD_DRIVER
    DAsaveExcelDriver aTargetDir & "\" & CEXCEL_DRIVER
    DAsavePPDriver aTargetDir & "\" & CPP_DRIVER
    
    DACloseApps
End Sub

'######################
Sub BackupDrivers(importdir)
    On Error Resume Next

	Dim wrdPath
	Dim xlsPath
	Dim ppPath
	
	wrdPath = daFso.GetAbsolutePathName(importdir & "\" & CWORD_DRIVER)
	xlsPath= daFso.GetAbsolutePathName(importdir & "\" & CEXCEL_DRIVER) 
	ppPath= daFso.GetAbsolutePathName(importdir & "\" & CPP_DRIVER) 

    If daFso.FileExists( wrdPath ) Then daFso.CopyFile wrdPath, wrdPath & ".bak"
	If daFso.FileExists( xlsPath ) Then daFso.CopyFile xlsPath, xlsPath & ".bak"
	If daFso.FileExists( ppPath ) Then daFso.CopyFile ppPath, ppPath & ".bak"
End Sub

'######################
Sub ImportSelectedProjectFiles(dir, app_name)
    On Error Resume Next
    
    Dim base
    Dim lcApp_name
    lcApp_name = LCase(app_name)
    
    'Driver Specific
    base = dir & "\" & lcApp_name & "\"
        
    DAImportFile base & "ApplicationSpecific.bas", "ApplicationSpecific", app_name
    DAImportFile base & "MigrationAnalyser.cls", "MigrationAnalyser", app_name

    DAImportFile base & "Preparation.bas", "Preparation", app_name

    'app resource
    DAImportFile base & lcApp_name & "_res.bas", lcApp_name & "_res", app_name
    
    'Common
    base = dir & "\"
    DAImportFile base & "AnalysisDriver.bas", "AnalysisDriver", app_name
    DAImportFile base & "CommonMigrationAnalyser.bas", "CommonMigrationAnalyser", app_name
    DAImportFile base & "CollectedFiles.cls", "CollectedFiles", app_name
    DAImportFile base & "DocumentAnalysis.cls", "DocumentAnalysis", app_name
    DAImportFile base & "FileTypeAssociation.cls", "FileTypeAssociation", app_name
    DAImportFile base & "IssueInfo.cls", "IssueInfo", app_name
    DAImportFile base & "PrepareInfo.cls", "PrepareInfo", app_name
    DAImportFile base & "StringDataManager.cls", "StringDataManager", app_name
    DAImportFile base & "LocalizeResults.bas", "LocalizeResults", app_name
 
    DAImportFile base & "CommonPreparation.bas", "CommonPreparation", app_name

    'common resource
    DAImportFile base & "common_res.bas", "common_res", app_name
    DAImportFile base & "results_res.bas", "results_res", app_name

End Sub

</script>
</job>