| 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 17 matching lines...) Expand all Loading... |
| 28 if (charset == FXFONT_HANGEUL_CHARSET) | 28 if (charset == FXFONT_HANGEUL_CHARSET) |
| 29 return 949; | 29 return 949; |
| 30 if (charset == FXFONT_CHINESEBIG5_CHARSET) | 30 if (charset == FXFONT_CHINESEBIG5_CHARSET) |
| 31 return 950; | 31 return 950; |
| 32 return 0; | 32 return 0; |
| 33 } | 33 } |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 void CFX_SystemHandler::SetCursor(int32_t nCursorType) { | 37 void CFX_SystemHandler::SetCursor(int32_t nCursorType) { |
| 38 m_pEnv->FFI_SetCursor(nCursorType); | 38 m_pEnv->SetCursor(nCursorType); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect) { | 41 void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect) { |
| 42 CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd; | 42 CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd; |
| 43 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); | 43 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); |
| 44 UnderlyingPageType* pPage = pSDKAnnot->GetUnderlyingPage(); | 44 UnderlyingPageType* pPage = pSDKAnnot->GetUnderlyingPage(); |
| 45 if (!pPage || !pPageView) | 45 if (!pPage || !pPageView) |
| 46 return; | 46 return; |
| 47 | 47 |
| 48 CFX_Matrix page2device; | 48 CFX_Matrix page2device; |
| 49 pPageView->GetCurrentMatrix(page2device); | 49 pPageView->GetCurrentMatrix(page2device); |
| 50 CFX_Matrix device2page; | 50 CFX_Matrix device2page; |
| 51 device2page.SetReverse(page2device); | 51 device2page.SetReverse(page2device); |
| 52 FX_FLOAT left, top, right, bottom; | 52 FX_FLOAT left, top, right, bottom; |
| 53 device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top); | 53 device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top); |
| 54 device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right, | 54 device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right, |
| 55 bottom); | 55 bottom); |
| 56 CFX_FloatRect rcPDF(left, bottom, right, top); | 56 CFX_FloatRect rcPDF(left, bottom, right, top); |
| 57 rcPDF.Normalize(); | 57 rcPDF.Normalize(); |
| 58 | 58 |
| 59 m_pEnv->FFI_Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, | 59 m_pEnv->Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, rcPDF.bottom); |
| 60 rcPDF.bottom); | |
| 61 } | 60 } |
| 62 | 61 |
| 63 void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller, | 62 void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller, |
| 64 CFX_FloatRect& rect) { | 63 CFX_FloatRect& rect) { |
| 65 CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller; | 64 CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller; |
| 66 if (!pFFL) | 65 if (!pFFL) |
| 67 return; | 66 return; |
| 68 | 67 |
| 69 CFX_FloatPoint leftbottom = CFX_FloatPoint(rect.left, rect.bottom); | 68 CFX_FloatPoint leftbottom = CFX_FloatPoint(rect.left, rect.bottom); |
| 70 CFX_FloatPoint righttop = CFX_FloatPoint(rect.right, rect.top); | 69 CFX_FloatPoint righttop = CFX_FloatPoint(rect.right, rect.top); |
| 71 CFX_FloatPoint ptA = pFFL->PWLtoFFL(leftbottom); | 70 CFX_FloatPoint ptA = pFFL->PWLtoFFL(leftbottom); |
| 72 CFX_FloatPoint ptB = pFFL->PWLtoFFL(righttop); | 71 CFX_FloatPoint ptB = pFFL->PWLtoFFL(righttop); |
| 73 CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot(); | 72 CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot(); |
| 74 UnderlyingPageType* pPage = pAnnot->GetUnderlyingPage(); | 73 UnderlyingPageType* pPage = pAnnot->GetUnderlyingPage(); |
| 75 ASSERT(pPage); | 74 ASSERT(pPage); |
| 76 | 75 |
| 77 m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y); | 76 m_pEnv->OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y); |
| 78 } | 77 } |
| 79 | 78 |
| 80 bool CFX_SystemHandler::IsSelectionImplemented() const { | 79 bool CFX_SystemHandler::IsSelectionImplemented() const { |
| 81 if (m_pEnv) { | 80 if (m_pEnv) { |
| 82 FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo(); | 81 FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo(); |
| 83 if (pInfo && pInfo->FFI_OutputSelectedRect) | 82 if (pInfo && pInfo->FFI_OutputSelectedRect) |
| 84 return true; | 83 return true; |
| 85 } | 84 } |
| 86 return false; | 85 return false; |
| 87 } | 86 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 113 if (!pDoc) | 112 if (!pDoc) |
| 114 return nullptr; | 113 return nullptr; |
| 115 | 114 |
| 116 std::unique_ptr<CFX_Font> pFXFont(new CFX_Font); | 115 std::unique_ptr<CFX_Font> pFXFont(new CFX_Font); |
| 117 pFXFont->LoadSubst(sFontFaceName, TRUE, 0, 0, 0, CharSet2CP(nCharset), FALSE); | 116 pFXFont->LoadSubst(sFontFaceName, TRUE, 0, 0, 0, CharSet2CP(nCharset), FALSE); |
| 118 return pDoc->AddFont(pFXFont.get(), nCharset, FALSE); | 117 return pDoc->AddFont(pFXFont.get(), nCharset, FALSE); |
| 119 } | 118 } |
| 120 | 119 |
| 121 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, | 120 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, |
| 122 TimerCallback lpTimerFunc) { | 121 TimerCallback lpTimerFunc) { |
| 123 return m_pEnv->FFI_SetTimer(uElapse, lpTimerFunc); | 122 return m_pEnv->SetTimer(uElapse, lpTimerFunc); |
| 124 } | 123 } |
| 125 | 124 |
| 126 void CFX_SystemHandler::KillTimer(int32_t nID) { | 125 void CFX_SystemHandler::KillTimer(int32_t nID) { |
| 127 m_pEnv->FFI_KillTimer(nID); | 126 m_pEnv->KillTimer(nID); |
| 128 } | 127 } |
| 129 | 128 |
| 130 FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() { | 129 FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() { |
| 131 return m_pEnv->FFI_GetLocalTime(); | 130 return m_pEnv->GetLocalTime(); |
| 132 } | 131 } |
| 133 | 132 |
| 134 bool CFX_SystemHandler::IsSHIFTKeyDown(uint32_t nFlag) const { | 133 bool CFX_SystemHandler::IsSHIFTKeyDown(uint32_t nFlag) const { |
| 135 return !!m_pEnv->FFI_IsSHIFTKeyDown(nFlag); | 134 return !!m_pEnv->IsSHIFTKeyDown(nFlag); |
| 136 } | 135 } |
| 137 | 136 |
| 138 bool CFX_SystemHandler::IsCTRLKeyDown(uint32_t nFlag) const { | 137 bool CFX_SystemHandler::IsCTRLKeyDown(uint32_t nFlag) const { |
| 139 return !!m_pEnv->FFI_IsCTRLKeyDown(nFlag); | 138 return !!m_pEnv->IsCTRLKeyDown(nFlag); |
| 140 } | 139 } |
| 141 | 140 |
| 142 bool CFX_SystemHandler::IsALTKeyDown(uint32_t nFlag) const { | 141 bool CFX_SystemHandler::IsALTKeyDown(uint32_t nFlag) const { |
| 143 return !!m_pEnv->FFI_IsALTKeyDown(nFlag); | 142 return !!m_pEnv->IsALTKeyDown(nFlag); |
| 144 } | 143 } |
| OLD | NEW |