[sword-svn] r127 - in trunk/src/SwordReader_GUI: . SRFramework

dtrotzjr at www.crosswire.org dtrotzjr at www.crosswire.org
Sun Apr 27 20:19:43 MST 2008


Author: dtrotzjr
Date: 2008-04-27 20:19:43 -0700 (Sun, 27 Apr 2008)
New Revision: 127

Modified:
   trunk/src/SwordReader_GUI/SRFramework/WCString.cpp
   trunk/src/SwordReader_GUI/SRMainFrame.cpp
   trunk/src/SwordReader_GUI/SRTextView.cpp
   trunk/src/SwordReader_GUI/SRTextView.h
   trunk/src/SwordReader_GUI/SwordReaderResource.h
Log:
Bug fixes. Added TODO list.

Modified: trunk/src/SwordReader_GUI/SRFramework/WCString.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/WCString.cpp	2008-04-28 01:19:18 UTC (rev 126)
+++ trunk/src/SwordReader_GUI/SRFramework/WCString.cpp	2008-04-28 03:19:43 UTC (rev 127)
@@ -104,6 +104,9 @@
 WCString &WCString::operator=(const std::string &rhs)
 {
     unsigned int i = 0;
+    
+    data.clear();
+
     if(rhs.length() > data.size())
         data.resize(rhs.length());
     for(i = 0; i < rhs.length(); i++)
@@ -119,6 +122,8 @@
     // This is so dangerous...
     while(rhs[len]) len++;
 
+    data.clear();
+
     if(len > data.size())
         data.resize(len);
     for(i = 0; i < len; i++)
@@ -133,6 +138,8 @@
     unsigned int len = 0;
     // This is so dangerous...
     while(rhs[len]) len++;
+    
+    data.clear();
 
     if(len > data.size())
         data.resize(len);

Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp	2008-04-28 01:19:18 UTC (rev 126)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp	2008-04-28 03:19:43 UTC (rev 127)
@@ -228,8 +228,6 @@
 	WCString heading;
 	char strNum[10];
 	while (true) {
-        if(m_keyCurVerse->Verse() == 26)
-            s = "";
         m_modCurText->SetKey(m_keyCurVerse);
 		int pvHeading = 0;
 		do {
@@ -247,10 +245,15 @@
         s += (TCHAR *)m_modCurText->RenderText();
         s += " "; // Many verses do not have a space after them.
 		if (s.length() > 0) {
-            if(m_keyCurVerse->Verse() == 31){
+            // If the following failed it was due to a bad tag in this verse. 
+            // Use the stripped version instead.
+            if(!m_viewText->AddText(s.w_str(), s.length())){ 
+                s = GetVerseHeader(*m_keyCurVerse);
+                s += (TCHAR *)m_modCurText->StripText();
+                s += " "; // Many verses do not have a space after them. 
                 m_viewText->AddText(s.w_str(), s.length());
-            }else
-                m_viewText->AddText(s.w_str(), s.length());
+            }
+
 		}
         if (m_keyCurVerse->Verse() == GetMaxVerses())
 			break;

Modified: trunk/src/SwordReader_GUI/SRTextView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.cpp	2008-04-28 01:19:18 UTC (rev 126)
+++ trunk/src/SwordReader_GUI/SRTextView.cpp	2008-04-28 03:19:43 UTC (rev 127)
@@ -875,9 +875,11 @@
     }
 }
 
-VOID SRTextView::AddText(const TCHAR *szText, DWORD dwSize)
+BOOL SRTextView::AddText(const TCHAR *szText, DWORD dwSize)
 {
     DWORD i = 0;
+    INT   tag_pairs = 0;
+    DWORD dwOldEnd = m_dwBuffEnd;
     if(!m_dwBuffSize){
         m_dwBuffSize = BTEXT_BUFF_INC > dwSize ? BTEXT_BUFF_INC : dwSize;
         m_lpszBuff = new TCHAR[m_dwBuffSize];
@@ -923,11 +925,19 @@
         */
         if(szText[i] == 0x09) // Horizontal tab, replace with a single space. (for now at least.)
             m_lpszBuff[m_dwBuffEnd++] = ' ';
-        else if(szText[i] != '\n') // Ignore new-lines
+        else if(szText[i] != '\n'){ // Ignore new-lines
+            if(szText[i] == '<')
+                tag_pairs++;
+            else if(szText[i] == '>')
+                tag_pairs--;
             m_lpszBuff[m_dwBuffEnd++] = szText[i];
+        }
+        
     }
-    for(i = 0; i + m_dwBuffEnd < m_dwBuffSize; i++)
-        m_lpszBuff[i + m_dwBuffEnd] = 0;
+    if(tag_pairs != 0)
+        m_dwBuffEnd = dwOldEnd;
+    m_lpszBuff[m_dwBuffEnd] = 0;
+    return tag_pairs == 0;
 }
 
 BOOL SRTextView::UpdateWindow()

Modified: trunk/src/SwordReader_GUI/SRTextView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.h	2008-04-28 01:19:18 UTC (rev 126)
+++ trunk/src/SwordReader_GUI/SRTextView.h	2008-04-28 03:19:43 UTC (rev 127)
@@ -410,8 +410,9 @@
         BTEXT_BUFF_INC
         @param szText the text being added to this control.
         @param dwSize the length of the text being added.
+        @return TRUE if sucessful FALSE if malformed tags encountered.
      */
-    VOID    AddText(const TCHAR *szText, DWORD dwSize);
+    BOOL    AddText(const TCHAR *szText, DWORD dwSize);
     //! Scrolls the window a full height in a given direction.
     /*! @param nDirection the direction to scroll 
         \code

Modified: trunk/src/SwordReader_GUI/SwordReaderResource.h
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderResource.h	2008-04-28 01:19:18 UTC (rev 126)
+++ trunk/src/SwordReader_GUI/SwordReaderResource.h	2008-04-28 03:19:43 UTC (rev 127)
@@ -3,6 +3,22 @@
 #include <map>
 #include <swmodule.h>
 
+/*****************************************************************************
+ TODO:
+ 1) Implement the Find dialog
+ 2) Set the menu items to reflect current settings at startup (modules, options)
+ 3) Implement actions when settings or modules are changed.
+ 4) Speed up the page loads (go multi-threaded, and initially load the page 
+    requested then load the rest in the background)
+ 5) Load the last viewed text at startup.
+ 6) Separate the OT and NT Books in the Book Chooser.
+ 7) Highlight the current Book/Chap/Verse in the choosers.
+ 8) Allow the Choosers to respond to up/down/left/right buttons for selecting 
+    the items.
+ 9) More to come...
+
+ *****************************************************************************/
+
 struct ltstr
 {
   bool operator()(const char* s1, const char* s2) const




More information about the sword-cvs mailing list