]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/helpdata.cpp
Only call Select within SetString when internal data has been restored,
[wxWidgets.git] / src / html / helpdata.cpp
index ab8e0036fa3c3ed63dfd4fbce3afe26aa1221288..c0418b8d392ae0a489f003650281efe04cc29eae 100644 (file)
@@ -570,14 +570,24 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
 
 bool wxHtmlHelpData::AddBook(const wxString& book)
 {
-    if (book.Right(4).Lower() == wxT(".zip") ||
-        book.Right(4).Lower() == wxT(".htb") /*html book*/)
+    wxString extension(book.Right(4).Lower());
+    if (extension == wxT(".zip") ||
+#if wxUSE_LIBMSPACK
+        extension == wxT(".chm") /*compressed html help book*/ ||
+#endif
+        extension == wxT(".htb") /*html book*/)
     {
         wxFileSystem fsys;
         wxString s;
         bool rt = FALSE;
 
-        s = fsys.FindFirst(book + wxT("#zip:") + wxT("*.hhp"), wxFILE);
+#if wxUSE_LIBMSPACK
+        if (extension == wxT(".chm"))
+            s = fsys.FindFirst(book + wxT("#chm:*.hhp"), wxFILE);
+        else
+#endif
+            s = fsys.FindFirst(book + wxT("#zip:*.hhp"), wxFILE);
+
         while (!s.IsEmpty())
         {
             if (AddBook(s)) rt = TRUE;
@@ -586,60 +596,58 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
 
         return rt;
     }
-    else
-    {
-        wxFSFile *fi;
-        wxFileSystem fsys;
 
-        wxString title = _("noname"),
-                 safetitle,
-                 start = wxEmptyString,
-                 contents = wxEmptyString,
-                 index = wxEmptyString,
-                 charset = wxEmptyString;
-
-        fi = fsys.OpenFile(book);
-        if (fi == NULL)
-        {
-            wxLogError(_("Cannot open HTML help book: %s"), book.c_str());
-            return FALSE;
-        }
-        fsys.ChangePathTo(book);
+    wxFSFile *fi;
+    wxFileSystem fsys;
 
-        const wxChar *lineptr;
-        wxChar linebuf[300];
-        wxString tmp;
-        wxHtmlFilterPlainText filter;
-        tmp = filter.ReadFile(*fi);
-        lineptr = tmp.c_str();
+    wxString title = _("noname"),
+             safetitle,
+             start = wxEmptyString,
+             contents = wxEmptyString,
+             index = wxEmptyString,
+             charset = wxEmptyString;
 
-        do 
-        {
-            lineptr = ReadLine(lineptr, linebuf, 300);
-            
-            for (wxChar *ch = linebuf; *ch != wxT('\0') && *ch != wxT('='); ch++)
-               *ch = tolower(*ch);
-
-            if (wxStrstr(linebuf, _T("title=")) == linebuf)
-                title = linebuf + wxStrlen(_T("title="));
-            if (wxStrstr(linebuf, _T("default topic=")) == linebuf)
-                start = linebuf + wxStrlen(_T("default topic="));
-            if (wxStrstr(linebuf, _T("index file=")) == linebuf)
-                index = linebuf + wxStrlen(_T("index file="));
-            if (wxStrstr(linebuf, _T("contents file=")) == linebuf)
-                contents = linebuf + wxStrlen(_T("contents file="));
-            if (wxStrstr(linebuf, _T("charset=")) == linebuf)
-                charset = linebuf + wxStrlen(_T("charset="));
-        } while (lineptr != NULL);
-
-        wxFontEncoding enc;
-        if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM;
-        else enc = wxFontMapper::Get()->CharsetToEncoding(charset);
-        bool rtval = AddBookParam(*fi, enc,
-                                  title, contents, index, start, fsys.GetPath());
-        delete fi;
-        return rtval;
+    fi = fsys.OpenFile(book);
+    if (fi == NULL)
+    {
+        wxLogError(_("Cannot open HTML help book: %s"), book.c_str());
+        return FALSE;
     }
+    fsys.ChangePathTo(book);
+
+    const wxChar *lineptr;
+    wxChar linebuf[300];
+    wxString tmp;
+    wxHtmlFilterPlainText filter;
+    tmp = filter.ReadFile(*fi);
+    lineptr = tmp.c_str();
+
+    do 
+    {
+        lineptr = ReadLine(lineptr, linebuf, 300);
+        
+        for (wxChar *ch = linebuf; *ch != wxT('\0') && *ch != wxT('='); ch++)
+           *ch = tolower(*ch);
+
+        if (wxStrstr(linebuf, _T("title=")) == linebuf)
+            title = linebuf + wxStrlen(_T("title="));
+        if (wxStrstr(linebuf, _T("default topic=")) == linebuf)
+            start = linebuf + wxStrlen(_T("default topic="));
+        if (wxStrstr(linebuf, _T("index file=")) == linebuf)
+            index = linebuf + wxStrlen(_T("index file="));
+        if (wxStrstr(linebuf, _T("contents file=")) == linebuf)
+            contents = linebuf + wxStrlen(_T("contents file="));
+        if (wxStrstr(linebuf, _T("charset=")) == linebuf)
+            charset = linebuf + wxStrlen(_T("charset="));
+    } while (lineptr != NULL);
+
+    wxFontEncoding enc;
+    if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM;
+    else enc = wxFontMapper::Get()->CharsetToEncoding(charset);
+    bool rtval = AddBookParam(*fi, enc,
+                              title, contents, index, start, fsys.GetPath());
+    delete fi;
+    return rtval;
 }
 
 wxString wxHtmlHelpData::FindPageByName(const wxString& x)