2 eval 'exec perl -wS $0 ${1+"$@"}'
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
33 #*************************************************************************
35 # pushids - push HID.LST and *.win files for userexperience feedback
38 use lib
("$ENV{SOLARENV}/bin/modules", "$ENV{COMMON_ENV_TOOLS}/modules");
46 print "usage: $ARGV[0] <path tp hid.lst> <path to *.win files> <output file>\n";
47 print "example: $ARGV[0] ./hid.lst global/win common/misc/UserFeedbackNames.csv\n\n";
51 my ($hid, $winpath, $outfile) = @ARGV;
55 open HID
, "<$hid" or die "can't open file $filename $! $^E";
58 my ($longname, $ID) = split " +";
60 $upperlongname = $longname;
61 $upperlongname =~ tr/a-z/A-Z/;
62 $undeclared_hids{$upperlongname} = $longname;
64 if ( exists $hids{$upperlongname} && ( $hids{$upperlongname} != $ID ) )
66 print STDERR
"errror: unclear definition of longname: $longname = $hids{$upperlongname} or $ID\n";
68 $hids{$upperlongname} = $ID;
70 if ( exists $revhids{ $ID } && ( $revhids{ $ID } ne $upperlongname ) )
72 print STDERR
"warn: two longnames have the same ID: $longname and $revhids{$ID} share ID $ID\n";
74 $revhids{$ID} = $upperlongname;
86 foreach ( glob("$winpath/*win") ) {
88 open WIN
, "< $filename" or die "can't open file $filename $! $^E";
91 my $parentshortname = "";
104 my ($shortname, $longname) = split " +";
106 $shortname = "" if ( !$shortname );
107 $longname = "" if ( !$longname );
109 # fake a correct entry if only *active is given and overwrite the attempt to declare it differently
110 if ( $shortname =~ /\*active/i )
112 $longname = "Active";
117 if ( $longname =~ /^(.uno:|http|private:factory|service:|macro:|.HelpId:)/i || $longname =~ s/^sym://i )
124 my $upperlongname = $longname;
125 $upperlongname =~ tr/a-z/A-Z/;
126 if ( $shortname !~ /^[\+\*]/ && !exists $hids{$upperlongname} )
128 print STDERR
"errror: Longname not in hid.lst: $filename $longname\n";
130 if ( exists $hids{$upperlongname} )
132 $ID = $hids{$upperlongname};
134 delete $undeclared_hids{$upperlongname};
137 $iteminfo = "$shortname $longname $ID";
138 # print "$iteminfo\n" if ( ! ( $shortname && $longname && $ID ));
139 $iteminfo =~ s/^\*//;
140 $iteminfo =~ s/^\+//;
142 # find start of deklaration
143 if ( $shortname =~ s/^\+// )
145 # copy existing dialog
146 if ( exists $dialogs{ $longname } )
148 my @old = @
{$dialogs{ $longname }};
149 my ($oldshort, $oldlong, $oldID ) = split ( " ", shift @old );
150 $iteminfo = "$shortname $oldlong $oldID";
152 $parentinfo = $iteminfo;
153 $parentshortname = $shortname;
154 $dialogs{ $parentshortname } = \
@dialog;
155 @dialog = (); # break the link
156 push ( @
{$dialogs{ $parentshortname }}, $iteminfo );
157 push @names, " $parentinfo";
161 push @names, "$parentinfo $_";
165 { # fake new dialog instead
166 $shortname = "*".$shortname;
169 if ( $shortname =~ s/^\*// )
171 $parentinfo = $iteminfo;
172 $parentshortname = $shortname;
173 $dialogs{ $parentshortname } = \
@dialog;
174 @dialog = (); # break the link
175 push ( @
{$dialogs{ $parentshortname }}, $iteminfo );
176 push @names, " $parentinfo";
180 push ( @
{$dialogs{ $parentshortname }}, $iteminfo );
181 push @names, "$parentinfo $iteminfo";
188 for ( keys %undeclared_hids ) {
189 $iteminfo = "$undeclared_hids{$_} $undeclared_hids{$_} $hids{$_}";
190 push @names, " $iteminfo";
193 #----------------------------------------------------------------------------
196 open HIDS
, ">$outfile" or die "can't open file $filename $! $^E";
197 print HIDS
join "\n", @names;