Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: xfa/fgas/font/fgas_stdfontmgr.cpp

Issue 1885973002: Remove implicit cast from CFX_ByteString to (const char*). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Typo Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fgas/crt/fgas_stream.cpp ('k') | xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fgas/font/fgas_stdfontmgr.h" 7 #include "xfa/fgas/font/fgas_stdfontmgr.h"
8 8
9 #include "core/fxcrt/include/fx_stream.h" 9 #include "core/fxcrt/include/fx_stream.h"
10 #include "xfa/fgas/crt/fgas_codepage.h" 10 #include "xfa/fgas/crt/fgas_codepage.h"
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { 484 CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() {
485 Restart: 485 Restart:
486 void* pCurHandle = 486 void* pCurHandle =
487 m_FolderQueue.GetSize() == 0 487 m_FolderQueue.GetSize() == 0
488 ? NULL 488 ? NULL
489 : m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; 489 : m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle;
490 if (NULL == pCurHandle) { 490 if (NULL == pCurHandle) {
491 if (m_FolderPaths.GetSize() < 1) { 491 if (m_FolderPaths.GetSize() < 1) {
492 return ""; 492 return "";
493 } 493 }
494 pCurHandle = FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1]); 494 pCurHandle =
495 FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1].c_str());
495 FX_HandleParentPath hpp; 496 FX_HandleParentPath hpp;
496 hpp.pFileHandle = pCurHandle; 497 hpp.pFileHandle = pCurHandle;
497 hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1]; 498 hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1];
498 m_FolderQueue.Add(hpp); 499 m_FolderQueue.Add(hpp);
499 } 500 }
500 CFX_ByteString bsName; 501 CFX_ByteString bsName;
501 FX_BOOL bFolder; 502 FX_BOOL bFolder;
502 CFX_ByteString bsFolderSpearator = 503 CFX_ByteString bsFolderSpearator =
503 CFX_ByteString::FromUnicode(CFX_WideString(FX_GetFolderSeparator())); 504 CFX_ByteString::FromUnicode(CFX_WideString(FX_GetFolderSeparator()));
504 while (TRUE) { 505 while (TRUE) {
(...skipping 13 matching lines...) Expand all
518 continue; 519 continue;
519 } 520 }
520 if (bsName == "." || bsName == "..") { 521 if (bsName == "." || bsName == "..") {
521 continue; 522 continue;
522 } 523 }
523 if (bFolder) { 524 if (bFolder) {
524 FX_HandleParentPath hpp; 525 FX_HandleParentPath hpp;
525 hpp.bsParentPath = 526 hpp.bsParentPath =
526 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + 527 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath +
527 bsFolderSpearator + bsName; 528 bsFolderSpearator + bsName;
528 hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath); 529 hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str());
529 if (hpp.pFileHandle == NULL) { 530 if (hpp.pFileHandle == NULL) {
530 continue; 531 continue;
531 } 532 }
532 m_FolderQueue.Add(hpp); 533 m_FolderQueue.Add(hpp);
533 pCurHandle = hpp.pFileHandle; 534 pCurHandle = hpp.pFileHandle;
534 continue; 535 continue;
535 } 536 }
536 bsName = 537 bsName =
537 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + 538 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath +
538 bsFolderSpearator + bsName; 539 bsFolderSpearator + bsName;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 const FX_WCHAR* pszFontFamily) { 695 const FX_WCHAR* pszFontFamily) {
695 return nullptr; 696 return nullptr;
696 } 697 }
697 698
698 IFX_Font* CFX_FontMgrImp::GetFontByCodePage(uint16_t wCodePage, 699 IFX_Font* CFX_FontMgrImp::GetFontByCodePage(uint16_t wCodePage,
699 uint32_t dwFontStyles, 700 uint32_t dwFontStyles,
700 const FX_WCHAR* pszFontFamily) { 701 const FX_WCHAR* pszFontFamily) {
701 CFX_ByteString bsHash; 702 CFX_ByteString bsHash;
702 bsHash.Format("%d, %d", wCodePage, dwFontStyles); 703 bsHash.Format("%d, %d", wCodePage, dwFontStyles);
703 bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); 704 bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
704 uint32_t dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); 705 uint32_t dwHash = FX_HashCode_String_GetA(bsHash.c_str(), bsHash.GetLength());
705 706
706 CFX_ArrayTemplate<IFX_Font*>* pFonts = nullptr; 707 CFX_ArrayTemplate<IFX_Font*>* pFonts = nullptr;
707 if (m_Hash2Fonts.Lookup(dwHash, pFonts)) { 708 if (m_Hash2Fonts.Lookup(dwHash, pFonts)) {
708 if (!pFonts) 709 if (!pFonts)
709 return nullptr; 710 return nullptr;
710 711
711 if (pFonts->GetSize() != 0) 712 if (pFonts->GetSize() != 0)
712 return pFonts->GetAt(0)->Retain(); 713 return pFonts->GetAt(0)->Retain();
713 } 714 }
714 715
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 return nullptr; 752 return nullptr;
752 const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode); 753 const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode);
753 uint16_t wCodePage = x ? x->wCodePage : 0xFFFF; 754 uint16_t wCodePage = x ? x->wCodePage : 0xFFFF;
754 uint16_t wBitField = x ? x->wBitField : 0x03E7; 755 uint16_t wBitField = x ? x->wBitField : 0x03E7;
755 CFX_ByteString bsHash; 756 CFX_ByteString bsHash;
756 if (wCodePage == 0xFFFF) 757 if (wCodePage == 0xFFFF)
757 bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles); 758 bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles);
758 else 759 else
759 bsHash.Format("%d, %d", wCodePage, dwFontStyles); 760 bsHash.Format("%d, %d", wCodePage, dwFontStyles);
760 bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); 761 bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
761 uint32_t dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); 762 uint32_t dwHash = FX_HashCode_String_GetA(bsHash.c_str(), bsHash.GetLength());
762 CFX_ArrayTemplate<IFX_Font*>* pFonts = nullptr; 763 CFX_ArrayTemplate<IFX_Font*>* pFonts = nullptr;
763 if (m_Hash2Fonts.Lookup(dwHash, pFonts)) { 764 if (m_Hash2Fonts.Lookup(dwHash, pFonts)) {
764 if (!pFonts) 765 if (!pFonts)
765 return nullptr; 766 return nullptr;
766 for (int32_t i = 0; i < pFonts->GetSize(); ++i) { 767 for (int32_t i = 0; i < pFonts->GetSize(); ++i) {
767 if (VerifyUnicode(pFonts->GetAt(i), wUnicode)) 768 if (VerifyUnicode(pFonts->GetAt(i), wUnicode))
768 return pFonts->GetAt(i)->Retain(); 769 return pFonts->GetAt(i)->Retain();
769 } 770 }
770 } 771 }
771 if (!pFonts) 772 if (!pFonts)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 return pFontAccess ? LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE) 853 return pFontAccess ? LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE)
853 : nullptr; 854 : nullptr;
854 } 855 }
855 856
856 IFX_Font* CFX_FontMgrImp::LoadFont(const FX_WCHAR* pszFileName, 857 IFX_Font* CFX_FontMgrImp::LoadFont(const FX_WCHAR* pszFileName,
857 int32_t iFaceIndex, 858 int32_t iFaceIndex,
858 int32_t* pFaceCount) { 859 int32_t* pFaceCount) {
859 CFX_ByteString bsHash; 860 CFX_ByteString bsHash;
860 bsHash += CFX_WideString(pszFileName).UTF8Encode(); 861 bsHash += CFX_WideString(pszFileName).UTF8Encode();
861 862
862 uint32_t dwHash = 863 uint32_t dwHash = FX_HashCode_String_GetA(bsHash.c_str(), bsHash.GetLength());
863 FX_HashCode_String_GetA((const FX_CHAR*)bsHash, bsHash.GetLength());
864 IFX_FileAccess* pFontAccess = nullptr; 864 IFX_FileAccess* pFontAccess = nullptr;
865 if (!m_Hash2FileAccess.Lookup(dwHash, pFontAccess)) { 865 if (!m_Hash2FileAccess.Lookup(dwHash, pFontAccess)) {
866 pFontAccess = FX_CreateDefaultFileAccess(pszFileName); 866 pFontAccess = FX_CreateDefaultFileAccess(pszFileName);
867 m_Hash2FileAccess.SetAt(dwHash, pFontAccess); 867 m_Hash2FileAccess.SetAt(dwHash, pFontAccess);
868 } 868 }
869 869
870 return pFontAccess ? LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE) 870 return pFontAccess ? LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE)
871 : nullptr; 871 : nullptr;
872 } 872 }
873 873
(...skipping 13 matching lines...) Expand all
887 887
888 IFX_Font* CFX_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess, 888 IFX_Font* CFX_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess,
889 int32_t iFaceIndex, 889 int32_t iFaceIndex,
890 int32_t* pFaceCount, 890 int32_t* pFaceCount,
891 FX_BOOL bWantCache) { 891 FX_BOOL bWantCache) {
892 uint32_t dwHash = 0; 892 uint32_t dwHash = 0;
893 IFX_Font* pFont = nullptr; 893 IFX_Font* pFont = nullptr;
894 if (bWantCache) { 894 if (bWantCache) {
895 CFX_ByteString bsHash; 895 CFX_ByteString bsHash;
896 bsHash.Format("%d, %d", (uintptr_t)pFontAccess, iFaceIndex); 896 bsHash.Format("%d, %d", (uintptr_t)pFontAccess, iFaceIndex);
897 dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); 897 dwHash = FX_HashCode_String_GetA(bsHash.c_str(), bsHash.GetLength());
898 if (m_FileAccess2IFXFont.Lookup(dwHash, pFont)) { 898 if (m_FileAccess2IFXFont.Lookup(dwHash, pFont)) {
899 if (pFont) { 899 if (pFont) {
900 if (pFaceCount) 900 if (pFaceCount)
901 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces; 901 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces;
902 return pFont->Retain(); 902 return pFont->Retain();
903 } 903 }
904 } 904 }
905 } 905 }
906 906
907 CFX_Font* pInternalFont = new CFX_Font; 907 CFX_Font* pInternalFont = new CFX_Font;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 1025
1026 FXFT_Set_Pixel_Sizes(pFace, 0, 64); 1026 FXFT_Set_Pixel_Sizes(pFace, 0, 64);
1027 return pFace; 1027 return pFace;
1028 } 1028 }
1029 1029
1030 IFX_FileRead* CFX_FontMgrImp::CreateFontStream( 1030 IFX_FileRead* CFX_FontMgrImp::CreateFontStream(
1031 CFX_FontMapper* pFontMapper, 1031 CFX_FontMapper* pFontMapper,
1032 IFX_SystemFontInfo* pSystemFontInfo, 1032 IFX_SystemFontInfo* pSystemFontInfo,
1033 uint32_t index) { 1033 uint32_t index) {
1034 int iExact = 0; 1034 int iExact = 0;
1035 void* hFont = pSystemFontInfo->MapFont( 1035 void* hFont =
1036 0, 0, FXFONT_DEFAULT_CHARSET, 0, pFontMapper->GetFaceName(index), iExact); 1036 pSystemFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0,
1037 pFontMapper->GetFaceName(index).c_str(), iExact);
1037 if (!hFont) 1038 if (!hFont)
1038 return nullptr; 1039 return nullptr;
1039 1040
1040 uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0); 1041 uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0);
1041 if (dwFileSize == 0) 1042 if (dwFileSize == 0)
1042 return nullptr; 1043 return nullptr;
1043 1044
1044 uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); 1045 uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1);
1045 dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); 1046 dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize);
1046 1047
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 } 1503 }
1503 } 1504 }
1504 int32_t CFX_FontMgrImp::IsPartName(const CFX_WideString& Name1, 1505 int32_t CFX_FontMgrImp::IsPartName(const CFX_WideString& Name1,
1505 const CFX_WideString& Name2) { 1506 const CFX_WideString& Name2) {
1506 if (Name1.Find((const FX_WCHAR*)Name2) != -1) { 1507 if (Name1.Find((const FX_WCHAR*)Name2) != -1) {
1507 return 1; 1508 return 1;
1508 } 1509 }
1509 return 0; 1510 return 0;
1510 } 1511 }
1511 #endif 1512 #endif
OLDNEW
« no previous file with comments | « xfa/fgas/crt/fgas_stream.cpp ('k') | xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698