Exemple #1
0
void web_page::import_css( litehtml::tstring& text, const litehtml::tstring& url, litehtml::tstring& baseurl )
{
	std::wstring css_url;
	t_make_url(url.c_str(), baseurl.c_str(), css_url);

	if(download_and_wait(css_url.c_str()))
	{
#ifndef LITEHTML_UTF8
		LPWSTR css = load_text_file(m_waited_file.c_str(), false, L"UTF-8");
		if(css)
		{
			baseurl = css_url;
			text = css;
			delete css;
		}
#else
		LPSTR css = (LPSTR) load_utf8_file(m_waited_file.c_str(), false, L"UTF-8");
		if(css)
		{
			LPSTR css_urlA = cairo_font::wchar_to_utf8(css_url.c_str());
			baseurl = css_urlA;
			text = css;
			delete css;
			delete css_urlA;
		}
#endif
	}
}
void cairo_container::transform_text( litehtml::tstring& text, litehtml::text_transform tt )
{
	if(text.empty()) return;

#ifndef LITEHTML_UTF8
	switch(tt)
	{
	case litehtml::text_transform_capitalize:
		if(!text.empty())
		{
			text[0] = (WCHAR) CharUpper((LPWSTR) text[0]);
		}
		break;
	case litehtml::text_transform_uppercase:
		for(size_t i = 0; i < text.length(); i++)
		{
			text[i] = (WCHAR) CharUpper((LPWSTR) text[i]);
		}
		break;
	case litehtml::text_transform_lowercase:
		for(size_t i = 0; i < text.length(); i++)
		{
			text[i] = (WCHAR) CharLower((LPWSTR) text[i]);
		}
		break;
	}
#else
	LPWSTR txt = cairo_font::utf8_to_wchar(text.c_str());
	switch(tt)
	{
	case litehtml::text_transform_capitalize:
		CharUpperBuff(txt, 1);
		break;
	case litehtml::text_transform_uppercase:
		CharUpperBuff(txt, lstrlen(txt));
		break;
	case litehtml::text_transform_lowercase:
		CharLowerBuff(txt, lstrlen(txt));
		break;
	}
	LPSTR txtA = cairo_font::wchar_to_utf8(txt);
	text = txtA;
	delete txtA;
	delete txt;
#endif
}
void bb_litehtml_document_container::import_css( litehtml::tstring &text,const litehtml::tstring &url,litehtml::tstring &baseurl ){

	bbString css=_import_css( url.c_str(),"" );
	
	text=css.c_str();
//	text=static_cast<const litehtml::tchar_t*>( css );

	baseurl="";
}
Glib::RefPtr< Gio::InputStream > http_loader::load_file(const litehtml::tstring& url)
{
    m_url = url;

    Glib::RefPtr< Gio::MemoryInputStream > stream = Gio::MemoryInputStream::create();

    if(m_curl)
    {
        curl_easy_setopt(m_curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, &stream);
        curl_easy_perform(m_curl);
        char* new_url = NULL;
        if(curl_easy_getinfo(m_curl, CURLINFO_EFFECTIVE_URL, &new_url) == CURLE_OK)
        {
            if(new_url)
            {
                m_url = new_url;
            }
        }
    }

    return stream;
}