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;
	}
}
Beispiel #2
0
CSummInfo::CSummInfo()
{
	m_propSet.SetFormatVersion(0);
	DWORD dwOSVer;
	dwOSVer = (DWORD)MAKELONG(LOWORD(GetVersion()), 2);
	m_propSet.SetOSVersion(dwOSVer);
	m_propSet.SetClassID(FMTID_SummaryInformation);
	m_pSection = m_propSet.AddSection(FMTID_SummaryInformation);
	UINT cp = GetACP();
	m_pSection->Set(PID_CODEPAGE, (void*)&cp, VT_I2);
	SetTitle(_T(""));
	SetSubject(_T(""));
	SetAuthor(_T(""));
	SetKeywords(_T(""));
	SetComments(_T(""));
	SetTemplate(_T(""));
	SetLastAuthor(_T(""));
	m_pSection->Set(PIDSI_REVNUMBER, (void*)_T("0"), VT_LPSTR);
	FILETIME zeroTime = {0L, 0L};
	m_pSection->Set(PIDSI_EDITTIME, (void*)&zeroTime, VT_FILETIME);
	m_pSection->Set(PIDSI_LASTPRINTED, (void*)&zeroTime, VT_FILETIME);
	m_pSection->Set(PIDSI_LASTSAVE_DTM, (void*)&zeroTime, VT_FILETIME);
	m_pSection->Set(PIDSI_CREATE_DTM, (void*)&zeroTime, VT_FILETIME);
	SetNumPages(0);
	SetNumWords(0);
	SetNumChars(0);
	SetAppname(_T(""));
	SetSecurity(0);
}
Beispiel #3
0
void AHTMODEL::SetAHTOption( char *name, char *value )
{
    if (tstrcmp(name,"flag")) {
        int i;
        i = atoi( value );
        flag = i | AHTMODEL_FLAG_READY;
        return;
    }
    if (tstrcmp(name,"name")) {
        SetName( value );
        return;
    }
    if (tstrcmp(name,"class")) {
        SetClass( value );
        return;
    }
    if (tstrcmp(name,"author")) {
        SetAuthor( value );
        return;
    }
    if (tstrcmp(name,"ver")) {
        SetVersion( value );
        return;
    }
    if (tstrcmp(name,"icon")) {
        SetIconFile( value );
        return;
    }
    if (tstrcmp(name,"iconid")) {
        SetIconId( atoi( value ) );
        return;
    }
    if (tstrcmp(name,"exp")) {
        exp->PutStr( value );
        exp->PutCR();
        return;
    }
    if (tstrcmp(name,"helpkw")) {
        SetHelpKeyword( value );
        return;
    }
}
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;
}
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());
}
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;
	}
}