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.

110 lines
2.6 KiB

  1. //
  2. // editrec.h
  3. //
  4. #ifndef EDITREC_H
  5. #define EDITREC_H
  6. #include "private.h"
  7. #include "spans.h"
  8. #include "strary.h"
  9. #include "globals.h"
  10. typedef struct
  11. {
  12. TfGuidAtom gaType;
  13. BOOL fAppProperty;
  14. CSpanSet *pss;
  15. } PROPSPAN;
  16. class CInputContext;
  17. class CEditRecord : public ITfEditRecord,
  18. public CComObjectRootImmx
  19. {
  20. public:
  21. CEditRecord(CInputContext *pic);
  22. ~CEditRecord();
  23. BEGIN_COM_MAP_IMMX(CEditRecord)
  24. COM_INTERFACE_ENTRY(ITfEditRecord)
  25. END_COM_MAP_IMMX()
  26. IMMX_OBJECT_IUNKNOWN_FOR_ATL()
  27. // ITfEditRecord
  28. STDMETHODIMP GetSelectionStatus(BOOL *pfChanged);
  29. STDMETHODIMP GetTextAndPropertyUpdates(DWORD dwFlags, const GUID **rgProperties, ULONG cProperties, IEnumTfRanges **ppEnumProp);
  30. BOOL _GetSelectionStatus() { return _fSelChanged; }
  31. void _SetSelectionStatus() { _fSelChanged = TRUE; }
  32. CSpanSet *_GetTextSpanSet() { return &_ssText; }
  33. BOOL _AddProperty(TfGuidAtom gaType, CSpanSet *pss);
  34. CSpanSet *_FindCreateAppAttr(TfGuidAtom gaType);
  35. BOOL _SecondRef()
  36. {
  37. return (m_dwRef > 1);
  38. }
  39. BOOL _IsEmpty()
  40. {
  41. return (!_fSelChanged) &&
  42. (_ssText.GetCount() == 0) &&
  43. (_rgssProperties.Count() == 0); // prop ss are only added if non-empty
  44. }
  45. void _Reset()
  46. {
  47. int i;
  48. PROPSPAN *pps;
  49. _fSelChanged = FALSE;
  50. _ssText.Reset();
  51. for (i=0; i<_rgssProperties.Count(); i++)
  52. {
  53. pps = (PROPSPAN *)_rgssProperties.GetPtr(i);
  54. // nb: caller takes ownership of cicero property span sets, we just free the pointer array
  55. if (pps->fAppProperty)
  56. {
  57. delete pps->pss;
  58. }
  59. }
  60. _rgssProperties.Clear(); // perf: use Reset?
  61. }
  62. private:
  63. BOOL _InsertProperty(TfGuidAtom gaType, CSpanSet *pss, int i, BOOL fAppProperty);
  64. PROPSPAN *_FindProperty(TfGuidAtom gaType, int *piOut);
  65. int _FindPropertySpanIndex(TfGuidAtom gaType)
  66. {
  67. int i;
  68. _FindProperty(gaType, &i);
  69. return i;
  70. }
  71. CSpanSet *_FindPropertySpanSet(REFGUID rguid)
  72. {
  73. TfGuidAtom guidatom;
  74. PROPSPAN *pps;
  75. MyRegisterGUID(rguid, &guidatom);
  76. pps = _FindProperty(guidatom, NULL);
  77. return (pps == NULL) ? NULL : pps->pss;
  78. }
  79. CInputContext *_pic;
  80. CSpanSet _ssText;
  81. BOOL _fSelChanged;
  82. CStructArray<PROPSPAN> _rgssProperties;
  83. DBG_ID_DECLARE;
  84. };
  85. #endif // EDITREC_H