Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / tools / docx-templates-twiddling / fixstyle @ 187

History | View | Annotate | Download (1.7 kB)

1
#!/bin/sh
2
HERE=`pwd`
3
IN=`basename $1`
4
OUT=`basename $2`
5
INd=`dirname $1`
6
OUTd=`dirname $2`
7
INDIR=`(cd $INd; pwd)`
8
OUTDIR=`(cd $OUTd; pwd)`
9
AD=`dirname $0`
10
APPDIR=`(cd $AD; pwd)`
11
mkdir temp$$
12
cd temp$$
13
unzip -q $INDIR/$IN
14
# remove old template
15
if test -e $OUTDIR/$OUT
16
then
17
  echo "remove old template"
18
  rm $OUTDIR/$OUT
19
fi
20

    
21
# remove custom document properties
22
if test -e docProps/custom.xml
23
then
24
  echo "removed custom.xml"
25
  rm docProps/custom.xml
26
  #saxon docProps/custom.xml $APPDIR/fixdocprop.xsl  template="$3" > x.xml
27
  #mv x.xml docProps/custom.xml
28
fi
29

    
30
# remove custom xml folder
31
if test -e customXml
32
then
33
  echo "remove customXml folder"
34
  rm -r customXml
35
fi
36

    
37
# remove webSettings
38
if test -e word/webSettings.xml
39
then
40
	echo "remove webSettings.xml"
41
	rm word/webSettings.xml
42
fi
43

    
44
# remove word/_rels/settings.xml.rels
45
if test -e word/_rels/settings.xml.rels
46
then
47
	echo "remove settings.xml.rels"
48
	rm word/_rels/settings.xml.rels	
49
fi
50

    
51
# remove headers and footers
52
echo "remove all header and footer files"
53
rm word/footer*
54
rm word/header*
55

    
56
# remove theme directory
57
if test -e word/theme
58
then
59
	echo "remove document themes"
60
	rm -r word/theme
61
fi
62
	
63

    
64
# remove endnotes and footnotes
65
if test -e word/endnotes.xml
66
then
67
	echo "remove endotes.xml"
68
	rm word/endnotes.xml
69
fi
70
if test -e word/footnotes.xml
71
then
72
	echo "remove footnotes.xml"
73
	rm word/footnotes.xml
74
fi
75

    
76

    
77
# remove glossary dir
78
if test -e word/glossary
79
then
80
	echo "remove glossary directory"
81
	rm -r word/glossary
82
fi
83

    
84
# fix .rels
85
saxon _rels/.rels $APPDIR/fixdotrels.xsl > x
86
mv x _rels/.rels
87

    
88
#fix styles
89
saxon word/styles.xml $APPDIR/fixstyle.xsl > x
90
mv x word/styles.xml
91

    
92
# zip back together
93
zip -r -q $OUTDIR/$OUT .
94
cd ..
95
rm -rf temp$$
96

    
97
echo "stored template in $OUTDIR/$OUT"