1*cdf0e10cSrcweir:
2*cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}'
3*cdf0e10cSrcweir    if 0;
4*cdf0e10cSrcweir#*************************************************************************
5*cdf0e10cSrcweir#
6*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7*cdf0e10cSrcweir#
8*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates.
9*cdf0e10cSrcweir#
10*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite
11*cdf0e10cSrcweir#
12*cdf0e10cSrcweir# This file is part of OpenOffice.org.
13*cdf0e10cSrcweir#
14*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify
15*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3
16*cdf0e10cSrcweir# only, as published by the Free Software Foundation.
17*cdf0e10cSrcweir#
18*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful,
19*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of
20*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details
22*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code).
23*cdf0e10cSrcweir#
24*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License
25*cdf0e10cSrcweir# version 3 along with OpenOffice.org.  If not, see
26*cdf0e10cSrcweir# <http://www.openoffice.org/license.html>
27*cdf0e10cSrcweir# for a copy of the LGPLv3 License.
28*cdf0e10cSrcweir#
29*cdf0e10cSrcweir#*************************************************************************
30*cdf0e10cSrcweir#
31*cdf0e10cSrcweir# pushids - push HID.LST and *.win files for userexperience feedback
32*cdf0e10cSrcweir#
33*cdf0e10cSrcweir
34*cdf0e10cSrcweiruse lib ("$ENV{SOLARENV}/bin/modules", "$ENV{COMMON_ENV_TOOLS}/modules");
35*cdf0e10cSrcweir
36*cdf0e10cSrcweiruse Carp;
37*cdf0e10cSrcweir
38*cdf0e10cSrcweirsub parse_info($$);
39*cdf0e10cSrcweir
40*cdf0e10cSrcweirif ( @ARGV != 3 )
41*cdf0e10cSrcweir{
42*cdf0e10cSrcweir  print "usage:   $ARGV[0] <path tp hid.lst> <path to *.win files> <output file>\n";
43*cdf0e10cSrcweir  print "example: $ARGV[0] ./hid.lst global/win common/misc/UserFeedbackNames.csv\n\n";
44*cdf0e10cSrcweir  die "invalid params";
45*cdf0e10cSrcweir}
46*cdf0e10cSrcweir
47*cdf0e10cSrcweirmy ($hid, $winpath, $outfile) = @ARGV;
48*cdf0e10cSrcweir
49*cdf0e10cSrcweirmy @names;
50*cdf0e10cSrcweir
51*cdf0e10cSrcweiropen HID, "<$hid" or die "can't open file $filename $! $^E";
52*cdf0e10cSrcweirfor (<HID>) {
53*cdf0e10cSrcweir  chop;
54*cdf0e10cSrcweir  my ($longname, $ID) = split " +";
55*cdf0e10cSrcweir  next if ( ! $ID );
56*cdf0e10cSrcweir  $upperlongname = $longname;
57*cdf0e10cSrcweir  $upperlongname =~ tr/a-z/A-Z/;
58*cdf0e10cSrcweir  $undeclared_hids{$upperlongname} = $longname;
59*cdf0e10cSrcweir
60*cdf0e10cSrcweir  if ( exists $hids{$upperlongname} && ( $hids{$upperlongname} != $ID ) )
61*cdf0e10cSrcweir  {
62*cdf0e10cSrcweir    print STDERR "errror: unclear definition of longname: $longname = $hids{$upperlongname} or $ID\n";
63*cdf0e10cSrcweir  }
64*cdf0e10cSrcweir  $hids{$upperlongname} = $ID;
65*cdf0e10cSrcweir
66*cdf0e10cSrcweir  if ( exists $revhids{ $ID } && ( $revhids{ $ID } ne $upperlongname ) )
67*cdf0e10cSrcweir  {
68*cdf0e10cSrcweir    print STDERR "warn: two longnames have the same ID: $longname and $revhids{$ID} share ID $ID\n";
69*cdf0e10cSrcweir  }
70*cdf0e10cSrcweir  $revhids{$ID} = $upperlongname;
71*cdf0e10cSrcweir}
72*cdf0e10cSrcweir
73*cdf0e10cSrcweirclose HID;
74*cdf0e10cSrcweir
75*cdf0e10cSrcweirundef @revhids;
76*cdf0e10cSrcweir
77*cdf0e10cSrcweir#Add Active
78*cdf0e10cSrcweir$hids{"ACTIVE"} = 0;
79*cdf0e10cSrcweir
80*cdf0e10cSrcweirmy %dialogs = ();
81*cdf0e10cSrcweir
82*cdf0e10cSrcweirforeach ( glob("$winpath/*win") ) {
83*cdf0e10cSrcweir  $filename = $_;
84*cdf0e10cSrcweir  open WIN, "< $filename" or die "can't open file $filename $! $^E";
85*cdf0e10cSrcweir  my $parentinfo = "";
86*cdf0e10cSrcweir  my @dialog = ();
87*cdf0e10cSrcweir  my $parentshortname = "";
88*cdf0e10cSrcweir
89*cdf0e10cSrcweir  for ( <WIN> ) {
90*cdf0e10cSrcweir    chop;
91*cdf0e10cSrcweir
92*cdf0e10cSrcweir	s/^ +//;
93*cdf0e10cSrcweir	s/ +/ /g;
94*cdf0e10cSrcweir
95*cdf0e10cSrcweir    next if /^ *'/;
96*cdf0e10cSrcweir    next if /^ *$/;
97*cdf0e10cSrcweir
98*cdf0e10cSrcweir    my $ID = "";
99*cdf0e10cSrcweir    my $iteminfo;
100*cdf0e10cSrcweir    my ($shortname, $longname) = split " +";
101*cdf0e10cSrcweir
102*cdf0e10cSrcweir    $shortname = "" if ( !$shortname );
103*cdf0e10cSrcweir    $longname = "" if ( !$longname );
104*cdf0e10cSrcweir
105*cdf0e10cSrcweir    # fake a correct entry if only *active is given and overwrite the attempt to declare it differently
106*cdf0e10cSrcweir    if ( $shortname =~ /\*active/i )
107*cdf0e10cSrcweir    {
108*cdf0e10cSrcweir      $longname = "Active";
109*cdf0e10cSrcweir    }
110*cdf0e10cSrcweir
111*cdf0e10cSrcweir
112*cdf0e10cSrcweir# find UNO Names
113*cdf0e10cSrcweir    if ( $longname =~ /^(.uno:|http|private:factory|service:|macro:|.HelpId:)/i || $longname =~ s/^sym://i )
114*cdf0e10cSrcweir    {
115*cdf0e10cSrcweir      $ID = $longname;
116*cdf0e10cSrcweir      $longname = "";
117*cdf0e10cSrcweir    }
118*cdf0e10cSrcweir    else
119*cdf0e10cSrcweir    {
120*cdf0e10cSrcweir      my $upperlongname = $longname;
121*cdf0e10cSrcweir      $upperlongname =~ tr/a-z/A-Z/;
122*cdf0e10cSrcweir      if ( $shortname !~ /^[\+\*]/ && !exists $hids{$upperlongname} )
123*cdf0e10cSrcweir      {
124*cdf0e10cSrcweir        print STDERR "errror: Longname not in hid.lst: $filename $longname\n";
125*cdf0e10cSrcweir      }
126*cdf0e10cSrcweir      if ( exists $hids{$upperlongname} )
127*cdf0e10cSrcweir      {
128*cdf0e10cSrcweir          $ID = $hids{$upperlongname};
129*cdf0e10cSrcweir      }
130*cdf0e10cSrcweir      delete $undeclared_hids{$upperlongname};
131*cdf0e10cSrcweir    }
132*cdf0e10cSrcweir
133*cdf0e10cSrcweir    $iteminfo = "$shortname $longname $ID";
134*cdf0e10cSrcweir#    print "$iteminfo\n" if ( ! ( $shortname && $longname && $ID ));
135*cdf0e10cSrcweir    $iteminfo =~ s/^\*//;
136*cdf0e10cSrcweir    $iteminfo =~ s/^\+//;
137*cdf0e10cSrcweir
138*cdf0e10cSrcweir# find start of deklaration
139*cdf0e10cSrcweir    if ( $shortname =~ s/^\+// )
140*cdf0e10cSrcweir    {
141*cdf0e10cSrcweir      # copy existing dialog
142*cdf0e10cSrcweir      if ( exists $dialogs{ $longname } )
143*cdf0e10cSrcweir      {
144*cdf0e10cSrcweir        my @old = @{$dialogs{ $longname }};
145*cdf0e10cSrcweir        my ($oldshort, $oldlong, $oldID ) = split ( " ", shift @old );
146*cdf0e10cSrcweir        $iteminfo = "$shortname $oldlong $oldID";
147*cdf0e10cSrcweir
148*cdf0e10cSrcweir        $parentinfo = $iteminfo;
149*cdf0e10cSrcweir        $parentshortname = $shortname;
150*cdf0e10cSrcweir        $dialogs{ $parentshortname } = \@dialog;
151*cdf0e10cSrcweir        @dialog = ();        # break the link
152*cdf0e10cSrcweir        push ( @{$dialogs{ $parentshortname }}, $iteminfo );
153*cdf0e10cSrcweir        push @names, "   $parentinfo";
154*cdf0e10cSrcweir
155*cdf0e10cSrcweir        for ( @old )
156*cdf0e10cSrcweir        {
157*cdf0e10cSrcweir          push @names, "$parentinfo $_";
158*cdf0e10cSrcweir        }
159*cdf0e10cSrcweir      }
160*cdf0e10cSrcweir      else
161*cdf0e10cSrcweir      {  # fake new dialog instead
162*cdf0e10cSrcweir        $shortname = "*".$shortname;
163*cdf0e10cSrcweir      }
164*cdf0e10cSrcweir    }
165*cdf0e10cSrcweir    if ( $shortname =~ s/^\*// )
166*cdf0e10cSrcweir    {
167*cdf0e10cSrcweir      $parentinfo = $iteminfo;
168*cdf0e10cSrcweir      $parentshortname = $shortname;
169*cdf0e10cSrcweir      $dialogs{ $parentshortname } = \@dialog;
170*cdf0e10cSrcweir      @dialog = ();        # break the link
171*cdf0e10cSrcweir      push ( @{$dialogs{ $parentshortname }}, $iteminfo );
172*cdf0e10cSrcweir      push @names, "   $parentinfo";
173*cdf0e10cSrcweir    }
174*cdf0e10cSrcweir    else
175*cdf0e10cSrcweir    {
176*cdf0e10cSrcweir      push ( @{$dialogs{ $parentshortname }}, $iteminfo );
177*cdf0e10cSrcweir      push @names, "$parentinfo $iteminfo";
178*cdf0e10cSrcweir    }
179*cdf0e10cSrcweir
180*cdf0e10cSrcweir  }
181*cdf0e10cSrcweir  close WIN;
182*cdf0e10cSrcweir}
183*cdf0e10cSrcweir
184*cdf0e10cSrcweirfor ( keys %undeclared_hids ) {
185*cdf0e10cSrcweir  $iteminfo = "$undeclared_hids{$_} $undeclared_hids{$_} $hids{$_}";
186*cdf0e10cSrcweir  push @names, "   $iteminfo";
187*cdf0e10cSrcweir}
188*cdf0e10cSrcweir
189*cdf0e10cSrcweir#----------------------------------------------------------------------------
190*cdf0e10cSrcweir# write to files
191*cdf0e10cSrcweir
192*cdf0e10cSrcweiropen HIDS, ">$outfile" or die "can't open file $filename $! $^E";
193*cdf0e10cSrcweirprint HIDS join "\n", @names;
194*cdf0e10cSrcweirprint HIDS "\n";
195*cdf0e10cSrcweirclose HIDS;
196*cdf0e10cSrcweir
197