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

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_FontMap.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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 | « fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Icon.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 "../../include/pdfwindow/PDFWindow.h" 7 #include "../../include/pdfwindow/PDFWindow.h"
8 #include "../../include/pdfwindow/PWL_Wnd.h" 8 #include "../../include/pdfwindow/PWL_Wnd.h"
9 #include "../../include/pdfwindow/PWL_FontMap.h" 9 #include "../../include/pdfwindow/PWL_FontMap.h"
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 { 65 {
66 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) 66 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
67 { 67 {
68 return pData->sFontName; 68 return pData->sFontName;
69 } 69 }
70 } 70 }
71 71
72 return ""; 72 return "";
73 } 73 }
74 74
75 FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word) 75 bool CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word)
76 { 76 {
77 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) 77 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
78 { 78 {
79 if (m_aData.GetAt(nFontIndex)) 79 if (m_aData.GetAt(nFontIndex))
80 { 80 {
81 return CharCodeFromUnicode(nFontIndex, word) >= 0; 81 return CharCodeFromUnicode(nFontIndex, word) >= 0;
82 } 82 }
83 } 83 }
84 84
85 » return FALSE; 85 » return false;
86 } 86 }
87 87
88 int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word, int32_t nCharset, int32_t n FontIndex) 88 int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word, int32_t nCharset, int32_t n FontIndex)
89 { 89 {
90 if (nFontIndex > 0) 90 if (nFontIndex > 0)
91 { 91 {
92 if (KnowWord(nFontIndex, word)) 92 if (KnowWord(nFontIndex, word))
93 return nFontIndex; 93 return nFontIndex;
94 } 94 }
95 else 95 else
96 { 96 {
97 if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) 97 if (const CPWL_FontMap_Data* pData = GetFontMapData(0))
98 { 98 {
99 if (nCharset == DEFAULT_CHARSET || 99 if (nCharset == DEFAULT_CHARSET ||
100 pData->nCharset == SYMBOL_CHARSET || 100 pData->nCharset == SYMBOL_CHARSET ||
101 nCharset == pData->nCharset) 101 nCharset == pData->nCharset)
102 { 102 {
103 if (KnowWord(0, word)) 103 if (KnowWord(0, word))
104 { 104 {
105 return 0; 105 return 0;
106 } 106 }
107 } 107 }
108 } 108 }
109 } 109 }
110 110
111 int32_t nNewFontIndex = -1; 111 int32_t nNewFontIndex = -1;
112 112
113 » nNewFontIndex = GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE ); 113 » nNewFontIndex = GetFontIndex(GetNativeFontName(nCharset), nCharset, true );
114 if (nNewFontIndex >= 0) 114 if (nNewFontIndex >= 0)
115 { 115 {
116 if (KnowWord(nNewFontIndex, word)) 116 if (KnowWord(nNewFontIndex, word))
117 return nNewFontIndex; 117 return nNewFontIndex;
118 } 118 }
119 119
120 » nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE) ; 120 » nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, false) ;
121 if (nNewFontIndex >= 0) 121 if (nNewFontIndex >= 0)
122 { 122 {
123 if (KnowWord(nNewFontIndex, word)) 123 if (KnowWord(nNewFontIndex, word))
124 return nNewFontIndex; 124 return nNewFontIndex;
125 } 125 }
126 126
127 return -1; 127 return -1;
128 } 128 }
129 129
130 int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word) 130 int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 } 193 }
194 194
195 void CPWL_FontMap::Initial(const FX_CHAR* fontname) 195 void CPWL_FontMap::Initial(const FX_CHAR* fontname)
196 { 196 {
197 CFX_ByteString sFontName = fontname; 197 CFX_ByteString sFontName = fontname;
198 198
199 if (sFontName.IsEmpty()) 199 if (sFontName.IsEmpty())
200 sFontName = DEFAULT_FONT_NAME; 200 sFontName = DEFAULT_FONT_NAME;
201 201
202 » GetFontIndex(sFontName, ANSI_CHARSET, FALSE); 202 » GetFontIndex(sFontName, ANSI_CHARSET, false);
203 } 203 }
204 204
205 205
206 /* 206 /*
207 List of currently supported standard fonts: 207 List of currently supported standard fonts:
208 Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique 208 Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique
209 Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique 209 Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique
210 Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic 210 Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic
211 Symbol, ZapfDingbats 211 Symbol, ZapfDingbats
212 */ 212 */
213 213
214 const char* g_sDEStandardFontName[] = {"Courier", "Courier-Bold", "Courier-BoldO blique", "Courier-Oblique", 214 const char* g_sDEStandardFontName[] = {"Courier", "Courier-Bold", "Courier-BoldO blique", "Courier-Oblique",
215 "Helvetica", "Helvetica-Bold", "Helvetica-BoldOblique", "Helvetica-Obliq ue", 215 "Helvetica", "Helvetica-Bold", "Helvetica-BoldOblique", "Helvetica-Obliq ue",
216 "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", 216 "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic",
217 "Symbol", "ZapfDingbats"}; 217 "Symbol", "ZapfDingbats"};
218 218
219 FX_BOOL»CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) 219 bool» CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName)
220 { 220 {
221 for (int32_t i=0; i<14; i++) 221 for (int32_t i=0; i<14; i++)
222 { 222 {
223 if (sFontName == g_sDEStandardFontName[i]) 223 if (sFontName == g_sDEStandardFontName[i])
224 » » » return TRUE; 224 » » » return true;
225 } 225 }
226 226
227 » return FALSE; 227 » return false;
228 } 228 }
229 229
230 int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, int32_t nCharset ) 230 int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, int32_t nCharset )
231 { 231 {
232 for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++) 232 for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++)
233 { 233 {
234 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) 234 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i))
235 { 235 {
236 if (nCharset == DEFAULT_CHARSET || nCharset == pData->nC harset) 236 if (nCharset == DEFAULT_CHARSET || nCharset == pData->nC harset)
237 { 237 {
238 if (sFontName.IsEmpty() || pData->sFontName == s FontName) 238 if (sFontName.IsEmpty() || pData->sFontName == s FontName)
239 return i; 239 return i;
240 } 240 }
241 } 241 }
242 } 242 }
243 243
244 return -1; 244 return -1;
245 } 245 }
246 246
247 int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, int32_t nCha rset, FX_BOOL bFind) 247 int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, int32_t nCha rset, bool bFind)
248 { 248 {
249 int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCha rset); 249 int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCha rset);
250 if (nFontIndex >= 0) return nFontIndex; 250 if (nFontIndex >= 0) return nFontIndex;
251 251
252 // nFontIndex = FindFont("", nCharset); 252 // nFontIndex = FindFont("", nCharset);
253 // if (nFontIndex >= 0) return nFontIndex; 253 // if (nFontIndex >= 0) return nFontIndex;
254 254
255 CFX_ByteString sAlias; 255 CFX_ByteString sAlias;
256 CPDF_Font* pFont = NULL; 256 CPDF_Font* pFont = NULL;
257 257
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 } 587 }
588 588
589 CPWL_DocFontMap::~CPWL_DocFontMap() 589 CPWL_DocFontMap::~CPWL_DocFontMap()
590 { 590 {
591 } 591 }
592 592
593 CPDF_Document* CPWL_DocFontMap::GetDocument() 593 CPDF_Document* CPWL_DocFontMap::GetDocument()
594 { 594 {
595 return m_pAttachedDoc; 595 return m_pAttachedDoc;
596 } 596 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Icon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698