Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: xfa/fde/cfde_txtedtpage.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fde/cfde_txtedtpage.h ('k') | xfa/fde/cfde_txtedtparag.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_txtedtpage.h" 7 #include "xfa/fde/cfde_txtedtpage.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 19 matching lines...) Expand all
30 30
31 CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) 31 CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex)
32 : m_pEditEngine(pEngine), 32 : m_pEditEngine(pEngine),
33 m_PieceMassArr(100), 33 m_PieceMassArr(100),
34 m_pBgnParag(nullptr), 34 m_pBgnParag(nullptr),
35 m_pEndParag(nullptr), 35 m_pEndParag(nullptr),
36 m_nRefCount(0), 36 m_nRefCount(0),
37 m_nPageStart(-1), 37 m_nPageStart(-1),
38 m_nCharCount(0), 38 m_nCharCount(0),
39 m_nPageIndex(nPageIndex), 39 m_nPageIndex(nPageIndex),
40 m_bLoaded(FALSE) { 40 m_bLoaded(false) {
41 FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF)); 41 FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF));
42 FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF)); 42 FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF));
43 FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF)); 43 FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF));
44 FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF)); 44 FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF));
45 } 45 }
46 46
47 CFDE_TxtEdtPage::~CFDE_TxtEdtPage() { 47 CFDE_TxtEdtPage::~CFDE_TxtEdtPage() {
48 m_PieceMassArr.RemoveAll(TRUE); 48 m_PieceMassArr.RemoveAll(true);
49 } 49 }
50 50
51 CFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const { 51 CFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const {
52 return m_pEditEngine; 52 return m_pEditEngine;
53 } 53 }
54 54
55 FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() { 55 FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() {
56 return FDE_VISUALOBJ_Text; 56 return FDE_VISUALOBJ_Text;
57 } 57 }
58 58
59 void CFDE_TxtEdtPage::GetRect(FDE_TEXTEDITPIECE* hVisualObj, CFX_RectF& rt) {} 59 void CFDE_TxtEdtPage::GetRect(FDE_TEXTEDITPIECE* hVisualObj, CFX_RectF& rt) {}
60 60
61 int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex, 61 int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex,
62 CFX_RectF& rect, 62 CFX_RectF& rect,
63 FX_BOOL bBBox) const { 63 bool bBBox) const {
64 ASSERT(m_nRefCount > 0); 64 ASSERT(m_nRefCount > 0);
65 ASSERT(nIndex >= 0 && nIndex < m_nCharCount); 65 ASSERT(nIndex >= 0 && nIndex < m_nCharCount);
66 if (m_nRefCount < 1) { 66 if (m_nRefCount < 1) {
67 return 0; 67 return 0;
68 } 68 }
69 int32_t nCount = m_PieceMassArr.GetSize(); 69 int32_t nCount = m_PieceMassArr.GetSize();
70 for (int32_t i = 0; i < nCount; i++) { 70 for (int32_t i = 0; i < nCount; i++) {
71 const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); 71 const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i);
72 if (nIndex >= pPiece->nStart && 72 if (nIndex >= pPiece->nStart &&
73 nIndex < (pPiece->nStart + pPiece->nCount)) { 73 nIndex < (pPiece->nStart + pPiece->nCount)) {
74 CFX_RectFArray rectArr; 74 CFX_RectFArray rectArr;
75 m_pTextSet->GetCharRects(pPiece, rectArr, bBBox); 75 m_pTextSet->GetCharRects(pPiece, rectArr, bBBox);
76 rect = rectArr[nIndex - pPiece->nStart]; 76 rect = rectArr[nIndex - pPiece->nStart];
77 return pPiece->nBidiLevel; 77 return pPiece->nBidiLevel;
78 } 78 }
79 } 79 }
80 ASSERT(0); 80 ASSERT(0);
81 return 0; 81 return 0;
82 } 82 }
83 83
84 int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint, 84 int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint, bool& bBefore) {
85 FX_BOOL& bBefore) { 85 bool bVertical = m_pEditEngine->GetEditParams()->dwLayoutStyles &
86 FX_BOOL bVertical = m_pEditEngine->GetEditParams()->dwLayoutStyles & 86 FDE_TEXTEDITLAYOUT_DocVertical;
87 FDE_TEXTEDITLAYOUT_DocVertical;
88 CFX_PointF ptF = fPoint; 87 CFX_PointF ptF = fPoint;
89 NormalizePt2Rect(ptF, m_rtPageContents, kTolerance); 88 NormalizePt2Rect(ptF, m_rtPageContents, kTolerance);
90 int32_t nCount = m_PieceMassArr.GetSize(); 89 int32_t nCount = m_PieceMassArr.GetSize();
91 CFX_RectF rtLine; 90 CFX_RectF rtLine;
92 int32_t nBgn = 0; 91 int32_t nBgn = 0;
93 int32_t nEnd = 0; 92 int32_t nEnd = 0;
94 FX_BOOL bInLine = FALSE; 93 bool bInLine = false;
95 int32_t i = 0; 94 int32_t i = 0;
96 for (i = 0; i < nCount; i++) { 95 for (i = 0; i < nCount; i++) {
97 const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); 96 const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i);
98 if (!bInLine && (bVertical ? (pPiece->rtPiece.left <= ptF.x && 97 if (!bInLine && (bVertical ? (pPiece->rtPiece.left <= ptF.x &&
99 pPiece->rtPiece.right() > ptF.x) 98 pPiece->rtPiece.right() > ptF.x)
100 : (pPiece->rtPiece.top <= ptF.y && 99 : (pPiece->rtPiece.top <= ptF.y &&
101 pPiece->rtPiece.bottom() > ptF.y))) { 100 pPiece->rtPiece.bottom() > ptF.y))) {
102 nBgn = nEnd = i; 101 nBgn = nEnd = i;
103 rtLine = pPiece->rtPiece; 102 rtLine = pPiece->rtPiece;
104 bInLine = TRUE; 103 bInLine = true;
105 } else if (bInLine) { 104 } else if (bInLine) {
106 if (bVertical ? (!(pPiece->rtPiece.left <= ptF.x && 105 if (bVertical ? (!(pPiece->rtPiece.left <= ptF.x &&
107 pPiece->rtPiece.right() > ptF.x)) 106 pPiece->rtPiece.right() > ptF.x))
108 : (pPiece->rtPiece.bottom() <= ptF.y || 107 : (pPiece->rtPiece.bottom() <= ptF.y ||
109 pPiece->rtPiece.top > ptF.y)) { 108 pPiece->rtPiece.top > ptF.y)) {
110 nEnd = i - 1; 109 nEnd = i - 1;
111 break; 110 break;
112 } else { 111 } else {
113 rtLine.Union(pPiece->rtPiece); 112 rtLine.Union(pPiece->rtPiece);
114 } 113 }
115 } 114 }
116 } 115 }
117 NormalizePt2Rect(ptF, rtLine, kTolerance); 116 NormalizePt2Rect(ptF, rtLine, kTolerance);
118 int32_t nCaret = 0; 117 int32_t nCaret = 0;
119 FDE_TEXTEDITPIECE* pPiece = nullptr; 118 FDE_TEXTEDITPIECE* pPiece = nullptr;
120 for (i = nBgn; i <= nEnd; i++) { 119 for (i = nBgn; i <= nEnd; i++) {
121 pPiece = m_PieceMassArr.GetPtrAt(i); 120 pPiece = m_PieceMassArr.GetPtrAt(i);
122 nCaret = m_nPageStart + pPiece->nStart; 121 nCaret = m_nPageStart + pPiece->nStart;
123 if (pPiece->rtPiece.Contains(ptF)) { 122 if (pPiece->rtPiece.Contains(ptF)) {
124 CFX_RectFArray rectArr; 123 CFX_RectFArray rectArr;
125 m_pTextSet->GetCharRects(pPiece, rectArr, FALSE); 124 m_pTextSet->GetCharRects(pPiece, rectArr, false);
126 int32_t nRtCount = rectArr.GetSize(); 125 int32_t nRtCount = rectArr.GetSize();
127 for (int32_t j = 0; j < nRtCount; j++) { 126 for (int32_t j = 0; j < nRtCount; j++) {
128 if (rectArr[j].Contains(ptF)) { 127 if (rectArr[j].Contains(ptF)) {
129 nCaret = m_nPageStart + pPiece->nStart + j; 128 nCaret = m_nPageStart + pPiece->nStart + j;
130 if (nCaret >= m_pEditEngine->GetTextBufLength()) { 129 if (nCaret >= m_pEditEngine->GetTextBufLength()) {
131 bBefore = TRUE; 130 bBefore = true;
132 return m_pEditEngine->GetTextBufLength(); 131 return m_pEditEngine->GetTextBufLength();
133 } 132 }
134 FX_WCHAR wChar = m_pEditEngine->GetTextBuf()->GetCharByIndex(nCaret); 133 FX_WCHAR wChar = m_pEditEngine->GetTextBuf()->GetCharByIndex(nCaret);
135 if (wChar == L'\n' || wChar == L'\r') { 134 if (wChar == L'\n' || wChar == L'\r') {
136 if (wChar == L'\n') { 135 if (wChar == L'\n') {
137 if (m_pEditEngine->GetTextBuf()->GetCharByIndex(nCaret - 1) == 136 if (m_pEditEngine->GetTextBuf()->GetCharByIndex(nCaret - 1) ==
138 L'\r') { 137 L'\r') {
139 nCaret--; 138 nCaret--;
140 } 139 }
141 } 140 }
142 bBefore = TRUE; 141 bBefore = true;
143 return nCaret; 142 return nCaret;
144 } 143 }
145 if (bVertical 144 if (bVertical
146 ? (ptF.y > ((rectArr[j].top + rectArr[j].bottom()) / 2)) 145 ? (ptF.y > ((rectArr[j].top + rectArr[j].bottom()) / 2))
147 : (ptF.x > ((rectArr[j].left + rectArr[j].right()) / 2))) { 146 : (ptF.x > ((rectArr[j].left + rectArr[j].right()) / 2))) {
148 bBefore = FX_IsOdd(pPiece->nBidiLevel); 147 bBefore = FX_IsOdd(pPiece->nBidiLevel);
149 } else { 148 } else {
150 bBefore = !FX_IsOdd(pPiece->nBidiLevel); 149 bBefore = !FX_IsOdd(pPiece->nBidiLevel);
151 } 150 }
152 return nCaret; 151 return nCaret;
153 } 152 }
154 } 153 }
155 } 154 }
156 } 155 }
157 bBefore = TRUE; 156 bBefore = true;
158 return nCaret; 157 return nCaret;
159 } 158 }
160 159
161 int32_t CFDE_TxtEdtPage::GetCharStart() const { 160 int32_t CFDE_TxtEdtPage::GetCharStart() const {
162 return m_nPageStart; 161 return m_nPageStart;
163 } 162 }
164 163
165 int32_t CFDE_TxtEdtPage::GetCharCount() const { 164 int32_t CFDE_TxtEdtPage::GetCharCount() const {
166 return m_nCharCount; 165 return m_nCharCount;
167 } 166 }
168 167
169 int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip, 168 int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip,
170 FXTEXT_CHARPOS*& pCharPos, 169 FXTEXT_CHARPOS*& pCharPos,
171 CFX_RectF* pBBox) const { 170 CFX_RectF* pBBox) const {
172 pCharPos = FX_Alloc(FXTEXT_CHARPOS, m_nCharCount); 171 pCharPos = FX_Alloc(FXTEXT_CHARPOS, m_nCharCount);
173 int32_t nCharPosCount = 0; 172 int32_t nCharPosCount = 0;
174 FDE_TEXTEDITPIECE* pPiece = nullptr; 173 FDE_TEXTEDITPIECE* pPiece = nullptr;
175 int32_t nVisualObjCount = m_PieceMassArr.GetSize(); 174 int32_t nVisualObjCount = m_PieceMassArr.GetSize();
176 FXTEXT_CHARPOS* pos = pCharPos; 175 FXTEXT_CHARPOS* pos = pCharPos;
177 CFX_RectF rtObj; 176 CFX_RectF rtObj;
178 for (int32_t i = 0; i < nVisualObjCount; i++) { 177 for (int32_t i = 0; i < nVisualObjCount; i++) {
179 pPiece = m_PieceMassArr.GetPtrAt(i); 178 pPiece = m_PieceMassArr.GetPtrAt(i);
180 m_pTextSet->GetRect(pPiece, rtObj); 179 m_pTextSet->GetRect(pPiece, rtObj);
181 if (!rtClip.IntersectWith(rtObj)) { 180 if (!rtClip.IntersectWith(rtObj)) {
182 continue; 181 continue;
183 } 182 }
184 int32_t nCount = m_pTextSet->GetDisplayPos(pPiece, pos, FALSE); 183 int32_t nCount = m_pTextSet->GetDisplayPos(pPiece, pos, false);
185 nCharPosCount += nCount; 184 nCharPosCount += nCount;
186 pos += nCount; 185 pos += nCount;
187 } 186 }
188 if ((nCharPosCount * 5) < (m_nCharCount << 2)) { 187 if ((nCharPosCount * 5) < (m_nCharCount << 2)) {
189 FXTEXT_CHARPOS* pTemp = FX_Alloc(FXTEXT_CHARPOS, nCharPosCount); 188 FXTEXT_CHARPOS* pTemp = FX_Alloc(FXTEXT_CHARPOS, nCharPosCount);
190 FXSYS_memcpy(pTemp, pCharPos, sizeof(FXTEXT_CHARPOS) * nCharPosCount); 189 FXSYS_memcpy(pTemp, pCharPos, sizeof(FXTEXT_CHARPOS) * nCharPosCount);
191 FX_Free(pCharPos); 190 FX_Free(pCharPos);
192 pCharPos = pTemp; 191 pCharPos = pTemp;
193 } 192 }
194 return nCharPosCount; 193 return nCharPosCount;
195 } 194 }
196 195
197 void CFDE_TxtEdtPage::CalcRangeRectArray(int32_t nStart, 196 void CFDE_TxtEdtPage::CalcRangeRectArray(int32_t nStart,
198 int32_t nCount, 197 int32_t nCount,
199 CFX_RectFArray& RectFArr) const { 198 CFX_RectFArray& RectFArr) const {
200 int32_t nPieceCount = m_PieceMassArr.GetSize(); 199 int32_t nPieceCount = m_PieceMassArr.GetSize();
201 int32_t nEnd = nStart + nCount - 1; 200 int32_t nEnd = nStart + nCount - 1;
202 FX_BOOL bInRange = FALSE; 201 bool bInRange = false;
203 for (int32_t i = 0; i < nPieceCount; i++) { 202 for (int32_t i = 0; i < nPieceCount; i++) {
204 FDE_TEXTEDITPIECE* piece = m_PieceMassArr.GetPtrAt(i); 203 FDE_TEXTEDITPIECE* piece = m_PieceMassArr.GetPtrAt(i);
205 if (!bInRange) { 204 if (!bInRange) {
206 if (nStart >= piece->nStart && nStart < (piece->nStart + piece->nCount)) { 205 if (nStart >= piece->nStart && nStart < (piece->nStart + piece->nCount)) {
207 int32_t nRangeEnd = piece->nCount - 1; 206 int32_t nRangeEnd = piece->nCount - 1;
208 FX_BOOL bEnd = FALSE; 207 bool bEnd = false;
209 if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) { 208 if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) {
210 nRangeEnd = nEnd - piece->nStart; 209 nRangeEnd = nEnd - piece->nStart;
211 bEnd = TRUE; 210 bEnd = true;
212 } 211 }
213 CFX_RectFArray rcArr; 212 CFX_RectFArray rcArr;
214 m_pTextSet->GetCharRects(piece, rcArr, FALSE); 213 m_pTextSet->GetCharRects(piece, rcArr, false);
215 CFX_RectF rectPiece = rcArr[nStart - piece->nStart]; 214 CFX_RectF rectPiece = rcArr[nStart - piece->nStart];
216 rectPiece.Union(rcArr[nRangeEnd]); 215 rectPiece.Union(rcArr[nRangeEnd]);
217 RectFArr.Add(rectPiece); 216 RectFArr.Add(rectPiece);
218 if (bEnd) { 217 if (bEnd) {
219 return; 218 return;
220 } 219 }
221 bInRange = TRUE; 220 bInRange = true;
222 } 221 }
223 } else { 222 } else {
224 if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) { 223 if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) {
225 CFX_RectFArray rcArr; 224 CFX_RectFArray rcArr;
226 m_pTextSet->GetCharRects(piece, rcArr, FALSE); 225 m_pTextSet->GetCharRects(piece, rcArr, false);
227 CFX_RectF rectPiece = rcArr[0]; 226 CFX_RectF rectPiece = rcArr[0];
228 rectPiece.Union(rcArr[nEnd - piece->nStart]); 227 rectPiece.Union(rcArr[nEnd - piece->nStart]);
229 RectFArr.Add(rectPiece); 228 RectFArr.Add(rectPiece);
230 return; 229 return;
231 } 230 }
232 RectFArr.Add(piece->rtPiece); 231 RectFArr.Add(piece->rtPiece);
233 } 232 }
234 } 233 }
235 } 234 }
236 235
237 int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) { 236 int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) {
238 if (m_nRefCount < 0) { 237 if (m_nRefCount < 0) {
239 return -1; 238 return -1;
240 } 239 }
241 CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); 240 CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf();
242 FX_BOOL bBefore; 241 bool bBefore;
243 int32_t nIndex = GetCharIndex(fPoint, bBefore); 242 int32_t nIndex = GetCharIndex(fPoint, bBefore);
244 if (nIndex == m_pEditEngine->GetTextBufLength()) { 243 if (nIndex == m_pEditEngine->GetTextBufLength()) {
245 nIndex = m_pEditEngine->GetTextBufLength() - 1; 244 nIndex = m_pEditEngine->GetTextBufLength() - 1;
246 } 245 }
247 if (nIndex < 0) { 246 if (nIndex < 0) {
248 return -1; 247 return -1;
249 } 248 }
250 std::unique_ptr<CFX_WordBreak> pIter(new CFX_WordBreak); 249 std::unique_ptr<CFX_WordBreak> pIter(new CFX_WordBreak);
251 pIter->Attach(new CFDE_TxtEdtBufIter(pBuf)); 250 pIter->Attach(new CFDE_TxtEdtBufIter(pBuf));
252 pIter->SetAt(nIndex); 251 pIter->SetAt(nIndex);
253 nCount = pIter->GetWordLength(); 252 nCount = pIter->GetWordLength();
254 return pIter->GetWordPos(); 253 return pIter->GetWordPos();
255 } 254 }
256 255
257 FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) { 256 bool CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) {
258 return m_bLoaded; 257 return m_bLoaded;
259 } 258 }
260 259
261 int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, 260 int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
262 IFX_Pause* pPause) { 261 IFX_Pause* pPause) {
263 if (m_nRefCount > 0) { 262 if (m_nRefCount > 0) {
264 m_nRefCount++; 263 m_nRefCount++;
265 return m_nRefCount; 264 return m_nRefCount;
266 } 265 }
267 CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); 266 CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf();
(...skipping 18 matching lines...) Expand all
286 static_cast<CFDE_TxtEdtParag*>(m_pEditEngine->GetParag(nBgnParag)); 285 static_cast<CFDE_TxtEdtParag*>(m_pEditEngine->GetParag(nBgnParag));
287 m_pBgnParag->LoadParag(); 286 m_pBgnParag->LoadParag();
288 m_pBgnParag->GetLineRange(nStartLine - nStartLineInParag, nPageStart, nTemp); 287 m_pBgnParag->GetLineRange(nStartLine - nStartLineInParag, nPageStart, nTemp);
289 nEndParag = m_pEditEngine->Line2Parag(nBgnParag, nStartLineInParag, nEndLine, 288 nEndParag = m_pEditEngine->Line2Parag(nBgnParag, nStartLineInParag, nEndLine,
290 nEndLineInParag); 289 nEndLineInParag);
291 m_pEndParag = 290 m_pEndParag =
292 static_cast<CFDE_TxtEdtParag*>(m_pEditEngine->GetParag(nEndParag)); 291 static_cast<CFDE_TxtEdtParag*>(m_pEditEngine->GetParag(nEndParag));
293 m_pEndParag->LoadParag(); 292 m_pEndParag->LoadParag();
294 m_pEndParag->GetLineRange(nEndLine - nEndLineInParag, nPageEnd, nTemp); 293 m_pEndParag->GetLineRange(nEndLine - nEndLineInParag, nPageEnd, nTemp);
295 nPageEnd += (nTemp - 1); 294 nPageEnd += (nTemp - 1);
296 FX_BOOL bVertial = pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical; 295 bool bVertial = pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical;
297 FX_BOOL bLineReserve = 296 bool bLineReserve =
298 !!(pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve); 297 !!(pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve);
299 FX_FLOAT fLineStart = 298 FX_FLOAT fLineStart =
300 bVertial 299 bVertial
301 ? (bLineReserve ? (pParams->fPlateWidth - pParams->fLineSpace) : 0.0f) 300 ? (bLineReserve ? (pParams->fPlateWidth - pParams->fLineSpace) : 0.0f)
302 : 0.0f; 301 : 0.0f;
303 FX_FLOAT fLineStep = 302 FX_FLOAT fLineStep =
304 (bVertial && bLineReserve) ? (-pParams->fLineSpace) : pParams->fLineSpace; 303 (bVertial && bLineReserve) ? (-pParams->fLineSpace) : pParams->fLineSpace;
305 FX_FLOAT fLinePos = fLineStart; 304 FX_FLOAT fLinePos = fLineStart;
306 if (!m_pTextSet) 305 if (!m_pTextSet)
307 m_pTextSet.reset(new CFDE_TxtEdtTextSet(this)); 306 m_pTextSet.reset(new CFDE_TxtEdtTextSet(this));
308 307
309 m_PieceMassArr.RemoveAll(TRUE); 308 m_PieceMassArr.RemoveAll(true);
310 uint32_t dwBreakStatus = FX_TXTBREAK_None; 309 uint32_t dwBreakStatus = FX_TXTBREAK_None;
311 int32_t nPieceStart = 0; 310 int32_t nPieceStart = 0;
312 311
313 m_CharWidths.resize(nPageEnd - nPageStart + 1, 0); 312 m_CharWidths.resize(nPageEnd - nPageStart + 1, 0);
314 pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); 313 pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
315 pBreak->ClearBreakPieces(); 314 pBreak->ClearBreakPieces();
316 m_nPageStart = nPageStart; 315 m_nPageStart = nPageStart;
317 m_nCharCount = nPageEnd - nPageStart + 1; 316 m_nCharCount = nPageEnd - nPageStart + 1;
318 FX_BOOL bReload = FALSE; 317 bool bReload = false;
319 FX_FLOAT fDefCharWidth = 0; 318 FX_FLOAT fDefCharWidth = 0;
320 std::unique_ptr<IFX_CharIter> pIter(m_pIter->Clone()); 319 std::unique_ptr<IFX_CharIter> pIter(m_pIter->Clone());
321 pIter->SetAt(nPageStart); 320 pIter->SetAt(nPageStart);
322 m_pIter->SetAt(nPageStart); 321 m_pIter->SetAt(nPageStart);
323 FX_BOOL bFirstPiece = TRUE; 322 bool bFirstPiece = true;
324 do { 323 do {
325 if (bReload) { 324 if (bReload) {
326 dwBreakStatus = pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); 325 dwBreakStatus = pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
327 } else { 326 } else {
328 FX_WCHAR wAppend = pIter->GetChar(); 327 FX_WCHAR wAppend = pIter->GetChar();
329 dwBreakStatus = pBreak->AppendChar(wAppend); 328 dwBreakStatus = pBreak->AppendChar(wAppend);
330 } 329 }
331 if (pIter->GetAt() == nPageEnd && dwBreakStatus < FX_TXTBREAK_LineBreak) { 330 if (pIter->GetAt() == nPageEnd && dwBreakStatus < FX_TXTBREAK_LineBreak) {
332 dwBreakStatus = pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); 331 dwBreakStatus = pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
333 } 332 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 (FX_FLOAT)pPiece->m_iWidth / 20000.0f + fParaBreakWidth; 373 (FX_FLOAT)pPiece->m_iWidth / 20000.0f + fParaBreakWidth;
375 } else { 374 } else {
376 TxtEdtPiece.rtPiece.left = (FX_FLOAT)pPiece->m_iStartPos / 20000.0f; 375 TxtEdtPiece.rtPiece.left = (FX_FLOAT)pPiece->m_iStartPos / 20000.0f;
377 TxtEdtPiece.rtPiece.top = fLinePos; 376 TxtEdtPiece.rtPiece.top = fLinePos;
378 TxtEdtPiece.rtPiece.width = 377 TxtEdtPiece.rtPiece.width =
379 (FX_FLOAT)pPiece->m_iWidth / 20000.0f + fParaBreakWidth; 378 (FX_FLOAT)pPiece->m_iWidth / 20000.0f + fParaBreakWidth;
380 TxtEdtPiece.rtPiece.height = pParams->fLineSpace; 379 TxtEdtPiece.rtPiece.height = pParams->fLineSpace;
381 } 380 }
382 if (bFirstPiece) { 381 if (bFirstPiece) {
383 m_rtPageContents = TxtEdtPiece.rtPiece; 382 m_rtPageContents = TxtEdtPiece.rtPiece;
384 bFirstPiece = FALSE; 383 bFirstPiece = false;
385 } else { 384 } else {
386 m_rtPageContents.Union(TxtEdtPiece.rtPiece); 385 m_rtPageContents.Union(TxtEdtPiece.rtPiece);
387 } 386 }
388 nPieceStart += TxtEdtPiece.nCount; 387 nPieceStart += TxtEdtPiece.nCount;
389 m_PieceMassArr.Add(TxtEdtPiece); 388 m_PieceMassArr.Add(TxtEdtPiece);
390 for (int32_t k = 0; k < TxtEdtPiece.nCount; k++) { 389 for (int32_t k = 0; k < TxtEdtPiece.nCount; k++) {
391 CFX_Char* ptc = pPiece->GetCharPtr(k); 390 CFX_Char* ptc = pPiece->GetCharPtr(k);
392 m_CharWidths[TxtEdtPiece.nStart + k] = ptc->m_iCharWidth; 391 m_CharWidths[TxtEdtPiece.nStart + k] = ptc->m_iCharWidth;
393 } 392 }
394 } 393 }
395 fLinePos += fLineStep; 394 fLinePos += fLineStep;
396 pBreak->ClearBreakPieces(); 395 pBreak->ClearBreakPieces();
397 } 396 }
398 if (pIter->GetAt() == nPageEnd && dwBreakStatus == FX_TXTBREAK_LineBreak) { 397 if (pIter->GetAt() == nPageEnd && dwBreakStatus == FX_TXTBREAK_LineBreak) {
399 bReload = TRUE; 398 bReload = true;
400 pIter->Next(TRUE); 399 pIter->Next(true);
401 } 400 }
402 } while (pIter->Next(FALSE) && (pIter->GetAt() <= nPageEnd)); 401 } while (pIter->Next(false) && (pIter->GetAt() <= nPageEnd));
403 if (m_rtPageContents.left != 0) { 402 if (m_rtPageContents.left != 0) {
404 FX_FLOAT fDelta = 0.0f; 403 FX_FLOAT fDelta = 0.0f;
405 if (m_rtPageContents.width < pParams->fPlateWidth) { 404 if (m_rtPageContents.width < pParams->fPlateWidth) {
406 if (pParams->dwAlignment & FDE_TEXTEDITALIGN_Right) { 405 if (pParams->dwAlignment & FDE_TEXTEDITALIGN_Right) {
407 fDelta = pParams->fPlateWidth - m_rtPageContents.width; 406 fDelta = pParams->fPlateWidth - m_rtPageContents.width;
408 } else if (pParams->dwAlignment & FDE_TEXTEDITALIGN_Center) { 407 } else if (pParams->dwAlignment & FDE_TEXTEDITALIGN_Center) {
409 if ((pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) && 408 if ((pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) &&
410 m_nCharCount > 1) { 409 m_nCharCount > 1) {
411 int32_t nCount = m_nCharCount - 1; 410 int32_t nCount = m_nCharCount - 1;
412 int32_t n = (m_pEditEngine->m_nLimit - nCount) / 2; 411 int32_t n = (m_pEditEngine->m_nLimit - nCount) / 2;
(...skipping 12 matching lines...) Expand all
425 m_rtPageContents.Offset(-fOffset, 0.0f); 424 m_rtPageContents.Offset(-fOffset, 0.0f);
426 } 425 }
427 if (m_pEditEngine->GetEditParams()->dwLayoutStyles & 426 if (m_pEditEngine->GetEditParams()->dwLayoutStyles &
428 FDE_TEXTEDITLAYOUT_LastLineHeight) { 427 FDE_TEXTEDITLAYOUT_LastLineHeight) {
429 m_rtPageContents.height -= pParams->fLineSpace - pParams->fFontSize; 428 m_rtPageContents.height -= pParams->fLineSpace - pParams->fFontSize;
430 int32_t nCount = m_PieceMassArr.GetSize(); 429 int32_t nCount = m_PieceMassArr.GetSize();
431 FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(nCount - 1); 430 FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(nCount - 1);
432 pPiece->rtPiece.height = pParams->fFontSize; 431 pPiece->rtPiece.height = pParams->fFontSize;
433 } 432 }
434 m_nRefCount = 1; 433 m_nRefCount = 1;
435 m_bLoaded = TRUE; 434 m_bLoaded = true;
436 return 0; 435 return 0;
437 } 436 }
438 437
439 void CFDE_TxtEdtPage::UnloadPage(const CFX_RectF* pClipBox) { 438 void CFDE_TxtEdtPage::UnloadPage(const CFX_RectF* pClipBox) {
440 ASSERT(m_nRefCount > 0); 439 ASSERT(m_nRefCount > 0);
441 m_nRefCount--; 440 m_nRefCount--;
442 if (m_nRefCount != 0) 441 if (m_nRefCount != 0)
443 return; 442 return;
444 443
445 m_PieceMassArr.RemoveAll(FALSE); 444 m_PieceMassArr.RemoveAll(false);
446 m_pTextSet.reset(); 445 m_pTextSet.reset();
447 m_CharWidths.clear(); 446 m_CharWidths.clear();
448 if (m_pBgnParag) { 447 if (m_pBgnParag) {
449 m_pBgnParag->UnloadParag(); 448 m_pBgnParag->UnloadParag();
450 m_pBgnParag = nullptr; 449 m_pBgnParag = nullptr;
451 } 450 }
452 if (m_pEndParag) { 451 if (m_pEndParag) {
453 m_pEndParag->UnloadParag(); 452 m_pEndParag->UnloadParag();
454 m_pEndParag = nullptr; 453 m_pEndParag = nullptr;
455 } 454 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 ptF.x = rtF.left; 508 ptF.x = rtF.left;
510 } else if (ptF.x >= rtF.right()) { 509 } else if (ptF.x >= rtF.right()) {
511 ptF.x = rtF.right() - fTolerance; 510 ptF.x = rtF.right() - fTolerance;
512 } 511 }
513 if (ptF.y < rtF.top) { 512 if (ptF.y < rtF.top) {
514 ptF.y = rtF.top; 513 ptF.y = rtF.top;
515 } else if (ptF.y >= rtF.bottom()) { 514 } else if (ptF.y >= rtF.bottom()) {
516 ptF.y = rtF.bottom() - fTolerance; 515 ptF.y = rtF.bottom() - fTolerance;
517 } 516 }
518 } 517 }
OLDNEW
« no previous file with comments | « xfa/fde/cfde_txtedtpage.h ('k') | xfa/fde/cfde_txtedtparag.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698