Update ooo320-m1
[ooovba.git] / filter / source / svg / gentoken.pl
blob124457f3692f9639fcb3599768e1d5e2196673aa
1 # from oox/source/token - should really put this into solenv
3 $ARGV0 = shift @ARGV;
4 $ARGV1 = shift @ARGV;
5 $ARGV2 = shift @ARGV;
7 open ( TOKENS, $ARGV0 ) || die "can't open token file: $!";
8 my %tokens;
10 while ( defined ($line = <TOKENS>) )
12 if( !($line =~ /^#/) )
14 chomp($line);
15 @token = split(/\s+/,$line);
16 if ( not defined ($token[1]) )
18 $token[1] = "XML_".$token[0];
19 $token[1] =~ tr/\-\.\:/___/;
20 $token[1] =~ s/\+/PLUS/g;
21 $token[1] =~ s/\-/MINUS/g;
24 $tokens{$token[0]} = uc($token[1]);
27 close ( TOKENS );
29 open ( HXX, ">$ARGV1" ) || die "can't open tokens.hxx file: $!";
30 open ( GPERF, ">$ARGV2" ) || die "can't open tokens.gperf file: $!";
32 print ( GPERF "%language=C++\n" );
33 print ( GPERF "%global-table\n" );
34 print ( GPERF "%null-strings\n" );
35 print ( GPERF "%struct-type\n" );
36 print ( GPERF "struct xmltoken\n" );
37 print ( GPERF "{\n" );
38 print ( GPERF " const sal_Char *name; sal_Int32 nToken; \n" );
39 print ( GPERF "};\n" );
40 print ( GPERF "%%\n" );
42 print ( HXX "#ifndef INCLUDED_AUTOGEN_TOKEN_HXX\n" );
43 print ( HXX "#define INCLUDED_AUTOGEN_TOKEN_HXX\n\n" );
44 print ( HXX "#include <sal/types.h>\n\n" );
46 $i = 0;
47 foreach( sort(keys(%tokens)) )
49 print( HXX "const sal_Int32 $tokens{$_} = $i;\n" );
50 print( GPERF "$_,$tokens{$_}\n" );
51 $i = $i + 1;
53 print ( GPERF "%%\n" );
54 print ( HXX "const sal_Int32 XML_TOKEN_COUNT = $i;\n" );
55 print ( HXX "const sal_Int32 XML_TOKEN_INVALID = -1;\n\n" );
56 print ( HXX "#endif\n" );
57 close ( HXX );
58 close ( GPERF );