| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef _FX_TEXTBREAK | 7 #ifndef _FX_TEXTBREAK |
| 8 #define _FX_TEXTBREAK | 8 #define _FX_TEXTBREAK |
| 9 class IFX_Font; | 9 class IFX_Font; |
| 10 class CFX_Char; | 10 class CFX_Char; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #define FX_TXTLINEALIGNMENT_JustifiedRight (FX_TXTLINEALIGNMENT_Rig
ht | FX_TXTLINEALIGNMENT_Justified) | 53 #define FX_TXTLINEALIGNMENT_JustifiedRight (FX_TXTLINEALIGNMENT_Rig
ht | FX_TXTLINEALIGNMENT_Justified) |
| 54 #define FX_TXTLINEALIGNMENT_DistributedLeft (FX_TXTLINEALIGNMENT_Lef
t | FX_TXTLINEALIGNMENT_Distributed) | 54 #define FX_TXTLINEALIGNMENT_DistributedLeft (FX_TXTLINEALIGNMENT_Lef
t | FX_TXTLINEALIGNMENT_Distributed) |
| 55 #define FX_TXTLINEALIGNMENT_DistributedCenter (FX_TXTLINEALIGNMENT_Center | FX
_TXTLINEALIGNMENT_Distributed) | 55 #define FX_TXTLINEALIGNMENT_DistributedCenter (FX_TXTLINEALIGNMENT_Center | FX
_TXTLINEALIGNMENT_Distributed) |
| 56 #define FX_TXTLINEALIGNMENT_DistributedRight (FX_TXTLINEALIGNMENT_Right | FX_
TXTLINEALIGNMENT_Distributed) | 56 #define FX_TXTLINEALIGNMENT_DistributedRight (FX_TXTLINEALIGNMENT_Right | FX_
TXTLINEALIGNMENT_Distributed) |
| 57 #define FX_TXTLINEALIGNMENT_LowerMask 0x03 | 57 #define FX_TXTLINEALIGNMENT_LowerMask 0x03 |
| 58 #define FX_TXTLINEALIGNMENT_HigherMask 0x0C | 58 #define FX_TXTLINEALIGNMENT_HigherMask 0x0C |
| 59 #define FX_TXTBREAK_MinimumTabWidth 160000 | 59 #define FX_TXTBREAK_MinimumTabWidth 160000 |
| 60 class IFX_TxtAccess | 60 class IFX_TxtAccess |
| 61 { | 61 { |
| 62 public: | 62 public: |
| 63 virtual FX_WCHAR» GetChar(FX_LPVOID pIdentity, FX_INT32 index) const = 0; | 63 virtual FX_WCHAR» GetChar(FX_LPVOID pIdentity, int32_t index) const = 0; |
| 64 virtual FX_INT32» GetWidth(FX_LPVOID pIdentity, FX_INT32 index) const = 0; | 64 virtual int32_t» GetWidth(FX_LPVOID pIdentity, int32_t index) const = 0; |
| 65 }; | 65 }; |
| 66 typedef struct _FX_TXTRUN { | 66 typedef struct _FX_TXTRUN { |
| 67 _FX_TXTRUN() | 67 _FX_TXTRUN() |
| 68 { | 68 { |
| 69 pAccess = NULL; | 69 pAccess = NULL; |
| 70 pIdentity = NULL; | 70 pIdentity = NULL; |
| 71 pStr = NULL; | 71 pStr = NULL; |
| 72 pWidths = NULL; | 72 pWidths = NULL; |
| 73 iLength = 0; | 73 iLength = 0; |
| 74 pFont = NULL; | 74 pFont = NULL; |
| 75 fFontSize = 12; | 75 fFontSize = 12; |
| 76 dwStyles = 0; | 76 dwStyles = 0; |
| 77 iHorizontalScale = 100; | 77 iHorizontalScale = 100; |
| 78 iVerticalScale = 100; | 78 iVerticalScale = 100; |
| 79 iCharRotation = 0; | 79 iCharRotation = 0; |
| 80 dwCharStyles = 0; | 80 dwCharStyles = 0; |
| 81 pRect = NULL; | 81 pRect = NULL; |
| 82 wLineBreakChar = L'\n'; | 82 wLineBreakChar = L'\n'; |
| 83 bSkipSpace = TRUE; | 83 bSkipSpace = TRUE; |
| 84 } | 84 } |
| 85 IFX_TxtAccess *pAccess; | 85 IFX_TxtAccess *pAccess; |
| 86 FX_LPVOID pIdentity; | 86 FX_LPVOID pIdentity; |
| 87 FX_LPCWSTR pStr; | 87 FX_LPCWSTR pStr; |
| 88 FX_INT32» » *pWidths; | 88 int32_t» » *pWidths; |
| 89 FX_INT32» » iLength; | 89 int32_t» » iLength; |
| 90 IFX_Font *pFont; | 90 IFX_Font *pFont; |
| 91 FX_FLOAT fFontSize; | 91 FX_FLOAT fFontSize; |
| 92 FX_DWORD dwStyles; | 92 FX_DWORD dwStyles; |
| 93 FX_INT32» » iHorizontalScale; | 93 int32_t» » iHorizontalScale; |
| 94 FX_INT32» » iVerticalScale; | 94 int32_t» » iVerticalScale; |
| 95 FX_INT32» » iCharRotation; | 95 int32_t» » iCharRotation; |
| 96 FX_DWORD dwCharStyles; | 96 FX_DWORD dwCharStyles; |
| 97 FX_LPCRECTF pRect; | 97 FX_LPCRECTF pRect; |
| 98 FX_WCHAR wLineBreakChar; | 98 FX_WCHAR wLineBreakChar; |
| 99 FX_BOOL bSkipSpace; | 99 FX_BOOL bSkipSpace; |
| 100 } FX_TXTRUN, * FX_LPTXTRUN; | 100 } FX_TXTRUN, * FX_LPTXTRUN; |
| 101 typedef FX_TXTRUN const * FX_LPCTXTRUN; | 101 typedef FX_TXTRUN const * FX_LPCTXTRUN; |
| 102 class CFX_TxtPiece : public CFX_Target | 102 class CFX_TxtPiece : public CFX_Target |
| 103 { | 103 { |
| 104 public: | 104 public: |
| 105 CFX_TxtPiece() : m_dwStatus(FX_TXTBREAK_PieceBreak) | 105 CFX_TxtPiece() : m_dwStatus(FX_TXTBREAK_PieceBreak) |
| 106 , m_iStartPos(0) | 106 , m_iStartPos(0) |
| 107 , m_iWidth(-1) | 107 , m_iWidth(-1) |
| 108 , m_iStartChar(0) | 108 , m_iStartChar(0) |
| 109 , m_iChars(0) | 109 , m_iChars(0) |
| 110 , m_iBidiLevel(0) | 110 , m_iBidiLevel(0) |
| 111 , m_iBidiPos(0) | 111 , m_iBidiPos(0) |
| 112 , m_iHorizontalScale(100) | 112 , m_iHorizontalScale(100) |
| 113 , m_iVerticalScale(100) | 113 , m_iVerticalScale(100) |
| 114 , m_dwCharStyles(0) | 114 , m_dwCharStyles(0) |
| 115 , m_pChars(NULL) | 115 , m_pChars(NULL) |
| 116 , m_pUserData(NULL) | 116 , m_pUserData(NULL) |
| 117 { | 117 { |
| 118 } | 118 } |
| 119 FX_INT32 GetEndPos() const | 119 int32_t GetEndPos() const |
| 120 { | 120 { |
| 121 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; | 121 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; |
| 122 } | 122 } |
| 123 FX_INT32 GetLength() const | 123 int32_t GetLength() const |
| 124 { | 124 { |
| 125 return m_iChars; | 125 return m_iChars; |
| 126 } | 126 } |
| 127 FX_INT32 GetEndChar() const | 127 int32_t GetEndChar() const |
| 128 { | 128 { |
| 129 return m_iStartChar + m_iChars; | 129 return m_iStartChar + m_iChars; |
| 130 } | 130 } |
| 131 CFX_TxtChar* GetCharPtr(FX_INT32 index) const | 131 CFX_TxtChar* GetCharPtr(int32_t index) const |
| 132 { | 132 { |
| 133 FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL); | 133 FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL); |
| 134 return m_pChars->GetDataPtr(m_iStartChar + index); | 134 return m_pChars->GetDataPtr(m_iStartChar + index); |
| 135 } | 135 } |
| 136 void GetString(FX_LPWSTR pText) const | 136 void GetString(FX_LPWSTR pText) const |
| 137 { | 137 { |
| 138 FXSYS_assert(pText != NULL); | 138 FXSYS_assert(pText != NULL); |
| 139 FX_INT32 iEndChar = m_iStartChar + m_iChars; | 139 int32_t iEndChar = m_iStartChar + m_iChars; |
| 140 CFX_Char *pChar; | 140 CFX_Char *pChar; |
| 141 for (FX_INT32 i = m_iStartChar; i < iEndChar; i ++) { | 141 for (int32_t i = m_iStartChar; i < iEndChar; i ++) { |
| 142 pChar = m_pChars->GetDataPtr(i); | 142 pChar = m_pChars->GetDataPtr(i); |
| 143 *pText ++ = (FX_WCHAR)pChar->m_wCharCode; | 143 *pText ++ = (FX_WCHAR)pChar->m_wCharCode; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 void GetString(CFX_WideString &wsText) const | 147 void GetString(CFX_WideString &wsText) const |
| 148 { | 148 { |
| 149 FX_LPWSTR pText = wsText.GetBuffer(m_iChars); | 149 FX_LPWSTR pText = wsText.GetBuffer(m_iChars); |
| 150 GetString(pText); | 150 GetString(pText); |
| 151 wsText.ReleaseBuffer(m_iChars); | 151 wsText.ReleaseBuffer(m_iChars); |
| 152 } | 152 } |
| 153 void GetWidths(FX_INT32 *pWidths) const | 153 void GetWidths(int32_t *pWidths) const |
| 154 { | 154 { |
| 155 FXSYS_assert(pWidths != NULL); | 155 FXSYS_assert(pWidths != NULL); |
| 156 FX_INT32 iEndChar = m_iStartChar + m_iChars; | 156 int32_t iEndChar = m_iStartChar + m_iChars; |
| 157 CFX_Char *pChar; | 157 CFX_Char *pChar; |
| 158 for (FX_INT32 i = m_iStartChar; i < iEndChar; i ++) { | 158 for (int32_t i = m_iStartChar; i < iEndChar; i ++) { |
| 159 pChar = m_pChars->GetDataPtr(i); | 159 pChar = m_pChars->GetDataPtr(i); |
| 160 *pWidths ++ = pChar->m_iCharWidth; | 160 *pWidths ++ = pChar->m_iCharWidth; |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 FX_DWORD m_dwStatus; | 163 FX_DWORD m_dwStatus; |
| 164 FX_INT32» » » m_iStartPos; | 164 int32_t» » » m_iStartPos; |
| 165 FX_INT32» » » m_iWidth; | 165 int32_t» » » m_iWidth; |
| 166 FX_INT32» » » m_iStartChar; | 166 int32_t» » » m_iStartChar; |
| 167 FX_INT32» » » m_iChars; | 167 int32_t» » » m_iChars; |
| 168 FX_INT32» » » m_iBidiLevel; | 168 int32_t» » » m_iBidiLevel; |
| 169 FX_INT32» » » m_iBidiPos; | 169 int32_t» » » m_iBidiPos; |
| 170 FX_INT32» » » m_iHorizontalScale; | 170 int32_t» » » m_iHorizontalScale; |
| 171 FX_INT32» » » m_iVerticalScale; | 171 int32_t» » » m_iVerticalScale; |
| 172 FX_DWORD m_dwCharStyles; | 172 FX_DWORD m_dwCharStyles; |
| 173 CFX_TxtCharArray *m_pChars; | 173 CFX_TxtCharArray *m_pChars; |
| 174 FX_LPVOID m_pUserData; | 174 FX_LPVOID m_pUserData; |
| 175 }; | 175 }; |
| 176 typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray; | 176 typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray; |
| 177 class IFX_TxtBreak | 177 class IFX_TxtBreak |
| 178 { | 178 { |
| 179 public: | 179 public: |
| 180 static IFX_TxtBreak* Create(FX_DWORD dwPolicies); | 180 static IFX_TxtBreak* Create(FX_DWORD dwPolicies); |
| 181 virtual void Release() = 0; | 181 virtual void Release() = 0; |
| 182 virtual void SetLineWidth(FX_FLOAT fLineWidth) = 0; | 182 virtual void SetLineWidth(FX_FLOAT fLineWidth) = 0; |
| 183 virtual void SetLinePos(FX_FLOAT fLinePos) = 0; | 183 virtual void SetLinePos(FX_FLOAT fLinePos) = 0; |
| 184 virtual FX_DWORD GetLayoutStyles() const = 0; | 184 virtual FX_DWORD GetLayoutStyles() const = 0; |
| 185 virtual void SetLayoutStyles(FX_DWORD dwLayoutStyles)
= 0; | 185 virtual void SetLayoutStyles(FX_DWORD dwLayoutStyles)
= 0; |
| 186 virtual void SetFont(IFX_Font *pFont) = 0; | 186 virtual void SetFont(IFX_Font *pFont) = 0; |
| 187 virtual void SetFontSize(FX_FLOAT fFontSize) = 0; | 187 virtual void SetFontSize(FX_FLOAT fFontSize) = 0; |
| 188 virtual void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL
bEquidistant) = 0; | 188 virtual void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL
bEquidistant) = 0; |
| 189 virtual void SetDefaultChar(FX_WCHAR wch) = 0; | 189 virtual void SetDefaultChar(FX_WCHAR wch) = 0; |
| 190 virtual void SetParagraphBreakChar(FX_WCHAR wch) = 0; | 190 virtual void SetParagraphBreakChar(FX_WCHAR wch) = 0; |
| 191 virtual void SetLineBreakTolerance(FX_FLOAT fToleranc
e) = 0; | 191 virtual void SetLineBreakTolerance(FX_FLOAT fToleranc
e) = 0; |
| 192 virtual void» » » SetHorizontalScale(FX_INT32 iScale) = 0; | 192 virtual void» » » SetHorizontalScale(int32_t iScale) = 0; |
| 193 virtual void» » » SetVerticalScale(FX_INT32 iScale) = 0; | 193 virtual void» » » SetVerticalScale(int32_t iScale) = 0; |
| 194 virtual void» » » SetCharRotation(FX_INT32 iCharRotation)
= 0; | 194 virtual void» » » SetCharRotation(int32_t iCharRotation) =
0; |
| 195 virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0; | 195 virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0; |
| 196 virtual void» » » SetAlignment(FX_INT32 iAlignment) = 0; | 196 virtual void» » » SetAlignment(int32_t iAlignment) = 0; |
| 197 virtual FX_DWORD GetContextCharStyles() const = 0; | 197 virtual FX_DWORD GetContextCharStyles() const = 0; |
| 198 virtual void SetContextCharStyles(FX_DWORD dwCharStyl
es) = 0; | 198 virtual void SetContextCharStyles(FX_DWORD dwCharStyl
es) = 0; |
| 199 virtual void SetCombWidth(FX_FLOAT fCombWidth) = 0; | 199 virtual void SetCombWidth(FX_FLOAT fCombWidth) = 0; |
| 200 virtual void SetUserData(FX_LPVOID pUserData) = 0; | 200 virtual void SetUserData(FX_LPVOID pUserData) = 0; |
| 201 virtual FX_DWORD AppendChar(FX_WCHAR wch)
= 0; | 201 virtual FX_DWORD AppendChar(FX_WCHAR wch)
= 0; |
| 202 virtual FX_DWORD EndBreak(FX_DWORD dwStat
us = FX_TXTBREAK_PieceBreak) = 0; | 202 virtual FX_DWORD EndBreak(FX_DWORD dwStat
us = FX_TXTBREAK_PieceBreak) = 0; |
| 203 virtual FX_INT32» » » » » CountBreakChars() const
= 0; | 203 virtual int32_t» » » » » CountBreakChars() const
= 0; |
| 204 virtual FX_INT32» » » » » CountBreakPieces() const
= 0; | 204 virtual int32_t» » » » » CountBreakPieces() const
= 0; |
| 205 virtual const CFX_TxtPiece*»» » GetBreakPiece(FX_INT32 index) co
nst = 0; | 205 virtual const CFX_TxtPiece*»» » GetBreakPiece(int32_t index) con
st = 0; |
| 206 virtual void ClearBreakPieces
() = 0; | 206 virtual void ClearBreakPieces
() = 0; |
| 207 virtual void Reset() = 0; | 207 virtual void Reset() = 0; |
| 208 virtual FX_INT32» » GetDisplayPos(FX_LPCTXTRUN pTxtRun, FXTEXT_CHARP
OS *pCharPos, FX_BOOL bCharCode = FALSE, CFX_WideString *pWSForms = NULL, FX_Adj
ustCharDisplayPos pAdjustPos = NULL) const = 0; | 208 virtual int32_t» » GetDisplayPos(FX_LPCTXTRUN pTxtRun, FXTEXT_CHARP
OS *pCharPos, FX_BOOL bCharCode = FALSE, CFX_WideString *pWSForms = NULL, FX_Adj
ustCharDisplayPos pAdjustPos = NULL) const = 0; |
| 209 virtual FX_INT32» » GetCharRects(FX_LPCTXTRUN pTxtRun, CFX_RectFArra
y &rtArray, FX_BOOL bCharBBox = FALSE) const = 0; | 209 virtual int32_t» » GetCharRects(FX_LPCTXTRUN pTxtRun, CFX_RectFArra
y &rtArray, FX_BOOL bCharBBox = FALSE) const = 0; |
| 210 }; | 210 }; |
| 211 #endif | 211 #endif |
| OLD | NEW |