// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "helpdata.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
const wxChar *readptr = line;
while (*readptr != 0 && *readptr != _T('\r') && *readptr != _T('\n') &&
- writeptr != endptr)
+ writeptr != endptr)
*(writeptr++) = *(readptr++);
*writeptr = 0;
while (*readptr == _T('\r') || *readptr == _T('\n'))
readptr++;
if (*readptr == 0)
return NULL;
- else
+ else
return readptr;
}
wxHtmlHelpDataItem *ia = *a;
wxHtmlHelpDataItem *ib = *b;
+ if (ia == NULL)
+ return -1;
+ if (ib == NULL)
+ return 1;
+
if (ia->parent == ib->parent)
{
return ia->name.CmpNoCase(ib->name);
{
wxHtmlHelpDataItem *ia2 = ia;
wxHtmlHelpDataItem *ib2 = ib;
-
+
while (ia2->level > ib2->level)
{
ia2 = ia2->parent;
{
ib2 = ib2->parent;
}
-
+
wxASSERT(ia2);
wxASSERT(ib2);
int res = wxHtmlHelpIndexCompareFunc(&ia2, &ib2);
int m_count;
wxHtmlHelpDataItem *m_parentItem;
wxHtmlBookRecord *m_book;
-
+
wxHtmlHelpDataItems *m_data;
public:
m_book = b;
m_name = m_page = wxEmptyString;
m_level = 0;
- m_id = -1;
+ m_id = wxID_ANY;
m_count = 0;
m_parentItem = NULL;
}
item->id = m_id;
item->page = m_page;
item->name = m_name;
-
+
item->book = m_book;
m_data->Add(item);
m_count++;
{
wxLogError(_("Cannot open index file: %s"), indexfile.c_str());
}
- return TRUE;
+ return true;
}
inline static void CacheWriteInt32(wxOutputStream *f, wxInt32 value)
}
inline static void CacheWriteString(wxOutputStream *f, const wxString& str)
-{
+{
const wxWX2MBbuf mbstr = str.mb_str(wxConvUTF8);
size_t len = strlen((const char*)mbstr)+1;
CacheWriteInt32(f, len);
/* load header - version info : */
version = CacheReadInt32(f);
-
+
if (version != CURRENT_CACHED_BOOK_VERSION)
{
- // NB: We can just silently return FALSE here and don't worry about
+ // NB: We can just silently return false here and don't worry about
// it anymore, because AddBookParam will load the MS project in
- // absence of (properly versioned) .cached file and automatically
+ // absence of (properly versioned) .cached file and automatically
// create new .cached file immediately afterward.
return false;
}
/* save contents : */
int len = m_contents.size();
- for (cnt = 0, i = 0; i < len; i++)
+ for (cnt = 0, i = 0; i < len; i++)
if (m_contents[i].book == book && m_contents[i].level > 0)
cnt++;
CacheWriteInt32(f, cnt);
for (i = 0; i < len; i++)
{
- if (m_contents[i].book != book || m_contents[i].level == 0)
+ if (m_contents[i].book != book || m_contents[i].level == 0)
continue;
CacheWriteInt32(f, m_contents[i].level);
CacheWriteInt32(f, m_contents[i].id);
/* save index : */
len = m_index.size();
- for (cnt = 0, i = 0; i < len; i++)
- if (m_index[i].book == book && m_index[i].level > 0)
+ for (cnt = 0, i = 0; i < len; i++)
+ if (m_index[i].book == book && m_index[i].level > 0)
cnt++;
CacheWriteInt32(f, cnt);
for (i = 0; i < len; i++)
{
- if (m_index[i].book != book || m_index[i].level == 0)
+ if (m_index[i].book != book || m_index[i].level == 0)
continue;
CacheWriteString(f, m_index[i].name);
CacheWriteString(f, m_index[i].page);
}
else
{
- int cnt = 0;
+ int cnt2 = 0;
wxHtmlHelpDataItem *parent = m_index[i].parent;
for (int j = i-1; j >= 0; j--)
{
if (m_index[j].book == book && m_index[j].level > 0)
- cnt++;
+ cnt2++;
if (&m_index[j] == parent)
break;
}
- wxASSERT(cnt > 0);
- CacheWriteInt32(f, cnt);
+ wxASSERT(cnt2 > 0);
+ CacheWriteInt32(f, cnt2);
}
}
return true;
ContentsOld = m_contents.size();
if (!path.IsEmpty())
- fsys.ChangePathTo(path, TRUE);
+ fsys.ChangePathTo(path, true);
size_t booksCnt = m_bookRecords.GetCount();
for (size_t i = 0; i < booksCnt; i++)
}
bookr = new wxHtmlBookRecord(bookfile.GetLocation(), fsys.GetPath(), title, deftopic);
-
+
wxHtmlHelpDataItem *bookitem = new wxHtmlHelpDataItem;
bookitem->level = 0;
bookitem->id = 0;
{
wxFileSystem fsys;
wxString s;
- bool rt = FALSE;
+ bool rt = false;
#if wxUSE_LIBMSPACK
if (extension == wxT(".chm"))
while (!s.IsEmpty())
{
- if (AddBook(s)) rt = TRUE;
+ if (AddBook(s)) rt = true;
s = fsys.FindNext();
}
if (fi == NULL)
{
wxLogError(_("Cannot open HTML help book: %s"), book.c_str());
- return FALSE;
+ return false;
}
fsys.ChangePathTo(book);
tmp = filter.ReadFile(*fi);
lineptr = tmp.c_str();
- do
+ do
{
lineptr = ReadLine(lineptr, linebuf, 300);
-
+
for (wxChar *ch = linebuf; *ch != wxT('\0') && *ch != wxT('='); ch++)
- *ch = tolower(*ch);
+ *ch = (wxChar)wxTolower(*ch);
if (wxStrstr(linebuf, _T("title=")) == linebuf)
title = linebuf + wxStrlen(_T("title="));
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);
+
+ wxFontEncoding enc = wxFONTENCODING_SYSTEM;
+#if wxUSE_FONTMAP
+ if (charset != wxEmptyString)
+ enc = wxFontMapper::Get()->CharsetToEncoding(charset);
+#endif
bool rtval = AddBookParam(*fi, enc,
title, contents, index, start, fsys.GetPath());
#if WXWIN_COMPATIBILITY_2_4
wxHtmlContentsItem::wxHtmlContentsItem()
- : m_Level(0), m_ID(-1), m_Name(NULL), m_Page(NULL), m_Book(NULL),
+ : m_Level(0), m_ID(wxID_ANY), m_Name(NULL), m_Page(NULL), m_Book(NULL),
m_autofree(false)
{
}
m_WholeWords = whole_words_only;
m_Keyword = keyword;
- if (m_CaseSensitive)
+ if (!m_CaseSensitive)
m_Keyword.LowerCase();
}
int i, j;
int wrd = m_Keyword.Length();
- bool found = FALSE;
+ bool found = false;
wxHtmlFilterHTML filter;
wxString tmp = filter.ReadFile(file);
int lng = tmp.length();
tmp.LowerCase();
const wxChar *kwd = m_Keyword.c_str();
-
+
if (m_WholeWords)
{
for (i = 0; i < lng - wrd; i++)