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.

155 lines
5.5 KiB

  1. //---------------------------------------------------------------------------
  2. // CursorPosition.h : CVDCursorPosition header file
  3. //
  4. // Copyright (c) 1996 Microsoft Corporation, All Rights Reserved
  5. // Developed by Sheridan Software Systems, Inc.
  6. //---------------------------------------------------------------------------
  7. #ifndef __CVDCURSORPOSITION__
  8. #define __CVDCURSORPOSITION__
  9. #include "bookmark.h"
  10. class CVDRowsetSource;
  11. class CVDCursorPosition : public CVDNotifier
  12. {
  13. protected:
  14. // Construction/Destruction
  15. CVDCursorPosition();
  16. virtual ~CVDCursorPosition();
  17. public:
  18. static HRESULT Create(IRowPosition * pRowPosition,
  19. CVDCursorMain * pCursorMain,
  20. CVDCursorPosition ** ppCursorPosition,
  21. CVDResourceDLL * pResourceDLL);
  22. public:
  23. // Access functions
  24. CVDCursorMain * GetCursorMain() const {return m_pCursorMain;}
  25. CVDRowsetSource * GetRowsetSource() const {return m_pCursorMain;}
  26. // Updating
  27. ICursor * GetSameRowClone() const {return m_pSameRowClone;}
  28. void SetSameRowClone(ICursor * pSameRowClone) {m_pSameRowClone = pSameRowClone;}
  29. DWORD GetEditMode() const {return m_dwEditMode;}
  30. void SetEditMode(DWORD dwEditMode) {m_dwEditMode = dwEditMode;}
  31. // Column updates
  32. HRESULT CreateColumnUpdates();
  33. HRESULT ResetColumnUpdates();
  34. void DestroyColumnUpdates();
  35. CVDColumnUpdate * GetColumnUpdate(ULONG ulColumn) const;
  36. void SetColumnUpdate(ULONG ulColumn, CVDColumnUpdate * pColumnUpdate);
  37. // Positioning/reset functions
  38. void PositionToFirstRow();
  39. HRESULT SetCurrentHRow(HROW hRowNew);
  40. void SetCurrentRowStatus(WORD wStatus);
  41. HRESULT SetAddHRow(HROW hRowNew);
  42. HRESULT IsSameRowAsCurrent(HROW hRow, BOOL fCacheIfNotSame);
  43. HRESULT IsSameRowAsNew(HROW hRow);
  44. HRESULT SetRowPosition(HROW hRow);
  45. // adding/editing functions
  46. #ifndef VD_DONT_IMPLEMENT_ISTREAM
  47. HRESULT UpdateEntryIDStream(CVDRowsetColumn * pColumn, HROW hRow, IStream * pStream);
  48. #endif //VD_DONT_IMPLEMENT_ISTREAM
  49. void ReleaseSameRowClone();
  50. HROW GetEditRow() const;
  51. // bookmarks
  52. CVDBookmark m_bmCurrent; // current row's bookmark
  53. CVDBookmark m_bmCache; // used to cache bookmark of last non-current
  54. CVDBookmark m_bmAddRow; // add row's bookmark
  55. protected:
  56. // Data members
  57. CVDResourceDLL * m_pResourceDLL;
  58. CVDCursorMain * m_pCursorMain; // backwards pointer to CVDCursorMain
  59. IRowPosition * m_pRowPosition; // row position pointer, used to synchronize current position
  60. ICursor * m_pSameRowClone; // same-row clone used in ICursorUpdateARow::GetColumn() calls
  61. DWORD m_dwEditMode; // current edit mode
  62. CVDColumnUpdate ** m_ppColumnUpdates; // column updates
  63. VARIANT_BOOL m_fTempEditMode; // temporary edit mode? (caused by external SetData call)
  64. // IRowPositionChange
  65. VARIANT_BOOL m_fConnected; // have we added ourselves to the RowPosition's connection point
  66. DWORD m_dwAdviseCookie; // connection point identifier
  67. VARIANT_BOOL m_fPassivated; // external ref count went to zero
  68. VARIANT_BOOL m_fInternalSetRow; // OnRowPositionChange caused by internal call
  69. HRESULT ConnectIRowPositionChange();
  70. void DisconnectIRowPositionChange();
  71. void Passivate();
  72. HRESULT SendNotification(DBEVENTPHASE ePhase,
  73. DWORD dwEventWhat,
  74. ULONG cReasons,
  75. CURSOR_DBNOTIFYREASON rgReasons[]);
  76. public:
  77. void ReleaseCurrentRow();
  78. void ReleaseAddRow();
  79. //=--------------------------------------------------------------------------=
  80. // IRowsetNotify methods - IRowsetNotify is actually implemented off of CVDCursorMain
  81. // which forwards each method to the CVDCursorPosition objects
  82. // in its family
  83. //
  84. STDMETHOD(OnFieldChange)(IUnknown *pRowset, HROW hRow, ULONG cColumns, ULONG rgColumns[], DBREASON eReason,
  85. DBEVENTPHASE ePhase, BOOL fCantDeny);
  86. STDMETHOD(OnRowChange)(IUnknown *pRowset, ULONG cRows, const HROW rghRows[], DBREASON eReason, DBEVENTPHASE ePhase,
  87. BOOL fCantDeny);
  88. STDMETHOD(OnRowsetChange)(IUnknown *pRowset, DBREASON eReason, DBEVENTPHASE ePhase, BOOL fCantDeny);
  89. public:
  90. //=--------------------------------------------------------------------------=
  91. // IUnknown methods
  92. //
  93. STDMETHOD(QueryInterface)(REFIID riid, void **ppvObjOut);
  94. STDMETHOD_(ULONG, AddRef)(void);
  95. STDMETHOD_(ULONG, Release)(void);
  96. //=--------------------------------------------------------------------------=
  97. // IRowPositionChange method passed up from CVDRowPositionChange implementation
  98. //
  99. STDMETHOD(OnRowPositionChange)(DBREASON eReason, DBEVENTPHASE ePhase, BOOL fCantDeny);
  100. private:
  101. // the inner, private unknown implementation to give to connection point
  102. // container to avoid circular ref count
  103. //
  104. class CVDRowPositionChange : public IRowPositionChange
  105. {
  106. public:
  107. STDMETHOD(QueryInterface)(REFIID riid, void **ppvObjOut);
  108. STDMETHOD_(ULONG, AddRef)(void);
  109. STDMETHOD_(ULONG, Release)(void);
  110. // constructor is remarkably trivial
  111. //
  112. CVDRowPositionChange() : m_cRef(0) {}
  113. ULONG GetRefCount() const {return m_cRef;}
  114. private:
  115. CVDCursorPosition *m_pMainUnknown();
  116. ULONG m_cRef;
  117. //=--------------------------------------------------------------------------=
  118. // IRowPositionChange method
  119. //
  120. STDMETHOD(OnRowPositionChange)(DBREASON eReason, DBEVENTPHASE ePhase, BOOL fCantDeny);
  121. } m_RowPositionChange;
  122. friend class CVDRowPositionChange;
  123. };
  124. #endif //__CVDCURSORPOSITION__