2
# @(#$Id: rclsoff,v 1.12 2008-10-08 08:27:34 dockes Exp $ (C) 2004 J.F.Dockes
3
# Parts taken from Estraier:
4
#================================================================
5
# Estraier: a personal full-text search system
6
# Copyright (C) 2003-2004 Mikio Hirabayashi
7
#================================================================
8
#================================================================
9
# Extract text from a gnumeric spreadsheet
10
#================================================================
14
LC_ALL=C ; export LC_ALL
15
progname="rclgnumeric"
20
##############################################################################
21
# !! Leave the previous line unmodified!! Code imported from the
24
# Utility code common to all shell filters. This could be sourced at run
25
# time, but it's slightly more efficient to include the code in the
26
# filters at build time (with a sed script).
28
# Describe error in a way that can be interpreted by our caller
32
# Also alert on stderr just in case
33
echo ":2:$progname::: $*" 1>&2
42
if test -x $cmd -a ! -d $cmd ; then return 0; else return 1; fi ;;
44
oldifs=$IFS; IFS=":"; set -- $PATH; IFS=$oldifs
45
for d in $*;do test -x $d/$cmd -a ! -d $d/$cmd && return 0;done
57
senderror HELPERNOTFOUND $cmd
63
if test $# -ne 1 -o "$1" = "--help"
65
echo "Convert a $filetype file to HTML text for Recoll indexing."
66
echo "Usage: $progname [infile]"
72
# check the input file existence (may be '-' for stdin)
73
if test "X$infile" != X- -a ! -f "$infile"
75
senderror INPUTNOSUCHFILE "$infile"
78
# protect access to our temp files and directories
81
##############################################################################
82
# !! Leave the following line unmodified !
85
checkcmds xsltproc gunzip
87
# We need a temporary file
88
if test z"$RECOLL_TMPDIR" != z; then
90
elif test z"$TMPDIR" != z ; then
95
tmpfile=$ttdir/rclgnm.XXXXXX
97
tmpfile=`mktemp "$tmpfile"`
99
senderror "$0: Can't create temp file, exiting..."
107
trap cleanup EXIT HUP QUIT INT TERM
109
gunzip < $1 > $tmpfile || senderror "Cant uncompress input"
110
xsltproc --novalid --nonet - $tmpfile <<EOF
111
<?xml version="1.0"?>
112
<xsl:stylesheet version="1.0"
113
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
114
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
115
xmlns:xlink="http://www.w3.org/1999/xlink"
116
xmlns:dc="http://purl.org/dc/elements/1.1/"
117
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
118
xmlns:ooo="http://openoffice.org/2004/office"
119
xmlns:gnm="http://www.gnumeric.org/v10.dtd"
121
exclude-result-prefixes="office xlink meta ooo dc"
124
<xsl:output method="html" encoding="UTF-8"/>
126
<xsl:template match="/">
129
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
130
<xsl:apply-templates select="//office:document-meta/office:meta"/>
134
<xsl:apply-templates select="//gnm:Cells"/>
135
<xsl:apply-templates select="//gnm:Objects"/>
140
<xsl:template match="//dc:date">
142
<xsl:attribute name="name">date</xsl:attribute>
143
<xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
147
<xsl:template match="//dc:description">
149
<xsl:attribute name="name">abstract</xsl:attribute>
150
<xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
154
<xsl:template match="//meta:keyword">
156
<xsl:attribute name="name">keywords</xsl:attribute>
157
<xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
161
<xsl:template match="//dc:subject">
163
<xsl:attribute name="name">keywords</xsl:attribute>
164
<xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
168
<xsl:template match="//dc:title">
169
<title> <xsl:value-of select="."/> </title>
172
<xsl:template match="//meta:initial-creator">
174
<xsl:attribute name="name">author</xsl:attribute>
175
<xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
179
<xsl:template match="office:meta/*"/>
181
<xsl:template match="gnm:Cell">
182
<p><xsl:value-of select="."/></p>
185
<xsl:template match="gnm:CellComment">
186
<blockquote><xsl:value-of select="@Text"/></blockquote>