#!/bin/sh

#
# This makes rule re-use without acute pain in 
# a Makefile possible.
#

command=$1
TOOLSDIR=$2
OOBUILDDIR=$3;

FONTMUNGE_FILE=$OOBUILDDIR/officecfg/registry/data/org/openoffice/VCL.xcu

if test "z$command" = "z--apply"; then
# apply
	echo "Munging font mappings ..."
	cp $FONTMUNGE_FILE "$FONTMUNGE_FILE.bak"
	$TOOLSDIR/bin/font-munge $FONTMUNGE_FILE
	$TOOLSDIR/bin/help-font-munge $OOBUILDDIR/helpcontent2/source/auxiliary/*/*.css
	echo "done munging fonts."
    
elif test "z$command" = "z--revert"; then
# revert
	echo "Revert font mapping munging ..."
	if test -f $FONTMUNGE_FILE.bak; then
	    mv -f $FONTMUNGE_FILE.bak $FONTMUNGE_FILE;
	fi
	for cssfile in $OOBUILDDIR/helpcontent2/source/auxiliary/*/*.css ; do
	    if test -f $cssfile.bak ; then
		mv -f $cssfile.bak $cssfile;
	    fi;
	done

else
# error / help
	echo "Unknown option $command; try --apply or --revert <OOBUILDDIR>";
fi
