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: arrayfuncs.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:19:05 $
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 : misc functions for simpler listhandling. uses t_lists.inc
38 '\******************************************************************************
40 function listdebug( lsList() as string , cComment as string ) as integer
42 '///<h3>Write the content of a list plus a comment out to a file.</h3>
43 '///<i>It is required that following global variables are defined</i>
45 '///+<li>LDN = ListDebugName (char) = the basename of the debugfiles</li>
46 '///+<li>LDC = ListDebugCounter (int) = a number added to the filename</li>
52 cFile = LDN & LDC & ".log"
54 dim sList( 5 ) as string
57 sList( 2 ) = "---------------------------------------------------------------"
58 sList( 3 ) = cComment & " - Listsize: " & listcount( lsList() )
59 sList( 4 ) = "---------------------------------------------------------------"
62 ListWrite( sList() , cFile , "utf8" )
63 ListWriteAppend( lsList() , cFile , "utf8" )
67 '*******************************************************************************
69 function initlistdebug( cComment as string ) as integer
71 '///<h3>Print leading text to a file and an index of the current debug session</h3>
72 '///<i>It is required that following global variables are defined</i>
74 '///+<li>LDN = ListDebugName (char) = the basename of the debugfiles</li>
75 '///+<li>LDC = ListDebugCounter (int) = a number added to the filename</li>
80 dim sList( 5 ) as string
83 sList( 2 ) = "==============================================================="
84 sList( 3 ) = cComment & " ---- Debug-Offset is at: " & LDC
85 sList( 4 ) = "==============================================================="
88 ListWrite( sList() , cFile , "utf8" )
91 printlog( " *** Debug is enabled ***" )
96 '*******************************************************************************
98 function listmoveitem( source() as string, _
100 itemid as integer ) as integer
102 '///<h3>Move one item from one list to another by index</h3>
105 '///+<li>copy the list-item from list A to the end of list B, update listcount</li>
106 listappend( target() , source( itemid ) )
108 '///+<li>Delete the entry from the old list, reindex and update listcount</li>
109 listdelete( source() , itemid )
111 '///+<li>Return then updated listcount of the <i>source</i> list</li>
112 listmoveitem() = listcount( source() )
118 '*******************************************************************************
120 function listconvertpath( lsList() as string ) as integer
122 '///<h3>Execute <i>convertpath</i> on a list containing filepaths</h3>
125 dim iCurrentPath as integer
127 '///+<li>Convert all listitems with <i>convertpath</i></li>
128 for iCurrentPath = 1 to listcount( lsList() )
129 lsList( iCurrentPath ) = convertpath( lsList( iCurrentPath ) )
132 '///+<li>Return the number of processed paths (listcount)</li>
133 listconvertpath() = listcount( lsList() )
139 '*******************************************************************************
141 function listInsertSection( lsList() as string, _
142 cSection as string ) as integer
144 '///<h3>Appends a section (as ordinary list element) to a list</h3>
148 dim sSectionString as string
150 '///+<li>Get the current number of entries from the list</li>
151 iPos = listcount( lsList() )
153 '///+<li>Insert a blank list-entry if we are not at the beginning of the list</li>
155 listappend( lsList() , "" )
158 '///+<li>Build the section string of type [section-name]</li>
159 sSectionString = "[" & cSection & "]"
161 '///+<li>Append the new section to the list</li>
162 listappend( lsList() , sSectionString )
164 '///+<li>Return the new number of entries in the list (listcount)</li>
165 listInsertSection() = listcount( lsList() )