| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 "xfa/src/fxfa/app/xfa_ffimage.h" | |
| 8 | |
| 9 #include "xfa/src/fxfa/app/xfa_ffapp.h" | |
| 10 #include "xfa/src/fxfa/app/xfa_ffdoc.h" | |
| 11 #include "xfa/src/fxfa/app/xfa_ffdraw.h" | |
| 12 #include "xfa/src/fxfa/app/xfa_ffpageview.h" | |
| 13 #include "xfa/src/fxfa/app/xfa_ffwidget.h" | |
| 14 | |
| 15 CXFA_FFImage::CXFA_FFImage(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) | |
| 16 : CXFA_FFDraw(pPageView, pDataAcc) {} | |
| 17 CXFA_FFImage::~CXFA_FFImage() { | |
| 18 CXFA_FFImage::UnloadWidget(); | |
| 19 } | |
| 20 FX_BOOL CXFA_FFImage::IsLoaded() { | |
| 21 return GetDataAcc()->GetImageImage() != NULL; | |
| 22 } | |
| 23 FX_BOOL CXFA_FFImage::LoadWidget() { | |
| 24 if (GetDataAcc()->GetImageImage()) { | |
| 25 return TRUE; | |
| 26 } | |
| 27 GetDataAcc()->LoadImageImage(); | |
| 28 return CXFA_FFDraw::LoadWidget(); | |
| 29 } | |
| 30 void CXFA_FFImage::UnloadWidget() { | |
| 31 GetDataAcc()->SetImageImage(NULL); | |
| 32 } | |
| 33 void CXFA_FFImage::RenderWidget(CFX_Graphics* pGS, | |
| 34 CFX_Matrix* pMatrix, | |
| 35 FX_DWORD dwStatus, | |
| 36 int32_t iRotate) { | |
| 37 if (!IsMatchVisibleStatus(dwStatus)) { | |
| 38 return; | |
| 39 } | |
| 40 CFX_Matrix mtRotate; | |
| 41 GetRotateMatrix(mtRotate); | |
| 42 if (pMatrix) { | |
| 43 mtRotate.Concat(*pMatrix); | |
| 44 } | |
| 45 CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); | |
| 46 if (CFX_DIBitmap* pDIBitmap = GetDataAcc()->GetImageImage()) { | |
| 47 CFX_RectF rtImage; | |
| 48 GetRectWithoutRotate(rtImage); | |
| 49 if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { | |
| 50 XFA_RectWidthoutMargin(rtImage, mgWidget); | |
| 51 } | |
| 52 int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; | |
| 53 int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; | |
| 54 if (CXFA_Para para = m_pDataAcc->GetPara()) { | |
| 55 iHorzAlign = para.GetHorizontalAlign(); | |
| 56 iVertAlign = para.GetVerticalAlign(); | |
| 57 } | |
| 58 CXFA_Value value = m_pDataAcc->GetFormValue(); | |
| 59 CXFA_Image imageObj = value.GetImage(); | |
| 60 int32_t iAspect = imageObj.GetAspect(); | |
| 61 int32_t iImageXDpi = 0; | |
| 62 int32_t iImageYDpi = 0; | |
| 63 m_pDataAcc->GetImageDpi(iImageXDpi, iImageYDpi); | |
| 64 XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, | |
| 65 iImageYDpi, iHorzAlign, iVertAlign); | |
| 66 } | |
| 67 } | |
| OLD | NEW |