bump product version to 4.1.6.2
[LibreOffice.git] / solenv / bin / gen_userfeedback_VCL_names.pl
blob002fd50595c298c80e6d68137df75d2feba137a1
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
5 # This file is part of the LibreOffice project.
7 # This Source Code Form is subject to the terms of the Mozilla Public
8 # License, v. 2.0. If a copy of the MPL was not distributed with this
9 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 # This file incorporates work covered by the following license notice:
13 # Licensed to the Apache Software Foundation (ASF) under one or more
14 # contributor license agreements. See the NOTICE file distributed
15 # with this work for additional information regarding copyright
16 # ownership. The ASF licenses this file to you under the Apache
17 # License, Version 2.0 (the "License"); you may not use this file
18 # except in compliance with the License. You may obtain a copy of
19 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 # pushids - push HID.LST and *.win files for userexperience feedback
25 use lib ("$ENV{SOLARENV}/bin/modules", "$ENV{COMMON_ENV_TOOLS}/modules");
27 use Carp;
29 sub parse_info($$);
31 if ( @ARGV != 3 )
33 print "usage: $ARGV[0] <path tp hid.lst> <path to *.win files> <output file>\n";
34 print "example: $ARGV[0] ./hid.lst global/win common/misc/UserFeedbackNames.csv\n\n";
35 die "invalid params";
38 my ($hid, $winpath, $outfile) = @ARGV;
40 my @names;
42 open HID, "<$hid" or die "can't open file $filename $! $^E";
43 for (<HID>) {
44 chop;
45 my ($longname, $ID) = split " +";
46 next if ( ! $ID );
47 $upperlongname = $longname;
48 $upperlongname =~ tr/a-z/A-Z/;
49 $undeclared_hids{$upperlongname} = $longname;
51 if ( exists $hids{$upperlongname} && ( $hids{$upperlongname} != $ID ) )
53 print STDERR "warn: unclear definition of longname: $longname = $hids{$upperlongname} or $ID\n";
55 $hids{$upperlongname} = $ID;
57 if ( exists $revhids{ $ID } && ( $revhids{ $ID } ne $upperlongname ) )
59 print STDERR "warn: two longnames have the same ID: $longname and $revhids{$ID} share ID $ID\n";
61 $revhids{$ID} = $upperlongname;
64 close HID;
66 undef @revhids;
68 #Add Active
69 $hids{"ACTIVE"} = 0;
71 my %dialogs = ();
73 foreach ( glob("$winpath/*win") ) {
74 $filename = $_;
75 open WIN, "< $filename" or die "can't open file $filename $! $^E";
76 my $parentinfo = "";
77 my @dialog = ();
78 my $parentshortname = "";
80 for ( <WIN> ) {
81 chop;
83 s/^ +//;
84 s/ +/ /g;
86 next if /^ *'/;
87 next if /^ *$/;
89 my $ID = "";
90 my $iteminfo;
91 my ($shortname, $longname) = split " +";
93 $shortname = "" if ( !$shortname );
94 $longname = "" if ( !$longname );
96 # fake a correct entry if only *active is given and overwrite the attempt to declare it differently
97 if ( $shortname =~ /\*active/i )
99 $longname = "Active";
103 # find UNO Names
104 if ( $longname =~ /^(.uno:|http|private:factory|service:|macro:|.HelpId:)/i || $longname =~ s/^sym://i )
106 $ID = $longname;
107 $longname = "";
109 else
111 my $upperlongname = $longname;
112 $upperlongname =~ tr/a-z/A-Z/;
113 if ( $shortname !~ /^[\+\*]/ && !exists $hids{$upperlongname} )
115 print STDERR "warn: Longname not in hid.lst: $filename $longname\n";
117 if ( exists $hids{$upperlongname} )
119 $ID = $hids{$upperlongname};
121 delete $undeclared_hids{$upperlongname};
124 $iteminfo = "$shortname $longname $ID";
125 $iteminfo =~ s/^\*//;
126 $iteminfo =~ s/^\+//;
128 # find start of deklaration
129 if ( $shortname =~ s/^\+// )
131 # copy existing dialog
132 if ( exists $dialogs{ $longname } )
134 my @old = @{$dialogs{ $longname }};
135 my ($oldshort, $oldlong, $oldID ) = split ( " ", shift @old );
136 $iteminfo = "$shortname $oldlong $oldID";
138 $parentinfo = $iteminfo;
139 $parentshortname = $shortname;
140 $dialogs{ $parentshortname } = \@dialog;
141 @dialog = (); # break the link
142 push ( @{$dialogs{ $parentshortname }}, $iteminfo );
143 push @names, " $parentinfo";
145 for ( @old )
147 push @names, "$parentinfo $_";
150 else
151 { # fake new dialog instead
152 $shortname = "*".$shortname;
155 if ( $shortname =~ s/^\*// )
157 $parentinfo = $iteminfo;
158 $parentshortname = $shortname;
159 $dialogs{ $parentshortname } = \@dialog;
160 @dialog = (); # break the link
161 push ( @{$dialogs{ $parentshortname }}, $iteminfo );
162 push @names, " $parentinfo";
164 else
166 push ( @{$dialogs{ $parentshortname }}, $iteminfo );
167 push @names, "$parentinfo $iteminfo";
171 close WIN;
174 for ( keys %undeclared_hids ) {
175 $iteminfo = "$undeclared_hids{$_} $undeclared_hids{$_} $hids{$_}";
176 push @names, " $iteminfo";
179 #----------------------------------------------------------------------------
180 # write to files
182 open HIDS, ">$outfile" or die "can't open file $filename $! $^E";
183 print HIDS join "\n", @names;
184 print HIDS "\n";
185 close HIDS;