void IFileContainer::write(Rels::File& rels, const CPath& curdir, const CPath& directory, ContentTypes::File& content) const { CAtlMap<CString, size_t> namepair; POSITION pos = m_container.GetStartPosition(); while (NULL != pos) { const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.GetNext(pos); smart_ptr<OOX::File> pFile = pPair->m_value; smart_ptr<OOX::External> pExt = pFile.smart_dynamic_cast<OOX::External>(); if (!pExt.IsInit()) { OOX::CPath defdir = pFile->DefaultDirectory(); OOX::CPath name = pFile->DefaultFileName(); CAtlMap<CString, size_t>::CPair* pNamePair = namepair.Lookup(name.m_strFilename); if (NULL == pNamePair) namepair.SetAt(name.m_strFilename, 1); else name = name + pNamePair->m_key; OOX::CSystemUtility::CreateDirectories(curdir / defdir); pFile->write(curdir / defdir / name, directory / defdir, content); rels.registration(pPair->m_key, pFile->type(), defdir / name); } else { rels.registration(pPair->m_key, pExt); } } }
void IFileContainer::Commit(const CPath& path) { CAtlMap<CString, size_t> namepair; POSITION pos = m_container.GetStartPosition(); while (NULL != pos) { CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.GetNext(pos); smart_ptr<OOX::File> pFile = pPair->m_value; smart_ptr<OOX::External> pExt = pFile.smart_dynamic_cast<OOX::External>(); if (!pExt.IsInit()) { OOX::CPath defdir = pFile->DefaultDirectory(); OOX::CPath name = pFile->DefaultFileName(); CAtlMap<CString, size_t>::CPair* pNamePair = namepair.Lookup(name.m_strFilename); if (NULL == pNamePair) namepair.SetAt(name.m_strFilename, 1); else name = name + pNamePair->m_key; OOX::CSystemUtility::CreateDirectories(path / defdir); smart_ptr<OOX::IFileBuilder> fileBuilder = pPair->m_value.smart_dynamic_cast<OOX::IFileBuilder>(); if (fileBuilder.is_init()) fileBuilder->Commit(path / defdir / name); } } }
void CFunctionManager::FillSpecFunctionArray() { m_SelectedFunctions.RemoveAll(); for (size_t i = 0;i < m_pClass->Parents.GetCount(); i++) { SpecFunctionParent SpecParent; if (m_sSpecFunctions.Lookup(m_pClass->Parents[i]->Name, SpecParent)) { CAtlMap<int, bool> ConditionResult; bool bDefault = true; for (size_t i = 0; i < SpecParent.Conditions.GetCount(); i++) { bool bRes = CheckSpecialCondition(SpecParent.Conditions[i]); bDefault &= !bRes; ConditionResult.SetAt(SpecParent.Conditions[i], bRes); } if (SpecParent.Conditions.GetCount()) { ConditionResult.SetAt(0, bDefault); } CSmartAtlArray<SpecFunctionStruct>& SpecFunctions = SpecParent.SpecFunctions; for (size_t i = 0; i < SpecFunctions.GetCount(); i++) { if (SpecFunctions[i].Condition == -1) { m_SelectedFunctions.Add(SpecFunctions[i]); } else { bool bRes; if (ConditionResult.Lookup(SpecFunctions[i].Condition, bRes)) { if (bRes) { m_SelectedFunctions.Add(SpecFunctions[i]); } } } } } } }
BOOL CRegOpt::DoEnumCurrnetSubKey(HKEY hRootKey,LPCTSTR lpcKey,CAtlMap<CString,char>& vec_Key) { HKEY hKey; LONG lResult; //打开键 lResult = RegOpenKeyEx(hRootKey, lpcKey, NULL, KEY_READ, &hKey ); if(lResult != ERROR_SUCCESS) { m_iErrCode = lResult; return FALSE; } //枚举键名 BOOL bRet = TRUE; DWORD dwIndex=0; do { TCHAR szKey[MAX_PATH]={0}; DWORD dwKey = sizeof(szKey); lResult =RegEnumKey(hKey,dwIndex,szKey,dwKey); if (lResult != ERROR_SUCCESS) { if (lResult == ERROR_NO_MORE_ITEMS) { bRet = TRUE; break; } else { bRet = FALSE; m_iErrCode = lResult; break; } } vec_Key.SetAt(szKey,'1'); dwIndex++; } while (1); RegCloseKey(hKey); return bRet; }
bool CPeerInfo::TryInsertPeerIDMessageID(unsigned int PeerID, unsigned MessageID) { CAtlMap<unsigned int, void*> *MessageIDMap; if(PeerIDMessageIDMap.Lookup(PeerID, MessageIDMap) == false) { MessageIDMap = new CAtlMap<unsigned int, void*>(); PeerIDMessageIDMap.SetAt(PeerID, MessageIDMap); } void *Temp; if(MessageIDMap->Lookup(MessageID, Temp) == true) return false; else { MessageIDMap->SetAt(MessageID, NULL); return true; } }
IDTManager* CMainDlg::GetDTMgrForPhone() { if(m_pPhoneDTMgr == NULL && CreateObject != NULL) { CreateObject(__uuidof(IDTManager), (void**)&m_pPhoneDTMgr); if(m_pPhoneDTMgr != NULL) { CAtlMap<DtStateChangeNotifyCallBack,void*> *pCallback = new CAtlMap<DtStateChangeNotifyCallBack,void*>; pCallback->SetAt(PhoneSoftDownCallback, this); m_pPhoneDTMgr->Init(pCallback); } } return m_pPhoneDTMgr; }
int _tmain(int argc, _TCHAR* argv[]) { FT_Library pLibrary = NULL; //CString strFolder = _T("\\\\mediaserver\\Exchange\\Korshul\\Fonts"); CString strFolder = _T("X:\\AVS\\Sources\\TeamlabOffice\\trunk\\ServerComponents\\DesktopEditor\\freetype_names\\FontsDictionaryFiles"); CWinFontList* m_pList = NULL; if (!FT_Init_FreeType( &pLibrary )) { if (_T("") == strFolder) m_pList = new CWinFontList(pLibrary); else m_pList = new CWinFontList(pLibrary, strFolder); FT_Done_FreeType( pLibrary ); } CString strFontDictionaryPath = _T("X:\\AVS\\Sources\\TeamlabOffice\\trunk\\ServerComponents\\DesktopEditor\\freetype_names\\FontMaps\\FontDictionary.h"); int nCount = m_pList->GetFonts()->GetLength(); // теперь строим массив всех шрифтов по имени CAtlMap<CString, CFontInfoJS> mapFonts; CAtlMap<CString, CFontInfoJS> mapFontsUnicodes; CAtlArray<CString> arrFonts; CAtlArray<CString> arrFontsUnicodes; int nError = 0; CAtlMap<CString, BOOL> mapMainAscii; for (int i = 0; i < nCount; ++i) { CWinFontInfo* pInfo = (CWinFontInfo*)m_pList->GetByIndex(i); CString strPath = (CString)pInfo->m_wsFontPath; CString strName = (CString)pInfo->m_wsFontName; LONG lFontIndex = 0; LONG lFaceIndex = 0; //CAtlMap<CString, LONG>::CPair* pPairFontFiles = mapFontFiles.Lookup(strPath); //lFontIndex = pPairFontFiles->m_value; lFontIndex = (LONG)i; if (pInfo->m_lIndex >= 0) lFaceIndex = pInfo->m_lIndex; mapMainAscii.SetAt(pInfo->m_wsFontName, TRUE); CAtlMap<CString, CFontInfoJS>::CPair* pPair = mapFonts.Lookup(pInfo->m_wsFontName); if (NULL != pPair) { pPair->m_value.m_sName = pInfo->m_wsFontName; if (pInfo->m_bBold && pInfo->m_bItalic) { if (-1 != pPair->m_value.m_lIndexBI) nError++; pPair->m_value.m_lIndexBI = lFontIndex; pPair->m_value.m_lFaceIndexBI = lFaceIndex; pPair->m_value.namesBI.RemoveAll(); pPair->m_value.namesBI.Copy(pInfo->names); } else if (pInfo->m_bBold) { if (-1 != pPair->m_value.m_lIndexB) nError++; pPair->m_value.m_lIndexB = lFontIndex; pPair->m_value.m_lFaceIndexB = lFaceIndex; pPair->m_value.namesB.RemoveAll(); pPair->m_value.namesB.Copy(pInfo->names); } else if (pInfo->m_bItalic) { if (-1 != pPair->m_value.m_lIndexI) nError++; pPair->m_value.m_lIndexI = lFontIndex; pPair->m_value.m_lFaceIndexI = lFaceIndex; pPair->m_value.namesI.RemoveAll(); pPair->m_value.namesI.Copy(pInfo->names); } else { if (-1 != pPair->m_value.m_lIndexR) nError++; pPair->m_value.m_lIndexR = lFontIndex; pPair->m_value.m_lFaceIndexR = lFaceIndex; pPair->m_value.namesR.RemoveAll(); pPair->m_value.namesR.Copy(pInfo->names); } } else { CFontInfoJS fontInfo; fontInfo.m_sName = pInfo->m_wsFontName; if (pInfo->m_bBold && pInfo->m_bItalic) { fontInfo.m_lIndexBI = lFontIndex; fontInfo.m_lFaceIndexBI = lFaceIndex; fontInfo.namesBI.RemoveAll(); fontInfo.namesBI.Copy(pInfo->names); } else if (pInfo->m_bBold) { fontInfo.m_lIndexB = lFontIndex; fontInfo.m_lFaceIndexB = lFaceIndex; fontInfo.namesB.RemoveAll(); fontInfo.namesB.Copy(pInfo->names); } else if (pInfo->m_bItalic) { fontInfo.m_lIndexI = lFontIndex; fontInfo.m_lFaceIndexI = lFaceIndex; fontInfo.namesI.RemoveAll(); fontInfo.namesI.Copy(pInfo->names); } else { fontInfo.m_lIndexR = lFontIndex; fontInfo.m_lFaceIndexR = lFaceIndex; fontInfo.namesR.RemoveAll(); fontInfo.namesR.Copy(pInfo->names); } mapFonts.SetAt(fontInfo.m_sName, fontInfo); arrFonts.Add(fontInfo.m_sName); } } // additional names for (int i = 0; i < nCount; ++i) { CWinFontInfo* pInfo = (CWinFontInfo*)m_pList->GetByIndex(i); CString strPath = (CString)pInfo->m_wsFontPath; CString strName = (CString)pInfo->m_wsFontName; LONG lFontIndex = 0; LONG lFaceIndex = 0; //CAtlMap<CString, LONG>::CPair* pPairFontFiles = mapFontFiles.Lookup(strPath); //lFontIndex = pPairFontFiles->m_value; lFontIndex = (LONG)i; if (pInfo->m_lIndex >= 0) lFaceIndex = pInfo->m_lIndex; int nNamesAdditional = pInfo->names.GetCount(); for (int j = 0; j < nNamesAdditional; ++j) { CString strNameA = pInfo->names[j]; CAtlMap<CString, BOOL>::CPair* pPairMain = mapMainAscii.Lookup(strNameA); if (NULL != pPairMain) continue; WCHAR* pBufferA = strNameA.GetBuffer(); int len = strNameA.GetLength(); CAtlMap<CString, CFontInfoJS>* pMap = &mapFonts; CAtlArray<CString>* pArrFonts = &arrFonts; for (int k = 0; k < len; ++k) { if (pBufferA[k] > 255) { pMap = &mapFontsUnicodes; pArrFonts = &arrFontsUnicodes; break; } } CAtlMap<CString, CFontInfoJS>::CPair* pPair = pMap->Lookup(strNameA); if (NULL != pPair) { pPair->m_value.m_sName = strNameA; if (pInfo->m_bBold && pInfo->m_bItalic) { if (-1 != pPair->m_value.m_lIndexBI) nError++; pPair->m_value.m_lIndexBI = lFontIndex; pPair->m_value.m_lFaceIndexBI = lFaceIndex; pPair->m_value.namesBI.RemoveAll(); pPair->m_value.namesBI.Copy(pInfo->names); } else if (pInfo->m_bBold) { if (-1 != pPair->m_value.m_lIndexB) nError++; pPair->m_value.m_lIndexB = lFontIndex; pPair->m_value.m_lFaceIndexB = lFaceIndex; pPair->m_value.namesB.RemoveAll(); pPair->m_value.namesB.Copy(pInfo->names); } else if (pInfo->m_bItalic) { if (-1 != pPair->m_value.m_lIndexI) nError++; pPair->m_value.m_lIndexI = lFontIndex; pPair->m_value.m_lFaceIndexI = lFaceIndex; pPair->m_value.namesI.RemoveAll(); pPair->m_value.namesI.Copy(pInfo->names); } else { if (-1 != pPair->m_value.m_lIndexR) nError++; pPair->m_value.m_lIndexR = lFontIndex; pPair->m_value.m_lFaceIndexR = lFaceIndex; pPair->m_value.namesR.RemoveAll(); pPair->m_value.namesR.Copy(pInfo->names); } } else { CFontInfoJS fontInfo; fontInfo.m_sName = strNameA; if (pInfo->m_bBold && pInfo->m_bItalic) { fontInfo.m_lIndexBI = lFontIndex; fontInfo.m_lFaceIndexBI = lFaceIndex; fontInfo.namesBI.RemoveAll(); fontInfo.namesBI.Copy(pInfo->names); } else if (pInfo->m_bBold) { fontInfo.m_lIndexB = lFontIndex; fontInfo.m_lFaceIndexB = lFaceIndex; fontInfo.namesB.RemoveAll(); fontInfo.namesB.Copy(pInfo->names); } else if (pInfo->m_bItalic) { fontInfo.m_lIndexI = lFontIndex; fontInfo.m_lFaceIndexI = lFaceIndex; fontInfo.namesI.RemoveAll(); fontInfo.namesI.Copy(pInfo->names); } else { fontInfo.m_lIndexR = lFontIndex; fontInfo.m_lFaceIndexR = lFaceIndex; fontInfo.namesR.RemoveAll(); fontInfo.namesR.Copy(pInfo->names); } pMap->SetAt(fontInfo.m_sName, fontInfo); pArrFonts->Add(fontInfo.m_sName); } } } // ------------------------------------------- // теперь сортируем шрифты по имени ---------- size_t nCountFonts = arrFonts.GetCount(); for (size_t i = 0; i < nCountFonts; ++i) { for (size_t j = i + 1; j < nCountFonts; ++j) { if (arrFonts[i] > arrFonts[j]) { CString temp = arrFonts[i]; arrFonts[i] = arrFonts[j]; arrFonts[j] = temp; } } } size_t nCountFontsU = arrFontsUnicodes.GetCount(); for (size_t i = 0; i < nCountFontsU; ++i) { for (size_t j = i + 1; j < nCountFontsU; ++j) { if (arrFontsUnicodes[i] > arrFontsUnicodes[j]) { CString temp = arrFontsUnicodes[i]; arrFontsUnicodes[i] = arrFontsUnicodes[j]; arrFontsUnicodes[j] = temp; } } } #if 0 CFile oFile; oFile.CreateFile(_T("c:\\fonts.txt")); BYTE bom[3]; bom[0] = 0xEF; bom[1] = 0xBB; bom[2] = 0xBF; oFile.WriteFile((void*)&bom, 3); CString strInfos = _T(""); for (int index = 0; index < nCountFonts; ++index) { const CAtlMap<CString, CFontInfoJS>::CPair* pPair = mapFonts.Lookup(arrFonts[index]); CString strFontInfo = pPair->m_value.m_sName + _T(": ["); for (size_t i = 0; i < pPair->m_value.namesR.GetCount(); ++i) { strFontInfo += pPair->m_value.namesR[i]; strFontInfo += _T(","); } strFontInfo += _T(";"); for (size_t i = 0; i < pPair->m_value.namesI.GetCount(); ++i) { strFontInfo += pPair->m_value.namesI[i]; strFontInfo += _T(","); } strFontInfo += _T(";"); for (size_t i = 0; i < pPair->m_value.namesB.GetCount(); ++i) { strFontInfo += pPair->m_value.namesB[i]; strFontInfo += _T(","); } strFontInfo += _T(";"); for (size_t i = 0; i < pPair->m_value.namesBI.GetCount(); ++i) { strFontInfo += pPair->m_value.namesBI[i]; strFontInfo += _T(","); } strFontInfo += _T("]\n"); strInfos += strFontInfo; } oFile.WriteStringUTF8(strInfos); oFile.CloseFile(); #endif CFile oFileW; oFileW.CreateFile(strFontDictionaryPath); BYTE bom[3]; bom[0] = 0xEF; bom[1] = 0xBB; bom[2] = 0xBF; oFileW.WriteFile((void*)&bom, 3); CString strAll = _T(""); CString strConstant1 = _T("#ifndef _FONT_DICTIONARY_H\n\n\ typedef struct FD_FontMapRec_\n\ {\n\ const char* m_name;\n\ \n\ int m_index_r;\n\ int m_index_i;\n\ int m_index_b;\n\ int m_index_bi;\n\ } FD_FontMapRec;\n\n\ typedef struct FD_FontMapRecW_\n\ {\n\ const wchar_t* m_name;\n\ \n\ int m_index_r;\n\ int m_index_i;\n\ int m_index_b;\n\ int m_index_bi;\n\ } FD_FontMapRecW;\n\n"); strAll += strConstant1; int nAsciiNamesCount = (int)arrFonts.GetCount(); CString sAsciiNames = _T(""); sAsciiNames.Format(_T("#define FONTS_DICT_ASCII_NAMES_COUNT %d\n"), nAsciiNamesCount); sAsciiNames += _T("static const FD_FontMapRec FD_Ascii_Names[FONTS_DICT_ASCII_NAMES_COUNT] = \n{\n"); for (int k = 0; k < nAsciiNamesCount; ++k) { CAtlMap<CString, CFontInfoJS>::CPair* pPair = mapFonts.Lookup(arrFonts[k]); sAsciiNames += _T("\t{ \""); sAsciiNames += pPair->m_value.m_sName; sAsciiNames += _T("\", "); CString strP = _T(""); if (k != (nAsciiNamesCount - 1)) { strP.Format(_T("%d, %d, %d, %d },\n"), pPair->m_value.m_lIndexR, pPair->m_value.m_lIndexI, pPair->m_value.m_lIndexB, pPair->m_value.m_lIndexBI); } else { strP.Format(_T("%d, %d, %d, %d }\n"), pPair->m_value.m_lIndexR, pPair->m_value.m_lIndexI, pPair->m_value.m_lIndexB, pPair->m_value.m_lIndexBI); } sAsciiNames += strP; } sAsciiNames += _T("};\n\n"); strAll += sAsciiNames; int _offsets[256]; for (int t = 0; t < 256; ++t) _offsets[t] = -1; int nCurChar = -1; for (int k = 0; k < nAsciiNamesCount; ++k) { int nChar = (int)arrFonts[k].GetAt(0); nChar = max(0, min(nChar, 255)); if (nChar != nCurChar) { _offsets[nChar] = k; } nCurChar = nChar; } CString strAsciiOffsets = _T("static const int FD_Ascii_Names_Offsets[256] =\n{\n"); for (int k = 0; k < 256; ++k) { CString sMem = _T(""); sMem.Format(_T("%d"), _offsets[k]); while (sMem.GetLength() < 4) sMem = (_T(" ") + sMem); if (0 == k % 32) sMem = _T("\t") + sMem; if (k != 255) sMem += _T(","); if (0 == (k + 1) % 32) sMem += _T("\n"); strAsciiOffsets += sMem; } strAsciiOffsets += _T("};\n\n"); strAll += strAsciiOffsets; int nUnicodeNamesCount = (int)arrFontsUnicodes.GetCount(); CString sUnicodeNames = _T(""); sUnicodeNames.Format(_T("#define FONTS_DICT_UNICODE_NAMES_COUNT %d\n"), nUnicodeNamesCount); sUnicodeNames += _T("static const FD_FontMapRecW FD_Unicode_Names[FONTS_DICT_UNICODE_NAMES_COUNT] = \n{\n"); for (int k = 0; k < nUnicodeNamesCount; ++k) { CAtlMap<CString, CFontInfoJS>::CPair* pPair = mapFontsUnicodes.Lookup(arrFontsUnicodes[k]); sUnicodeNames += _T("\t{ L\""); sUnicodeNames += pPair->m_value.m_sName; sUnicodeNames += _T("\", "); CString strP = _T(""); if (k != (nAsciiNamesCount - 1)) { strP.Format(_T("%d, %d, %d, %d },\n"), pPair->m_value.m_lIndexR, pPair->m_value.m_lIndexI, pPair->m_value.m_lIndexB, pPair->m_value.m_lIndexBI); } else { strP.Format(_T("%d, %d, %d, %d }\n"), pPair->m_value.m_lIndexR, pPair->m_value.m_lIndexI, pPair->m_value.m_lIndexB, pPair->m_value.m_lIndexBI); } sUnicodeNames += strP; } sUnicodeNames += _T("};\n\n"); strAll += sUnicodeNames; CString strConstant2 = _T("typedef struct FD_Font_Rec\n\ {\n\ const char* m_name;\n\ \n\ long m_lIndex;\n\ \n\ unsigned char m_bBold;\n\ unsigned char m_bItalic;\n\ unsigned char m_bIsFixed;\n\ \n\ unsigned char m_aPanose[10];\n\ unsigned long m_ulUnicodeRange1;\n\ unsigned long m_ulUnicodeRange2;\n\ unsigned long m_ulUnicodeRange3;\n\ unsigned long m_ulUnicodeRange4;\n\ \n\ unsigned long m_ulCodePageRange1;\n\ unsigned long m_ulCodePageRange2;\n\ \n\ unsigned short m_usWeigth;\n\ unsigned short m_usWidth;\n\ \n\ short m_sFamilyClass;\n\ unsigned char m_eFontFormat;\n\ \n\ short m_shAvgCharWidth;\n\ short m_shAscent;\n\ short m_shDescent;\n\ short m_shLineGap;\n\ short m_shXHeight;\n\ short m_shCapHeight;\n\ } FD_Font;\n\n"); strAll += strConstant2; int nAllFontsCount = (int)nCount; CString sAllFontsNames = _T(""); sAllFontsNames.Format(_T("#define FONTS_DICT_ASCII_FONTS_COUNT %d\n"), nCount); sAllFontsNames += _T("static const FD_Font FD_Ascii_Files[FONTS_DICT_ASCII_FONTS_COUNT] = \n{\n"); for (int k = 0; k < nCount; ++k) { CWinFontInfo* pInfo = (CWinFontInfo*)m_pList->GetByIndex(k); #if 1 // CORRECT!!! if (pInfo->m_wsFontName == _T("Monotype Sorts")) pInfo->m_aPanose[0] = 5; #endif CString sMem = _T(""); sMem.Format(_T("\", %d, %d, %d, %d, { %d, %d, %d, %d, %d, %d, %d, %d, %d, %d }, %u, %u, %u, %u, %u, %u, %u, %u, %d, %d, %d, %d, %d, %d, %d, %d }"), pInfo->m_lIndex, pInfo->m_bBold, pInfo->m_bItalic, pInfo->m_bIsFixed, pInfo->m_aPanose[0], pInfo->m_aPanose[1], pInfo->m_aPanose[2], pInfo->m_aPanose[3], pInfo->m_aPanose[4], pInfo->m_aPanose[5], pInfo->m_aPanose[6], pInfo->m_aPanose[7], pInfo->m_aPanose[8], pInfo->m_aPanose[9], pInfo->m_ulUnicodeRange1, pInfo->m_ulUnicodeRange2, pInfo->m_ulUnicodeRange3, pInfo->m_ulUnicodeRange4, pInfo->m_ulCodePageRange1, pInfo->m_ulCodePageRange2, pInfo->m_usWeigth, pInfo->m_usWidth, pInfo->m_sFamilyClass, pInfo->m_eFontFormat, pInfo->m_shAvgCharWidth, pInfo->m_shAscent, pInfo->m_shDescent, pInfo->m_shLineGap, pInfo->m_shXHeight, pInfo->m_shCapHeight); sAllFontsNames += _T("\t{\""); sAllFontsNames += pInfo->m_wsFontName; sAllFontsNames += sMem; if (k != (nCount - 1)) sAllFontsNames += _T(",\n"); else sAllFontsNames += _T("\n"); } sAllFontsNames += _T("};\n\n"); strAll += sAllFontsNames; CString strError = _T(""); strError.Format(_T("// error : %d\n\n"), nError); strAll += strError; strAll += _T("#endif /* _FONT_DICTIONARY_H */"); oFileW.WriteStringUTF8(strAll); oFileW.CloseFile(); if (NULL != m_pList) delete m_pList; return 0; }