Chromium Code Reviews| 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 XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ | 7 #ifndef XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ |
| 8 #define XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ | 8 #define XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ |
| 9 | 9 |
| 10 #include "core/fxcrt/include/fx_basic.h" | 10 #include "core/fxcrt/include/fx_basic.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 int32_t iHorizontalScale; | 79 int32_t iHorizontalScale; |
| 80 int32_t iVerticalScale; | 80 int32_t iVerticalScale; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 class CFX_RTFPiece : public CFX_Target { | 83 class CFX_RTFPiece : public CFX_Target { |
| 84 public: | 84 public: |
| 85 CFX_RTFPiece(); | 85 CFX_RTFPiece(); |
| 86 ~CFX_RTFPiece() override; | 86 ~CFX_RTFPiece() override; |
| 87 | 87 |
| 88 void AppendChar(const CFX_RTFChar& tc) { | 88 void AppendChar(const CFX_RTFChar& tc) { |
| 89 ASSERT(m_pChars != NULL); | 89 ASSERT(m_pChars); |
| 90 m_pChars->Add(tc); | 90 m_pChars->Add(tc); |
| 91 if (m_iWidth < 0) { | 91 if (m_iWidth < 0) { |
| 92 m_iWidth = tc.m_iCharWidth; | 92 m_iWidth = tc.m_iCharWidth; |
| 93 } else { | 93 } else { |
| 94 m_iWidth += tc.m_iCharWidth; | 94 m_iWidth += tc.m_iCharWidth; |
| 95 } | 95 } |
| 96 m_iChars++; | 96 m_iChars++; |
| 97 } | 97 } |
| 98 int32_t GetEndPos() const { | 98 int32_t GetEndPos() const { |
| 99 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; | 99 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; |
| 100 } | 100 } |
| 101 int32_t GetLength() const { return m_iChars; } | 101 int32_t GetLength() const { return m_iChars; } |
| 102 int32_t GetEndChar() const { return m_iStartChar + m_iChars; } | 102 int32_t GetEndChar() const { return m_iStartChar + m_iChars; } |
| 103 CFX_RTFChar& GetChar(int32_t index) { | 103 CFX_RTFChar& GetChar(int32_t index) { |
| 104 ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); | 104 ASSERT(index > -1 && index < m_iChars && m_pChars); |
| 105 return *m_pChars->GetDataPtr(m_iStartChar + index); | 105 return *m_pChars->GetDataPtr(m_iStartChar + index); |
| 106 } | 106 } |
| 107 CFX_RTFChar* GetCharPtr(int32_t index) const { | 107 CFX_RTFChar* GetCharPtr(int32_t index) const { |
| 108 ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); | 108 ASSERT(index > -1 && index < m_iChars && m_pChars); |
| 109 return m_pChars->GetDataPtr(m_iStartChar + index); | 109 return m_pChars->GetDataPtr(m_iStartChar + index); |
| 110 } | 110 } |
| 111 void GetString(FX_WCHAR* pText) const { | 111 void GetString(FX_WCHAR* pText) const { |
| 112 ASSERT(pText != NULL); | 112 ASSERT(pText); |
| 113 int32_t iEndChar = m_iStartChar + m_iChars; | 113 int32_t iEndChar = m_iStartChar + m_iChars; |
| 114 CFX_RTFChar* pChar; | 114 CFX_RTFChar* pChar; |
| 115 for (int32_t i = m_iStartChar; i < iEndChar; i++) { | 115 for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
| 116 pChar = m_pChars->GetDataPtr(i); | 116 pChar = m_pChars->GetDataPtr(i); |
| 117 *pText++ = (FX_WCHAR)pChar->m_wCharCode; | 117 *pText++ = (FX_WCHAR)pChar->m_wCharCode; |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 void GetString(CFX_WideString& wsText) const { | 120 void GetString(CFX_WideString& wsText) const { |
| 121 FX_WCHAR* pText = wsText.GetBuffer(m_iChars); | 121 FX_WCHAR* pText = wsText.GetBuffer(m_iChars); |
| 122 GetString(pText); | 122 GetString(pText); |
| 123 wsText.ReleaseBuffer(m_iChars); | 123 wsText.ReleaseBuffer(m_iChars); |
| 124 } | 124 } |
| 125 void GetWidths(int32_t* pWidths) const { | 125 void GetWidths(int32_t* pWidths) const { |
| 126 ASSERT(pWidths != NULL); | 126 ASSERT(pWidths); |
| 127 int32_t iEndChar = m_iStartChar + m_iChars; | 127 int32_t iEndChar = m_iStartChar + m_iChars; |
| 128 CFX_RTFChar* pChar; | 128 CFX_RTFChar* pChar; |
| 129 for (int32_t i = m_iStartChar; i < iEndChar; i++) { | 129 for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
| 130 pChar = m_pChars->GetDataPtr(i); | 130 pChar = m_pChars->GetDataPtr(i); |
| 131 *pWidths++ = pChar->m_iCharWidth; | 131 *pWidths++ = pChar->m_iCharWidth; |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 void Reset() { | 134 void Reset() { |
| 135 m_dwStatus = FX_RTFBREAK_PieceBreak; | 135 m_dwStatus = FX_RTFBREAK_PieceBreak; |
| 136 if (m_iWidth > -1) { | 136 if (m_iWidth > -1) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 ASSERT(index > -1 && index < m_LinePieces.GetSize()); | 187 ASSERT(index > -1 && index < m_LinePieces.GetSize()); |
| 188 return m_LinePieces.GetPtrAt(index); | 188 return m_LinePieces.GetPtrAt(index); |
| 189 } | 189 } |
| 190 int32_t GetLineEnd() const { return m_iStart + m_iWidth; } | 190 int32_t GetLineEnd() const { return m_iStart + m_iWidth; } |
| 191 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { | 191 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { |
| 192 CFX_RTFChar* pChar; | 192 CFX_RTFChar* pChar; |
| 193 IFX_Retainable* pUnknown; | 193 IFX_Retainable* pUnknown; |
| 194 int32_t iCount = m_LineChars.GetSize(); | 194 int32_t iCount = m_LineChars.GetSize(); |
| 195 for (int32_t i = 0; i < iCount; i++) { | 195 for (int32_t i = 0; i < iCount; i++) { |
| 196 pChar = m_LineChars.GetDataPtr(i); | 196 pChar = m_LineChars.GetDataPtr(i); |
| 197 if ((pUnknown = pChar->m_pUserData) != NULL) { | 197 pUnknown = pChar->m_pUserData; |
| 198 if (pUnknown) | |
|
Lei Zhang
2016/06/23 17:56:00
Just get rid of |pUnknown| ?
dsinclair
2016/06/23 18:46:53
Done.
| |
| 198 pUnknown->Release(); | 199 pUnknown->Release(); |
| 199 } | |
| 200 } | 200 } |
| 201 m_LineChars.RemoveAll(); | 201 m_LineChars.RemoveAll(); |
| 202 m_LinePieces.RemoveAll(bLeaveMemory); | 202 m_LinePieces.RemoveAll(bLeaveMemory); |
| 203 m_iWidth = 0; | 203 m_iWidth = 0; |
| 204 m_iArabicChars = 0; | 204 m_iArabicChars = 0; |
| 205 m_iMBCSChars = 0; | 205 m_iMBCSChars = 0; |
| 206 } | 206 } |
| 207 | 207 |
| 208 CFX_RTFCharArray m_LineChars; | 208 CFX_RTFCharArray m_LineChars; |
| 209 CFX_RTFPieceArray m_LinePieces; | 209 CFX_RTFPieceArray m_LinePieces; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 uint32_t AppendChar(FX_WCHAR wch); | 242 uint32_t AppendChar(FX_WCHAR wch); |
| 243 uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak); | 243 uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak); |
| 244 int32_t CountBreakPieces() const; | 244 int32_t CountBreakPieces() const; |
| 245 const CFX_RTFPiece* GetBreakPiece(int32_t index) const; | 245 const CFX_RTFPiece* GetBreakPiece(int32_t index) const; |
| 246 void GetLineRect(CFX_RectF& rect) const; | 246 void GetLineRect(CFX_RectF& rect) const; |
| 247 void ClearBreakPieces(); | 247 void ClearBreakPieces(); |
| 248 void Reset(); | 248 void Reset(); |
| 249 int32_t GetDisplayPos(const FX_RTFTEXTOBJ* pText, | 249 int32_t GetDisplayPos(const FX_RTFTEXTOBJ* pText, |
| 250 FXTEXT_CHARPOS* pCharPos, | 250 FXTEXT_CHARPOS* pCharPos, |
| 251 FX_BOOL bCharCode = FALSE, | 251 FX_BOOL bCharCode = FALSE, |
| 252 CFX_WideString* pWSForms = NULL, | 252 CFX_WideString* pWSForms = nullptr, |
| 253 FX_AdjustCharDisplayPos pAdjustPos = NULL) const; | 253 FX_AdjustCharDisplayPos pAdjustPos = nullptr) const; |
| 254 int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, | 254 int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, |
| 255 CFX_RectFArray& rtArray, | 255 CFX_RectFArray& rtArray, |
| 256 FX_BOOL bCharBBox = FALSE) const; | 256 FX_BOOL bCharBBox = FALSE) const; |
| 257 uint32_t AppendChar_CharCode(FX_WCHAR wch); | 257 uint32_t AppendChar_CharCode(FX_WCHAR wch); |
| 258 uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); | 258 uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); |
| 259 uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); | 259 uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); |
| 260 uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); | 260 uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); |
| 261 uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); | 261 uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); |
| 262 uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); | 262 uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); |
| 263 | 263 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 FX_CHARTYPE m_eCharType; | 317 FX_CHARTYPE m_eCharType; |
| 318 uint32_t m_dwIdentity; | 318 uint32_t m_dwIdentity; |
| 319 CFX_RTFLine m_RTFLine1; | 319 CFX_RTFLine m_RTFLine1; |
| 320 CFX_RTFLine m_RTFLine2; | 320 CFX_RTFLine m_RTFLine2; |
| 321 CFX_RTFLine* m_pCurLine; | 321 CFX_RTFLine* m_pCurLine; |
| 322 int32_t m_iReady; | 322 int32_t m_iReady; |
| 323 int32_t m_iTolerance; | 323 int32_t m_iTolerance; |
| 324 }; | 324 }; |
| 325 | 325 |
| 326 #endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ | 326 #endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ |
| OLD | NEW |