| 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/src/javascript/Field.h" | 7 #include "fpdfsdk/src/javascript/Field.h" | 
| 8 | 8 | 
| 9 #include <algorithm> | 9 #include <algorithm> | 
| 10 #include <memory> | 10 #include <memory> | 
| (...skipping 2077 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2088     rcArray.GetElement(1, Upper_Lefty); | 2088     rcArray.GetElement(1, Upper_Lefty); | 
| 2089     rcArray.GetElement(2, Lower_Rightx); | 2089     rcArray.GetElement(2, Lower_Rightx); | 
| 2090     rcArray.GetElement(3, Lower_Righty); | 2090     rcArray.GetElement(3, Lower_Righty); | 
| 2091 | 2091 | 
| 2092     FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | 2092     FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | 
| 2093     pArray[0] = (FX_FLOAT)Upper_Leftx.ToInt(); | 2093     pArray[0] = (FX_FLOAT)Upper_Leftx.ToInt(); | 
| 2094     pArray[1] = (FX_FLOAT)Lower_Righty.ToInt(); | 2094     pArray[1] = (FX_FLOAT)Lower_Righty.ToInt(); | 
| 2095     pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt(); | 2095     pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt(); | 
| 2096     pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt(); | 2096     pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt(); | 
| 2097 | 2097 | 
| 2098     CPDF_Rect crRect(pArray); | 2098     CFX_FloatRect crRect(pArray); | 
| 2099     if (m_bDelay) { | 2099     if (m_bDelay) { | 
| 2100       AddDelay_Rect(FP_RECT, crRect); | 2100       AddDelay_Rect(FP_RECT, crRect); | 
| 2101     } else { | 2101     } else { | 
| 2102       Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); | 2102       Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); | 
| 2103     } | 2103     } | 
| 2104   } else { | 2104   } else { | 
| 2105     std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 2105     std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 
| 2106     if (FieldArray.empty()) | 2106     if (FieldArray.empty()) | 
| 2107       return FALSE; | 2107       return FALSE; | 
| 2108 | 2108 | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 2126     rcArray.SetElement(2, Lower_Rightx); | 2126     rcArray.SetElement(2, Lower_Rightx); | 
| 2127     rcArray.SetElement(3, Lower_Righty); | 2127     rcArray.SetElement(3, Lower_Righty); | 
| 2128     vp << rcArray; | 2128     vp << rcArray; | 
| 2129   } | 2129   } | 
| 2130   return TRUE; | 2130   return TRUE; | 
| 2131 } | 2131 } | 
| 2132 | 2132 | 
| 2133 void Field::SetRect(CPDFSDK_Document* pDocument, | 2133 void Field::SetRect(CPDFSDK_Document* pDocument, | 
| 2134                     const CFX_WideString& swFieldName, | 2134                     const CFX_WideString& swFieldName, | 
| 2135                     int nControlIndex, | 2135                     int nControlIndex, | 
| 2136                     const CPDF_Rect& rect) { | 2136                     const CFX_FloatRect& rect) { | 
| 2137   CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); | 2137   CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); | 
| 2138 | 2138 | 
| 2139   std::vector<CPDF_FormField*> FieldArray = | 2139   std::vector<CPDF_FormField*> FieldArray = | 
| 2140       GetFormFields(pDocument, swFieldName); | 2140       GetFormFields(pDocument, swFieldName); | 
| 2141   for (CPDF_FormField* pFormField : FieldArray) { | 2141   for (CPDF_FormField* pFormField : FieldArray) { | 
| 2142     if (nControlIndex < 0) { | 2142     if (nControlIndex < 0) { | 
| 2143       FX_BOOL bSet = FALSE; | 2143       FX_BOOL bSet = FALSE; | 
| 2144       for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { | 2144       for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { | 
| 2145         CPDF_FormControl* pFormControl = pFormField->GetControl(i); | 2145         CPDF_FormControl* pFormControl = pFormField->GetControl(i); | 
| 2146         ASSERT(pFormControl); | 2146         ASSERT(pFormControl); | 
| 2147 | 2147 | 
| 2148         if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { | 2148         if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { | 
| 2149           CPDF_Rect crRect = rect; | 2149           CFX_FloatRect crRect = rect; | 
| 2150 | 2150 | 
| 2151           CPDF_Page* pPDFPage = pWidget->GetPDFPage(); | 2151           CPDF_Page* pPDFPage = pWidget->GetPDFPage(); | 
| 2152           crRect.Intersect(pPDFPage->GetPageBBox()); | 2152           crRect.Intersect(pPDFPage->GetPageBBox()); | 
| 2153 | 2153 | 
| 2154           if (!crRect.IsEmpty()) { | 2154           if (!crRect.IsEmpty()) { | 
| 2155             CPDF_Rect rcOld = pWidget->GetRect(); | 2155             CFX_FloatRect rcOld = pWidget->GetRect(); | 
| 2156             if (crRect.left != rcOld.left || crRect.right != rcOld.right || | 2156             if (crRect.left != rcOld.left || crRect.right != rcOld.right || | 
| 2157                 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { | 2157                 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { | 
| 2158               pWidget->SetRect(crRect); | 2158               pWidget->SetRect(crRect); | 
| 2159               bSet = TRUE; | 2159               bSet = TRUE; | 
| 2160             } | 2160             } | 
| 2161           } | 2161           } | 
| 2162         } | 2162         } | 
| 2163       } | 2163       } | 
| 2164 | 2164 | 
| 2165       if (bSet) | 2165       if (bSet) | 
| 2166         UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); | 2166         UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); | 
| 2167     } else { | 2167     } else { | 
| 2168       if (nControlIndex >= pFormField->CountControls()) | 2168       if (nControlIndex >= pFormField->CountControls()) | 
| 2169         return; | 2169         return; | 
| 2170       if (CPDF_FormControl* pFormControl = | 2170       if (CPDF_FormControl* pFormControl = | 
| 2171               pFormField->GetControl(nControlIndex)) { | 2171               pFormField->GetControl(nControlIndex)) { | 
| 2172         if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { | 2172         if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { | 
| 2173           CPDF_Rect crRect = rect; | 2173           CFX_FloatRect crRect = rect; | 
| 2174 | 2174 | 
| 2175           CPDF_Page* pPDFPage = pWidget->GetPDFPage(); | 2175           CPDF_Page* pPDFPage = pWidget->GetPDFPage(); | 
| 2176           crRect.Intersect(pPDFPage->GetPageBBox()); | 2176           crRect.Intersect(pPDFPage->GetPageBBox()); | 
| 2177 | 2177 | 
| 2178           if (!crRect.IsEmpty()) { | 2178           if (!crRect.IsEmpty()) { | 
| 2179             CPDF_Rect rcOld = pWidget->GetRect(); | 2179             CFX_FloatRect rcOld = pWidget->GetRect(); | 
| 2180             if (crRect.left != rcOld.left || crRect.right != rcOld.right || | 2180             if (crRect.left != rcOld.left || crRect.right != rcOld.right || | 
| 2181                 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { | 2181                 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { | 
| 2182               pWidget->SetRect(crRect); | 2182               pWidget->SetRect(crRect); | 
| 2183               UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE); | 2183               UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE); | 
| 2184             } | 2184             } | 
| 2185           } | 2185           } | 
| 2186         } | 2186         } | 
| 2187       } | 2187       } | 
| 2188     } | 2188     } | 
| 2189   } | 2189   } | 
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3395                                 const CFX_WideString& string) { | 3395                                 const CFX_WideString& string) { | 
| 3396   CJS_DelayData* pNewData = new CJS_DelayData; | 3396   CJS_DelayData* pNewData = new CJS_DelayData; | 
| 3397   pNewData->sFieldName = m_FieldName; | 3397   pNewData->sFieldName = m_FieldName; | 
| 3398   pNewData->nControlIndex = m_nFormControlIndex; | 3398   pNewData->nControlIndex = m_nFormControlIndex; | 
| 3399   pNewData->eProp = prop; | 3399   pNewData->eProp = prop; | 
| 3400   pNewData->widestring = string; | 3400   pNewData->widestring = string; | 
| 3401 | 3401 | 
| 3402   m_pJSDoc->AddDelayData(pNewData); | 3402   m_pJSDoc->AddDelayData(pNewData); | 
| 3403 } | 3403 } | 
| 3404 | 3404 | 
| 3405 void Field::AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect) { | 3405 void Field::AddDelay_Rect(enum FIELD_PROP prop, const CFX_FloatRect& rect) { | 
| 3406   CJS_DelayData* pNewData = new CJS_DelayData; | 3406   CJS_DelayData* pNewData = new CJS_DelayData; | 
| 3407   pNewData->sFieldName = m_FieldName; | 3407   pNewData->sFieldName = m_FieldName; | 
| 3408   pNewData->nControlIndex = m_nFormControlIndex; | 3408   pNewData->nControlIndex = m_nFormControlIndex; | 
| 3409   pNewData->eProp = prop; | 3409   pNewData->eProp = prop; | 
| 3410   pNewData->rect = rect; | 3410   pNewData->rect = rect; | 
| 3411 | 3411 | 
| 3412   m_pJSDoc->AddDelayData(pNewData); | 3412   m_pJSDoc->AddDelayData(pNewData); | 
| 3413 } | 3413 } | 
| 3414 | 3414 | 
| 3415 void Field::AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color) { | 3415 void Field::AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color) { | 
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3585       Field::SetValue(pDocument, pData->sFieldName, pData->nControlIndex, | 3585       Field::SetValue(pDocument, pData->sFieldName, pData->nControlIndex, | 
| 3586                       pData->widestringarray); | 3586                       pData->widestringarray); | 
| 3587       break; | 3587       break; | 
| 3588   } | 3588   } | 
| 3589 } | 3589 } | 
| 3590 | 3590 | 
| 3591 void Field::AddField(CPDFSDK_Document* pDocument, | 3591 void Field::AddField(CPDFSDK_Document* pDocument, | 
| 3592                      int nPageIndex, | 3592                      int nPageIndex, | 
| 3593                      int nFieldType, | 3593                      int nFieldType, | 
| 3594                      const CFX_WideString& sName, | 3594                      const CFX_WideString& sName, | 
| 3595                      const CPDF_Rect& rcCoords) { | 3595                      const CFX_FloatRect& rcCoords) { | 
| 3596   // Not supported. | 3596   // Not supported. | 
| 3597 } | 3597 } | 
| OLD | NEW | 
|---|