1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: javatools.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:19:06 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/******************************************************************************
34 '* owner : joerg.Skottke@Sun.Com
36 '* short description : Tools to ease working with files including Java
38 '\******************************************************************************
40 function hBatchLoadJavaFiles( aFileList() , cIdent as string )
42 '///<h3>Load and close a list of files with recovery on error</h3>
43 '///<u>Input</u>: A list containing files to load<br>
44 '///<u>Returns</u>: No returnvalue
47 const CFN = "hBatchLoadJavaFiles::"
49 dim iSourceFiles as integer
50 iSourceFiles = listcount( aFileList() )
52 dim iCurrentFile as integer
53 dim cCurrentFile as string
56 '///+<li>Loop through the list, starting at index 2</li>
57 for iCurrentFile = 2 to iSourceFiles
59 cCurrentFile = aFileList( iCurrentFile )
62 printlog( "Processing file: " & cCurrentFile )
64 '///+<li>Load a file, verify</li>
65 brc = hFileOpen( aFileList( iCurrentFile ) )
67 warnlog( "Error while loading: " & cCurrentFile )
70 '///+<li>close the file, verify</li>
71 brc = hDestroyDocument()
73 warnlog( "Error while closing: " & cCurrentFile )
76 '///+<li>There should be one document left: The first doc</li>
77 if ( getDocumentCount() = 1 ) then
78 brc = hIdentifyWriterDoc( cIdent , false )
80 warnlog( "Document <" & cIdent & "> is missing, restarting" )
81 call ExitRestartTheOffice()
84 elseif ( getDocumentCount() <> 1 ) then
85 warnlog( "The number of open documents is incorrect, restarting" )
86 call ExitRestartTheOffice()
90 '///+<li>Check for hs_err_pidXXXX.log files (Java Exceptions)</li>
91 brc = hFindCopyRemoveJavaLogs( aFileList( 1 ) )
93 warnlog( "Java Exceptions were created." )
94 printlog( "Find the files in your local OOo-work directory." )
102 '*******************************************************************************
104 function hFindCopyRemoveJavaLogs( cSourcePath as string ) as boolean
106 '///<h3>Search/move hs_err_pidXXXX.log files within a directory recursively</h3>
107 '///<u>Input</u>: Start directory<br>
108 '///<u>Returns</u>: TRUE if no errors were found
111 ' Reason 1: The files are createn in the CVS tree and must be removed
112 ' Reason 2: The files have to be analyzed so the bugs can be fixed
113 ' Reason 3: The files must be moved away after each error so they can be
114 ' assigned to the correct documents
116 const CFN = "hFindCopyRemoveJavaLogs::"
118 dim aSourceFiles( 1000 ) as string
119 dim iSourceFiles as integer
120 dim aTargetPath as string
121 aTargetPath = hGetWorkPath()
123 dim iCurrentFile as integer
127 dim iSPLen as integer ' length of the source-path string + "/" + next letter
128 iSPLen = len( cSourcePath ) + 2
130 '///+<li>Look for leftover hs_err_pidXXXX.log files</li>
131 iSourceFiles = GetAllFileList( cSourcePath, "hs_err*.log", aSourceFiles() )
132 if ( iSourceFiles > 1 ) then
134 '///+<li>Print the list to the log</li>
135 hListPrint( aSourceFiles(), "New hs_err_pidXXXX.log files exist" )
138 '///+<li>Copy the hs_err...log files to the local work directory</li>
139 for iCurrentFile = 2 to listcount( aSourceFiles() )
141 ' Create the name of the file we want to copy the hs_err...log to
142 aTargetPath = aTargetPath & mid( aSourceFiles( iCurrentFile ) , iSPLen )
143 FileCopy( aSourceFiles( iCurrentFile ) , aTargetPath )
145 '///+<li>Delete the original log file(s)</li>
146 hDeleteFile( aSourceFiles( iCurrentFile ) )
151 Printlog( CFN & "No hs_err_pidXXXX.log file(s) found. Good."
155 hFindCopyRemoveJavaLogs() = brc