merge the formfield patch from ooo-build
[ooovba.git] / oox / source / token / genproperties.pl
blob9dbe15c8ac127578d518229f9c1c9195c3ca19f9
1 $ARGV0 = shift @ARGV;
2 $ARGV1 = shift @ARGV;
3 $ARGV2 = shift @ARGV;
5 open ( PROPS, $ARGV0 ) || die "can't open properties source file: $!";
6 my %props;
8 while ( <PROPS> )
10 chomp( $_ );
11 $_ =~ s/\s*//g;
12 $_ =~ /^[A-Z][a-zA-Z0-9]*$/ or die "invalid character in property '$_'";
13 $id = "PROP_$_";
14 $props{$_} = $id;
16 close ( TOKENS );
18 open ( HXX, ">$ARGV1" ) or die "can't open properties.hxx file: $!";
19 open ( WORDS, ">$ARGV2" ) or die "can't open propertynames.inc file: $!";
21 print ( HXX "#ifndef OOX_PROPERTIES_HXX\n" );
22 print ( HXX "#define OOX_PROPERTIES_HXX\n\n" );
23 print ( HXX "#include <sal/types.h>\n" );
24 print ( HXX "namespace oox {\n\n" );
26 print ( WORDS "static const sal_Char* propertywordlist[] = {\n" );
28 $i = 0;
29 foreach( sort( keys( %props ) ) )
31 print ( HXX "const sal_Int32 $props{$_} = $i;\n" );
32 print ( WORDS " \"$_\",\n" );
33 ++$i;
36 print ( HXX "const sal_Int32 PROP_COUNT = $i;\n" );
37 print ( HXX "const sal_Int32 PROP_INVALID = -1;\n\n" );
38 print ( HXX "} // namespace oox\n" );
39 print ( HXX "#endif\n" );
41 print ( WORDS " \"\"\n" );
42 print ( WORDS "};\n" );
44 close ( HXX );
45 close ( WORDS );