1:
2    eval 'exec perl -S $0 ${1+"$@"}'
3        if 0;
4#*************************************************************************
5#
6# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7#
8# Copyright 2000, 2010 Oracle and/or its affiliates.
9#
10# OpenOffice.org - a multi-platform office productivity suite
11#
12# This file is part of OpenOffice.org.
13#
14# OpenOffice.org is free software: you can redistribute it and/or modify
15# it under the terms of the GNU Lesser General Public License version 3
16# only, as published by the Free Software Foundation.
17#
18# OpenOffice.org is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21# GNU Lesser General Public License version 3 for more details
22# (a copy is included in the LICENSE file that accompanied this code).
23#
24# You should have received a copy of the GNU Lesser General Public License
25# version 3 along with OpenOffice.org.  If not, see
26# <http://www.openoffice.org/license.html>
27# for a copy of the LGPLv3 License.
28#
29#*************************************************************************
30#
31# Create ordinary theme from HiContrast images.
32#
33
34use File::Copy;
35use File::Find;
36use File::Path;
37use File::Spec;
38
39( $src, $dst ) = @ARGV;
40
41if ( $src eq "" || $dst eq "" ) {
42    print STDERR "Usage: hicontrast-to-theme.pl src dest\n\n";
43    print STDERR "Create ordinary theme from HiContrast images.\n";
44    exit 1;
45}
46
47$dst = File::Spec->rel2abs( $dst );
48
49@hc_table = (
50    [ ".*_h.png",         "_h.png",    ".png" ],
51    [ ".*_sch.png",       "_sch.png",  ".png" ],
52    [ ".*_hc.png",        "_hc.png",   ".png" ],
53    [ "lch_.*.png",       "lch_",      "lc_" ],
54    [ "sch_.*.png",       "sch_",      "sc_" ],
55    [ "lch[0-9].*.png",   "lch",       "lc" ],
56    [ "sch[0-9].*.png",   "sch",       "sc" ],
57    [ "loh[0-9].*.png",   "loh",       "lo" ],
58    [ "lxh[0-9].*.png",   "lxh",       "lx" ],
59    [ "sxh[0-9].*.png",   "sxh",       "sx" ],
60    [ "avh[0-9].*.png",   "avh",       "av" ],
61    [ "avlh[0-9].*.png",  "avlh",      "avl" ],
62    [ "idh[0-9].*.png",   "idh",       "id" ],
63    [ "imh[0-9].*.png",   "imh",       "im" ],
64    [ "mih[0-9].*.png",   "mih",       "mi" ],
65    [ "tbh[0-9].*.png",   "tbh",       "tb" ],
66    [ "nah[0-9].*.png",   "nah",       "na" ],
67    [ "nch[0-9].*.png",   "nch",       "nc" ],
68    [ "nvh[0-9].*.png",   "nvh",       "nv" ],
69    [ "ouh[0-9].*.png",   "ouh",       "ou" ],
70    [ "ddh[0-9].*.png",   "ddh",       "dd" ],
71    [ "sfh[0-9].*.png",   "sfh",       "sf" ],
72    [ "srh[0-9].*.png",   "srh",       "sr" ],
73    [ "wrh[0-9].*.png",   "wrh",       "wr" ],
74    [ "alh[0-9].*.png",   "alh",       "al" ],
75    [ "ath[0-9].*.png",   "ath",       "at" ],
76    [ "bih[0-9].*.png",   "bih",       "bi" ],
77    [ "coh[0-9].*.png",   "coh",       "co" ],
78    [ "foh[0-9].*.png",   "foh",       "fo" ],
79    [ "fuh[0-9].*.png",   "fuh",       "fu" ],
80    [ "oph[0-9].*.png",   "oph",       "op" ],
81    [ "unh[0-9].*.png",   "unh",       "un" ],
82    [ "edh[0-9].*.png",   "edh",       "ed" ],
83    [ "cdh[0-9].*.png",   "cdh",       "cd" ],
84    [ "frh[0-9].*.png",   "frh",       "fr" ],
85    [ "fwh[0-9].*.png",   "fwh",       "fw" ],
86    [ "nuh[0-9].*.png",   "nuh",       "nu" ],
87    [ "prh[0-9].*.png",   "prh",       "pr" ],
88    [ "shh[0-9].*.png",   "shh",       "sh" ],
89    [ "trh[0-9].*.png",   "trh",       "tr" ],
90    [ "reh[0-9].*.png",   "reh",       "re" ],
91    [ "joh[0-9].*.png",   "joh",       "jo" ],
92    [ "fph[0-9].*.png",   "fph",       "fp" ],
93    [ "dah[0-9].*.png",   "dah",       "da" ]
94);
95
96my (@from_stat, @to_stat);
97
98sub copy_normalized {
99    $file = $_;
100    for $hc ( @hc_table ) {
101        ( $what, $from, $to ) = @$hc;
102        if ( $file =~ /$what/&&!($file=~/\.svn/) ) {
103            my $dir = File::Spec->catdir( $dst, $File::Find::dir );
104
105            if ( ! -d $dir ) {
106                mkpath( $dir );
107            }
108
109            ( my $copy = $file ) =~ s/$from/$to/;
110            $copy = File::Spec->catfile( $dir, $copy );
111
112	        @from_stat = stat($file);
113	        @to_stat = stat($copy);
114			if ( $from_stat[9] > $to_stat[9] ) {
115	            copy( $file, $copy ) || die $!;
116				utime( $from_stat[9], $from_stat[9], $copy );
117			}
118
119            last;
120        }
121    }
122}
123
124chdir( $src );
125find( \&copy_normalized, '.' );
126