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.

151 lines
3.1 KiB

  1. /*++
  2. Copyright (C) 1993-1999 Microsoft Corporation
  3. Module Name:
  4. iperpbag.cpp
  5. Abstract:
  6. Implementation of the IPersistPropertyBag interface exposed on the
  7. Polyline object.
  8. --*/
  9. #include "polyline.h"
  10. #include "unkhlpr.h"
  11. /*
  12. * CImpIPersistPropertyBag interface implementation
  13. */
  14. IMPLEMENT_CONTAINED_INTERFACE(CPolyline, CImpIPersistPropertyBag)
  15. /*
  16. * CImpIPersistPropertyBag::GetClassID
  17. *
  18. * Purpose:
  19. * Returns the CLSID of the object represented by this interface.
  20. *
  21. * Parameters:
  22. * pClsID LPCLSID in which to store our CLSID.
  23. */
  24. STDMETHODIMP
  25. CImpIPersistPropertyBag::GetClassID(
  26. OUT LPCLSID pClsID
  27. )
  28. {
  29. HRESULT hr = S_OK;
  30. if (pClsID == NULL) {
  31. return E_POINTER;
  32. }
  33. try {
  34. *pClsID = m_pObj->m_clsID;
  35. } catch (...) {
  36. hr = E_POINTER;
  37. }
  38. return hr;
  39. }
  40. /*
  41. * CImpIPersistPropertyBag::InitNew
  42. *
  43. * Purpose:
  44. * Informs the object that it is being created new instead of
  45. * loaded from a persistent state. This will be called in lieu
  46. * of IPersistStreamInit::Load.
  47. *
  48. * Parameters:
  49. * None
  50. */
  51. STDMETHODIMP
  52. CImpIPersistPropertyBag::InitNew(void)
  53. {
  54. //Nothing for us to do
  55. return NOERROR;
  56. }
  57. /*
  58. * CImpIPersistPropertyBag::Load
  59. *
  60. * Purpose:
  61. * Instructs the object to load itself from a previously saved
  62. * IPropertyBag that was handled by Save in another object lifetime.
  63. * This function should not hold on to pIPropertyBag.
  64. *
  65. * This function is called in lieu of IPersistStreamInit::InitNew
  66. * when the object already has a persistent state.
  67. *
  68. * Parameters:
  69. * pIPropBag IPropertyBag* from which to load our data.
  70. * pIError IErrorLog* for storing errors. NULL if caller not interested in errors.
  71. */
  72. STDMETHODIMP CImpIPersistPropertyBag::Load (
  73. IPropertyBag* pIPropBag,
  74. IErrorLog* pIError
  75. )
  76. {
  77. HRESULT hr = S_OK;
  78. if (NULL == pIPropBag) {
  79. return (E_POINTER);
  80. }
  81. try {
  82. //Read all the data into the control structure.
  83. hr = m_pObj->m_pCtrl->LoadFromPropertyBag ( pIPropBag, pIError );
  84. } catch (...) {
  85. hr = E_POINTER;
  86. }
  87. return hr;
  88. }
  89. /*
  90. * CImpIPersistPropertyBag::Save
  91. *
  92. * Purpose:
  93. * Saves the data for this object to an IPropertyBag.
  94. *
  95. * Parameters:
  96. * pIPropBag IPropertyBag* in which to save our data.
  97. * fClearDirty BOOL indicating if this call should clear
  98. * the object's dirty flag (TRUE) or leave it
  99. * unchanged (FALSE).
  100. * fSaveAllProps BOOL indicating if this call should save all properties.
  101. */
  102. STDMETHODIMP
  103. CImpIPersistPropertyBag::Save (
  104. IN IPropertyBag* pIPropBag,
  105. IN BOOL fClearDirty,
  106. IN BOOL fSaveAllProps
  107. )
  108. {
  109. HRESULT hr = S_OK;
  110. if (NULL == pIPropBag) {
  111. return (E_POINTER);
  112. }
  113. try {
  114. hr = m_pObj->m_pCtrl->SaveToPropertyBag ( pIPropBag, fSaveAllProps );
  115. } catch (...) {
  116. hr = E_POINTER;
  117. }
  118. if (SUCCEEDED(hr)) {
  119. if (fClearDirty) {
  120. m_pObj->m_fDirty=FALSE;
  121. }
  122. }
  123. return hr;
  124. }