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

Side by Side Diff: xfa/fxfa/app/xfa_fontmgr.cpp

Issue 1979723003: Make CFX_WideString(const CFX_WideString&) explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Override Created 4 years, 7 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/fxfa/app/xfa_ffwidgethandler.cpp ('k') | xfa/fxfa/app/xfa_textlayout.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/fxfa/include/xfa_fontmgr.h" 7 #include "xfa/fxfa/include/xfa_fontmgr.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 break; 1706 break;
1707 } else if (dwFontNameHash < dwLocalNameHash) { 1707 } else if (dwFontNameHash < dwLocalNameHash) {
1708 iStart = iMid + 1; 1708 iStart = iMid + 1;
1709 } else { 1709 } else {
1710 iEnd = iMid - 1; 1710 iEnd = iMid - 1;
1711 } 1711 }
1712 } while (iEnd >= iStart); 1712 } while (iEnd >= iStart);
1713 } 1713 }
1714 const XFA_FONTINFO* XFA_GetFontINFOByFontName( 1714 const XFA_FONTINFO* XFA_GetFontINFOByFontName(
1715 const CFX_WideStringC& wsFontName) { 1715 const CFX_WideStringC& wsFontName) {
1716 CFX_WideString wsFontNameTemp = wsFontName; 1716 CFX_WideString wsFontNameTemp(wsFontName);
1717 wsFontNameTemp.Remove(L' '); 1717 wsFontNameTemp.Remove(L' ');
1718 uint32_t dwCurFontNameHash = 1718 uint32_t dwCurFontNameHash =
1719 FX_HashCode_GetW(wsFontNameTemp.AsStringC(), true); 1719 FX_HashCode_GetW(wsFontNameTemp.AsStringC(), true);
1720 int32_t iStart = 0; 1720 int32_t iStart = 0;
1721 int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1; 1721 int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1;
1722 int32_t iMid = 0; 1722 int32_t iMid = 0;
1723 const XFA_FONTINFO* pFontInfo = NULL; 1723 const XFA_FONTINFO* pFontInfo = NULL;
1724 do { 1724 do {
1725 iMid = (iStart + iEnd) / 2; 1725 iMid = (iStart + iEnd) / 2;
1726 uint32_t dwFontNameHash = g_XFAFontsMap[iMid].dwFontNameHash; 1726 uint32_t dwFontNameHash = g_XFAFontsMap[iMid].dwFontNameHash;
(...skipping 11 matching lines...) Expand all
1738 1738
1739 CXFA_DefFontMgr::~CXFA_DefFontMgr() { 1739 CXFA_DefFontMgr::~CXFA_DefFontMgr() {
1740 for (int32_t i = 0; i < m_CacheFonts.GetSize(); i++) 1740 for (int32_t i = 0; i < m_CacheFonts.GetSize(); i++)
1741 m_CacheFonts[i]->Release(); 1741 m_CacheFonts[i]->Release();
1742 } 1742 }
1743 1743
1744 IFX_Font* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc, 1744 IFX_Font* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc,
1745 const CFX_WideStringC& wsFontFamily, 1745 const CFX_WideStringC& wsFontFamily,
1746 uint32_t dwFontStyles, 1746 uint32_t dwFontStyles,
1747 uint16_t wCodePage) { 1747 uint16_t wCodePage) {
1748 CFX_WideString wsFontName = wsFontFamily; 1748 CFX_WideString wsFontName(wsFontFamily);
1749 IFX_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr(); 1749 IFX_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr();
1750 IFX_Font* pFont = 1750 IFX_Font* pFont =
1751 pFDEFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage); 1751 pFDEFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage);
1752 if (!pFont) { 1752 if (!pFont) {
1753 const XFA_FONTINFO* pCurFont = 1753 const XFA_FONTINFO* pCurFont =
1754 XFA_GetFontINFOByFontName(wsFontName.AsStringC()); 1754 XFA_GetFontINFOByFontName(wsFontName.AsStringC());
1755 if (pCurFont && pCurFont->pReplaceFont) { 1755 if (pCurFont && pCurFont->pReplaceFont) {
1756 uint32_t dwStyle = 0; 1756 uint32_t dwStyle = 0;
1757 if (dwFontStyles & FX_FONTSTYLE_Bold) { 1757 if (dwFontStyles & FX_FONTSTYLE_Bold) {
1758 dwStyle |= FX_FONTSTYLE_Bold; 1758 dwStyle |= FX_FONTSTYLE_Bold;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 IFX_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily, 1875 IFX_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily,
1876 uint32_t dwFontStyles, 1876 uint32_t dwFontStyles,
1877 CPDF_Font** pPDFFont, 1877 CPDF_Font** pPDFFont,
1878 FX_BOOL bStrictMatch) { 1878 FX_BOOL bStrictMatch) {
1879 uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false); 1879 uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false);
1880 CFX_ByteString strKey; 1880 CFX_ByteString strKey;
1881 strKey.Format("%u%u", dwHashCode, dwFontStyles); 1881 strKey.Format("%u%u", dwHashCode, dwFontStyles);
1882 auto it = m_FontMap.find(strKey); 1882 auto it = m_FontMap.find(strKey);
1883 if (it != m_FontMap.end()) 1883 if (it != m_FontMap.end())
1884 return it->second; 1884 return it->second;
1885 CFX_ByteString bsPsName = CFX_ByteString::FromUnicode(wsFontFamily); 1885 CFX_ByteString bsPsName =
1886 CFX_ByteString::FromUnicode(CFX_WideString(wsFontFamily));
1886 FX_BOOL bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold; 1887 FX_BOOL bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold;
1887 FX_BOOL bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic; 1888 FX_BOOL bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic;
1888 CFX_ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic); 1889 CFX_ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic);
1889 IFX_Font* pFont = 1890 IFX_Font* pFont =
1890 FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch); 1891 FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch);
1891 if (pFont) 1892 if (pFont)
1892 m_FontMap[strKey] = pFont; 1893 m_FontMap[strKey] = pFont;
1893 return pFont; 1894 return pFont;
1894 } 1895 }
1895 1896
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2065 CXFA_PDFFontMgr* pMgr = NULL; 2066 CXFA_PDFFontMgr* pMgr = NULL;
2066 m_PDFFontMgrArray.GetNextAssoc(ps, (void*&)hDoc, (void*&)pMgr); 2067 m_PDFFontMgrArray.GetNextAssoc(ps, (void*&)hDoc, (void*&)pMgr);
2067 delete pMgr; 2068 delete pMgr;
2068 } 2069 }
2069 m_PDFFontMgrArray.RemoveAll(); 2070 m_PDFFontMgrArray.RemoveAll();
2070 m_FontMap.clear(); 2071 m_FontMap.clear();
2071 } 2072 }
2072 void CXFA_FontMgr::SetDefFontMgr(CXFA_DefFontMgr* pFontMgr) { 2073 void CXFA_FontMgr::SetDefFontMgr(CXFA_DefFontMgr* pFontMgr) {
2073 m_pDefFontMgr = pFontMgr; 2074 m_pDefFontMgr = pFontMgr;
2074 } 2075 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffwidgethandler.cpp ('k') | xfa/fxfa/app/xfa_textlayout.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698