ProcessPaste.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // ProcessPaste.h: interface for the CProcessCopy class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_PROCESSPASTE_H__185CBB6F_4B63_4397_8FF9_E18D777DA506__INCLUDED_)
  5. #define AFX_PROCESSPASTE_H__185CBB6F_4B63_4397_8FF9_E18D777DA506__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "ArrayEx.h"
  10. #include "ProcessCopy.h"
  11. // returns the increment necessary to fit "count" elements between (dStart,dEnd)
  12. // if this returns 0, then "count" elements cannot fit between (dStart,dEnd).
  13. double GetFitIncrement( int count, double dStart, double dEnd );
  14. /*------------------------------------------------------------------*\
  15. ID based Globals
  16. \*------------------------------------------------------------------*/
  17. // Sets lID's lDate to GetCurrentTime() and updates paste stats
  18. BOOL MarkClipAsPasted(long lID);
  19. long NewGroupID( long lParentID = 0, CString text = "" );
  20. // creates copies of all lSrc Data and returns the copy's lDataID (or 0 on fail)
  21. long NewCopyDataID( long lSrc );
  22. BOOL DeleteID( long lID, bool bDisband = true ); // deletes the given item
  23. // deletes all items in the group, but not the group record itself
  24. BOOL DeleteGroupID( long lGroupID, bool bDisband = true );
  25. BOOL DeleteDataID( long lDataID ); // deletes all data for the given ID
  26. // Deletes everything in the Main and Data tables
  27. BOOL DeleteAllIDs();
  28. // all "formatIDs" (Data.lID) must be elements of the "lDataID" (Data.lDataID) set
  29. BOOL DeleteFormats( long lDataID, ARRAY& formatIDs );
  30. /*------------------------------------------------------------------*\
  31. CClipIDs - an array of Clip IDs
  32. \*------------------------------------------------------------------*/
  33. class CClipIDs : public CArrayEx<int>
  34. {
  35. public:
  36. // PASTING FUNCTIONS
  37. // allocate an HGLOBAL of the given Format Type representing the Clip IDs in this array.
  38. HGLOBAL Render( UINT cfType );
  39. // Fills "types" with the Format Types corresponding to the Clip IDs in this array.
  40. void GetTypes( CClipTypes& types );
  41. // Aggregates the cfType Format Data of the Clip IDs in this array, assuming
  42. // each Format is NULL terminated and placing pSeparator between them.
  43. CString AggregateText( UINT cfType, char* pSeparator );
  44. // MANAGEMENT FUNCTIONS
  45. // returns the address of the given id in this array or NULL.
  46. long* FindID( long lID );
  47. // Blindly Moves IDs into the lParentID Group sequentially with the given order
  48. // (i.e. this does not check to see if the IDs' order conflict)
  49. // if( dIncrement < 0 ), this does not change the order
  50. BOOL MoveTo( long lParentID, double dFirst = 0, double dIncrement = -1 );
  51. // reorders the "lParentID" Group, inserting before the given id.
  52. // if the id cannot be found, this appends the IDs.
  53. BOOL ReorderGroupInsert( long lParentID, long lInsertBeforeID = 0 );
  54. // Empties this array and fills it with the elements of the given group ID
  55. BOOL LoadElementsOf( long lGroupID );
  56. // Creates copies (duplicates) of all items in this array and assigns the
  57. // lParentID of the copies to the given "lParentID" group.
  58. // - if lParentID <= 0, then the copies have the same parent as the source
  59. // - pCopies is filled with the corresponding duplicate IDs.
  60. // - pAddNewTable and pSeekTable are used for more efficient recursion.
  61. BOOL CopyTo( long lParentID, CClipIDs* pCopies = NULL,
  62. CMainTable* pAddNewTable = NULL, CMainTable* pSeekTable = NULL );
  63. BOOL DeleteIDs( bool bDisband = true );
  64. };
  65. /*------------------------------------------------------------------*\
  66. COleClipSource
  67. \*------------------------------------------------------------------*/
  68. class COleClipSource : public COleDataSource
  69. {
  70. //DECLARE_DYNAMIC(COleClipSource)
  71. public:
  72. CClipIDs m_ClipIDs;
  73. COleClipSource();
  74. virtual ~COleClipSource();
  75. BOOL DoDelayRender();
  76. BOOL DoImmediateRender();
  77. protected:
  78. DECLARE_MESSAGE_MAP()
  79. public:
  80. virtual BOOL OnRenderGlobalData(LPFORMATETC lpFormatEtc, HGLOBAL* phGlobal);
  81. };
  82. /*------------------------------------------------------------------*\
  83. CProcessPaste
  84. \*------------------------------------------------------------------*/
  85. class CProcessPaste
  86. {
  87. public:
  88. // true if we should delete m_pOle,
  89. // false if it will be automatically deleted
  90. bool m_bDeleteOle;
  91. COleClipSource* m_pOle;
  92. CProcessPaste();
  93. ~CProcessPaste();
  94. CClipIDs& GetClipIDs() { return m_pOle->m_ClipIDs; }
  95. BOOL DoPaste();
  96. BOOL DoDrag();
  97. void MarkAsPasted();
  98. };
  99. #endif // !defined(AFX_PROCESSPASTE_H__185CBB6F_4B63_4397_8FF9_E18D777DA506__INCLUDED_)