--- wvparse.c	2004-10-10 05:05:51.000000000 +0530
+++ ../wv-1.0.3-modified/wvparse.c	2005-05-26 12:41:28.000000000 +0530
@@ -34,6 +34,12 @@ wvInit (void)
 #endif
 }
 
+void
+wvSetOpenModeReadOnly (gboolean readonly)
+{
+    ms_ole_set_readonly (readonly);
+}
+
 int
 wvInitParser (wvParseStruct * ps, char *path)
 {
--- libole2/ms-ole.c	2004-10-23 06:29:51.000000000 +0530
+++ ../wv-1.0.3-modified/libole2/ms-ole.c	2005-05-26 12:52:11.000000000 +0530
@@ -331,6 +331,11 @@ MsOlePos  ms_ole_stream_write       (MsO
  */
 gboolean libole2_debug = FALSE;
 
+/*
+ * A global variable to specify the mode of opening the ole-file-stream.
+ */
+gboolean ms_ole_open_readonly = FALSE;
+
 typedef guint32 PPS_IDX ;
 
 #if OLE_DEBUG > 0
@@ -1705,6 +1710,15 @@ ms_ole_unref (MsOle *fs)
 	fs->ref_count--;
 }
 
+/**
+ * ms_ole_set_readonly:
+ * @flag: TRUE if ole filesystem to be opened in READONLY mode.
+ **/
+void
+ms_ole_set_readonly (gboolean flag)
+{
+	ms_ole_open_readonly = flag;
+}
 
 /**
  * ms_ole_open_vfs:
@@ -1723,9 +1737,10 @@ ms_ole_open_vfs (MsOle **fs, const char 
 		 gboolean try_mmap,
 		 MsOleSysWrappers *wrappers)
 {
-	int prot = PROT_READ | PROT_WRITE;
+	int prot;
 	MsOle *f;
 	MsOleHandleType file;
+	int open_flag;
 
 	if (!fs)
 		return MS_OLE_ERR_BADARG;
@@ -1734,13 +1749,25 @@ ms_ole_open_vfs (MsOle **fs, const char 
 	g_print ("New OLE file '%s'\n", name);
 #endif
 
+	if (ms_ole_open_readonly) {
+		prot = PROT_READ;
+		open_flag = O_RDONLY;
+	} else {
+		prot = PROT_READ | PROT_WRITE;
+		open_flag = O_RDWR;
+	}
+
 	f = *fs = ms_ole_new ();
 	take_wrapper_functions (f, wrappers);
 
-	f->file_des = file = f->syswrap->open2 (name, O_RDWR, f->syswrap->closure);
+	f->file_des = file = f->syswrap->open2 (name, open_flag, f->syswrap->closure);
 	f->ref_count = 0;
-	f->mode = 'w';
 
+	if (ms_ole_open_readonly)
+		f->mode = 'r';
+	else
+		f->mode = 'w';
+	
 	if (file == BAD_MSOLE_HANDLE) {
 		f->file_des = file = f->syswrap->open2 (name, O_RDONLY, f->syswrap->closure);
 		f->mode = 'r';
@@ -1984,6 +2011,9 @@ ms_ole_destroy (MsOle **ptr)
 #if OLE_DEBUG > 0
 	g_print ("FIXME: should truncate to remove unused blocks\n");
 #endif
+	/* Reset the readonly flag */
+	ms_ole_open_readonly = FALSE;
+
 	if (f) {
 		if (f->ref_count != 0)
 			g_warning ("Unclosed files exist on this OLE stream\n");
