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