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

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

Issue 1544963002: Clean up misc nits found while fixing bugs. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase 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 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 } 1544 }
1545 1545
1546 void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) { 1546 void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) {
1547 m_bCalculate = bEnabled; 1547 m_bCalculate = bEnabled;
1548 } 1548 }
1549 1549
1550 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { 1550 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const {
1551 return m_bCalculate; 1551 return m_bCalculate;
1552 } 1552 }
1553 1553
1554 #ifdef _WIN32
1555 CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) {
1556 CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
1557 CPDF_Stream* pRetStream = NULL;
1558
1559 if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile.c_str())) {
1560 int nWidth = pBmp->GetWidth();
1561 int nHeight = pBmp->GetHeight();
1562
1563 CPDF_Image Image(pDocument);
1564 Image.SetImage(pBmp, FALSE);
1565 CPDF_Stream* pImageStream = Image.GetStream();
1566 if (pImageStream) {
1567 if (pImageStream->GetObjNum() == 0)
1568 pDocument->AddIndirectObject(pImageStream);
1569
1570 CPDF_Dictionary* pStreamDict = new CPDF_Dictionary();
1571 pStreamDict->SetAtName("Subtype", "Form");
1572 pStreamDict->SetAtName("Name", "IMG");
1573 CPDF_Array* pMatrix = new CPDF_Array();
1574 pStreamDict->SetAt("Matrix", pMatrix);
1575 pMatrix->AddInteger(1);
1576 pMatrix->AddInteger(0);
1577 pMatrix->AddInteger(0);
1578 pMatrix->AddInteger(1);
1579 pMatrix->AddInteger(-nWidth / 2);
1580 pMatrix->AddInteger(-nHeight / 2);
1581 CPDF_Dictionary* pResource = new CPDF_Dictionary();
1582 pStreamDict->SetAt("Resources", pResource);
1583 CPDF_Dictionary* pXObject = new CPDF_Dictionary();
1584 pResource->SetAt("XObject", pXObject);
1585 pXObject->SetAtReference("Img", pDocument, pImageStream);
1586 CPDF_Array* pProcSet = new CPDF_Array();
1587 pResource->SetAt("ProcSet", pProcSet);
1588 pProcSet->AddName("PDF");
1589 pProcSet->AddName("ImageC");
1590 pStreamDict->SetAtName("Type", "XObject");
1591 CPDF_Array* pBBox = new CPDF_Array();
1592 pStreamDict->SetAt("BBox", pBBox);
1593 pBBox->AddInteger(0);
1594 pBBox->AddInteger(0);
1595 pBBox->AddInteger(nWidth);
1596 pBBox->AddInteger(nHeight);
1597 pStreamDict->SetAtInteger("FormType", 1);
1598
1599 pRetStream = new CPDF_Stream(NULL, 0, NULL);
1600 CFX_ByteString csStream;
1601 csStream.Format("q\n%d 0 0 %d 0 0 cm\n/Img Do\nQ", nWidth, nHeight);
1602 pRetStream->InitStream((uint8_t*)csStream.c_str(), csStream.GetLength(),
1603 pStreamDict);
1604 pDocument->AddIndirectObject(pRetStream);
1605 }
1606
1607 delete pBmp;
1608 }
1609
1610 return pRetStream;
1611 }
1612 #endif
1613
1614 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { 1554 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) {
1615 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); 1555 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
1616 ASSERT(pEnv); 1556 ASSERT(pEnv);
1617 if (!pEnv->IsJSInitiated()) 1557 if (!pEnv->IsJSInitiated())
1618 return; 1558 return;
1619 1559
1620 if (m_bBusy) 1560 if (m_bBusy)
1621 return; 1561 return;
1622 1562
1623 m_bBusy = TRUE; 1563 m_bBusy = TRUE;
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 break; 2292 break;
2353 } 2293 }
2354 } 2294 }
2355 } 2295 }
2356 2296
2357 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { 2297 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) {
2358 CPDF_Rect rcAnnot; 2298 CPDF_Rect rcAnnot;
2359 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); 2299 pAnnot->GetPDFAnnot()->GetRect(rcAnnot);
2360 return rcAnnot; 2300 return rcAnnot;
2361 } 2301 }
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