Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/sysui/desktop/share/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 4 kB image not shown  

Quelle  create_mime_xml.pl   Sprache: Shell

 
#!/usr/bin/env perl
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
#   Licensed to the Apache Software Foundation (ASF) under one or more
#   contributor license agreements. See the NOTICE file distributed
#   with this work for additional information regarding copyright
#   ownership. The ASF licenses this file to you under the Apache
#   License, Version 2.0 (the "License"); you may not use this file
#   except in compliance with the License. You may obtain a copy of
#   the License at http://www.apache.org/licenses/LICENSE-2.0 .
#

use File::Basename;
$basedir = dirname($0);
$productname = 'LibreOffice';
$mimedir = $basedir.'/../mimetypes';

$FS= ' ';       # field separator (space) - for documents.ulf
$, = "\n";      # set output field separator (newline)
$\ = "\n";      # set output record separator (newline)

## get list of components and corresponding translations from documents.ulf
open(DOCUMENTS_ULF, $ARGV[0]) || die 'Cannot open "documents.ulf".';
while (<DOCUMENTS_ULF>) {
    if (/^\[/) {
        # section starts
        s/^\[(.*)]/$1/;
        chomp;
        $module = $_;
    } else {
        # translated strings
        ($lang,$junk,$comment) = split($FS, $_, 3);
        $comment =~ s/^"(.*)"$/$1/;
        $comment =~ s/%PRODUCTNAME/$productname/;
        chomp $lang;
        chomp $comment;
        if ($lang eq "en-US") {
            $value = " $comment";
        } else {
            $value = ' '.$comment.'';
        }
        push(@{$mimehash{$module}}, $value) unless $lang eq "";
    }
}
close DOCUMENTS_ULF;

## creating the xml on stdout
print '';
print '';

foreach $component (sort(keys %mimehash)) {
    # mimetype and glob
    getMimedata($component);
    print ' ';
    print (sort({customsort($a) cmp customsort($b)} @{$mimehash{$component}}));
    print ' ';
    if ( $component =~ /oasis/ ) {
        if ( $component =~ /flat-xml/ ) {
            print ' ';
            print ' .( $mimetype =~ /-/  ? ' priority="60"' : '').'>';
            print ' ';
            print ' ';
            print ' ';
            print ' ';
            print ' ';
            print ' ';
        } else {
            print ' .( $mimetype =~ /-/  ? ' priority="60"' : '').'>';
            print ' ';
            print ' ';
            print ' ';
            print ' ';
            print ' ';
            print ' ';
        }
    }
    print ' ';
}
print '';

sub customsort {
        # sort <comment> before <comment xml:lang...>
        $in = shift;
        $in =~ tr/>/A/;
        $in =~ tr/ /Z/;
        return $in;
}

## get mime-type and glob from ../mimetype/*.desktop
sub getMimedata {
    $desktop_name = shift;
    $desktop_file = $mimedir.'/'.$desktop_name.'.desktop';
    $mimetype = "";
    $glob = "";
    open(DESKTOP_FILE, $desktop_file) || die "Cannot open desktop-file $desktop_file. ".$!;
    while (<DESKTOP_FILE>) {
        ## get mimetype
        if (/^MimeType=/) {
            s/^MimeType=(.*)\n$/$1/;
            $mimetype = "$_";
        }
        ## get glob
        if (/^Patterns=/) {
            s/^Patterns=(.*)\n$/\1/;
            $glob = "$_";
        }
    }
    close DESKTOP_FILE;
    # die if we cannot determine the glob-pattern or mimtetype
    die "Could not get mime-type from $desktop_file" if ($mimetype eq "");
    die "Could not get glob-pattern from $desktop_file" if ($glob eq "");
}

## END vim: set ts=4:

Messung V0.5
C=95 H=96 G=95

¤ Dauer der Verarbeitung: 0.21 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.