예제 #1
0
bool CLangData::ReadInfo(PCTSTR pszFile)
{
	try
	{
		Clear();

		icpf::config cfg(icpf::config::eIni);
		const uint_t uiLangName = cfg.register_string(_T("Info/Lang Name"), _t(""));
		const uint_t uiFontFace = cfg.register_string(_T("Info/Font Face"), _T(""));
		const uint_t uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff);
		const uint_t uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false);
		const uint_t uiHelpName = cfg.register_string(_T("Info/Help name"), _T(""));
		const uint_t uiAuthor = cfg.register_string(_T("Info/Author"), _T(""));
		const uint_t uiVersion = cfg.register_string(_T("Info/Format version"), _T("1"));

		cfg.read(pszFile);
		
		// we don't support old language versions
		const tchar_t* pszVersion = cfg.get_string(uiVersion);
		if(_tcscmp(pszVersion, TRANSLATION_FORMAT_VERSION) != 0)
			return false;

		const tchar_t* psz = cfg.get_string(uiLangName);
		if(!psz || psz[0] == _t('\0'))
			return false;
		SetLangName(psz);

		psz = cfg.get_string(uiFontFace);
		if(!psz || psz[0] == _t('\0'))
			return false;
		SetFontFace(psz);

		ll_t ll = cfg.get_signed_num(uiSize);
		if(ll == 0)
			return false;
		SetPointSize((WORD)ll);

		SetDirection(cfg.get_bool(uiRTL));

		psz = cfg.get_string(uiHelpName);
		if(!psz || psz[0] == _t('\0'))
			return false;
		SetHelpName(psz);

		psz = cfg.get_string(uiAuthor);
		if(!psz || psz[0] == _t('\0'))
			return false;
		SetAuthor(psz);

		SetFilename(pszFile);

		m_bModified = false;

		return true;
	}
	catch(...)
	{
		return false;
	}
}
예제 #2
0
CLangData& CLangData::operator=(const CLangData& rSrc)
{
	if(this != &rSrc)
	{
		SetFilename(rSrc.GetFilename(true));
		SetLangName(rSrc.GetLangName());
		SetFontFace(rSrc.GetFontFace());
		SetPointSize(rSrc.GetPointSize());
		SetDirection(rSrc.GetDirection());
		SetHelpName(rSrc.GetHelpName());
		SetAuthor(rSrc.GetAuthor());
		m_bRTL = rSrc.m_bRTL;
		m_bUpdating = rSrc.m_bUpdating;
		m_uiSectionID = rSrc.m_uiSectionID;
		m_wPointSize = rSrc.m_wPointSize;
		m_bModified = false;

		m_mapTranslation.insert(rSrc.m_mapTranslation.begin(), rSrc.m_mapTranslation.end());
	}

	return *this;
}
예제 #3
0
CLangData::CLangData(const CLangData& ld) :
	m_pszFilename(NULL),
	m_pszLngName(NULL),
	m_pszFontFace(NULL),
	m_pszHelpName(NULL),
	m_pszAuthor(NULL),
	m_bRTL(ld.m_bRTL),
	m_bUpdating(ld.m_bUpdating),
	m_uiSectionID(ld.m_uiSectionID),
	m_wPointSize(ld.m_wPointSize),
	m_bModified(false)
{
	SetFilename(ld.GetFilename(true));
	SetLangName(ld.GetLangName());
	SetFontFace(ld.GetFontFace());
	SetPointSize(ld.GetPointSize());
	SetDirection(ld.GetDirection());
	SetHelpName(ld.GetHelpName());
	SetAuthor(ld.GetAuthor());

	m_mapTranslation.insert(ld.m_mapTranslation.begin(), ld.m_mapTranslation.end());
}
예제 #4
0
void CairoRenderer::RenderOperator(const Operator *pOp, const Object **pParams, int nParams)
{
	const char *cstr;
	double x, y;
	double v[6];
	int i, n;
	const Object *pObj;
	const Stream *pStream;
	const Dictionary *pDict;
	cairo_matrix_t matrix;
	int nWidth, nHeight;
	cairo_surface_t *pSurface;

	cstr = pOp->GetValue();

	if (strchr("fFbBW", *cstr) != NULL)
		if (cstr[1] == '\0')
			cairo_set_fill_rule(m_pCairo, CAIRO_FILL_RULE_WINDING);
		else if (cstr[1] == '*')
			cairo_set_fill_rule(m_pCairo, CAIRO_FILL_RULE_EVEN_ODD);

	if (*cstr == 'b')  //close, fill, and stroke
	{
		cairo_close_path(m_pCairo);
		cairo_fill(m_pCairo);
		Stroke();
	}
	else if (strcmp(cstr, "B") == 0 || strcmp(cstr, "B*") == 0)  //fill and stroke
	{
		cairo_fill(m_pCairo);
		Stroke();
	}
	else if (strcmp(cstr, "BDC") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "BI") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "BMC") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "BT") == 0)
	{
		cairo_save(m_pCairo);
		cairo_move_to(m_pCairo, 0.0, 0.0);
		m_cairo_face = NULL;
	}
	else if (strcmp(cstr, "BX") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "c") == 0)  //curve to
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_curve_to(m_pCairo, v[0], v[1], v[2], v[3], v[4], v[5]);
	}
	else if (strcmp(cstr, "cm") == 0)  //concat
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_matrix_init(&matrix, v[0], v[1], v[2], v[3], v[4], v[5]);
		cairo_transform(m_pCairo, &matrix);
	}
	else if (strcmp(cstr, "CS") == 0)  //color space
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "cs") == 0)  //color space
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "d") == 0)  //line dash
		SetDash(pParams[0], pParams[1]);
	else if (strcmp(cstr, "d0") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "d1") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "Do") == 0)
	{
		pStream = (const Stream *)GetResource(XOBJECT, ((Name *)pParams[0])->GetValue());
		pDict = pStream->GetDictionary();
		pObj = pDict->GetValue("Subtype");
		if (strcmp(((const Name *)pObj)->GetValue(), "Image") == 0)
		{
			nWidth = ((const Numeric *)pDict->GetValue("Width"))->GetValue();
			nHeight = ((const Numeric *)pDict->GetValue("Height"))->GetValue();
			cairo_matrix_init(&matrix, 1.0 / nWidth, 0.0, 0.0, -1.0 / nHeight, 0.0, 1.0);
			cairo_save(m_pCairo);
			cairo_transform(m_pCairo, &matrix);
			cairo_rectangle(m_pCairo, 0.0, 0.0, nWidth, nHeight);
			cairo_clip(m_pCairo);
			pSurface = CreateImageSurface(pStream, nWidth, nHeight);
			cairo_set_source_surface(m_pCairo, pSurface, 0.0, 0.0);
			cairo_paint(m_pCairo);
			cairo_surface_destroy(pSurface);
			cairo_restore(m_pCairo);
		}
	}
	else if (strcmp(cstr, "DP") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "EI") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "EMC") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "ET") == 0)
	{
		cairo_restore(m_pCairo);
		if (m_cairo_face)
		{
			cairo_set_font_face(m_pCairo, NULL);
			cairo_font_face_destroy(m_cairo_face);
		}
	}
	else if (strcmp(cstr, "EX") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (*cstr == 'f' || *cstr == 'F')  //fill
		cairo_fill(m_pCairo);
	else if (strcmp(cstr, "G") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		m_pStrokeColor[0] = v[0];
		m_pStrokeColor[1] = v[0];
		m_pStrokeColor[2] = v[0];
	}
	else if (strcmp(cstr, "g") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_source_rgba(m_pCairo, v[0], v[0], v[0], 1.0);
	}
	else if (strcmp(cstr, "gs") == 0)  //set graphics state
		SetGraphicsState(((const Name *)pParams[0])->GetValue());
	else if (strcmp(cstr, "h") == 0)  //close subpath
		cairo_close_path(m_pCairo);
	else if (strcmp(cstr, "i") == 0)  //flatness tolerance
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_tolerance(m_pCairo, v[0]);
	}
	else if (strcmp(cstr, "ID") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "j") == 0)  //line join
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_line_join(m_pCairo, (cairo_line_join_t)v[0]);
	}
	else if (strcmp(cstr, "J") == 0)  //line cap
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_line_cap(m_pCairo, (cairo_line_cap_t)v[0]);
	}
	else if (strcmp(cstr, "K") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		m_pStrokeColor[0] = (1.0 - v[0]) * (1.0 - v[3]);
		m_pStrokeColor[1] = (1.0 - v[1]) * (1.0 - v[3]);
		m_pStrokeColor[2] = (1.0 - v[2]) * (1.0 - v[3]);
	}
	else if (strcmp(cstr, "k") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_source_rgba(m_pCairo, (1.0 - v[0]) * (1.0 - v[3]), (1.0 - v[1]) * (1.0 - v[3]), (1.0 - v[2]) * (1.0 - v[3]), 1.0);
	}
	else if (strcmp(cstr, "l") == 0)  //line to
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_line_to(m_pCairo, v[0], v[1]);
	}
	else if (strcmp(cstr, "m") == 0)  //new sub path
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_move_to(m_pCairo, v[0], v[1]);
	}
	else if (strcmp(cstr, "M") == 0)  //miter limit
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_miter_limit(m_pCairo, v[0]);
	}
	else if (strcmp(cstr, "MP") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "n") == 0)  //end path
		cairo_new_path(m_pCairo);
	else if (strcmp(cstr, "q") == 0)  //save graphics state
		cairo_save(m_pCairo);
	else if (strcmp(cstr, "Q") == 0)  //restore graphics state
		cairo_restore(m_pCairo);
	else if (strcmp(cstr, "re") == 0)  //rectangle
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_rectangle(m_pCairo, v[0], v[1], v[2], v[3]);
	}
	else if (strcmp(cstr, "RG") == 0)
	{
		ConvertNumeric(pParams, nParams, m_pStrokeColor);
	}
	else if (strcmp(cstr, "rg") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_source_rgba(m_pCairo, v[0], v[1], v[2], 1.0);
	}
	else if (strcmp(cstr, "ri") == 0)  //color rendering intent
		SetIntent(((const Name *)pParams[0])->GetValue());
	else if (strcmp(cstr, "s") == 0)  //close and stroke
	{
		cairo_close_path(m_pCairo);
		Stroke();
	}
	else if (strcmp(cstr, "S") == 0)  //stroke
		Stroke();
	else if (strcmp(cstr, "SC") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "sc") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "SCN") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "scn") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "sh") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "T*") == 0)
	{
		cairo_translate(m_pCairo, 0.0, -m_dTextLead);
		cairo_move_to(m_pCairo, 0.0, 0.0);
	}
	else if (strcmp(cstr, "Tc") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "Td") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_translate(m_pCairo, v[0], v[1]);
		cairo_move_to(m_pCairo, 0.0, 0.0);
	}
	else if (strcmp(cstr, "TD") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_translate(m_pCairo, v[0], v[1]);
		cairo_move_to(m_pCairo, 0.0, 0.0);
		m_dTextLead = -v[1];
	}
	else if (strcmp(cstr, "Tf") == 0)
	{
		ChangeFont(((const Name *)pParams[0])->GetValue());
		SetFontFace(m_pFontData->GetFontFile());

		ConvertNumeric(pParams + 1, nParams - 1, v);
		cairo_matrix_init_scale(m_pFontMatrix, v[0], -v[0]);
		cairo_set_font_matrix(m_pCairo, m_pFontMatrix);
	}
	else if (strcmp(cstr, "Tj") == 0)
		RenderString((const String *)pParams[0]);
	else if (strcmp(cstr, "TJ") == 0)
	{
		n = ((const Array *)pParams[0])->GetSize();
		for (i = 0; i < n; i++)
		{
			pObj = ((const Array *)pParams[0])->GetValue(i);
			if (pObj->GetType() == Object::OBJ_STRING)
				RenderString((const String *)pObj);
			else if (pObj->GetType() == Object::OBJ_NUMERIC)
				cairo_translate(m_pCairo, -((const Numeric *)pObj)->GetValue() / 1000.0, 0.0);
		}
	}
	else if (strcmp(cstr, "TL") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		m_dTextLead = v[0];
	}
	else if (strcmp(cstr, "Tm") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_matrix_init(&matrix, v[0], v[1], v[2], v[3], v[4], v[5]);
		cairo_matrix_multiply(&matrix, m_pFontMatrix, &matrix);
		cairo_set_font_matrix(m_pCairo, &matrix);
		cairo_move_to(m_pCairo, 0.0, 0.0);
	}
	else if (strcmp(cstr, "Tr") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		m_nTextMode = v[0];
	}
	else if (strcmp(cstr, "Ts") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "Tw") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "Tz") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_scale(m_pCairo, v[0] / 100.0, 1.0);
	}
	else if (strcmp(cstr, "v") == 0)  //curve to
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_get_current_point(m_pCairo, &x, &y);
		cairo_curve_to(m_pCairo, x, y, v[0], v[1], v[2], v[3]);
	}
	else if (strcmp(cstr, "w") == 0)  //line width
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_line_width(m_pCairo, v[0] + 0.5);
	}
	else if (*cstr == 'W')  //clipping path
		cairo_clip(m_pCairo);
	else if (strcmp(cstr, "y") == 0)  //curve to
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_curve_to(m_pCairo, v[0], v[1], v[2], v[3], v[2], v[3]);
	}
	else if (strcmp(cstr, "'") == 0)
	{
		cairo_translate(m_pCairo, 0.0, -m_dTextLead);
		cairo_move_to(m_pCairo, 0.0, 0.0);
		RenderString((const String *)pParams[0]);
	}
	else if (strcmp(cstr, "\"") == 0)
	{
		cairo_translate(m_pCairo, 0.0, -m_dTextLead);
		cairo_move_to(m_pCairo, 0.0, 0.0);
		RenderString((const String *)pParams[2]);
	}
	else
	{
		assert(false);
	}
}
예제 #5
0
bool CLangData::ReadTranslation(PCTSTR pszFile, bool bUpdateTranslation, bool bIgnoreVersion)
{
	try
	{
		if(!bUpdateTranslation)
			Clear();

		// load data from file
		icpf::config cfg(icpf::config::eIni);
		const uint_t uiLangName = cfg.register_string(_T("Info/Lang Name"), _t(""));
		const uint_t uiFontFace = cfg.register_string(_T("Info/Font Face"), _T(""));
		const uint_t uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff);
		const uint_t uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false);
		const uint_t uiHelpName = cfg.register_string(_T("Info/Help name"), _T(""));
		const uint_t uiAuthor = cfg.register_string(_T("Info/Author"), _T(""));
		const uint_t uiVersion = cfg.register_string(_T("Info/Format version"), _T("1"));

		cfg.read(pszFile);

		// we don't support old language versions unless requested specifically
		if(!bIgnoreVersion)
		{
			const tchar_t* pszVersion = cfg.get_string(uiVersion);
			if(_tcscmp(pszVersion, TRANSLATION_FORMAT_VERSION) != 0)
				return false;
		}

		const tchar_t* psz = cfg.get_string(uiLangName);
		if(!psz || psz[0] == _t('\0'))
			return false;
		SetLangName(psz);

		psz = cfg.get_string(uiFontFace);
		if(!psz || psz[0] == _t('\0'))
			return false;
		SetFontFace(psz);

		ll_t ll = cfg.get_signed_num(uiSize);
		if(ll == 0)
			return false;
		SetPointSize((WORD)ll);

		SetDirection(cfg.get_bool(uiRTL));

		psz = cfg.get_string(uiHelpName);
		if(!psz || psz[0] == _t('\0'))
			return false;
		SetHelpName(psz);

		psz = cfg.get_string(uiAuthor);
		if(!psz || psz[0] == _t('\0'))
			return false;
		SetAuthor(psz);

		m_bUpdating = bUpdateTranslation;
		m_uiSectionID = 0;
		if(!cfg.enum_properties(_t("*"), EnumAttributesCallback, this))
		{
			m_bUpdating = false;
			return false;
		}
		m_bUpdating = false;

		SetFilename(pszFile);

		m_bModified = false;

		return true;
	}
	catch(...)
	{
		return false;
	}
}