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.

150 lines
3.5 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)
  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. {
  92. TRACEBEGIN(TRCSUBSYSNOTM, TRCSCOPEINTERN, "CNotifyMgr::NotifyPreReplaceRange");
  93. ITxNotify *plist;
  94. for( plist = _pitnlist; plist != NULL; plist = plist->_pnext )
  95. {
  96. if( plist != pITNignore )
  97. {
  98. plist->OnPreReplaceRange( cp, cchDel, cchNew, cpFormatMin,
  99. cpFormatMax );
  100. }
  101. }
  102. }
  103. /*
  104. * CNotifyMgr::NotifyPostReplaceRange (pITNignore, cp, cchDel, cchNew)
  105. *
  106. * @mfunc
  107. * send an OnReplaceRange notification to all sinks (except pITNignore)
  108. *
  109. * @comm
  110. * pITNignore typically is the TxtPtr/etc that is actually making the
  111. * ReplaceRange modification
  112. */
  113. void CNotifyMgr::NotifyPostReplaceRange(
  114. ITxNotify * pITNignore, //@parm Notification sink to ignore
  115. LONG cp, //@parm cp where ReplaceRange starts ("cpMin")
  116. LONG cchDel, //@parm Count of chars after cp that are deleted
  117. LONG cchNew, //@parm Count of chars inserted after cp
  118. LONG cpFormatMin,//@parm cpMin for a formatting change
  119. LONG cpFormatMax)//@parm cpMost for a formatting change
  120. {
  121. TRACEBEGIN(TRCSUBSYSNOTM, TRCSCOPEINTERN, "CNotifyMgr::NotifyPostReplaceRange");
  122. ITxNotify *plist;
  123. for( plist = _pitnlist; plist != NULL; plist = plist->_pnext )
  124. {
  125. if( plist != pITNignore )
  126. {
  127. plist->OnPostReplaceRange( cp, cchDel, cchNew, cpFormatMin,
  128. cpFormatMax );
  129. }
  130. }
  131. }