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.

163 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 2001, Microsoft Corporation
  3. Module Name:
  4. polytext.h
  5. Abstract:
  6. This file defines the CPolyText Class.
  7. Author:
  8. Revision History:
  9. Notes:
  10. --*/
  11. #ifndef _POLYTEXT_H_
  12. #define _POLYTEXT_H_
  13. #include "template.h"
  14. #include "imc.h"
  15. class CCompClauseStore
  16. {
  17. public:
  18. CCompClauseStore()
  19. {
  20. m_lpCompClause = NULL;
  21. m_dwCompClauseLen = 0;
  22. }
  23. virtual ~CCompClauseStore()
  24. {
  25. ClearString();
  26. }
  27. void ClearString()
  28. {
  29. if (m_lpCompClause)
  30. {
  31. delete m_lpCompClause;
  32. m_lpCompClause = NULL;
  33. }
  34. }
  35. HRESULT Set(IMCCLock<COMPOSITIONSTRING> &comp)
  36. {
  37. LPDWORD lpCompClause = (LPDWORD)comp.GetOffsetPointer(comp->dwCompClauseOffset);
  38. m_dwCompClauseLen = comp->dwCompClauseLen / sizeof(DWORD);
  39. if (m_dwCompClauseLen < 2)
  40. return E_FAIL;
  41. ClearString();
  42. m_lpCompClause = new DWORD[m_dwCompClauseLen + 1];
  43. if (!m_lpCompClause)
  44. return E_OUTOFMEMORY;
  45. Assert(!*lpCompClause);
  46. // memcpy(m_lpCompClause, (lpCompClause + 1),
  47. // (m_dwCompClauseLen - 1) * sizeof(DWORD));
  48. memcpy(m_lpCompClause, lpCompClause,
  49. m_dwCompClauseLen * sizeof(DWORD));
  50. Shift(0);
  51. return S_OK;
  52. }
  53. HRESULT Shift(DWORD dwPos)
  54. {
  55. DWORD i;
  56. DWORD dwCur = 0;
  57. if (!m_lpCompClause)
  58. return E_FAIL;
  59. for (i = 0; i < m_dwCompClauseLen; i++)
  60. {
  61. if (m_lpCompClause[i] > dwPos)
  62. m_lpCompClause[dwCur++] = m_lpCompClause[i] - dwPos;
  63. }
  64. m_lpCompClause[dwCur] = (DWORD)(-1);
  65. m_dwCompClauseLen = dwCur;
  66. return S_OK;
  67. }
  68. BOOL IsAtFirstBoundary(DWORD dwPos)
  69. {
  70. if (!m_lpCompClause)
  71. return FALSE;
  72. if (!m_lpCompClause[0])
  73. {
  74. Assert(0);
  75. return FALSE;
  76. }
  77. if (m_lpCompClause[0] == dwPos)
  78. return TRUE;
  79. return FALSE;
  80. }
  81. HRESULT Copy(CCompClauseStore *compclause)
  82. {
  83. m_dwCompClauseLen = compclause->m_dwCompClauseLen;
  84. if (m_dwCompClauseLen < 2)
  85. return E_FAIL;
  86. ClearString();
  87. m_lpCompClause = new DWORD[m_dwCompClauseLen + 1];
  88. if (!m_lpCompClause)
  89. return E_OUTOFMEMORY;
  90. Assert(*compclause->m_lpCompClause);
  91. memcpy(m_lpCompClause, compclause->m_lpCompClause,
  92. m_dwCompClauseLen * sizeof(DWORD));
  93. Shift(0);
  94. return S_OK;
  95. }
  96. private:
  97. LPDWORD m_lpCompClause;
  98. DWORD m_dwCompClauseLen;
  99. };
  100. class CPolyText
  101. {
  102. public:
  103. CPolyText() { }
  104. virtual ~CPolyText() { }
  105. public:
  106. HRESULT SplitPolyStringAndAttr(IMCLock& imc, HDC hDC, POLYTEXTW poly_text, PBYTE pbAttrPtr, CCompClauseStore *compclause);
  107. HRESULT SplitPolyStringAndAttr(IMCLock& imc, HDC hDC, POLYTEXTW poly_text);
  108. HRESULT RemoveLastLine(BOOL fVert);
  109. HRESULT ShiftPolyText(int dx, int dy);
  110. HRESULT GetPolyTextExtent(POINT pt, HDC hDC, BOOL fVert, ULONG *puEdge, ULONG *puQuadrant);
  111. HRESULT GetPolyTextExtentRect(DWORD &ach, HDC hDC, BOOL fVert, BOOL fGetLastPoint, RECT *prc);
  112. void RemoveAll()
  113. {
  114. m_poly_text.RemoveAll();
  115. m_TfGuidAtom.RemoveAll();
  116. }
  117. INT_PTR GetPolySize() { return m_poly_text.GetSize(); }
  118. const POLYTEXTW* GetPolyData() const { return m_poly_text.GetData(); }
  119. POLYTEXTW GetPolyAt(int n) const { return m_poly_text.GetAt(n); }
  120. INT_PTR GetAttrSize() { return m_TfGuidAtom.GetSize(); }
  121. const TfGuidAtom* GetAttrData() const { return m_TfGuidAtom.GetData(); }
  122. TfGuidAtom GetAttrAt(int n) const { return m_TfGuidAtom.GetAt(n); }
  123. private:
  124. CArray<POLYTEXTW, POLYTEXTW> m_poly_text;
  125. CArray<TfGuidAtom, TfGuidAtom> m_TfGuidAtom;
  126. };
  127. #endif // _POLYTEXT_H_