1'/*************************************************************************
2' *
3' * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4' *
5' * Copyright 2000, 2010 Oracle and/or its affiliates.
6' *
7' * OpenOffice.org - a multi-platform office productivity suite
8' *
9' * This file is part of OpenOffice.org.
10' *
11' * OpenOffice.org is free software: you can redistribute it and/or modify
12' * it under the terms of the GNU Lesser General Public License version 3
13' * only, as published by the Free Software Foundation.
14' *
15' * OpenOffice.org is distributed in the hope that it will be useful,
16' * but WITHOUT ANY WARRANTY; without even the implied warranty of
17' * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18' * GNU Lesser General Public License version 3 for more details
19' * (a copy is included in the LICENSE file that accompanied this code).
20' *
21' * You should have received a copy of the GNU Lesser General Public License
22' * version 3 along with OpenOffice.org.  If not, see
23' * http://www.openoffice.org/license.html
24' * for a copy of the LGPLv3 License.
25' *
26' ************************************************************************/
27'### Build Support Module for running commands to export and import
28'### modules from Word, Excel and PowerPoint Document Analysis driver documents
29
30
31<job id="DocAnalysisBuildCmd" error="true" debug="true">
32   <script language="VBScript" src="DocAnalysisRunMacro.vbs"/>
33   <script language="VBScript">
34
35Const CTITLE = "Document Analysis Command"
36
37Const CWORD_DRIVER = "_OOoDocAnalysisWordDriver.doc"
38Const CEXCEL_DRIVER = "_OOoDocAnalysisExcelDriver.xls"
39Const CPP_DRIVER = "_OOoDocAnalysisPPTDriver.ppt"
40Const CStub = "Stripped"
41
42Const CUTIL_APPNAME_WORD = "Word"
43Const CUTIL_APPNAME_EXCEL = "Excel"
44Const CUTIL_APPNAME_POWERPOINT = "Powerpoint"
45
46Const CDIAG_STD_DELAY = 2
47
48Const CDEFAULT_SOURCE_DIR = ".\sources\"
49Const CDEFAULT_TARGET_DIR = "."
50
51Const CSOURCE_DIR_ARG = "X"
52Const CTARGET_DIR_ARG = "T"
53Const CUSAGE_ARG = "?"
54
55Const CSTR_PAW = "\PAW\"
56
57'######### Doc Analysis Build - Main Script Body #############
58Dim mArgsNamed, mArgsUnnamed
59Dim mSourceDir
60Dim mTargetDir
61
62On Error Resume Next
63
64'### Process Arguments ###
65Set mArgsNamed = WScript.Arguments.Named
66Set mArgsUnnamed = WScript.Arguments.Unnamed
67
68If mArgsNamed.Exists(CUSAGE_ARG) Then
69	Usage
70	FinalExit
71End If
72
73'# Source Dir
74if mArgsNamed.Exists(CSOURCE_DIR_ARG) Then
75	mSourceDir = mArgsNamed.Item(CSOURCE_DIR_ARG)
76Else
77	mSourceDir = CDEFAULT_SOURCE_DIR
78End If
79
80'# Target Dir
81if mArgsNamed.Exists(CTARGET_DIR_ARG ) Then
82	mTargetDir = mArgsNamed.Item(CTARGET_DIR_ARG )
83Else
84	mTargetDir = CDEFAULT_TARGET_DIR
85End If
86
87mSourceDir = daFso.GetAbsolutePathName(mSourceDir )
88mTargetDir = daFso.GetAbsolutePathName(mTargetDir )
89
90'# Check source and target dirs exist
91If Not daFso.FolderExists(mSourceDir) Then
92	DAErrMsg "Source directory does not exist: " & mSourceDir, CDA_ERR_STD_DELAY
93    FinalExit
94End If
95If Not daFso.FolderExists(mTargetDir) Then
96	DAErrMsg "Target directory does not exist: " & mTargetDir, CDA_ERR_STD_DELAY
97    FinalExit
98End If
99
100Set mArgsNamed = Nothing
101Set mArgsUnnamed = Nothing
102
103'#### then continue with PAW
104ImportAll mTargetDir & CSTR_PAW
105
106'# Cleanup
107FinalExit
108
109
110'######### End - Main Script Body #############
111
112
113'#### Doc Analysis Build - Support Functions ####
114
115Sub Usage()
116	DAdiagMsg "Build command line tool to create Document Analysis driver documents" & vbLf & vbLf &_
117	"DocAnalysisBuildCmd [/X:<sourceDir>] [/T:<targetDir>]" & vbLf & vbLf &_
118	"/X:<sourceDir> base <source> directory " & vbLf & _
119	"            The <sourceDir> is the base dir under which all the " & vbLf & _
120	"            _res.bas files are located to import from" & vbLf & vbLf & _
121	"/T:<targetDir> target directory " & vbLf & _
122	"            <targetDir> is where the new Driver docs" & vbLf & _
123	"            will be created", 30
124End Sub
125
126'######################
127Sub FinalExit()
128    DACleanUp
129	wscript.quit
130End Sub
131
132'######################
133Sub ImportAll( aTargetDir )
134
135    '#### Create automation servers ####
136    DAsetupWrdServer
137    DAsetupExcelServer
138    DAsetupPPServer
139
140    If Not daFso.FolderExists( aTargetDir ) Then
141        daFso.CreateFolder( aTargetDir )
142    End If
143
144    BackupDrivers aTargetDir
145
146    DAOpenWrdDriver mSourceDir & "\" & CSTUB & CWORD_DRIVER
147    DAOpenExcelDriver mSourceDir & "\" & CSTUB & CEXCEL_DRIVER
148    DAOpenPPDriver mSourceDir & "\" & CSTUB & CPP_DRIVER
149
150    DASetTitle CTITLE & " - Import"
151
152    ImportSelectedProjectFiles mSourceDir, CUTIL_APPNAME_WORD
153    ImportSelectedProjectFiles mSourceDir, CUTIL_APPNAME_EXCEL
154    ImportSelectedProjectFiles mSourceDir, CUTIL_APPNAME_POWERPOINT
155
156    DAsaveWrdDriver aTargetDir & "\" & CWORD_DRIVER
157    DAsaveExcelDriver aTargetDir & "\" & CEXCEL_DRIVER
158    DAsavePPDriver aTargetDir & "\" & CPP_DRIVER
159
160    DACloseApps
161End Sub
162
163'######################
164Sub BackupDrivers(importdir)
165    On Error Resume Next
166
167	Dim wrdPath
168	Dim xlsPath
169	Dim ppPath
170
171	wrdPath = daFso.GetAbsolutePathName(importdir & "\" & CWORD_DRIVER)
172	xlsPath= daFso.GetAbsolutePathName(importdir & "\" & CEXCEL_DRIVER)
173	ppPath= daFso.GetAbsolutePathName(importdir & "\" & CPP_DRIVER)
174
175    If daFso.FileExists( wrdPath ) Then daFso.CopyFile wrdPath, wrdPath & ".bak"
176	If daFso.FileExists( xlsPath ) Then daFso.CopyFile xlsPath, xlsPath & ".bak"
177	If daFso.FileExists( ppPath ) Then daFso.CopyFile ppPath, ppPath & ".bak"
178End Sub
179
180'######################
181Sub ImportSelectedProjectFiles(dir, app_name)
182    On Error Resume Next
183
184    Dim base
185    Dim lcApp_name
186    lcApp_name = LCase(app_name)
187
188    'Driver Specific
189    base = dir & "\" & lcApp_name & "\"
190
191    DAImportFile base & "ApplicationSpecific.bas", "ApplicationSpecific", app_name
192    DAImportFile base & "MigrationAnalyser.cls", "MigrationAnalyser", app_name
193
194    DAImportFile base & "Preparation.bas", "Preparation", app_name
195
196    'app resource
197    DAImportFile base & lcApp_name & "_res.bas", lcApp_name & "_res", app_name
198
199    'Common
200    base = dir & "\"
201    DAImportFile base & "AnalysisDriver.bas", "AnalysisDriver", app_name
202    DAImportFile base & "CommonMigrationAnalyser.bas", "CommonMigrationAnalyser", app_name
203    DAImportFile base & "CollectedFiles.cls", "CollectedFiles", app_name
204    DAImportFile base & "DocumentAnalysis.cls", "DocumentAnalysis", app_name
205    DAImportFile base & "FileTypeAssociation.cls", "FileTypeAssociation", app_name
206    DAImportFile base & "IssueInfo.cls", "IssueInfo", app_name
207    DAImportFile base & "PrepareInfo.cls", "PrepareInfo", app_name
208    DAImportFile base & "StringDataManager.cls", "StringDataManager", app_name
209    DAImportFile base & "LocalizeResults.bas", "LocalizeResults", app_name
210
211    DAImportFile base & "CommonPreparation.bas", "CommonPreparation", app_name
212
213    'common resource
214    DAImportFile base & "common_res.bas", "common_res", app_name
215    DAImportFile base & "results_res.bas", "results_res", app_name
216
217End Sub
218
219</script>
220</job>
221
222