'encoding UTF-8 Do not remove or change this line! '************************************************************** ' ' Licensed to the Apache Software Foundation (ASF) under one ' or more contributor license agreements. See the NOTICE file ' distributed with this work for additional information ' regarding copyright ownership. The ASF licenses this file ' to you under the Apache License, Version 2.0 (the ' "License"); you may not use this file except in compliance ' with the License. You may obtain a copy of the License at ' ' http://www.apache.org/licenses/LICENSE-2.0 ' ' Unless required by applicable law or agreed to in writing, ' software distributed under the License is distributed on an ' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ' KIND, either express or implied. See the License for the ' specific language governing permissions and limitations ' under the License. ' '************************************************************** '* '* 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