summaryrefslogtreecommitdiffstats
path: root/oox/source/drawingml/customshapes/generatePresetsData.pl
blob: 99b2ff153036fb039a91f8a8a42cead3620afcee (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env perl
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

sub loadData()
{
    open (IN, "<custom-shapes.log");

    my %sources;

    while (<IN>)
    {
        if (/==csdata== /)
        {
            if (/shape name: '/)
            {
                chop;
                s/.*shape name: '([^']+)'.*/$1/;
                $name = $_;
            }
            else
            {
                if (/==csdata== begin/)
                {
                    $inside = true;
                    @code = ();
                }
                else
                {
                    if (/==csdata== end/)
                    {
                        s/^  <\/([^>]+)>/$1/;
                        undef $inside;
                        $sources{$name} = [ @code ];
                    }
                }
            }
        }
        else
        {
            if ($inside)
            {
                push @code, $_;
            }
        }
    }

    close (IN);

    return \%sources;
}

sub generateData
{
    my $sources = shift;
    open (OUT, ">oox-drawingml-cs-presets");

    foreach $shape (sort(keys %$sources))
    {
        printf OUT "/* %s */\n", $shape;
        print OUT @{$sources->{$shape}};
    }

    close OUT;
}

generateData(loadData());

# vim:set ft=perl shiftwidth=4 softtabstop=4 expandtab: #