File indexing completed on 2024-05-12 16:37:17
0001 #!/usr/bin/perl -w 0002 0003 # This script takes a Words XML file as entry (as saved by Words) 0004 # and generates a Words XML file that is ready to be used as a template. 0005 # Usually one will run unzip first, to extract maindoc.xml from the document, 0006 # and use that as the <inputFile>. 0007 # David Faure <faure@kde.org> 0008 0009 die "Usage: $0 inputFile outputFile.kwt" unless ($#ARGV == 1); 0010 open(IN, "<$ARGV[0]") or die "Can't open $ARGV[0] for reading"; 0011 open(OUT, ">$ARGV[1]") or die "Can't open $ARGV[1] for reading"; 0012 0013 my $inStyle = 0; 0014 my $styleName = ''; 0015 while(<IN>) 0016 { 0017 $inStyle = 1 if ( /<STYLE/ ); 0018 $inStyle = 0 if ( /<\/STYLE/ ); 0019 $styleName = $1 if ( $inStyle && /<NAME value=\"(.*)\"/ ); 0020 0021 my $ok = 1; 0022 # FONT name must be taken from the KDE standard font -> removing 0023 # align=left must be removed so that auto is used instead, for RTL users 0024 $ok = 0 if ( /FONT name/ || /FLOW align=\"left\"/ ); 0025 0026 # Remove font size from Standard style, comes from KDE standard font 0027 $ok = 0 if ( $inStyle && ($styleName eq 'Standard') && /<SIZE value=\"12\"/ ); 0028 0029 if ( $ok ) { 0030 print OUT $_; 0031 } 0032 } 0033 0034 close IN; 0035 close OUT;