| OLD | NEW |
| 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 "xfa/include/fxfa/xfa_ffwidget.h" | 7 #include "xfa/include/fxfa/xfa_ffwidget.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 int32_t& iImageYDpi) { | 971 int32_t& iImageYDpi) { |
| 972 CFX_WideString wsHref; | 972 CFX_WideString wsHref; |
| 973 pImage->GetHref(wsHref); | 973 pImage->GetHref(wsHref); |
| 974 CFX_WideString wsImage; | 974 CFX_WideString wsImage; |
| 975 pImage->GetContent(wsImage); | 975 pImage->GetContent(wsImage); |
| 976 if (wsHref.IsEmpty() && wsImage.IsEmpty()) { | 976 if (wsHref.IsEmpty() && wsImage.IsEmpty()) { |
| 977 return NULL; | 977 return NULL; |
| 978 } | 978 } |
| 979 CFX_WideString wsContentType; | 979 CFX_WideString wsContentType; |
| 980 pImage->GetContentType(wsContentType); | 980 pImage->GetContentType(wsContentType); |
| 981 FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType); | 981 FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType.AsWideStringC()); |
| 982 CFX_ByteString bsContent; | 982 CFX_ByteString bsContent; |
| 983 uint8_t* pImageBuffer = NULL; | 983 uint8_t* pImageBuffer = NULL; |
| 984 IFX_FileRead* pImageFileRead = NULL; | 984 IFX_FileRead* pImageFileRead = NULL; |
| 985 if (wsImage.GetLength() > 0) { | 985 if (wsImage.GetLength() > 0) { |
| 986 XFA_ATTRIBUTEENUM iEncoding = | 986 XFA_ATTRIBUTEENUM iEncoding = |
| 987 (XFA_ATTRIBUTEENUM)pImage->GetTransferEncoding(); | 987 (XFA_ATTRIBUTEENUM)pImage->GetTransferEncoding(); |
| 988 if (iEncoding == XFA_ATTRIBUTEENUM_Base64) { | 988 if (iEncoding == XFA_ATTRIBUTEENUM_Base64) { |
| 989 CFX_ByteString bsData = wsImage.UTF8Encode(); | 989 CFX_ByteString bsData = wsImage.UTF8Encode(); |
| 990 int32_t iLength = bsData.GetLength(); | 990 int32_t iLength = bsData.GetLength(); |
| 991 pImageBuffer = FX_Alloc(uint8_t, iLength); | 991 pImageBuffer = FX_Alloc(uint8_t, iLength); |
| 992 int32_t iRead = XFA_Base64Decode((const FX_CHAR*)bsData, pImageBuffer); | 992 int32_t iRead = XFA_Base64Decode((const FX_CHAR*)bsData, pImageBuffer); |
| 993 if (iRead > 0) { | 993 if (iRead > 0) { |
| 994 pImageFileRead = FX_CreateMemoryStream(pImageBuffer, iRead); | 994 pImageFileRead = FX_CreateMemoryStream(pImageBuffer, iRead); |
| 995 } | 995 } |
| 996 } else { | 996 } else { |
| 997 bsContent = CFX_ByteString::FromUnicode(wsImage); | 997 bsContent = CFX_ByteString::FromUnicode(wsImage); |
| 998 pImageFileRead = FX_CreateMemoryStream( | 998 pImageFileRead = FX_CreateMemoryStream( |
| 999 (uint8_t*)(const uint8_t*)bsContent, bsContent.GetLength()); | 999 (uint8_t*)(const uint8_t*)bsContent, bsContent.GetLength()); |
| 1000 } | 1000 } |
| 1001 } else { | 1001 } else { |
| 1002 CFX_WideString wsURL = wsHref; | 1002 CFX_WideString wsURL = wsHref; |
| 1003 if (wsURL.Left(7) != FX_WSTRC(L"http://") && | 1003 if (wsURL.Left(7) != FX_WSTRC(L"http://") && |
| 1004 wsURL.Left(6) != FX_WSTRC(L"ftp://")) { | 1004 wsURL.Left(6) != FX_WSTRC(L"ftp://")) { |
| 1005 CFX_DIBitmap* pBitmap = | 1005 CFX_DIBitmap* pBitmap = |
| 1006 pDoc->GetPDFNamedImage(wsURL, iImageXDpi, iImageYDpi); | 1006 pDoc->GetPDFNamedImage(wsURL.AsWideStringC(), iImageXDpi, iImageYDpi); |
| 1007 if (pBitmap) { | 1007 if (pBitmap) { |
| 1008 bNameImage = TRUE; | 1008 bNameImage = TRUE; |
| 1009 return pBitmap; | 1009 return pBitmap; |
| 1010 } | 1010 } |
| 1011 } | 1011 } |
| 1012 pImageFileRead = pDoc->GetDocProvider()->OpenLinkedFile(pDoc, wsURL); | 1012 pImageFileRead = pDoc->GetDocProvider()->OpenLinkedFile(pDoc, wsURL); |
| 1013 } | 1013 } |
| 1014 if (!pImageFileRead) { | 1014 if (!pImageFileRead) { |
| 1015 FX_Free(pImageBuffer); | 1015 FX_Free(pImageBuffer); |
| 1016 return NULL; | 1016 return NULL; |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 iType != XFA_ELEMENT_Rectangle) { | 1956 iType != XFA_ELEMENT_Rectangle) { |
| 1957 return; | 1957 return; |
| 1958 } | 1958 } |
| 1959 CXFA_StrokeArray strokes; | 1959 CXFA_StrokeArray strokes; |
| 1960 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { | 1960 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { |
| 1961 box.GetStrokes(strokes); | 1961 box.GetStrokes(strokes); |
| 1962 } | 1962 } |
| 1963 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); | 1963 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); |
| 1964 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); | 1964 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); |
| 1965 } | 1965 } |
| OLD | NEW |