Chromium Code Reviews| 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/fxfa/app/xfa_ffimageedit.h" | 7 #include "xfa/fxfa/app/xfa_ffimageedit.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/core/cfwl_message.h" | 9 #include "xfa/fwl/core/cfwl_message.h" |
| 10 #include "xfa/fwl/core/ifwl_app.h" | 10 #include "xfa/fwl/core/ifwl_app.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 FWLToClient(ms.m_fx, ms.m_fy); | 101 FWLToClient(ms.m_fx, ms.m_fy); |
| 102 TranslateFWLMessage(&ms); | 102 TranslateFWLMessage(&ms); |
| 103 IXFA_AppProvider* pAppProvider = GetAppProvider(); | 103 IXFA_AppProvider* pAppProvider = GetAppProvider(); |
| 104 if (!pAppProvider) { | 104 if (!pAppProvider) { |
| 105 return TRUE; | 105 return TRUE; |
| 106 } | 106 } |
| 107 CFX_WideString wsTitle; | 107 CFX_WideString wsTitle; |
| 108 CFX_WideString wsFilter; | 108 CFX_WideString wsFilter; |
| 109 pAppProvider->LoadString(XFA_IDS_ImageFilter, wsFilter); | 109 pAppProvider->LoadString(XFA_IDS_ImageFilter, wsFilter); |
| 110 CFX_WideStringArray wsPathArray; | 110 CFX_WideStringArray wsPathArray; |
| 111 pAppProvider->ShowFileDialog(wsTitle, wsFilter, wsPathArray); | 111 pAppProvider->ShowFileDialog(wsTitle.AsWideStringC(), |
| 112 wsFilter.AsWideStringC(), wsPathArray); | |
| 112 int32_t iSize = wsPathArray.GetSize(); | 113 int32_t iSize = wsPathArray.GetSize(); |
| 113 if (iSize < 1) { | 114 if (iSize < 1) { |
| 114 return TRUE; | 115 return TRUE; |
| 115 } | 116 } |
| 116 CFX_WideString wsFilePath = wsPathArray[0]; | 117 CFX_WideString wsFilePath = wsPathArray[0]; |
| 117 FX_STRSIZE nLen = wsFilePath.GetLength(); | 118 FX_STRSIZE nLen = wsFilePath.GetLength(); |
| 118 FX_STRSIZE nIndex = nLen - 1; | 119 FX_STRSIZE nIndex = nLen - 1; |
| 119 while (nIndex > 0 && wsFilePath[nIndex] != '.') { | 120 while (nIndex > 0 && wsFilePath[nIndex] != '.') { |
| 120 nIndex--; | 121 nIndex--; |
| 121 } | 122 } |
| 122 if (nIndex <= 0) { | 123 if (nIndex <= 0) { |
| 123 return TRUE; | 124 return TRUE; |
| 124 } | 125 } |
| 125 CFX_WideString wsContentType(L"image/"); | 126 CFX_WideString wsContentType(L"image/"); |
| 126 wsContentType += wsFilePath.Right(nLen - nIndex - 1); | 127 wsContentType += wsFilePath.Right(nLen - nIndex - 1); |
| 127 wsContentType.MakeLower(); | 128 wsContentType.MakeLower(); |
| 128 FXCODEC_IMAGE_TYPE eImageType = XFA_GetImageType(wsContentType); | 129 FXCODEC_IMAGE_TYPE eImageType = |
| 130 XFA_GetImageType(wsContentType.AsWideStringC()); | |
|
Lei Zhang
2016/04/05 00:45:48
XFA_GetImageType() takes the CFX_WideStringC and m
Tom Sepez
2016/04/05 16:34:22
There are a bunch of these. I was planning on a f
Tom Sepez
2016/04/05 18:47:17
Anyway, I did this here, but the first thing the X
| |
| 129 if (eImageType == FXCODEC_IMAGE_UNKNOWN) { | 131 if (eImageType == FXCODEC_IMAGE_UNKNOWN) { |
| 130 return TRUE; | 132 return TRUE; |
| 131 } | 133 } |
| 132 CFX_WideString wsImage; | 134 CFX_WideString wsImage; |
| 133 IFX_FileRead* pFileRead = FX_CreateFileRead(wsFilePath); | 135 IFX_FileRead* pFileRead = FX_CreateFileRead(wsFilePath); |
| 134 if (pFileRead) { | 136 if (pFileRead) { |
| 135 int32_t nDataSize = pFileRead->GetSize(); | 137 int32_t nDataSize = pFileRead->GetSize(); |
| 136 if (nDataSize > 0) { | 138 if (nDataSize > 0) { |
| 137 CFX_ByteString bsBuf; | 139 CFX_ByteString bsBuf; |
| 138 FX_CHAR* pImageBuffer = bsBuf.GetBuffer(nDataSize); | 140 FX_CHAR* pImageBuffer = bsBuf.GetBuffer(nDataSize); |
| 139 pFileRead->ReadBlock(pImageBuffer, 0, nDataSize); | 141 pFileRead->ReadBlock(pImageBuffer, 0, nDataSize); |
| 140 bsBuf.ReleaseBuffer(); | 142 bsBuf.ReleaseBuffer(); |
| 141 if (!bsBuf.IsEmpty()) { | 143 if (!bsBuf.IsEmpty()) { |
| 142 FX_CHAR* pData = XFA_Base64Encode(bsBuf, nDataSize); | 144 FX_CHAR* pData = XFA_Base64Encode(bsBuf, nDataSize); |
| 143 wsImage = CFX_WideString::FromLocal(pData); | 145 wsImage = CFX_WideString::FromLocal(pData); |
| 144 FX_Free(pData); | 146 FX_Free(pData); |
| 145 } | 147 } |
| 146 } | 148 } |
| 147 m_pDataAcc->SetImageEditImage(NULL); | 149 m_pDataAcc->SetImageEditImage(NULL); |
| 148 pFileRead->Release(); | 150 pFileRead->Release(); |
| 149 } | 151 } |
| 150 m_pDataAcc->SetImageEdit(wsContentType, CFX_WideStringC(), wsImage); | 152 m_pDataAcc->SetImageEdit(wsContentType.AsWideStringC(), CFX_WideStringC(), |
| 153 wsImage.AsWideStringC()); | |
| 151 m_pDataAcc->LoadImageEditImage(); | 154 m_pDataAcc->LoadImageEditImage(); |
| 152 AddInvalidateRect(); | 155 AddInvalidateRect(); |
| 153 m_pDocView->SetChangeMark(); | 156 m_pDocView->SetChangeMark(); |
| 154 return TRUE; | 157 return TRUE; |
| 155 } | 158 } |
| 156 void CXFA_FFImageEdit::SetFWLRect() { | 159 void CXFA_FFImageEdit::SetFWLRect() { |
| 157 if (!m_pNormalWidget) { | 160 if (!m_pNormalWidget) { |
| 158 return; | 161 return; |
| 159 } | 162 } |
| 160 CFX_RectF rtUIMargin; | 163 CFX_RectF rtUIMargin; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 176 return m_pOldDelegate->OnProcessMessage(pMessage); | 179 return m_pOldDelegate->OnProcessMessage(pMessage); |
| 177 } | 180 } |
| 178 FWL_ERR CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) { | 181 FWL_ERR CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) { |
| 179 CXFA_FFField::OnProcessEvent(pEvent); | 182 CXFA_FFField::OnProcessEvent(pEvent); |
| 180 return m_pOldDelegate->OnProcessEvent(pEvent); | 183 return m_pOldDelegate->OnProcessEvent(pEvent); |
| 181 } | 184 } |
| 182 FWL_ERR CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics, | 185 FWL_ERR CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics, |
| 183 const CFX_Matrix* pMatrix) { | 186 const CFX_Matrix* pMatrix) { |
| 184 return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 187 return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
| 185 } | 188 } |
| OLD | NEW |