'encoding UTF-8 Do not remove or change this line! '************************************************************************** '* 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: t_filetools.inc,v $ '* '* $Revision: 1.4 $ '* '* last change: $Author: rt $ $Date: 2008-09-04 09:17:26 $ '* '* 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 '* '* for a copy of the LGPLv3 License. '* '/************************************************************************ '* '* owner : joerg.skottke@sun.com '* '* short description : Functions that work with files like deleting, loading... '* '\****************************************************************************** private const VERBOSE = false function hHandleActivesOnLoad( iTries as integer , iAdd as integer ) as boolean '///

Handle any dialogs that might pop up when loading a file

'///Beware: This function gives only limited control over the dialogs closed, '///+ it just closes anything it can.
'///Please refer to the inline documentation for further details
'///Input: '///
    '///+
  1. Number of dialogs to be closed (integer)
  2. '/// '///+
  3. Additional dialogs (integer).
  4. '/// '///
'///Returns: '///
    '///+
  1. Errorcondition (boolean)
  2. '/// '///
'///Description: '/// use "global/tools/includes/optional/t_stringtools.inc" const CFN = "hHandleActivesOnLoad::" dim iTry as integer dim iActives as integer dim cMessage as string dim bSkip as boolean printlog( CFN & "Enter" ) ' not good but apparently required - else hDestroyDocument will handle the ' dialogs and warn about them. ' think positive: preset the returnvalue with "true" hHandleActivesOnLoad() = true for iTry = 1 to iTries + iAdd ' handle three possible dialogs: ' 1. The warning that the user should create a new document based ' on this Sample/Template (the document is write protected) ' 2. The question to update links to the internet. Note: If you ' use proxies, they must be set correctly otherwise the result ' is undefined. ' 3. Some weird usage information dialog which is an active with just ' one OK button. ' Although this works quite well, there is a flaw that we will not ' get information about an "active" dialog that cannot be closed by ' .yes() or .ok(). If this happens, we probably run into an error kontext "Active" try if ( active.exists( 1 ) ) then iActives = iActives + 1 cMessage = hRemoveLineBreaks( active.getText() ) printlog( CFN & "MSG (" & iActives & "): " & cMessage ) printlog( CFN & "Ressource type is: " & Active.getRT() ) printlog( CFN & "Buttoncount is: " & Active.getButtonCount() ) bSkip = false ' ok to create a new document try active.cancel() printlog( CFN & "MSG (" & iActives & "): closed with Cancel" ) bSkip = true catch printlog( CFN & "Missed - this dialog has no OK button (create new document)" ) active.ok() endcatch if ( not bSkip ) then if ( Active.getRT() = 304 ) then if ( Active.getButtonCount() = 1 ) then active.ok() printlog( CFN & "MSG (" & iActives & "): closed with OK" ) bSkip = true else endif else endif endif if ( not bSkip ) then ' no to update links try active.no() printlog( CFN & "MSG (" & iActives & "): closed with NO" ) catch printlog( CFN & "Missed - this dialog has no NO button (update links)" ) endcatch endif endif catch qaerrorlog( "Problem while trying to handle messageboxes" ) hHandleActivesOnLoad() = false endcatch next iTry ' now see how many dialogs were allowed and how many have been closed ' this does not change the return value of the function if ( iActives > iTries ) then printlog( CFN & "Exit: The test closed more dialogs than expected" ) hHandleActivesOnLoad() = false else printlog( CFN & "Exit" ) endif end function '******************************************************************************* function hHandleInitialDialogs() as integer const CFN = "hHandleInitialDialogs::" '///

Handle dialogs while opening samples/templates etc.

'///The returnvalue is of limited use
'///Input: '///
    '///+
  1. Nothing
  2. '///
'///Returns: '///
    '///+
  1. Id of the dialog (integer)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hGetWorkPath() as string '///

Retrieve the users work directory

'///Uses: Call to UNO service
'///Errorhandling: Fixes "$(user)"-type path (uses fallback)
'///Errorhandling: Handles broken UNO connection (uses fallback)
'///Input: '///
    '///+
  1. Nothing
  2. '///
'///Returns: '///
    '///+
  1. Path to local workdir (string)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hGetFileSizeAsLong( cFileName as string ) as long '///

Get the size (long) of a file

'///Input: '///
    '///+
  1. Filename (string)
  2. '///
'///Returns: '///
    '///+
  1. Size of file (long)
  2. '///
'///Description: '/// end function '******************************************************************************* function hGetWorkFile( cFileName as string ) as string '///

Returns a fully qualified filename to a workfile

'///Input: '///
    '///+
  1. Filename without path (string)
  2. '///
'///Returns: '///
    '///+
  1. Filename including path to user work directory (string)
  2. '///
'///Description: '/// end function