Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

904 lines
22 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // File: candlst.cpp
  4. //
  5. // Contents: candidate list classes
  6. //
  7. //----------------------------------------------------------------------------
  8. #include "private.h"
  9. #include "candlstx.h"
  10. #include "hanja.h"
  11. //
  12. // CCandidateStringEx
  13. //
  14. /* C C A N D I D A T E S T R I N G E X */
  15. /*------------------------------------------------------------------------------
  16. ------------------------------------------------------------------------------*/
  17. CCandidateStringEx::CCandidateStringEx(int nIndex, LPCWSTR psz, LANGID langid, void *pv, IUnknown *punk)
  18. {
  19. size_t cch = 0;
  20. StringCchLengthW((LPWSTR)psz, CIC_KOR_CANDSTR_MAX, &cch);
  21. m_psz = new WCHAR[cch+1];
  22. if (m_psz)
  23. StringCchCopyW(m_psz, cch+1, psz);
  24. m_langid = langid;
  25. m_pv = pv;
  26. m_punk = punk;
  27. if (m_punk)
  28. m_punk->AddRef();
  29. m_pszRead = NULL;
  30. m_pszInlineComment = NULL;
  31. #if 0
  32. m_pszPopupComment = NULL;
  33. m_dwPopupCommentGroupID = 0;
  34. m_pszPrefix = NULL;
  35. m_pszSuffix = NULL;
  36. #endif
  37. m_nIndex = nIndex;
  38. m_cRef = 1;
  39. }
  40. /* ~ C C A N D I D A T E S T R I N G E X */
  41. /*------------------------------------------------------------------------------
  42. ------------------------------------------------------------------------------*/
  43. CCandidateStringEx::~CCandidateStringEx()
  44. {
  45. if (m_punk)
  46. m_punk->Release();
  47. delete m_psz;
  48. delete m_pszRead;
  49. if (m_pszInlineComment != NULL) {
  50. delete m_pszInlineComment;
  51. }
  52. #if 0
  53. if (m_pszPopupComment != NULL) {
  54. delete m_pszPopupComment;
  55. }
  56. if (m_pszPrefix != NULL) {
  57. delete m_pszPrefix;
  58. }
  59. if (m_pszSuffix != NULL) {
  60. delete m_pszSuffix;
  61. }
  62. #endif
  63. }
  64. /* Q U E R Y I N T E R F A C E */
  65. /*------------------------------------------------------------------------------
  66. ------------------------------------------------------------------------------*/
  67. STDAPI CCandidateStringEx::QueryInterface(REFIID riid, void **ppvObj)
  68. {
  69. if (ppvObj == NULL)
  70. return E_POINTER;
  71. *ppvObj = NULL;
  72. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfCandidateString))
  73. *ppvObj = SAFECAST(this, ITfCandidateString*);
  74. else
  75. if (IsEqualGUID(riid, IID_ITfCandidateStringInlineComment))
  76. *ppvObj = SAFECAST(this, ITfCandidateStringInlineComment*);
  77. else
  78. if (IsEqualGUID( riid, IID_ITfCandidateStringColor))
  79. *ppvObj = SAFECAST(this, ITfCandidateStringColor*);
  80. #if 0
  81. else
  82. if (IsEqualGUID( riid, IID_ITfCandidateStringPopupComment))
  83. *ppvObj = SAFECAST(this, ITfCandidateStringPopupComment*);
  84. else
  85. if (IsEqualGUID( riid, IID_ITfCandidateStringFixture))
  86. *ppvObj = SAFECAST( this, ITfCandidateStringFixture*);
  87. else
  88. if (IsEqualGUID( riid, IID_ITfCandidateStringIcon))
  89. *ppvObj = SAFECAST( this, ITfCandidateStringIcon*);
  90. #endif
  91. if (*ppvObj == NULL)
  92. return E_NOINTERFACE;
  93. AddRef();
  94. return S_OK;
  95. }
  96. /* A D D R E F */
  97. /*------------------------------------------------------------------------------
  98. ------------------------------------------------------------------------------*/
  99. STDAPI_(ULONG) CCandidateStringEx::AddRef()
  100. {
  101. m_cRef++;
  102. return m_cRef;
  103. }
  104. /* R E L E A S E */
  105. /*------------------------------------------------------------------------------
  106. ------------------------------------------------------------------------------*/
  107. STDAPI_(ULONG) CCandidateStringEx::Release()
  108. {
  109. m_cRef--;
  110. if (0 < m_cRef) {
  111. return m_cRef;
  112. }
  113. delete this;
  114. return 0;
  115. }
  116. /* G E T S T R I N G */
  117. /*------------------------------------------------------------------------------
  118. ------------------------------------------------------------------------------*/
  119. HRESULT CCandidateStringEx::GetString(BSTR *pbstr)
  120. {
  121. *pbstr = SysAllocString(m_psz);
  122. return S_OK;
  123. }
  124. /* G E T I N D E X */
  125. /*------------------------------------------------------------------------------
  126. ------------------------------------------------------------------------------*/
  127. HRESULT CCandidateStringEx::GetIndex(ULONG *pnIndex)
  128. {
  129. *pnIndex = m_nIndex;
  130. return S_OK;
  131. }
  132. /* G E T I N L I N E C O M M E N T S T R I N G */
  133. /*------------------------------------------------------------------------------
  134. ------------------------------------------------------------------------------*/
  135. HRESULT CCandidateStringEx::GetInlineCommentString(BSTR *pbstr)
  136. {
  137. if (m_pszInlineComment == NULL) {
  138. return S_FALSE;
  139. }
  140. *pbstr = SysAllocString(m_pszInlineComment);
  141. return S_OK;
  142. }
  143. #if 0
  144. /* G E T P O P U P C O M M E N T */
  145. /*------------------------------------------------------------------------------
  146. ------------------------------------------------------------------------------*/
  147. HRESULT CCandidateStringEx::GetPopupCommentString(BSTR *pbstr)
  148. {
  149. if (m_pszPopupComment == NULL) {
  150. return S_FALSE;
  151. }
  152. *pbstr = SysAllocString(m_pszPopupComment);
  153. return S_OK;
  154. }
  155. /* G E T P O P U P C O M M E N T G R O U P I D */
  156. /*------------------------------------------------------------------------------
  157. ------------------------------------------------------------------------------*/
  158. HRESULT CCandidateStringEx::GetPopupCommentGroupID(DWORD *pdwGroupID)
  159. {
  160. *pdwGroupID = m_dwPopupCommentGroupID;
  161. return S_OK;
  162. }
  163. #endif
  164. /* G E T C O L O R */
  165. /*------------------------------------------------------------------------------
  166. ------------------------------------------------------------------------------*/
  167. HRESULT CCandidateStringEx::GetColor(CANDUICOLOR *pcol)
  168. {
  169. // TODO: Set diferent color according to the Hanja category
  170. if (m_bHanjaCat == HANJA_K0)
  171. {
  172. pcol->type = CANDUICOL_SYSTEM;
  173. pcol->cr = COLOR_MENUTEXT;
  174. }
  175. else
  176. {
  177. pcol->type = CANDUICOL_COLORREF;
  178. // If button face is black
  179. if (GetSysColor(COLOR_3DFACE) == RGB(0,0,0))
  180. pcol->cr = RGB(0, 128, 255);
  181. else
  182. pcol->cr = RGB(0, 0, 255);
  183. }
  184. return S_OK;
  185. }
  186. #if 0
  187. /* G E T P R E F I X S T R I N G */
  188. /*------------------------------------------------------------------------------
  189. ------------------------------------------------------------------------------*/
  190. HRESULT CCandidateStringEx::GetPrefixString(BSTR *pbstr)
  191. {
  192. if (m_pszPrefix == NULL) {
  193. return S_FALSE;
  194. }
  195. *pbstr = SysAllocString(m_pszPrefix);
  196. return S_OK;
  197. }
  198. /* G E T S U F F I X S T R I N G */
  199. /*------------------------------------------------------------------------------
  200. ------------------------------------------------------------------------------*/
  201. HRESULT CCandidateStringEx::GetSuffixString(BSTR *pbstr)
  202. {
  203. if (m_pszSuffix == NULL) {
  204. return S_FALSE;
  205. }
  206. *pbstr = SysAllocString(m_pszSuffix);
  207. return S_OK;
  208. }
  209. /* G E T I C O N */
  210. /*------------------------------------------------------------------------------
  211. ------------------------------------------------------------------------------*/
  212. HRESULT CCandidateStringEx::GetIcon( HICON *phIcon )
  213. {
  214. if (m_hIcon == NULL) {
  215. return S_FALSE;
  216. }
  217. *phIcon = m_hIcon;
  218. return S_OK;
  219. }
  220. #endif
  221. /* S E T R E A D I N G S T R I N G */
  222. /*------------------------------------------------------------------------------
  223. ------------------------------------------------------------------------------*/
  224. HRESULT CCandidateStringEx::SetReadingString(LPCWSTR psz)
  225. {
  226. if (psz == NULL)
  227. return S_FALSE;
  228. if (m_pszRead != NULL) {
  229. delete m_pszRead;
  230. }
  231. size_t cch = 0;
  232. StringCchLengthW((LPWSTR)psz, CIC_KOR_CANDSTR_MAX, &cch);
  233. m_pszRead = new WCHAR[cch+1];
  234. if (m_pszRead == NULL)
  235. return E_OUTOFMEMORY;
  236. StringCchCopyW(m_pszRead, cch+1, psz);
  237. return S_OK;
  238. }
  239. /* S E T I N L I N E C O M M E N T */
  240. /*------------------------------------------------------------------------------
  241. ------------------------------------------------------------------------------*/
  242. HRESULT CCandidateStringEx::SetInlineComment(LPCWSTR psz)
  243. {
  244. if (m_pszInlineComment != NULL)
  245. delete m_pszInlineComment;
  246. if (psz != NULL)
  247. {
  248. size_t cch = 0;
  249. StringCchLengthW((LPWSTR)psz, CIC_KOR_CANDSTR_MAX, &cch);
  250. m_pszInlineComment = new WCHAR[cch+1];
  251. if (m_pszInlineComment == NULL)
  252. return E_OUTOFMEMORY;
  253. StringCchCopyW(m_pszInlineComment, cch+1, psz);
  254. }
  255. else
  256. m_pszInlineComment = NULL;
  257. return S_OK;
  258. }
  259. #if 0
  260. /* S E T P O P U P C O M M E N T */
  261. /*------------------------------------------------------------------------------
  262. ------------------------------------------------------------------------------*/
  263. HRESULT CCandidateStringEx::SetPopupComment( LPCWSTR psz, DWORD dwGroupID )
  264. {
  265. if (m_pszPopupComment != NULL) {
  266. delete m_pszPopupComment;
  267. }
  268. m_dwPopupCommentGroupID = 0;
  269. if (psz != NULL) {
  270. UINT cch = 0;
  271. StringCchLengthW((LPWSTR)psz, CIC_KOR_CANDSTR_MAX, &cch);
  272. m_pszPopupComment = new WCHAR[cch+1];
  273. if (m_pszPopupComment == NULL)
  274. return E_OUTOFMEMORY;
  275. StringCchCopyW(m_pszPopupComment, cch+1, psz);
  276. m_dwPopupCommentGroupID = dwGroupID;
  277. }
  278. else {
  279. m_pszPopupComment = NULL;
  280. }
  281. return S_OK;
  282. }
  283. /* S E T P R E F I X S T R I N G */
  284. /*------------------------------------------------------------------------------
  285. ------------------------------------------------------------------------------*/
  286. HRESULT CCandidateStringEx::SetPrefixString( LPCWSTR psz )
  287. {
  288. if (m_pszPrefix != NULL) {
  289. delete m_pszPrefix;
  290. }
  291. if (psz != NULL) {
  292. UINT cch = 0;
  293. StringCchLengthW((LPWSTR)psz, CIC_KOR_CANDSTR_MAX, &cch);
  294. m_pszPrefix = new WCHAR[cch+1];
  295. if (m_pszPrefix == NULL)
  296. return E_OUTOFMEMORY;
  297. StringCchCopyW(m_pszPrefix, cch+1, psz);
  298. }
  299. else {
  300. m_pszPrefix = NULL;
  301. }
  302. return S_OK;
  303. }
  304. /* S E T S U F F I X S T R I N G */
  305. /*------------------------------------------------------------------------------
  306. ------------------------------------------------------------------------------*/
  307. HRESULT CCandidateStringEx::SetSuffixString( LPCWSTR psz )
  308. {
  309. if (m_pszSuffix != NULL) {
  310. delete m_pszSuffix;
  311. }
  312. if (psz != NULL) {
  313. UINT cch = 0;
  314. StringCchLengthW((LPWSTR)psz, CIC_KOR_CANDSTR_MAX, &cch);
  315. m_pszSuffix = new WCHAR[cch+1];
  316. if (m_pszSuffix == NULL)
  317. return E_OUTOFMEMORY;
  318. StringCchCopyW(m_pszSuffix, cch+1, psz);
  319. }
  320. else {
  321. m_pszSuffix = NULL;
  322. }
  323. return S_OK;
  324. }
  325. /* S E T I C O N */
  326. /*------------------------------------------------------------------------------
  327. ------------------------------------------------------------------------------*/
  328. HRESULT CCandidateStringEx::SetIcon( HICON hIcon )
  329. {
  330. m_hIcon = hIcon;
  331. return S_OK;
  332. }
  333. #endif
  334. //
  335. // CCandidateListEx
  336. //
  337. /* C C A N D I D A T E L I S T E X */
  338. /*------------------------------------------------------------------------------
  339. ------------------------------------------------------------------------------*/
  340. CCandidateListEx::CCandidateListEx(CANDLISTCALLBACKEX pfnCallback, ITfContext *pic, ITfRange *pRange)
  341. {
  342. m_pfnCallback = pfnCallback;
  343. m_pic = pic;
  344. m_pic->AddRef();
  345. m_pRange = pRange;
  346. m_pRange->AddRef();
  347. m_cRef = 1;
  348. m_iInitialSelection = 0;
  349. m_pExtraCand = NULL;
  350. }
  351. /* ~ C C A N D I D A T E L I S T E X */
  352. /*------------------------------------------------------------------------------
  353. ------------------------------------------------------------------------------*/
  354. CCandidateListEx::~CCandidateListEx()
  355. {
  356. m_pic->Release();
  357. m_pRange->Release();
  358. while(m_rgCandStr.Count())
  359. {
  360. CCandidateStringEx *pCandStringEx;
  361. pCandStringEx = m_rgCandStr.Get(0);
  362. pCandStringEx->Release();
  363. m_rgCandStr.Remove(0, 1);
  364. }
  365. if (m_pExtraCand != NULL)
  366. m_pExtraCand->Release();
  367. }
  368. /* Q U E R Y I N T E R F A C E */
  369. /*------------------------------------------------------------------------------
  370. ------------------------------------------------------------------------------*/
  371. STDAPI CCandidateListEx::QueryInterface(REFIID riid, void **ppvObj)
  372. {
  373. if (ppvObj == NULL)
  374. return E_POINTER;
  375. *ppvObj = NULL;
  376. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfCandidateList))
  377. *ppvObj = SAFECAST(this, ITfCandidateList *);
  378. else
  379. if (IsEqualIID(riid, IID_ITfCandidateListExtraCandidate))
  380. *ppvObj = SAFECAST(this, ITfCandidateListExtraCandidate *);
  381. if (*ppvObj == NULL) {
  382. return E_NOINTERFACE;
  383. }
  384. AddRef();
  385. return S_OK;
  386. }
  387. /* A D D R E F */
  388. /*------------------------------------------------------------------------------
  389. ------------------------------------------------------------------------------*/
  390. STDAPI_(ULONG) CCandidateListEx::AddRef()
  391. {
  392. m_cRef++;
  393. return m_cRef;
  394. }
  395. /* R E L E A S E */
  396. /*------------------------------------------------------------------------------
  397. ------------------------------------------------------------------------------*/
  398. STDAPI_(ULONG) CCandidateListEx::Release()
  399. {
  400. m_cRef--;
  401. if (0 < m_cRef) {
  402. return m_cRef;
  403. }
  404. delete this;
  405. return 0;
  406. }
  407. /* E N U M C A N D I D A T E S */
  408. /*------------------------------------------------------------------------------
  409. ------------------------------------------------------------------------------*/
  410. HRESULT CCandidateListEx::EnumCandidates(IEnumTfCandidates **ppEnum)
  411. {
  412. HRESULT hr = S_OK;
  413. if (!(*ppEnum = new CEnumCandidatesEx(this))) {
  414. hr = E_OUTOFMEMORY;
  415. }
  416. return hr;
  417. }
  418. /* G E T C A N D I D A T E */
  419. /*------------------------------------------------------------------------------
  420. ------------------------------------------------------------------------------*/
  421. HRESULT CCandidateListEx::GetCandidate(ULONG nIndex, ITfCandidateString **ppCand)
  422. {
  423. CCandidateStringEx *pCandString;
  424. UINT nCnt = m_rgCandStr.Count();
  425. if (nIndex >= nCnt)
  426. return E_FAIL;
  427. pCandString = m_rgCandStr.Get(nIndex);
  428. return pCandString->QueryInterface(IID_ITfCandidateString, (void **)ppCand
  429. );
  430. }
  431. /* G E T C A N D I D A T E N U M */
  432. /*------------------------------------------------------------------------------
  433. ------------------------------------------------------------------------------*/
  434. HRESULT CCandidateListEx::GetCandidateNum(ULONG *pnCnt)
  435. {
  436. *pnCnt = m_rgCandStr.Count();
  437. return S_OK;
  438. }
  439. /* S E T R E S U L T */
  440. /*------------------------------------------------------------------------------
  441. ------------------------------------------------------------------------------*/
  442. HRESULT CCandidateListEx::SetResult(ULONG nIndex, TfCandidateResult imcr)
  443. {
  444. if (m_pExtraCand && (nIndex == IEXTRACANDIDATE))
  445. {
  446. if (m_pfnCallback == NULL)
  447. return S_OK;
  448. return (m_pfnCallback)(m_pic, m_pRange, this, m_pExtraCand, imcr);
  449. }
  450. if (nIndex >= (UINT)m_rgCandStr.Count())
  451. return E_FAIL;
  452. if (m_pfnCallback == NULL)
  453. return S_OK;
  454. return (m_pfnCallback)(m_pic, m_pRange, this, m_rgCandStr.Get(nIndex), imcr);
  455. }
  456. /* G E T E X T R A C A N D I D A T E */
  457. /*------------------------------------------------------------------------------
  458. ------------------------------------------------------------------------------*/
  459. HRESULT CCandidateListEx::GetExtraCandidate(ITfCandidateString **ppCand)
  460. {
  461. if (ppCand == NULL)
  462. return E_POINTER;
  463. if (m_pExtraCand != NULL)
  464. return m_pExtraCand->QueryInterface(IID_ITfCandidateString, (void **)ppCand);
  465. return S_FALSE;
  466. }
  467. /* A D D S T R I N G */
  468. /*------------------------------------------------------------------------------
  469. ------------------------------------------------------------------------------*/
  470. HRESULT CCandidateListEx::AddString( LPCWSTR psz, LANGID langid, void *pv, IUnknown *punk, CCandidateStringEx **ppCandStr )
  471. {
  472. int nCnt = m_rgCandStr.Count();
  473. CCandidateStringEx *pCand = new CCandidateStringEx(nCnt, psz, langid, pv, punk);
  474. if (!pCand)
  475. return E_OUTOFMEMORY;
  476. m_rgCandStr.Insert(nCnt, 1);
  477. m_rgCandStr.Set(nCnt, pCand);
  478. if (ppCandStr) {
  479. *ppCandStr = pCand;
  480. (*ppCandStr)->AddRef();
  481. }
  482. return S_OK;
  483. }
  484. /* S E T I N I T I A L S E L E C T I O N */
  485. /*------------------------------------------------------------------------------
  486. Set initial selection to open candidate UI
  487. (internal use method)
  488. ------------------------------------------------------------------------------*/
  489. HRESULT CCandidateListEx::SetInitialSelection(ULONG iSelection)
  490. {
  491. m_iInitialSelection = iSelection;
  492. return S_OK;
  493. }
  494. /* G E T I N I T I A L S E L E C T I O N */
  495. /*------------------------------------------------------------------------------
  496. Get initial selection to open candidate UI
  497. (internal use method)
  498. ------------------------------------------------------------------------------*/
  499. HRESULT CCandidateListEx::GetInitialSelection(ULONG *piSelection)
  500. {
  501. if (piSelection == NULL) {
  502. return E_POINTER;
  503. }
  504. *piSelection = m_iInitialSelection;
  505. return S_OK;
  506. }
  507. /* A D D E X T R A S T R I N G */
  508. /*------------------------------------------------------------------------------
  509. Create extra candidate string ("0-Ban Kouho")
  510. (internal use method)
  511. ------------------------------------------------------------------------------*/
  512. HRESULT CCandidateListEx::AddExtraString(LPCWSTR psz, LANGID langid, void *pv, IUnknown *punk, CCandidateStringEx **ppCandStr)
  513. {
  514. if (m_pExtraCand != NULL)
  515. return E_FAIL;
  516. m_pExtraCand = new CCandidateStringEx(IEXTRACANDIDATE, psz, langid, pv, punk);
  517. if (!m_pExtraCand)
  518. return E_OUTOFMEMORY;
  519. if (ppCandStr)
  520. {
  521. *ppCandStr = m_pExtraCand;
  522. (*ppCandStr)->AddRef();
  523. }
  524. return S_OK;
  525. }
  526. //
  527. // CEnumCandidateEx
  528. //
  529. /* C E N U M C A N D I D A T E S E X */
  530. /*------------------------------------------------------------------------------
  531. ------------------------------------------------------------------------------*/
  532. CEnumCandidatesEx::CEnumCandidatesEx(CCandidateListEx *pList)
  533. {
  534. m_pList = pList;
  535. m_pList->AddRef();
  536. m_nCur = 0;
  537. m_cRef = 1;
  538. }
  539. /* ~ C E N U M C A N D I D A T E S E X */
  540. /*------------------------------------------------------------------------------
  541. ------------------------------------------------------------------------------*/
  542. CEnumCandidatesEx::~CEnumCandidatesEx()
  543. {
  544. m_pList->Release();
  545. }
  546. /* Q U E R Y I N T E R F A C E */
  547. /*------------------------------------------------------------------------------
  548. ------------------------------------------------------------------------------*/
  549. STDAPI CEnumCandidatesEx::QueryInterface(REFIID riid, void **ppvObj)
  550. {
  551. if (ppvObj == NULL)
  552. return E_POINTER;
  553. *ppvObj = NULL;
  554. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IEnumTfCandidates)) {
  555. *ppvObj = SAFECAST(this, IEnumTfCandidates *);
  556. }
  557. if (*ppvObj == NULL) {
  558. return E_NOINTERFACE;
  559. }
  560. AddRef();
  561. return S_OK;
  562. }
  563. /* A D D R E F */
  564. /*------------------------------------------------------------------------------
  565. ------------------------------------------------------------------------------*/
  566. STDAPI_(ULONG) CEnumCandidatesEx::AddRef()
  567. {
  568. m_cRef++;
  569. return m_cRef;
  570. }
  571. /* R E L E A S E */
  572. /*------------------------------------------------------------------------------
  573. ------------------------------------------------------------------------------*/
  574. STDAPI_(ULONG) CEnumCandidatesEx::Release()
  575. {
  576. m_cRef--;
  577. if (0 < m_cRef) {
  578. return m_cRef;
  579. }
  580. delete this;
  581. return 0;
  582. }
  583. /* C L O N E */
  584. /*------------------------------------------------------------------------------
  585. ------------------------------------------------------------------------------*/
  586. HRESULT CEnumCandidatesEx::Clone(IEnumTfCandidates **ppEnum)
  587. {
  588. return E_NOTIMPL;
  589. }
  590. /* N E X T */
  591. /*------------------------------------------------------------------------------
  592. ------------------------------------------------------------------------------*/
  593. HRESULT CEnumCandidatesEx::Next(ULONG ulCount, ITfCandidateString **ppCand, ULONG *pcFetched)
  594. {
  595. ULONG cFetched = 0;
  596. while (cFetched < ulCount) {
  597. CCandidateStringEx *pCand;
  598. if (m_nCur >= m_pList->m_rgCandStr.Count())
  599. break;
  600. pCand = m_pList->m_rgCandStr.Get(m_nCur);
  601. if (FAILED(pCand->QueryInterface(IID_ITfCandidateString, (void **)ppCand)))
  602. break;
  603. ppCand++;
  604. cFetched++;
  605. m_nCur++;
  606. }
  607. if (pcFetched)
  608. *pcFetched = cFetched;
  609. return (cFetched == ulCount) ? S_OK : S_FALSE;
  610. }
  611. /* R E S E T */
  612. /*------------------------------------------------------------------------------
  613. ------------------------------------------------------------------------------*/
  614. HRESULT CEnumCandidatesEx::Reset()
  615. {
  616. m_nCur = 0;
  617. return S_OK;
  618. }
  619. /* S K I P */
  620. /*------------------------------------------------------------------------------
  621. ------------------------------------------------------------------------------*/
  622. HRESULT CEnumCandidatesEx::Skip(ULONG ulCount)
  623. {
  624. while (ulCount) {
  625. if (m_nCur >= m_pList->m_rgCandStr.Count())
  626. break;
  627. m_nCur++;
  628. ulCount--;
  629. }
  630. return ulCount ? S_FALSE : S_OK;
  631. }