Well, wxHTML compiles in Unicode mode now. But if it works (without

further changes), it shall be considered proof that there is such a
thing as a divine intervention.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4250 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ove Kaaven 1999-10-29 03:10:22 +00:00
parent 0e36104428
commit 66a77a748e
14 changed files with 183 additions and 109 deletions

View File

@ -58,19 +58,19 @@ static char* ReadLine(char *line, char *buf)
static wxString SafeFileName(const wxString& s)
{
wxString res = s;
res.Replace(":", "_", TRUE);
res.Replace(" ", "_", TRUE);
res.Replace("/", "_", TRUE);
res.Replace("\\", "_", TRUE);
res.Replace("#", "_", TRUE);
res.Replace(".", "_", TRUE);
res.Replace(wxT(":"), wxT("_"), TRUE);
res.Replace(wxT(" "), wxT("_"), TRUE);
res.Replace(wxT("/"), wxT("_"), TRUE);
res.Replace(wxT("\\"), wxT("_"), TRUE);
res.Replace(wxT("#"), wxT("_"), TRUE);
res.Replace(wxT("."), wxT("_"), TRUE);
return res;
}
static int LINKAGEMODE IndexCompareFunc(const void *a, const void *b)
{
return strcmp(((wxHtmlContentsItem*)a) -> m_Name, ((wxHtmlContentsItem*)b) -> m_Name);
return wxStrcmp(((wxHtmlContentsItem*)a) -> m_Name, ((wxHtmlContentsItem*)b) -> m_Name);
}
@ -103,7 +103,7 @@ class HP_TagHandler : public wxHtmlTagHandler
public:
HP_TagHandler(wxHtmlBookRecord *b) : wxHtmlTagHandler() {m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString; m_Level = 0; }
wxString GetSupportedTags() { return "UL,OBJECT,PARAM"; }
wxString GetSupportedTags() { return wxT("UL,OBJECT,PARAM"); }
bool HandleTag(const wxHtmlTag& tag);
void WriteOut(wxHtmlContentsItem*& array, int& size);
void ReadIn(wxHtmlContentsItem* array, int size);
@ -118,7 +118,7 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
m_Level--;
return TRUE;
}
else if (tag.GetName() == "OBJECT") {
else if (tag.GetName() == wxT("OBJECT")) {
m_Name = m_Page = wxEmptyString;
ParseInner(tag);
if (m_Page != wxEmptyString) {
@ -126,19 +126,19 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
m_Items = (wxHtmlContentsItem*) realloc(m_Items, (m_ItemsCnt + wxHTML_REALLOC_STEP) * sizeof(wxHtmlContentsItem));
m_Items[m_ItemsCnt].m_Level = m_Level;
m_Items[m_ItemsCnt].m_ID = m_ID;
m_Items[m_ItemsCnt].m_Page = new char[m_Page.Length() + 1];
strcpy(m_Items[m_ItemsCnt].m_Page, m_Page.c_str());
m_Items[m_ItemsCnt].m_Name = new char [m_Name.Length() + 1];
strcpy(m_Items[m_ItemsCnt].m_Name, m_Name.c_str());
m_Items[m_ItemsCnt].m_Page = new wxChar[m_Page.Length() + 1];
wxStrcpy(m_Items[m_ItemsCnt].m_Page, m_Page.c_str());
m_Items[m_ItemsCnt].m_Name = new wxChar [m_Name.Length() + 1];
wxStrcpy(m_Items[m_ItemsCnt].m_Name, m_Name.c_str());
m_Items[m_ItemsCnt].m_Book = m_Book;
m_ItemsCnt++;
}
return TRUE;
}
else { // "PARAM"
if (m_Name == wxEmptyString && tag.GetParam("NAME") == "Name") m_Name = tag.GetParam("VALUE");
if (tag.GetParam("NAME") == "Local") m_Page = tag.GetParam("VALUE");
if (tag.GetParam("NAME") == "ID") tag.ScanParam("VALUE", "%i", &m_ID);
if (m_Name == wxEmptyString && tag.GetParam(wxT("NAME")) == wxT("Name")) m_Name = tag.GetParam(wxT("VALUE"));
if (tag.GetParam(wxT("NAME")) == wxT("Local")) m_Page = tag.GetParam(wxT("VALUE"));
if (tag.GetParam(wxT("NAME")) == wxT("ID")) tag.ScanParam(wxT("VALUE"), wxT("%i"), &m_ID);
return FALSE;
}
}
@ -256,11 +256,11 @@ bool wxHtmlHelpData::LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f)
f -> Read(&x, sizeof(x));
m_Contents[i].m_ID = x;
f -> Read(&x, sizeof(x));
m_Contents[i].m_Name = new char[x];
f -> Read(m_Contents[i].m_Name, x);
m_Contents[i].m_Name = new wxChar[x];
f -> Read(m_Contents[i].m_Name, x*sizeof(wxChar));
f -> Read(&x, sizeof(x));
m_Contents[i].m_Page = new char[x];
f -> Read(m_Contents[i].m_Page, x);
m_Contents[i].m_Page = new wxChar[x];
f -> Read(m_Contents[i].m_Page, x*sizeof(wxChar));
m_Contents[i].m_Book = book;
}
@ -272,11 +272,11 @@ bool wxHtmlHelpData::LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f)
m_Index = (wxHtmlContentsItem*) realloc(m_Index, (m_IndexCnt / wxHTML_REALLOC_STEP + 1) * wxHTML_REALLOC_STEP * sizeof(wxHtmlContentsItem));
for (i = st; i < m_IndexCnt; i++) {
f -> Read(&x, sizeof(x));
m_Index[i].m_Name = new char[x];
f -> Read(m_Index[i].m_Name, x);
m_Index[i].m_Name = new wxChar[x];
f -> Read(m_Index[i].m_Name, x*sizeof(wxChar));
f -> Read(&x, sizeof(x));
m_Index[i].m_Page = new char[x];
f -> Read(m_Index[i].m_Page, x);
m_Index[i].m_Page = new wxChar[x];
f -> Read(m_Index[i].m_Page, x*sizeof(wxChar));
m_Index[i].m_Book = book;
}
return TRUE;
@ -299,12 +299,12 @@ bool wxHtmlHelpData::SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f)
f -> Write(&x, sizeof(x));
x = m_Contents[i].m_ID;
f -> Write(&x, sizeof(x));
x = strlen(m_Contents[i].m_Name) + 1;
x = wxStrlen(m_Contents[i].m_Name) + 1;
f -> Write(&x, sizeof(x));
f -> Write(m_Contents[i].m_Name, x);
x = strlen(m_Contents[i].m_Page) + 1;
f -> Write(m_Contents[i].m_Name, x*sizeof(wxChar));
x = wxStrlen(m_Contents[i].m_Page) + 1;
f -> Write(&x, sizeof(x));
f -> Write(m_Contents[i].m_Page, x);
f -> Write(m_Contents[i].m_Page, x*sizeof(wxChar));
}
/* save index : */
@ -314,12 +314,12 @@ bool wxHtmlHelpData::SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f)
f -> Write(&x, sizeof(x));
for (i = 0; i < m_IndexCnt; i++) {
if (m_Index[i].m_Book != book || m_Index[i].m_Level == 0) continue;
x = strlen(m_Index[i].m_Name) + 1;
x = wxStrlen(m_Index[i].m_Name) + 1;
f -> Write(&x, sizeof(x));
f -> Write(m_Index[i].m_Name, x);
x = strlen(m_Index[i].m_Page) + 1;
f -> Write(m_Index[i].m_Name, x*sizeof(wxChar));
x = wxStrlen(m_Index[i].m_Page) + 1;
f -> Write(&x, sizeof(x));
f -> Write(m_Index[i].m_Page, x);
f -> Write(m_Index[i].m_Page, x*sizeof(wxChar));
}
return TRUE;
}
@ -356,10 +356,10 @@ bool wxHtmlHelpData::AddBookParam(const wxString& title, const wxString& contfil
m_Contents = (wxHtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + wxHTML_REALLOC_STEP) * sizeof(wxHtmlContentsItem));
m_Contents[m_ContentsCnt].m_Level = 0;
m_Contents[m_ContentsCnt].m_ID = 0;
m_Contents[m_ContentsCnt].m_Page = new char[deftopic.Length() + 1];
strcpy(m_Contents[m_ContentsCnt].m_Page, deftopic.c_str());
m_Contents[m_ContentsCnt].m_Name = new char [title.Length() + 1];
strcpy(m_Contents[m_ContentsCnt].m_Name, title.c_str());
m_Contents[m_ContentsCnt].m_Page = new wxChar[deftopic.Length() + 1];
wxStrcpy(m_Contents[m_ContentsCnt].m_Page, deftopic.c_str());
m_Contents[m_ContentsCnt].m_Name = new wxChar [title.Length() + 1];
wxStrcpy(m_Contents[m_ContentsCnt].m_Name, title.c_str());
m_Contents[m_ContentsCnt].m_Book = bookr;
// store the contents index for later
@ -473,7 +473,7 @@ wxString wxHtmlHelpData::FindPageByName(const wxString& x)
cnt = m_ContentsCnt;
for (i = 0; i < cnt; i++) {
if (strcmp(m_Contents[i].m_Name, x) == 0) {
if (wxStrcmp(m_Contents[i].m_Name, x) == 0) {
url = m_Contents[i].m_Book -> GetBasePath() + m_Contents[i].m_Page;
return url;
}
@ -484,7 +484,7 @@ wxString wxHtmlHelpData::FindPageByName(const wxString& x)
cnt = m_IndexCnt;
for (i = 0; i < cnt; i++) {
if (strcmp(m_Index[i].m_Name, x) == 0) {
if (wxStrcmp(m_Index[i].m_Name, x) == 0) {
url = m_Index[i].m_Book -> GetBasePath() + m_Index[i].m_Page;
return url;
}
@ -592,11 +592,11 @@ wxASSERT(m_Active);
void wxSearchEngine::LookFor(const wxString& keyword)
{
if (m_Keyword) delete[] m_Keyword;
m_Keyword = new char[keyword.Length() + 1];
strcpy(m_Keyword, keyword.c_str());
for (int i = strlen(m_Keyword) - 1; i >= 0; i--)
if ((m_Keyword[i] >= 'A') && (m_Keyword[i] <= 'Z'))
m_Keyword[i] += 'a' - 'A';
m_Keyword = new wxChar[keyword.Length() + 1];
wxStrcpy(m_Keyword, keyword.c_str());
for (int i = wxStrlen(m_Keyword) - 1; i >= 0; i--)
if ((m_Keyword[i] >= wxT('A')) && (m_Keyword[i] <= wxT('Z')))
m_Keyword[i] += wxT('a') - wxT('A');
}
@ -607,7 +607,7 @@ bool wxSearchEngine::Scan(wxInputStream *stream)
int i, j;
int lng = stream ->GetSize();
int wrd = strlen(m_Keyword);
int wrd = wxStrlen(m_Keyword);
bool found = FALSE;
char *buf = new char[lng + 1];
stream -> Read(buf, lng);

View File

@ -73,11 +73,11 @@ bool wxHtmlCell::AdjustPagebreak(int *pagebreak)
wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
{
m_Word = word;
m_Word.Replace("&nbsp;", " ", TRUE);
m_Word.Replace("&quot;", "\"", TRUE);
m_Word.Replace("&lt;", "<", TRUE);
m_Word.Replace("&gt;", ">", TRUE);
m_Word.Replace("&amp;", "&", TRUE);
m_Word.Replace(wxT("&nbsp;"), wxT(" "), TRUE);
m_Word.Replace(wxT("&quot;"), wxT("\""), TRUE);
m_Word.Replace(wxT("&lt;"), wxT("<"), TRUE);
m_Word.Replace(wxT("&gt;"), wxT(">"), TRUE);
m_Word.Replace(wxT("&amp;"), wxT("&"), TRUE);
dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent);
SetCanLiveOnPagebreak(FALSE);
}
@ -381,11 +381,11 @@ void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag)
wxString wd = tag.GetParam("WIDTH");
if (wd[wd.Length()-1] == '%') {
sscanf(wd.c_str(), "%i%%", &wdi);
wxSscanf(wd.c_str(), wxT("%i%%"), &wdi);
SetWidthFloat(wdi, wxHTML_UNITS_PERCENT);
}
else {
sscanf(wd.c_str(), "%i", &wdi);
wxSscanf(wd.c_str(), wxT("%i"), &wdi);
SetWidthFloat(wdi, wxHTML_UNITS_PIXELS);
}
}

View File

@ -64,8 +64,8 @@ wxString wxHtmlFilterPlainText::ReadFile(const wxFSFile& file) const
doc = src;
delete [] src;
doc.Replace("<", "&lt;", TRUE);
doc.Replace(">", "&gt;", TRUE);
doc.Replace(wxT("<"), wxT("&lt;"), TRUE);
doc.Replace(wxT(">"), wxT("&gt;"), TRUE);
doc2 = "<HTML><BODY><PRE>\n" + doc + "\n</PRE></BODY></HTML>";
return doc2;
}

View File

@ -42,10 +42,10 @@ IMPLEMENT_CLASS(wxHtmlTagsCache,wxObject)
wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source)
{
const char *src = source.c_str();
const wxChar *src = source.c_str();
int i, tg, pos, stpos;
int lng = source.Length();
char dummy[256];
wxChar dummy[256];
m_Cache = NULL;
m_CacheSize = 0;
@ -53,28 +53,28 @@ wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source)
pos = 0;
while (pos < lng) {
if (src[pos] == '<') { // tag found:
if (src[pos] == wxT('<')) { // tag found:
if (m_CacheSize % CACHE_INCREMENT == 0)
m_Cache = (sCacheItem*) realloc(m_Cache, (m_CacheSize + CACHE_INCREMENT) * sizeof(sCacheItem));
tg = m_CacheSize++;
m_Cache[tg].Key = stpos = pos++;
dummy[0] = 0; i = 0;
while ((src[pos] != '>') && (src[pos] != ' ')) {
while ((src[pos] != wxT('>')) && (src[pos] != wxT(' '))) {
dummy[i] = src[pos++];
if ((dummy[i] >= 'a') && (dummy[i] <= 'z')) dummy[i] -= ('a' - 'A');
if ((dummy[i] >= wxT('a')) && (dummy[i] <= wxT('z'))) dummy[i] -= (wxT('a') - wxT('A'));
i++;
}
dummy[i] = 0;
m_Cache[tg].Name = new char[i+1];
memcpy(m_Cache[tg].Name, dummy, i+1);
m_Cache[tg].Name = new wxChar[i+1];
memcpy(m_Cache[tg].Name, dummy, (i+1)*sizeof(wxChar));
while (src[pos] != '>') pos++;
while (src[pos] != wxT('>')) pos++;
if (src[stpos+1] == '/') { // ending tag:
if (src[stpos+1] == wxT('/')) { // ending tag:
m_Cache[tg].End1 = m_Cache[tg].End2 = -2;
// find matching begin tag:
for (i = tg; i >= 0; i--)
if ((m_Cache[i].End1 == -1) && (strcmp(m_Cache[i].Name, dummy+1) == 0)) {
if ((m_Cache[i].End1 == -1) && (wxStrcmp(m_Cache[i].Name, dummy+1) == 0)) {
m_Cache[i].End1 = stpos;
m_Cache[i].End2 = pos + 1;
break;
@ -157,8 +157,8 @@ wxHtmlTag::wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCac
bool wxHtmlTag::HasParam(const wxString& par) const
{
const char *st = m_Params, *p = par;
const char *st2, *p2;
const wxChar *st = m_Params, *p = par;
const wxChar *st2, *p2;
if (*st == 0) return FALSE;
if (*p == 0) return FALSE;
@ -186,8 +186,8 @@ bool wxHtmlTag::HasParam(const wxString& par) const
wxString wxHtmlTag::GetParam(const wxString& par, bool with_commas) const
{
const char *st = m_Params, *p = par;
const char *st2, *p2;
const wxChar *st = m_Params, *p = par;
const wxChar *st2, *p2;
bool comma;
char comma_char;
@ -240,10 +240,10 @@ wxString wxHtmlTag::GetParam(const wxString& par, bool with_commas) const
int wxHtmlTag::ScanParam(const wxString& par, char *format, void *param) const
int wxHtmlTag::ScanParam(const wxString& par, wxChar *format, void *param) const
{
wxString parval = GetParam(par);
return sscanf((const char*)parval, format, param);
return wxSscanf((const wxChar*)parval, format, param);
}
#endif

View File

@ -296,7 +296,7 @@ void wxHtmlWindow::ReadCustomization(wxConfigBase *cfg, wxString path)
m_Parser -> m_ItalicModeFixed = cfg -> Read("wxHtmlWindow/ItalicModeFixed", m_Parser -> m_ItalicModeFixed);
m_Parser -> m_ItalicModeNormal = cfg -> Read("wxHtmlWindow/ItalicModeNormal", m_Parser -> m_ItalicModeNormal);
for (int i = 0; i < 7; i++) {
tmp.Printf("wxHtmlWindow/FontsSize%i", i);
tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i);
m_Parser -> m_FontsSizes[i] = cfg -> Read(tmp, m_Parser -> m_FontsSizes[i]);
}
@ -322,7 +322,7 @@ void wxHtmlWindow::WriteCustomization(wxConfigBase *cfg, wxString path)
cfg -> Write("wxHtmlWindow/ItalicModeFixed", (long) m_Parser -> m_ItalicModeFixed);
cfg -> Write("wxHtmlWindow/ItalicModeNormal", (long) m_Parser -> m_ItalicModeNormal);
for (int i = 0; i < 7; i++) {
tmp.Printf("wxHtmlWindow/FontsSize%i", i);
tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i);
cfg -> Write(tmp, (long) m_Parser -> m_FontsSizes[i]);
}

View File

@ -370,11 +370,11 @@ wxString wxHtmlPrintout::TranslateHeader(const wxString& instr, int page)
wxString r = instr;
wxString num;
num.Printf("%i", page);
r.Replace("@PAGENUM@", num);
num.Printf(wxT("%i"), page);
r.Replace(wxT("@PAGENUM@"), num);
num.Printf("%i", m_NumPages);
r.Replace("@PAGESCNT@", num);
num.Printf(wxT("%i"), m_NumPages);
r.Replace(wxT("@PAGESCNT@"), num);
return r;
}

View File

@ -37,19 +37,19 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
wxColour oldclr = m_WParser -> GetActualColor();
int oldsize = m_WParser -> GetFontSize();
if (tag.HasParam("COLOR")) {
if (tag.HasParam(wxT("COLOR"))) {
unsigned long tmp = 0;
wxColour clr;
if (tag.ScanParam("COLOR", "#%lX", &tmp) == 1) {
if (tag.ScanParam(wxT("COLOR"), wxT("#%lX"), &tmp) == 1) {
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
m_WParser -> SetActualColor(clr);
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr));
}
}
if (tag.HasParam("SIZE")) {
if (tag.HasParam(wxT("SIZE"))) {
long tmp = 0;
if (tag.ScanParam("SIZE", "%li", &tmp) == 1) {
if (tag.ScanParam(wxT("SIZE"), wxT("%li"), &tmp) == 1) {
m_WParser -> SetFontSize(oldsize+tmp);
m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
}

View File

@ -79,7 +79,7 @@ TAG_HANDLER_BEGIN(HR, "HR")
c -> SetAlignHor(wxHTML_ALIGN_CENTER);
c -> SetAlign(tag);
c -> SetWidthFloat(tag);
if (tag.HasParam("SIZE") && tag.ScanParam("SIZE", "%i", &sz) == 1) {}
if (tag.HasParam(wxT("SIZE")) && tag.ScanParam(wxT("SIZE"), wxT("%i"), &sz) == 1) {}
else sz = 1;
c -> InsertCell(new wxHtmlLineCell(sz));

View File

@ -75,10 +75,10 @@ wxHtmlImageMapAreaCell::wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::celltype
type = t;
while ((i = x.Find( ',' )) != -1)
{
coords.Add( atoi( x.Left( i ).c_str() ) );
coords.Add( wxAtoi( x.Left( i ).c_str() ) );
x = x.Mid( i + 1 );
}
coords.Add( atoi( x.c_str() ) );
coords.Add( wxAtoi( x.c_str() ) );
}
wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
@ -382,8 +382,8 @@ TAG_HANDLER_BEGIN(IMG, "IMG, MAP, AREA")
wxString mn = wxEmptyString;
str = m_WParser -> GetFS() -> OpenFile(tmp);
if (tag.HasParam("WIDTH")) tag.ScanParam("WIDTH", "%i", &w);
if (tag.HasParam("HEIGHT")) tag.ScanParam("HEIGHT", "%i", &h);
if (tag.HasParam(wxT("WIDTH"))) tag.ScanParam(wxT("WIDTH"), wxT("%i"), &w);
if (tag.HasParam(wxT("HEIGHT"))) tag.ScanParam(wxT("HEIGHT"), wxT("%i"), &h);
al = wxHTML_ALIGN_BOTTOM;
if (tag.HasParam("ALIGN")) {
wxString alstr = tag.GetParam("ALIGN");

View File

@ -167,23 +167,23 @@ TAG_HANDLER_BEGIN(BODY, "BODY")
unsigned long tmp;
wxColour clr;
if (tag.HasParam("TEXT")) {
if (tag.ScanParam("TEXT", "#%lX", &tmp) == 1) {
if (tag.HasParam(wxT("TEXT"))) {
if (tag.ScanParam(wxT("TEXT"), wxT("#%lX"), &tmp) == 1) {
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
m_WParser -> SetActualColor(clr);
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr));
}
}
if (tag.HasParam("LINK")) {
if (tag.ScanParam("LINK", "#%lX", &tmp) == 1) {
if (tag.HasParam(wxT("LINK"))) {
if (tag.ScanParam(wxT("LINK"), wxT("#%lX"), &tmp) == 1) {
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
m_WParser -> SetLinkColor(clr);
}
}
if (tag.HasParam("BGCOLOR")) {
if (tag.ScanParam("BGCOLOR", "#%lX", &tmp) == 1) {
if (tag.HasParam(wxT("BGCOLOR"))) {
if (tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &tmp) == 1) {
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
if (m_WParser -> GetWindow() != NULL)

View File

@ -98,7 +98,7 @@ TAG_HANDLER_BEGIN(OLULLI, "OL,UL,LI")
c -> InsertCell(new wxHtmlListmarkCell(m_WParser -> GetDC(), m_WParser -> GetActualColor()));
else {
wxString mark;
mark.Printf("%i.", m_Numbering);
mark.Printf(wxT("%i."), m_Numbering);
c -> InsertCell(new wxHtmlWordCell(mark, *(m_WParser -> GetDC())));
}
m_WParser -> CloseContainer();

View File

@ -70,13 +70,13 @@ wxHtmlPRECell::wxHtmlPRECell(const wxString& s, wxDC& dc) : wxHtmlCell()
while (tokenizer.HasMoreTokens()) {
if (i % 10 == 0) m_Text = (wxString**) realloc(m_Text, sizeof(wxString*) * (i + 10));
tmp = tokenizer.NextToken();
tmp.Replace("&nbsp;", " ", TRUE);
tmp.Replace("&quot;", "\"", TRUE);
tmp.Replace("&lt;", "<", TRUE);
tmp.Replace("&gt;", ">", TRUE);
tmp.Replace("&amp;", "&", TRUE);
tmp.Replace("\t", " ", TRUE);
tmp.Replace("\r", "", TRUE);
tmp.Replace(wxT("&nbsp;"), wxT(" "), TRUE);
tmp.Replace(wxT("&quot;"), wxT("\""), TRUE);
tmp.Replace(wxT("&lt;"), wxT("<"), TRUE);
tmp.Replace(wxT("&gt;"), wxT(">"), TRUE);
tmp.Replace(wxT("&amp;"), wxT("&"), TRUE);
tmp.Replace(wxT("\t"), wxT(" "), TRUE);
tmp.Replace(wxT("\r"), wxT(""), TRUE);
m_Text[i++] = new wxString(tmp);
dc.GetTextExtent(tmp, &x, &z, &z);

View File

@ -122,10 +122,10 @@ wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& t
/* scan params: */
m_tBkg = m_rBkg = -1;
if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &m_tBkg);
if (tag.HasParam("VALIGN")) m_tValign = tag.GetParam("VALIGN"); else m_tValign = wxEmptyString;
if (tag.HasParam("CELLSPACING") && tag.ScanParam("CELLSPACING", "%i", &m_Spacing) == 1) {} else m_Spacing = 2;
if (tag.HasParam("CELLPADDING") && tag.ScanParam("CELLPADDING", "%i", &m_Padding) == 1) {} else m_Padding = 3;
if (tag.HasParam(wxT("BGCOLOR"))) tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &m_tBkg);
if (tag.HasParam(wxT("VALIGN"))) m_tValign = tag.GetParam(wxT("VALIGN")); else m_tValign = wxEmptyString;
if (tag.HasParam(wxT("CELLSPACING")) && tag.ScanParam(wxT("CELLSPACING"), wxT("%i"), &m_Spacing) == 1) {} else m_Spacing = 2;
if (tag.HasParam(wxT("CELLPADDING")) && tag.ScanParam(wxT("CELLPADDING"), wxT("%i"), &m_Padding) == 1) {} else m_Padding = 3;
if (m_HasBorders)
SetBorder(TABLE_BORDER_CLR_1, TABLE_BORDER_CLR_2);
@ -191,8 +191,8 @@ void wxHtmlTableCell::AddRow(const wxHtmlTag& tag)
/* scan params: */
m_rBkg = m_tBkg;
if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &m_rBkg);
if (tag.HasParam("VALIGN")) m_rValign = tag.GetParam("VALIGN"); else m_rValign = m_tValign;
if (tag.HasParam(wxT("BGCOLOR"))) tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &m_rBkg);
if (tag.HasParam(wxT("VALIGN"))) m_rValign = tag.GetParam(wxT("VALIGN")); else m_rValign = m_tValign;
}
@ -222,11 +222,11 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
wxString wd = tag.GetParam("WIDTH");
if (wd[wd.Length()-1] == '%') {
sscanf(wd.c_str(), "%i%%", &m_ColsInfo[c].width);
wxSscanf(wd.c_str(), wxT("%i%%"), &m_ColsInfo[c].width);
m_ColsInfo[c].units = wxHTML_UNITS_PERCENT;
}
else {
sscanf(wd.c_str(), "%i", &m_ColsInfo[c].width);
wxSscanf(wd.c_str(), wxT("%i"), &m_ColsInfo[c].width);
m_ColsInfo[c].units = wxHTML_UNITS_PIXELS;
}
}
@ -235,8 +235,8 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
// spanning:
{
if (tag.HasParam("COLSPAN")) tag.ScanParam("COLSPAN", "%i", &m_CellInfo[r][c].colspan);
if (tag.HasParam("ROWSPAN")) tag.ScanParam("ROWSPAN", "%i", &m_CellInfo[r][c].rowspan);
if (tag.HasParam(wxT("COLSPAN"))) tag.ScanParam(wxT("COLSPAN"), wxT("%i"), &m_CellInfo[r][c].colspan);
if (tag.HasParam(wxT("ROWSPAN"))) tag.ScanParam(wxT("ROWSPAN"), wxT("%i"), &m_CellInfo[r][c].rowspan);
if ((m_CellInfo[r][c].colspan != 1) || (m_CellInfo[r][c].rowspan != 1)) {
int i, j;
@ -252,7 +252,7 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
//background color:
{
int bk = m_rBkg;
if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &bk);
if (tag.HasParam(wxT("BGCOLOR"))) tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &bk);
if (bk != -1) {
wxColour clr = wxColour((bk & 0xFF0000) >> 16 , (bk & 0x00FF00) >> 8, (bk & 0x0000FF));
cell -> SetBackgroundColour(clr);

74
src/html/search.cpp Normal file
View File

@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
// Name: search.cpp
// Purpose: search engine
// Author: Vaclav Slavik
// RCS-ID: $Id$
// Copyright: (c) 1999 Vaclav Slavik
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation
#endif
#include "wx/wxprec.h"
#include "wx/defs.h"
#if wxUSE_HTML
#ifdef __BORDLANDC__
#pragma hdrstop
#endif
#ifndef WXPRECOMP
#include <wx/wx.h>
#endif
#include "wx/html/helpdata.h"
//--------------------------------------------------------------------------------
// wxSearchEngine
//--------------------------------------------------------------------------------
void wxSearchEngine::LookFor(const wxString& keyword)
{
if (m_Keyword) delete[] m_Keyword;
m_Keyword = new wxChar[keyword.Length() + 1];
wxStrcpy(m_Keyword, keyword.c_str());
for (int i = wxStrlen(m_Keyword) - 1; i >= 0; i--)
if ((m_Keyword[i] >= wxT('A')) && (m_Keyword[i] <= wxT('Z')))
m_Keyword[i] += wxT('a') - wxT('A');
}
bool wxSearchEngine::Scan(wxInputStream *stream)
{
wxASSERT_MSG(m_Keyword != NULL, _("wxSearchEngine::LookFor must be called before scanning!"));
int i, j;
int lng = stream ->GetSize();
int wrd = wxStrlen(m_Keyword);
bool found = FALSE;
char *buf = new char[lng + 1];
stream -> Read(buf, lng);
buf[lng] = 0;
for (i = 0; i < lng; i++)
if ((buf[i] >= 'A') && (buf[i] <= 'Z')) buf[i] += 'a' - 'A';
for (i = 0; i < lng - wrd; i++) {
j = 0;
while ((j < wrd) && (buf[i + j] == m_Keyword[j])) j++;
if (j == wrd) {found = TRUE; break;}
}
delete[] buf;
return found;
}
#endif