Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / sysui / desktop / share / brand.pl
blobae2911be9ed0f3eda8f6e1e46b7c94163b2845b3
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
6 # This file is part of the LibreOffice project.
8 # This Source Code Form is subject to the terms of the Mozilla Public
9 # License, v. 2.0. If a copy of the MPL was not distributed with this
10 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 # This file incorporates work covered by the following license notice:
14 # Licensed to the Apache Software Foundation (ASF) under one or more
15 # contributor license agreements. See the NOTICE file distributed
16 # with this work for additional information regarding copyright
17 # ownership. The ASF licenses this file to you under the Apache
18 # License, Version 2.0 (the "License"); you may not use this file
19 # except in compliance with the License. You may obtain a copy of
20 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
24 # This tool is used to re-write and substitute variables
25 # into Unix .desktop, mimelnk, .keys files etc.
28 $destdir = pop @ARGV;
29 mkdir $destdir,0777;
31 $productname = "LibreOffice";
32 $productfilename = "libreoffice";
33 $urls = 0;
34 $prefix = "";
35 $iconprefix = "";
37 while ($_ = $ARGV[0], /^-/) {
38 shift;
39 last if /^--$/;
40 if (/^-p/) {
41 $productname = $ARGV[0];
42 shift;
44 if (/^-u/) {
45 $productfilename = $ARGV[0];
46 shift;
48 if (/^--prefix/) {
49 $prefix = $ARGV[0];
50 shift;
52 if (/^--iconprefix/) {
53 $iconprefix = $ARGV[0];
54 shift;
56 if (/^--category/) {
57 $category = $ARGV[0];
58 shift;
60 # Whether we can handle URLs on the command-line
61 if (/^--urls/) {
62 $urls = 1;
67 while (<>) {
68 unless (open INFILE,$ARGV) {
69 print STDOUT "Can't open input file $ARGV: $!\n";
70 exit 1;
73 $srcfile = substr($ARGV, rindex($ARGV, "/") + 1);
75 unless (open OUTFILE,"> $destdir/$prefix$srcfile") {
76 print STDOUT "Can't open output file $destdir/$prefix$srcfile: $!\n";
77 exit 1;
80 while (<INFILE>) {
81 # remove possible Windows line-ends
82 chomp;
84 # patch all occurrences of openoffice in ICON line with
85 # $prefix
86 s/Icon=/Icon=$iconprefix/;
88 # patch all occurrences of openoffice in icon_filename
89 # line with $prefix
90 s/icon_filename=/icon_filename=$iconprefix/;
92 # patch all occurrences of openoffice in EXEC line with
93 # $productfilename
94 if ( /Exec/ ) {
95 s/openoffice/$productfilename/;
98 # if $productfilename != "openoffice, add it to the list
99 # of applications.
100 if ( /user_level=$/ ) {
101 $_ = $_ . $productfilename;
102 } elsif ( /user_level/ ) {
103 s/$productfilename,//;
104 s/user_level=/user_level=$productfilename,/
107 # append special category if specified
108 if ( /Categories/ ) {
109 if ( length($category) > 0 ) {
110 $_ = "$_$category;";
114 # replace %PRODUCTNAME placeholders
115 s/%PRODUCTNAME/$productname/g;
117 if ( $urls ) {
118 s/%%FILE%%/%U/g;
119 } else {
120 s/%%FILE%%/%F/g;
123 print OUTFILE "$_\n";
126 close(OUTFILE);
127 close(INFILE);