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

Side by Side Diff: fpdfsdk/javascript/Document.cpp

Issue 2391313002: Rename CPDFSDK_Environment to CPDFSDK_FormfillEnvironment (Closed)
Patch Set: Rebase to master Created 4 years, 2 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
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/javascript/Document.h" 7 #include "fpdfsdk/javascript/Document.h"
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "core/fpdfapi/font/cpdf_font.h" 12 #include "core/fpdfapi/font/cpdf_font.h"
13 #include "core/fpdfapi/page/cpdf_page.h" 13 #include "core/fpdfapi/page/cpdf_page.h"
14 #include "core/fpdfapi/parser/cpdf_array.h" 14 #include "core/fpdfapi/parser/cpdf_array.h"
15 #include "core/fpdfapi/parser/cpdf_document.h" 15 #include "core/fpdfapi/parser/cpdf_document.h"
16 #include "core/fpdfapi/parser/fpdf_parser_decode.h" 16 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
17 #include "core/fpdfdoc/cpdf_interform.h" 17 #include "core/fpdfdoc/cpdf_interform.h"
18 #include "core/fpdfdoc/cpdf_nametree.h" 18 #include "core/fpdfdoc/cpdf_nametree.h"
19 #include "fpdfsdk/cpdfsdk_annotiterator.h" 19 #include "fpdfsdk/cpdfsdk_annotiterator.h"
20 #include "fpdfsdk/cpdfsdk_document.h" 20 #include "fpdfsdk/cpdfsdk_document.h"
21 #include "fpdfsdk/cpdfsdk_environment.h" 21 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
22 #include "fpdfsdk/cpdfsdk_interform.h" 22 #include "fpdfsdk/cpdfsdk_interform.h"
23 #include "fpdfsdk/cpdfsdk_pageview.h" 23 #include "fpdfsdk/cpdfsdk_pageview.h"
24 #include "fpdfsdk/cpdfsdk_widget.h" 24 #include "fpdfsdk/cpdfsdk_widget.h"
25 #include "fpdfsdk/javascript/Annot.h" 25 #include "fpdfsdk/javascript/Annot.h"
26 #include "fpdfsdk/javascript/Field.h" 26 #include "fpdfsdk/javascript/Field.h"
27 #include "fpdfsdk/javascript/Icon.h" 27 #include "fpdfsdk/javascript/Icon.h"
28 #include "fpdfsdk/javascript/JS_Define.h" 28 #include "fpdfsdk/javascript/JS_Define.h"
29 #include "fpdfsdk/javascript/JS_EventHandler.h" 29 #include "fpdfsdk/javascript/JS_EventHandler.h"
30 #include "fpdfsdk/javascript/JS_Object.h" 30 #include "fpdfsdk/javascript/JS_Object.h"
31 #include "fpdfsdk/javascript/JS_Value.h" 31 #include "fpdfsdk/javascript/JS_Value.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 218 }
219 if (vp.IsGetting()) { 219 if (vp.IsGetting()) {
220 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) { 220 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) {
221 vp << pPageView->GetPageIndex(); 221 vp << pPageView->GetPageIndex();
222 } 222 }
223 } else { 223 } else {
224 int iPageCount = m_pDocument->GetPageCount(); 224 int iPageCount = m_pDocument->GetPageCount();
225 int iPageNum = 0; 225 int iPageNum = 0;
226 vp >> iPageNum; 226 vp >> iPageNum;
227 227
228 CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); 228 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv();
229 if (iPageNum >= 0 && iPageNum < iPageCount) { 229 if (iPageNum >= 0 && iPageNum < iPageCount) {
230 pEnv->JS_docgotoPage(iPageNum); 230 pEnv->JS_docgotoPage(iPageNum);
231 } else if (iPageNum >= iPageCount) { 231 } else if (iPageNum >= iPageCount) {
232 pEnv->JS_docgotoPage(iPageCount - 1); 232 pEnv->JS_docgotoPage(iPageCount - 1);
233 } else if (iPageNum < 0) { 233 } else if (iPageNum < 0) {
234 pEnv->JS_docgotoPage(0); 234 pEnv->JS_docgotoPage(0);
235 } 235 }
236 } 236 }
237 237
238 return TRUE; 238 return TRUE;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 CFX_WideString cSubject = 401 CFX_WideString cSubject =
402 iLength > 4 ? params[4].ToCFXWideString(pRuntime) : L""; 402 iLength > 4 ? params[4].ToCFXWideString(pRuntime) : L"";
403 CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString(pRuntime) : L""; 403 CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString(pRuntime) : L"";
404 404
405 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 405 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
406 CFX_ByteTextBuf textBuf; 406 CFX_ByteTextBuf textBuf;
407 if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) 407 if (!pInterForm->ExportFormToFDFTextBuf(textBuf))
408 return FALSE; 408 return FALSE;
409 409
410 pRuntime->BeginBlock(); 410 pRuntime->BeginBlock();
411 CPDFSDK_Environment* pEnv = pContext->GetReaderEnv(); 411 CPDFSDK_FormFillEnvironment* pEnv = pContext->GetReaderEnv();
412 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, 412 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI,
413 cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), 413 cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(),
414 cMsg.c_str()); 414 cMsg.c_str());
415 pRuntime->EndBlock(); 415 pRuntime->EndBlock();
416 return TRUE; 416 return TRUE;
417 } 417 }
418 418
419 FX_BOOL Document::print(IJS_Context* cc, 419 FX_BOOL Document::print(IJS_Context* cc,
420 const std::vector<CJS_Value>& params, 420 const std::vector<CJS_Value>& params,
421 CJS_Value& vRet, 421 CJS_Value& vRet,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 if (nlength >= 5) 470 if (nlength >= 5)
471 bShrinkToFit = params[4].ToBool(pRuntime); 471 bShrinkToFit = params[4].ToBool(pRuntime);
472 if (nlength >= 6) 472 if (nlength >= 6)
473 bPrintAsImage = params[5].ToBool(pRuntime); 473 bPrintAsImage = params[5].ToBool(pRuntime);
474 if (nlength >= 7) 474 if (nlength >= 7)
475 bReverse = params[6].ToBool(pRuntime); 475 bReverse = params[6].ToBool(pRuntime);
476 if (nlength >= 8) 476 if (nlength >= 8)
477 bAnnotations = params[7].ToBool(pRuntime); 477 bAnnotations = params[7].ToBool(pRuntime);
478 } 478 }
479 479
480 if (CPDFSDK_Environment* pEnv = m_pDocument->GetEnv()) { 480 if (CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv()) {
481 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, 481 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage,
482 bReverse, bAnnotations); 482 bReverse, bAnnotations);
483 return TRUE; 483 return TRUE;
484 } 484 }
485 return FALSE; 485 return FALSE;
486 } 486 }
487 487
488 // removes the specified field from the document. 488 // removes the specified field from the document.
489 // comment: 489 // comment:
490 // note: if the filed name is not rational, adobe is dumb for it. 490 // note: if the filed name is not rational, adobe is dumb for it.
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 cBcc = CJS_Value(pRuntime, pValue).ToCFXWideString(pRuntime); 750 cBcc = CJS_Value(pRuntime, pValue).ToCFXWideString(pRuntime);
751 751
752 pValue = pRuntime->GetObjectProperty(pObj, L"cSubject"); 752 pValue = pRuntime->GetObjectProperty(pObj, L"cSubject");
753 cSubject = CJS_Value(pRuntime, pValue).ToCFXWideString(pRuntime); 753 cSubject = CJS_Value(pRuntime, pValue).ToCFXWideString(pRuntime);
754 754
755 pValue = pRuntime->GetObjectProperty(pObj, L"cMsg"); 755 pValue = pRuntime->GetObjectProperty(pObj, L"cMsg");
756 cMsg = CJS_Value(pRuntime, pValue).ToCFXWideString(pRuntime); 756 cMsg = CJS_Value(pRuntime, pValue).ToCFXWideString(pRuntime);
757 } 757 }
758 758
759 pRuntime->BeginBlock(); 759 pRuntime->BeginBlock();
760 CPDFSDK_Environment* pEnv = pRuntime->GetReaderEnv(); 760 CPDFSDK_FormFillEnvironment* pEnv = pRuntime->GetReaderEnv();
761 pEnv->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), cSubject.c_str(), 761 pEnv->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), cSubject.c_str(),
762 cCc.c_str(), cBcc.c_str(), cMsg.c_str()); 762 cCc.c_str(), cBcc.c_str(), cMsg.c_str());
763 pRuntime->EndBlock(); 763 pRuntime->EndBlock();
764 764
765 return TRUE; 765 return TRUE;
766 } 766 }
767 767
768 FX_BOOL Document::author(IJS_Context* cc, 768 FX_BOOL Document::author(IJS_Context* cc,
769 CJS_PropValue& vp, 769 CJS_PropValue& vp,
770 CFX_WideString& sError) { 770 CFX_WideString& sError) {
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 1689
1690 if (arrayObject) { 1690 if (arrayObject) {
1691 scrollPositionArray.reset(new float[arrayObject->GetCount()]); 1691 scrollPositionArray.reset(new float[arrayObject->GetCount()]);
1692 int j = 0; 1692 int j = 0;
1693 for (size_t i = 2; i < arrayObject->GetCount(); i++) 1693 for (size_t i = 2; i < arrayObject->GetCount(); i++)
1694 scrollPositionArray[j++] = arrayObject->GetFloatAt(i); 1694 scrollPositionArray[j++] = arrayObject->GetFloatAt(i);
1695 scrollPositionArraySize = j; 1695 scrollPositionArraySize = j;
1696 } 1696 }
1697 1697
1698 pRuntime->BeginBlock(); 1698 pRuntime->BeginBlock();
1699 CPDFSDK_Environment* pApp = m_pDocument->GetEnv(); 1699 CPDFSDK_FormFillEnvironment* pApp = m_pDocument->GetEnv();
1700 pApp->DoGoToAction(dest.GetPageIndex(pDocument), dest.GetZoomMode(), 1700 pApp->DoGoToAction(dest.GetPageIndex(pDocument), dest.GetZoomMode(),
1701 scrollPositionArray.get(), scrollPositionArraySize); 1701 scrollPositionArray.get(), scrollPositionArraySize);
1702 pRuntime->EndBlock(); 1702 pRuntime->EndBlock();
1703 1703
1704 return TRUE; 1704 return TRUE;
1705 } 1705 }
1706 1706
1707 void Document::AddDelayData(CJS_DelayData* pData) { 1707 void Document::AddDelayData(CJS_DelayData* pData) {
1708 m_DelayData.push_back(std::unique_ptr<CJS_DelayData>(pData)); 1708 m_DelayData.push_back(std::unique_ptr<CJS_DelayData>(pData));
1709 } 1709 }
(...skipping 11 matching lines...) Expand all
1721 } 1721 }
1722 } 1722 }
1723 1723
1724 for (const auto& pData : DelayDataForFieldAndControlIndex) 1724 for (const auto& pData : DelayDataForFieldAndControlIndex)
1725 Field::DoDelay(m_pDocument.Get(), pData.get()); 1725 Field::DoDelay(m_pDocument.Get(), pData.get());
1726 } 1726 }
1727 1727
1728 CJS_Document* Document::GetCJSDoc() const { 1728 CJS_Document* Document::GetCJSDoc() const {
1729 return static_cast<CJS_Document*>(m_pJSObject); 1729 return static_cast<CJS_Document*>(m_pJSObject);
1730 } 1730 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698