3 $basedir = dirname
($0);
4 $productname = 'OpenOffice.org';
5 $mimedir = $basedir.'/../mimetypes';
7 $FS= ' '; # field seperator (space) - for documents.ulf
8 $, = "\n"; # set output field separator (newline)
9 $\
= "\n"; # set output record separator (newline)
11 ## get list of components and corresponding translations from documents.ulf
12 open(DOCUMENTS_ULF
, $ARGV[0]) || die 'Cannot open "documents.ulf".';
13 while (<DOCUMENTS_ULF
>) {
21 ($lang,$junk,$comment) = split($FS, $_, 3);
22 $comment =~ s/^"(.*)"$/$1/;
23 $comment =~ s/%PRODUCTNAME/$productname/;
26 if ($lang eq "en-US") {
27 $value = " <comment>$comment</comment>";
29 $value = ' <comment xml:lang="'.$lang.'">'.$comment.'</comment>';
31 push(@
{$mimehash{$module}}, $value) unless $lang eq "";
36 ## creating the xml on stdout
37 print '<?xml version="1.0" encoding="UTF-8"?>';
38 print '<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">';
40 foreach $component (sort(keys %mimehash)) {
41 print STDERR
"Processing entries for $component";
43 getMimedata
($component);
44 print ' <mime-type type="'.$mimetype.'">';
45 print (sort({customsort
($a) cmp customsort
($b)} @
{$mimehash{$component}}));
46 print ' <glob pattern="'.$glob.'"/>';
47 if ( $component =~ /oasis/ ) {
48 print ' <magic'.( $mimetype =~ /-/ ?
' priority="60"' : '').'>';
49 print ' <match type="string" offset="38" value="'.$mimetype.'"/>';
52 print ' </mime-type>';
57 # sort <comment> before <comment xml:lang...>
64 ## get mime-type and glob from ../mimetype/*.desktop
66 $desktop_name = shift;
67 $desktop_file = $mimedir.'/'.$desktop_name.'.desktop';
70 open(DESKTOP_FILE
, $desktop_file) || die 'Cannot open "desktop"-file.'.$!;
71 while (<DESKTOP_FILE
>) {
74 s/^MimeType=(.*)\n$/$1/;
79 s/^Patterns=(.*)\n$/\1/;
84 # die if we cannot determine the glob-pattern or mimtetype
85 die "Could not get mime-type fom $desktop_file" if ($mimetype eq "");
86 die "Could not get glob-pattern fom $desktop_file" if ($glob eq "");