summaryrefslogtreecommitdiffstats
path: root/karbon/tests/oasis-karbon.sh
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 /karbon/tests/oasis-karbon.sh
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 'karbon/tests/oasis-karbon.sh')
-rwxr-xr-xkarbon/tests/oasis-karbon.sh87
1 files changed, 87 insertions, 0 deletions
diff --git a/karbon/tests/oasis-karbon.sh b/karbon/tests/oasis-karbon.sh
new file mode 100755
index 00000000..60ec6f54
--- /dev/null
+++ b/karbon/tests/oasis-karbon.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+# This script helps finding out problems in the OASIS loading/saving code,
+# by converting .karbon -> .odg -> .karbon and comparing the initial and final .karbon files.
+# We use the karbon format as a "dump" of the Karbon data, to check if everything is correct
+# in memory, but the point is of course to ensure that the .odg has all the information.
+
+# To use this script, you need to pass the full path to an existing karbon file as argument.
+# Don't use a relative path, dcopstart won't handle it
+input="$1"
+
+# Set this to 1 in order to validate the saved oasis document using oasislint
+checkoasis="1"
+
+appname=karbon
+oldextension=karbon
+oasisextension=odg
+oasismimetype=application/vnd.oasis.opendocument.graphics
+
+test -f "$input" || { echo "No such file $input"; exit 1; }
+
+# Load old native file
+appid=`dcopstart $appname $input`
+test -n "$appid" || { echo "Error starting $appname!"; exit 1; }
+while `dcop $appid Document-0 isLoading` == "true"; do
+ sleep 1;
+done
+
+# Save again (in case of changes in syntax etc.)
+origfile=$PWD/oasisregtest-initial.$oldextension
+dcop $appid Document-0 saveAs $origfile || exit 1
+test -f $origfile || exit 1
+
+# Save to OASIS
+tmpoasisfile=$PWD/oasisregtest.$oasisextension
+dcop $appid Document-0 setOutputMimeType $oasismimetype || exit 1
+dcop $appid Document-0 saveAs $tmpoasisfile || exit 1
+test -f $tmpoasisfile || exit 1
+
+dcopquit $appid
+
+# Load resulting OASIS file, convert to old native format
+tmpnativefile=$PWD/oasisregtest-final.$oldextension
+appid=`dcopstart $appname $tmpoasisfile`
+while `dcop $appid Document-0 isLoading` == "true"; do
+ sleep 1;
+done
+dcop $appid Document-0 setOutputMimeType "application/x-$appname" || exit 1
+dcop $appid Document-0 saveAs $tmpnativefile || exit 1
+test -f $tmpnativefile || exit 1
+
+# Unpack everything
+rm -rf oasisregtest-orig
+mkdir oasisregtest-orig
+rm -rf oasisregtest-final
+mkdir oasisregtest-final
+rm -rf oasisregtest-oasis
+mkdir oasisregtest-oasis
+cd oasisregtest-orig || exit 1
+unzip $origfile || exit 1
+cd ..
+cd oasisregtest-final || exit 1
+unzip $tmpnativefile || exit 1
+cd ..
+# Validate OASIS format
+cd oasisregtest-oasis || exit 1
+unzip $tmpoasisfile || exit 1
+if test "$checkoasis" = "1"; then
+ if type -p oasislint >/dev/null 2>&1; then
+ for f in content.xml styles.xml meta.xml settings.xml; do
+ echo "Checking $f..." ; oasislint $f
+ done
+ fi
+ if type -p oasislint-strict >/dev/null 2>&1; then
+ for f in content.xml styles.xml meta.xml settings.xml; do
+ echo "Checking $f strict..." && oasislint-strict $f
+ done
+ fi
+fi
+cd ..
+
+# Compare initial and final "native format" files
+diff -urp oasisregtest-orig oasisregtest-final 2>&1 | tee oasisdiff | less
+
+echo "See oasisregtest-oasis for the OASIS xml files."
+echo "For a better diffing mechanism, launch xemacs and paste into a terminal:"
+echo "gnudoit '(ediff-files \"$PWD/oasisregtest-orig/maindoc.xml\" \"$PWD/oasisregtest-final/maindoc.xml\")'"