#!/bin/bash ver="0.4" if [[ $1 = "" || $2 = "" ]] then echo -e " OpenOffice.org Converter by Dicky 'Mas Saint' Wahyu Purnomo ver $ver ==================================================================== Syntax : oo2txt [filename.sxw/filename.sxc] [text/html] Requirement : GNU sed version 3.0x or above Lynx UnZip Tips : oo2txt filename.sxw text > filename.txt Contact Me : Dicky Wahyu Purnomo 'Mas Saint' Email : dicky.wahyu@massaint.or.id Web : http://massaint.or.id YahooID : dicky_wp ICQ # : 5561766 " else file=$1 tmpfile=/tmp/OO2TXT`date +%d%m%Y%H%M` unzip -qq -o -C "$1" content.xml -d /tmp/ mv /tmp/content.xml $tmpfile echo " " > $tmpfile.html cat $tmpfile | tr ">" "\n" | sed s/$/'>'/g | grep -v '' | grep -v "^>$" | egrep -v "text:table-of-content|text:index-title-template|text:index-entry-|style:font-decl|style:style|style:properties|style:tab|style:background|style:column|text:list-style|text:list-level-style-number|text:list-level-style-bullet|text:sequence-decl|number:number|office:script|office:font-decls|office:automatic-styles|table:table-column|table:table-header-rows" | sed s/'text:style-name='/'class='/g | sed s/'text:p'/'p'/g | sed s/'office:body'/'body'/g | sed s/'office:document-content'/'html'/g | sed s/'table:table '/'table border=1 cellspacing=0 cellpadding=2 style=border-style:solid;color:black'/g | sed s/'table:table-row'/'tr'/g | sed s/'table:table-cell'/'td'/g | sed s/'table:table'/'table'/g | sed s/'text:unordered-list'/'ul'/g | sed s/'text:ordered-list'/'ol'/g | sed s/'text:list-item'/'li'/g | grep -v "^[1-9]$" | grep -v "^[1-9][0-9]$" | sed s/"^<\/td>$"/"\ <\/td>"/g >> $tmpfile.html if [[ $2 == "text" ]] then lynx -dump $tmpfile.html fi if [[ $2 == "html" ]] then cat $tmpfile.html fi rm -f $tmpfile fi