fix invalid superflous #endif from 5bd2890a56125d391b42f34d51e2e0c57b0a80b0
[LibreOffice.git] / solenv / bin / gen_userfeedback_VCL_names.pl
blob5cfb5d4c7f9dca9ce1cae2b3e250245d052ca25c
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 2000, 2010 Oracle and/or its affiliates.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # This file is part of OpenOffice.org.
14 # OpenOffice.org is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU Lesser General Public License version 3
16 # only, as published by the Free Software Foundation.
18 # OpenOffice.org is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU Lesser General Public License version 3 for more details
22 # (a copy is included in the LICENSE file that accompanied this code).
24 # You should have received a copy of the GNU Lesser General Public License
25 # version 3 along with OpenOffice.org. If not, see
26 # <http://www.openoffice.org/license.html>
27 # for a copy of the LGPLv3 License.
29 #*************************************************************************
31 # pushids - push HID.LST and *.win files for userexperience feedback
34 use lib ("$ENV{SOLARENV}/bin/modules", "$ENV{COMMON_ENV_TOOLS}/modules");
36 use Carp;
38 sub parse_info($$);
40 if ( @ARGV != 3 )
42 print "usage: $ARGV[0] <path tp hid.lst> <path to *.win files> <output file>\n";
43 print "example: $ARGV[0] ./hid.lst global/win common/misc/UserFeedbackNames.csv\n\n";
44 die "invalid params";
47 my ($hid, $winpath, $outfile) = @ARGV;
49 my @names;
51 open HID, "<$hid" or die "can't open file $filename $! $^E";
52 for (<HID>) {
53 chop;
54 my ($longname, $ID) = split " +";
55 next if ( ! $ID );
56 $upperlongname = $longname;
57 $upperlongname =~ tr/a-z/A-Z/;
58 $undeclared_hids{$upperlongname} = $longname;
60 if ( exists $hids{$upperlongname} && ( $hids{$upperlongname} != $ID ) )
62 print STDERR "warn: unclear definition of longname: $longname = $hids{$upperlongname} or $ID\n";
64 $hids{$upperlongname} = $ID;
66 if ( exists $revhids{ $ID } && ( $revhids{ $ID } ne $upperlongname ) )
68 print STDERR "warn: two longnames have the same ID: $longname and $revhids{$ID} share ID $ID\n";
70 $revhids{$ID} = $upperlongname;
73 close HID;
75 undef @revhids;
77 #Add Active
78 $hids{"ACTIVE"} = 0;
80 my %dialogs = ();
82 foreach ( glob("$winpath/*win") ) {
83 $filename = $_;
84 open WIN, "< $filename" or die "can't open file $filename $! $^E";
85 my $parentinfo = "";
86 my @dialog = ();
87 my $parentshortname = "";
89 for ( <WIN> ) {
90 chop;
92 s/^ +//;
93 s/ +/ /g;
95 next if /^ *'/;
96 next if /^ *$/;
98 my $ID = "";
99 my $iteminfo;
100 my ($shortname, $longname) = split " +";
102 $shortname = "" if ( !$shortname );
103 $longname = "" if ( !$longname );
105 # fake a correct entry if only *active is given and overwrite the attempt to declare it differently
106 if ( $shortname =~ /\*active/i )
108 $longname = "Active";
112 # find UNO Names
113 if ( $longname =~ /^(.uno:|http|private:factory|service:|macro:|.HelpId:)/i || $longname =~ s/^sym://i )
115 $ID = $longname;
116 $longname = "";
118 else
120 my $upperlongname = $longname;
121 $upperlongname =~ tr/a-z/A-Z/;
122 if ( $shortname !~ /^[\+\*]/ && !exists $hids{$upperlongname} )
124 print STDERR "warn: Longname not in hid.lst: $filename $longname\n";
126 if ( exists $hids{$upperlongname} )
128 $ID = $hids{$upperlongname};
130 delete $undeclared_hids{$upperlongname};
133 $iteminfo = "$shortname $longname $ID";
134 $iteminfo =~ s/^\*//;
135 $iteminfo =~ s/^\+//;
137 # find start of deklaration
138 if ( $shortname =~ s/^\+// )
140 # copy existing dialog
141 if ( exists $dialogs{ $longname } )
143 my @old = @{$dialogs{ $longname }};
144 my ($oldshort, $oldlong, $oldID ) = split ( " ", shift @old );
145 $iteminfo = "$shortname $oldlong $oldID";
147 $parentinfo = $iteminfo;
148 $parentshortname = $shortname;
149 $dialogs{ $parentshortname } = \@dialog;
150 @dialog = (); # break the link
151 push ( @{$dialogs{ $parentshortname }}, $iteminfo );
152 push @names, " $parentinfo";
154 for ( @old )
156 push @names, "$parentinfo $_";
159 else
160 { # fake new dialog instead
161 $shortname = "*".$shortname;
164 if ( $shortname =~ s/^\*// )
166 $parentinfo = $iteminfo;
167 $parentshortname = $shortname;
168 $dialogs{ $parentshortname } = \@dialog;
169 @dialog = (); # break the link
170 push ( @{$dialogs{ $parentshortname }}, $iteminfo );
171 push @names, " $parentinfo";
173 else
175 push ( @{$dialogs{ $parentshortname }}, $iteminfo );
176 push @names, "$parentinfo $iteminfo";
180 close WIN;
183 for ( keys %undeclared_hids ) {
184 $iteminfo = "$undeclared_hids{$_} $undeclared_hids{$_} $hids{$_}";
185 push @names, " $iteminfo";
188 #----------------------------------------------------------------------------
189 # write to files
191 open HIDS, ">$outfile" or die "can't open file $filename $! $^E";
192 print HIDS join "\n", @names;
193 print HIDS "\n";
194 close HIDS;