summaryrefslogtreecommitdiffstats
path: root/kword/templates/make_template.pl
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kword/templates/make_template.pl
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kword/templates/make_template.pl')
-rwxr-xr-xkword/templates/make_template.pl35
1 files changed, 35 insertions, 0 deletions
diff --git a/kword/templates/make_template.pl b/kword/templates/make_template.pl
new file mode 100755
index 00000000..b485e7c1
--- /dev/null
+++ b/kword/templates/make_template.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl -w
+
+# This script takes a KWord XML file as entry (as saved by KWord)
+# and generates a KWord XML file that is ready to be used as a template.
+# Usually one will run unzip first, to extract maindoc.xml from the document,
+# and use that as the <inputFile>.
+# David Faure <faure@kde.org>
+
+die "Usage: $0 inputFile outputFile.kwt" unless ($#ARGV == 1);
+open(IN, "<$ARGV[0]") or die "Can't open $ARGV[0] for reading";
+open(OUT, ">$ARGV[1]") or die "Can't open $ARGV[1] for reading";
+
+my $inStyle = 0;
+my $styleName = '';
+while(<IN>)
+{
+ $inStyle = 1 if ( /<STYLE/ );
+ $inStyle = 0 if ( /<\/STYLE/ );
+ $styleName = $1 if ( $inStyle && /<NAME value=\"(.*)\"/ );
+
+ my $ok = 1;
+ # FONT name must be taken from the KDE standard font -> removing
+ # align=left must be removed so that auto is used instead, for RTL users
+ $ok = 0 if ( /FONT name/ || /FLOW align=\"left\"/ );
+
+ # Remove font size from Standard style, comes from KDE standard font
+ $ok = 0 if ( $inStyle && ($styleName eq 'Standard') && /<SIZE value=\"12\"/ );
+
+ if ( $ok ) {
+ print OUT $_;
+ }
+}
+
+close IN;
+close OUT;