'encoding UTF-8 Do not remove or change this line! '************************************************************************** ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ' ' Copyright 2000, 2010 Oracle and/or its affiliates. ' ' OpenOffice.org - a multi-platform office productivity suite ' ' 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 : Replacements for routines in t_lists.inc adds some '* '******************************************************************************* '* ' #1 hListTestUpperBoundary ' Tests upper boundary of arrays ' #1 hListTestLowerBoundary ' Tests lower boundary of arrays ' #1 hListDelete ' Deletes one item from a list by index ' #1 hListAppend ' Append an item to a list ' #1 hManageComparisionList ' quick way to compare/create reference lists ' #1 hListFileGetSize ' find out how big an array has to be to hold the file ' #1 hListCompare ' compare two lists ' #1 hListPrependString ' Insert a string infront of each item in a list ' #1 hListAppendList ' Append one list to another ' #1 hCountMatchesInList ' Return count of occurrences of a string within a list '* '\****************************************************************************** ' Note: These functions fix some minor bugs and introduce strict boundary ' checking for the arrays we work with. The arrays must be compatible ' to those from the "standard" list-functions. ' Why: Two reasons: ' ' 1) When working with listboxes it might happen that they are empty (bug) ' or contain more items than expected. In this case the tests would ' usually break. This is not desired as many testcases do not rely ' on the content of the listboxes. ' ' 2) This way eases the trouble of debugging huge amounts of arrays ' like those in the installation test or anywhere else where we work ' with reference lists. This is a coding help. '******************************************************************************* function hListTestUpperBoundary( aList() as string ) as boolean '///

Verify that ListCount does not exceed upper boundary

'///About listfunctions: All listfunctions rely on a special type of '///+ array. This can be string arrays and - in some cases - numeric '///+ arrays. What makes the arrays unique is that the first item which '///+ has the index 0 contains the number of items in the list to be used, '///+ anything that is stored beyond this number is ignored. This has three '///+ consequences: 1) all listfunctions that alter an array must update '///+ the index stored in array(0) and 2) it is possible that the index '///+ point beyond ubound of the array which will most likely cause a '///+ runtime error. 3) Means that arrays may only have an upper boundary '///+ declared, all loops must start with index array(1) and must end with '///+ index array(val( array(0))
'///Input: '///
    '///+
  1. List (string)
  2. '///
'///Returns: '///
    '///+
  1. Errorstatus (boolean)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hListTestLowerBoundary( aList() as string ) as boolean '///

Verify that the lower boundaries of an array are ok

'///Prerequisite: Array compatible with those from t_lists.inc '///About listfunctions: All listfunctions rely on a special type of '///+ array. This can be string arrays and - in some cases - numeric '///+ arrays. What makes the arrays unique is that the first item which '///+ has the index 0 contains the number of items in the list to be used, '///+ anything that is stored beyond this number is ignored. This has three '///+ consequences: 1) all listfunctions that alter an array must update '///+ the index stored in array(0) and 2) it is possible that the index '///+ point beyond ubound of the array which will most likely cause a '///+ runtime error. 3) Means that arrays may only have an upper boundary '///+ declared, all loops must start with index array(1) and must end with '///+ index array(val( array(0))
'///Input: '///
    '///+
  1. List (string)
  2. '///
'///Returns: '///
    '///+
  1. Errorstatus (boolean)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hListDelete( aList() as string, iItemToDelete as integer ) as boolean '///

Delete one item from a list specified by index

'///Prerequisite: Array compatible with those from t_lists.inc
'///About listfunctions: All listfunctions rely on a special type of '///+ array. This can be string arrays and - in some cases - numeric '///+ arrays. What makes the arrays unique is that the first item which '///+ has the index 0 contains the number of items in the list to be used, '///+ anything that is stored beyond this number is ignored. This has three '///+ consequences: 1) all listfunctions that alter an array must update '///+ the index stored in array(0) and 2) it is possible that the index '///+ point beyond ubound of the array which will most likely cause a '///+ runtime error. 3) Means that arrays may only have an upper boundary '///+ declared, all loops must start with index array(1) and must end with '///+ index array(val( array(0))
'///Review the code, it has many unused variables '/// end function '******************************************************************************* function hListAppend( sNewString as string, aTargetList() as string ) as integer '///

Append an item to an existing list

'///Prerequisite: Array compatible with those from t_lists.inc '///About listfunctions: All listfunctions rely on a special type of '///+ array. This can be string arrays and - in some cases - numeric '///+ arrays. What makes the arrays unique is that the first item which '///+ has the index 0 contains the number of items in the list to be used, '///+ anything that is stored beyond this number is ignored. This has three '///+ consequences: 1) all listfunctions that alter an array must update '///+ the index stored in array(0) and 2) it is possible that the index '///+ point beyond ubound of the array which will most likely cause a '///+ runtime error. 3) Means that arrays may only have an upper boundary '///+ declared, all loops must start with index array(1) and must end with '///+ index array(val( array(0))
const CFN = "hListAppend::" dim iCurrentListSize as integer dim iNewListSize as integer dim iArraySize as integer dim irc as integer iCurrentListSize = val( aTargetList( 0 ) ) iNewListSize = iCurrentListSize + 1 iArraySize = ubound( aTargetList() ) if ( iNewListSize > iArraySize ) then warnlog ( CFN & "Cannot append, array too small" ) printlog( CFN & "Array-Size.....: " & iArraySize ) printlog( CFN & "Requested index: " & iNewListSize ) irc = -1 else aTargetList( iNewListSize ) = sNewString aTargetList( 0 ) = iNewListSize irc = iNewListSize endif hListAppend() = irc end function '******************************************************************************* function hManageComparisionList( sFileIn as string, sFileOut as string, sListOut() as string ) as integer '///

Function to create or compare a list to a reference

'///Prerequisite: List of items to compare, input- and outputfilename
'///About listfunctions: All listfunctions rely on a special type of '///+ array. This can be string arrays and - in some cases - numeric '///+ arrays. What makes the arrays unique is that the first item which '///+ has the index 0 contains the number of items in the list to be used, '///+ anything that is stored beyond this number is ignored. This has three '///+ consequences: 1) all listfunctions that alter an array must update '///+ the index stored in array(0) and 2) it is possible that the index '///+ point beyond ubound of the array which will most likely cause a '///+ runtime error. 3) Means that arrays may only have an upper boundary '///+ declared, all loops must start with index array(1) and must end with '///+ index array(val( array(0))
'///BEWARE: This is a core function and used by many tests!
'///Please read the inline documentation for further reference

'///Function parameters: '///
    '///+
  1. sFileIn = The file that contains the reference data
  2. '///+
  3. sFileOut = The file new lists are written to in case of an error
  4. '///+
  5. sListOut() = The list containing the newly retrieved data.
  6. '///
'///Description: '/// end function '******************************************************************************* function hListFileGetSize( sFileIn as string ) as integer '///

Get the number of lines from a file

'///Prerequisites: Path to an existing plain text file '///About listfunctions: All listfunctions rely on a special type of '///+ array. This can be string arrays and - in some cases - numeric '///+ arrays. What makes the arrays unique is that the first item which '///+ has the index 0 contains the number of items in the list to be used, '///+ anything that is stored beyond this number is ignored. This has three '///+ consequences: 1) all listfunctions that alter an array must update '///+ the index stored in array(0) and 2) it is possible that the index '///+ point beyond ubound of the array which will most likely cause a '///+ runtime error. 3) Means that arrays may only have an upper boundary '///+ declared, all loops must start with index array(1) and must end with '///+ index array(val( array(0))
'/// end function '******************************************************************************* function hListCompare( aListOne() as String, aListTwo() as String ) as boolean const CFN = "hListcompare::" '///

Compare two lists with each other, where list TWO is the reference

'///Prerequisites: Two lists compatible with listfunctions
'///About listfunctions: All listfunctions rely on a special type of '///+ array. This can be string arrays and - in some cases - numeric '///+ arrays. What makes the arrays unique is that the first item which '///+ has the index 0 contains the number of items in the list to be used, '///+ anything that is stored beyond this number is ignored. This has three '///+ consequences: 1) all listfunctions that alter an array must update '///+ the index stored in array(0) and 2) it is possible that the index '///+ point beyond ubound of the array which will most likely cause a '///+ runtime error. 3) Means that arrays may only have an upper boundary '///+ declared, all loops must start with index array(1) and must end with '///+ index array(val( array(0))
'///Duplicates gCompare2Lists but does not print warnlogs, evaluate returncode instead '/// end function '******************************************************************************* function hListPrependString( aList() as string, cString as string ) as boolean '///

Insert a string infront of each item in a list

'///Prerequisites: A list compatible with listfunctions
'///About listfunctions: All listfunctions rely on a special type of '///+ array. This can be string arrays and - in some cases - numeric '///+ arrays. What makes the arrays unique is that the first item which '///+ has the index 0 contains the number of items in the list to be used, '///+ anything that is stored beyond this number is ignored. This has three '///+ consequences: 1) all listfunctions that alter an array must update '///+ the index stored in array(0) and 2) it is possible that the index '///+ point beyond ubound of the array which will most likely cause a '///+ runtime error. 3) Means that arrays may only have an upper boundary '///+ declared, all loops must start with index array(1) and must end with '///+ index array(val( array(0))

'///Note that the function alters the input list. If the list contains '///+ strings of the type "MyString" the items will be changed to '///+ read "Some Text : MyString"
'///Input: '///
    '///+
  1. List (string)
  2. '///+
  3. A text to be inserted infront of every item in the list
  4. '///
'///Returns: '///
    '///+
  1. Errorcondition (boolean)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hListAppendList( aBaseList() as string, aListToAppend() as string ) as integer '///

Append one list to another

'///Prerequisites: A list compatible with listfunctions
'///About listfunctions: All listfunctions rely on a special type of '///+ array. This can be string arrays and - in some cases - numeric '///+ arrays. What makes the arrays unique is that the first item which '///+ has the index 0 contains the number of items in the list to be used, '///+ anything that is stored beyond this number is ignored. This has three '///+ consequences: 1) all listfunctions that alter an array must update '///+ the index stored in array(0) and 2) it is possible that the index '///+ point beyond ubound of the array which will most likely cause a '///+ runtime error. 3) Means that arrays may only have an upper boundary '///+ declared, all loops must start with index array(1) and must end with '///+ index array(val( array(0))

'///Input: '///
    '///+
  1. Target list (string)
  2. '///+
  3. Source list (string)
  4. '///
'///Returns: '///
    '///+
  1. Listsize (integer)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hCountMatchesInList( acItemList() as string, cSearchTerm as string ) as integer '///

Find out how many times a string is found in a list

'///Parameter(s):
'///
    '///+
  1. List to be searched (String)
  2. '/// '///+
  3. Expression to search for (String)
  4. '/// '///
'///Returns:
'///
    '///+
  1. Number of hits (Integer)
  2. '/// '///
const CFN = "hCountMatchesInList::" printlog( CFN & "Enter" ) dim iHitCount as integer dim iItemCount as integer dim iCurrentItem as integer '///Description: '/// printlog( CFN & "Exit with result: " & iHitCount ) hCountMatchesInList() = iHitCount end function