| 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 "../../include/formfiller/FormFiller.h" | 7 #include "../../include/formfiller/FormFiller.h" |
| 8 #include "../../include/formfiller/FFL_FormFiller.h" | 8 #include "../../include/formfiller/FFL_FormFiller.h" |
| 9 #include "../../include/formfiller/FFL_IFormFiller.h" | 9 #include "../../include/formfiller/FFL_IFormFiller.h" |
| 10 #include "../../include/formfiller/FFL_CBA_Fontmap.h" | 10 #include "../../include/formfiller/FFL_CBA_Fontmap.h" |
| 11 #include "../../include/formfiller/FFL_ComboBox.h" | 11 #include "../../include/formfiller/FFL_ComboBox.h" |
| 12 | 12 |
| 13 | 13 /* ------------------------------- CFFL_ComboBox ------------------------------- |
| 14 /* ------------------------------- CFFL_ComboBox -------------------------------
*/ | 14 */ |
| 15 | 15 |
| 16 CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) : | 16 CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) |
| 17 CFFL_FormFiller(pApp, pAnnot), m_pFontMap( NULL ) | 17 : CFFL_FormFiller(pApp, pAnnot), m_pFontMap(NULL) { |
| 18 { | 18 m_State.nIndex = 0; |
| 19 m_State.nIndex = 0; | 19 m_State.nStart = 0; |
| 20 m_State.nStart = 0; | 20 m_State.nEnd = 0; |
| 21 m_State.nEnd = 0; | 21 } |
| 22 } | 22 |
| 23 | 23 CFFL_ComboBox::~CFFL_ComboBox() { |
| 24 CFFL_ComboBox::~CFFL_ComboBox() | 24 delete m_pFontMap; |
| 25 { | 25 } |
| 26 delete m_pFontMap; | 26 |
| 27 } | 27 PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() { |
| 28 | 28 PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam(); |
| 29 PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() | 29 |
| 30 { | 30 ASSERT(m_pWidget != NULL); |
| 31 PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam(); | 31 |
| 32 | 32 int nFlags = m_pWidget->GetFieldFlags(); |
| 33 ASSERT(m_pWidget != NULL); | 33 |
| 34 | 34 if (nFlags & FIELDFLAG_EDIT) { |
| 35 int nFlags = m_pWidget->GetFieldFlags(); | 35 cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT; |
| 36 | 36 } |
| 37 if (nFlags & FIELDFLAG_EDIT) | 37 |
| 38 { | 38 if (!m_pFontMap) { |
| 39 cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT; | 39 m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler()); |
| 40 } | 40 m_pFontMap->Initial(); |
| 41 | 41 } |
| 42 if (!m_pFontMap) | 42 |
| 43 { | 43 cp.pFontMap = m_pFontMap; |
| 44 m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler()); | 44 cp.pFocusHandler = this; |
| 45 m_pFontMap->Initial(); | 45 |
| 46 } | 46 return cp; |
| 47 | 47 } |
| 48 cp.pFontMap = m_pFontMap; | 48 |
| 49 cp.pFocusHandler = this; | 49 CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp, |
| 50 | 50 CPDFSDK_PageView* pPageView) { |
| 51 return cp; | 51 CPWL_ComboBox* pWnd = new CPWL_ComboBox(); |
| 52 } | 52 pWnd->AttachFFLData(this); |
| 53 | 53 pWnd->Create(cp); |
| 54 CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageVie
w* pPageView) | 54 |
| 55 { | 55 CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller(); |
| 56 CPWL_ComboBox * pWnd = new CPWL_ComboBox(); | 56 pWnd->SetFillerNotify(pFormFiller); |
| 57 pWnd->AttachFFLData(this); | 57 |
| 58 pWnd->Create(cp); | 58 int32_t nCurSel = m_pWidget->GetSelectedIndex(0); |
| 59 | 59 CFX_WideString swText; |
| 60 CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller(); | 60 if (nCurSel < 0) |
| 61 pWnd->SetFillerNotify(pFormFiller); | 61 swText = m_pWidget->GetValue(); |
| 62 | 62 else |
| 63 int32_t nCurSel = m_pWidget->GetSelectedIndex(0); | 63 swText = m_pWidget->GetOptionLabel(nCurSel); |
| 64 CFX_WideString swText; | 64 |
| 65 if (nCurSel < 0) | 65 for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) { |
| 66 swText = m_pWidget->GetValue(); | 66 pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str()); |
| 67 else | 67 } |
| 68 swText = m_pWidget->GetOptionLabel(nCurSel); | 68 |
| 69 | 69 pWnd->SetSelect(nCurSel); |
| 70 for (int32_t i=0,sz=m_pWidget->CountOptions(); i<sz; i++) | 70 pWnd->SetText(swText.c_str()); |
| 71 { | 71 return pWnd; |
| 72 pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str()); | 72 } |
| 73 } | 73 |
| 74 | 74 FX_BOOL CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, |
| 75 pWnd->SetSelect(nCurSel); | 75 FX_UINT nChar, |
| 76 pWnd->SetText(swText.c_str()); | 76 FX_UINT nFlags) { |
| 77 return pWnd; | 77 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); |
| 78 } | 78 } |
| 79 | 79 |
| 80 | 80 FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView) { |
| 81 FX_BOOL CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFla
gs) | 81 CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE); |
| 82 { | 82 if (!pWnd) |
| 83 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); | 83 return FALSE; |
| 84 } | 84 |
| 85 | 85 int32_t nCurSel = pWnd->GetSelect(); |
| 86 FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView) | 86 if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)) |
| 87 { | 87 return nCurSel != m_pWidget->GetSelectedIndex(0); |
| 88 CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE); | 88 |
| 89 if (!pWnd) | 89 if (nCurSel >= 0) |
| 90 return FALSE; | 90 return nCurSel != m_pWidget->GetSelectedIndex(0); |
| 91 | 91 |
| 92 return pWnd->GetText() != m_pWidget->GetValue(); |
| 93 } |
| 94 |
| 95 void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView) { |
| 96 ASSERT(m_pWidget != NULL); |
| 97 |
| 98 if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { |
| 99 CFX_WideString swText = pWnd->GetText(); |
| 92 int32_t nCurSel = pWnd->GetSelect(); | 100 int32_t nCurSel = pWnd->GetSelect(); |
| 93 if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)) | 101 |
| 94 return nCurSel != m_pWidget->GetSelectedIndex(0); | 102 // mantis:0004157 |
| 95 | 103 FX_BOOL bSetValue = TRUE; |
| 96 if (nCurSel >= 0) | 104 |
| 97 return nCurSel != m_pWidget->GetSelectedIndex(0); | 105 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) { |
| 98 | 106 if (nCurSel >= 0) { |
| 99 return pWnd->GetText() != m_pWidget->GetValue(); | 107 if (swText != m_pWidget->GetOptionLabel(nCurSel)) |
| 100 } | 108 bSetValue = TRUE; |
| 101 | 109 else |
| 102 void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView) | 110 bSetValue = FALSE; |
| 103 { | 111 } else |
| 104 ASSERT(m_pWidget != NULL); | 112 bSetValue = TRUE; |
| 105 | 113 } else |
| 106 if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) | 114 bSetValue = FALSE; |
| 107 { | 115 |
| 108 CFX_WideString swText = pWnd->GetText(); | 116 CFX_WideString sOldValue; |
| 109 int32_t nCurSel = pWnd->GetSelect(); | 117 |
| 110 | 118 if (bSetValue) { |
| 111 //mantis:0004157 | 119 sOldValue = m_pWidget->GetValue(); |
| 112 FX_BOOL bSetValue = TRUE; | 120 m_pWidget->SetValue(swText, FALSE); |
| 113 | 121 } else { |
| 114 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) | 122 m_pWidget->GetSelectedIndex(0); |
| 115 { | 123 m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE); |
| 116 if (nCurSel >= 0) | 124 } |
| 117 { | 125 |
| 118 if (swText != m_pWidget->GetOptionLabel(nCurSel)) | 126 m_pWidget->ResetFieldAppearance(TRUE); |
| 119 bSetValue = TRUE; | 127 m_pWidget->UpdateField(); |
| 120 else | 128 SetChangeMark(); |
| 121 bSetValue = FALSE; | 129 |
| 122 } | 130 m_pWidget->GetPDFPage(); |
| 123 else | 131 } |
| 124 bSetValue = TRUE; | 132 } |
| 133 |
| 134 void CFFL_ComboBox::GetActionData(CPDFSDK_PageView* pPageView, |
| 135 CPDF_AAction::AActionType type, |
| 136 PDFSDK_FieldAction& fa) { |
| 137 switch (type) { |
| 138 case CPDF_AAction::KeyStroke: |
| 139 if (CPWL_ComboBox* pComboBox = |
| 140 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { |
| 141 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { |
| 142 fa.bFieldFull = pEdit->IsTextFull(); |
| 143 int nSelStart = 0; |
| 144 int nSelEnd = 0; |
| 145 pEdit->GetSel(nSelStart, nSelEnd); |
| 146 fa.nSelEnd = nSelEnd; |
| 147 fa.nSelStart = nSelStart; |
| 148 fa.sValue = pEdit->GetText(); |
| 149 fa.sChangeEx = GetSelectExportText(); |
| 150 |
| 151 if (fa.bFieldFull) { |
| 152 fa.sChange = L""; |
| 153 fa.sChangeEx = L""; |
| 154 } |
| 125 } | 155 } |
| 126 else | 156 } |
| 127 bSetValue = FALSE; | 157 break; |
| 128 | 158 case CPDF_AAction::Validate: |
| 129 CFX_WideString sOldValue; | 159 if (CPWL_ComboBox* pComboBox = |
| 130 | 160 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { |
| 131 | 161 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { |
| 132 if (bSetValue) | 162 fa.sValue = pEdit->GetText(); |
| 133 { | |
| 134 sOldValue = m_pWidget->GetValue(); | |
| 135 m_pWidget->SetValue(swText, FALSE); | |
| 136 } | 163 } |
| 137 else | 164 } |
| 138 { | 165 break; |
| 139 m_pWidget->GetSelectedIndex(0); | |
| 140 m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE); | |
| 141 } | |
| 142 | |
| 143 m_pWidget->ResetFieldAppearance(TRUE); | |
| 144 m_pWidget->UpdateField(); | |
| 145 SetChangeMark(); | |
| 146 | |
| 147 m_pWidget->GetPDFPage(); | |
| 148 | |
| 149 | |
| 150 } | |
| 151 } | |
| 152 | |
| 153 void CFFL_ComboBox::GetActionData( CPDFSDK_PageView* pPageView, CPDF_AAction::A
ActionType type, PDFSDK_FieldAction& fa) | |
| 154 { | |
| 155 switch (type) | |
| 156 { | |
| 157 case CPDF_AAction::KeyStroke: | |
| 158 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, F
ALSE)) | |
| 159 { | |
| 160 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) | |
| 161 { | |
| 162 fa.bFieldFull = pEdit->IsTextFull(); | |
| 163 int nSelStart = 0; | |
| 164 int nSelEnd = 0; | |
| 165 pEdit->GetSel(nSelStart, nSelEnd); | |
| 166 fa.nSelEnd = nSelEnd; | |
| 167 fa.nSelStart = nSelStart; | |
| 168 fa.sValue = pEdit->GetText(); | |
| 169 fa.sChangeEx = GetSelectExportText(); | |
| 170 | |
| 171 if (fa.bFieldFull) | |
| 172 { | |
| 173 fa.sChange = L""; | |
| 174 fa.sChangeEx = L""; | |
| 175 } | |
| 176 } | |
| 177 } | |
| 178 break; | |
| 179 case CPDF_AAction::Validate: | |
| 180 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, F
ALSE)) | |
| 181 { | |
| 182 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) | |
| 183 { | |
| 184 fa.sValue = pEdit->GetText(); | |
| 185 } | |
| 186 } | |
| 187 break; | |
| 188 case CPDF_AAction::LoseFocus: | 166 case CPDF_AAction::LoseFocus: |
| 189 case CPDF_AAction::GetFocus: | 167 case CPDF_AAction::GetFocus: |
| 190 ASSERT(m_pWidget != NULL); | 168 ASSERT(m_pWidget != NULL); |
| 191 fa.sValue = m_pWidget->GetValue(); | 169 fa.sValue = m_pWidget->GetValue(); |
| 192 break; | 170 break; |
| 193 default: | 171 default: |
| 194 break; | 172 break; |
| 195 } | 173 } |
| 196 } | 174 } |
| 197 | 175 |
| 198 | 176 void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, |
| 199 | 177 CPDF_AAction::AActionType type, |
| 200 void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AAc
tionType type, | 178 const PDFSDK_FieldAction& fa) { |
| 201 const PDFSDK_FieldAction& fa) | 179 switch (type) { |
| 202 { | |
| 203 switch (type) | |
| 204 { | |
| 205 case CPDF_AAction::KeyStroke: | 180 case CPDF_AAction::KeyStroke: |
| 206 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, F
ALSE)) | 181 if (CPWL_ComboBox* pComboBox = |
| 207 { | 182 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { |
| 208 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) | 183 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { |
| 209 { | 184 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); |
| 210 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); | 185 pEdit->ReplaceSel(fa.sChange.c_str()); |
| 211 pEdit->ReplaceSel(fa.sChange.c_str()); | |
| 212 } | |
| 213 } | 186 } |
| 214 break; | 187 } |
| 188 break; |
| 215 default: | 189 default: |
| 216 break; | 190 break; |
| 217 } | 191 } |
| 218 } | 192 } |
| 219 | 193 |
| 220 FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, const
PDFSDK_FieldAction& faOld, | 194 FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, |
| 221 const PDFSDK_FieldAction& faNew) | 195 const PDFSDK_FieldAction& faOld, |
| 222 { | 196 const PDFSDK_FieldAction& faNew) { |
| 223 switch (type) | 197 switch (type) { |
| 224 { | |
| 225 case CPDF_AAction::KeyStroke: | 198 case CPDF_AAction::KeyStroke: |
| 226 return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || faOld.nS
elStart != faNew.nSelStart || | 199 return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || |
| 227 faOld.sChange != faNew.sChange; | 200 faOld.nSelStart != faNew.nSelStart || |
| 201 faOld.sChange != faNew.sChange; |
| 228 default: | 202 default: |
| 229 break; | 203 break; |
| 230 } | 204 } |
| 231 | 205 |
| 232 return FALSE; | 206 return FALSE; |
| 233 } | 207 } |
| 234 | 208 |
| 235 void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView) | 209 void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView) { |
| 236 { | 210 ASSERT(pPageView != NULL); |
| 237 ASSERT(pPageView != NULL); | 211 |
| 238 | 212 if (CPWL_ComboBox* pComboBox = |
| 239 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE
)) | 213 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { |
| 240 { | 214 m_State.nIndex = pComboBox->GetSelect(); |
| 241 m_State.nIndex = pComboBox->GetSelect(); | 215 |
| 242 | 216 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { |
| 243 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) | 217 pEdit->GetSel(m_State.nStart, m_State.nEnd); |
| 244 { | 218 m_State.sValue = pEdit->GetText(); |
| 245 pEdit->GetSel(m_State.nStart, m_State.nEnd); | 219 } |
| 246 m_State.sValue = pEdit->GetText(); | 220 } |
| 247 } | 221 } |
| 248 } | 222 |
| 249 } | 223 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) { |
| 250 | 224 ASSERT(pPageView != NULL); |
| 251 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) | 225 |
| 252 { | 226 if (CPWL_ComboBox* pComboBox = |
| 253 ASSERT(pPageView != NULL); | 227 (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE)) { |
| 254 | 228 if (m_State.nIndex >= 0) |
| 255 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE)
) | 229 pComboBox->SetSelect(m_State.nIndex); |
| 256 { | 230 else { |
| 257 if (m_State.nIndex >= 0) | 231 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) { |
| 258 pComboBox->SetSelect(m_State.nIndex); | 232 pEdit->SetText(m_State.sValue.c_str()); |
| 259 else | 233 pEdit->SetSel(m_State.nStart, m_State.nEnd); |
| 260 { | 234 } |
| 261 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) | 235 } |
| 262 { | 236 } |
| 263 pEdit->SetText(m_State.sValue.c_str()); | 237 } |
| 264 pEdit->SetSel(m_State.nStart, m_State.nEnd); | 238 |
| 265 } | 239 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, |
| 266 } | 240 FX_BOOL bRestoreValue) { |
| 267 } | 241 if (bRestoreValue) |
| 268 } | 242 SaveState(pPageView); |
| 269 | 243 |
| 270 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRe
storeValue) | 244 DestroyPDFWindow(pPageView); |
| 271 { | 245 |
| 272 if (bRestoreValue) | 246 CPWL_Wnd* pRet = NULL; |
| 273 SaveState(pPageView); | 247 |
| 274 | 248 if (bRestoreValue) { |
| 275 DestroyPDFWindow(pPageView); | 249 RestoreState(pPageView); |
| 276 | 250 pRet = GetPDFWindow(pPageView, FALSE); |
| 277 CPWL_Wnd* pRet = NULL; | 251 } else |
| 278 | 252 pRet = GetPDFWindow(pPageView, TRUE); |
| 279 if (bRestoreValue) | 253 |
| 280 { | 254 m_pWidget->UpdateField(); |
| 281 RestoreState(pPageView); | 255 |
| 282 pRet = GetPDFWindow(pPageView, FALSE); | 256 return pRet; |
| 283 } | 257 } |
| 284 else | 258 |
| 285 pRet = GetPDFWindow(pPageView, TRUE); | 259 void CFFL_ComboBox::OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag) { |
| 286 | 260 ASSERT(m_pWidget != NULL); |
| 287 m_pWidget->UpdateField(); | 261 |
| 288 | 262 int nFlags = m_pWidget->GetFieldFlags(); |
| 289 return pRet; | 263 |
| 290 } | 264 if (nFlags & FIELDFLAG_COMMITONSELCHANGE) { |
| 291 | 265 if (m_bValid) { |
| 292 void CFFL_ComboBox::OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag) | 266 CPDFSDK_PageView* pPageView = GetCurPageView(); |
| 293 { | 267 ASSERT(pPageView != NULL); |
| 294 ASSERT(m_pWidget != NULL); | 268 |
| 295 | 269 if (CommitData(pPageView, nFlag)) { |
| 296 int nFlags = m_pWidget->GetFieldFlags(); | 270 DestroyPDFWindow(pPageView); |
| 297 | 271 m_bValid = FALSE; |
| 298 if (nFlags & FIELDFLAG_COMMITONSELCHANGE) | 272 } |
| 299 { | 273 } |
| 300 if (m_bValid) | 274 } |
| 301 { | 275 } |
| 302 CPDFSDK_PageView* pPageView = GetCurPageView(); | 276 |
| 303 ASSERT(pPageView != NULL); | 277 void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) { |
| 304 | 278 ASSERT(m_pApp != NULL); |
| 305 if (CommitData(pPageView, nFlag)) | 279 |
| 306 { | 280 ASSERT(pWnd != NULL); |
| 307 DestroyPDFWindow(pPageView); | 281 |
| 308 m_bValid = FALSE; | 282 if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) { |
| 309 } | 283 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; |
| 310 } | 284 pEdit->SetCharSet(134); |
| 311 } | 285 pEdit->SetCodePage(936); |
| 312 } | 286 |
| 313 | 287 pEdit->SetReadyToInput(); |
| 314 void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) | 288 CFX_WideString wsText = pEdit->GetText(); |
| 315 { | 289 int nCharacters = wsText.GetLength(); |
| 316 ASSERT(m_pApp != NULL); | 290 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); |
| 317 | 291 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); |
| 318 ASSERT(pWnd != NULL); | 292 m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, |
| 319 | 293 nCharacters, TRUE); |
| 320 if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) | 294 |
| 321 { | 295 pEdit->SetEditNotify(this); |
| 322 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; | 296 } |
| 323 pEdit->SetCharSet(134); | 297 } |
| 324 pEdit->SetCodePage(936); | 298 |
| 325 | 299 void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd) { |
| 326 pEdit->SetReadyToInput(); | 300 ASSERT(m_pApp != NULL); |
| 327 CFX_WideString wsText = pEdit->GetText(); | 301 } |
| 328 int nCharacters = wsText.GetLength(); | 302 |
| 329 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); | 303 FX_BOOL CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument) { |
| 330 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); | 304 ASSERT(pDocument != NULL); |
| 331 m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCh
aracters, TRUE); | 305 |
| 332 | 306 return FALSE; |
| 333 pEdit->SetEditNotify(this); | 307 } |
| 334 } | 308 |
| 335 } | 309 FX_BOOL CFFL_ComboBox::CanCut(CPDFSDK_Document* pDocument) { |
| 336 | 310 ASSERT(pDocument != NULL); |
| 337 void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd) | 311 |
| 338 { | 312 return FALSE; |
| 339 ASSERT(m_pApp != NULL); | 313 } |
| 340 } | 314 |
| 341 | 315 FX_BOOL CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument) { |
| 342 FX_BOOL CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument) | 316 ASSERT(pDocument != NULL); |
| 343 { | 317 |
| 344 ASSERT(pDocument != NULL); | 318 return FALSE; |
| 345 | 319 } |
| 346 return FALSE; | 320 |
| 347 } | 321 void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit) { |
| 348 | 322 ASSERT(pEdit != NULL); |
| 349 FX_BOOL CFFL_ComboBox::CanCut(CPDFSDK_Document* pDocument) | 323 } |
| 350 { | 324 |
| 351 ASSERT(pDocument != NULL); | 325 CFX_WideString CFFL_ComboBox::GetSelectExportText() { |
| 352 | 326 CFX_WideString swRet; |
| 353 return FALSE; | 327 |
| 354 } | 328 int nExport = -1; |
| 355 | 329 CPDFSDK_PageView* pPageView = GetCurPageView(); |
| 356 FX_BOOL CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument) | 330 if (CPWL_ComboBox* pComboBox = |
| 357 { | 331 (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) { |
| 358 ASSERT(pDocument != NULL); | 332 nExport = pComboBox->GetSelect(); |
| 359 | 333 } |
| 360 return FALSE; | 334 |
| 361 } | 335 if (nExport >= 0) { |
| 362 | 336 if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) { |
| 363 void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit) | 337 swRet = pFormField->GetOptionValue(nExport); |
| 364 { | 338 if (swRet.IsEmpty()) |
| 365 ASSERT(pEdit != NULL); | 339 swRet = pFormField->GetOptionLabel(nExport); |
| 366 } | 340 } |
| 367 | 341 } |
| 368 CFX_WideString CFFL_ComboBox::GetSelectExportText() | 342 |
| 369 { | 343 return swRet; |
| 370 CFX_WideString swRet; | 344 } |
| 371 | |
| 372 int nExport = -1; | |
| 373 CPDFSDK_PageView *pPageView = GetCurPageView(); | |
| 374 if (CPWL_ComboBox * pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALS
E)) | |
| 375 { | |
| 376 nExport = pComboBox->GetSelect(); | |
| 377 } | |
| 378 | |
| 379 if (nExport >= 0) | |
| 380 { | |
| 381 if (CPDF_FormField * pFormField = m_pWidget->GetFormField()) | |
| 382 { | |
| 383 swRet = pFormField->GetOptionValue(nExport); | |
| 384 if (swRet.IsEmpty()) | |
| 385 swRet = pFormField->GetOptionLabel(nExport); | |
| 386 } | |
| 387 } | |
| 388 | |
| 389 return swRet; | |
| 390 } | |
| OLD | NEW |