Exemplo n.º 1
0
// converting diacritic marks
void  CColorRichEditView::SetText(const CString& S)
{
	CStringAndPosition SP;
	SP.m_BufferLength = MultiByteToWideChar(GetCodePage(), 0,(const char*)S, S.GetLength(), NULL, NULL);
	SP.m_pBuffer = new char[SP.m_BufferLength*2+1];
	memset(SP.m_pBuffer,0, SP.m_BufferLength*2+1);
	int debug = S.GetLength();
	assert (debug  == SP.m_BufferLength);
	if (S.GetLength()>0)
	{
		if (!MultiByteToWideChar(GetCodePage(), 0, (const char*)S, S.GetLength(), (WCHAR*)SP.m_pBuffer, SP.m_BufferLength))
		{
			ErrorMessage ("MultiByteToWideChar failed");
		};
	}
	
				

	SP.m_Position = 0;
	EDITSTREAM es;
	es.dwCookie = (DWORD) &SP;
	es.pfnCallback = MyStreamInCallback; 
	SP.m_BufferLength *= 2;
	GetRichEditCtrl().StreamIn(SF_TEXT|SF_UNICODE, es);
};
Exemplo n.º 2
0
int KItemNull::Init(KItemNullData & ItemNullData)
{
    if (ItemNullData.wszName[0] != L'\0')
        SetName(ATL::CW2A(ItemNullData.wszName, GetCodePage()));
    
    m_nLink = ItemNullData.nLink;
    if (m_nLink)
        SetLinkInfo(ATL::CW2A(ItemNullData.wszLinkInfo, GetCodePage()));

    m_dwPosType = static_cast<DWORD>(ItemNullData.nPosType);
	SetRelPos(ItemNullData.fRelX, ItemNullData.fRelY);
	SetSize(ItemNullData.fWidth, ItemNullData.fHeight);
	SetAlpha(ItemNullData.nAlpha);
	m_nTipIndex = ItemNullData.nTipIndex;

	if (ItemNullData.nDisableScale)
	{
		EnableScale(false);
		m_fRelX *= ItemNullData.fScale;
		m_fRelY *= ItemNullData.fScale;
	}
	else
	{
		m_fRelX *= ItemNullData.fScale;
		m_fRelY *= ItemNullData.fScale;
		m_fWidth *= ItemNullData.fScale;
		m_fHeight *= ItemNullData.fScale;
	}
	if (ItemNullData.nLockShowAndHide)
	{
		Hide();
		LockShowAndHide(true);
	}

	m_fUserData = ItemNullData.fUserData;

    if (ItemNullData.pEventOwner)
	{
		ItemNullData.pEventOwner->UpdateDrawList();
		if(ItemNullData.dwEventID)
		{
			m_dwEvent = ItemNullData.dwEventID;
			ItemNullData.pEventOwner->UpdateEvent();
		}
	}

	m_nAreaIndex = ItemNullData.nAreaTestIndex;

	if (ItemNullData.nIntPos)
		SetIntPos(true);

    return true;
}
Exemplo n.º 3
0
/*------------------------------------------------
  get locale information by ANSI
--------------------------------------------------*/
int MyGetLocaleInfoA(int ilang, int codepage,
	LCTYPE lctype, char* dst, int n)
{
	int r;
	LCID locale;
	
	*dst = 0;
	locale = MAKELCID((WORD)ilang, SORT_DEFAULT);
	
	if(GetVersion() & 0x80000000) // 95/98/Me
		r = GetLocaleInfoA(locale, lctype, dst, n);
	else  // NT4/2000/XP
	{
		WCHAR buf[80];
		r = GetLocaleInfoW(locale, lctype, buf, 80);
		if(r)
		{
			int codepage = GetCodePage(GetUserDefaultLangID());
			r = WideCharToMultiByte(codepage, 0, buf, -1, dst, n,
				NULL, NULL);
		}
	}
	
	return r;
}
Exemplo n.º 4
0
    //--------------------------------------------------------------------------------
    CUTF16String::CUTF16String( const CTString< CChar16, CDefaultSource >& Src ) : m_String( Src )
    {
		if( GetCodePage() != CCodePage::eUTF8 )
		{
			operator = ( CUTF32String( *this ).ToUTF16String() );
		}
    }
Exemplo n.º 5
0
BOOL Open2(const TCHAR *FileName, 
		   const TCHAR *Section,
		   INT FileType, 
		   const TCHAR *Value,
		   XCONNECTDATA *ConnectInfo)
{
	TRACE_FUNCTION_INFO;
	if (ConnectInfo->bLogOpened)
		return FALSE;

	ConnectInfo->Init();
	ConnectInfo->iCodePage = GetCodePage();
	if (!Open3(FileName, Section, FileType, Value, ConnectInfo->iCodePage, 
		ConnectInfo->strLogName, ConnectInfo->TempFile, ConnectInfo->XFile))
		return FALSE;

	if (!ConnectInfo->MemWriter.Create(ConnectInfo->strLogName))
		return FALSE;

	StringCopy(ConnectInfo->cConfigValue, MAX_CONFIG_VALUE_SIZE, Value);
	StringCopy(ConnectInfo->cConfigFile, MAX_PATH, FileName);
	StringCopy(ConnectInfo->cSection, MAX_PATH, Section);

	ConnectInfo->iFileType  = FileType;
	ConnectInfo->iLevel     = logDebug;
	ConnectInfo->bLogOpened = TRUE;

	return TRUE;
}
Exemplo n.º 6
0
	//--------------------------------------------------------------------------------
	CUTF16String& CUTF16String::operator = ( CTString< CChar16, CDefaultSource >::ref_type Src )
	{
		m_String = Src;
		if( GetCodePage() != CCodePage::eUTF8 )
		{
			operator = ( CUTF32String( *this ).ToUTF16String() );
		}
		return *this;
	}
Exemplo n.º 7
0
// FindLocaleDirectory:  Search the provided path for one of the expected code page subdirectories
// Returns empty string on failure, or the full path to the c:\my\directory\1033\myrcfile.dll
static MyString FindLocaleDirectory(const MyString &path, const MyString &dllName)
{
    // We'll be checking for 3 different locales:  The user's default locale
    // The user's primary language locale, and english (in that order)
    const LCID lcidUser = MAKELCID(GetUserDefaultUILanguage(), SORT_DEFAULT);
    LCID rglcid[3] = {lcidUser, MAKELCID(MAKELANGID(PRIMARYLANGID(lcidUser), SUBLANG_DEFAULT), SORTIDFROMLCID(lcidUser)), ENGLISH_LCID};

    for (int i = 0; i < _countof(rglcid); i++)
    {
        LCID lcid = rglcid[i];
        // Turn the LCID into a string
        wchar_t wzNumBuf[12];
        _itow_s(lcid, wzNumBuf, _countof(wzNumBuf), 10);
        MyString localePath = MakePath(path, wzNumBuf, dllName);

        // Check to see if the file exists
        if (FileExists(localePath))
        {
            // make sure the console can support a codepage for this language.
            UINT ConsoleCP = GetConsoleOutputCP();
            
            // Dev10 #843375: For a GUI application, GetConsoleOutputCP returns 0
            // If that's the case, we don't care about capabilities of the console, 
            // since we're not outputting to the console, anyway...
            if ( ConsoleCP != 0 && lcid != ENGLISH_LCID )
            {
                LANGID LanguageID = MAKELANGID( lcid, SUBLANGID(lcid) );
                // we know the console cannot support arabic or hebrew (right to left scripts?)
                if( PRIMARYLANGID(LanguageID) == LANG_ARABIC || PRIMARYLANGID(LanguageID) == LANG_HEBREW )
                    continue;

                UINT LangOEMCodepage = GetCodePage(LanguageID, LOCALE_IDEFAULTCODEPAGE);
                UINT LangANSICodepage = GetCodePage(LanguageID, LOCALE_IDEFAULTANSICODEPAGE);

                // We can only support it if the console's code page is UTF8, OEM, or ANSI
                if( ConsoleCP != CP_UTF8 && ConsoleCP != LangOEMCodepage && ConsoleCP != LangANSICodepage )
                    continue;
            }

            return localePath;
        }
    }
    return W("");
}
Exemplo n.º 8
0
int CodePage::c_specialchars(int argc, const char * argv[], void * param)
{
	for (int i=1;i < argc;i++)
	{
		const char * chars = argv[i];
		while (*chars)
		{
			GetCodePage()->AddChar(UTFtoUnicode(chars));
		}
	}
	return 0;
}
Exemplo n.º 9
0
void Edit::OnUseCharset (wxCommandEvent &event) {
    int Nr;
    int charset = GetCodePage();
    switch (event.GetId()) {
        case myID_CHARSETANSI: {charset = wxSTC_CHARSET_ANSI; break;}
        case myID_CHARSETMAC: {charset = wxSTC_CHARSET_ANSI; break;}
    }
    for (Nr = 0; Nr < wxSTC_STYLE_LASTPREDEFINED; Nr++) {
        StyleSetCharacterSet (Nr, charset);
    }
    SetCodePage (charset);
}
Exemplo n.º 10
0
void CharMap::SplitCodePage(wxUint32 splitCodeFirst)
{
	CodePage *page = GetCodePage(splitCodeFirst);
	if (page == NULL || page->GetRangeStart() == splitCodeFirst) {
		return;
	}
	CodePage oldPage(*page);
	CodePage newPage(*page, splitCodeFirst, page->GetRangeEnd());
	RemoveCodePage(page);
	// Todo: delete only present glyphs
	for (wxUint32 i = splitCodeFirst; i <= oldPage.GetRangeEnd(); i++) {
		oldPage.Remove(i);
	}
	oldPage.SetEnd(splitCodeFirst - 1);
	AddCodePage(oldPage);
	AddCodePage(newPage);
}
Exemplo n.º 11
0
//********************************************************************
static Byte DbfLanguage()
{
// Код языка в заголовке DBF-файла

	long cp = GetCodePage();
	switch(cp)
		{
		case 437:	return 0x01;	// DOS USA
		case 850:	return 0x02;	// DOS Multilingual
		case 1251:	return 0x03;	// Windows ANSI
		case 1250:	return 0xC8;	// Windows EE
		case 852:	return 0x64;	// DOS USA
		case 866:	return 0x66;	// Russian DOS
		case 865:	return 0x65;	// Nordic DOS
		}

	return 0;
}
Exemplo n.º 12
0
bool CItem::IsDir() const
{
    if (NItemName::HasTailSlash(Name, GetCodePage()))
        return true;
    if (!FromCentral)
        return false;
    WORD highAttributes = WORD((ExternalAttributes >> 16 ) & 0xFFFF);
    switch(MadeByVersion.HostOS)
    {
    case NFileHeader::NHostOS::kAMIGA:
        switch (highAttributes & NFileHeader::NAmigaAttribute::kIFMT)
        {
        case NFileHeader::NAmigaAttribute::kIFDIR:
            return true;
        case NFileHeader::NAmigaAttribute::kIFREG:
            return false;
        default:
            return false; // change it throw kUnknownAttributes;
        }
    case NFileHeader::NHostOS::kFAT:
    case NFileHeader::NHostOS::kNTFS:
    case NFileHeader::NHostOS::kHPFS:
    case NFileHeader::NHostOS::kVFAT:
        return ((ExternalAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
    case NFileHeader::NHostOS::kAtari:
    case NFileHeader::NHostOS::kMac:
    case NFileHeader::NHostOS::kVMS:
    case NFileHeader::NHostOS::kVM_CMS:
    case NFileHeader::NHostOS::kAcorn:
    case NFileHeader::NHostOS::kMVS:
        return false; // change it throw kUnknownAttributes;
    default:
        /*
        switch (highAttributes & NFileHeader::NUnixAttribute::kIFMT)
        {
          case NFileHeader::NUnixAttribute::kIFDIR:
            return true;
          default:
            return false;
        }
        */
        return false;
    }
}
Exemplo n.º 13
0
	BOOL KColorSchemeMgr::Init()
	{
		KSmartTabFile TabFile;
		LPCSTR szFilePath = NULL;
		int nRowCount = 0;
		KColorScheme* pScheme = NULL;
		
		szFilePath = g_pUI->m_FilePathMgr.GetFilePath("SchemeElemColor");
        KGLOG_PROCESS_ERROR(szFilePath);

		TabFile = g_OpenTabFile(szFilePath);
		KGLOG_PROCESS_ERROR(TabFile);

		m_nSchemeCount = TabFile->GetHeight() - 1;
		KGLOG_PROCESS_ERROR(m_nSchemeCount > 0);

		pScheme = (KColorScheme*)realloc(m_pScheme, sizeof(KColorScheme) * m_nSchemeCount);
		KGLOG_PROCESS_ERROR(pScheme);

		m_pScheme = pScheme;

		for (int nIndex = 0; nIndex < (int)m_nSchemeCount; ++nIndex)
		{
			char szName[COLOR_NAME_MAX_LEN] = { 0 };
			int	nRed = 0;
			int nGreen = 0;
			int nBlue = 0;

			TabFile->GetString(nIndex + 2, "name", "", szName, _countof(szName));
			TabFile->GetInteger(nIndex + 2, "r", 0, &nRed);
			TabFile->GetInteger(nIndex + 2, "g", 0, &nGreen);
			TabFile->GetInteger(nIndex + 2, "b", 0, &nBlue);

			wcsncpy(m_pScheme[nIndex].wszSchemeName, ATL::CA2W(szName, GetCodePage()), COLOR_NAME_MAX_LEN - 1);
			m_pScheme[nIndex].wszSchemeName[COLOR_NAME_MAX_LEN - 1] = L'\0';

			m_pScheme[nIndex].dwColor = D3DCOLOR_XRGB((BYTE)nRed, (BYTE)nGreen, (BYTE)nBlue);
		}

		return TRUE;
Exit0:
		return FALSE;
	}
Exemplo n.º 14
0
// converting diacritic marks
CString CColorRichEditView::GetText() const
{
	CRichEditCtrl& re = GetRichEditCtrl();
	int TextLen = re.GetTextLength();
	CStringAndPosition SP;
	SP.m_pBuffer = new char[TextLen*2];
	EDITSTREAM es;
	es.dwCookie = (DWORD) &SP;
	es.pfnCallback = MyStreamOutCallback; 
	GetRichEditCtrl().StreamOut(SF_TEXT|SF_UNICODE, es);
	char* buf = new char[TextLen+1];
	if (!WideCharToMultiByte(GetCodePage(), 0, (WCHAR*)SP.m_pBuffer, TextLen, buf, TextLen, NULL, NULL))
	{
		ErrorMessage ("WideCharToMultiByte failed");
	};
	buf[TextLen] =0;
	CString S = buf;
	delete buf;
	return S;
};
Exemplo n.º 15
0
bool CItem::IsDir() const
{
  if (NItemName::HasTailSlash(Name, GetCodePage()))
    return true;
  if (!FromCentral)
    return false;
  
  UInt16 highAttrib = (UInt16)((ExternalAttrib >> 16 ) & 0xFFFF);

  Byte hostOS = GetHostOS();
  switch (hostOS)
  {
    case NHostOS::kAMIGA:
      switch (highAttrib & NAmigaAttrib::kIFMT)
      {
        case NAmigaAttrib::kIFDIR: return true;
        case NAmigaAttrib::kIFREG: return false;
        default: return false; // change it throw kUnknownAttributes;
      }
    case NHostOS::kFAT:
    case NHostOS::kNTFS:
    case NHostOS::kHPFS:
    case NHostOS::kVFAT:
      return ((ExternalAttrib & FILE_ATTRIBUTE_DIRECTORY) != 0);
    case NHostOS::kAtari:
    case NHostOS::kMac:
    case NHostOS::kVMS:
    case NHostOS::kVM_CMS:
    case NHostOS::kAcorn:
    case NHostOS::kMVS:
      return false; // change it throw kUnknownAttributes;
    case NHostOS::kUnix:
      return (highAttrib & NUnixAttrib::kIFDIR) != 0;
    default:
      return false;
  }
}
Exemplo n.º 16
0
//********************************************************************
Bool UpdateActiveCodeTable()
{
// ¬ыбор кодовой таблицы дл¤ комбинации "¤зык - кодировка"

	// »ндекс в code_table[]
	long indexCodeTable = 1;
	switch(gActiveCode)
		{
		case ROUT_CODE_ASCII: indexCodeTable  = 0; break;
		case ROUT_CODE_ANSI:  indexCodeTable  = 1; break;
		case ROUT_CODE_KOI8R: indexCodeTable  = 2; break;
		case ROUT_CODE_ISO:   indexCodeTable  = 3; break;
		case ROUT_CODE_UTF8:   indexCodeTable  = 1; break; // use ansi code table, convert to utf8 later
		}

	gActiveCodeTable = code_table[indexCodeTable ][gLanguage];
	if ( !gActiveCodeTable )
		{
		NOT_IMPLEMENTED;
		return FALSE;
		}
	// —пециальна¤ настройка ASCIII дл¤ ”збекского и  азахского
	if (gActiveCode == ROUT_CODE_ASCII)
		{
		//  орректное сохранение и восстановление
		// оригинальной таблицы. 17.10.98  E.P.
		static uchar saveTable_cyr[256] = {0};
		static uchar wasHere = 0;

		if (!wasHere)
			{
			memcpy(saveTable_cyr,  ascii_cyr,  256);
			wasHere=1;
			}
		else
			{
			memcpy(ascii_cyr,  saveTable_cyr,  256);
			}

		// Change ascii_cyr for Uzbek language. 06.05.98 E.P.
		if (langUzbek)
			{
			// ѕо информации из секции [TigerToUserCharSet] REC6UZB.DAT
			if ( gCountTigerToUserCharSet )
				ChangeUserFontToAscii();
			else  // ѕерекодировка из шрифта "PANDA Courier UZ" в DOS-кодировку
				{
				// Argument is in "PANDA Courier UZ" coding for Uzbek.
				// Value is in Uzbek DOS Lexicon coding.
				// PANDA --> ASCII
				ascii_cyr[140]=242;   // UZBEK_UU
				ascii_cyr[156]=243;   // UZBEK_u
				ascii_cyr[138]=244;   // UZBEK_KK
				ascii_cyr[154]=245;   // UZBEK_k
				ascii_cyr[128]=246;   // UZBEK_GG
				ascii_cyr[144]=247;   // UZBEK_g
				ascii_cyr[141]=248;   // UZBEK_XX
				ascii_cyr[157]=249;   // UZBEK_x
				}
			}

		// ƒл¤ центральноевропейских ¤зыков. 05.09.2000 E.P.
		long codePage = GetCodePage();
		if (codePage == 852)
			fromcp1250_to_cp852();

		// Change ascii_cyr for Kazakh language. 17.08.98 E.P.
		if (langKaz)
			{
			// ѕо информации из секции [TigerToUserCharSet] REC6KAZ.DAT
			if ( gCountTigerToUserCharSet )
				ChangeUserFontToAscii();
			else
				{
				// Argument is in "Usual New Kazakh" font coding.
				// Value is in KeyKaz DOS driver coding.
				// "Usual New Kazakh"--> DOS
				ascii_cyr[162]=240;   // KAZ_AA
				ascii_cyr[173]=241;   // KAZ_GG
				ascii_cyr[188]=242;   // KAZ_KK
				ascii_cyr[168]=243;   // KAZ_NN
				ascii_cyr[164]=244;   // KAZ_OO
				ascii_cyr[184]=245;   // KAZ_YY1
				ascii_cyr[176]=246;   // KAZ_YY2
				ascii_cyr[190]=247;   // KAZ_HH
				ascii_cyr[161]=248;   // KAZ_a
				ascii_cyr[172]=249;   // KAZ_g
				ascii_cyr[186]=250;   // KAZ_k
				ascii_cyr[166]=251;   // KAZ_n
				ascii_cyr[163]=252;   // KAZ_o
				ascii_cyr[181]=253;   // KAZ_y1
				ascii_cyr[175]=254;   // KAZ_y2
				ascii_cyr[189]='h';   // KAZ_h
				}
			}
		}

	// ƒл¤ ‘ранцузского Windows специально обрабатываютс¤
	// символы, набираемые на клавиатуре
	if (gWinFrench)
		{
		gActiveCodeTable[0x91/*KEY_D5*/] = 0xd5;
		gActiveCodeTable[0x92/*KEY_D7*/] = 0xd7;
		gActiveCodeTable[0x93/*KEY_D8*/] = 0xd8;
		}

	return TRUE;

}
Exemplo n.º 17
0
uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) {
  return GetCodePage();
}
Exemplo n.º 18
0
bool CLocalItem::IsDir() const
{
  return NItemName::HasTailSlash(Name, GetCodePage());
}
Exemplo n.º 19
0
CMainApp::Error_Codes CMainApp::ParseCommandLine(int argc, char ** argv)
{
    char * pArgument;
    int count = 0;

    if(argc==1)
        m_dwFlags |= HELP;
        
    while(++count<argc)
    {
        pArgument = argv[count];
        if(*pArgument=='/' || *pArgument=='-')
        {
            while(*(++pArgument))
            {
                switch(*pArgument)
                {
                    case 'a':   // Append resources
                    case 'A':
                    {
                        //Make sure no other conflicting flags are specified
                        if(IsFlag(REPLACE) | IsFlag(UPDATE) | IsFlag(EXTRACT))
                        {
                            Banner();
                            WriteCon(CONERR, "Please use -a without the -r, -u or -t option!");
                            return ERR_COMMAND_LINE;
                        }

                        // Make sure none of the next item is another option
                        
                        for(int c=1; c<=4; c++)
                            if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-')
                            {
                                Banner();
                                WriteCon(CONERR, "Not enough parameters specified for the -a option\r\n"\
                                                 "  -a  InputExeFile  InputUSTokFile  InputLOCTokFile  OutputExeFile\r\n");
                                return ERR_COMMAND_LINE;
                            };

                        m_dwFlags |= APPEND;

                        // Get the input EXE file name
                        m_strInExe = argv[++count];
                        
                        // Get the source token file name
                        m_strSrcTok = argv[++count];

                        // Get the target token file name
                        m_strTgtTok = argv[++count];

                        // Get the output EXE file name
                        m_strOutExe = argv[++count];
                    }
                    break;
                    case 'b':
                    case 'B':
                        m_dwFlags |= BITMAPS;
                    break;
                    case 'd':
                    case 'D':   // Default  for unmappable characters
                        m_unmappedChar = argv[++count][0];
                    break;
                    case 'f':
                    case 'F':
                        m_dwFlags |= FONTS;
                    break;
                    case 'i':   // Input language/sublanguage
                    case 'I':
                        m_dwFlags |= INPUT_LANG;
                        m_usIPriLangId = GetLangID(argv[++count]);
                        m_usISubLangId = GetLangID(argv[++count]);
                    break;
                    case '?':   // Help
                    case 'h':
                    case 'H':
                        m_dwFlags |= HELP;
                    break;
                    case 'n':
                    case 'N':
                        m_dwFlags |= NOLOGO;
                    break;
                    case 'o':   // Output language/sublanguage
                    case 'O':
                        m_dwFlags |= OUTPUT_LANG;
                        m_usOPriLangId = GetLangID(argv[++count]);
                        m_usOSubLangId = GetLangID(argv[++count]);
                    break;
                    case 'p':   // Code page
                    case 'P':
                        m_uiCodePage = GetCodePage(argv[++count]);
                    break;
                    case 'r':   // Replace resources
                    case 'R':
                    {
                        //Make sure no other conflicting flags are specified
                        if(IsFlag(APPEND) | IsFlag(EXTRACT) | IsFlag(UPDATE))
                        {
                            Banner();
                            WriteCon(CONERR, "Please use -r without the -a, -u or -t option!");
                            return ERR_COMMAND_LINE;
                        }

                        // Make sure none of the next item is another option
                        for(int c=1; c<=3; c++)
                            if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-')
                            {
                                Banner();
                                WriteCon(CONERR, "Not enough parameters specified for the -r option\r\n"\
                                                 "  -r  InputExeFile  InputLOCTokFile  OutputExeFile\r\n");
                                return ERR_COMMAND_LINE;
                            };
                        
                        m_dwFlags |= REPLACE;

                        // Get the input EXE file name
                        m_strInExe = argv[++count];
                        
                        // Get the target token file name
                        m_strTgtTok = argv[++count];

                        // Get the output EXE file name
                        m_strOutExe = argv[++count];
                    }
                    break;
                    case 'u':   // Update resources
                    case 'U':
                    {
                        //Make sure no other conflicting flags are specified
                        if(IsFlag(APPEND) | IsFlag(EXTRACT) | IsFlag(REPLACE))
                        {
                            Banner();
                            WriteCon(CONERR, "Please use -u without the -a, -r or -t option!");
                            return ERR_COMMAND_LINE;
                        }

                        // Make sure none of the next item is another option
                        for(int c=1; c<=4; c++)
                            if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-')
                            {
                                Banner();
                                WriteCon(CONERR, "Not enough parameters specified for the -u option\r\n"\
                                                 "  -u  InputExeFile  InputUSTokFile  InputLOCTokFile  OutputExeFile\r\n");
                                return ERR_COMMAND_LINE;
                            };
                        
                        m_dwFlags |= UPDATE;

                        // Get the input EXE file name
                        m_strInExe = argv[++count];
                        
                        // Get the source token file name
                        m_strSrcTok = argv[++count];

                        // Get the target token file name
                        m_strTgtTok = argv[++count];

                        // Get the output EXE file name
                        m_strOutExe = argv[++count];
                    }
                    break;
                    case 's':
                    case 'S':
                        m_dwFlags |= SPLIT;
                    break;
                    case 't':   // Create token file
                    case 'T':
                    {
                        //Make sure no other conflicting flags are specified
                        if(IsFlag(APPEND) | IsFlag(REPLACE) | IsFlag(UPDATE))
                        {
                            Banner();
                            WriteCon(CONERR, "Please use -t without the -a, -u or -r option!");
                            return ERR_COMMAND_LINE;
                        }

                        // Make sure none of the next item is another option
                        for(int c=1; c<=2; c++)
                            if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-')
                            {
                                Banner();
                                WriteCon(CONERR, "Not enough parameters specified for the -t option\r\n"\
                                                 "  -t  InputExeFile  OutputTokenFile\r\n");
                                return ERR_COMMAND_LINE;
                            };
                        
                        m_dwFlags |= EXTRACT;

                        // Get the input EXE file name
                        m_strInExe = argv[++count];
                        
                        // Get the target token file name
                        m_strTgtTok = argv[++count];
                    }
                    break;
                    case 'w':   // Display warnings
                    case 'W':
                        m_dwFlags |= WARNING;
                    break;
                    default:
                    break;
                }
            }
        }
    }

    // Do we want the banner
    if(!IsFlag(NOLOGO)) 
        Banner();
	
    // Before exiting make sure we display the help screen if requested
    if(IsFlag(HELP)) 
    {
        Help();
        return ERR_HELP_CHOOSE;
    }
 
    // Check if the code page we have is installed in this system
    if(!IsValidCodePage(m_uiCodePage))
    {
        // Warn the user and get back the default CP
        m_uiCodePage = GetACP();
        WriteCon(CONERR, "The code page specified is not installed in the system or is invalid! Using system default!\r\n");
    }

    // Make sure the input file is there
    CFileStatus fs;
    if(!m_strInExe.IsEmpty())
    {
        if(!CFile::GetStatus(m_strInExe, fs))
        {
            WriteCon(CONERR, "File not found: %s\r\n", m_strInExe);
            return ERR_FILE_NOTFOUND;
        }    
    }

    // Check if the tgt token file or exe are read only
    if(!m_strOutExe.IsEmpty())
    {
        if(CFile::GetStatus(m_strOutExe, fs))
        {
            if((fs.m_attribute & 0x1)==0x1)
            {
                WriteCon(CONERR, "File is read only: %s\r\n", m_strOutExe);
                return ERR_FILE_CREATE;
            }
        }    
    }

    if(!m_strTgtTok.IsEmpty() && IsFlag(EXTRACT))
    {
        if(CFile::GetStatus(m_strTgtTok, fs))
        {
            if((fs.m_attribute & 0x1)==0x1)
            {
                WriteCon(CONERR, "File is read only: %s\r\n", m_strTgtTok);
                return ERR_FILE_CREATE;
            }
        }    
    }

    //
    // Check the value specified for the output language.
    // If none has been specified, warn the user and default to neutral.
    //
    if(IsFlag(APPEND) | IsFlag(REPLACE))
    {
        if(m_usOPriLangId==-1)
        {
            m_usOPriLangId = LANG_NEUTRAL; // set the PRI language ID to neutral
            WriteCon(CONERR, "Output language ID not specified, default to neutral(%d)\r\n", m_usOPriLangId);
        }
    
        if(m_usOSubLangId==-1)
        {
            m_usOSubLangId = SUBLANG_NEUTRAL; // set the SEC language ID to neutral
            WriteCon(CONERR, "Output sub-language ID not specified, default to neutral(%d)\r\n", m_usOSubLangId);
        }
    }

    WriteCon(CONWRN, "Code Page              : %d\r\n", m_uiCodePage);
    WriteCon(CONWRN, "In  Primary Language   : %d (%d)\r\n", m_usIPriLangId, MAKELANGID(m_usIPriLangId,m_usISubLangId));
    WriteCon(CONWRN, "In  Secondary Language : %d (0x%x)\r\n", m_usISubLangId, MAKELANGID(m_usIPriLangId,m_usISubLangId));
    WriteCon(CONWRN, "Out Primary Language   : %d (%d)\r\n", m_usOPriLangId, MAKELANGID(m_usOPriLangId,m_usOSubLangId));
    WriteCon(CONWRN, "Out Secondary Language : %d (0x%x)\r\n", m_usOSubLangId, MAKELANGID(m_usOPriLangId,m_usOSubLangId));
    WriteCon(CONWRN, "Default unmapped char  : %c \r\n", m_unmappedChar);

    return ERR_NOERROR;
}
Exemplo n.º 20
0
//********************************************************************
Bool OneChar(Handle charHandle)
{
	// write one symbol
	char sCodePageName[200]={0};
	CHECK_MEMORY(10);

	struct letterEx *alt = CED_GetAlternatives(charHandle);
	ASSERT(alt);
	long codePage = GetCodePage();

	// source symbol
	Byte c1 = alt->alternative;

	Byte c2 = gActiveCodeTable[c1];

	// remember for the  Words.cpp module
	gCharHandle = charHandle;
	gAlt = alt;
	gCharCode = c1;
	gCharBack = gMemCur;

	// Пробелы, вставленные для выравнивания SmartText,
	// имеют оценку 253; их следует пропускать
	// для всех остальных форматов
	if (c1 == ' ' && alt->probability == 253 &&
		gFormat != ROUT_FMT_SmartText
	    )
		return TRUE;

	// Специальные случаи перекодировки
	switch(c1)
		{
		// unknows symbol
		case bad_char:
			c2 = gBadChar;
			break;

		case 0x97:
			//  long dash -> double hyphen
			// except SmartText и HTML
			// 29.02.2000
			if (gFormat == ROUT_FMT_HTML || gFormat == ROUT_FMT_HOCR || gActiveCode==ROUT_CODE_UTF8)
				{
				// there is long dash in html and unicode
				c2 = c1;
				}
			else
				{
				c2 = '-';
				if (gFormat != ROUT_FMT_SmartText)
					*gMemCur++ = '-';
				}
			break;

		// Угловые скобки в HTML заменяются на круглые
		case '<':
		case '>':
			if (gFormat == ROUT_FMT_HTML || gFormat == ROUT_FMT_HOCR) {
				*gMemCur++ = '&';
				*gMemCur++ = (c1 == '<' ? 'l' : 'g');
				*gMemCur++ = 't';
				*gMemCur++ = ';';
				return TRUE;
			}
			break;

		case '&':
                        if(gFormat == ROUT_FMT_HTML || gFormat == ROUT_FMT_HOCR) {
                            *gMemCur++ = '&';
                            *gMemCur++ = 'a';
                            *gMemCur++ = 'm';
                            *gMemCur++ = 'p';
                            *gMemCur++ = ';';
                            return TRUE;
                        }
                        break;

		// Дифтонг oe / OE
		case oe_deaf_sound:
			if( FALSE == (
					gLanguage==PUMA_LANG_RUSSIAN ||
					langKaz ||   // 18.08.98 E.P.
					gLanguage==PUMA_LANG_FRENCH &&
					gActiveCode==ROUT_CODE_ANSI
					) ||
					gFormat == ROUT_FMT_HTML || gFormat == ROUT_FMT_HOCR
				)
				{
				*gMemCur++ = 'o';
				c2='e';
				}
			break;

		case OE_cap_deaf_sound:
			if( FALSE == (
					gLanguage==PUMA_LANG_RUSSIAN ||
					langKaz ||   // 18.08.98 E.P.
					gLanguage==PUMA_LANG_FRENCH &&
					gActiveCode==ROUT_CODE_ANSI
					) ||
					gFormat == ROUT_FMT_HTML || gFormat == ROUT_FMT_HOCR
				)
				{
				*gMemCur++ = 'O';
				c2='E';
				}
			break;

		//	0xA9 © -> (C),
		//	0xAE ® -> (R)
		case  0xA9:  case  0xAE:
		    if(gActiveCode == ROUT_CODE_UTF8)
		        break;

			if( gActiveCode==ROUT_CODE_ASCII ||
				gActiveCode==ROUT_CODE_ISO
			  )
				*gMemCur++ = '(';

			*gMemCur++ = c2;

			if( gActiveCode==ROUT_CODE_ASCII ||
				gActiveCode==ROUT_CODE_ISO
			  )
				*gMemCur++ = ')';

			return TRUE;
			break;

		// 0x99 ™ -> (TM) except ANSI and UTF8
		case  0x99:
            if( gActiveCode!=ROUT_CODE_ANSI && gActiveCode!=ROUT_CODE_UTF8)
				{
				*gMemCur++ = '(';
				*gMemCur++ = c2;	// 'T'
				*gMemCur++ = 'M';
				*gMemCur++ = ')';
				return TRUE;
				}

			break;

		}	// switch(c1)
		if(gActiveCode!=ROUT_CODE_UTF8){
				*gMemCur++ = c2;
		}
		else {
			const char *utfchar;
			utfchar = getUTF8Str((char )c2, GetCodePage());
			int i;
			for(i=0; utfchar[i] != '\0' ;i++){
				*gMemCur++ = utfchar[i];
			}
		}
	return TRUE;
}
Exemplo n.º 21
0
void KItemNull::OnInitEnd(KItemNullData &ItemNullData)
{
	if (ItemNullData.nScript)
	{
		g_pUI->m_Script.OnItemInit(this, ATL::CW2A(KUiComponentsDecoder::GetSelf().GetDecodedScript(), GetCodePage()));
	}
}
Exemplo n.º 22
0
void
AwtMenuItem::DrawSelf(DRAWITEMSTRUCT& drawInfo)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    if (env->EnsureLocalCapacity(4) < 0) {
        return;
    }

    // self is sun.awt.windows.WMenuItemPeer
    jobject self = GetPeer(env);

    //  target is java.awt.MenuItem
    jobject target = env->GetObjectField(self, AwtObject::targetID);

    HDC hDC = drawInfo.hDC;
    RECT rect = drawInfo.rcItem;
    RECT textRect = rect;
    SIZE size;

    DWORD crBack,crText;
    HBRUSH hbrBack;

    jobject font = GetFont(env);
    jstring text = GetJavaString(env);
    size = AwtFont::getMFStringSize(hDC, font, text);

    /* 4700350: If the font size is taller than the menubar, change to the
     * default font.  Otherwise, menu text is painted over the title bar and
     * client area.  -bchristi
     */
    if (IsTopMenu() && size.cy > ::GetSystemMetrics(SM_CYMENU)) {
        env->DeleteLocalRef(font);
        font = env->NewLocalRef(GetDefaultFont(env));
        size = AwtFont::getMFStringSize(hDC, font, text);
    }

    /* Fix for bug 4257944 by [email protected]
    * check state of the parent
    */
    AwtMenu* menu = GetMenuContainer();
    DASSERT(menu != NULL && GetID() >= 0);

    //Check whether the MenuItem is disabled.
    BOOL bEnabled = (jboolean)env->GetBooleanField(target,
                                                   AwtMenuItem::enabledID);
    if (menu != NULL) {
        bEnabled = bEnabled && !menu->IsDisabledAndPopup();
    }

    if ((drawInfo.itemState) & (ODS_SELECTED)) {
        // Set background and text colors for selected item
        crBack = ::GetSysColor (COLOR_HIGHLIGHT);
        // Disabled text must be drawn in gray.
        crText = ::GetSysColor(bEnabled? COLOR_HIGHLIGHTTEXT : COLOR_GRAYTEXT);
    } else {
        // COLOR_MENUBAR is only defined on WindowsXP. Our binaries are
        // built on NT, hence the below ifdef.

#ifndef COLOR_MENUBAR
#define COLOR_MENUBAR 30
#endif
        // Set background and text colors for unselected item
        if (IS_WINXP && IsTopMenu() && AwtDesktopProperties::IsXPStyle()) {
            crBack = ::GetSysColor (COLOR_MENUBAR);
        } else {
            crBack = ::GetSysColor (COLOR_MENU);
        }
        // Disabled text must be drawn in gray.
        crText = ::GetSysColor (bEnabled ? COLOR_MENUTEXT : COLOR_GRAYTEXT);
    }

    // Fill item rectangle with background color
    hbrBack = ::CreateSolidBrush (crBack);
    DASSERT(hbrBack);
    VERIFY(::FillRect (hDC, &rect, hbrBack));
    VERIFY(::DeleteObject (hbrBack));

    // Set current background and text colors
    ::SetBkColor (hDC, crBack);
    ::SetTextColor (hDC, crText);

    int nOldBkMode = ::SetBkMode(hDC, OPAQUE);
    DASSERT(nOldBkMode != 0);

    //draw check mark
    int checkWidth = ::GetSystemMetrics(SM_CXMENUCHECK);
    // Workaround for CR#6401956
    if (IS_WINVISTA) {
        AdjustCheckWidth(checkWidth);
    }

    if (IsCheckbox()) {
        // means that target is a java.awt.CheckboxMenuItem
        jboolean state =
            (jboolean)env->GetBooleanField(target, AwtMenuItem::stateID);
        if (state) {
            DASSERT(drawInfo.itemState & ODS_CHECKED);
            RECT checkRect;
            ::CopyRect(&checkRect, &textRect);
            if (GetRTL())
                checkRect.left = checkRect.right - checkWidth;
            else
                checkRect.right = checkRect.left + checkWidth;

            DrawCheck(hDC, checkRect);
        }
    }

    ::SetBkMode(hDC, TRANSPARENT);
    int x = 0;
    //draw string
    if (!IsTopMenu()){
        textRect.left += checkWidth;
        x = (GetRTL()) ? textRect.right - checkWidth - size.cx : textRect.left;
    } else {
        x = textRect.left = (textRect.left + textRect.right - size.cx) / 2;
    }

    int y = (textRect.top+textRect.bottom-size.cy)/2;

    // Text must be drawn in emboss if the Menu is disabled and not selected.
    BOOL bEmboss = !bEnabled && !(drawInfo.itemState & ODS_SELECTED);
    if (bEmboss) {
        ::SetTextColor(hDC, GetSysColor(COLOR_BTNHILIGHT));
        AwtFont::drawMFString(hDC, font, text, x + 1, y + 1, GetCodePage());
        ::SetTextColor(hDC, GetSysColor(COLOR_BTNSHADOW));
    }
    AwtFont::drawMFString(hDC, font, text, x, y, GetCodePage());

    jstring shortcutLabel =
        (jstring)env->GetObjectField(self, AwtMenuItem::shortcutLabelID);
    if (!IsTopMenu() && shortcutLabel != NULL) {
        UINT oldAlign = 0;
        if (GetRTL()){
            oldAlign = ::SetTextAlign(hDC, TA_LEFT);
            AwtFont::drawMFString(hDC, font, shortcutLabel, textRect.left, y,
                                  GetCodePage());
        } else {
            oldAlign = ::SetTextAlign(hDC, TA_RIGHT);
            AwtFont::drawMFString(hDC, font, shortcutLabel,
                                  textRect.right - checkWidth, y,
                                  GetCodePage());
        }

        ::SetTextAlign(hDC, oldAlign);
    }

    VERIFY(::SetBkMode(hDC,nOldBkMode));

    env->DeleteLocalRef(target);
    env->DeleteLocalRef(text);
    env->DeleteLocalRef(font);
    env->DeleteLocalRef(shortcutLabel);
}