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.

152 lines
3.7 KiB

  1. /*
  2. * NOTMGR.C
  3. *
  4. * Purpose:
  5. * Notification Manager implemenation
  6. *
  7. * Author:
  8. * AlexGo 6/5/95
  9. *
  10. * Copyright (c) 1995-1997, Microsoft Corporation. All rights reserved.
  11. */
  12. #include "_common.h"
  13. #include "_notmgr.h"
  14. ASSERTDATA
  15. /*
  16. * CNotifyMgr::CNotifyMgr ()
  17. */
  18. CNotifyMgr::CNotifyMgr()
  19. {
  20. TRACEBEGIN(TRCSUBSYSNOTM, TRCSCOPEINTERN, "CNotifyMgr::CNotifyMgr");
  21. _pitnlist = NULL;
  22. }
  23. /*
  24. * CNotifyMgr::~CNotifyMgr ()
  25. *
  26. */
  27. CNotifyMgr::~CNotifyMgr()
  28. {
  29. TRACEBEGIN(TRCSUBSYSNOTM, TRCSCOPEINTERN, "CNotifyMgr::~CNotifyMgr");
  30. ITxNotify *plist;
  31. for( plist = _pitnlist; plist != NULL; plist = plist->_pnext )
  32. {
  33. plist->Zombie();
  34. }
  35. TRACEERRSZSC("CNotifyMgr::~CNotifyMgr(): zombie(s) exist", _pitnlist != 0);
  36. }
  37. /*
  38. * CNotifyMgr::Add (pITN)
  39. *
  40. * @mfunc
  41. * Adds a notification sink to the list
  42. *
  43. * Algorithm:
  44. * puts the entry at the *front* of the notification list, so
  45. * that high frequency entries (like ranges and text pointers
  46. * existing on the stack) can be added and removed efficiently
  47. */
  48. void CNotifyMgr::Add(
  49. ITxNotify *pITN )
  50. {
  51. TRACEBEGIN(TRCSUBSYSNOTM, TRCSCOPEINTERN, "CNotifyMgr::Add");
  52. pITN->_pnext = _pitnlist;
  53. _pitnlist = pITN;
  54. }
  55. /*
  56. * CNotifyMgr::Remove (pITN)
  57. *
  58. * @mfunc
  59. * removes a notification sink from the list
  60. */
  61. void CNotifyMgr::Remove(
  62. ITxNotify *pITN )
  63. {
  64. TRACEBEGIN(TRCSUBSYSNOTM, TRCSCOPEINTERN, "CNotifyMgr::Remove");
  65. ITxNotify *plist = _pitnlist;
  66. ITxNotify **ppprev = &_pitnlist;
  67. while(plist)
  68. {
  69. if( plist == pITN )
  70. {
  71. *ppprev = plist->_pnext;
  72. break;
  73. }
  74. ppprev = &(plist->_pnext);
  75. plist = plist->_pnext;
  76. }
  77. }
  78. /*
  79. * CNotifyMgr::NotifyPreReplaceRange (pITNignore, cp, cchDel, cchNew, cpFormatMin, cpFormatMax, dwFlags)
  80. *
  81. * @mfunc
  82. * send an OnReplaceRange notification to all sinks (except pITNignore)
  83. */
  84. void CNotifyMgr::NotifyPreReplaceRange(
  85. ITxNotify * pITNignore, //@parm Notification sink to ignore
  86. LONG cp, //@parm cp where ReplaceRange starts ("cpMin")
  87. LONG cchDel, //@parm Count of chars after cp that are deleted
  88. LONG cchNew, //@parm Count of chars inserted after cp
  89. LONG cpFormatMin, //@parm cpMin for a formatting change
  90. LONG cpFormatMax, //@parm cpMost for a formatting change
  91. NOTIFY_DATA *pNotifyData) //@parm special data to indicate changes
  92. {
  93. TRACEBEGIN(TRCSUBSYSNOTM, TRCSCOPEINTERN, "CNotifyMgr::NotifyPreReplaceRange");
  94. ITxNotify *plist;
  95. for( plist = _pitnlist; plist != NULL; plist = plist->_pnext )
  96. {
  97. if( plist != pITNignore )
  98. {
  99. plist->OnPreReplaceRange( cp, cchDel, cchNew, cpFormatMin,
  100. cpFormatMax, pNotifyData );
  101. }
  102. }
  103. }
  104. /*
  105. * CNotifyMgr::NotifyPostReplaceRange (pITNignore, cp, cchDel, cchNew, cpFormatMin, cpFormatMax, dwFlags)
  106. *
  107. * @mfunc
  108. * send an OnReplaceRange notification to all sinks (except pITNignore)
  109. *
  110. * @comm
  111. * pITNignore typically is the TxtPtr/etc that is actually making the
  112. * ReplaceRange modification
  113. */
  114. void CNotifyMgr::NotifyPostReplaceRange(
  115. ITxNotify * pITNignore, //@parm Notification sink to ignore
  116. LONG cp, //@parm cp where ReplaceRange starts ("cpMin")
  117. LONG cchDel, //@parm Count of chars after cp that are deleted
  118. LONG cchNew, //@parm Count of chars inserted after cp
  119. LONG cpFormatMin, //@parm cpMin for a formatting change
  120. LONG cpFormatMax, //@parm cpMost for a formatting change
  121. NOTIFY_DATA *pNotifyData) //@parm special data to indicate changes
  122. {
  123. TRACEBEGIN(TRCSUBSYSNOTM, TRCSCOPEINTERN, "CNotifyMgr::NotifyPostReplaceRange");
  124. ITxNotify *plist;
  125. for( plist = _pitnlist; plist != NULL; plist = plist->_pnext )
  126. {
  127. if( plist != pITNignore )
  128. {
  129. plist->OnPostReplaceRange( cp, cchDel, cchNew, cpFormatMin,
  130. cpFormatMax, pNotifyData );
  131. }
  132. }
  133. }