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

Side by Side Diff: core/fpdfapi/fpdf_font/fpdf_font.cpp

Issue 1841643002: Code change to avoid signed/unsigned mismatch warnings (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase 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 | « core/fpdfapi/fpdf_font/font_int.h ('k') | core/fpdfapi/fpdf_font/fpdf_font_cid_unittest.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 "core/fpdfapi/fpdf_font/font_int.h" 7 #include "core/fpdfapi/fpdf_font/font_int.h"
8 8
9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" 9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
10 #include "core/fpdfapi/fpdf_page/pageint.h" 10 #include "core/fpdfapi/fpdf_page/pageint.h"
(...skipping 27 matching lines...) Expand all
38 CFX_StockFontArray::~CFX_StockFontArray() { 38 CFX_StockFontArray::~CFX_StockFontArray() {
39 for (size_t i = 0; i < FX_ArraySize(m_StockFonts); ++i) { 39 for (size_t i = 0; i < FX_ArraySize(m_StockFonts); ++i) {
40 if (!m_StockFonts[i]) 40 if (!m_StockFonts[i])
41 continue; 41 continue;
42 CPDF_Dictionary* pFontDict = m_StockFonts[i]->GetFontDict(); 42 CPDF_Dictionary* pFontDict = m_StockFonts[i]->GetFontDict();
43 if (pFontDict) 43 if (pFontDict)
44 pFontDict->Release(); 44 pFontDict->Release();
45 } 45 }
46 } 46 }
47 47
48 CPDF_Font* CFX_StockFontArray::GetFont(int index) const { 48 CPDF_Font* CFX_StockFontArray::GetFont(uint32_t index) const {
49 if (index < 0 || index >= FX_ArraySize(m_StockFonts)) 49 if (index >= FX_ArraySize(m_StockFonts))
50 return nullptr; 50 return nullptr;
51 return m_StockFonts[index].get(); 51 return m_StockFonts[index].get();
52 } 52 }
53 53
54 void CFX_StockFontArray::SetFont(int index, CPDF_Font* font) { 54 void CFX_StockFontArray::SetFont(uint32_t index, CPDF_Font* font) {
55 if (index < 0 || index >= FX_ArraySize(m_StockFonts)) 55 if (index >= FX_ArraySize(m_StockFonts))
56 return; 56 return;
57 m_StockFonts[index].reset(font); 57 m_StockFonts[index].reset(font);
58 } 58 }
59 59
60 CPDF_FontGlobals::CPDF_FontGlobals() { 60 CPDF_FontGlobals::CPDF_FontGlobals() {
61 FXSYS_memset(m_EmbeddedCharsets, 0, sizeof(m_EmbeddedCharsets)); 61 FXSYS_memset(m_EmbeddedCharsets, 0, sizeof(m_EmbeddedCharsets));
62 FXSYS_memset(m_EmbeddedToUnicodes, 0, sizeof(m_EmbeddedToUnicodes)); 62 FXSYS_memset(m_EmbeddedToUnicodes, 0, sizeof(m_EmbeddedToUnicodes));
63 } 63 }
64 64
65 CPDF_FontGlobals::~CPDF_FontGlobals() {} 65 CPDF_FontGlobals::~CPDF_FontGlobals() {}
66 66
67 CPDF_Font* CPDF_FontGlobals::Find(CPDF_Document* pDoc, int index) { 67 CPDF_Font* CPDF_FontGlobals::Find(CPDF_Document* pDoc, uint32_t index) {
68 auto it = m_StockMap.find(pDoc); 68 auto it = m_StockMap.find(pDoc);
69 if (it == m_StockMap.end()) 69 if (it == m_StockMap.end())
70 return nullptr; 70 return nullptr;
71 return it->second ? it->second->GetFont(index) : nullptr; 71 return it->second ? it->second->GetFont(index) : nullptr;
72 } 72 }
73 73
74 void CPDF_FontGlobals::Set(CPDF_Document* pDoc, int index, CPDF_Font* pFont) { 74 void CPDF_FontGlobals::Set(CPDF_Document* pDoc,
75 uint32_t index,
76 CPDF_Font* pFont) {
75 if (!pdfium::ContainsKey(m_StockMap, pDoc)) 77 if (!pdfium::ContainsKey(m_StockMap, pDoc))
76 m_StockMap[pDoc].reset(new CFX_StockFontArray); 78 m_StockMap[pDoc].reset(new CFX_StockFontArray);
77 m_StockMap[pDoc]->SetFont(index, pFont); 79 m_StockMap[pDoc]->SetFont(index, pFont);
78 } 80 }
79 81
80 void CPDF_FontGlobals::Clear(CPDF_Document* pDoc) { 82 void CPDF_FontGlobals::Clear(CPDF_Document* pDoc) {
81 m_StockMap.erase(pDoc); 83 m_StockMap.erase(pDoc);
82 } 84 }
83 85
84 86
(...skipping 29 matching lines...) Expand all
114 return CFX_WideString(buf + index + 1, len); 116 return CFX_WideString(buf + index + 1, len);
115 } 117 }
116 if (m_pBaseMap) { 118 if (m_pBaseMap) {
117 return m_pBaseMap->UnicodeFromCID((uint16_t)charcode); 119 return m_pBaseMap->UnicodeFromCID((uint16_t)charcode);
118 } 120 }
119 return CFX_WideString(); 121 return CFX_WideString();
120 } 122 }
121 123
122 uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) { 124 uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) {
123 for (const auto& pair : m_Map) { 125 for (const auto& pair : m_Map) {
124 if (pair.second == unicode) 126 if (pair.second == static_cast<uint32_t>(unicode))
125 return pair.first; 127 return pair.first;
126 } 128 }
127 return 0; 129 return 0;
128 } 130 }
129 131
130 // Static. 132 // Static.
131 uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) { 133 uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) {
132 const FX_CHAR* buf = str.GetCStr(); 134 const FX_CHAR* buf = str.GetCStr();
133 int len = str.GetLength(); 135 int len = str.GetLength();
134 if (len == 0) 136 if (len == 0)
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 294 }
293 if (cid_set) { 295 if (cid_set) {
294 m_pBaseMap = CPDF_ModuleMgr::Get() 296 m_pBaseMap = CPDF_ModuleMgr::Get()
295 ->GetPageModule() 297 ->GetPageModule()
296 ->GetFontGlobals() 298 ->GetFontGlobals()
297 ->m_CMapManager.GetCID2UnicodeMap(cid_set, FALSE); 299 ->m_CMapManager.GetCID2UnicodeMap(cid_set, FALSE);
298 } else { 300 } else {
299 m_pBaseMap = NULL; 301 m_pBaseMap = NULL;
300 } 302 }
301 } 303 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_font/font_int.h ('k') | core/fpdfapi/fpdf_font/fpdf_font_cid_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698