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 #*************************************************************************
47 # variables to setup the compiler line
53 my $preprocess_flag; # preprocess to stdout
59 my $errstring = shift @_;
62 print STDERR
"$errstring\n";
64 foreach my $i (@cleanuplist) {
65 unlink "$workfile$i" if -f
"$workfile$i" or print STDERR
"ERROR - couldn't remove $workfile$i\n";
73 my $whichcom = $ENV{COM
};
74 my $extra_cflags = $ENV{EXTRA_CFLAGS
};
75 $extra_cflags = "" if (!$extra_cflags);
76 if ( "$whichcom" eq "GCC" ) {
77 $appext = ""; # windows for now
78 $compiler = "gcc -x c $extra_cflags";
82 $preprocess_flag = "-E"; # preprocess to stdout
83 } elsif ( "$whichcom" eq "MSC" ) {
84 $appext = ".exe"; # windows for now
89 $preprocess_flag = "-EP"; # preprocess to stdout
90 } elsif ( "$whichcom" eq "C52" ) {
91 $appext = ""; # windows for now
96 $preprocess_flag = "-E"; # preprocess to stdout
98 # hack for SO cc wrapper
99 $ENV{wrapper_override_cc_wrapper
} = "TRUE";
100 $solarincludes =~ s/stl/xstlx/g;
101 $defs =~ s/\/stl/\
/xstlx/g;
103 print STDERR
"----------------------------------------------------------------------\n";
104 print STDERR
"OOops... looks like your compiler isn't known to \n$0\n";
105 print STDERR
"please edit the \"setcompiler\" section of this script to make it work.\n";
106 print STDERR
"----------------------------------------------------------------------\n";
107 die "ERROR - compiler (or \$COM settings) unknown!\n";
111 #---------------------------------------------------
112 $filename = shift @ARGV;
114 $prjname = shift @ARGV;
115 $defs = join " ",@ARGV if ($#ARGV);
117 if ( !defined $prjname ) { die "ERROR - check usage\n"; }
119 if ( $ENV{NO_HID_FILES
} ) {
120 $no_hid_files = $ENV{"NO_HID_FILES"};
122 $solarincludes = $ENV{SOLARINCLUDES
};
123 if (defined $ENV{TMPDIR
}) {
124 $tmpdir = $ENV{TMPDIR
};
125 } elsif (defined $ENV{TMP
}) {
128 die "ERROR - \"TMPDIR\" & \"TMP\" environment variables not set\n";
130 die "ERROR - \"$tmpdir\" doesn't exist\n" if ( ! -d
$tmpdir );
134 # convert windows only?
136 $filename =~ s/\\/\//g
;
138 $filebase = $filename;
139 $filebase =~ s/.*[\\\/]//;
140 $filebase =~ s/\..*?$//;
141 $workfile = "$tmpdir/${filebase}_".$$;
142 #$workfile =~ s/setup/set_up/;
144 # now get $workfile ready for shell usage...
145 $shell_workfile = $workfile;
147 print "workfile: $workfile\n";
149 #remove old objects which remained in place by a former bug
150 unlink "$workfile.obj";
152 # can't do this for modules with mixed case!
153 #$prjname =~ lc $prjname;
155 if ( -f
"$workfile.hid" )
157 unlink "$workfile.hid" or die "ERRROR - cannot remove $workfile.hid\n";;
160 # hack to quit for files which cannot be handled
161 if ( defined $ENV{"NO_HID_FILES"} ) {
162 foreach $fname ( split / /, $ENV{"NO_HID_FILES"} )
164 if ( $fname eq $filename )
166 print "No hid generation for $filename due to NO_HID_FILES\n";
167 print "Touching $srs/$filebase.hid anyways\n";
168 open TOUCH
, ">$srs/$filebase.hid" or die "ERRROR - cannot open $srs/$filebase.hid for writing\n";
175 #echo "perl5 -p -e "s/=[ \t]*\".*\"/=\"\"/go; s/\".*\"[ \t]*;/\"\" ;/go ; s/(\".*)\/\/(.*\")/$1\/\\\/$2/go ;" < %filename% > %srs%\%workfile%.c0"
176 #call perl5 -p -e "s/=[ \t]*\".*\"/=\"\"/go; s/\".*\"[ \t]*;/\"\" ;/go ; s/(\".*)\/\/(.*\")/$1\/\\\/$2/go ;" < %filename% > %srs%\%workfile%.c0
178 print "$ENV{SOLARBINDIR}/hidc $filename ${shell_workfile}.c1 $prjname \n";
179 $ret = system "$ENV{SOLARBINDIR}/hidc $filename ${shell_workfile}.c1 $prjname";
181 push @cleanuplist, ".c1";
182 cleandie
("ERROR - calling \"hidc\" failed");
184 push @cleanuplist, ".c1";
186 print "$compiler $solarincludes $defs $preprocess_flag ${shell_workfile}.c1 > ${shell_workfile}.c2\n";
187 $ret = system "$compiler $solarincludes $defs $preprocess_flag ${shell_workfile}.c1 > ${shell_workfile}.c2";
189 push @cleanuplist, ".c2";
190 cleandie
("ERROR - calling compiler for preprocessing failed");
192 push @cleanuplist, ".c2";
194 if (!open C_PROG
, ">$workfile.c") {
195 push @cleanuplist, ".c";
196 cleandie
("ERROR - open $workfile.c\n for writing failed");
198 push @cleanuplist, ".c";
199 print C_PROG
"#include <stdio.h>\n";
200 print C_PROG
"#include <wctype.h>\n";
202 if ( !open PRE
, "<$workfile.c2" ) {
203 cleandie
("ERROR - open $workfile.c2\n for reading failed");
214 if ( $InMain && !/^\s*$/ )
223 #cl %SOLARINCLUDES% %_srs%\%_workfile%.c /Fe%_srs%\%_workfile%$appext
224 my $outobj_param = "";
225 if ( $outobj_flag ne "" )
227 $outobj_param = "$outobj_flag${shell_workfile}$objext";
229 print "$compiler $solarincludes $defs ${shell_workfile}.c $outobj_param $outbin_flag${shell_workfile}$appext \n";
230 $ret = system "$compiler $solarincludes $defs ${shell_workfile}.c $outobj_param $outbin_flag${shell_workfile}$appext";
232 push @cleanuplist, "$appext";
233 cleandie
("ERROR - compiling $workfile.c failed");
235 push @cleanuplist, "$objext";
236 push @cleanuplist, "$appext";
238 #awk -f %ENV_TOOLS%\hidcode.awk < %srs%\%workfile%.c3 > %srs%\%workfile%.hid
239 if ( !open C3
,"$workfile$appext|" ) {
240 cleandie
("ERROR - executing $workfile$appext failed");
242 if ( !open HID
,">$srs/$filebase.hid.$ENV{INPATH}" ) {
243 cleandie
("ERROR - open $srs/$filebase.hid.$ENV{INPATH} for writing failed");
248 @fields = split /\s+/;
250 if ( $fields[1] eq "HelpID" )
252 print HID
"$fields[0] $fields[2]\n";
256 @arr = split /:/, $fields[0];
257 if( $arr[1] =~ /^leer$|^bitmap$|^font$|^color$|^image$|^imagelist$|^date$|^brush$|^fixedtext$|^keycode$|^time$|^mapmode$/i )
259 #print "skipping $arr[1]\n";
263 if ( $fields[1] eq "Norm" )
265 # Felder der Zeile auf Variable verteilen
266 $helpIDString = $fields[0];
267 $GClass = lc($fields[2]);
269 $LClass = lc($fields[4]);
270 $LID = $fields[5] || 0;
279 $VAL1 = 536870912; #2 hoch 29
280 if ( $GClass eq "workwindow" ) { $nHID= $VAL1 *5; }
281 elsif( $GClass eq "modelessdialog" ) { $nHID= $VAL1 *4; }
282 elsif( $GClass eq "floatingwindow" ) { $nHID= $VAL1 *3; }
283 elsif( $GClass eq "modaldialog" ) { $nHID= $VAL1 *2; }
284 elsif( $GClass eq "tabpage" ) { $nHID= $VAL1 *1; }
285 elsif( $GClass eq "dockingwindow" ) { $nHID= $VAL1 *6; }
286 #Maximal bis 7 dann sind 32Bit ausgeschoepft
289 $outline = "No GClass ".$helpIDString." ".$nHID." ".$GClass;
294 if ( $LClass eq "tabcontrol" ) { $nHID += 0; }
295 elsif( $LClass eq "radiobutton" ) { $nHID += 2*256; }
296 elsif( $LClass eq "checkbox" ) { $nHID += 4*256; }
297 elsif( $LClass eq "tristatebox" ) { $nHID += 6*256; }
298 elsif( $LClass eq "edit" ) { $nHID += 8*256; }
299 elsif( $LClass eq "multilineedit" ) { $nHID += 10*256; }
300 elsif( $LClass eq "multilistbox" ) { $nHID += 12*256; }
301 elsif( $LClass eq "listbox" ) { $nHID += 14*256; }
302 elsif( $LClass eq "combobox" ) { $nHID += 16*256; }
303 elsif( $LClass eq "pushbutton" ) { $nHID += 18*256; }
304 elsif( $LClass eq "spinfield" ) { $nHID += 20*256; }
305 elsif( $LClass eq "patternfield" ) { $nHID += 22*256; }
306 elsif( $LClass eq "numericfield" ) { $nHID += 24*256; }
307 elsif( $LClass eq "metricfield" ) { $nHID += 26*256; }
308 elsif( $LClass eq "currencyfield" ) { $nHID += 28*256; }
309 elsif( $LClass eq "datefield" ) { $nHID += 30*256; }
310 elsif( $LClass eq "timefield" ) { $nHID += 32*256; }
311 elsif( $LClass eq "imageradiobutton" ) { $nHID += 34*256; }
312 elsif( $LClass eq "numericbox" ) { $nHID += 36*256; }
313 elsif( $LClass eq "metricbox" ) { $nHID += 38*256; }
314 elsif( $LClass eq "currencybox" ) { $nHID += 40*256; }
315 elsif( $LClass eq "datebox" ) { $nHID += 42*256; }
316 elsif( $LClass eq "timebox" ) { $nHID += 44*256; }
317 elsif( $LClass eq "imagebutton" ) { $nHID += 46*256; }
318 elsif( $LClass eq "menubutton" ) { $nHID += 48*256; }
319 elsif( $LClass eq "morebutton" ) { $nHID += 50*256; }
322 $outline = "No LClass ".$helpIDString." ".$nHID;
327 #GID und LID auch beruecksichtigen
330 $nHID += $GID * 16384; #14 Bit nach links shiften
332 # check here and not above to avoid warnings for restypes not generated anyways
333 if( $GID == 0 || $GID >32767 || $LID > 511 )
336 print STDERR
"Invalid Global or Local ID: 0 < GID <= 32767 ; LID <= 511\n";
337 print STDERR
"$helpIDString GID = $GID; LID = $LID\n";
342 # 1. Stelle selber ausgeben, falls groesser als 2^21
343 # wg. problemen von awk/gawk bei printf mit %u
346 if( $nHID >= 4000000000 ) {
349 }elsif( $nHID >= 3000000000) {
352 }elsif( $nHID >= 2000000000) {
357 { printf HID
"%s %d%u \n",$helpIDString,$x, $nHID; }
359 { printf HID
"%s %u \n",$helpIDString, $nHID; }
366 rename("$srs/$filebase.hid.$ENV{INPATH}", "$srs/$filebase.hid") or cleandie
("ERROR - couldn't rename tmp file to final for $filebase");
369 foreach my $i (@cleanuplist) {
370 if ( -f
"$workfile$i" ) {
371 unlink "$workfile$i" or cleandie
("");