summaryrefslogtreecommitdiff
path: root/oox/source/token/genproperties.pl
blob: 9dbe15c8ac127578d518229f9c1c9195c3ca19f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$ARGV0 = shift @ARGV;
$ARGV1 = shift @ARGV;
$ARGV2 = shift @ARGV;

open ( PROPS, $ARGV0 ) || die "can't open properties source file: $!";
my %props;

while ( <PROPS> )
{
    chomp( $_ );
    $_ =~ s/\s*//g;
    $_ =~ /^[A-Z][a-zA-Z0-9]*$/ or die "invalid character in property '$_'";
    $id = "PROP_$_";
    $props{$_} = $id;
}
close ( TOKENS );

open ( HXX, ">$ARGV1" ) or die "can't open properties.hxx file: $!";
open ( WORDS, ">$ARGV2" ) or die "can't open propertynames.inc file: $!";

print ( HXX "#ifndef OOX_PROPERTIES_HXX\n" );
print ( HXX "#define OOX_PROPERTIES_HXX\n\n" );
print ( HXX "#include <sal/types.h>\n" );
print ( HXX "namespace oox {\n\n" );

print ( WORDS "static const sal_Char* propertywordlist[] = {\n" );

$i = 0;
foreach( sort( keys( %props ) ) )
{
    print ( HXX "const sal_Int32 $props{$_} = $i;\n" );
    print ( WORDS "    \"$_\",\n" );
    ++$i;
}

print ( HXX "const sal_Int32 PROP_COUNT = $i;\n" );
print ( HXX "const sal_Int32 PROP_INVALID = -1;\n\n" );
print ( HXX "} // namespace oox\n" );
print ( HXX "#endif\n" );

print ( WORDS "    \"\"\n" );
print ( WORDS "};\n" );

close ( HXX );
close ( WORDS );