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

Side by Side Diff: fpdfsdk/cfx_systemhandler.cpp

Issue 1923093002: Remove IFX_SystemHandler. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "fpdfsdk/cfx_systemhandler.h"
8
9 #include "fpdfsdk/formfiller/cffl_formfiller.h"
10 #include "fpdfsdk/include/fsdk_mgr.h"
11
12 namespace {
13
14 int CharSet2CP(int charset) {
15 if (charset == 128)
16 return 932;
17 if (charset == 134)
18 return 936;
19 if (charset == 129)
20 return 949;
21 if (charset == 136)
22 return 950;
23 return 0;
24 }
25
26 } // namespace
27
28 void CFX_SystemHandler::SetCursor(int32_t nCursorType) {
29 m_pEnv->FFI_SetCursor(nCursorType);
30 }
31
32 void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect) {
33 CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd;
34 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView();
35 UnderlyingPageType* pPage = pSDKAnnot->GetUnderlyingPage();
36 if (!pPage || !pPageView)
37 return;
38
39 CFX_Matrix page2device;
40 pPageView->GetCurrentMatrix(page2device);
41 CFX_Matrix device2page;
42 device2page.SetReverse(page2device);
43 FX_FLOAT left, top, right, bottom;
44 device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top);
45 device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right,
46 bottom);
47 CFX_FloatRect rcPDF(left, bottom, right, top);
48 rcPDF.Normalize();
49
50 m_pEnv->FFI_Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right,
51 rcPDF.bottom);
52 }
53
54 void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller,
55 CFX_FloatRect& rect) {
56 CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller;
57 if (!pFFL)
58 return;
59
60 CFX_FloatPoint leftbottom = CFX_FloatPoint(rect.left, rect.bottom);
61 CFX_FloatPoint righttop = CFX_FloatPoint(rect.right, rect.top);
62 CFX_FloatPoint ptA = pFFL->PWLtoFFL(leftbottom);
63 CFX_FloatPoint ptB = pFFL->PWLtoFFL(righttop);
64 CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot();
65 UnderlyingPageType* pPage = pAnnot->GetUnderlyingPage();
66 ASSERT(pPage);
67
68 m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y);
69 }
70
71 FX_BOOL CFX_SystemHandler::IsSelectionImplemented() {
72 if (m_pEnv) {
73 FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo();
74 if (pInfo && pInfo->FFI_OutputSelectedRect)
75 return TRUE;
76 }
77 return FALSE;
78 }
79
80 FX_BOOL CFX_SystemHandler::FindNativeTrueTypeFont(
81 int32_t nCharset,
82 CFX_ByteString sFontFaceName) {
83 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
84 if (!pFontMgr)
85 return FALSE;
86
87 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
88 if (!pFontMapper)
89 return FALSE;
90
91 if (pFontMapper->m_InstalledTTFonts.empty())
92 pFontMapper->LoadInstalledFonts();
93
94 for (const auto& font : pFontMapper->m_InstalledTTFonts) {
95 if (font.Compare(sFontFaceName.AsStringC()))
96 return TRUE;
97 }
98
99 return FALSE;
100 }
101
102 CPDF_Font* CFX_SystemHandler::AddNativeTrueTypeFontToPDF(
103 CPDF_Document* pDoc,
104 CFX_ByteString sFontFaceName,
105 uint8_t nCharset) {
106 if (!pDoc)
107 return nullptr;
108
109 CFX_Font* pFXFont = new CFX_Font();
110 pFXFont->LoadSubst(sFontFaceName, TRUE, 0, 0, 0, CharSet2CP(nCharset), FALSE);
111 CPDF_Font* pFont = pDoc->AddFont(pFXFont, nCharset, FALSE);
112 delete pFXFont;
113 return pFont;
114 }
115
116 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse,
117 TimerCallback lpTimerFunc) {
118 return m_pEnv->FFI_SetTimer(uElapse, lpTimerFunc);
119 }
120
121 void CFX_SystemHandler::KillTimer(int32_t nID) {
122 m_pEnv->FFI_KillTimer(nID);
123 }
124
125 FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() {
126 return m_pEnv->FFI_GetLocalTime();
127 }
128
129 FX_BOOL CFX_SystemHandler::IsSHIFTKeyDown(uint32_t nFlag) {
130 return m_pEnv->FFI_IsSHIFTKeyDown(nFlag);
131 }
132
133 FX_BOOL CFX_SystemHandler::IsCTRLKeyDown(uint32_t nFlag) {
134 return m_pEnv->FFI_IsCTRLKeyDown(nFlag);
135 }
136
137 FX_BOOL CFX_SystemHandler::IsALTKeyDown(uint32_t nFlag) {
138 return m_pEnv->FFI_IsALTKeyDown(nFlag);
139 }
140
141 FX_BOOL CFX_SystemHandler::IsINSERTKeyDown(uint32_t nFlag) {
142 return m_pEnv->FFI_IsINSERTKeyDown(nFlag);
143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698