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