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

Side by Side Diff: fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp

Issue 2031653003: Get rid of NULLs in fpdfsdk/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_core
Patch Set: rebase Created 4 years, 6 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/fpdfxfa/fpdfxfa_app.cpp ('k') | fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h » ('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/fpdfxfa/include/fpdfxfa_doc.h" 7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 else 120 else
121 m_iDocType = DOCTYPE_STATIC_XFA; 121 m_iDocType = DOCTYPE_STATIC_XFA;
122 122
123 m_pXFADocView = m_pXFADoc->CreateDocView(XFA_DOCVIEW_View); 123 m_pXFADocView = m_pXFADoc->CreateDocView(XFA_DOCVIEW_View);
124 if (m_pXFADocView->StartLayout() < 0) { 124 if (m_pXFADocView->StartLayout() < 0) {
125 CloseXFADoc(pDocHandler); 125 CloseXFADoc(pDocHandler);
126 SetLastError(FPDF_ERR_XFALAYOUT); 126 SetLastError(FPDF_ERR_XFALAYOUT);
127 return FALSE; 127 return FALSE;
128 } 128 }
129 129
130 m_pXFADocView->DoLayout(NULL); 130 m_pXFADocView->DoLayout(nullptr);
131 m_pXFADocView->StopLayout(); 131 m_pXFADocView->StopLayout();
132 m_nLoadStatus = FXFA_LOADSTATUS_LOADED; 132 m_nLoadStatus = FXFA_LOADSTATUS_LOADED;
133 133
134 return TRUE; 134 return TRUE;
135 } 135 }
136 136
137 int CPDFXFA_Document::GetPageCount() { 137 int CPDFXFA_Document::GetPageCount() {
138 if (!m_pPDFDoc && !m_pXFADoc) 138 if (!m_pPDFDoc && !m_pXFADoc)
139 return 0; 139 return 0;
140 140
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 m_pPDFDoc->DeletePage(page_index); 207 m_pPDFDoc->DeletePage(page_index);
208 208
209 if (page_index < 0 || page_index >= m_XFAPageList.GetSize()) 209 if (page_index < 0 || page_index >= m_XFAPageList.GetSize())
210 return; 210 return;
211 211
212 if (CPDFXFA_Page* pPage = m_XFAPageList.GetAt(page_index)) 212 if (CPDFXFA_Page* pPage = m_XFAPageList.GetAt(page_index))
213 pPage->Release(); 213 pPage->Release();
214 } 214 }
215 215
216 void CPDFXFA_Document::RemovePage(CPDFXFA_Page* page) { 216 void CPDFXFA_Document::RemovePage(CPDFXFA_Page* page) {
217 m_XFAPageList.SetAt(page->GetPageIndex(), NULL); 217 m_XFAPageList.SetAt(page->GetPageIndex(), nullptr);
218 } 218 }
219 219
220 CPDFSDK_Document* CPDFXFA_Document::GetSDKDocument( 220 CPDFSDK_Document* CPDFXFA_Document::GetSDKDocument(
221 CPDFDoc_Environment* pFormFillEnv) { 221 CPDFDoc_Environment* pFormFillEnv) {
222 if (!m_pSDKDoc && pFormFillEnv) 222 if (!m_pSDKDoc && pFormFillEnv)
223 m_pSDKDoc = new CPDFSDK_Document(this, pFormFillEnv); 223 m_pSDKDoc = new CPDFSDK_Document(this, pFormFillEnv);
224 return m_pSDKDoc; 224 return m_pSDKDoc;
225 } 225 }
226 226
227 void CPDFXFA_Document::FXRect2PDFRect(const CFX_RectF& fxRectF, 227 void CPDFXFA_Document::FXRect2PDFRect(const CFX_RectF& fxRectF,
(...skipping 22 matching lines...) Expand all
250 if (!m_pXFADoc || !m_pSDKDoc) 250 if (!m_pXFADoc || !m_pSDKDoc)
251 return; 251 return;
252 252
253 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 253 if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
254 return; 254 return;
255 255
256 CFX_FloatRect rcPage; 256 CFX_FloatRect rcPage;
257 FXRect2PDFRect(rt, rcPage); 257 FXRect2PDFRect(rt, rcPage);
258 258
259 CPDFXFA_Page* pPage = GetPage(pPageView); 259 CPDFXFA_Page* pPage = GetPage(pPageView);
260 260 if (!pPage)
261 if (pPage == NULL)
262 return; 261 return;
263 262
264 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 263 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
265 if (!pEnv) 264 if (!pEnv)
266 return; 265 return;
267 266
268 pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, 267 pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom,
269 rcPage.right, rcPage.top); 268 rcPage.right, rcPage.top);
270 } 269 }
271 270
(...skipping 17 matching lines...) Expand all
289 return; 288 return;
290 289
291 CFX_RectF rect; 290 CFX_RectF rect;
292 hWidget->GetRect(rect); 291 hWidget->GetRect(rect);
293 InvalidateRect(pPageView, rect, dwFlags); 292 InvalidateRect(pPageView, rect, dwFlags);
294 } 293 }
295 294
296 void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget, 295 void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget,
297 FX_BOOL bVisible, 296 FX_BOOL bVisible,
298 const CFX_RectF* pRtAnchor) { 297 const CFX_RectF* pRtAnchor) {
299 if (!hWidget || pRtAnchor == NULL) 298 if (!hWidget || !pRtAnchor || !m_pXFADoc || !m_pSDKDoc || !m_pXFADocView)
300 return;
301
302 if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView)
303 return; 299 return;
304 300
305 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 301 if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
306 return; 302 return;
307 303
308 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); 304 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
309 if (!pWidgetHandler) 305 if (!pWidgetHandler)
310 return; 306 return;
311 307
312 CXFA_FFPageView* pPageView = hWidget->GetPageView(); 308 CXFA_FFPageView* pPageView = hWidget->GetPageView();
313 if (!pPageView) 309 if (!pPageView)
314 return; 310 return;
315 311
316 CPDFXFA_Page* pPage = GetPage(pPageView); 312 CPDFXFA_Page* pPage = GetPage(pPageView);
317 313 if (!pPage)
318 if (pPage == NULL)
319 return; 314 return;
320 315
321 CFX_FloatRect rcCaret; 316 CFX_FloatRect rcCaret;
322 FXRect2PDFRect(*pRtAnchor, rcCaret); 317 FXRect2PDFRect(*pRtAnchor, rcCaret);
323 318
324 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 319 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
325 if (!pEnv) 320 if (!pEnv)
326 return; 321 return;
327 322
328 pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top, 323 pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 if (hWidget->CanPaste()) 473 if (hWidget->CanPaste())
479 menuFlag |= FXFA_MEMU_PASTE; 474 menuFlag |= FXFA_MEMU_PASTE;
480 if (hWidget->CanCopy()) 475 if (hWidget->CanCopy())
481 menuFlag |= FXFA_MEMU_COPY; 476 menuFlag |= FXFA_MEMU_COPY;
482 if (hWidget->CanCut()) 477 if (hWidget->CanCut())
483 menuFlag |= FXFA_MEMU_CUT; 478 menuFlag |= FXFA_MEMU_CUT;
484 if (hWidget->CanSelectAll()) 479 if (hWidget->CanSelectAll())
485 menuFlag |= FXFA_MEMU_SELECTALL; 480 menuFlag |= FXFA_MEMU_SELECTALL;
486 481
487 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 482 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
488 return pEnv && pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL); 483 return pEnv &&
484 pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, nullptr);
489 } 485 }
490 486
491 void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView, 487 void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView,
492 uint32_t dwFlags) { 488 uint32_t dwFlags) {
493 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 489 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
494 if (!pEnv) 490 if (!pEnv)
495 return; 491 return;
496 492
497 if (m_nLoadStatus != FXFA_LOADSTATUS_LOADING && 493 if (m_nLoadStatus != FXFA_LOADSTATUS_LOADING &&
498 m_nLoadStatus != FXFA_LOADSTATUS_CLOSING && 494 m_nLoadStatus != FXFA_LOADSTATUS_CLOSING &&
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 591 }
596 void CPDFXFA_Document::SetCalculationsEnabled(CXFA_FFDoc* hDoc, 592 void CPDFXFA_Document::SetCalculationsEnabled(CXFA_FFDoc* hDoc,
597 FX_BOOL bEnabled) { 593 FX_BOOL bEnabled) {
598 if (hDoc != m_pXFADoc || !m_pSDKDoc) 594 if (hDoc != m_pXFADoc || !m_pSDKDoc)
599 return; 595 return;
600 if (m_pSDKDoc->GetInterForm()) 596 if (m_pSDKDoc->GetInterForm())
601 m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled); 597 m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled);
602 } 598 }
603 599
604 void CPDFXFA_Document::GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) { 600 void CPDFXFA_Document::GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) {
605 if (hDoc != m_pXFADoc) 601 if (hDoc != m_pXFADoc || !m_pPDFDoc)
606 return; 602 return;
607 if (m_pPDFDoc == NULL) 603
608 return;
609 CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo(); 604 CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo();
610 605 if (!pInfoDict)
611 if (pInfoDict == NULL)
612 return; 606 return;
613 607
614 CFX_ByteString csTitle = pInfoDict->GetStringBy("Title"); 608 CFX_ByteString csTitle = pInfoDict->GetStringBy("Title");
615 wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength())); 609 wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength()));
616 csTitle.ReleaseBuffer(csTitle.GetLength()); 610 csTitle.ReleaseBuffer(csTitle.GetLength());
617 } 611 }
618 612
619 void CPDFXFA_Document::SetTitle(CXFA_FFDoc* hDoc, 613 void CPDFXFA_Document::SetTitle(CXFA_FFDoc* hDoc,
620 const CFX_WideString& wsTitle) { 614 const CFX_WideString& wsTitle) {
621 if (hDoc != m_pXFADoc || !m_pPDFDoc) 615 if (hDoc != m_pXFADoc || !m_pPDFDoc)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, 718 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc,
725 const CFX_WideString& bsURL, 719 const CFX_WideString& bsURL,
726 FX_BOOL bAppend) { 720 FX_BOOL bAppend) {
727 if (hDoc != m_pXFADoc) 721 if (hDoc != m_pXFADoc)
728 return; 722 return;
729 723
730 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 724 if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
731 return; 725 return;
732 726
733 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 727 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
734 if (pEnv == NULL) 728 if (!pEnv)
735 return; 729 return;
736 730
737 CFX_WideStringC str(bsURL.c_str()); 731 CFX_WideStringC str(bsURL.c_str());
738 732
739 pEnv->FFI_GotoURL(this, str, bAppend); 733 pEnv->FFI_GotoURL(this, str, bAppend);
740 } 734 }
741 735
742 FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) { 736 FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) {
743 if (hDoc != m_pXFADoc || !m_pSDKDoc) 737 if (hDoc != m_pXFADoc || !m_pSDKDoc)
744 return FALSE; 738 return FALSE;
745 if (m_pSDKDoc->GetInterForm()) 739 if (m_pSDKDoc->GetInterForm())
746 return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled(); 740 return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled();
747 741
748 return TRUE; 742 return TRUE;
749 } 743 }
750 void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc, 744 void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc,
751 FX_BOOL bEnabled) { 745 FX_BOOL bEnabled) {
752 if (hDoc != m_pXFADoc || !m_pSDKDoc) 746 if (hDoc != m_pXFADoc || !m_pSDKDoc)
753 return; 747 return;
754 if (m_pSDKDoc->GetInterForm()) 748 if (m_pSDKDoc->GetInterForm())
755 m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled); 749 m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled);
756 } 750 }
757 void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, 751 void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc,
758 CXFA_FFWidget* hWidget) { 752 CXFA_FFWidget* hWidget) {
759 if (hDoc != m_pXFADoc) 753 if (hDoc != m_pXFADoc)
760 return; 754 return;
761 755
762 if (NULL == hWidget) { 756 if (!hWidget) {
763 m_pSDKDoc->SetFocusAnnot(NULL); 757 m_pSDKDoc->SetFocusAnnot(nullptr);
764 return; 758 return;
765 } 759 }
766 760
767 int pageViewCount = m_pSDKDoc->GetPageViewCount(); 761 int pageViewCount = m_pSDKDoc->GetPageViewCount();
768 for (int i = 0; i < pageViewCount; i++) { 762 for (int i = 0; i < pageViewCount; i++) {
769 CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i); 763 CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i);
770 if (pPageView == NULL) 764 if (!pPageView)
771 continue; 765 continue;
772 CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget); 766 CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget);
773 if (pAnnot) { 767 if (pAnnot) {
774 m_pSDKDoc->SetFocusAnnot(pAnnot); 768 m_pSDKDoc->SetFocusAnnot(pAnnot);
775 break; 769 break;
776 } 770 }
777 } 771 }
778 } 772 }
779 void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, 773 void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc,
780 int32_t nStartPage, 774 int32_t nStartPage,
781 int32_t nEndPage, 775 int32_t nEndPage,
782 uint32_t dwOptions) { 776 uint32_t dwOptions) {
783 if (hDoc != m_pXFADoc) 777 if (hDoc != m_pXFADoc)
784 return; 778 return;
785 779
786 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 780 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
787 if (pEnv == NULL) 781 if (!pEnv || !pEnv->GetFormFillInfo() ||
782 !pEnv->GetFormFillInfo()->m_pJsPlatform ||
783 !pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) {
788 return; 784 return;
785 }
789 786
790 if (!pEnv->GetFormFillInfo() ||
791 pEnv->GetFormFillInfo()->m_pJsPlatform == NULL)
792 return;
793 if (pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print == NULL)
794 return;
795 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( 787 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print(
796 pEnv->GetFormFillInfo()->m_pJsPlatform, 788 pEnv->GetFormFillInfo()->m_pJsPlatform,
797 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, 789 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage,
798 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, 790 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage,
799 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, 791 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder,
800 dwOptions & XFA_PRINTOPT_PrintAnnot); 792 dwOptions & XFA_PRINTOPT_PrintAnnot);
801 } 793 }
802 794
803 void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { 795 void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) {
804 if (hDoc != m_pXFADoc) 796 if (hDoc != m_pXFADoc)
805 return; 797 return;
806 798
807 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 799 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
808 if (pEnv == NULL) 800 if (!pEnv)
809 return; 801 return;
810 802
811 pEnv->FFI_GetURL(this, wsDocURL); 803 pEnv->FFI_GetURL(this, wsDocURL);
812 } 804 }
813 805
814 FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) { 806 FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) {
815 if (hDoc != m_pXFADoc) 807 if (hDoc != m_pXFADoc)
816 return 0; 808 return 0;
817 if (m_pSDKDoc) { 809 if (m_pSDKDoc) {
818 if (CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm()) { 810 if (CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm()) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 Param.m_eType = XFA_EVENT_PostSubmit; 892 Param.m_eType = XFA_EVENT_PostSubmit;
901 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); 893 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
902 while (pWidgetAcc) { 894 while (pWidgetAcc) {
903 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); 895 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param);
904 pWidgetAcc = pWidgetAccIterator->MoveToNext(); 896 pWidgetAcc = pWidgetAccIterator->MoveToNext();
905 } 897 }
906 m_pXFADocView->UpdateDocView(); 898 m_pXFADocView->UpdateDocView();
907 } 899 }
908 900
909 FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { 901 FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) {
910 if (!_NotifySubmit(TRUE)) 902 if (!_NotifySubmit(TRUE) || !m_pXFADocView)
911 return FALSE;
912 if (NULL == m_pXFADocView)
913 return FALSE; 903 return FALSE;
914 m_pXFADocView->UpdateDocView(); 904 m_pXFADocView->UpdateDocView();
915 905
916 FX_BOOL ret = _SubmitData(hDoc, submit); 906 FX_BOOL ret = _SubmitData(hDoc, submit);
917 _NotifySubmit(FALSE); 907 _NotifySubmit(FALSE);
918 return ret; 908 return ret;
919 } 909 }
920 910
921 IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, 911 IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc,
922 const CFX_WideString& wsLink) { 912 const CFX_WideString& wsLink) {
923 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 913 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
924 if (pEnv == NULL) 914 if (!pEnv)
925 return FALSE; 915 return FALSE;
926 CFX_ByteString bs = wsLink.UTF16LE_Encode(); 916 CFX_ByteString bs = wsLink.UTF16LE_Encode();
927 int len = bs.GetLength() / sizeof(unsigned short); 917 int len = bs.GetLength() / sizeof(unsigned short);
928 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( 918 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile(
929 0, (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "rb"); 919 0, (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "rb");
930 bs.ReleaseBuffer(len * sizeof(unsigned short)); 920 bs.ReleaseBuffer(len * sizeof(unsigned short));
931 921
932 if (pFileHandler == NULL) 922 if (!pFileHandler)
933 return NULL; 923 return nullptr;
934 return new CFPDF_FileStream(pFileHandler); 924 return new CFPDF_FileStream(pFileHandler);
935 } 925 }
936 FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, 926 FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
937 int fileType, 927 int fileType,
938 FPDF_DWORD encodeType, 928 FPDF_DWORD encodeType,
939 FPDF_DWORD flag) { 929 FPDF_DWORD flag) {
940 if (!m_pXFADocView) 930 if (!m_pXFADocView)
941 return FALSE; 931 return FALSE;
942 932
943 CFX_ByteString content; 933 CFX_ByteString content;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 return FALSE; 1238 return FALSE;
1249 1239
1250 if (!m_pJSContext) { 1240 if (!m_pJSContext) {
1251 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc); 1241 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc);
1252 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); 1242 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext();
1253 } 1243 }
1254 1244
1255 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, 1245 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName,
1256 pValue); 1246 pValue);
1257 } 1247 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfxfa/fpdfxfa_app.cpp ('k') | fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698