3
# This script helps finding out problems in the OASIS loading/saving code,
4
# by converting .kfo -> .odf -> .kfo and comparing the initial and final .kwd files.
5
# We use the kfo format as a "dump" of the KFormula data, to check if everything is correct
6
# in memory, but the point is of course to ensure that the .odt has all the information.
8
# To use this script, you need to pass the full path to an existing kwd file as argument.
9
# Don't use a relative path, dcopstart won't handle it
12
# Set this to 1 in order to validate the saved oasis document using oasislint
18
oasismimetype=application/vnd.oasis.opendocument.formula
20
test -f "$input" || { echo "No such file $input"; exit 1; }
22
# Load old native file
23
appid=`dcopstart $appname $input`
24
test -n "$appid" || { echo "Error starting $appname!"; exit 1; }
25
while `dcop $appid Document-0 isLoading` == "true"; do
29
# Save again (in case of changes in syntax etc.)
30
origfile=$PWD/oasisregtest-initial.$oldextension
31
dcop $appid Document-0 saveAs $origfile || exit 1
32
test -f $origfile || exit 1
35
tmpoasisfile=$PWD/oasisregtest.$oasisextension
36
dcop $appid Document-0 setOutputMimeType $oasismimetype || exit 1
37
dcop $appid Document-0 saveAs $tmpoasisfile || exit 1
38
test -f $tmpoasisfile || exit 1
42
# Load resulting OASIS file, convert to old native format
43
tmpnativefile=$PWD/oasisregtest-final.$oldextension
44
appid=`dcopstart $appname $tmpoasisfile`
45
while `dcop $appid Document-0 isLoading` == "true"; do
48
dcop $appid Document-0 setOutputMimeType "application/x-$appname" || exit 1
49
dcop $appid Document-0 saveAs $tmpnativefile || exit 1
50
test -f $tmpnativefile || exit 1
53
rm -rf oasisregtest-orig
54
mkdir oasisregtest-orig
55
rm -rf oasisregtest-final
56
mkdir oasisregtest-final
57
rm -rf oasisregtest-oasis
58
mkdir oasisregtest-oasis
59
cd oasisregtest-orig || exit 1
60
unzip $origfile || exit 1
62
cd oasisregtest-final || exit 1
63
unzip $tmpnativefile || exit 1
65
# Validate OASIS format
66
cd oasisregtest-oasis || exit 1
67
unzip $tmpoasisfile || exit 1
68
if test "$checkoasis" = "1"; then
69
if type -p oasislint >/dev/null 2>&1; then
70
for f in content.xml styles.xml meta.xml settings.xml; do
71
echo "Checking $f..." ; oasislint $f
74
if type -p oasislint-strict >/dev/null 2>&1; then
75
for f in content.xml styles.xml meta.xml settings.xml; do
76
echo "Checking $f strict..." && oasislint-strict $f
82
# Compare initial and final "native format" files
83
diff -urp oasisregtest-orig oasisregtest-final 2>&1 | tee oasisdiff | less
85
echo "See oasisregtest-oasis for the OASIS xml files."
86
echo "For a better diffing mechanism, launch xemacs and paste into a terminal:"
87
echo "gnudoit '(ediff-files \"$PWD/oasisregtest-orig/maindoc.xml\" \"$PWD/oasisregtest-final/maindoc.xml\")'"