'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 : Functions for manipulation of strings '* '\****************************************************************************** function hRemoveLineBreaks( cString as string ) as string dim myString as string : myString = cString myString = hStringReplaceChar( myString, CHR$(09), " " ) myString = hStringReplaceChar( myString, CHR$(13), " " ) myString = hStringReplaceChar( myString, CHR$(10), "" ) hRemoveLineBreaks() = myString end function '******************************************************************************* function hCompareSubStrings( cRef as string, cSub as string ) as integer '///

Find substring in a reference string

'///Used to determine that we are on "The first doc!"

'///Parameter(s): '///
    '///+
  1. Term to search for (string)
  2. '///+
  3. Term to be searched (string)
  4. '///
'///Returns: '///
    '///+
  1. Errorcode (integer)
  2. '/// '///
'///Description: '/// end function '****************************************************************************** function hGetDirTreeLevel( cFullPath as string ) as integer '///

Count the numbers of pathseparators in a path-string

'///Used to find the level of current directory within the directory tree.
'///+The function prints a warning when no pathseparators were found


'///Parameter(s): '///
    '///+
  1. Path (string) with no trailing pathseparator
  2. '///
'///Returns: '///
    '///+
  1. Number of Pathseparators within the string (integer)
  2. '/// '///
'///Description: '/// hGetDirTreeLevel() = iSeparatorCount end function '******************************************************************************* function hGetStringFromStaticTextField( oControl as object ) as string use "global\tools\includes\optional\t_accels.inc" '///

Get the string from a static textfield

'///Static textfields like those in the document properties dialog are '///+ in certain places designed in a way that the string can be selected '///+ and copied to the clipboard. This has been introduced with SRC680m212 '///+ (9156). This function uses keyboard shortcuts for "Select All" '///+ and "Copy" to get the string into the clipboard as .uno.Copy '///+ is not enabled.

'///Parameter(s):
'///
    '///+
  1. Name of the control (Object)
  2. '/// '///
'///Returns:
'///
    '///+
  1. Content of the field (String)
  2. '/// '///
const CFN = "hGetStringFromStaticTextField::" dim brc as boolean 'a multi purpose boolean returnvalue dim cSelectAll as string dim cCopy as string dim cText as string if ( GVERBOSE ) then printlog( CFN & "Enter" ) '///Description: '/// hGetStringFromStaticTextField() = cText end function '******************************************************************************* function hConvertStringToLong( cValue as string ) as long '///

Convert a stringvalue to long int

'///The purpose of this function is to isolate the filesize from a string '///+ of the type "1.345 Bytes" by removing the thousands-separator '///+ and the trailing unit. The result is then a filesize as long integer '///+ which then can be compared to the result from the BASIC function '///+ FileLen( FileSpec )

'///Parameter(s):
'///
    '///+
  1. String containing a long integer value (String)
  2. '/// '///
'///Returns:
'///
    '///+
  1. Value of the string as long integer (Long)
  2. '/// '///
const CFN = "hConvertStringToLong::" const ONE_CHARACTER = 1 if ( GVERBOSE ) then printlog( CFN & "Enter with option: " & cValue ) dim iLen as integer : iLen = len( cValue ) dim iChar as integer dim cChar as string dim cStringValue as string : cStringValue = "" '///Description: '/// end function '******************************************************************************* function hStringReplace( cString as string, search_string as string, replace_with as string ) as string const CFN = "hStringReplace(): " dim search_string_position as string dim search_string_found as boolean : search_string_found = true dim len_search_string as integer : len_search_string = len( search_string ) dim len_replace_with as integer : len_replace_with = len( replace_with ) dim myString as string : myString = cString if ( GVERBOSE ) then printlog( CFN & "Replace all <" & search_string & "> with <" & replace_with & "> in <" & myString & ">" ) if ( not instr( replace_with, search_string ) and len_search_string >= len_replace_with ) then do while( search_string_found ) search_string_position = instr( myString, search_string ) if ( search_string_position > 0 ) then mid( myString, search_string_position, len( search_string ), replace_with ) else search_string_found = false endif loop else warnlog( CFN & "Function used incorrectly" ) warnlog( CFN & "Replace all <" & search_string & "> with <" & replace_with & "> in <" & myString & ">" ) warnlog( CFN & "The new string must be of equal length or shorter than the string to be replaced" ) warnlog( CFN & "The new string may not contain the string to be replaced (e.g. replace 'a' with 'ha' is not allowed)" ) endif if ( GVERBOSE ) then printlog( CFN & "Return string is <" & myString & ">" ) hStringReplace() = myString end function