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