2 eval 'exec perl -wS $0 ${1+"$@"}'
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");
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";
38 my ($hid, $winpath, $outfile) = @ARGV;
42 open HID
, "<$hid" or die "can't open file $filename $! $^E";
45 my ($longname, $ID) = split " +";
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;
73 foreach ( glob("$winpath/*win") ) {
75 open WIN
, "< $filename" or die "can't open file $filename $! $^E";
78 my $parentshortname = "";
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 )
104 if ( $longname =~ /^(.uno:|http|private:factory|service:|macro:|.HelpId:)/i || $longname =~ s/^sym://i )
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";
147 push @names, "$parentinfo $_";
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";
166 push ( @
{$dialogs{ $parentshortname }}, $iteminfo );
167 push @names, "$parentinfo $iteminfo";
174 for ( keys %undeclared_hids ) {
175 $iteminfo = "$undeclared_hids{$_} $undeclared_hids{$_} $hids{$_}";
176 push @names, " $iteminfo";
179 #----------------------------------------------------------------------------
182 open HIDS
, ">$outfile" or die "can't open file $filename $! $^E";
183 print HIDS
join "\n", @names;