Converter.cpp
上传用户:hell82222
上传日期:2013-12-19
资源大小:1872k
文件大小:5k
- // Converter.cpp: implementation of the CConverter class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "FileSwitch.h"
- #include "Converter.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- #include "cmndef.h"
- CMapStringToPtr CConverter::m_mapFont;
- CConverter::CConverter()
- {
- if(m_mapFont.IsEmpty())
- {
- TCHAR szFileName[MAX_PATH];
- HMODULE hModule=::GetModuleHandle("fileswitch.dll");
- ::GetModuleFileName(hModule,szFileName,MAX_PATH);
- (*_tcsrchr(szFileName,'\'))=' ';
- _tcscat(szFileName,_T("\support\kmconv.fmp"));
- //short adInitAd2 _((const char * initfilepath, short *initerror));
- CFileFind filefind;
- CString strTemp2;
- if(filefind.FindFile(szFileName))
- {
- CStdioFile file;
- if(file.Open(szFileName,CFile::modeRead))
- {
- CString strTemp;
- while(file.ReadString(strTemp))
- {
- int iPos=strTemp.Find(';');
- if(iPos!=-1)
- {
- strTemp2=strTemp.Right(strTemp.GetLength()-iPos-1);
- int iPos2=strTemp2.Find(';');
- if(iPos2!=-1)
- {
- CString strTemp3=strTemp2.Right(strTemp2.GetLength()-iPos2-1);
- int ipos3=strTemp3.Find(';');
- if(ipos3!=-1)
- {
- double dscale=::atof(strTemp3.Left(ipos3));
- if(dscale<PRECISION)
- dscale=1.0;
- double dheightscale=::atof(strTemp3.Right(strTemp3.GetLength()-ipos3-1));
- m_mapFont.SetAt(strTemp.Left(iPos),new FONTMAPITEM(strTemp2.Left(iPos2),dscale,dheightscale));
- }
- else
- {
- double dscale=::atof(strTemp3);
- if(dscale<PRECISION)
- dscale=1.0;
- m_mapFont.SetAt(strTemp.Left(iPos),new FONTMAPITEM(strTemp2.Left(iPos2),dscale,1.0));
- }
- }
- else
- {
- m_mapFont.SetAt(strTemp.Left(iPos),new FONTMAPITEM(strTemp2,1.0,1.0));
- }
- }
- }
- file.Close();
- }
- }
- }
- }
- CConverter::~CConverter()
- {
- CString str;
- void* pvoid;
- POSITION pos=m_mapFont.GetStartPosition();
- while(pos!=NULL)
- {
- m_mapFont.GetNextAssoc(pos,str,pvoid);
- delete pvoid;
- }
- m_mapFont.RemoveAll();
- }
- void CConverter::calculate_finddir(double angle,double pt[])
- {
- angle=angle*PI/180;
- pt[0]=cos(angle);
- pt[1]=sin(angle);
- pt[2]=0.0;
- }
- void CConverter::calculate_convert_ii(CString& strSource)
- {
- //专为宝石开发
- char tmp_str1[10],tmp_str2[10],tmp_str3[10];
- char tmp_str4[10],tmp_str5[10],tmp_str6[10];
- char tmp_str7[10];
- tmp_str5[0] = 0xD3;
- tmp_str5[1] = 0x5D;
- tmp_str5[2] = ' ';
- tmp_str6[0] = 0xB4;
- tmp_str6[1] = 0x5D;
- tmp_str6[2] = ' ';
- tmp_str7[0] = '^';
- tmp_str7[1] = 'B';
- tmp_str7[2] = '%';
- tmp_str7[3] = ' ';
- tmp_str4[0] = 2;
- tmp_str4[1] = 'B';
- tmp_str4[2] = ' ';
- tmp_str3[0] = 8;
- tmp_str3[1] = 2;
- tmp_str3[2] = '%';
- tmp_str3[3] = 32;
- tmp_str3[4] = ' ';
- tmp_str2[0] = 2;
- tmp_str2[1] = '%';
- tmp_str2[2] = 32;
- tmp_str2[3] = ' ';
- tmp_str1[0] = 2;
- tmp_str1[1] = '%';
- tmp_str1[2] = ' ';
-
- CString my_string;int len_findstring;
- my_string=strSource;
- len_findstring=my_string.Find(tmp_str4);
- while(len_findstring!=-1)
- {
- //my_string.Delete(len_findstring,4);
- //len_findstring=my_string.Find(tmp_str4);
- //
- my_string.Delete(len_findstring,2);
- my_string.Insert(len_findstring,"Φ");
- len_findstring=my_string.Find(tmp_str4);
- }
- len_findstring=my_string.Find(tmp_str3);
- while(len_findstring!=-1)
- {
- my_string.Delete(len_findstring,3);
- len_findstring=my_string.Find(tmp_str3);
- }
- len_findstring=my_string.Find(tmp_str2);
- while(len_findstring!=-1)
- {
- my_string.Delete(len_findstring,3);
- len_findstring=my_string.Find(tmp_str2);
- }
- len_findstring=my_string.Find(tmp_str1);
- while(len_findstring!=-1)
- {
- my_string.Delete(len_findstring,2);
- len_findstring=my_string.Find(tmp_str1);
- }
- len_findstring=my_string.Find(tmp_str5);
- while (len_findstring!=-1) {
- char Right[3]={0xD3,0xA6,' '};
- my_string.Delete(len_findstring,2);
- my_string.Insert(len_findstring,Right);
- len_findstring=my_string.Find(tmp_str5);
- }
- len_findstring=my_string.Find(tmp_str6);
- while (len_findstring!=-1) {
- char Right[3]={0xB4,0xF3,' '};
- my_string.Delete(len_findstring,2);
- my_string.Insert(len_findstring,Right);
- len_findstring=my_string.Find(tmp_str6);
- }
- len_findstring=my_string.Find(tmp_str7);
- while(len_findstring!=-1)
- {
- my_string.Delete(len_findstring,3);
- len_findstring=my_string.Find(tmp_str7);
- }
- len_findstring=my_string.Find(']');
- if (len_findstring!=-1)
- {
- for(int i = 0; i < my_string.GetLength(); i ++)
- {
- char ch = my_string.GetAt(i);
- if (ch == ']')
- {
- my_string.SetAt(i,' ');
- }
- else if (ch & 0x80)
- {
- i ++;
- }
- }
- }
- strSource=my_string;
- }