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

Side by Side Diff: fpdfsdk/src/fpdf_sysfontinfo.cpp

Issue 1287193005: Use override in more classes in fpdfsdk/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits, rebase Created 5 years, 4 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/fpdf_dataavail.cpp ('k') | fpdfsdk/src/fpdfsave.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 "../../public/fpdf_sysfontinfo.h" 7 #include "../../public/fpdf_sysfontinfo.h"
8 #include "../include/fsdk_define.h" 8 #include "../include/fsdk_define.h"
9 #include "../include/pdfwindow/PWL_FontMap.h" 9 #include "../include/pdfwindow/PWL_FontMap.h"
10 10
11 class CFX_ExternalFontInfo final : public IFX_SystemFontInfo { 11 class CFX_ExternalFontInfo final : public IFX_SystemFontInfo {
12 public: 12 public:
13 CFX_ExternalFontInfo(FPDF_SYSFONTINFO* pInfo) : m_pInfo(pInfo) {} 13 explicit CFX_ExternalFontInfo(FPDF_SYSFONTINFO* pInfo) : m_pInfo(pInfo) {}
14 14
15 virtual void Release() override { 15 void Release() override {
16 if (m_pInfo->Release) 16 if (m_pInfo->Release)
17 m_pInfo->Release(m_pInfo); 17 m_pInfo->Release(m_pInfo);
18 delete this; 18 delete this;
19 } 19 }
20 20
21 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override { 21 FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override {
22 if (m_pInfo->EnumFonts) { 22 if (m_pInfo->EnumFonts) {
23 m_pInfo->EnumFonts(m_pInfo, pMapper); 23 m_pInfo->EnumFonts(m_pInfo, pMapper);
24 return TRUE; 24 return TRUE;
25 } 25 }
26 return FALSE; 26 return FALSE;
27 } 27 }
28 28
29 virtual void* MapFont(int weight, 29 void* MapFont(int weight,
30 FX_BOOL bItalic, 30 FX_BOOL bItalic,
31 int charset, 31 int charset,
32 int pitch_family, 32 int pitch_family,
33 const FX_CHAR* family, 33 const FX_CHAR* family,
34 int& iExact) override { 34 int& iExact) override {
35 if (m_pInfo->MapFont) 35 if (m_pInfo->MapFont)
36 return m_pInfo->MapFont(m_pInfo, weight, bItalic, charset, pitch_family, 36 return m_pInfo->MapFont(m_pInfo, weight, bItalic, charset, pitch_family,
37 family, &iExact); 37 family, &iExact);
38 return NULL; 38 return NULL;
39 } 39 }
40 40
41 virtual void* GetFont(const FX_CHAR* family) override { 41 void* GetFont(const FX_CHAR* family) override {
42 if (m_pInfo->GetFont) 42 if (m_pInfo->GetFont)
43 return m_pInfo->GetFont(m_pInfo, family); 43 return m_pInfo->GetFont(m_pInfo, family);
44 return NULL; 44 return NULL;
45 } 45 }
46 46
47 virtual FX_DWORD GetFontData(void* hFont, 47 FX_DWORD GetFontData(void* hFont,
48 FX_DWORD table, 48 FX_DWORD table,
49 uint8_t* buffer, 49 uint8_t* buffer,
50 FX_DWORD size) override { 50 FX_DWORD size) override {
51 if (m_pInfo->GetFontData) 51 if (m_pInfo->GetFontData)
52 return m_pInfo->GetFontData(m_pInfo, hFont, table, buffer, size); 52 return m_pInfo->GetFontData(m_pInfo, hFont, table, buffer, size);
53 return 0; 53 return 0;
54 } 54 }
55 55
56 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override { 56 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override {
57 if (m_pInfo->GetFaceName == NULL) 57 if (m_pInfo->GetFaceName == NULL)
58 return FALSE; 58 return FALSE;
59 FX_DWORD size = m_pInfo->GetFaceName(m_pInfo, hFont, NULL, 0); 59 FX_DWORD size = m_pInfo->GetFaceName(m_pInfo, hFont, NULL, 0);
60 if (size == 0) 60 if (size == 0)
61 return FALSE; 61 return FALSE;
62 char* buffer = FX_Alloc(char, size); 62 char* buffer = FX_Alloc(char, size);
63 size = m_pInfo->GetFaceName(m_pInfo, hFont, buffer, size); 63 size = m_pInfo->GetFaceName(m_pInfo, hFont, buffer, size);
64 name = CFX_ByteString(buffer, size); 64 name = CFX_ByteString(buffer, size);
65 FX_Free(buffer); 65 FX_Free(buffer);
66 return TRUE; 66 return TRUE;
67 } 67 }
68 68
69 virtual FX_BOOL GetFontCharset(void* hFont, int& charset) override { 69 FX_BOOL GetFontCharset(void* hFont, int& charset) override {
70 if (m_pInfo->GetFontCharset) { 70 if (m_pInfo->GetFontCharset) {
71 charset = m_pInfo->GetFontCharset(m_pInfo, hFont); 71 charset = m_pInfo->GetFontCharset(m_pInfo, hFont);
72 return TRUE; 72 return TRUE;
73 } 73 }
74 return FALSE; 74 return FALSE;
75 } 75 }
76 76
77 virtual void DeleteFont(void* hFont) override { 77 void DeleteFont(void* hFont) override {
78 if (m_pInfo->DeleteFont) 78 if (m_pInfo->DeleteFont)
79 m_pInfo->DeleteFont(m_pInfo, hFont); 79 m_pInfo->DeleteFont(m_pInfo, hFont);
80 } 80 }
81 81
82 private: 82 private:
83 ~CFX_ExternalFontInfo() {} 83 ~CFX_ExternalFontInfo() override {}
84 84
85 FPDF_SYSFONTINFO* const m_pInfo; 85 FPDF_SYSFONTINFO* const m_pInfo;
86 }; 86 };
87 87
88 DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, 88 DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper,
89 const char* name, 89 const char* name,
90 int charset) { 90 int charset) {
91 ((CFX_FontMapper*)mapper)->AddInstalledFont(name, charset); 91 ((CFX_FontMapper*)mapper)->AddInstalledFont(name, charset);
92 } 92 }
93 93
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 pFontInfoExt->GetFaceName = DefaultGetFaceName; 179 pFontInfoExt->GetFaceName = DefaultGetFaceName;
180 pFontInfoExt->GetFont = DefaultGetFont; 180 pFontInfoExt->GetFont = DefaultGetFont;
181 pFontInfoExt->GetFontCharset = DefaultGetFontCharset; 181 pFontInfoExt->GetFontCharset = DefaultGetFontCharset;
182 pFontInfoExt->GetFontData = DefaultGetFontData; 182 pFontInfoExt->GetFontData = DefaultGetFontData;
183 pFontInfoExt->MapFont = DefaultMapFont; 183 pFontInfoExt->MapFont = DefaultMapFont;
184 pFontInfoExt->Release = DefaultRelease; 184 pFontInfoExt->Release = DefaultRelease;
185 pFontInfoExt->version = 1; 185 pFontInfoExt->version = 1;
186 pFontInfoExt->m_pFontInfo = pFontInfo; 186 pFontInfoExt->m_pFontInfo = pFontInfo;
187 return pFontInfoExt; 187 return pFontInfoExt;
188 } 188 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdf_dataavail.cpp ('k') | fpdfsdk/src/fpdfsave.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698