| 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 <memory> | 10 #include <memory> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 , | 44 , |
| 45 m_hMixXFAWidget(NULL), | 45 m_hMixXFAWidget(NULL), |
| 46 m_pWidgetHandler(NULL) | 46 m_pWidgetHandler(NULL) |
| 47 #endif // PDF_ENABLE_XFA | 47 #endif // PDF_ENABLE_XFA |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 CPDFSDK_Widget::~CPDFSDK_Widget() {} | 51 CPDFSDK_Widget::~CPDFSDK_Widget() {} |
| 52 | 52 |
| 53 #ifdef PDF_ENABLE_XFA | 53 #ifdef PDF_ENABLE_XFA |
| 54 IXFA_Widget* CPDFSDK_Widget::GetMixXFAWidget() const { | 54 CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const { |
| 55 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 55 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
| 56 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 56 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
| 57 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 57 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
| 58 if (!m_hMixXFAWidget) { | 58 if (!m_hMixXFAWidget) { |
| 59 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { | 59 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { |
| 60 CFX_WideString sName; | 60 CFX_WideString sName; |
| 61 if (GetFieldType() == FIELDTYPE_RADIOBUTTON) { | 61 if (GetFieldType() == FIELDTYPE_RADIOBUTTON) { |
| 62 sName = GetAnnotName(); | 62 sName = GetAnnotName(); |
| 63 if (sName.IsEmpty()) | 63 if (sName.IsEmpty()) |
| 64 sName = GetName(); | 64 sName = GetName(); |
| 65 } else { | 65 } else { |
| 66 sName = GetName(); | 66 sName = GetName(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 if (!sName.IsEmpty()) | 69 if (!sName.IsEmpty()) |
| 70 m_hMixXFAWidget = pDocView->GetWidgetByName(sName); | 70 m_hMixXFAWidget = pDocView->GetWidgetByName(sName); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 return m_hMixXFAWidget; | 73 return m_hMixXFAWidget; |
| 74 } | 74 } |
| 75 | 75 |
| 76 return NULL; | 76 return NULL; |
| 77 } | 77 } |
| 78 | 78 |
| 79 IXFA_Widget* CPDFSDK_Widget::GetGroupMixXFAWidget() { | 79 CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() { |
| 80 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 80 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
| 81 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 81 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
| 82 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 82 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
| 83 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { | 83 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { |
| 84 CFX_WideString sName = GetName(); | 84 CFX_WideString sName = GetName(); |
| 85 if (!sName.IsEmpty()) | 85 if (!sName.IsEmpty()) |
| 86 return pDocView->GetWidgetByName(sName); | 86 return pDocView->GetWidgetByName(sName); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 return nullptr; | 90 return nullptr; |
| 91 } | 91 } |
| 92 | 92 |
| 93 IXFA_WidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const { | 93 CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const { |
| 94 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 94 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
| 95 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 95 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
| 96 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 96 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
| 97 if (!m_pWidgetHandler) { | 97 if (!m_pWidgetHandler) { |
| 98 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { | 98 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { |
| 99 m_pWidgetHandler = pDocView->GetWidgetHandler(); | 99 m_pWidgetHandler = pDocView->GetWidgetHandler(); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 return m_pWidgetHandler; | 102 return m_pWidgetHandler; |
| 103 } | 103 } |
| 104 | 104 |
| 105 return NULL; | 105 return NULL; |
| 106 } | 106 } |
| 107 | 107 |
| 108 static XFA_EVENTTYPE GetXFAEventType(PDFSDK_XFAAActionType eXFAAAT) { | 108 static XFA_EVENTTYPE GetXFAEventType(PDFSDK_XFAAActionType eXFAAAT) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 case CPDF_AAction::DocumentSaved: | 174 case CPDF_AAction::DocumentSaved: |
| 175 case CPDF_AAction::PrintDocument: | 175 case CPDF_AAction::PrintDocument: |
| 176 case CPDF_AAction::DocumentPrinted: | 176 case CPDF_AAction::DocumentPrinted: |
| 177 break; | 177 break; |
| 178 } | 178 } |
| 179 | 179 |
| 180 return eEventType; | 180 return eEventType; |
| 181 } | 181 } |
| 182 | 182 |
| 183 FX_BOOL CPDFSDK_Widget::HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) { | 183 FX_BOOL CPDFSDK_Widget::HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) { |
| 184 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 184 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 185 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 185 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 186 XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT); | 186 XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT); |
| 187 | 187 |
| 188 if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && | 188 if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && |
| 189 GetFieldType() == FIELDTYPE_RADIOBUTTON) { | 189 GetFieldType() == FIELDTYPE_RADIOBUTTON) { |
| 190 if (IXFA_Widget* hGroupWidget = GetGroupMixXFAWidget()) { | 190 if (CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget()) { |
| 191 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hGroupWidget); | 191 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hGroupWidget); |
| 192 if (pXFAWidgetHandler->HasEvent(pAcc, eEventType)) | 192 if (pXFAWidgetHandler->HasEvent(pAcc, eEventType)) |
| 193 return TRUE; | 193 return TRUE; |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 | 196 |
| 197 { | 197 { |
| 198 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); | 198 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); |
| 199 return pXFAWidgetHandler->HasEvent(pAcc, eEventType); | 199 return pXFAWidgetHandler->HasEvent(pAcc, eEventType); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 return FALSE; | 204 return FALSE; |
| 205 } | 205 } |
| 206 | 206 |
| 207 FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, | 207 FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, |
| 208 PDFSDK_FieldAction& data, | 208 PDFSDK_FieldAction& data, |
| 209 CPDFSDK_PageView* pPageView) { | 209 CPDFSDK_PageView* pPageView) { |
| 210 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 210 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
| 211 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 211 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
| 212 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 212 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 213 XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT); | 213 XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT); |
| 214 | 214 |
| 215 if (eEventType != XFA_EVENT_Unknown) { | 215 if (eEventType != XFA_EVENT_Unknown) { |
| 216 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 216 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 217 CXFA_EventParam param; | 217 CXFA_EventParam param; |
| 218 param.m_eType = eEventType; | 218 param.m_eType = eEventType; |
| 219 param.m_wsChange = data.sChange; | 219 param.m_wsChange = data.sChange; |
| 220 param.m_iCommitKey = data.nCommitKey; | 220 param.m_iCommitKey = data.nCommitKey; |
| 221 param.m_bShift = data.bShift; | 221 param.m_bShift = data.bShift; |
| 222 param.m_iSelStart = data.nSelStart; | 222 param.m_iSelStart = data.nSelStart; |
| 223 param.m_iSelEnd = data.nSelEnd; | 223 param.m_iSelEnd = data.nSelEnd; |
| 224 param.m_wsFullText = data.sValue; | 224 param.m_wsFullText = data.sValue; |
| 225 param.m_bKeyDown = data.bKeyDown; | 225 param.m_bKeyDown = data.bKeyDown; |
| 226 param.m_bModifier = data.bModifier; | 226 param.m_bModifier = data.bModifier; |
| 227 param.m_wsNewText = data.sValue; | 227 param.m_wsNewText = data.sValue; |
| 228 if (data.nSelEnd > data.nSelStart) | 228 if (data.nSelEnd > data.nSelStart) |
| 229 param.m_wsNewText.Delete(data.nSelStart, | 229 param.m_wsNewText.Delete(data.nSelStart, |
| 230 data.nSelEnd - data.nSelStart); | 230 data.nSelEnd - data.nSelStart); |
| 231 for (int i = 0; i < data.sChange.GetLength(); i++) | 231 for (int i = 0; i < data.sChange.GetLength(); i++) |
| 232 param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]); | 232 param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]); |
| 233 param.m_wsPrevText = data.sValue; | 233 param.m_wsPrevText = data.sValue; |
| 234 | 234 |
| 235 if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && | 235 if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && |
| 236 GetFieldType() == FIELDTYPE_RADIOBUTTON) { | 236 GetFieldType() == FIELDTYPE_RADIOBUTTON) { |
| 237 if (IXFA_Widget* hGroupWidget = GetGroupMixXFAWidget()) { | 237 if (CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget()) { |
| 238 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hGroupWidget); | 238 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hGroupWidget); |
| 239 param.m_pTarget = pAcc; | 239 param.m_pTarget = pAcc; |
| 240 if (pXFAWidgetHandler->ProcessEvent(pAcc, ¶m) != | 240 if (pXFAWidgetHandler->ProcessEvent(pAcc, ¶m) != |
| 241 XFA_EVENTERROR_Success) { | 241 XFA_EVENTERROR_Success) { |
| 242 return FALSE; | 242 return FALSE; |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); | 246 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); |
| 247 param.m_pTarget = pAcc; | 247 param.m_pTarget = pAcc; |
| 248 int32_t nRet = pXFAWidgetHandler->ProcessEvent(pAcc, ¶m); | 248 int32_t nRet = pXFAWidgetHandler->ProcessEvent(pAcc, ¶m); |
| 249 | 249 |
| 250 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { | 250 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { |
| 251 pDocView->UpdateDocView(); | 251 pDocView->UpdateDocView(); |
| 252 } | 252 } |
| 253 return nRet == XFA_EVENTERROR_Success; | 253 return nRet == XFA_EVENTERROR_Success; |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 return FALSE; | 258 return FALSE; |
| 259 } | 259 } |
| 260 | 260 |
| 261 void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { | 261 void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { |
| 262 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 262 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 263 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 263 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 264 CPDF_FormField* pFormField = GetFormField(); | 264 CPDF_FormField* pFormField = GetFormField(); |
| 265 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 265 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
| 266 switch (GetFieldType()) { | 266 switch (GetFieldType()) { |
| 267 case FIELDTYPE_CHECKBOX: | 267 case FIELDTYPE_CHECKBOX: |
| 268 case FIELDTYPE_RADIOBUTTON: { | 268 case FIELDTYPE_RADIOBUTTON: { |
| 269 CPDF_FormControl* pFormCtrl = GetFormControl(); | 269 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 270 XFA_CHECKSTATE eCheckState = | 270 XFA_CHECKSTATE eCheckState = |
| 271 pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off; | 271 pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off; |
| 272 pWidgetAcc->SetCheckState(eCheckState); | 272 pWidgetAcc->SetCheckState(eCheckState); |
| 273 } break; | 273 } break; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 302 if (bSynchronizeElse) | 302 if (bSynchronizeElse) |
| 303 pWidgetAcc->ProcessValueChanged(); | 303 pWidgetAcc->ProcessValueChanged(); |
| 304 } | 304 } |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 | 308 |
| 309 void CPDFSDK_Widget::SynchronizeXFAValue() { | 309 void CPDFSDK_Widget::SynchronizeXFAValue() { |
| 310 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 310 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
| 311 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 311 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
| 312 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); | 312 CXFA_FFDocView* pXFADocView = pDoc->GetXFADocView(); |
| 313 if (!pXFADocView) | 313 if (!pXFADocView) |
| 314 return; | 314 return; |
| 315 | 315 |
| 316 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 316 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 317 if (GetXFAWidgetHandler()) { | 317 if (GetXFAWidgetHandler()) { |
| 318 CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, GetFormField(), | 318 CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, GetFormField(), |
| 319 GetFormControl()); | 319 GetFormControl()); |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 void CPDFSDK_Widget::SynchronizeXFAItems() { | 324 void CPDFSDK_Widget::SynchronizeXFAItems() { |
| 325 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 325 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
| 326 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 326 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
| 327 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); | 327 CXFA_FFDocView* pXFADocView = pDoc->GetXFADocView(); |
| 328 if (!pXFADocView) | 328 if (!pXFADocView) |
| 329 return; | 329 return; |
| 330 | 330 |
| 331 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 331 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 332 if (GetXFAWidgetHandler()) | 332 if (GetXFAWidgetHandler()) |
| 333 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); | 333 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 | 336 |
| 337 void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView, | 337 void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, |
| 338 IXFA_Widget* hWidget, | 338 CXFA_FFWidget* hWidget, |
| 339 CPDF_FormField* pFormField, | 339 CPDF_FormField* pFormField, |
| 340 CPDF_FormControl* pFormControl) { | 340 CPDF_FormControl* pFormControl) { |
| 341 ASSERT(hWidget); | 341 ASSERT(hWidget); |
| 342 | 342 |
| 343 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { | 343 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = |
| 344 pXFADocView->GetWidgetHandler()) { |
| 344 ASSERT(pFormControl); | 345 ASSERT(pFormControl); |
| 345 | 346 |
| 346 switch (pFormField->GetFieldType()) { | 347 switch (pFormField->GetFieldType()) { |
| 347 case FIELDTYPE_CHECKBOX: { | 348 case FIELDTYPE_CHECKBOX: { |
| 348 if (CXFA_WidgetAcc* pWidgetAcc = | 349 if (CXFA_WidgetAcc* pWidgetAcc = |
| 349 pXFAWidgetHandler->GetDataAcc(hWidget)) { | 350 pXFAWidgetHandler->GetDataAcc(hWidget)) { |
| 350 pFormField->CheckControl( | 351 pFormField->CheckControl( |
| 351 pFormField->GetControlIndex(pFormControl), | 352 pFormField->GetControlIndex(pFormControl), |
| 352 pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On, true); | 353 pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On, true); |
| 353 } | 354 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 400 |
| 400 CFX_WideString sValue; | 401 CFX_WideString sValue; |
| 401 pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); | 402 pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); |
| 402 pFormField->SetValue(sValue, TRUE); | 403 pFormField->SetValue(sValue, TRUE); |
| 403 } | 404 } |
| 404 } break; | 405 } break; |
| 405 } | 406 } |
| 406 } | 407 } |
| 407 } | 408 } |
| 408 | 409 |
| 409 void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView, | 410 void CPDFSDK_Widget::SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, |
| 410 IXFA_Widget* hWidget, | 411 CXFA_FFWidget* hWidget, |
| 411 CPDF_FormField* pFormField, | 412 CPDF_FormField* pFormField, |
| 412 CPDF_FormControl* pFormControl) { | 413 CPDF_FormControl* pFormControl) { |
| 413 ASSERT(hWidget); | 414 ASSERT(hWidget); |
| 414 | 415 |
| 415 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { | 416 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = |
| 417 pXFADocView->GetWidgetHandler()) { |
| 416 switch (pFormField->GetFieldType()) { | 418 switch (pFormField->GetFieldType()) { |
| 417 case FIELDTYPE_LISTBOX: { | 419 case FIELDTYPE_LISTBOX: { |
| 418 pFormField->ClearSelection(FALSE); | 420 pFormField->ClearSelection(FALSE); |
| 419 pFormField->ClearOptions(TRUE); | 421 pFormField->ClearOptions(TRUE); |
| 420 | 422 |
| 421 if (CXFA_WidgetAcc* pWidgetAcc = | 423 if (CXFA_WidgetAcc* pWidgetAcc = |
| 422 pXFAWidgetHandler->GetDataAcc(hWidget)) { | 424 pXFAWidgetHandler->GetDataAcc(hWidget)) { |
| 423 for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; | 425 for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; |
| 424 i++) { | 426 i++) { |
| 425 CFX_WideString swText; | 427 CFX_WideString swText; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); | 586 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); |
| 585 CFX_ByteString csFont = ""; | 587 CFX_ByteString csFont = ""; |
| 586 FX_FLOAT fFontSize = 0.0f; | 588 FX_FLOAT fFontSize = 0.0f; |
| 587 pDa.GetFont(csFont, fFontSize); | 589 pDa.GetFont(csFont, fFontSize); |
| 588 | 590 |
| 589 return fFontSize; | 591 return fFontSize; |
| 590 } | 592 } |
| 591 | 593 |
| 592 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { | 594 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { |
| 593 #ifdef PDF_ENABLE_XFA | 595 #ifdef PDF_ENABLE_XFA |
| 594 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 596 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 595 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 597 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 596 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 598 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
| 597 if (nIndex < pWidgetAcc->CountSelectedItems()) | 599 if (nIndex < pWidgetAcc->CountSelectedItems()) |
| 598 return pWidgetAcc->GetSelectedItem(nIndex); | 600 return pWidgetAcc->GetSelectedItem(nIndex); |
| 599 } | 601 } |
| 600 } | 602 } |
| 601 } | 603 } |
| 602 #endif // PDF_ENABLE_XFA | 604 #endif // PDF_ENABLE_XFA |
| 603 CPDF_FormField* pFormField = GetFormField(); | 605 CPDF_FormField* pFormField = GetFormField(); |
| 604 return pFormField->GetSelectedIndex(nIndex); | 606 return pFormField->GetSelectedIndex(nIndex); |
| 605 } | 607 } |
| 606 | 608 |
| 607 #ifdef PDF_ENABLE_XFA | 609 #ifdef PDF_ENABLE_XFA |
| 608 CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const { | 610 CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const { |
| 609 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 611 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 610 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 612 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 611 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 613 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
| 612 CFX_WideString sValue; | 614 CFX_WideString sValue; |
| 613 pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display | 615 pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display |
| 614 : XFA_VALUEPICTURE_Edit); | 616 : XFA_VALUEPICTURE_Edit); |
| 615 return sValue; | 617 return sValue; |
| 616 } | 618 } |
| 617 } | 619 } |
| 618 } | 620 } |
| 619 #else | 621 #else |
| 620 CFX_WideString CPDFSDK_Widget::GetValue() const { | 622 CFX_WideString CPDFSDK_Widget::GetValue() const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 633 return pFormField->GetOptionLabel(nIndex); | 635 return pFormField->GetOptionLabel(nIndex); |
| 634 } | 636 } |
| 635 | 637 |
| 636 int CPDFSDK_Widget::CountOptions() const { | 638 int CPDFSDK_Widget::CountOptions() const { |
| 637 CPDF_FormField* pFormField = GetFormField(); | 639 CPDF_FormField* pFormField = GetFormField(); |
| 638 return pFormField->CountOptions(); | 640 return pFormField->CountOptions(); |
| 639 } | 641 } |
| 640 | 642 |
| 641 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { | 643 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { |
| 642 #ifdef PDF_ENABLE_XFA | 644 #ifdef PDF_ENABLE_XFA |
| 643 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 645 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 644 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 646 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 645 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 647 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
| 646 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) | 648 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) |
| 647 return pWidgetAcc->GetItemState(nIndex); | 649 return pWidgetAcc->GetItemState(nIndex); |
| 648 | 650 |
| 649 return FALSE; | 651 return FALSE; |
| 650 } | 652 } |
| 651 } | 653 } |
| 652 } | 654 } |
| 653 #endif // PDF_ENABLE_XFA | 655 #endif // PDF_ENABLE_XFA |
| 654 CPDF_FormField* pFormField = GetFormField(); | 656 CPDF_FormField* pFormField = GetFormField(); |
| 655 return pFormField->IsItemSelected(nIndex); | 657 return pFormField->IsItemSelected(nIndex); |
| 656 } | 658 } |
| 657 | 659 |
| 658 int CPDFSDK_Widget::GetTopVisibleIndex() const { | 660 int CPDFSDK_Widget::GetTopVisibleIndex() const { |
| 659 CPDF_FormField* pFormField = GetFormField(); | 661 CPDF_FormField* pFormField = GetFormField(); |
| 660 return pFormField->GetTopVisibleIndex(); | 662 return pFormField->GetTopVisibleIndex(); |
| 661 } | 663 } |
| 662 | 664 |
| 663 bool CPDFSDK_Widget::IsChecked() const { | 665 bool CPDFSDK_Widget::IsChecked() const { |
| 664 #ifdef PDF_ENABLE_XFA | 666 #ifdef PDF_ENABLE_XFA |
| 665 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 667 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 666 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 668 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 667 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) | 669 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) |
| 668 return pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; | 670 return pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; |
| 669 } | 671 } |
| 670 } | 672 } |
| 671 #endif // PDF_ENABLE_XFA | 673 #endif // PDF_ENABLE_XFA |
| 672 CPDF_FormControl* pFormCtrl = GetFormControl(); | 674 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 673 return pFormCtrl->IsChecked(); | 675 return pFormCtrl->IsChecked(); |
| 674 } | 676 } |
| 675 | 677 |
| 676 int CPDFSDK_Widget::GetAlignment() const { | 678 int CPDFSDK_Widget::GetAlignment() const { |
| (...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 } | 1869 } |
| 1868 | 1870 |
| 1869 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, | 1871 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, |
| 1870 PDFSDK_FieldAction& data, | 1872 PDFSDK_FieldAction& data, |
| 1871 CPDFSDK_PageView* pPageView) { | 1873 CPDFSDK_PageView* pPageView) { |
| 1872 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 1874 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
| 1873 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 1875 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 1874 | 1876 |
| 1875 #ifdef PDF_ENABLE_XFA | 1877 #ifdef PDF_ENABLE_XFA |
| 1876 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); | 1878 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); |
| 1877 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 1879 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 1878 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); | 1880 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); |
| 1879 | 1881 |
| 1880 if (eEventType != XFA_EVENT_Unknown) { | 1882 if (eEventType != XFA_EVENT_Unknown) { |
| 1881 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 1883 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 1882 CXFA_EventParam param; | 1884 CXFA_EventParam param; |
| 1883 param.m_eType = eEventType; | 1885 param.m_eType = eEventType; |
| 1884 param.m_wsChange = data.sChange; | 1886 param.m_wsChange = data.sChange; |
| 1885 param.m_iCommitKey = data.nCommitKey; | 1887 param.m_iCommitKey = data.nCommitKey; |
| 1886 param.m_bShift = data.bShift; | 1888 param.m_bShift = data.bShift; |
| 1887 param.m_iSelStart = data.nSelStart; | 1889 param.m_iSelStart = data.nSelStart; |
| 1888 param.m_iSelEnd = data.nSelEnd; | 1890 param.m_iSelEnd = data.nSelEnd; |
| 1889 param.m_wsFullText = data.sValue; | 1891 param.m_wsFullText = data.sValue; |
| 1890 param.m_bKeyDown = data.bKeyDown; | 1892 param.m_bKeyDown = data.bKeyDown; |
| 1891 param.m_bModifier = data.bModifier; | 1893 param.m_bModifier = data.bModifier; |
| 1892 param.m_wsNewText = data.sValue; | 1894 param.m_wsNewText = data.sValue; |
| 1893 if (data.nSelEnd > data.nSelStart) | 1895 if (data.nSelEnd > data.nSelStart) |
| 1894 param.m_wsNewText.Delete(data.nSelStart, | 1896 param.m_wsNewText.Delete(data.nSelStart, |
| 1895 data.nSelEnd - data.nSelStart); | 1897 data.nSelEnd - data.nSelStart); |
| 1896 for (int i = data.sChange.GetLength() - 1; i >= 0; i--) | 1898 for (int i = data.sChange.GetLength() - 1; i >= 0; i--) |
| 1897 param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]); | 1899 param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]); |
| 1898 param.m_wsPrevText = data.sValue; | 1900 param.m_wsPrevText = data.sValue; |
| 1899 | 1901 |
| 1900 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); | 1902 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); |
| 1901 param.m_pTarget = pAcc; | 1903 param.m_pTarget = pAcc; |
| 1902 int32_t nRet = pXFAWidgetHandler->ProcessEvent(pAcc, ¶m); | 1904 int32_t nRet = pXFAWidgetHandler->ProcessEvent(pAcc, ¶m); |
| 1903 | 1905 |
| 1904 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { | 1906 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { |
| 1905 pDocView->UpdateDocView(); | 1907 pDocView->UpdateDocView(); |
| 1906 } | 1908 } |
| 1907 | 1909 |
| 1908 if (nRet == XFA_EVENTERROR_Success) | 1910 if (nRet == XFA_EVENTERROR_Success) |
| 1909 return TRUE; | 1911 return TRUE; |
| 1910 } | 1912 } |
| 1911 } | 1913 } |
| 1912 } | 1914 } |
| 1913 #endif // PDF_ENABLE_XFA | 1915 #endif // PDF_ENABLE_XFA |
| 1914 | 1916 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 int nFieldFlags = GetFieldFlags(); | 1977 int nFieldFlags = GetFieldFlags(); |
| 1976 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | 1978 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
| 1977 return FALSE; | 1979 return FALSE; |
| 1978 | 1980 |
| 1979 return TRUE; | 1981 return TRUE; |
| 1980 } | 1982 } |
| 1981 return FALSE; | 1983 return FALSE; |
| 1982 } | 1984 } |
| 1983 | 1985 |
| 1984 #ifdef PDF_ENABLE_XFA | 1986 #ifdef PDF_ENABLE_XFA |
| 1985 CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(IXFA_Widget* pAnnot, | 1987 CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(CXFA_FFWidget* pAnnot, |
| 1986 CPDFSDK_PageView* pPageView, | 1988 CPDFSDK_PageView* pPageView, |
| 1987 CPDFSDK_InterForm* pInterForm) | 1989 CPDFSDK_InterForm* pInterForm) |
| 1988 : CPDFSDK_Annot(pPageView), | 1990 : CPDFSDK_Annot(pPageView), |
| 1989 m_pInterForm(pInterForm), | 1991 m_pInterForm(pInterForm), |
| 1990 m_hXFAWidget(pAnnot) {} | 1992 m_hXFAWidget(pAnnot) {} |
| 1991 | 1993 |
| 1992 FX_BOOL CPDFSDK_XFAWidget::IsXFAField() { | 1994 FX_BOOL CPDFSDK_XFAWidget::IsXFAField() { |
| 1993 return TRUE; | 1995 return TRUE; |
| 1994 } | 1996 } |
| 1995 | 1997 |
| 1996 CFX_ByteString CPDFSDK_XFAWidget::GetType() const { | 1998 CFX_ByteString CPDFSDK_XFAWidget::GetType() const { |
| 1997 return FSDK_XFAWIDGET_TYPENAME; | 1999 return FSDK_XFAWIDGET_TYPENAME; |
| 1998 } | 2000 } |
| 1999 | 2001 |
| 2000 CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { | 2002 CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { |
| 2001 CPDFSDK_PageView* pPageView = GetPageView(); | 2003 CPDFSDK_PageView* pPageView = GetPageView(); |
| 2002 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 2004 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
| 2003 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); | 2005 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); |
| 2004 IXFA_DocView* pDocView = pDoc->GetXFADocView(); | 2006 CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); |
| 2005 IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); | 2007 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); |
| 2006 | 2008 |
| 2007 CFX_RectF rcBBox; | 2009 CFX_RectF rcBBox; |
| 2008 pWidgetHandler->GetRect(GetXFAWidget(), rcBBox); | 2010 pWidgetHandler->GetRect(GetXFAWidget(), rcBBox); |
| 2009 | 2011 |
| 2010 return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, | 2012 return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, |
| 2011 rcBBox.top + rcBBox.height); | 2013 rcBBox.top + rcBBox.height); |
| 2012 } | 2014 } |
| 2013 #endif // PDF_ENABLE_XFA | 2015 #endif // PDF_ENABLE_XFA |
| 2014 | 2016 |
| 2015 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) | 2017 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2142 | 2144 |
| 2143 void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) { | 2145 void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) { |
| 2144 m_bCalculate = bEnabled; | 2146 m_bCalculate = bEnabled; |
| 2145 } | 2147 } |
| 2146 | 2148 |
| 2147 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { | 2149 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { |
| 2148 return m_bCalculate; | 2150 return m_bCalculate; |
| 2149 } | 2151 } |
| 2150 | 2152 |
| 2151 #ifdef PDF_ENABLE_XFA | 2153 #ifdef PDF_ENABLE_XFA |
| 2152 void CPDFSDK_InterForm::AddXFAMap(IXFA_Widget* hWidget, | 2154 void CPDFSDK_InterForm::AddXFAMap(CXFA_FFWidget* hWidget, |
| 2153 CPDFSDK_XFAWidget* pWidget) { | 2155 CPDFSDK_XFAWidget* pWidget) { |
| 2154 m_XFAMap.SetAt(hWidget, pWidget); | 2156 m_XFAMap.SetAt(hWidget, pWidget); |
| 2155 } | 2157 } |
| 2156 | 2158 |
| 2157 void CPDFSDK_InterForm::RemoveXFAMap(IXFA_Widget* hWidget) { | 2159 void CPDFSDK_InterForm::RemoveXFAMap(CXFA_FFWidget* hWidget) { |
| 2158 m_XFAMap.RemoveKey(hWidget); | 2160 m_XFAMap.RemoveKey(hWidget); |
| 2159 } | 2161 } |
| 2160 | 2162 |
| 2161 CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(IXFA_Widget* hWidget) { | 2163 CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(CXFA_FFWidget* hWidget) { |
| 2162 CPDFSDK_XFAWidget* pWidget = NULL; | 2164 CPDFSDK_XFAWidget* pWidget = NULL; |
| 2163 m_XFAMap.Lookup(hWidget, pWidget); | 2165 m_XFAMap.Lookup(hWidget, pWidget); |
| 2164 | 2166 |
| 2165 return pWidget; | 2167 return pWidget; |
| 2166 } | 2168 } |
| 2167 | 2169 |
| 2168 void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) { | 2170 void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) { |
| 2169 m_bXfaCalculate = bEnabled; | 2171 m_bXfaCalculate = bEnabled; |
| 2170 } | 2172 } |
| 2171 FX_BOOL CPDFSDK_InterForm::IsXfaCalculateEnabled() const { | 2173 FX_BOOL CPDFSDK_InterForm::IsXfaCalculateEnabled() const { |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2860 break; | 2862 break; |
| 2861 } | 2863 } |
| 2862 } | 2864 } |
| 2863 } | 2865 } |
| 2864 | 2866 |
| 2865 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2867 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { |
| 2866 CFX_FloatRect rcAnnot; | 2868 CFX_FloatRect rcAnnot; |
| 2867 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2869 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
| 2868 return rcAnnot; | 2870 return rcAnnot; |
| 2869 } | 2871 } |
| OLD | NEW |