2 # -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil -*-
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # This file incorporates work covered by the following license notice:
12 # Licensed to the Apache Software Foundation (ASF) under one or more
13 # contributor license agreements. See the NOTICE file distributed
14 # with this work for additional information regarding copyright
15 # ownership. The ASF licenses this file to you under the Apache
16 # License, Version 2.0 (the "License"); you may not use this file
17 # except in compliance with the License. You may obtain a copy of
18 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
30 if (! -e
"$base_path/$fname") {
31 print "Skipping non-existent $base_path/$fname\n";
34 open ($fileh, "$base_path/$fname") || die "Can't open $base_path/$fname: $!";
36 m/xlink:href=\"\.uno:(\S+)\"\s+/ || next;
44 # filter out already seen icons & do prefixing
45 sub read_new_icons
($$)
49 my @images = read_icons
($fname);
52 for my $icon (@images) {
53 my $iname = "cmd/" . $prefix . $icon . ".png";
54 if (!defined $global_hash{$iname} &&
55 !defined $new_icons{$iname}) {
56 push @new_icons, $iname;
57 $new_icons{$iname} = 1;
70 # a very noddy sorting algorithm
71 for my $uiconfig (@uiconfigs) {
72 my @images = read_new_icons
($uiconfig, $prefix);
74 for my $icon (@images) {
75 if (!defined $group{$icon}) {
76 if (!defined $group{$prev}) {
77 $group{$icon} = $cur_max;
80 $group{$icon} = $group{$prev} + (1.0 - 0.5 / $cur_max);
85 for my $icon (sort { $group{$a} <=> $group{$b} } keys %group) {
86 push @global_list, $icon;
87 $global_hash{$icon} = 1;
93 my @images = read_new_icons
(shift, shift);
95 for my $icon (@images) {
96 push @global_list, $icon;
97 $global_hash{$icon} = 1;
101 sub chew_controlfile
($)
106 open ($fileh, $fname) || die "Can't open $fname: $!";
113 if ($line =~ s/^-- (\S+)\s*//) {
116 my $small = (lc ($line) eq 'small');
117 if (lc($code) eq 'group') {
119 process_group
("lc_", @list);
121 process_group
("sc_", @list);
122 } elsif (lc ($code) eq 'ordered') {
124 for my $file (@list) {
125 process_file
($file, "lc_");
128 for my $file (@list) {
129 process_file
($file, "sc_");
131 } elsif (lc ($code) eq 'literal') {
132 for my $file (@list) {
133 if (!defined $global_hash{$file}) {
134 push @global_list, $file;
135 $global_hash{$file} = 1;
139 die ("Unknown code '$code'");
150 print "image-sort <image-sort.lst> /path/to/OOOo/source/root\n";
154 # where the control file lives
155 my $control = shift @ARGV;
156 # where the uiconfigs live
157 $base_path = shift @ARGV;
160 my $outf = shift @ARGV;
161 open ($output, ">$outf") || die "Can't open $outf: $!";
168 chew_controlfile
($control);
170 for my $icon (@global_list) {
171 print $output $icon . "\n" if (!($icon =~ /^sc_/));
173 for my $icon (@global_list) {
174 print $output $icon . "\n" if ($icon =~ /^sc_/);
177 close $output if (!$stdout_out);
179 # dnl vim:set shiftwidth=4 softtabstop=4 expandtab: