1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3    if 0;
4#**************************************************************
5#
6#  Licensed to the Apache Software Foundation (ASF) under one
7#  or more contributor license agreements.  See the NOTICE file
8#  distributed with this work for additional information
9#  regarding copyright ownership.  The ASF licenses this file
10#  to you under the Apache License, Version 2.0 (the
11#  "License"); you may not use this file except in compliance
12#  with the License.  You may obtain a copy of the License at
13#
14#    http://www.apache.org/licenses/LICENSE-2.0
15#
16#  Unless required by applicable law or agreed to in writing,
17#  software distributed under the License is distributed on an
18#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19#  KIND, either express or implied.  See the License for the
20#  specific language governing permissions and limitations
21#  under the License.
22#
23#**************************************************************
24
25
26#
27# pushids - push HID.LST and *.win files for userexperience feedback
28#
29
30use lib ("$ENV{SOLARENV}/bin/modules", "$ENV{COMMON_ENV_TOOLS}/modules");
31
32use Carp;
33
34sub parse_info($$);
35
36if ( @ARGV != 3 )
37{
38  print "usage:   $ARGV[0] <path tp hid.lst> <path to *.win files> <output file>\n";
39  print "example: $ARGV[0] ./hid.lst global/win common/misc/UserFeedbackNames.csv\n\n";
40  die "invalid params";
41}
42
43my ($hid, $winpath, $outfile) = @ARGV;
44
45my @names;
46
47open HID, "<$hid" or die "can't open file $filename $! $^E";
48for (<HID>) {
49  chop;
50  my ($longname, $ID) = split " +";
51  next if ( ! $ID );
52  $upperlongname = $longname;
53  $upperlongname =~ tr/a-z/A-Z/;
54  $undeclared_hids{$upperlongname} = $longname;
55
56  if ( exists $hids{$upperlongname} && ( $hids{$upperlongname} != $ID ) )
57  {
58    print STDERR "error: unclear definition of longname: $longname = $hids{$upperlongname} or $ID\n";
59  }
60  $hids{$upperlongname} = $ID;
61
62  if ( exists $revhids{ $ID } && ( $revhids{ $ID } ne $upperlongname ) )
63  {
64    print STDERR "warn: two longnames have the same ID: $longname and $revhids{$ID} share ID $ID\n";
65  }
66  $revhids{$ID} = $upperlongname;
67}
68
69close HID;
70
71undef @revhids;
72
73#Add Active
74$hids{"ACTIVE"} = 0;
75
76my %dialogs = ();
77
78foreach ( glob("$winpath/*win") ) {
79  $filename = $_;
80  open WIN, "< $filename" or die "can't open file $filename $! $^E";
81  my $parentinfo = "";
82  my @dialog = ();
83  my $parentshortname = "";
84
85  for ( <WIN> ) {
86    chop;
87
88	s/^ +//;
89	s/ +/ /g;
90
91    next if /^ *'/;
92    next if /^ *$/;
93
94    my $ID = "";
95    my $iteminfo;
96    my ($shortname, $longname) = split " +";
97
98    $shortname = "" if ( !$shortname );
99    $longname = "" if ( !$longname );
100
101    # fake a correct entry if only *active is given and overwrite the attempt to declare it differently
102    if ( $shortname =~ /\*active/i )
103    {
104      $longname = "Active";
105    }
106
107
108# find UNO Names
109    if ( $longname =~ /^(.uno:|http|private:factory|service:|macro:|.HelpId:)/i || $longname =~ s/^sym://i )
110    {
111      $ID = $longname;
112      $longname = "";
113    }
114    else
115    {
116      my $upperlongname = $longname;
117      $upperlongname =~ tr/a-z/A-Z/;
118      if ( $shortname !~ /^[\+\*]/ && !exists $hids{$upperlongname} )
119      {
120        print STDERR "error: Longname not in hid.lst: $filename $longname\n";
121      }
122      if ( exists $hids{$upperlongname} )
123      {
124          $ID = $hids{$upperlongname};
125      }
126      delete $undeclared_hids{$upperlongname};
127    }
128
129    $iteminfo = "$shortname $longname $ID";
130#    print "$iteminfo\n" if ( ! ( $shortname && $longname && $ID ));
131    $iteminfo =~ s/^\*//;
132    $iteminfo =~ s/^\+//;
133
134# find start of deklaration
135    if ( $shortname =~ s/^\+// )
136    {
137      # copy existing dialog
138      if ( exists $dialogs{ $longname } )
139      {
140        my @old = @{$dialogs{ $longname }};
141        my ($oldshort, $oldlong, $oldID ) = split ( " ", shift @old );
142        $iteminfo = "$shortname $oldlong $oldID";
143
144        $parentinfo = $iteminfo;
145        $parentshortname = $shortname;
146        $dialogs{ $parentshortname } = \@dialog;
147        @dialog = ();        # break the link
148        push ( @{$dialogs{ $parentshortname }}, $iteminfo );
149        push @names, "   $parentinfo";
150
151        for ( @old )
152        {
153          push @names, "$parentinfo $_";
154        }
155      }
156      else
157      {  # fake new dialog instead
158        $shortname = "*".$shortname;
159      }
160    }
161    if ( $shortname =~ s/^\*// )
162    {
163      $parentinfo = $iteminfo;
164      $parentshortname = $shortname;
165      $dialogs{ $parentshortname } = \@dialog;
166      @dialog = ();        # break the link
167      push ( @{$dialogs{ $parentshortname }}, $iteminfo );
168      push @names, "   $parentinfo";
169    }
170    else
171    {
172      push ( @{$dialogs{ $parentshortname }}, $iteminfo );
173      push @names, "$parentinfo $iteminfo";
174    }
175
176  }
177  close WIN;
178}
179
180for ( keys %undeclared_hids ) {
181  $iteminfo = "$undeclared_hids{$_} $undeclared_hids{$_} $hids{$_}";
182  push @names, "   $iteminfo";
183}
184
185#----------------------------------------------------------------------------
186# write to files
187
188open HIDS, ">$outfile" or die "can't open file $filename $! $^E";
189print HIDS join "\n", @names;
190print HIDS "\n";
191close HIDS;
192
193