| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "fpdfsdk/cfx_systemhandler.h" | 7 #include "fpdfsdk/cfx_systemhandler.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 FX_FLOAT top; | 50 FX_FLOAT top; |
| 51 FX_FLOAT right; | 51 FX_FLOAT right; |
| 52 FX_FLOAT bottom; | 52 FX_FLOAT bottom; |
| 53 device2page.Transform(static_cast<FX_FLOAT>(rect.left), | 53 device2page.Transform(static_cast<FX_FLOAT>(rect.left), |
| 54 static_cast<FX_FLOAT>(rect.top), left, top); | 54 static_cast<FX_FLOAT>(rect.top), left, top); |
| 55 device2page.Transform(static_cast<FX_FLOAT>(rect.right), | 55 device2page.Transform(static_cast<FX_FLOAT>(rect.right), |
| 56 static_cast<FX_FLOAT>(rect.bottom), right, bottom); | 56 static_cast<FX_FLOAT>(rect.bottom), right, bottom); |
| 57 CFX_FloatRect rcPDF(left, bottom, right, top); | 57 CFX_FloatRect rcPDF(left, bottom, right, top); |
| 58 rcPDF.Normalize(); | 58 rcPDF.Normalize(); |
| 59 | 59 |
| 60 m_pEnv->Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, rcPDF.bottom); | 60 m_pFormFillEnv->Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, |
| 61 rcPDF.bottom); |
| 61 } | 62 } |
| 62 | 63 |
| 63 void CFX_SystemHandler::OutputSelectedRect(CFFL_FormFiller* pFormFiller, | 64 void CFX_SystemHandler::OutputSelectedRect(CFFL_FormFiller* pFormFiller, |
| 64 CFX_FloatRect& rect) { | 65 CFX_FloatRect& rect) { |
| 65 if (!pFormFiller) | 66 if (!pFormFiller) |
| 66 return; | 67 return; |
| 67 | 68 |
| 68 CFX_FloatPoint leftbottom = CFX_FloatPoint(rect.left, rect.bottom); | 69 CFX_FloatPoint leftbottom = CFX_FloatPoint(rect.left, rect.bottom); |
| 69 CFX_FloatPoint righttop = CFX_FloatPoint(rect.right, rect.top); | 70 CFX_FloatPoint righttop = CFX_FloatPoint(rect.right, rect.top); |
| 70 CFX_FloatPoint ptA = pFormFiller->PWLtoFFL(leftbottom); | 71 CFX_FloatPoint ptA = pFormFiller->PWLtoFFL(leftbottom); |
| 71 CFX_FloatPoint ptB = pFormFiller->PWLtoFFL(righttop); | 72 CFX_FloatPoint ptB = pFormFiller->PWLtoFFL(righttop); |
| 72 | 73 |
| 73 CPDFSDK_Annot* pAnnot = pFormFiller->GetSDKAnnot(); | 74 CPDFSDK_Annot* pAnnot = pFormFiller->GetSDKAnnot(); |
| 74 UnderlyingPageType* pPage = pAnnot->GetUnderlyingPage(); | 75 UnderlyingPageType* pPage = pAnnot->GetUnderlyingPage(); |
| 75 ASSERT(pPage); | 76 ASSERT(pPage); |
| 76 | 77 |
| 77 m_pEnv->OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y); | 78 m_pFormFillEnv->OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y); |
| 78 } | 79 } |
| 79 | 80 |
| 80 bool CFX_SystemHandler::IsSelectionImplemented() const { | 81 bool CFX_SystemHandler::IsSelectionImplemented() const { |
| 81 if (!m_pEnv) | 82 if (!m_pFormFillEnv) |
| 82 return false; | 83 return false; |
| 83 | 84 |
| 84 FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo(); | 85 FPDF_FORMFILLINFO* pInfo = m_pFormFillEnv->GetFormFillInfo(); |
| 85 return pInfo && pInfo->FFI_OutputSelectedRect; | 86 return pInfo && pInfo->FFI_OutputSelectedRect; |
| 86 } | 87 } |
| 87 | 88 |
| 88 void CFX_SystemHandler::SetCursor(int32_t nCursorType) { | 89 void CFX_SystemHandler::SetCursor(int32_t nCursorType) { |
| 89 m_pEnv->SetCursor(nCursorType); | 90 m_pFormFillEnv->SetCursor(nCursorType); |
| 90 } | 91 } |
| 91 | 92 |
| 92 bool CFX_SystemHandler::FindNativeTrueTypeFont(CFX_ByteString sFontFaceName) { | 93 bool CFX_SystemHandler::FindNativeTrueTypeFont(CFX_ByteString sFontFaceName) { |
| 93 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 94 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 94 if (!pFontMgr) | 95 if (!pFontMgr) |
| 95 return false; | 96 return false; |
| 96 | 97 |
| 97 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); | 98 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); |
| 98 if (!pFontMapper) | 99 if (!pFontMapper) |
| 99 return false; | 100 return false; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 119 if (!pDoc) | 120 if (!pDoc) |
| 120 return nullptr; | 121 return nullptr; |
| 121 | 122 |
| 122 std::unique_ptr<CFX_Font> pFXFont(new CFX_Font); | 123 std::unique_ptr<CFX_Font> pFXFont(new CFX_Font); |
| 123 pFXFont->LoadSubst(sFontFaceName, TRUE, 0, 0, 0, CharSet2CP(nCharset), false); | 124 pFXFont->LoadSubst(sFontFaceName, TRUE, 0, 0, 0, CharSet2CP(nCharset), false); |
| 124 return pDoc->AddFont(pFXFont.get(), nCharset, FALSE); | 125 return pDoc->AddFont(pFXFont.get(), nCharset, FALSE); |
| 125 } | 126 } |
| 126 | 127 |
| 127 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, | 128 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, |
| 128 TimerCallback lpTimerFunc) { | 129 TimerCallback lpTimerFunc) { |
| 129 return m_pEnv->SetTimer(uElapse, lpTimerFunc); | 130 return m_pFormFillEnv->SetTimer(uElapse, lpTimerFunc); |
| 130 } | 131 } |
| 131 | 132 |
| 132 void CFX_SystemHandler::KillTimer(int32_t nID) { | 133 void CFX_SystemHandler::KillTimer(int32_t nID) { |
| 133 m_pEnv->KillTimer(nID); | 134 m_pFormFillEnv->KillTimer(nID); |
| 134 } | 135 } |
| 135 | 136 |
| 136 bool CFX_SystemHandler::IsSHIFTKeyDown(uint32_t nFlag) const { | 137 bool CFX_SystemHandler::IsSHIFTKeyDown(uint32_t nFlag) const { |
| 137 return !!m_pEnv->IsSHIFTKeyDown(nFlag); | 138 return !!m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 138 } | 139 } |
| 139 | 140 |
| 140 bool CFX_SystemHandler::IsCTRLKeyDown(uint32_t nFlag) const { | 141 bool CFX_SystemHandler::IsCTRLKeyDown(uint32_t nFlag) const { |
| 141 return !!m_pEnv->IsCTRLKeyDown(nFlag); | 142 return !!m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 142 } | 143 } |
| 143 | 144 |
| 144 bool CFX_SystemHandler::IsALTKeyDown(uint32_t nFlag) const { | 145 bool CFX_SystemHandler::IsALTKeyDown(uint32_t nFlag) const { |
| 145 return !!m_pEnv->IsALTKeyDown(nFlag); | 146 return !!m_pFormFillEnv->IsALTKeyDown(nFlag); |
| 146 } | 147 } |
| OLD | NEW |