[sword-cvs] sword/src/modules/filters osisrtf.cpp,1.20,1.21 thmlrtf.cpp,1.34,1.35

sword@www.crosswire.org sword@www.crosswire.org
Wed, 6 Aug 2003 03:34:39 -0700


Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv11696/src/modules/filters

Modified Files:
	osisrtf.cpp thmlrtf.cpp 
Log Message:
added figure support

Index: osisrtf.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisrtf.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- osisrtf.cpp	5 Aug 2003 09:06:30 -0000	1.20
+++ osisrtf.cpp	6 Aug 2003 10:34:36 -0000	1.21
@@ -270,6 +270,44 @@
 			}
 		}
 
+		else if (!strcmp(tag.getName(), "figure")) {
+			const char *src = tag.getAttribute("src");
+			if (!src)		// assert we have a src attribute
+				return false;
+
+			char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)];
+			*filepath = 0;
+			strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath"));
+			strcat(filepath, src);
+
+// we do this because BibleCS looks for this EXACT format for an image tag
+			buf+="<figure src=\"";
+			buf+=filepath;
+			buf+="\" />";
+/*
+			char imgc;
+			for (c = filepath + strlen(filepath); c > filepath && *c != '.'; c--);
+			c++;
+			FILE* imgfile;
+				    if (stricmp(c, "jpg") || stricmp(c, "jpeg")) {
+						  imgfile = fopen(filepath, "r");
+						  if (imgfile != NULL) {
+								buf += "{\\nonshppict {\\pict\\jpegblip ";
+								while (feof(imgfile) != EOF) {
+									   buf.appendFormatted("%2x", fgetc(imgfile));
+								}
+								fclose(imgfile);
+								buf += "}}";
+						  }
+				    }
+				    else if (stricmp(c, "png")) {
+						  buf += "{\\*\\shppict {\\pict\\pngblip ";
+
+						  buf += "}}";
+				    }
+*/
+			delete [] filepath;
+		}
 		else {
 			return false;  // we still didn't handle token
 		}

Index: thmlrtf.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlrtf.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- thmlrtf.cpp	30 Jul 2003 00:51:34 -0000	1.34
+++ thmlrtf.cpp	6 Aug 2003 10:34:36 -0000	1.35
@@ -162,7 +162,7 @@
                         }
                         text += " ";
                 }
-                else {
+			 else {
                         text += *from;
                 }
         }
@@ -240,41 +240,45 @@
 			if (!src)		// assert we have a src attribute
 				return false;
 
-                        char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)];
-                        *filepath = 0;
-                        strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath"));
-                        unsigned long i = strlen(filepath);
-                        const char *c;
+			char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)];
+			*filepath = 0;
+			strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath"));
+			unsigned long i = strlen(filepath);
+			const char *c;
 			for (c = (src + 5); *c != '"'; c++) {
 				filepath[i] = *c;
-                                i++;
+				i++;
 			}
-                        filepath[i] = 0;
-
-                        for (c = filepath + strlen(filepath); c > filepath && *c != '.'; c--);
-                        c++;
+			filepath[i] = 0;
 
-                        char imgc;
-                        FILE* imgfile;
+			buf+="<figure src=\"";
+			buf+=filepath;
+			buf+="\" />";
 /*
-                        if (stricmp(c, "jpg") || stricmp(c, "jpeg")) {
-                                imgfile = fopen(filepath, "r");
-                                if (imgfile != NULL) {
-                                        buf += "{\\nonshppict {\\pict\\jpegblip ";
-                                        while (feof(imgfile) != EOF) {
-                                                buf.appendFormatted("%2x", fgetc(imgfile));
-                                        }
-                                        fclose(imgfile);
-                                        buf += "}}";
-                                }
-                        }
-                        else if (stricmp(c, "png")) {
-                                buf += "{\\*\\shppict {\\pict\\pngblip ";
+			char imgc;
+			FILE* imgfile;
+			for (c = filepath + strlen(filepath); c > filepath && *c != '.'; c--);
+			c++;
 
-                                buf += "}}";
-                        }
+
+			if (stricmp(c, "jpg") || stricmp(c, "jpeg")) {
+				imgfile = fopen(filepath, "r");
+				if (imgfile != NULL) {
+					buf += "{\\nonshppict {\\pict\\jpegblip ";
+					while (feof(imgfile) != EOF) {
+						buf.appendFormatted("%2x", fgetc(imgfile));
+					}
+					fclose(imgfile);
+					buf += "}}";
+				}
+			}
+			else if (stricmp(c, "png")) {
+				buf += "{\\*\\shppict {\\pict\\pngblip ";
+
+				buf += "}}";
+			}
 */
-                        delete [] filepath;
+			delete [] filepath;
 		}
 		else {
 			return false;  // we still didn't handle token