2 eval 'exec perl -wS $0 ${1+"$@"}'
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: mhids.pl,v $
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
33 #*************************************************************************
48 # variables to setup the compiler line
54 my $preprocess_flag; # preprocess to stdout
60 my $errstring = shift @_;
63 print STDERR
"$errstring\n";
65 foreach my $i (@cleanuplist) {
66 unlink "$workfile$i" if -f
"$workfile$i" or print STDERR
"ERROR - couldn't remove $workfile$i\n";
74 my $whichcom = $ENV{COM
};
75 my $extra_cflags = $ENV{EXTRA_CFLAGS
};
76 $extra_cflags = "" if (!$extra_cflags);
77 if ( "$whichcom" eq "GCC" ) {
78 $appext = ""; # windows for now
79 $compiler = "gcc -x c $extra_cflags";
83 $preprocess_flag = "-E"; # preprocess to stdout
84 } elsif ( "$whichcom" eq "MSC" ) {
85 $appext = ".exe"; # windows for now
90 $preprocess_flag = "-EP"; # preprocess to stdout
91 } elsif ( "$whichcom" eq "C52" ) {
92 $appext = ""; # windows for now
97 $preprocess_flag = "-E"; # preprocess to stdout
99 # hack for SO cc wrapper
100 $ENV{wrapper_override_cc_wrapper
} = "TRUE";
101 $solarincludes =~ s/stl/xstlx/g;
102 $defs =~ s/\/stl/\
/xstlx/g;
104 print STDERR
"----------------------------------------------------------------------\n";
105 print STDERR
"OOops... looks like your compiler isn't known to \n$0\n";
106 print STDERR
"please edit the \"setcompiler\" section of this script to make it work.\n";
107 print STDERR
"----------------------------------------------------------------------\n";
108 die "ERROR - compiler (or \$COM settings) unknown!\n";
112 #---------------------------------------------------
117 my @expectedArgs = ( \
$filename, \
$srs, \
$prjname );
118 my $expectedArgsIndex = 0;
119 while ( ( $#ARGV >= 0 ) && ( $expectedArgsIndex < 3 ) )
127 ${$expectedArgs[ $expectedArgsIndex ]} = $_;
128 ++$expectedArgsIndex;
131 $defs = join " ",@ARGV if ($#ARGV);
133 if ( !defined $prjname ) { die "ERROR - check usage\n"; }
135 if ( $ENV{NO_HID_FILES
} ) {
136 $no_hid_files = $ENV{"NO_HID_FILES"};
138 $solarincludes = $ENV{SOLARINCLUDES
};
139 if (defined $ENV{TMPDIR
}) {
140 $tmpdir = $ENV{TMPDIR
};
141 } elsif (defined $ENV{TMP
}) {
144 die "ERROR - \"TMPDIR\" & \"TMP\" environment variables not set\n";
146 die "ERROR - \"$tmpdir\" doesn't exist\n" if ( ! -d
$tmpdir );
150 # convert windows only?
152 $filename =~ s/\\/\//g
;
154 $filebase = $filename;
155 $filebase =~ s/.*[\\\/]//;
156 $filebase =~ s/\..*?$//;
157 $workfile = "$tmpdir/${filebase}_".$$;
158 #$workfile =~ s/setup/set_up/;
160 # now get $workfile ready for shell usage...
161 $shell_workfile = $workfile;
163 print "workfile: $workfile\n" if $verbose;
165 #remove old objects which remained in place by a former bug
166 unlink "$workfile.obj";
168 # can't do this for modules with mixed case!
169 #$prjname =~ lc $prjname;
171 if ( -f
"$workfile.hid" )
173 unlink "$workfile.hid" or die "ERRROR - cannot remove $workfile.hid\n";;
176 # hack to quit for files which cannot be handled
177 if ( defined $ENV{"NO_HID_FILES"} ) {
178 foreach $fname ( split / /, $ENV{"NO_HID_FILES"} )
180 if ( $fname eq $filename )
182 print "No hid generation for $filename due to NO_HID_FILES\n";
183 print "Touching $srs/$filebase.hid anyways\n";
184 open TOUCH
, ">$srs/$filebase.hid" or die "ERRROR - cannot open $srs/$filebase.hid for writing\n";
191 #echo "perl5 -p -e "s/=[ \t]*\".*\"/=\"\"/go; s/\".*\"[ \t]*;/\"\" ;/go ; s/(\".*)\/\/(.*\")/$1\/\\\/$2/go ;" < %filename% > %srs%\%workfile%.c0"
192 #call perl5 -p -e "s/=[ \t]*\".*\"/=\"\"/go; s/\".*\"[ \t]*;/\"\" ;/go ; s/(\".*)\/\/(.*\")/$1\/\\\/$2/go ;" < %filename% > %srs%\%workfile%.c0
194 print "$ENV{SOLARBINDIR}/hidc $filename ${shell_workfile}.c1 $prjname \n";
195 $ret = system "$ENV{SOLARBINDIR}/hidc $filename ${shell_workfile}.c1 $prjname";
197 push @cleanuplist, ".c1";
198 cleandie
("ERROR - calling \"hidc\" failed");
200 push @cleanuplist, ".c1";
202 print "$compiler $solarincludes $defs $preprocess_flag ${shell_workfile}.c1 > ${shell_workfile}.c2\n";
203 $ret = system "$compiler $solarincludes $defs $preprocess_flag ${shell_workfile}.c1 > ${shell_workfile}.c2";
205 push @cleanuplist, ".c2";
206 cleandie
("ERROR - calling compiler for preprocessing failed");
208 push @cleanuplist, ".c2";
210 if (!open C_PROG
, ">$workfile.c") {
211 push @cleanuplist, ".c";
212 cleandie
("ERROR - open $workfile.c\n for writing failed");
214 push @cleanuplist, ".c";
215 print C_PROG
"#include <stdio.h>\n";
216 print C_PROG
"#include <wctype.h>\n";
218 if ( !open PRE
, "<$workfile.c2" ) {
219 cleandie
("ERROR - open $workfile.c2\n for reading failed");
230 if ( $InMain && !/^\s*$/ )
239 #cl %SOLARINCLUDES% %_srs%\%_workfile%.c /Fe%_srs%\%_workfile%$appext
240 my $outobj_param = "";
241 if ( $outobj_flag ne "" )
243 $outobj_param = "$outobj_flag${shell_workfile}$objext";
245 print "$compiler $solarincludes $defs ${shell_workfile}.c $outobj_param $outbin_flag${shell_workfile}$appext \n" if $verbose;
246 $ret = system "$compiler $solarincludes $defs ${shell_workfile}.c $outobj_param $outbin_flag${shell_workfile}$appext";
248 push @cleanuplist, "$appext";
249 cleandie
("ERROR - compiling $workfile.c failed");
251 push @cleanuplist, "$objext";
252 push @cleanuplist, "$appext";
254 #awk -f %ENV_TOOLS%\hidcode.awk < %srs%\%workfile%.c3 > %srs%\%workfile%.hid
255 if ( !open C3
,"$workfile$appext|" ) {
256 cleandie
("ERROR - executing $workfile$appext failed");
258 if ( !open HID
,">$srs/$filebase.hid.$ENV{INPATH}" ) {
259 cleandie
("ERROR - open $srs/$filebase.hid.$ENV{INPATH} for writing failed");
264 @fields = split /\s+/;
266 if ( $fields[1] eq "HelpID" )
268 print HID
"$fields[0] $fields[2]\n";
272 @arr = split /:/, $fields[0];
273 if( $arr[1] =~ /^leer$|^bitmap$|^font$|^color$|^image$|^imagelist$|^date$|^brush$|^fixedtext$|^keycode$|^time$|^mapmode$/i )
275 #print "skipping $arr[1]\n";
279 if ( $fields[1] eq "Norm" )
281 # Felder der Zeile auf Variable verteilen
282 $helpIDString = $fields[0];
283 $GClass = lc($fields[2]);
285 $LClass = lc($fields[4]);
286 $LID = $fields[5] || 0;
295 $VAL1 = 536870912; #2 hoch 29
296 if ( $GClass eq "workwindow" ) { $nHID= $VAL1 *5; }
297 elsif( $GClass eq "modelessdialog" ) { $nHID= $VAL1 *4; }
298 elsif( $GClass eq "floatingwindow" ) { $nHID= $VAL1 *3; }
299 elsif( $GClass eq "modaldialog" ) { $nHID= $VAL1 *2; }
300 elsif( $GClass eq "tabpage" ) { $nHID= $VAL1 *1; }
301 elsif( $GClass eq "dockingwindow" ) { $nHID= $VAL1 *6; }
302 #Maximal bis 7 dann sind 32Bit ausgeschoepft
305 $outline = "No GClass ".$helpIDString." ".$nHID." ".$GClass;
310 if ( $LClass eq "tabcontrol" ) { $nHID += 0; }
311 elsif( $LClass eq "radiobutton" ) { $nHID += 2*256; }
312 elsif( $LClass eq "checkbox" ) { $nHID += 4*256; }
313 elsif( $LClass eq "tristatebox" ) { $nHID += 6*256; }
314 elsif( $LClass eq "edit" ) { $nHID += 8*256; }
315 elsif( $LClass eq "multilineedit" ) { $nHID += 10*256; }
316 elsif( $LClass eq "multilistbox" ) { $nHID += 12*256; }
317 elsif( $LClass eq "listbox" ) { $nHID += 14*256; }
318 elsif( $LClass eq "combobox" ) { $nHID += 16*256; }
319 elsif( $LClass eq "pushbutton" ) { $nHID += 18*256; }
320 elsif( $LClass eq "spinfield" ) { $nHID += 20*256; }
321 elsif( $LClass eq "patternfield" ) { $nHID += 22*256; }
322 elsif( $LClass eq "numericfield" ) { $nHID += 24*256; }
323 elsif( $LClass eq "metricfield" ) { $nHID += 26*256; }
324 elsif( $LClass eq "currencyfield" ) { $nHID += 28*256; }
325 elsif( $LClass eq "datefield" ) { $nHID += 30*256; }
326 elsif( $LClass eq "timefield" ) { $nHID += 32*256; }
327 elsif( $LClass eq "imageradiobutton" ) { $nHID += 34*256; }
328 elsif( $LClass eq "numericbox" ) { $nHID += 36*256; }
329 elsif( $LClass eq "metricbox" ) { $nHID += 38*256; }
330 elsif( $LClass eq "currencybox" ) { $nHID += 40*256; }
331 elsif( $LClass eq "datebox" ) { $nHID += 42*256; }
332 elsif( $LClass eq "timebox" ) { $nHID += 44*256; }
333 elsif( $LClass eq "imagebutton" ) { $nHID += 46*256; }
334 elsif( $LClass eq "menubutton" ) { $nHID += 48*256; }
335 elsif( $LClass eq "morebutton" ) { $nHID += 50*256; }
338 $outline = "No LClass ".$helpIDString." ".$nHID;
343 #GID und LID auch beruecksichtigen
346 $nHID += $GID * 16384; #14 Bit nach links shiften
348 # check here and not above to avoid warnings for restypes not generated anyways
349 if( $GID == 0 || $GID >32767 || $LID > 511 )
352 print STDERR
"Invalid Global or Local ID: 0 < GID <= 32767 ; LID <= 511\n";
353 print STDERR
"$helpIDString GID = $GID; LID = $LID\n";
358 # 1. Stelle selber ausgeben, falls groesser als 2^21
359 # wg. problemen von awk/gawk bei printf mit %u
362 if( $nHID >= 4000000000 ) {
365 }elsif( $nHID >= 3000000000) {
368 }elsif( $nHID >= 2000000000) {
373 { printf HID
"%s %d%u \n",$helpIDString,$x, $nHID; }
375 { printf HID
"%s %u \n",$helpIDString, $nHID; }
382 rename("$srs/$filebase.hid.$ENV{INPATH}", "$srs/$filebase.hid") or cleandie
("ERROR - couldn't rename tmp file to final for $filebase");
385 foreach my $i (@cleanuplist) {
386 if ( -f
"$workfile$i" ) {
387 unlink "$workfile$i" or cleandie
("");