Source code of Windows XP (NT5)
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.

126 lines
2.7 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(LPCLSID pClsID)
  26. {
  27. *pClsID=m_pObj->m_clsID;
  28. return NOERROR;
  29. }
  30. /*
  31. * CImpIPersistPropertyBag::InitNew
  32. *
  33. * Purpose:
  34. * Informs the object that it is being created new instead of
  35. * loaded from a persistent state. This will be called in lieu
  36. * of IPersistStreamInit::Load.
  37. *
  38. * Parameters:
  39. * None
  40. */
  41. STDMETHODIMP
  42. CImpIPersistPropertyBag::InitNew(void)
  43. {
  44. //Nothing for us to do
  45. return NOERROR;
  46. }
  47. /*
  48. * CImpIPersistPropertyBag::Load
  49. *
  50. * Purpose:
  51. * Instructs the object to load itself from a previously saved
  52. * IPropertyBag that was handled by Save in another object lifetime.
  53. * This function should not hold on to pIPropertyBag.
  54. *
  55. * This function is called in lieu of IPersistStreamInit::InitNew
  56. * when the object already has a persistent state.
  57. *
  58. * Parameters:
  59. * pIPropBag IPropertyBag* from which to load our data.
  60. * pIError IErrorLog* for storing errors. NULL if caller not interested in errors.
  61. */
  62. STDMETHODIMP CImpIPersistPropertyBag::Load (
  63. IPropertyBag* pIPropBag,
  64. IErrorLog* pIError )
  65. {
  66. HRESULT hr = S_OK;
  67. if (NULL==pIPropBag)
  68. return ResultFromScode(E_POINTER);
  69. //Read all the data into the control structure.
  70. hr = m_pObj->m_pCtrl->LoadFromPropertyBag ( pIPropBag, pIError );
  71. return hr;
  72. }
  73. /*
  74. * CImpIPersistPropertyBag::Save
  75. *
  76. * Purpose:
  77. * Saves the data for this object to an IPropertyBag.
  78. *
  79. * Parameters:
  80. * pIPropBag IPropertyBag* in which to save our data.
  81. * fClearDirty BOOL indicating if this call should clear
  82. * the object's dirty flag (TRUE) or leave it
  83. * unchanged (FALSE).
  84. * fSaveAllProps BOOL indicating if this call should save all properties.
  85. */
  86. STDMETHODIMP
  87. CImpIPersistPropertyBag::Save (
  88. IPropertyBag* pIPropBag,
  89. BOOL fClearDirty,
  90. BOOL fSaveAllProps )
  91. {
  92. HRESULT hr = S_OK;
  93. if (NULL==pIPropBag)
  94. return ResultFromScode(E_POINTER);
  95. hr = m_pObj->m_pCtrl->SaveToPropertyBag ( pIPropBag, fSaveAllProps );
  96. if (FAILED(hr))
  97. return hr;
  98. if (fClearDirty)
  99. m_pObj->m_fDirty=FALSE;
  100. return hr;
  101. }