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/include/fsdk_baseform.h" | 7 #include "fpdfsdk/include/fsdk_baseform.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> |
10 #include <memory> | 11 #include <memory> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 14 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
14 #include "core/fpdfapi/fpdf_parser/include/cfdf_document.h" | 15 #include "core/fpdfapi/fpdf_parser/include/cfdf_document.h" |
15 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
16 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" | 18 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" |
18 #include "fpdfsdk/formfiller/cffl_formfiller.h" | 19 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
19 #include "fpdfsdk/include/fsdk_actionhandler.h" | 20 #include "fpdfsdk/include/fsdk_actionhandler.h" |
(...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 for (int i = 0; i < kNumFieldTypes; ++i) | 1991 for (int i = 0; i < kNumFieldTypes; ++i) |
1991 m_bNeedHightlight[i] = FALSE; | 1992 m_bNeedHightlight[i] = FALSE; |
1992 m_iHighlightAlpha = 0; | 1993 m_iHighlightAlpha = 0; |
1993 } | 1994 } |
1994 | 1995 |
1995 CPDFSDK_InterForm::~CPDFSDK_InterForm() { | 1996 CPDFSDK_InterForm::~CPDFSDK_InterForm() { |
1996 delete m_pInterForm; | 1997 delete m_pInterForm; |
1997 m_pInterForm = nullptr; | 1998 m_pInterForm = nullptr; |
1998 m_Map.clear(); | 1999 m_Map.clear(); |
1999 #ifdef PDF_ENABLE_XFA | 2000 #ifdef PDF_ENABLE_XFA |
2000 m_XFAMap.RemoveAll(); | 2001 m_XFAMap.clear(); |
2001 #endif // PDF_ENABLE_XFA | 2002 #endif // PDF_ENABLE_XFA |
2002 } | 2003 } |
2003 | 2004 |
2004 FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { | 2005 FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { |
2005 return FALSE; | 2006 return FALSE; |
2006 } | 2007 } |
2007 | 2008 |
2008 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, | 2009 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, |
2009 FX_BOOL bNext) const { | 2010 FX_BOOL bNext) const { |
2010 std::unique_ptr<CBA_AnnotIterator> pIterator( | 2011 std::unique_ptr<CBA_AnnotIterator> pIterator( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2107 m_bCalculate = bEnabled; | 2108 m_bCalculate = bEnabled; |
2108 } | 2109 } |
2109 | 2110 |
2110 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { | 2111 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { |
2111 return m_bCalculate; | 2112 return m_bCalculate; |
2112 } | 2113 } |
2113 | 2114 |
2114 #ifdef PDF_ENABLE_XFA | 2115 #ifdef PDF_ENABLE_XFA |
2115 void CPDFSDK_InterForm::AddXFAMap(CXFA_FFWidget* hWidget, | 2116 void CPDFSDK_InterForm::AddXFAMap(CXFA_FFWidget* hWidget, |
2116 CPDFSDK_XFAWidget* pWidget) { | 2117 CPDFSDK_XFAWidget* pWidget) { |
2117 m_XFAMap.SetAt(hWidget, pWidget); | 2118 FXSYS_assert(hWidget); |
| 2119 m_XFAMap[hWidget] = pWidget; |
2118 } | 2120 } |
2119 | 2121 |
2120 void CPDFSDK_InterForm::RemoveXFAMap(CXFA_FFWidget* hWidget) { | 2122 void CPDFSDK_InterForm::RemoveXFAMap(CXFA_FFWidget* hWidget) { |
2121 m_XFAMap.RemoveKey(hWidget); | 2123 FXSYS_assert(hWidget); |
| 2124 m_XFAMap.erase(hWidget); |
2122 } | 2125 } |
2123 | 2126 |
2124 CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(CXFA_FFWidget* hWidget) { | 2127 CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(CXFA_FFWidget* hWidget) { |
2125 CPDFSDK_XFAWidget* pWidget = NULL; | 2128 FXSYS_assert(hWidget); |
2126 m_XFAMap.Lookup(hWidget, pWidget); | 2129 auto it = m_XFAMap.find(hWidget); |
2127 | 2130 return it != m_XFAMap.end() ? it->second : nullptr; |
2128 return pWidget; | |
2129 } | 2131 } |
2130 | 2132 |
2131 void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) { | 2133 void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) { |
2132 m_bXfaCalculate = bEnabled; | 2134 m_bXfaCalculate = bEnabled; |
2133 } | 2135 } |
2134 FX_BOOL CPDFSDK_InterForm::IsXfaCalculateEnabled() const { | 2136 FX_BOOL CPDFSDK_InterForm::IsXfaCalculateEnabled() const { |
2135 return m_bXfaCalculate; | 2137 return m_bXfaCalculate; |
2136 } | 2138 } |
2137 | 2139 |
2138 FX_BOOL CPDFSDK_InterForm::IsXfaValidationsEnabled() { | 2140 FX_BOOL CPDFSDK_InterForm::IsXfaValidationsEnabled() { |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2447 bool bIncludeOrExclude, | 2449 bool bIncludeOrExclude, |
2448 CFX_ByteTextBuf& textBuf) { | 2450 CFX_ByteTextBuf& textBuf) { |
2449 std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( | 2451 std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( |
2450 m_pDocument->GetPath().AsStringC(), fields, bIncludeOrExclude)); | 2452 m_pDocument->GetPath().AsStringC(), fields, bIncludeOrExclude)); |
2451 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; | 2453 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; |
2452 } | 2454 } |
2453 | 2455 |
2454 #ifdef PDF_ENABLE_XFA | 2456 #ifdef PDF_ENABLE_XFA |
2455 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, | 2457 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, |
2456 FX_BOOL bSynchronizeElse) { | 2458 FX_BOOL bSynchronizeElse) { |
2457 int x = 0; | |
2458 if (m_FieldSynchronizeMap.Lookup(pFormField, x)) | |
2459 return; | |
2460 | |
2461 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2459 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
2462 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2460 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
2463 ASSERT(pFormCtrl); | |
2464 ASSERT(m_pInterForm); | |
2465 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { | 2461 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { |
2466 pWidget->Synchronize(bSynchronizeElse); | 2462 pWidget->Synchronize(bSynchronizeElse); |
2467 } | 2463 } |
2468 } | 2464 } |
2469 } | 2465 } |
2470 #endif // PDF_ENABLE_XFA | 2466 #endif // PDF_ENABLE_XFA |
2471 | 2467 |
2472 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( | 2468 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( |
2473 const CFX_WideString& sFileExt) { | 2469 const CFX_WideString& sFileExt) { |
2474 CFX_WideString sFileName; | 2470 CFX_WideString sFileName; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2824 break; | 2820 break; |
2825 } | 2821 } |
2826 } | 2822 } |
2827 } | 2823 } |
2828 | 2824 |
2829 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2825 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { |
2830 CFX_FloatRect rcAnnot; | 2826 CFX_FloatRect rcAnnot; |
2831 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2827 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
2832 return rcAnnot; | 2828 return rcAnnot; |
2833 } | 2829 } |
OLD | NEW |