--- desktop/scripts/soffice.sh~	2007-03-27 15:04:38.380150637 +0200
+++ desktop/scripts/soffice.sh	2007-03-27 19:49:12.717713134 +0200
@@ -39,13 +39,105 @@
 # export STAR_PROFILE_LOCKING_DISABLED
 #
 
-# file locking now enabled by default
-SAL_ENABLE_FILE_LOCKING=1
-export SAL_ENABLE_FILE_LOCKING
-
-# Uncomment the line below if you suspect that OpenGL is not
-# working on your system.
-# SAL_NOOPENGL=true; export SAL_NOOPENGL
+# Ubuntu helper functions
+file_or_home_on_nfs()
+{
+    case $(stat -f -c %T $HOME) in nfs*|smb)
+        return 0
+    esac
+    for i; do
+       case "$i" in -*) continue; esac
+       [ -f "$i" ] || continue
+       case $(stat -f -c %T "$i") in nfs*|smb)
+            return 0
+       esac
+    done
+    return 1
+}
+
+# FIXME: this is conservative; allow more known working configurations
+working_opengl_support()
+{
+    if [ -n "$(lsmod | awk '/^(fglrx|nvidia)/ {print $1}')" ]; then
+	return 1
+    fi
+    return 0
+}
+
+# read Ubuntu config file
+
+FILE_LOCKING=auto
+OPENGL_SUPPORT=no
+if [ -f /etc/openoffice/soffice.sh ]; then
+    . /etc/openoffice/soffice.sh
+fi
+
+# sanity checks
+
+case "$FILE_LOCKING" in
+    auto|yes|no) ;;
+    *)
+        echo >&2 "unknown value '$FILE_LOCKING' for FILE_LOCKING parameter."
+	FILE_LOCKING=auto
+	echo >&2 "FILE_LOCKING reset to '$FILE_LOCKING'"
+esac
+    
+case "$OPENGL_SUPPORT" in
+    auto|yes|no) ;;
+    *)
+        echo >&2 "unknown value '$OPENGL_SUPPORT' for OPENGL_SUPPORT parameter."
+	OPENGL_SUPPORT=auto
+	echo >&2 "OPENGL_SUPPORT reset to '$OPENGL_SUPPORT'"
+esac
+
+# adjust environment
+
+if [ -z "$SAL_ENABLE_FILE_LOCKING" ]; then
+    case "$FILE_LOCKING" in
+	auto)
+        if ! file_or_home_on_nfs "$@"; then
+            # file locking now enabled by default
+	    SAL_ENABLE_FILE_LOCKING=1
+	    export SAL_ENABLE_FILE_LOCKING
+	fi
+        ;;
+	yes)
+	SAL_ENABLE_FILE_LOCKING=1
+	export SAL_ENABLE_FILE_LOCKING
+        ;;
+	no)
+	SAL_ENABLE_FILE_LOCKING=0
+	export SAL_ENABLE_FILE_LOCKING
+    esac
+fi
+
+if [ -z "$SAL_NOOPENGL" ]; then
+    case "$OPENGL_SUPPORT" in
+	auto)
+        if ! working_opengl_support; then
+	    SAL_NOOPENGL=true
+	    export SAL_NOOPENGL
+	fi
+        ;;
+	yes)
+	:
+	unset SAL_NOOPENGL
+	#export SAL_NOOPENGL
+        ;;
+	no)
+	SAL_NOOPENGL=true
+	export SAL_NOOPENGL
+    esac
+fi
+
+
+# other Ubuntu stuff
+
+# turn off autohinting for thai (Ubuntu #35305).
+case "$LANG" in th*)
+    SAL_AUTOHINTING_PRIORITY=0
+    export SAL_AUTOHINTING_PRIORITY
+esac
 
 sd_platform=`uname -s`
 
