Clip.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // ProcessCopy.h: classes for saving the clipboard to db
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_PROCESSCOPY_H__185CBB6F_4B63_4397_8FF9_E18D777DA506__INCLUDED_)
  5. #define AFX_PROCESSCOPY_H__185CBB6F_4B63_4397_8FF9_E18D777DA506__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include <afxole.h>
  10. #include <afxtempl.h>
  11. #include "tinyxml.h"
  12. class CClip;
  13. class CCopyThread;
  14. typedef CArray<CLIPFORMAT, CLIPFORMAT> CClipTypes;
  15. /*----------------------------------------------------------------------------*\
  16. COleDataObjectEx
  17. \*----------------------------------------------------------------------------*/
  18. class COleDataObjectEx : public COleDataObject
  19. {
  20. public:
  21. // creates global from IStream if necessary
  22. HGLOBAL GetGlobalData(CLIPFORMAT cfFormat, LPFORMATETC lpFormatEtc = NULL);
  23. };
  24. /*----------------------------------------------------------------------------*\
  25. CClipFormat - holds the data of one clip format.
  26. \*----------------------------------------------------------------------------*/
  27. class CClipFormat
  28. {
  29. public:
  30. CLIPFORMAT m_cfType;
  31. HGLOBAL m_hgData;
  32. bool bDeleteData;
  33. long m_lDBID;
  34. CClipFormat(CLIPFORMAT cfType = 0, HGLOBAL hgData = 0, long lDBID = -1);
  35. ~CClipFormat();
  36. void Clear();
  37. void Free();
  38. };
  39. /*----------------------------------------------------------------------------*\
  40. CClipFormats - holds an array of CClipFormat
  41. \*----------------------------------------------------------------------------*/
  42. class CClipFormats : public CArray<CClipFormat,CClipFormat&>
  43. {
  44. public:
  45. // returns a pointer to the CClipFormat in this array which matches the given type
  46. // or NULL if that type doesn't exist in this array.
  47. CClipFormat* FindFormat(UINT cfType);
  48. };
  49. /*----------------------------------------------------------------------------*\
  50. CClip - holds multiple CClipFormats and clip statistics
  51. - provides static functions for manipulating a Clip as a single unit.
  52. \*----------------------------------------------------------------------------*/
  53. class CClip
  54. {
  55. public:
  56. CClip();
  57. ~CClip();
  58. const CClip& operator=(const CClip &clip);
  59. static DWORD m_LastAddedCRC;
  60. static long m_LastAddedID;
  61. long m_ID;
  62. CClipFormats m_Formats;
  63. CTime m_Time;
  64. CString m_Desc;
  65. ULONG m_lTotalCopySize;
  66. long m_lParent;
  67. long m_lDontAutoDelete;
  68. long m_lShortCut;
  69. BOOL m_bIsGroup;
  70. DWORD m_CRC;
  71. CString m_csQuickPaste;
  72. void Clear();
  73. void EmptyFormats();
  74. bool AddFormat(CLIPFORMAT cfType, void* pData, UINT nLen);
  75. bool LoadFromClipboard(CClipTypes* pClipTypes);
  76. bool SetDescFromText(HGLOBAL hgData);
  77. bool SetDescFromType();
  78. bool AddToDB(bool bCheckForDuplicates = true);
  79. bool ModifyMainTable();
  80. bool SaveFromEditWnd(BOOL bUpdateDesc);
  81. void MakeLatestTime();
  82. BOOL LoadMainTable(long lID);
  83. DWORD GenerateCRC();
  84. // Allocates a Global containing the requested Clip's Format Data
  85. static HGLOBAL LoadFormat(long lID, UINT cfType);
  86. // Fills "formats" with the Data of all Formats in the db for the given Clip ID
  87. bool LoadFormats(long lID, bool bOnlyLoad_CF_TEXT = false);
  88. // Fills "types" with all Types in the db for the given Clip ID
  89. static void LoadTypes(long lID, CClipTypes& types);
  90. protected:
  91. bool AddToMainTable();
  92. bool AddToDataTable();
  93. int FindDuplicate();
  94. };
  95. /*----------------------------------------------------------------------------*\
  96. CClipList
  97. \*----------------------------------------------------------------------------*/
  98. class CClipList : public CList<CClip*,CClip*>
  99. {
  100. public:
  101. ~CClipList();
  102. // returns the number of clips actually saved
  103. // while this does empty the Format Data, it does not delete the Clips.
  104. int AddToDB( bool bLatestTime = false, bool bShowStatus = true );
  105. const CClipList& operator=(const CClipList &cliplist);
  106. };
  107. #endif // !defined(AFX_PROCESSCOPY_H__185CBB6F_4B63_4397_8FF9_E18D777DA506__INCLUDED_)