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.

180 lines
5.0 KiB

  1. /*
  2. * @doc INTERNAL
  3. *
  4. * @module _LDTE.H - Lighweight Data Transfer Engine |
  5. *
  6. * Declaration for CLightDTEngine class
  7. *
  8. * Author:
  9. * alexgo 3/25/95
  10. *
  11. * Copyright (c) 1995-1997, Microsoft Corporation. All rights reserved.
  12. */
  13. #ifndef __LDTE_H__
  14. #define __LDTE_H__
  15. #include "_m_undo.h"
  16. #include "_dragdrp.h"
  17. class CTxtRange;
  18. class CTxtEdit;
  19. /*
  20. * DataObjectInfo
  21. *
  22. * Purpose:
  23. * enumeration of bit flags used to indicate what operations
  24. * are possible from a given data object.
  25. */
  26. typedef enum tagDataObjectInfo
  27. {
  28. DOI_NONE = 0,
  29. DOI_CANUSETOM = 1, // TOM<-->TOM optimized data transfers
  30. DOI_CANPASTEPLAIN = 2, // plain text pasting available
  31. DOI_CANPASTERICH = 4, // rich text pasting available
  32. DOI_CANPASTEOLE = 8, // object may be pasted as an OLE embedding
  33. // (note that this flag may be combined with
  34. // others).
  35. } DataObjectInfo;
  36. class CLightDTEngine;
  37. typedef struct _READHGLOBAL
  38. { // Used by RtfHGlobalToRange()
  39. LPSTR ptext; // ANSI string remaining to be read
  40. LONG cbLeft; // Bytes remaining (might exceed string len)
  41. } READHGLOBAL;
  42. typedef struct _WRITEHGLOBAL
  43. { // Used by RtfHGlobalToRange()
  44. HGLOBAL hglobal;
  45. LONG cch; // Count of ASCII chars written (a cb)
  46. LONG cb; // Count of bytes in hglobal
  47. } WRITEHGLOBAL;
  48. // the following macro (should be an in-line function...) defines
  49. // the formula by which in-memory buffers will grow. It is exponential
  50. // (sort of "if we needed this much memory, chances are we'll need at
  51. // least as much more) but the actual growth factor should be played with
  52. // to achieve better performance across most common scenarios
  53. #define GROW_BUFFER(cbCurrentSize, cbRequestedGrowth) (ULONG)max(2*(cbCurrentSize), (cbCurrentSize) + 2*(cbRequestedGrowth))
  54. //DWORD packed flags for PasteDataObjectToRange. Make sure new values
  55. //are assigned such that flags can be or'd together.
  56. #define PDOR_NONE 0x00000000 //No flags
  57. #define PDOR_NOQUERY 0x00000001 //Do not call QueryAcceptData
  58. #define PDOR_DROP 0x00000002 //This is a drop operation
  59. class CLightDTEngine
  60. {
  61. public:
  62. CLightDTEngine();
  63. ~CLightDTEngine();
  64. void Init(CTxtEdit * ped);
  65. void ReleaseDropTarget();
  66. void Destroy();
  67. // clipboard
  68. HRESULT CopyRangeToClipboard(CTxtRange *prg, LONG lStreamFormat);
  69. HRESULT CutRangeToClipboard (CTxtRange *prg, LONG lStreamFormat,
  70. IUndoBuilder *publdr);
  71. DWORD CanPaste( IDataObject *pdo, CLIPFORMAT cf, DWORD flags );
  72. void FlushClipboard(void);
  73. // data object
  74. HRESULT RangeToDataObject( CTxtRange *prg, LONG lStreamFormat,
  75. IDataObject **ppdo );
  76. HRESULT PasteDataObjectToRange( IDataObject *pdo, CTxtRange *prg,
  77. CLIPFORMAT cf, REPASTESPECIAL *rps,
  78. IUndoBuilder *publdr, DWORD dwFlags );
  79. HRESULT CreateOleObjFromDataObj( IDataObject *pdo, CTxtRange *prg,
  80. REPASTESPECIAL *rps, INT iFormatEtc,
  81. IUndoBuilder *publdr );
  82. // drag drop
  83. HRESULT GetDropTarget( IDropTarget **ppDropTarget );
  84. HRESULT StartDrag( CTxtSelection *psel, IUndoBuilder *publdr );
  85. BOOL fInDrag();
  86. // file I/O
  87. LONG LoadFromEs( CTxtRange *prg, LONG lStreamFormat, EDITSTREAM *pes,
  88. BOOL fTestLimit, IUndoBuilder *publdr);
  89. LONG SaveToEs( CTxtRange *prg, LONG lStreamFormat,
  90. EDITSTREAM *pes );
  91. // conversion routines
  92. HGLOBAL AnsiPlainTextFromRange( CTxtRange *prg );
  93. HGLOBAL UnicodePlainTextFromRange( CTxtRange *prg );
  94. HGLOBAL RtfFromRange( CTxtRange *prg, LONG lStreamFormat );
  95. // direct clipboard support
  96. HRESULT RenderClipboardFormat(WPARAM wFmt);
  97. HRESULT RenderAllClipboardFormats();
  98. HRESULT DestroyClipboard();
  99. LONG ReadPlainText( CTxtRange *prg, EDITSTREAM *pes, BOOL fTestLimit,
  100. IUndoBuilder *publdr, LONG lStreamFormat);
  101. protected:
  102. LONG WritePlainText( CTxtRange *prg, EDITSTREAM *pes, LONG lStreamFormat);
  103. HRESULT HGlobalToRange(DWORD dwFormatIndex, HGLOBAL hGlobal, LPTSTR ptext,
  104. CTxtRange *prg, IUndoBuilder * publdr);
  105. HRESULT DIBToRange(HGLOBAL hGlobal, CTxtRange *prg, IUndoBuilder * publdr);
  106. LONG GetStreamCodePage(LONG lStreamFormat);
  107. CTxtEdit * _ped;
  108. CDropTarget * _pdt; // the current drop target
  109. IDataObject * _pdo; // data object that may be on the clipboard.
  110. BYTE _fUseLimit; // Whether to use limit text in calculation
  111. // Note: if we need more flags do the bit
  112. // field thing.
  113. BYTE _fOleless; // Ole clipboard support?
  114. };
  115. /*
  116. * CLightDTEngine::Init (ped)
  117. *
  118. * @mfunc
  119. * initializes the object
  120. */
  121. inline void CLightDTEngine::Init(
  122. CTxtEdit *ped) // @parm text
  123. {
  124. _ped = ped;
  125. }
  126. /*
  127. * CLightDTEngine::ReleaseDropTarget (ped)
  128. *
  129. * @mfunc
  130. * Releases the drop target if there is one.
  131. */
  132. inline void CLightDTEngine::ReleaseDropTarget()
  133. {
  134. if (_pdt)
  135. {
  136. _pdt->Release();
  137. _pdt = NULL;
  138. }
  139. }
  140. /*
  141. * CLightDTEngine::fInDrag ()
  142. *
  143. * @mfunc
  144. * Tells whether a drag operation is occuring
  145. */
  146. inline BOOL CLightDTEngine::fInDrag()
  147. {
  148. return (_pdt != NULL) ? _pdt->fInDrag() : FALSE;
  149. }
  150. #endif // !__LDTE_H__