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 #include "xfa/fde/cfde_txtedtparag.h" | 7 #include "xfa/fde/cfde_txtedtparag.h" |
8 | 8 |
9 #include "xfa/fde/cfde_txtedtbuf.h" | 9 #include "xfa/fde/cfde_txtedtbuf.h" |
10 #include "xfa/fde/cfde_txtedtbufiter.h" | 10 #include "xfa/fde/cfde_txtedtbufiter.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 const FDE_TXTEDTPARAMS* pParam = m_pEngine->GetEditParams(); | 37 const FDE_TXTEDTPARAMS* pParam = m_pEngine->GetEditParams(); |
38 FX_WCHAR wcAlias = 0; | 38 FX_WCHAR wcAlias = 0; |
39 if (pParam->dwMode & FDE_TEXTEDITMODE_Password) { | 39 if (pParam->dwMode & FDE_TEXTEDITMODE_Password) { |
40 wcAlias = m_pEngine->GetAliasChar(); | 40 wcAlias = m_pEngine->GetAliasChar(); |
41 } | 41 } |
42 std::unique_ptr<IFX_CharIter> pIter( | 42 std::unique_ptr<IFX_CharIter> pIter( |
43 new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(pTxtBuf), wcAlias)); | 43 new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(pTxtBuf), wcAlias)); |
44 pIter->SetAt(m_nCharStart); | 44 pIter->SetAt(m_nCharStart); |
45 int32_t nEndIndex = m_nCharStart + m_nCharCount; | 45 int32_t nEndIndex = m_nCharStart + m_nCharCount; |
46 CFX_ArrayTemplate<int32_t> LineBaseArr; | 46 CFX_ArrayTemplate<int32_t> LineBaseArr; |
47 FX_BOOL bReload = FALSE; | 47 bool bReload = false; |
48 uint32_t dwBreakStatus = FX_TXTBREAK_None; | 48 uint32_t dwBreakStatus = FX_TXTBREAK_None; |
49 do { | 49 do { |
50 if (bReload) { | 50 if (bReload) { |
51 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 51 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
52 } else { | 52 } else { |
53 FX_WCHAR wAppend = pIter->GetChar(); | 53 FX_WCHAR wAppend = pIter->GetChar(); |
54 dwBreakStatus = pTxtBreak->AppendChar(wAppend); | 54 dwBreakStatus = pTxtBreak->AppendChar(wAppend); |
55 } | 55 } |
56 if (pIter->GetAt() + 1 == nEndIndex && | 56 if (pIter->GetAt() + 1 == nEndIndex && |
57 dwBreakStatus < FX_TXTBREAK_LineBreak) { | 57 dwBreakStatus < FX_TXTBREAK_LineBreak) { |
58 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 58 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
59 } | 59 } |
60 if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { | 60 if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { |
61 int32_t nCount = pTxtBreak->CountBreakPieces(); | 61 int32_t nCount = pTxtBreak->CountBreakPieces(); |
62 int32_t nTotal = 0; | 62 int32_t nTotal = 0; |
63 for (int32_t j = 0; j < nCount; j++) { | 63 for (int32_t j = 0; j < nCount; j++) { |
64 const CFX_TxtPiece* Piece = pTxtBreak->GetBreakPiece(j); | 64 const CFX_TxtPiece* Piece = pTxtBreak->GetBreakPiece(j); |
65 nTotal += Piece->GetLength(); | 65 nTotal += Piece->GetLength(); |
66 } | 66 } |
67 LineBaseArr.Add(nTotal); | 67 LineBaseArr.Add(nTotal); |
68 pTxtBreak->ClearBreakPieces(); | 68 pTxtBreak->ClearBreakPieces(); |
69 } | 69 } |
70 if ((pIter->GetAt() + 1 == nEndIndex) && | 70 if ((pIter->GetAt() + 1 == nEndIndex) && |
71 (dwBreakStatus == FX_TXTBREAK_LineBreak)) { | 71 (dwBreakStatus == FX_TXTBREAK_LineBreak)) { |
72 bReload = TRUE; | 72 bReload = true; |
73 pIter->Next(TRUE); | 73 pIter->Next(true); |
74 } | 74 } |
75 } while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex)); | 75 } while (pIter->Next(false) && (pIter->GetAt() < nEndIndex)); |
76 pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 76 pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
77 pTxtBreak->ClearBreakPieces(); | 77 pTxtBreak->ClearBreakPieces(); |
78 int32_t nLineCount = LineBaseArr.GetSize(); | 78 int32_t nLineCount = LineBaseArr.GetSize(); |
79 m_nLineCount = nLineCount; | 79 m_nLineCount = nLineCount; |
80 if (m_lpData) { | 80 if (m_lpData) { |
81 m_lpData = FX_Realloc(int32_t, m_lpData, nLineCount + 1); | 81 m_lpData = FX_Realloc(int32_t, m_lpData, nLineCount + 1); |
82 } else { | 82 } else { |
83 m_lpData = FX_Alloc(int32_t, nLineCount + 1); | 83 m_lpData = FX_Alloc(int32_t, nLineCount + 1); |
84 } | 84 } |
85 int32_t* pIntArr = m_lpData; | 85 int32_t* pIntArr = m_lpData; |
(...skipping 17 matching lines...) Expand all Loading... |
103 | 103 |
104 void CFDE_TxtEdtParag::CalcLines() { | 104 void CFDE_TxtEdtParag::CalcLines() { |
105 CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); | 105 CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); |
106 CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); | 106 CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); |
107 int32_t nCount = 0; | 107 int32_t nCount = 0; |
108 uint32_t dwBreakStatus = FX_TXTBREAK_None; | 108 uint32_t dwBreakStatus = FX_TXTBREAK_None; |
109 int32_t nEndIndex = m_nCharStart + m_nCharCount; | 109 int32_t nEndIndex = m_nCharStart + m_nCharCount; |
110 std::unique_ptr<IFX_CharIter> pIter( | 110 std::unique_ptr<IFX_CharIter> pIter( |
111 new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(pTxtBuf))); | 111 new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(pTxtBuf))); |
112 pIter->SetAt(m_nCharStart); | 112 pIter->SetAt(m_nCharStart); |
113 FX_BOOL bReload = FALSE; | 113 bool bReload = false; |
114 do { | 114 do { |
115 if (bReload) { | 115 if (bReload) { |
116 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 116 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
117 } else { | 117 } else { |
118 FX_WCHAR wAppend = pIter->GetChar(); | 118 FX_WCHAR wAppend = pIter->GetChar(); |
119 dwBreakStatus = pTxtBreak->AppendChar(wAppend); | 119 dwBreakStatus = pTxtBreak->AppendChar(wAppend); |
120 } | 120 } |
121 if (pIter->GetAt() + 1 == nEndIndex && | 121 if (pIter->GetAt() + 1 == nEndIndex && |
122 dwBreakStatus < FX_TXTBREAK_LineBreak) { | 122 dwBreakStatus < FX_TXTBREAK_LineBreak) { |
123 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 123 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
124 } | 124 } |
125 if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { | 125 if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { |
126 nCount++; | 126 nCount++; |
127 pTxtBreak->ClearBreakPieces(); | 127 pTxtBreak->ClearBreakPieces(); |
128 } | 128 } |
129 if ((pIter->GetAt() + 1 == nEndIndex) && | 129 if ((pIter->GetAt() + 1 == nEndIndex) && |
130 (dwBreakStatus == FX_TXTBREAK_LineBreak)) { | 130 (dwBreakStatus == FX_TXTBREAK_LineBreak)) { |
131 bReload = TRUE; | 131 bReload = true; |
132 pIter->Next(TRUE); | 132 pIter->Next(true); |
133 } | 133 } |
134 } while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex)); | 134 } while (pIter->Next(false) && (pIter->GetAt() < nEndIndex)); |
135 pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 135 pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
136 pTxtBreak->ClearBreakPieces(); | 136 pTxtBreak->ClearBreakPieces(); |
137 m_nLineCount = nCount; | 137 m_nLineCount = nCount; |
138 } | 138 } |
139 | 139 |
140 void CFDE_TxtEdtParag::GetLineRange(int32_t nLineIndex, | 140 void CFDE_TxtEdtParag::GetLineRange(int32_t nLineIndex, |
141 int32_t& nStart, | 141 int32_t& nStart, |
142 int32_t& nCount) const { | 142 int32_t& nCount) const { |
143 int32_t* pLineBaseArr = m_lpData; | 143 int32_t* pLineBaseArr = m_lpData; |
144 ASSERT(nLineIndex < m_nLineCount); | 144 ASSERT(nLineIndex < m_nLineCount); |
145 nStart = m_nCharStart; | 145 nStart = m_nCharStart; |
146 pLineBaseArr++; | 146 pLineBaseArr++; |
147 for (int32_t i = 0; i < nLineIndex; i++) { | 147 for (int32_t i = 0; i < nLineIndex; i++) { |
148 nStart += *pLineBaseArr; | 148 nStart += *pLineBaseArr; |
149 pLineBaseArr++; | 149 pLineBaseArr++; |
150 } | 150 } |
151 nCount = *pLineBaseArr; | 151 nCount = *pLineBaseArr; |
152 } | 152 } |
OLD | NEW |