[sword-svn] r2820 - in trunk: bindings/corba bindings/corba/omniorbcpp bindings/corba/orbitcpp include src/modules/filters src/utilfuns

scribe at crosswire.org scribe at crosswire.org
Tue Jun 11 10:21:12 MST 2013


Author: scribe
Date: 2013-06-11 10:21:12 -0700 (Tue, 11 Jun 2013)
New Revision: 2820

Modified:
   trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
   trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp
   trunk/bindings/corba/omniorbcpp/testclient.cpp
   trunk/bindings/corba/orbitcpp/swordorb-impl.hpp
   trunk/bindings/corba/swordorb.idl
   trunk/include/osisxhtml.h
   trunk/include/swbuf.h
   trunk/include/swmodule.h
   trunk/src/modules/filters/osisxhtml.cpp
   trunk/src/utilfuns/swbuf.cpp
Log:
added better processing of poetry lines
changed swbuf append methods to return *this
guarded against bad markup where a stack pop without a push might result in a core dump



Modified: trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp	2013-06-10 13:08:06 UTC (rev 2819)
+++ trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp	2013-06-11 17:21:12 UTC (rev 2820)
@@ -332,6 +332,10 @@
 	return CORBA::string_dup(assureValidUTF8((char *)delegate->renderText()));
 }
 
+char* swordorb_SWModule_i::getRenderHeader(){
+	return CORBA::string_dup(assureValidUTF8(((char *)(delegate->getRenderHeader() ? delegate->getRenderHeader():""))));
+}
+
 char* swordorb_SWModule_i::getRawEntry(){
 	return CORBA::string_dup(assureValidUTF8((char *)delegate->getRawEntry()));
 }

Modified: trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp	2013-06-10 13:08:06 UTC (rev 2819)
+++ trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp	2013-06-11 17:21:12 UTC (rev 2820)
@@ -62,6 +62,7 @@
   void begin();
   char* getStripText();
   char* getRenderText();
+  char* getRenderHeader();
   char* getRawEntry();
   void setRawEntry(const char* entryBuffer);
   char* getConfigEntry(const char* key);

Modified: trunk/bindings/corba/omniorbcpp/testclient.cpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/testclient.cpp	2013-06-10 13:08:06 UTC (rev 2819)
+++ trunk/bindings/corba/omniorbcpp/testclient.cpp	2013-06-11 17:21:12 UTC (rev 2820)
@@ -93,6 +93,7 @@
 			std::cout << "KeyText: " << module->getKeyText() << "\n";
 			std::cout << "Text: " << module->getRenderText() << "\n";
 		}
+		std::cout << "RenderHeader:\n" << module->getRenderHeader() << "\n";
 /*
 		swordorb::SearchHitList *searchResults;
 		bool lucene = module->hasSearchFramework();

Modified: trunk/bindings/corba/orbitcpp/swordorb-impl.hpp
===================================================================
--- trunk/bindings/corba/orbitcpp/swordorb-impl.hpp	2013-06-10 13:08:06 UTC (rev 2819)
+++ trunk/bindings/corba/orbitcpp/swordorb-impl.hpp	2013-06-11 17:21:12 UTC (rev 2820)
@@ -57,6 +57,7 @@
 	char *getStripText() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->StripText()); }
 	StringList *getEntryAttribute(const char *level1, const char *level2, const char *level3, CORBA::Boolean filtered) throw(CORBA::SystemException);
 	char *getRenderText() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->RenderText()); }
+	char *getRenderHeader() throw(CORBA::SystemException) { return CORBA::string_dup((char *)((delegate->getRenderHeader()?delegate->getRenderHeader():""))); }
 	char *getRawEntry() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->getRawEntry()); }
 	void  setRawEntry(const char *entryBuffer) throw(CORBA::SystemException) { delegate->setEntry(entryBuffer); }
 	char *getConfigEntry(const char *key) throw(CORBA::SystemException) { return CORBA::string_dup(((char *)delegate->getConfigEntry(key)) ? (char *)delegate->getConfigEntry(key):SWNULL); }

Modified: trunk/bindings/corba/swordorb.idl
===================================================================
--- trunk/bindings/corba/swordorb.idl	2013-06-10 13:08:06 UTC (rev 2819)
+++ trunk/bindings/corba/swordorb.idl	2013-06-11 17:21:12 UTC (rev 2820)
@@ -87,6 +87,8 @@
 	void          begin();
 	string        getStripText();
 	string        getRenderText();
+	// CSS styles associated with this text
+	string        getRenderHeader();
 	string        getRawEntry();
 	void          setRawEntry(in string entryBuffer);
 	string        getConfigEntry(in string key);

Modified: trunk/include/osisxhtml.h
===================================================================
--- trunk/include/osisxhtml.h	2013-06-10 13:08:06 UTC (rev 2819)
+++ trunk/include/osisxhtml.h	2013-06-11 17:21:12 UTC (rev 2820)
@@ -50,6 +50,7 @@
 		TagStack *quoteStack;
 		TagStack *hiStack;
 		TagStack *titleStack;
+		TagStack *lineStack;
 		int consecutiveNewlines;
 		SWBuf lastTransChange;
 		SWBuf w;

Modified: trunk/include/swbuf.h
===================================================================
--- trunk/include/swbuf.h	2013-06-10 13:08:06 UTC (rev 2819)
+++ trunk/include/swbuf.h	2013-06-11 17:21:12 UTC (rev 2820)
@@ -232,7 +232,7 @@
 	* @param str Append this.
 	* @param max Append only max chars.
 	*/
-	void append(const char *str, long max = -1);
+	SWBuf &append(const char *str, long max = -1);
 
 	/**
 	* SWBuf::append - appends a value to the current value of this SWBuf
@@ -240,17 +240,18 @@
 	* @param str Append this.
 	* @param max Append only max chars.
 	*/
-	inline void append(const SWBuf &str, long max = -1) { append(str.c_str(), max); }
+	inline SWBuf &append(const SWBuf &str, long max = -1) { return append(str.c_str(), max); }
 
 	/**
 	* SWBuf::append - appends a value to the current value of this SWBuf
 	* If the allocated memory is not enough, it will be resized accordingly.
 	* @param ch Append this.
 	*/
-	inline void append(char ch) {
+	inline SWBuf &append(char ch) {
 		assureMore(1);
 		*end++ = ch;
 		*end = 0;
+		return *this;
 	}
 
 	/**
@@ -260,10 +261,11 @@
 	* platforms (stupid windoze; stupid c++ spec for not mandating 4byte).
 	* @param ch Append this.
 	*/
-	inline void append(wchar_t wch) {
+	inline SWBuf &append(wchar_t wch) {
 		assureMore(sizeof(wchar_t)*2);
 		for (unsigned int i = 0; i < sizeof(wchar_t); i++) *end++ = ((char *)&wch)[i];
 		for (unsigned int i = 0; i < sizeof(wchar_t); i++) end[i] = 0;
+		return *this;
 	}
 
 	/**
@@ -282,7 +284,7 @@
 	* @param format The format string. Same syntax as printf, for example.
 	* @param ... Add all arguments here.
 	*/
-	void appendFormatted(const char *format, ...);
+	SWBuf &appendFormatted(const char *format, ...);
 	
 	/** 
 	* SWBuf::insert - inserts the given string at position into this string

Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h	2013-06-10 13:08:06 UTC (rev 2819)
+++ trunk/include/swmodule.h	2013-06-11 17:21:12 UTC (rev 2820)
@@ -644,7 +644,7 @@
 	virtual const char *renderText(const char *buf = 0, int len = -1, bool render = true);
 	SWDEPRECATED const char *RenderText(const char *buf = 0, int len = -1, bool render = true) { return renderText(buf, len, render); }
 
-	/** Produces any header data which might be useful which associated with the
+	/** Produces any header data which might be useful which is associated with the
 	 *	processing done with this filter.  A typical example is a suggested
 	 *	CSS style block for classed containers.
 	 */

Modified: trunk/src/modules/filters/osisxhtml.cpp
===================================================================
--- trunk/src/modules/filters/osisxhtml.cpp	2013-06-10 13:08:06 UTC (rev 2819)
+++ trunk/src/modules/filters/osisxhtml.cpp	2013-06-11 17:21:12 UTC (rev 2820)
@@ -34,14 +34,19 @@
 SWORD_NAMESPACE_START
 
 const char *OSISXHTML::getHeader() const {
-	return "\
+	const static char *header = "\
 		.divineName { font-variant: small-caps; }\n\
 		.wordsOfJesus { color: red; }\n\
 		.transChangeSupplied { font-style: italic; }\n\
 		.small, .sub, .sup { font-size: .83em }\n\
 		.sub             { vertical-align: sub }\n\
 		.sup             { vertical-align: super }\n\
+		.indent1         { margin-left: 10px }\n\
+		.indent2         { margin-left: 20px }\n\
+		.indent3         { margin-left: 30px }\n\
+		.indent4         { margin-left: 40px }\n\
 	";
+	return header;
 }
 
 
@@ -153,7 +158,7 @@
 class OSISXHTML::TagStack : public std::stack<SWBuf> {
 };
 
-OSISXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key), quoteStack(new TagStack()), hiStack(new TagStack()), titleStack(new TagStack()) {
+OSISXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key), quoteStack(new TagStack()), hiStack(new TagStack()), titleStack(new TagStack()), lineStack(new TagStack()) {
 	inXRefNote    = false;
 	suspendLevel = 0;
 	wordsOfChristStart = "<span class=\"wordsOfJesus\"> ";
@@ -174,6 +179,7 @@
 	delete quoteStack;
 	delete hiStack;
 	delete titleStack;
+	delete lineStack;
 }
 
 void OSISXHTML::MyUserData::outputNewline(SWBuf &buf) {
@@ -389,19 +395,23 @@
 
 		// <l> poetry, etc
 		else if (!strcmp(tag.getName(), "l")) {
+			// start line marker
+			if (tag.getAttribute("sID") || (!tag.isEndTag() && !tag.isEmpty())) {
+				// nested lines plus if the line itself has an x-indent type attribute value
+				outText(SWBuf("<span class=\"line indent").appendFormatted("%d\">", u->lineStack->size() + (SWBuf("x-indent") == tag.getAttribute("type")?1:0)).c_str(), buf, u);
+				u->lineStack->push(tag.toString());
+			}
 			// end line marker
-			if (tag.getAttribute("eID")) {
+			else if (tag.getAttribute("eID") || tag.isEndTag()) {
+				outText("</span>", buf, u);
 				u->outputNewline(buf);
+				if (u->lineStack->size()) u->lineStack->pop();
 			}
 			// <l/> without eID or sID
 			// Note: this is improper osis. This should be <lb/>
 			else if (tag.isEmpty() && !tag.getAttribute("sID")) {
 				u->outputNewline(buf);
 			}
-			// end of the line
-			else if (tag.isEndTag()) {
-				u->outputNewline(buf);
-			}
 		}
 
 		// <lb.../>
@@ -474,7 +484,7 @@
 			else if (tag.isEndTag()) {
 				if (!u->titleStack->empty()) {
 					XMLTag tag(u->titleStack->top());
-					u->titleStack->pop();
+					if (u->titleStack->size()) u->titleStack->pop();
 					SWBuf pushed = tag.getAttribute("pushed");
 					if (pushed.size()) {
 						buf += (SWBuf)"</" + pushed + ">\n\n";
@@ -563,7 +573,7 @@
 				SWBuf type = "";
 				if (!u->hiStack->empty()) {
 					XMLTag tag(u->hiStack->top());
-					u->hiStack->pop();
+					if (u->hiStack->size()) u->hiStack->pop();
 					type = tag.getAttribute("type");
 					if (!type.length()) type = tag.getAttribute("rend");
 				}
@@ -619,7 +629,7 @@
 				// if it is </q> then pop the stack for the attributes
 				if (tag.isEndTag() && !u->quoteStack->empty()) {
 					XMLTag qTag(u->quoteStack->top());
-					u->quoteStack->pop();
+					if (u->quoteStack->size()) u->quoteStack->pop();
 
 					type    = qTag.getAttribute("type");
 					who     = qTag.getAttribute("who");

Modified: trunk/src/utilfuns/swbuf.cpp
===================================================================
--- trunk/src/utilfuns/swbuf.cpp	2013-06-10 13:08:06 UTC (rev 2819)
+++ trunk/src/utilfuns/swbuf.cpp	2013-06-11 17:21:12 UTC (rev 2820)
@@ -97,7 +97,7 @@
 * SWBuf::append - appends a value to the current value of this SWBuf
 * 
 */
-void SWBuf::append(const char *str, long max) {
+SWBuf &SWBuf::append(const char *str, long max) {
 //	if (!str) //A null string was passed
 //		return;
 	if (max < 0)
@@ -106,6 +106,7 @@
 	for (;((max)&&(*str));max--)
 		*end++ = *str++;
 	*end = 0;
+	return *this;
 }
 
 /******************************************************************************
@@ -124,7 +125,7 @@
 * WARNING: This function can only write at most
 * JUNKBUFSIZE to the string per call.
 */
-void SWBuf::appendFormatted(const char *format, ...) {
+SWBuf &SWBuf::appendFormatted(const char *format, ...) {
 	va_list argptr;
 
 	va_start(argptr, format);
@@ -138,6 +139,7 @@
 	va_start(argptr, format);
 	end += vsprintf(end, format, argptr);
 	va_end(argptr);
+	return *this;
 }
 
 void SWBuf::insert(unsigned long pos, const char* str, unsigned long start, signed long max) {




More information about the sword-cvs mailing list