1 #*************************************************************************
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: converter.pm,v $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
33 package par2script
::converter
;
35 use par2script
::remover
;
37 #############################
39 #############################
41 sub convert_array_to_hash
45 my ($line, $key, $value);
49 for ( my $i = 0; $i <= $#{$arrayref}; $i++ )
51 $line = ${$arrayref}[$i];
53 if ( $line =~ /^\s*(\w+?)\s+(.*?)\s*$/ )
57 $newhash{$key} = $value;
64 sub convert_hash_into_array
69 my ($key, $value, $input);
71 foreach $key (keys %{$hashref})
73 $value = $hashref->{$key};
74 $input = "$key = $value\n";
81 sub convert_stringlist_into_array_2
83 my ( $input, $separator ) = @_;
91 while ( $last =~ /^\s*(.+?)\s*\Q$separator\E\s*(.+)\s*$/) # "$" for minimal matching
95 par2script
::remover
::remove_leading_and_ending_whitespaces
(\
$first);
96 if ( $first ) { push(@newarray, $first); }
99 par2script
::remover
::remove_leading_and_ending_whitespaces
(\
$last);
100 if ( $last ) { push(@newarray, $last); }
105 sub convert_stringlist_into_array
107 my ( $includestringref, $separator ) = @_;
112 $last = ${$includestringref};
114 while ( $last =~ /^\s*(.+?)\s*\Q$separator\E\s*(.+)\s*$/) # "$" for minimal matching
118 par2script
::remover
::remove_leading_and_ending_whitespaces
(\
$first);
119 push(@newarray, $first);
122 par2script
::remover
::remove_leading_and_ending_whitespaces
(\
$last);
123 push(@newarray, $last);
128 #############################################################################
129 # The file name contains for some files "/". If this programs runs on
130 # a windows platform, this has to be converted to "\".
131 #############################################################################
133 sub convert_slash_to_backslash
135 my ($filesarrayref) = @_;
137 my ($onefile, $filename);
139 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
141 $onefile = ${$filesarrayref}[$i];
142 $onefile->{'Name'} =~ s/\//\\/g
;