Update ooo320-m1
[ooovba.git] / solenv / bin / gen_userfeedback_VCL_names.pl
blobeb68f987416f6d642d46f4d2f96fc0594d035bbc
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
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
12 # $RCSfile: ,v $
14 # $Revision: $
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");
40 use Carp;
42 sub parse_info($$);
44 if ( @ARGV != 3 )
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";
48 die "invalid params";
51 my ($hid, $winpath, $outfile) = @ARGV;
53 my @names;
55 open HID, "<$hid" or die "can't open file $filename $! $^E";
56 for (<HID>) {
57 chop;
58 my ($longname, $ID) = split " +";
59 next if ( ! $ID );
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;
77 close HID;
79 undef @revhids;
81 #Add Active
82 $hids{"ACTIVE"} = 0;
84 my %dialogs = ();
86 foreach ( glob("$winpath/*win") ) {
87 $filename = $_;
88 open WIN, "< $filename" or die "can't open file $filename $! $^E";
89 my $parentinfo = "";
90 my @dialog = ();
91 my $parentshortname = "";
93 for ( <WIN> ) {
94 chop;
96 s/^ +//;
97 s/ +/ /g;
99 next if /^ *'/;
100 next if /^ *$/;
102 my $ID = "";
103 my $iteminfo;
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";
116 # find UNO Names
117 if ( $longname =~ /^(.uno:|http|private:factory|service:|macro:|.HelpId:)/i || $longname =~ s/^sym://i )
119 $ID = $longname;
120 $longname = "";
122 else
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";
159 for ( @old )
161 push @names, "$parentinfo $_";
164 else
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";
178 else
180 push ( @{$dialogs{ $parentshortname }}, $iteminfo );
181 push @names, "$parentinfo $iteminfo";
185 close WIN;
188 for ( keys %undeclared_hids ) {
189 $iteminfo = "$undeclared_hids{$_} $undeclared_hids{$_} $hids{$_}";
190 push @names, " $iteminfo";
193 #----------------------------------------------------------------------------
194 # write to files
196 open HIDS, ">$outfile" or die "can't open file $filename $! $^E";
197 print HIDS join "\n", @names;
198 print HIDS "\n";
199 close HIDS;