Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: fpdfsdk/src/fsdk_baseform.cpp

Issue 1577453002: Merge to XFA: Clean up misc nits found while fixing bugs. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/fpdfsave.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_FontMap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "fpdfsdk/include/fsdk_baseform.h" 7 #include "fpdfsdk/include/fsdk_baseform.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 } 2182 }
2183 2183
2184 FX_BOOL CPDFSDK_InterForm::IsXfaValidationsEnabled() { 2184 FX_BOOL CPDFSDK_InterForm::IsXfaValidationsEnabled() {
2185 return m_bXfaValidationsEnabled; 2185 return m_bXfaValidationsEnabled;
2186 } 2186 }
2187 void CPDFSDK_InterForm::XfaSetValidationsEnabled(FX_BOOL bEnabled) { 2187 void CPDFSDK_InterForm::XfaSetValidationsEnabled(FX_BOOL bEnabled) {
2188 m_bXfaValidationsEnabled = bEnabled; 2188 m_bXfaValidationsEnabled = bEnabled;
2189 } 2189 }
2190 #endif // PDF_ENABLE_XFA 2190 #endif // PDF_ENABLE_XFA
2191 2191
2192 #ifdef _WIN32
2193 CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) {
2194 CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
2195 CPDF_Stream* pRetStream = NULL;
2196
2197 if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile.c_str())) {
2198 int nWidth = pBmp->GetWidth();
2199 int nHeight = pBmp->GetHeight();
2200
2201 CPDF_Image Image(pDocument);
2202 Image.SetImage(pBmp, FALSE);
2203 CPDF_Stream* pImageStream = Image.GetStream();
2204 if (pImageStream) {
2205 if (pImageStream->GetObjNum() == 0)
2206 pDocument->AddIndirectObject(pImageStream);
2207
2208 CPDF_Dictionary* pStreamDict = new CPDF_Dictionary();
2209 pStreamDict->SetAtName("Subtype", "Form");
2210 pStreamDict->SetAtName("Name", "IMG");
2211 CPDF_Array* pMatrix = new CPDF_Array();
2212 pStreamDict->SetAt("Matrix", pMatrix);
2213 pMatrix->AddInteger(1);
2214 pMatrix->AddInteger(0);
2215 pMatrix->AddInteger(0);
2216 pMatrix->AddInteger(1);
2217 pMatrix->AddInteger(-nWidth / 2);
2218 pMatrix->AddInteger(-nHeight / 2);
2219 CPDF_Dictionary* pResource = new CPDF_Dictionary();
2220 pStreamDict->SetAt("Resources", pResource);
2221 CPDF_Dictionary* pXObject = new CPDF_Dictionary();
2222 pResource->SetAt("XObject", pXObject);
2223 pXObject->SetAtReference("Img", pDocument, pImageStream);
2224 CPDF_Array* pProcSet = new CPDF_Array();
2225 pResource->SetAt("ProcSet", pProcSet);
2226 pProcSet->AddName("PDF");
2227 pProcSet->AddName("ImageC");
2228 pStreamDict->SetAtName("Type", "XObject");
2229 CPDF_Array* pBBox = new CPDF_Array();
2230 pStreamDict->SetAt("BBox", pBBox);
2231 pBBox->AddInteger(0);
2232 pBBox->AddInteger(0);
2233 pBBox->AddInteger(nWidth);
2234 pBBox->AddInteger(nHeight);
2235 pStreamDict->SetAtInteger("FormType", 1);
2236
2237 pRetStream = new CPDF_Stream(NULL, 0, NULL);
2238 CFX_ByteString csStream;
2239 csStream.Format("q\n%d 0 0 %d 0 0 cm\n/Img Do\nQ", nWidth, nHeight);
2240 pRetStream->InitStream((uint8_t*)csStream.c_str(), csStream.GetLength(),
2241 pStreamDict);
2242 pDocument->AddIndirectObject(pRetStream);
2243 }
2244
2245 delete pBmp;
2246 }
2247
2248 return pRetStream;
2249 }
2250 #endif // _WIN32
2251
2252 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { 2192 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) {
2253 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); 2193 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
2254 ASSERT(pEnv); 2194 ASSERT(pEnv);
2255 if (!pEnv->IsJSInitiated()) 2195 if (!pEnv->IsJSInitiated())
2256 return; 2196 return;
2257 2197
2258 if (m_bBusy) 2198 if (m_bBusy)
2259 return; 2199 return;
2260 2200
2261 m_bBusy = TRUE; 2201 m_bBusy = TRUE;
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 break; 2954 break;
3015 } 2955 }
3016 } 2956 }
3017 } 2957 }
3018 2958
3019 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { 2959 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) {
3020 CPDF_Rect rcAnnot; 2960 CPDF_Rect rcAnnot;
3021 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); 2961 pAnnot->GetPDFAnnot()->GetRect(rcAnnot);
3022 return rcAnnot; 2962 return rcAnnot;
3023 } 2963 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfsave.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_FontMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698