Subversion Repositories Kolibri OS

Rev

Rev 5690 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5690 Rev 5704
Line 24... Line 24...
24
 
24
 
25
byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, 
25
byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, 
26
	link, ignor_text, cur_encoding, text_align, t_html, t_body;
26
	link, ignor_text, cur_encoding, text_align, t_html, t_body;
Line 27... Line -...
27
byte condition_text_active, condition_text_val, condition_href, condition_max;
-
 
28
 
-
 
29
enum { _WIN, _DOS, _KOI, _UTF, _DEFAULT };
27
byte condition_text_active, condition_text_val, condition_href, condition_max;
Line 30... Line 28...
30
 
28
 
31
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
29
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
32
 
30
 
Line 98... Line 96...
98
	}
96
	}
99
}
97
}
100
//=======================================================================
98
//=======================================================================
Line 101... Line -...
101
 
-
 
102
 
-
 
103
void BufEncode(int set_new_encoding)
-
 
104
{
-
 
105
	int bufpointer_realsize;
-
 
106
	cur_encoding = set_new_encoding;
-
 
107
	if (o_bufpointer==0)
-
 
108
	{
-
 
109
		o_bufpointer = malloc(bufsize);
-
 
110
		strcpy(o_bufpointer, bufpointer);
-
 
111
	}
-
 
112
	else
-
 
113
	{
-
 
114
		strcpy(bufpointer, o_bufpointer);
-
 
115
	}
-
 
116
	if (set_new_encoding==_WIN) bufpointer = ChangeCharset("CP1251",  "CP866", bufpointer);
-
 
117
	if (set_new_encoding==_UTF) bufpointer = ChangeCharset("UTF-8",   "CP866", bufpointer);
-
 
118
	if (set_new_encoding==_KOI) bufpointer = ChangeCharset("KOI8-RU", "CP866", bufpointer);
-
 
119
}
99
 
120
 
100
 
121
void TWebBrowser::Prepare(dword bufpos, in_filesize){
101
void TWebBrowser::Prepare(dword bufpos, in_filesize){
122
	bufsize = in_filesize;
102
	bufsize = in_filesize;
123
	bufpointer = bufpos;
103
	bufpointer = bufpos;
Line 153... Line 133...
153
 
133
 
154
	if (pre_text<>2)
134
	if (pre_text<>2)
155
	{
135
	{
156
		pre_text=0;
136
		pre_text=0;
157
		if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
-
 
158
		if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
137
		if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
Line 159... Line 138...
159
	}
138
	}
160
	
139
	
161
	for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
140
	for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
Line 181... Line 160...
181
				if (!tab_len) tab_len = 4;
160
				if (!tab_len) tab_len = 4;
182
				for (j=0; j
161
				for (j=0; j
183
				break;
162
				break;
184
			}
163
			}
185
			goto DEFAULT_MARK;		
164
			goto DEFAULT_MARK;		
186
		case '=': //quoted printable
-
 
187
			if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
-
 
188
 
-
 
189
			temp[0] = ESBYTE[bufpos+1];
-
 
190
			temp[1] = ESBYTE[bufpos+2];
-
 
191
			temp[2] = '\0';
-
 
192
			if (bukva = Hex2Symb(#temp))
-
 
193
			{
-
 
194
				bufpos+=2;
-
 
195
				goto DEFAULT_MARK;
-
 
196
			}
-
 
197
			break;
-
 
Line 198... Line 165...
198
			
165
			
199
		case '&': //  and so on
166
		case '&': //  and so on
200
			bufpos++;
167
			bufpos++;
201
			tag=0;
168
			tag=0;
Line 311... Line 278...
311
	}
278
	}
312
	else opened = 1;
279
	else opened = 1;
Line 313... Line 280...
313
		
280
		
314
	if (isTag("html"))
281
	if (isTag("html"))
315
	{
-
 
316
		IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (opened==0) ignor_text = 1; ELSE ignor_text = 0;
282
	{
317
		t_html = opened;
283
		t_html = opened;
318
		return;
284
		return;
Line 319... Line 285...
319
	}
285
	}
Line 360... Line 326...
360
			{
326
			{
361
				bg_color=GetColor(#options);
327
				bg_color=GetColor(#options);
362
				DrawBuf.Fill(bg_color);
328
				DrawBuf.Fill(bg_color);
363
			}
329
			}
364
		} while(GetNextParam());
330
		} while(GetNextParam());
365
		if (opened) && (cur_encoding==_DEFAULT)
331
		if (opened) && (cur_encoding==CH_NULL)
366
		{
332
		{
367
			debugln("Document has no information about encoding, UTF will be used");
333
			debugln("Document has no information about encoding, UTF will be used");
368
			BufEncode(_UTF);
334
			//BufEncode(CH_UTF8);
369
		}
335
		}
370
		return;
336
		return;
371
	}
337
	}
Line 372... Line 338...
372
 
338
 
Line 592... Line 558...
592
		do{
558
		do{
593
			if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
559
			if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
594
			{
560
			{
595
				strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
561
				strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
596
				strlwr(#options);
562
				strlwr(#options);
597
				meta_encoding = _DEFAULT;
563
				meta_encoding = CH_NULL;
598
				if (!strcmp(#options, "utf-8"))  || (!strcmp(#options,"utf8")) meta_encoding = _UTF;
564
				if (!strcmp(#options, "utf-8"))             || (!strcmp(#options,"utf8"))         meta_encoding = CH_UTF8;
599
				if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) meta_encoding = _KOI;
565
				else if (!strcmp(#options, "koi8-r"))       || (!strcmp(#options, "koi8-u"))      meta_encoding = CH_KOI8;
600
				if (!strcmp(#options, "windows-1251")) || (!strcmp(#options, "windows1251")) meta_encoding = _WIN;
566
				else if (!strcmp(#options, "windows-1251")) || (!strcmp(#options, "windows1251")) meta_encoding = CH_CP1251;
-
 
567
				else if (!strcmp(#options, "windows-1252")) || (!strcmp(#options, "windows1252")) meta_encoding = CH_CP1252;
-
 
568
				else if (!strcmp(#options, "iso-8859-5"))   || (!strcmp(#options, "iso8859-5"))   meta_encoding = CH_ISO8859_5;
601
				if (!strcmp(#options, "dos"))    || (!strcmp(#options, "cp-866"))   meta_encoding = _DOS;
569
				else if (!strcmp(#options, "dos"))          || (!strcmp(#options, "cp-866"))      meta_encoding = CH_CP866;
602
				if (cur_encoding==_DEFAULT) BufEncode(meta_encoding);
570
				if (cur_encoding==CH_NULL) BufEncode(meta_encoding);
603
				return;
571
				return;
604
			}
572
			}
605
		} while(GetNextParam());
573
		} while(GetNextParam());
606
		return;
574
		return;
607
	}
575
	}
608
}
576
}
Line -... Line 577...
-
 
577
 
-
 
578
void BufEncode(int set_new_encoding)
-
 
579
{
-
 
580
	int bufpointer_realsize;
-
 
581
	cur_encoding = set_new_encoding;
-
 
582
	if (o_bufpointer==0)
-
 
583
	{
-
 
584
		o_bufpointer = malloc(bufsize);
-
 
585
		strcpy(o_bufpointer, bufpointer);
-
 
586
	}
-
 
587
	else
-
 
588
	{
-
 
589
		strcpy(bufpointer, o_bufpointer);
-
 
590
	}
-
 
591
	debugln(charsets[set_new_encoding]);
-
 
592
	bufpointer = ChangeCharset(charsets[set_new_encoding], "CP866", bufpointer);
-
 
593
}
-
 
594
 
609
 
595
 
610
void TWebBrowser::DrawScroller()
596
void TWebBrowser::DrawScroller()
611
{
597
{
612
	scroll_wv.max_area = list.count;
598
	scroll_wv.max_area = list.count;
613
	scroll_wv.cur_area = list.visible;
599
	scroll_wv.cur_area = list.visible;
Line 650... Line 636...
650
int isTag(dword text) 
636
int isTag(dword text) 
651
{ 
637
{ 
652
	if (!strcmp(#tag,text)) return 1; else return 0;
638
	if (!strcmp(#tag,text)) return 1; else return 0;
653
}
639
}
Line 654... Line -...
654
 
-
 
655
 
-
 
656
:dword Hex2Symb(char* htmlcolor)
-
 
657
{
-
 
658
  dword j=0, symbol=0;
-
 
659
  char ch=0x00;
-
 
660
  for (;j<2;j++)
-
 
661
  {
-
 
662
    ch=ESBYTE[htmlcolor+j];
-
 
663
    if (ch==0x0d) || (ch=='\9') RETURN 0;
-
 
664
    if ((ch>='0') && (ch<='9')) ch -= '0';
-
 
665
    if ((ch>='A') && (ch<='F')) ch -= 'A'-10;
-
 
666
    if ((ch>='a') && (ch<='f')) ch -= 'a'-10;
-
 
667
    symbol = symbol*0x10 + ch;
-
 
668
  }
-
 
669
  AL=symbol;
-
 
670
}
-