xref: /aoo41x/main/sysui/desktop/share/brand.pl (revision cdf0e10c)
1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3    if 0;
4
5#*************************************************************************
6#
7# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8#
9# Copyright 2000, 2010 Oracle and/or its affiliates.
10#
11# OpenOffice.org - a multi-platform office productivity suite
12#
13# This file is part of OpenOffice.org.
14#
15# OpenOffice.org is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Lesser General Public License version 3
17# only, as published by the Free Software Foundation.
18#
19# OpenOffice.org is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22# GNU Lesser General Public License version 3 for more details
23# (a copy is included in the LICENSE file that accompanied this code).
24#
25# You should have received a copy of the GNU Lesser General Public License
26# version 3 along with OpenOffice.org.  If not, see
27# <http://www.openoffice.org/license.html>
28# for a copy of the LGPLv3 License.
29#
30#*************************************************************************
31
32
33#*********************************************************************
34#
35# main
36#
37
38$destdir = pop @ARGV;
39mkdir $destdir,0777;
40
41$productname = "OpenOffice.org";
42$productfilename = "openoffice";
43$prefix = "";
44$iconprefix = "";
45
46while ($_ = $ARGV[0], /^-/) {
47    shift;
48    last if /^--$/;
49    if (/^-p/) {
50        $productname = $ARGV[0];
51        shift;
52    }
53    if (/^-u/) {
54        $productfilename = $ARGV[0];
55        shift;
56    }
57    if (/^--prefix/) {
58        $prefix = $ARGV[0];
59        shift;
60    }
61    if (/^--iconprefix/) {
62        $iconprefix = $ARGV[0];
63        shift;
64    }
65    if (/^--category/) {
66        $category = $ARGV[0];
67        shift;
68    }
69}
70
71
72while (<>) {
73    unless (open INFILE,$ARGV) {
74        print STDOUT "Can't open input file $ARGV: $!\n";
75        exit 1;
76    }
77
78    $srcfile = substr($ARGV, rindex($ARGV, "/") + 1);
79
80    unless (open OUTFILE,"> $destdir/$prefix$srcfile") {
81        print STDOUT "Can't open output file $destdir/$prefix$srcfile: $!\n";
82        exit 1;
83    }
84
85    while (<INFILE>) {
86        # remove possible Windows line-ends
87        chomp;
88
89        # patch all occurances of openoffice in ICON line with
90        # $prefix
91        s/Icon=/Icon=$iconprefix/;
92
93        # patch all occurances of openoffice in icon_filename
94        # line with $prefix
95        s/icon_filename=/icon_filename=$iconprefix/;
96
97        # patch all occurances of openoffice in EXEC line with
98        # $productfilename
99        if ( /Exec/ ) {
100            s/openoffice/$productfilename/;
101        }
102
103        # if $productfilename != "openoffice, add it to the list
104        # of applications.
105        if ( /user_level=$/ ) {
106		    $_ = $_ . $productfilename;
107		} elsif ( /user_level/ ) {
108            s/$productfilename,//;
109            s/user_level=/user_level=$productfilename,/
110        }
111
112        # append special category if specified
113        if ( /Categories/ ) {
114            if ( length($category) > 0 ) {
115                $_ = "$_$category;";
116            }
117        }
118
119        # replace %PRODUCTNAME placeholders
120        s/%PRODUCTNAME/$productname/g;
121
122        print OUTFILE "$_\n";
123    }
124
125    close(OUTFILE);
126    close(INFILE);
127}
128