Cleanup: Get this rid of "this->" in fpdfsdk/
[pdfium.git] / fpdfsdk / src / formfiller / FFL_ComboBox.cpp
index 3f2c453..e10c981 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#include "../../include/formfiller/FormFiller.h"\r
-#include "../../include/formfiller/FFL_FormFiller.h"\r
-#include "../../include/formfiller/FFL_IFormFiller.h"\r
-#include "../../include/formfiller/FFL_CBA_Fontmap.h"\r
-#include "../../include/formfiller/FFL_ComboBox.h"\r
-\r
-\r
-/* ------------------------------- CFFL_ComboBox ------------------------------- */\r
-\r
-CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) :\r
-       CFFL_FormFiller(pApp, pAnnot), m_pFontMap( NULL )\r
-{\r
-       //m_pFontMap = new CBA_FontMap( pAnnot, GetSystemHandler() );\r
-        m_State.nIndex = 0;\r
-        m_State.nStart = 0;\r
-        m_State.nEnd   = 0;\r
-}\r
-\r
-CFFL_ComboBox::~CFFL_ComboBox()\r
-{\r
-       if (m_pFontMap)\r
-       {\r
-               delete m_pFontMap;\r
-               m_pFontMap = NULL;\r
-       }\r
-\r
-//     for (int i=0,sz=m_IMBox.GetSize(); i<sz; i++)\r
-//     {\r
-//             delete m_IMBox.GetAt(i);\r
-//     }\r
-// \r
-//     m_IMBox.RemoveAll();\r
-}\r
-\r
-PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam()\r
-{\r
-       PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();\r
-\r
-       ASSERT(m_pWidget != NULL);\r
-\r
-       int nFlags = m_pWidget->GetFieldFlags();\r
-       \r
-       if (nFlags & FIELDFLAG_EDIT)\r
-       {               \r
-               cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;\r
-       }\r
-\r
-       /*\r
-       if (nFlags & FIELDFLAG_COMMITONSELCHANGE)\r
-       {               \r
-               m_bCommitOnSelectChange = TRUE;\r
-       }\r
-       */\r
-\r
-       if (!m_pFontMap)\r
-       {\r
-               ASSERT(this->m_pApp != NULL);\r
-               m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler());\r
-               m_pFontMap->Initial();\r
-       }\r
-\r
-       cp.pFontMap = m_pFontMap;\r
-       cp.pFocusHandler = this;\r
-\r
-       return cp;\r
-}\r
-\r
-CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView)\r
-{\r
-       CPWL_ComboBox * pWnd = new CPWL_ComboBox();\r
-       pWnd->AttachFFLData(this);\r
-       pWnd->Create(cp);\r
-\r
-       ASSERT(m_pApp != NULL);\r
-       CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller();\r
-       pWnd->SetFillerNotify(pFormFiller);\r
-\r
-       ASSERT(m_pWidget != NULL);\r
-       FX_INT32 nCurSel = m_pWidget->GetSelectedIndex(0);\r
-       \r
-       CFX_WideString swText;\r
-       \r
-       if (nCurSel < 0)\r
-               swText = m_pWidget->GetValue();\r
-       else\r
-               swText = m_pWidget->GetOptionLabel(nCurSel);\r
-       \r
-       for (FX_INT32 i=0,sz=m_pWidget->CountOptions(); i<sz; i++)\r
-       {\r
-               pWnd->AddString(m_pWidget->GetOptionLabel(i));                  \r
-       }\r
-       \r
-       pWnd->SetSelect(nCurSel);\r
-       pWnd->SetText(swText);\r
-       \r
-       return pWnd;\r
-}\r
-\r
-\r
-FX_BOOL        CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)\r
-{\r
-       return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);\r
-}\r
-\r
-FX_BOOL        CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView)\r
-{\r
-       if (CPWL_ComboBox * pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))\r
-       {\r
-               FX_INT32 nCurSel = pWnd->GetSelect();\r
-\r
-               ASSERT(m_pWidget != NULL);\r
-\r
-               if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)\r
-               {\r
-                       if (nCurSel >= 0)\r
-                       {\r
-                               return nCurSel != m_pWidget->GetSelectedIndex(0);\r
-                       }\r
-                       else\r
-                       {\r
-                               return pWnd->GetText() != m_pWidget->GetValue();\r
-                       }\r
-               }\r
-               else\r
-               {\r
-                       return nCurSel != m_pWidget->GetSelectedIndex(0);\r
-               }\r
-       }\r
-       \r
-       return FALSE;\r
-}\r
-\r
-void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView)\r
-{\r
-       ASSERT(m_pWidget != NULL);\r
-\r
-       if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))\r
-       {\r
-               CFX_WideString swText = pWnd->GetText();\r
-               FX_INT32 nCurSel = pWnd->GetSelect();\r
-\r
-               //mantis:0004157\r
-               FX_BOOL bSetValue = TRUE;\r
-\r
-               if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)\r
-               {\r
-                       if (nCurSel >= 0)\r
-                       {\r
-                               if (swText != m_pWidget->GetOptionLabel(nCurSel))\r
-                                       bSetValue = TRUE;\r
-                               else\r
-                                       bSetValue = FALSE;\r
-                       }\r
-                       else\r
-                               bSetValue = TRUE;\r
-               }\r
-               else\r
-                       bSetValue = FALSE;\r
-\r
-               CFX_WideString sOldValue;\r
-               \r
-\r
-               if (bSetValue)\r
-               {\r
-                       sOldValue = m_pWidget->GetValue();\r
-                       m_pWidget->SetValue(swText, FALSE);\r
-               }\r
-               else\r
-               {\r
-                       m_pWidget->GetSelectedIndex(0);\r
-                       m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE);\r
-               }\r
-\r
-               m_pWidget->ResetFieldAppearance(TRUE);\r
-               m_pWidget->UpdateField();\r
-               SetChangeMark();\r
-\r
-               m_pWidget->GetPDFPage();\r
-               \r
-\r
-       }\r
-}\r
-\r
- void CFFL_ComboBox::GetActionData( CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, PDFSDK_FieldAction& fa)\r
-{\r
-       switch (type)\r
-       {\r
-       case CPDF_AAction::KeyStroke:\r
-               if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))\r
-               {\r
-                       if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)\r
-                       {\r
-                               fa.bFieldFull = pEdit->IsTextFull();    \r
-                               int nSelStart = 0;\r
-                               int nSelEnd = 0;\r
-                               pEdit->GetSel(nSelStart, nSelEnd);\r
-                               fa.nSelEnd = nSelEnd;\r
-                               fa.nSelStart = nSelStart;\r
-                               fa.sValue = pEdit->GetText();\r
-                               fa.sChangeEx = GetSelectExportText();\r
-\r
-                               if (fa.bFieldFull)\r
-                               {\r
-                                       fa.sChange = L"";\r
-                                       fa.sChangeEx = L"";\r
-                               }\r
-                       }\r
-               }\r
-               break;\r
-       case CPDF_AAction::Validate:\r
-               if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))\r
-               {\r
-                       if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)\r
-                       {\r
-                               fa.sValue = pEdit->GetText();\r
-                       }\r
-               }\r
-               break;\r
-       case CPDF_AAction::LoseFocus:\r
-       case CPDF_AAction::GetFocus:\r
-               ASSERT(m_pWidget != NULL);\r
-               fa.sValue = m_pWidget->GetValue();\r
-               break;\r
-       default:\r
-               break;\r
-       }\r
-}\r
-\r
-\r
-\r
-void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, \r
-                                                                       const PDFSDK_FieldAction& fa)\r
-{\r
-       switch (type)\r
-       {\r
-       case CPDF_AAction::KeyStroke:\r
-               if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))\r
-               {\r
-                       if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)\r
-                       {\r
-                               pEdit->SetSel(fa.nSelStart, fa.nSelEnd);\r
-                               pEdit->ReplaceSel(fa.sChange);\r
-                       }\r
-               }\r
-               break;\r
-       default:\r
-               break;\r
-       }\r
-}\r
-\r
-FX_BOOL        CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld, \r
-                                                                       const PDFSDK_FieldAction& faNew)\r
-{\r
-       switch (type)\r
-       {\r
-       case CPDF_AAction::KeyStroke:\r
-               return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || faOld.nSelStart != faNew.nSelStart ||\r
-                       faOld.sChange != faNew.sChange;\r
-       default:\r
-               break;\r
-       }\r
-\r
-       return FALSE;\r
-}\r
-\r
-void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView)\r
-{\r
-       ASSERT(pPageView != NULL);\r
-\r
-       if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))\r
-       {\r
-               m_State.nIndex = pComboBox->GetSelect();\r
-\r
-               if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)\r
-               {\r
-                       pEdit->GetSel(m_State.nStart, m_State.nEnd);\r
-                       m_State.sValue = pEdit->GetText();\r
-               }\r
-       }\r
-}\r
-\r
-void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView)\r
-{\r
-       ASSERT(pPageView != NULL);\r
-\r
-       if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE))\r
-       {\r
-               if (m_State.nIndex >= 0)\r
-                       pComboBox->SetSelect(m_State.nIndex);\r
-               else\r
-               {\r
-                       if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)\r
-                       {\r
-                               pEdit->SetText(m_State.sValue);\r
-                               pEdit->SetSel(m_State.nStart, m_State.nEnd);\r
-                       }\r
-               }\r
-       }\r
-}\r
-\r
-CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue)\r
-{\r
-       if (bRestoreValue)\r
-               SaveState(pPageView);\r
-       \r
-       DestroyPDFWindow(pPageView);\r
-       \r
-       CPWL_Wnd* pRet = NULL;\r
-       \r
-       if (bRestoreValue)\r
-       {\r
-               RestoreState(pPageView);\r
-               pRet = this->GetPDFWindow(pPageView, FALSE);\r
-       }\r
-       else\r
-               pRet = this->GetPDFWindow(pPageView, TRUE);\r
-       \r
-       m_pWidget->UpdateField();\r
-       \r
-       return pRet;\r
-}\r
-\r
-void CFFL_ComboBox::OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag)\r
-{\r
-       ASSERT(m_pWidget != NULL);\r
-       \r
-       int nFlags = m_pWidget->GetFieldFlags();\r
-       \r
-       if (nFlags & FIELDFLAG_COMMITONSELCHANGE)\r
-       {\r
-               if (m_bValid)\r
-               {\r
-                       CPDFSDK_PageView* pPageView = this->GetCurPageView();\r
-                       ASSERT(pPageView != NULL);\r
-\r
-                       if (CommitData(pPageView, nFlag))\r
-                       {\r
-                               DestroyPDFWindow(pPageView);\r
-                               m_bValid = FALSE;\r
-                       }\r
-               }\r
-       }\r
-}\r
-\r
-void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd)\r
-{\r
-       ASSERT(m_pApp != NULL);\r
-\r
-       ASSERT(pWnd != NULL);\r
-\r
-       if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT)\r
-       {\r
-               CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;\r
-               pEdit->SetCharSet(134);\r
-               pEdit->SetCodePage(936);\r
-\r
-               pEdit->SetReadyToInput();\r
-               CFX_WideString wsText = pEdit->GetText();\r
-               int nCharacters = wsText.GetLength();\r
-               CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();\r
-               unsigned short* pBuffer = (unsigned short*)(FX_LPCSTR)bsUTFText;\r
-               m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE);\r
-\r
-               pEdit->SetEditNotify(this);\r
-       }\r
-}\r
-\r
-void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd)\r
-{\r
-       ASSERT(m_pApp != NULL);\r
-}\r
-\r
-FX_BOOL        CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument)\r
-{\r
-       ASSERT(pDocument != NULL);\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL CFFL_ComboBox::CanCut(CPDFSDK_Document* pDocument)\r
-{\r
-       ASSERT(pDocument != NULL);\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument)\r
-{\r
-       ASSERT(pDocument != NULL);\r
-\r
-       return FALSE;\r
-}\r
-\r
-void CFFL_ComboBox::DoCopy(CPDFSDK_Document* pDocument)\r
-{\r
-       ASSERT(pDocument != NULL);\r
-}\r
-\r
-void CFFL_ComboBox::DoCut(CPDFSDK_Document* pDocument)\r
-{\r
-       ASSERT(pDocument != NULL);\r
-}\r
-\r
-void CFFL_ComboBox::DoPaste(CPDFSDK_Document* pDocument)\r
-{\r
-       ASSERT(pDocument != NULL);\r
-}\r
-\r
-void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit)\r
-{\r
-       ASSERT(pEdit != NULL);\r
-}\r
-\r
-CFX_WideString CFFL_ComboBox::GetSelectExportText()\r
-{\r
-       CFX_WideString swRet;\r
-       \r
-       int nExport = -1;\r
-       CPDFSDK_PageView *pPageView = GetCurPageView();\r
-       if (CPWL_ComboBox * pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))\r
-       {\r
-               nExport = pComboBox->GetSelect();\r
-       }\r
-       \r
-       if (nExport >= 0)\r
-       {\r
-               if (CPDF_FormField * pFormField = m_pWidget->GetFormField())\r
-               {\r
-                       swRet = pFormField->GetOptionValue(nExport);\r
-                       if (swRet.IsEmpty())\r
-                               swRet = pFormField->GetOptionLabel(nExport);\r
-               }\r
-       }\r
-       \r
-       return swRet;\r
-}\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "../../include/formfiller/FormFiller.h"
+#include "../../include/formfiller/FFL_FormFiller.h"
+#include "../../include/formfiller/FFL_IFormFiller.h"
+#include "../../include/formfiller/FFL_CBA_Fontmap.h"
+#include "../../include/formfiller/FFL_ComboBox.h"
+
+
+/* ------------------------------- CFFL_ComboBox ------------------------------- */
+
+CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) :
+       CFFL_FormFiller(pApp, pAnnot), m_pFontMap( NULL )
+{
+        m_State.nIndex = 0;
+        m_State.nStart = 0;
+        m_State.nEnd   = 0;
+}
+
+CFFL_ComboBox::~CFFL_ComboBox()
+{
+       if (m_pFontMap)
+       {
+               delete m_pFontMap;
+               m_pFontMap = NULL;
+       }
+}
+
+PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam()
+{
+       PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
+
+       ASSERT(m_pWidget != NULL);
+
+       int nFlags = m_pWidget->GetFieldFlags();
+       
+       if (nFlags & FIELDFLAG_EDIT)
+       {               
+               cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
+       }
+
+       if (!m_pFontMap)
+       {
+               m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler());
+               m_pFontMap->Initial();
+       }
+
+       cp.pFontMap = m_pFontMap;
+       cp.pFocusHandler = this;
+
+       return cp;
+}
+
+CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView)
+{
+       CPWL_ComboBox * pWnd = new CPWL_ComboBox();
+       pWnd->AttachFFLData(this);
+       pWnd->Create(cp);
+
+       CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller();
+       pWnd->SetFillerNotify(pFormFiller);
+
+       int32_t nCurSel = m_pWidget->GetSelectedIndex(0);
+       CFX_WideString swText;
+       if (nCurSel < 0)
+               swText = m_pWidget->GetValue();
+       else
+               swText = m_pWidget->GetOptionLabel(nCurSel);
+
+       for (int32_t i=0,sz=m_pWidget->CountOptions(); i<sz; i++)
+       {
+               pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str());
+       }
+
+       pWnd->SetSelect(nCurSel);
+       pWnd->SetText(swText.c_str());
+       return pWnd;
+}
+
+
+FX_BOOL        CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
+{
+       return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
+}
+
+FX_BOOL        CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView)
+{
+       if (CPWL_ComboBox * pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+       {
+               int32_t nCurSel = pWnd->GetSelect();
+
+               ASSERT(m_pWidget != NULL);
+
+               if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
+               {
+                       if (nCurSel >= 0)
+                       {
+                               return nCurSel != m_pWidget->GetSelectedIndex(0);
+                       }
+                       else
+                       {
+                               return pWnd->GetText() != m_pWidget->GetValue();
+                       }
+               }
+               else
+               {
+                       return nCurSel != m_pWidget->GetSelectedIndex(0);
+               }
+       }
+       
+       return FALSE;
+}
+
+void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView)
+{
+       ASSERT(m_pWidget != NULL);
+
+       if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+       {
+               CFX_WideString swText = pWnd->GetText();
+               int32_t nCurSel = pWnd->GetSelect();
+
+               //mantis:0004157
+               FX_BOOL bSetValue = TRUE;
+
+               if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
+               {
+                       if (nCurSel >= 0)
+                       {
+                               if (swText != m_pWidget->GetOptionLabel(nCurSel))
+                                       bSetValue = TRUE;
+                               else
+                                       bSetValue = FALSE;
+                       }
+                       else
+                               bSetValue = TRUE;
+               }
+               else
+                       bSetValue = FALSE;
+
+               CFX_WideString sOldValue;
+               
+
+               if (bSetValue)
+               {
+                       sOldValue = m_pWidget->GetValue();
+                       m_pWidget->SetValue(swText, FALSE);
+               }
+               else
+               {
+                       m_pWidget->GetSelectedIndex(0);
+                       m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE);
+               }
+
+               m_pWidget->ResetFieldAppearance(TRUE);
+               m_pWidget->UpdateField();
+               SetChangeMark();
+
+               m_pWidget->GetPDFPage();
+               
+
+       }
+}
+
+ void CFFL_ComboBox::GetActionData( CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, PDFSDK_FieldAction& fa)
+{
+       switch (type)
+       {
+       case CPDF_AAction::KeyStroke:
+               if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+               {
+                       if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+                       {
+                               fa.bFieldFull = pEdit->IsTextFull();    
+                               int nSelStart = 0;
+                               int nSelEnd = 0;
+                               pEdit->GetSel(nSelStart, nSelEnd);
+                               fa.nSelEnd = nSelEnd;
+                               fa.nSelStart = nSelStart;
+                               fa.sValue = pEdit->GetText();
+                               fa.sChangeEx = GetSelectExportText();
+
+                               if (fa.bFieldFull)
+                               {
+                                       fa.sChange = L"";
+                                       fa.sChangeEx = L"";
+                               }
+                       }
+               }
+               break;
+       case CPDF_AAction::Validate:
+               if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+               {
+                       if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+                       {
+                               fa.sValue = pEdit->GetText();
+                       }
+               }
+               break;
+       case CPDF_AAction::LoseFocus:
+       case CPDF_AAction::GetFocus:
+               ASSERT(m_pWidget != NULL);
+               fa.sValue = m_pWidget->GetValue();
+               break;
+       default:
+               break;
+       }
+}
+
+
+
+void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, 
+                                                                       const PDFSDK_FieldAction& fa)
+{
+       switch (type)
+       {
+       case CPDF_AAction::KeyStroke:
+               if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+               {
+                       if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+                       {
+                               pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
+                               pEdit->ReplaceSel(fa.sChange.c_str());
+                       }
+               }
+               break;
+       default:
+               break;
+       }
+}
+
+FX_BOOL        CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld, 
+                                                                       const PDFSDK_FieldAction& faNew)
+{
+       switch (type)
+       {
+       case CPDF_AAction::KeyStroke:
+               return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || faOld.nSelStart != faNew.nSelStart ||
+                       faOld.sChange != faNew.sChange;
+       default:
+               break;
+       }
+
+       return FALSE;
+}
+
+void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView)
+{
+       ASSERT(pPageView != NULL);
+
+       if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+       {
+               m_State.nIndex = pComboBox->GetSelect();
+
+               if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+               {
+                       pEdit->GetSel(m_State.nStart, m_State.nEnd);
+                       m_State.sValue = pEdit->GetText();
+               }
+       }
+}
+
+void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView)
+{
+       ASSERT(pPageView != NULL);
+
+       if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE))
+       {
+               if (m_State.nIndex >= 0)
+                       pComboBox->SetSelect(m_State.nIndex);
+               else
+               {
+                       if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+                       {
+                               pEdit->SetText(m_State.sValue.c_str());
+                               pEdit->SetSel(m_State.nStart, m_State.nEnd);
+                       }
+               }
+       }
+}
+
+CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue)
+{
+       if (bRestoreValue)
+               SaveState(pPageView);
+       
+       DestroyPDFWindow(pPageView);
+       
+       CPWL_Wnd* pRet = NULL;
+       
+       if (bRestoreValue)
+       {
+               RestoreState(pPageView);
+               pRet = GetPDFWindow(pPageView, FALSE);
+       }
+       else
+               pRet = GetPDFWindow(pPageView, TRUE);
+       
+       m_pWidget->UpdateField();
+       
+       return pRet;
+}
+
+void CFFL_ComboBox::OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag)
+{
+       ASSERT(m_pWidget != NULL);
+       
+       int nFlags = m_pWidget->GetFieldFlags();
+       
+       if (nFlags & FIELDFLAG_COMMITONSELCHANGE)
+       {
+               if (m_bValid)
+               {
+                       CPDFSDK_PageView* pPageView = GetCurPageView();
+                       ASSERT(pPageView != NULL);
+
+                       if (CommitData(pPageView, nFlag))
+                       {
+                               DestroyPDFWindow(pPageView);
+                               m_bValid = FALSE;
+                       }
+               }
+       }
+}
+
+void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd)
+{
+       ASSERT(m_pApp != NULL);
+
+       ASSERT(pWnd != NULL);
+
+       if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT)
+       {
+               CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
+               pEdit->SetCharSet(134);
+               pEdit->SetCodePage(936);
+
+               pEdit->SetReadyToInput();
+               CFX_WideString wsText = pEdit->GetText();
+               int nCharacters = wsText.GetLength();
+               CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();
+               unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str();
+               m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE);
+
+               pEdit->SetEditNotify(this);
+       }
+}
+
+void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd)
+{
+       ASSERT(m_pApp != NULL);
+}
+
+FX_BOOL        CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument)
+{
+       ASSERT(pDocument != NULL);
+
+       return FALSE;
+}
+
+FX_BOOL CFFL_ComboBox::CanCut(CPDFSDK_Document* pDocument)
+{
+       ASSERT(pDocument != NULL);
+
+       return FALSE;
+}
+
+FX_BOOL        CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument)
+{
+       ASSERT(pDocument != NULL);
+
+       return FALSE;
+}
+
+void CFFL_ComboBox::DoCopy(CPDFSDK_Document* pDocument)
+{
+       ASSERT(pDocument != NULL);
+}
+
+void CFFL_ComboBox::DoCut(CPDFSDK_Document* pDocument)
+{
+       ASSERT(pDocument != NULL);
+}
+
+void CFFL_ComboBox::DoPaste(CPDFSDK_Document* pDocument)
+{
+       ASSERT(pDocument != NULL);
+}
+
+void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit)
+{
+       ASSERT(pEdit != NULL);
+}
+
+CFX_WideString CFFL_ComboBox::GetSelectExportText()
+{
+       CFX_WideString swRet;
+       
+       int nExport = -1;
+       CPDFSDK_PageView *pPageView = GetCurPageView();
+       if (CPWL_ComboBox * pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+       {
+               nExport = pComboBox->GetSelect();
+       }
+       
+       if (nExport >= 0)
+       {
+               if (CPDF_FormField * pFormField = m_pWidget->GetFormField())
+               {
+                       swRet = pFormField->GetOptionValue(nExport);
+                       if (swRet.IsEmpty())
+                               swRet = pFormField->GetOptionLabel(nExport);
+               }
+       }
+       
+       return swRet;
+}