CF_TextAggregator.cpp 934 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "stdafx.h"
  2. #include ".\cf_textaggregator.h"
  3. #include "Misc.h"
  4. CCF_TextAggregator::CCF_TextAggregator(CStringA csSepator) :
  5. m_csSeparator(csSepator)
  6. {
  7. }
  8. CCF_TextAggregator::~CCF_TextAggregator(void)
  9. {
  10. }
  11. bool CCF_TextAggregator::AddClip(LPVOID lpData, int nDataSize, int nPos, int nCount)
  12. {
  13. LPCSTR pText = (LPCSTR)lpData;
  14. if(pText == NULL)
  15. {
  16. return false;
  17. }
  18. //Ensure it's null terminated
  19. if(pText[nDataSize-1] != '\0')
  20. {
  21. int len = 0;
  22. for(len = 0; len < nDataSize && pText[len] != '\0'; len++ )
  23. {
  24. }
  25. // if it is not null terminated, skip this item
  26. if(len >= nDataSize)
  27. return false;
  28. }
  29. m_csNewText += pText;
  30. if(nPos != nCount-1)
  31. {
  32. m_csNewText += m_csSeparator;
  33. }
  34. return true;
  35. }
  36. HGLOBAL CCF_TextAggregator::GetHGlobal()
  37. {
  38. long lLen = m_csNewText.GetLength();
  39. HGLOBAL hGlobal = NewGlobalP(m_csNewText.GetBuffer(lLen), lLen+sizeof(char));
  40. m_csNewText.ReleaseBuffer();
  41. return hGlobal;
  42. }